Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/gui/orxonox_gui_gtk.h @ 3458

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

orxonox/trunk: merged branches/updater back into the trunk
merged with command: svn merge branches/updater trunk -r 3241:HEAD
resolved conflicts in debug.h in favor of the trunk.

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