Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk/gui: keys in the new Style

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