Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/branches/updater: saveable flag is now protected

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