Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/updater/src/gui/orxonox_gui_gtk.h @ 3275

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

orxonox/branches/updater: doxygen tags

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