Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/branches/updater: now the Data-bar downloads something, and the Progress is displayed. (not very nice, but it works).

NOT THREAD SAVE <<

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