Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk/gui: minor fix

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