Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk/gui: modularity improved. Now init() of Subclasses execute the init() of their superclass to set the default values for specific Widgets

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