Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/branches/updater: gtk_gui: now setTitle is a virtual function of Widget.

File size: 9.7 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 public:
196  //virtual gint OptionChange (GtkWidget* widget, GdkEvent* event, gpointer data);
197  void init(void);
198
199  int value; //!< every option has a value either true or false (0,1) or something else like 25 for 25% of the volume
200  char* flagName; //!< options have a flag name that will be appendet if you start the Program from the GUI.
201  char* flagNameShort; //!< like flag_name but shorter
202  int defaultValue; //!< A default value is good, for hiding a option if it is not needed. (hidden if value == default_value)
203  bool saveable;  //!< Options can be Saved.
204
205  void setFlagName (char* flagname, int defaultvalue);
206  void setFlagName (char* flagname, char* flagnameshort, int defaultvalue);
207  virtual void redraw () = 0; //!< A Option must be able to redraw itself.
208};
209
210//! Buttons can be pressed, and released.
211/**
212 * Buttons are mainly there for executing some action like Starting the Programm, or Quiting it.
213 */
214class Button : public Option
215{
216 public:
217  Button (char* buttonname);
218  void init(void);
219
220  void setTitle(char* title);
221 
222  void redraw();
223};
224
225//! CheckButtons are a key in configuring bool Variables
226/** CheckButtons can configure bool Variables like wireframe on/off, enable_sound etc.
227 */
228class CheckButton : public Option
229{
230 public:
231  CheckButton (char* buttonname);
232#ifdef HAVE_GTK2
233  static gint OptionChange (GtkWidget* widget, Widget* checkbutton);
234#endif /* HAVE_GTK2 */
235 
236  void init(void);
237  void setTitle(char* title);
238
239  bool isActive();           //!< a Bool value to see, if this CheckButton is active.
240  void redraw ();
241};
242
243//! Sliders are Options that can be modified in their value
244/**
245 * good for volume, brightness, etc.
246 */
247class Slider : public Option
248{
249 public:
250  Slider (char* slidername,int start, int end);
251  void init(int start, int end);
252
253  void setTitle(char* title);
254  void setValue(int value);
255
256#ifdef HAVE_GTK2
257  static gint OptionChange (GtkWidget* widget, Widget* slider);
258#endif /* HAVE_GTK2 */
259  void redraw();
260};
261
262//! A Menu is an Option that has a dropdown menu, where you can chose between different Items
263class Menu : public Option
264{
265 private:
266#ifdef HAVE_GTK2
267  GtkWidget* menu;     //!< The menu That will hold the Options.
268  GtkWidget* item;     //!< One Item From a Menu.
269#endif /* HAVE_GTK2 */
270  va_list itemlist;    //!< The list to readin multiple Options.
271 
272 public:
273  Menu (char* menuname, ...);
274  void init(void);
275
276  void setTitle(char* title);
277
278  void addItem(char* itemName);
279#ifdef HAVE_GTK2
280  static gint OptionChange (GtkWidget* widget, Widget* menu);
281#endif /* HAVE_GTK2 */
282  void redraw();
283};
284
285//! A CharLabel is a simple Label, that holds a char*, and will be updated, if changed.
286class OptionLabel : public Option
287{
288 public:
289  OptionLabel(char* label, char* value);
290  void init(void);
291 
292  char* cValue;   //!< The Value the Label will have.
293 
294  void setValue(char* newValue);
295  void setTitle(char* title);
296  void redraw();
297};
298
299//! A label is a Widget, that displays a text
300class Label : public Widget
301{
302 public:
303  Label ();
304  Label (char* text);
305  void init(void);
306 
307  void setTitle(char* text);
308  char* getText ();
309};
310
311//! A ProgressBar is a Widget, that can display a Progress
312class ProgressBar : public Widget
313{
314 public:
315  ProgressBar (void);
316  ProgressBar (char* label);
317  ~ProgressBar ();
318  void init (void);
319
320  void setTitle(char* title);
321
322  void setProgress (double progress);
323  void setTotalSize (double totalSize);
324  double getProgress (void);
325
326 private:
327  double totalSize;         //!< The total Size of a download Bar
328  double progress;          //!< The progress of a Bar.
329#ifdef HAVE_GTK2
330  GtkAdjustment* adjustment;
331#endif /* HAVE_GTK2 */
332};
333
334//! Image is the keeper of one Image
335/**
336 * Images are mighty cool.
337 * Images can help you lighten up the Programming process, and will give everyone a better impression of the Software.
338 */
339class Image : public Widget
340{
341 public:
342  Image (char* imgaename);
343  void init(void);
344
345  void setTitle(char* title);
346};
347
348//gint orxonox_gui_quit (GtkWidget* widget, GdkEvent* event, gpointer data);
349
350#endif /* _ORXONOX_GUI_GTK_H */
Note: See TracBrowser for help on using the repository browser.