Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/gui/orxonox_gui_gtk.h @ 3165

Last change on this file since 3165 was 3165, checked in by bensch, 19 years ago

orxonox/trunk/gui: compiling as not-GTK possibe, but it is not usable yet

File size: 8.4 KB
Line 
1/*!
2 \file orxonox_gui_gtk.h
3 \brief Contains all th different Widgets.
4*/
5
6#ifndef _ORXONOX_GUI_GTK_H
7#define _ORXONOX_GUI_GTK_H
8
9#if HAVE_CONFIG_H
10#include <config.h> 
11#endif
12
13#ifdef HAVE_GTK2
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#endif /* HAVE_GTK2 */
29
30#ifdef HAVE_GTK2
31bool initGTK(int argc, char *argv[]);
32bool mainloopGTK(void);
33#endif /* HAVE_GTK2 */
34
35
36//! This is the topmost object that can be displayed all others are derived from it.
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#ifdef HAVE_GTK2
45  GtkWidget* widget; //!< widget is the gtk_widget that the specific Object Contains.
46#endif /* HAVE_GTK2 */
47  void init(void);
48  int isOption; //!< with this Paramenter one can set the option-type: -2:Container, -1: Box, 0: not an Option, 1: Bool-option, 2: int-option, 3: float option, 4:char option, 5: char* option
49  /**
50     \briefdefines isOption 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#ifdef HAVE_GTK2
55  gulong connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *));
56  gulong connectSignal (char* event, gint (*signal)(GtkWidget*, Widget *));
57  gulong connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEvent*, void *));
58  gulong connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEventKey*, void *));
59  void disconnectSignal (gulong signalID);
60#endif /* HAVE_GTK2 */
61  void show ();
62  void hide ();
63  void setSize(int width, int height);
64
65  void walkThrough (void (*function)(Widget*));
66  static void listOptions (Widget* widget);
67  static void setOptions (Widget* widget);
68 
69#ifdef HAVE_GTK2
70  static gint doNothingSignal (GtkWidget *widget, GdkEvent* event, void* nothing);
71#endif /* HAVE_GTK2 */
72};
73
74//! This is a Packer Object, which has the ability to Pack other Widgets into itself.
75class Packer : public Widget
76{
77 public:
78  Widget* down; //!< this points to the Widget below this.
79  char* groupName; //!< For each Packer you can specify a Groupname under which the lowerWidgets will be saved.
80
81  void init(void);
82  void setGroupName (char* name);
83  char* getGroupName (void);
84};
85
86//! This is a Container Class, it can contain one sub-Widget: down.
87/**
88 * A Container is a Widget that can hold a subWidget in addition to a next-Widget.
89 * The Container can by itself not be displayed created or used.
90 * The derived classes of Container can be displayed
91*/
92class Container : public Packer
93{
94 private:
95  int borderwidth;
96  int policy;
97 
98 public:
99  void init(void);
100  //  void setBorderWidth (int borderwidth);
101  //  virtual void setTitle (char* title) = 0;
102  void fill (Widget *lowerWidget);
103};
104
105//! Window is the class that creates new Windows, and handels them
106/**
107 * A Window is a class derived from Container that contains a window-widget.
108 * It has the ability to hold one sub-object
109 */
110class Window : public Container
111{
112 private:
113  bool isOpen;
114 public:
115  static Window* mainWindow;
116  static void addWindow(Window* windowToAdd);
117
118  Window (void);
119  Window (char* windowName);
120  void init ();
121 
122  void setTitle (char* title);
123  void showall ();
124  void open();
125  void close();
126
127#ifdef HAVE_GTK2
128  static gint windowOpen (GtkWidget *widget, GdkEvent* event, void* window);
129  static gint windowClose (GtkWidget *widget, GdkEvent* event, void* window);
130  static gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data);
131#endif /* HAVE_GTK2 */
132};
133
134//! Frame is the class that handles frames
135/**
136 * A Frame is an object, that has a border and if you like a name on it.
137 * It can contain a Widget, which means that you can insert anything you like inside of a frame
138 */
139class Frame :public Container
140{
141 public:
142  Frame (char* frameName);
143  Frame (void);
144  void init(void);
145 
146  void setTitle (char* title);
147};
148
149//! EventBox is a Container that can Handle all Events happening inside of it.
150/**
151 * Example: if you have a picture, and you want it to catch mouse-clicks, you have to pack it inside a EventBox
152 */
153class EventBox : public Container
154{
155 public:
156  EventBox (char* eventBoxName);
157  EventBox (void);
158  void init(void);
159 
160  void setTitle (char* title);
161};
162
163//! A Box can contain multiple Widgets
164/**
165 * A Box can Contain multiple Widgets, that are ordered either horizontally or vertically
166 * I defined the standartbox to be horizontally.
167 * A Box is always filled left->right (horizontally) or up->down (vertically)
168 */
169class Box : public Packer
170{
171 public:
172  Box (void);
173  Box (char boxtype);
174  void init(char boxtype);
175
176  void fill (Widget* lowerWidget);
177
178};
179
180//! Image is the keeper of one Image
181/**
182 * Images are mighty cool.
183 * Images can help you lighten up the Programming process, and will give everyone a better impression of the Software.
184 */
185class Image : public Widget
186{
187 public:
188  Image (char* imgaename);
189  void init(void);
190};
191
192//! An Option is a Widget that contains something that may change its state.
193/**
194 * Options are the essence of a GUI, they: Configure, Start, Quit, Execute, and make it worth something
195 */
196class Option : public Widget
197{
198 public:
199  //virtual gint OptionChange (GtkWidget *widget, GdkEvent *event, gpointer data);
200  void init(void);
201
202  int value; //!< every option has a value either true or false (0,1) or something else like 25 for 25% of the volume
203  char* flagName; //!< options have a flag name that will be appendet if you start the Program from the GUI.
204  char* flagNameShort; //!< like flag_name but shorter
205  int defaultValue; //!< A default value is good, for hiding a option if it is not needed. (hidden if value == default_value)
206  bool saveable;  //! Options can be Saved.
207
208  void setFlagName (char* flagname, int defaultvalue);
209  void setFlagName (char* flagname, char* flagnameshort, int defaultvalue);
210  virtual void redraw () = 0; //!< A Option must be able to redraw itself.
211};
212
213//! Buttons can be pressed, and released.
214/**
215 * Buttons are mainly there for executing some action like Starting the Programm, or Quiting it.
216 */
217class Button : public Option
218{
219 public:
220  Button (char* buttonname);
221  void init(void);
222
223  void setTitle(char* title);
224 
225  void redraw();
226};
227
228//! CheckButtons are a key in configuring bool Variables
229/** CheckButtons can configure bool Variables like wireframe on/off, enable_sound etc.
230 */
231class CheckButton : public Option
232{
233 public:
234  CheckButton (char* buttonname);
235#ifdef HAVE_GTK2
236  static gint OptionChange (GtkWidget* widget, Widget* checkbutton);
237#endif /* HAVE_GTK2 */
238 
239  void init(void);
240  void setTitle(char* title);
241
242  bool isActive();
243  void redraw ();
244};
245
246//! Sliders are Options that can be modified in their value
247/**
248 * good for volume, brightness, etc.
249 */
250class Slider : public Option
251{
252 public:
253  Slider (char* slidername,int start, int end);
254  void init(int start, int end);
255
256  void setTitle(char* title);
257  void setValue(int value);
258
259#ifdef HAVE_GTK2
260  static gint OptionChange (GtkWidget* widget, Widget* slider);
261#endif /* HAVE_GTK2 */
262  void redraw();
263};
264
265//! A Menu is an Option that has a dropdown menu, where you can chose between different Items
266class Menu : public Option
267{
268 private:
269#ifdef HAVE_GTK2
270  GtkWidget* menu;
271  GtkWidget* item;
272#endif /* HAVE_GTK2 */
273  va_list itemlist;
274 
275 public:
276  Menu (char* menuname, ...);
277  void init(void);
278
279  void setTitle(char* title);
280
281  void addItem(char* itemName);
282#ifdef HAVE_GTK2
283  static gint OptionChange (GtkWidget* widget, Widget* menu);
284#endif /* HAVE_GTK2 */
285  void redraw();
286};
287
288//! A CharLabel is a simple Label, that holds a char*, and will be updated, if changed.
289class OptionLabel : public Option
290{
291 public:
292  OptionLabel(char* label, char* value);
293  void init(void);
294 
295  char* cValue;
296 
297  void setValue(char* newValue);
298  void setTitle(char* title);
299  void redraw();
300};
301
302//! A label is a Widget, that displays a text
303class Label : public Widget
304{
305 public:
306  Label ();
307  Label (char* text);
308  void init(void);
309 
310  void setText (char* text);
311  char* getText ();
312};
313
314
315//gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data);
316
317#endif /* _ORXONOX_GUI_GTK_H */
Note: See TracBrowser for help on using the repository browser.