Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk/gui: key now able to be set.

File size: 7.3 KB
Line 
1/*!
2 \file orxonox_gui.h
3 \brief Contains all Widgets and the Creation of the Gui
4*/
5
6#ifndef _ORXONOX_GUI_H
7#define _ORXONOX_GUI_H
8
9#if HAVE_CONFIG_H
10#include <config.h> 
11#endif
12
13#include <stdlib.h>
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>
28
29//! Class that creates the OrxonoxGui
30class OrxonoxGui
31{
32 public:
33  OrxonoxGui (int argc, char *argv[]);
34  ~OrxonoxGui ();
35
36};
37
38//! This is the topmost object that can be displayed all others are derived from it.
39class Widget
40{
41 private:
42 public:
43  ~Widget ();
44
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.
47  void init(void);
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
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;
54  void connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *));
55  void connectSignal (char* event, gint (*signal)(GtkWidget*, Widget *));
56  void connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEvent*, void *));
57  void connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEventKey*, void *));
58  void show ();
59  void hide ();
60  void setSize(int width, int height);
61
62  void walkThrough (void (*function)(Widget*));
63  static void listOptions (Widget* widget);
64  static void setOptions (Widget* widget);
65
66};
67
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.
73  char* groupName; //!< For each Packer you can specify a Groupname under which the lowerWidgets will be saved.
74
75  void init(void);
76  void setGroupName (char* name);
77  char* getGroupName (void);
78};
79
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*/
86class Container : public Packer
87{
88 private:
89  int borderwidth;
90  int policy;
91 
92 public:
93  void init(void);
94  //  void setBorderWidth (int borderwidth);
95  //  virtual void setTitle (char* title) = 0;
96  void fill (Widget *lowerWidget);
97};
98
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 */
104class Window : public Container
105{
106 private:
107  bool isOpen;
108 public:
109  Window (char* windowName);
110  Window (void);
111  void init ();
112 
113  void setTitle (char* title);
114  void showall (); 
115  static gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data);
116};
117
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 */
123class Frame :public Container
124{
125 public:
126  Frame (char* frameName);
127  Frame (void);
128  void init(void);
129 
130  void setTitle (char* title);
131};
132
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 */
137class EventBox : public Container
138{
139 public:
140  EventBox (char* eventBoxName);
141  EventBox (void);
142  void init(void);
143 
144  void setTitle (char* title);
145};
146
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 */
153class Box : public Packer
154{
155 public:
156  Box (void);
157  Box (char boxtype);
158  void init(char boxtype);
159
160  void fill (Widget* lowerWidget);
161
162};
163
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 */
169class Image : public Widget
170{
171 public:
172  Image (char* imgaename);
173  void init(void);
174};
175
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 */
180class Option : public Widget
181{
182 public:
183  //virtual gint OptionChange (GtkWidget *widget, GdkEvent *event, gpointer data);
184  void init(void);
185
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)
190
191  void setFlagName (char* flagname, int defaultvalue);
192  void setFlagName (char* flagname, char* flagnameshort, int defaultvalue);
193  virtual void redraw () = 0; //!< A Option must be able to redraw itself.
194};
195
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 */
200class Button : public Option
201{
202 public:
203  Button (char* buttonname);
204  void init(void);
205
206  void setTitle(char* title);
207 
208  void redraw();
209};
210
211//! CheckButtons are a key in configuring bool Variables
212/** CheckButtons can configure bool Variables like wireframe on/off, enable_sound etc.
213 */
214class CheckButton : public Option
215{
216 public:
217  CheckButton (char* buttonname);
218  static gint OptionChange (GtkWidget* widget, Widget* checkbutton);
219 
220  void init(void);
221  void setTitle(char* title);
222
223  void redraw ();
224};
225
226//! Sliders are Options that can be modified in their value
227/**
228 * good for volume, brightness, etc.
229 */
230class Slider : public Option
231{
232 public:
233  Slider (char* slidername,int start, int end);
234  void init(int start, int end);
235
236  void setTitle(char* title);
237  void setValue(int value);
238
239  static gint OptionChange (GtkWidget* widget, Widget* slider);
240  void redraw();
241};
242
243//! A Menu is an Option that has a dropdown menu, where you can chose between different Items
244class Menu : public Option
245{
246 private:
247  GtkWidget* menu;
248  GtkWidget* item;
249  va_list itemlist;
250 
251 public:
252  Menu (char* menuname, ...);
253  void init(void);
254
255  void setTitle(char* title);
256
257  void addItem(char* itemName);
258  static gint OptionChange (GtkWidget* widget, Widget* menu);
259  void redraw();
260};
261
262//! A label is a Widget, that displays a text
263class Label : public Widget
264{
265 public:
266  Label ();
267  Label (char* text);
268  void init(void);
269 
270  void setText (char* text);
271  char* getText ();
272};
273
274//gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data);
275
276#endif /* _ORXONOX_GUI_H */
Note: See TracBrowser for help on using the repository browser.