Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/sound/gui/orxonox_gui.h @ 3456

Last change on this file since 3456 was 2635, checked in by bensch, 20 years ago

orxonox/trunk/gui: minor fix

File size: 7.2 KB
Line 
1/*!
2 \file orxonox_gui.h
3 \brief Contains all Widgets and the Creation of the Gui
4*/
5
6#ifndef _ORXONOX_GUI_H
7#define _ORXONOX_GUI_H
8
9#if HAVE_CONFIG_H
10#include <config.h> 
11#endif
12
13#include <stdlib.h>
14#include <gtk/gtkmain.h>
15#include <gtk/gtkwindow.h>
16#include <gtk/gtkframe.h>
17#include <gtk/gtkhbox.h>
18#include <gtk/gtkvbox.h>
19#include <gtk/gtkbutton.h>
20#include <gtk/gtkcheckbutton.h>
21#include <gtk/gtkhscale.h>
22#include <gtk/gtkoptionmenu.h>
23#include <gtk/gtkmenu.h>
24#include <gtk/gtkmenuitem.h>
25#include <gtk/gtklabel.h>
26#include <gtk/gtkimage.h>
27#include <gtk/gtkeventbox.h>
28
29//! Class that creates the OrxonoxGui
30class OrxonoxGui
31{
32 public:
33  OrxonoxGui (int argc, char *argv[]);
34  ~OrxonoxGui ();
35
36};
37
38//! This is the topmost object that can be displayed all others are derived from it.
39class Widget
40{
41 private:
42 public:
43  ~Widget ();
44
45  Widget* next; //!< next always points to the next Widget in the list. Every Widget has a next one, or has NULL as next
46  GtkWidget* widget; //!< widget is the gtk_widget that the specific Object Contains.
47  void init(void);
48  int is_option; //!< with this Paramenter one can set the IsOption type: -2:Container, -1: Box, 0: not an Option, 1: Bool-option, 2: int-option
49  /**
50     \briefdefines is_option states
51  */
52  enum option { containerType = -2, boxType = -1, nothingType = 0, boolType = 1, intType = 2}; 
53  char* label; //!< The name of the Widget. Some do display it, Options need it to save;
54  void connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *));
55  void connectSignal (char* event, gint (*signal)(GtkWidget*, Widget *));
56  void connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEvent*, void *));
57  void show ();
58  void hide ();
59  void setSize(int width, int height);
60
61  void walkThrough (void (*function)(Widget*));
62  static void listOptions (Widget* widget);
63  static void setOptions (Widget* widget);
64
65};
66
67//! This is a Packer Object, which has the ability to Pack other Widgets into itself.
68class Packer : public Widget
69{
70 public:
71  Widget* down; //!< this points to the Widget below this.
72  char* groupName; //!< For each Packer you can specify a Groupname under which the lowerWidgets will be saved.
73
74  void init(void);
75  void setGroupName (char* name);
76  char* getGroupName (void);
77};
78
79//! This is a Container Class, it can contain one sub-Widget: down.
80/**
81 * A Container is a Widget that can hold a subWidget in addition to a next-Widget.
82 * The Container can by itself not be displayed created or used.
83 * The derived classes of Container can be displayed
84*/
85class Container : public Packer
86{
87 private:
88  int borderwidth;
89  int policy;
90 
91 public:
92  void init(void);
93  //  void setBorderWidth (int borderwidth);
94  //  virtual void setTitle (char* title) = 0;
95  void fill (Widget *lowerWidget);
96};
97
98//! Window is the class that creates new Windows, and handels them
99/**
100 * A Window is a class derived from Container that contains a window-widget.
101 * It has the ability to hold one sub-object
102 */
103class Window : public Container
104{
105 private:
106  bool isOpen;
107 public:
108  Window (char* windowName);
109  Window (void);
110  void init ();
111 
112  void setTitle (char* title);
113  void showall (); 
114  static gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data);
115};
116
117//! Frame is the class that handles frames
118/**
119 * A Frame is an object, that has a border and if you like a name on it.
120 * It can contain a Widget, which means that you can insert anything you like inside of a frame
121 */
122class Frame :public Container
123{
124 public:
125  Frame (char* frameName);
126  Frame (void);
127  void init(void);
128 
129  void setTitle (char* title);
130};
131
132//! EventBox is a Container that can Handle all Events happening inside of it.
133/**
134 * Example: if you have a picture, and you want it to catch mouse-clicks, you have to pack it inside a EventBox
135 */
136class EventBox : public Container
137{
138 public:
139  EventBox (char* eventBoxName);
140  EventBox (void);
141  void init(void);
142 
143  void setTitle (char* title);
144};
145
146//! A Box can contain multiple Widgets
147/**
148 * A Box can Contain multiple Widgets, that are ordered either horizontally or vertically
149 * I defined the standartbox to be horizontally.
150 * A Box is always filled left->right (horizontally) or up->down (vertically)
151 */
152class Box : public Packer
153{
154 public:
155  Box (void);
156  Box (char boxtype);
157  void init(char boxtype);
158
159  void fill (Widget* lowerWidget);
160
161};
162
163//! Image is the keeper of one Image
164/**
165 * Images are mighty cool.
166 * Images can help you lighten up the Programming process, and will give everyone a better impression of the Software.
167 */
168class Image : public Widget
169{
170 public:
171  Image (char* imgaename);
172  void init(void);
173};
174
175//! An Option is a Widget that contains something that may change its state.
176/**
177 * Options are the essence of a GUI, they: Configure, Start, Quit, Execute, and make it worth something
178 */
179class Option : public Widget
180{
181 public:
182  //virtual gint OptionChange (GtkWidget *widget, GdkEvent *event, gpointer data);
183  void init(void);
184
185  int value; //!< every option has a value either true or false (0,1) or something else like 25 for 25% of the volume
186  char* flag_name; //!< options have a flag name that will be appendet if you start the Program from the GUI.
187  char* flag_name_short; //!< like flag_name but shorter
188  int default_value; //!< A default value is good, for hiding a option if it is not needed. (hidden if value == default_value)
189
190  void setFlagName (char* flagname, int defaultvalue);
191  void setFlagName (char* flagname, char* flagnameshort, int defaultvalue);
192  virtual void redraw () = 0; //!< A Option must be able to redraw itself.
193};
194
195//! Buttons can be pressed, and released.
196/**
197 * Buttons are mainly there for executing some action like Starting the Programm, or Quiting it.
198 */
199class Button : public Option
200{
201 public:
202  Button (char* buttonname);
203  void init(void);
204
205  void setTitle(char* title);
206 
207  void redraw();
208};
209
210//! CheckButtons are a key in configuring bool Variables
211/** CheckButtons can configure bool Variables like wireframe on/off, enable_sound etc.
212 */
213class CheckButton : public Option
214{
215 public:
216  CheckButton (char* buttonname);
217  static gint OptionChange (GtkWidget* widget, Widget* checkbutton);
218 
219  void init(void);
220  void setTitle(char* title);
221
222  void redraw ();
223};
224
225//! Sliders are Options that can be modified in their value
226/**
227 * good for volume, brightness, etc.
228 */
229class Slider : public Option
230{
231 public:
232  Slider (char* slidername,int start, int end);
233  void init(int start, int end);
234
235  void setTitle(char* title);
236  void setValue(int value);
237
238  static gint OptionChange (GtkWidget* widget, Widget* slider);
239  void redraw();
240};
241
242//! A Menu is an Option that has a dropdown menu, where you can chose between different Items
243class Menu : public Option
244{
245 private:
246  GtkWidget* menu;
247  GtkWidget* item;
248  va_list itemlist;
249 
250 public:
251  Menu (char* menuname, ...);
252  void init(void);
253
254  void setTitle(char* title);
255
256  void addItem(char* itemName);
257  static gint OptionChange (GtkWidget* widget, Widget* menu);
258  void redraw();
259};
260
261//! A label is a Widget, that displays a text
262class Label : public Widget
263{
264 public:
265  Label ();
266  Label (char* text);
267  void init(void);
268 
269  void setText (char * text);
270  char* getText ();
271};
272
273//gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data);
274
275#endif /* _ORXONOX_GUI_H */
Note: See TracBrowser for help on using the repository browser.