Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/gui/orxonox_gui_gtk.h @ 3156

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

orxonox/trunk/gui: setting keys is really sexy now

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