Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/gui/orxonox_gui.h @ 2595

Last change on this file since 2595 was 2595, checked in by bensch, 20 years ago

orxonox/trunk/gui: Generalized plugins (returning Widget* now). Enumerator for isOption added

File size: 7.0 KB
RevLine 
[2588]1/*!
2 \file orxonox_gui.h
3 \brief Contains all Widgets and the Creation of the Gui
4*/
5
[1809]6#ifndef _ORXONOX_GUI_H
7#define _ORXONOX_GUI_H
8
9#include <stdlib.h>
10#include <string.h>
[2018]11#include <gtk/gtkmain.h>
12#include <gtk/gtkwindow.h>
13#include <gtk/gtkframe.h>
14#include <gtk/gtkhbox.h>
15#include <gtk/gtkvbox.h>
16#include <gtk/gtkbutton.h>
17#include <gtk/gtkcheckbutton.h>
18#include <gtk/gtkhscale.h>
19#include <gtk/gtkoptionmenu.h>
20#include <gtk/gtkmenu.h>
21#include <gtk/gtkmenuitem.h>
22#include <gtk/gtklabel.h>
[2024]23#include <gtk/gtkimage.h>
[2580]24#include <gtk/gtkeventbox.h>
[1809]25
[2588]26//! Class that creates the OrxonoxGui
[2018]27class OrxonoxGui
[1817]28{
[2018]29 public:
30  OrxonoxGui (int argc, char *argv[]);
31  ~OrxonoxGui ();
32
33};
34
[2588]35//! This is the topmost object that can be displayed all others are derived from it.
36
[2018]37class Widget
38{
[2586]39 private:
[2018]40 public:
[2588]41  Widget* next; //!< next always points to the next Widget in the list. Every Widget has a next one, or has NULL as next
42  GtkWidget* widget; //!< widget is the gtk_widget that the specific Object Contains.
[2586]43  virtual void init(void);
[2588]44  int is_option; //!< with this Paramenter one can set the IsOption type: -2:Container, -1: Box, 0: not an Option, 1: Bool-option, 2: int-option
[2595]45  enum option { containerType = -2, boxType = -1, nothingType = 0, boolType = 1, intType = 2}; //!< defines is_option states
[2018]46  void connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *));
47  void connectSignal (char* event, gint (*signal)(GtkWidget*, Widget *));
[2581]48  void connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEvent*, void *));
[2018]49  void show ();
50
[2584]51  void walkThrough (void (*function)(Widget*));
52  static void listOptions (Widget* widget);
53  static void setOptions (Widget* widget);
54
[2018]55};
56
57
[2588]58//! This is a Container Class, it can contain one sub-Widget: down.
59/**
60 * A Container is a Widget that can hold a subWidget in addition to a next-Widget.
61 * The Container can by itself not be displayed created or used.
62 * The derived classes of Container can be displayed
63*/
[2018]64class Container : public Widget
65{
66 private:
67  int borderwidth;
68  int policy;
69  char* label;
[1817]70 
[2018]71 public:
[2586]72  void init(void);
[2588]73  Widget* down; //!< this points to the Widget below this.
74  //  void setBorderWidth (int borderwidth);
75  //  virtual void setTitle (char* title) = 0;
[2018]76  void fill (Widget *lowerWidget);
77};
78
[2588]79//! Window is the class that creates new Windows, and handels them
80/**
81 * A Window is a class derived from Container that contains a window-widget.
82 * It has the ability to hold one sub-object
83 */
[2018]84class Window : public Container
85{
86 public:
87  Window (char* windowName);
88  Window (void);
89  ~Window ();
[2586]90  void init ();
[1817]91 
[2018]92  void setTitle (char* title);
[2588]93  void showall (); 
[2018]94  static gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data);
[1817]95};
96
[2588]97//! Frame is the class that handles frames
98/**
99 * A Frame is an object, that has a border and if you like a name on it.
100 * It can contain a Widget, which means that you can insert anything you like inside of a frame
101 */
[2018]102class Frame :public Container
103{
104 public:
105  Frame (char* frameName);
106  Frame (void);
107  ~Frame ();
[2586]108  void init(void);
[2018]109 
110  void setTitle (char* title);
111};
112
[2588]113//! EventBox is a Container that can Handle all Events happening inside of it.
114/**
115 * Example: if you have a picture, and you want it to catch mouse-clicks, you have to pack it inside a EventBox
116 */
[2580]117class EventBox : public Container
118{
119 public:
120  EventBox (char* eventBoxName);
121  EventBox (void);
122  ~EventBox ();
[2586]123  void init(void);
124 
[2580]125  void setTitle (char* title);
126};
127
[2588]128//! A Box can contain multiple Widgets
129/**
130 * A Box can Contain multiple Widgets, that are ordered either horizontally or vertically
131 * I defined the standartbox to be horizontally.
132 * A Box is always filled left->right (horizontally) or up->down (vertically)
133 */
[2018]134class Box : public Widget
135{
136 public:
137  Box (void);
138  Box (char boxtype);
139  ~Box (void);
[2586]140  void init(char boxtype);
[2018]141
[2588]142  Widget* down; //!< the Lower Widget of a Box.
[2018]143  void fill (Widget* lowerWidget);
144
145};
146
[2588]147//! Image is the keeper of one Image
148/**
149 * Images are mighty cool.
150 * Images can help you lighten up the Programming process, and will give everyone a better impression of the Software.
151 */
[2024]152class Image : public Widget
153{
154 public:
155  Image (char* imgaename);
156  ~Image ();
[2586]157  void init(void);
[2024]158};
159
[2588]160//! An Option is a Widget that contains something that may change its state.
161/**
162 * Options are the essence of a GUI, they: Configure, Start, Quit, Execute, and make it worth something
163 */
[2018]164class Option : public Widget
165{
166 public:
167  //virtual gint OptionChange (GtkWidget *widget, GdkEvent *event, gpointer data);
[2586]168  void init(void);
169
[2588]170  int value; //!< every option has a value either true or false (0,1) or something else like 25 for 25% of the volume
171  char* option_name; //!< options have a name, that can be displayed around them
172  char* flag_name; //!< options have a flag name that will be appendet if you start the Program from the GUI.
173  char* flag_name_short; //!< like flag_name but shorter
174  int default_value; //!< A default value is good, for hiding a option if it is not needed. (hidden if value == default_value)
[2018]175
176  void setFlagName (char* flagname, int defaultvalue);
177  void setFlagName (char* flagname, char* flagnameshort, int defaultvalue);
[2588]178  virtual void redraw () = 0; //!< A Option must be able to redraw itself.
[2018]179};
180
[2588]181//! Buttons can be pressed, and released.
182/**
183 * Buttons are mainly there for executing some action like Starting the Programm, or Quiting it.
184 */
[2018]185class Button : public Option
186{
187 public:
188  Button (char* buttonname);
189  ~Button (void);
[2586]190  void init(void);
191
192  void setTitle(char* title);
[2018]193 
194  void redraw();
195};
196
[2588]197//! CheckButtons are a key in configuring bool Variables
198/** CheckButtons can configure bool Variables like wireframe on/off, enable_sound etc.
199 */
[2018]200class CheckButton : public Option
201{
202 public:
203  CheckButton (char* buttonname);
204  ~CheckButton (void);
205  static gint OptionChange (GtkWidget* widget, Widget* checkbutton);
[2586]206 
207  void init(void);
208  void setTitle(char* title);
209
[2018]210  void redraw ();
211};
212
[2588]213//! Sliders are Options that can be modified in their value
214/**
215 * good for volume, brightness, etc.
216 */
[2018]217class Slider : public Option
218{
219 public:
220  Slider (char* slidername,int start, int end);
221  ~Slider ();
[2586]222  void init(int start, int end);
223
224  void setTitle(char* title);
225  void setValue(int value);
226
[2018]227  static gint OptionChange (GtkWidget* widget, Widget* slider);
228  void redraw();
229};
230
[2588]231//! A Menu is an Option that has a dropdown menu, where you can chose between different Items
[2018]232class Menu : public Option
233{
[2587]234 private:
235  GtkWidget* menu;
236  GtkWidget* item;
237  va_list itemlist;
238 
[2018]239 public:
240  Menu (char* menuname, ...);
241  ~Menu ();
[2587]242  void init(void);
[2018]243
[2587]244  void setTitle(char* title);
245
246  void addItem(char* itemName);
[2018]247  static gint OptionChange (GtkWidget* widget, Widget* menu);
248  void redraw();
249};
250
[2588]251//! A label is a Widget, that displays a text
[2018]252class Label : public Widget
253{
254 public:
255  Label ();
256  Label (char* text);
257  ~Label ();
[2586]258  void init(void);
[2018]259 
260  void setText (char * text);
261  char* getText ();
262};
263
264//gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data);
265
[1809]266#endif /* _ORXONOX_GUI_H */
Note: See TracBrowser for help on using the repository browser.