Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/branches/updater: implemented a new SignalHandler, signals for starting and quiting the Gui are now located in OrxonoxGuiExec.
Now thinking about a way to pass options to Orxonox (so the GUI really makes sense)

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