Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk/gui: modified savable rutine. now a widget has to be set saveable, otherwise it won't be saved

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  Window (char* windowName);
110  Window (void);
111  void init ();
112 
113  void setTitle (char* title);
114  void showall (); 
115  static gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data);
116};
117
118//! Frame is the class that handles frames
119/**
120 * A Frame is an object, that has a border and if you like a name on it.
121 * It can contain a Widget, which means that you can insert anything you like inside of a frame
122 */
123class Frame :public Container
124{
125 public:
126  Frame (char* frameName);
127  Frame (void);
128  void init(void);
129 
130  void setTitle (char* title);
131};
132
133//! EventBox is a Container that can Handle all Events happening inside of it.
134/**
135 * Example: if you have a picture, and you want it to catch mouse-clicks, you have to pack it inside a EventBox
136 */
137class EventBox : public Container
138{
139 public:
140  EventBox (char* eventBoxName);
141  EventBox (void);
142  void init(void);
143 
144  void setTitle (char* title);
145};
146
147//! A Box can contain multiple Widgets
148/**
149 * A Box can Contain multiple Widgets, that are ordered either horizontally or vertically
150 * I defined the standartbox to be horizontally.
151 * A Box is always filled left->right (horizontally) or up->down (vertically)
152 */
153class Box : public Packer
154{
155 public:
156  Box (void);
157  Box (char boxtype);
158  void init(char boxtype);
159
160  void fill (Widget* lowerWidget);
161
162};
163
164//! Image is the keeper of one Image
165/**
166 * Images are mighty cool.
167 * Images can help you lighten up the Programming process, and will give everyone a better impression of the Software.
168 */
169class Image : public Widget
170{
171 public:
172  Image (char* imgaename);
173  void init(void);
174};
175
176//! An Option is a Widget that contains something that may change its state.
177/**
178 * Options are the essence of a GUI, they: Configure, Start, Quit, Execute, and make it worth something
179 */
180class Option : public Widget
181{
182 public:
183  //virtual gint OptionChange (GtkWidget *widget, GdkEvent *event, gpointer data);
184  void init(void);
185
186  int value; //!< every option has a value either true or false (0,1) or something else like 25 for 25% of the volume
187  char* flag_name; //!< options have a flag name that will be appendet if you start the Program from the GUI.
188  char* flag_name_short; //!< like flag_name but shorter
189  int default_value; //!< A default value is good, for hiding a option if it is not needed. (hidden if value == default_value)
190  bool saveable;
191
192  void setFlagName (char* flagname, int defaultvalue);
193  void setFlagName (char* flagname, char* flagnameshort, int defaultvalue);
194  virtual void redraw () = 0; //!< A Option must be able to redraw itself.
195};
196
197//! Buttons can be pressed, and released.
198/**
199 * Buttons are mainly there for executing some action like Starting the Programm, or Quiting it.
200 */
201class Button : public Option
202{
203 public:
204  Button (char* buttonname);
205  void init(void);
206
207  void setTitle(char* title);
208 
209  void redraw();
210};
211
212//! CheckButtons are a key in configuring bool Variables
213/** CheckButtons can configure bool Variables like wireframe on/off, enable_sound etc.
214 */
215class CheckButton : public Option
216{
217 public:
218  CheckButton (char* buttonname);
219  static gint OptionChange (GtkWidget* widget, Widget* checkbutton);
220 
221  void init(void);
222  void setTitle(char* title);
223
224  void redraw ();
225};
226
227//! Sliders are Options that can be modified in their value
228/**
229 * good for volume, brightness, etc.
230 */
231class Slider : public Option
232{
233 public:
234  Slider (char* slidername,int start, int end);
235  void init(int start, int end);
236
237  void setTitle(char* title);
238  void setValue(int value);
239
240  static gint OptionChange (GtkWidget* widget, Widget* slider);
241  void redraw();
242};
243
244//! A Menu is an Option that has a dropdown menu, where you can chose between different Items
245class Menu : public Option
246{
247 private:
248  GtkWidget* menu;
249  GtkWidget* item;
250  va_list itemlist;
251 
252 public:
253  Menu (char* menuname, ...);
254  void init(void);
255
256  void setTitle(char* title);
257
258  void addItem(char* itemName);
259  static gint OptionChange (GtkWidget* widget, Widget* menu);
260  void redraw();
261};
262
263//! A label is a Widget, that displays a text
264class Label : public Widget
265{
266 public:
267  Label ();
268  Label (char* text);
269  void init(void);
270 
271  void setText (char* text);
272  char* getText ();
273};
274
275//gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data);
276
277#endif /* _ORXONOX_GUI_H */
Note: See TracBrowser for help on using the repository browser.