Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/old.bezierTrack/gui/orxonox_gui.h @ 3715

Last change on this file since 3715 was 2740, checked in by bensch, 20 years ago

orxonox/trunk/gui: now Building a Window-Chain

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