Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk/gui: added Version number to the GUI.

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 <string.h>
15#include <gtk/gtkmain.h>
16#include <gtk/gtkwindow.h>
17#include <gtk/gtkframe.h>
18#include <gtk/gtkhbox.h>
19#include <gtk/gtkvbox.h>
20#include <gtk/gtkbutton.h>
21#include <gtk/gtkcheckbutton.h>
22#include <gtk/gtkhscale.h>
23#include <gtk/gtkoptionmenu.h>
24#include <gtk/gtkmenu.h>
25#include <gtk/gtkmenuitem.h>
26#include <gtk/gtklabel.h>
27#include <gtk/gtkimage.h>
28#include <gtk/gtkeventbox.h>
29
30//! Class that creates the OrxonoxGui
31class OrxonoxGui
32{
33 public:
34  OrxonoxGui (int argc, char *argv[]);
35  ~OrxonoxGui ();
36
37};
38
39//! This is the topmost object that can be displayed all others are derived from it.
40
41class Widget
42{
43 private:
44 public:
45  ~Widget ();
46
47  Widget* next; //!< next always points to the next Widget in the list. Every Widget has a next one, or has NULL as next
48  GtkWidget* widget; //!< widget is the gtk_widget that the specific Object Contains.
49  virtual void init(void);
50  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
51  /**
52     \briefdefines is_option states
53  */
54  enum option { containerType = -2, boxType = -1, nothingType = 0, boolType = 1, intType = 2}; 
55  char* label; //!< The name of the Widget. Some do display it, Options need it to save;
56  void connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *));
57  void connectSignal (char* event, gint (*signal)(GtkWidget*, Widget *));
58  void connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEvent*, void *));
59  void show ();
60  void hide ();
61  void setSize(int width, int height);
62
63  void walkThrough (void (*function)(Widget*));
64  static void listOptions (Widget* widget);
65  static void setOptions (Widget* widget);
66
67};
68
69//! This is a Packer Object, which has the ability to Pack other Widgets into itself.
70class Packer : public Widget
71{
72 public:
73  Widget* down; //!< this points to the Widget below this.
74  char* groupName; //!< For each Packer you can specify a Groupname under which the lowerWidgets will be saved.
75
76  void init(void);
77  void setGroupName (char* name);
78  char* getGroupName (void);
79};
80
81//! This is a Container Class, it can contain one sub-Widget: down.
82/**
83 * A Container is a Widget that can hold a subWidget in addition to a next-Widget.
84 * The Container can by itself not be displayed created or used.
85 * The derived classes of Container can be displayed
86*/
87class Container : public Packer
88{
89 private:
90  int borderwidth;
91  int policy;
92 
93 public:
94  void init(void);
95  //  void setBorderWidth (int borderwidth);
96  //  virtual void setTitle (char* title) = 0;
97  void fill (Widget *lowerWidget);
98};
99
100//! Window is the class that creates new Windows, and handels them
101/**
102 * A Window is a class derived from Container that contains a window-widget.
103 * It has the ability to hold one sub-object
104 */
105class Window : public Container
106{
107 private:
108  bool isOpen;
109 public:
110  Window (char* windowName);
111  Window (void);
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
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.