Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/branches/updater: implemented update-functions: do nothing yet, will follow in next commit…

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