Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/gui/orxonox_gui_gtk.h @ 3165

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

orxonox/trunk/gui: compiling as not-GTK possibe, but it is not usable yet

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