Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk/gui: better signal-handling

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