Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/gui/orxonox_gui.h @ 2617

Last change on this file since 2617 was 2614, checked in by bensch, 20 years ago

orxonox/trunk/gui: added simple config-file stuffing. (only save needs it now, load still has to do it)

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