Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk/gui: banner Window is as it should be

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  static Window* lastWindow;
95  Window (void);
96  Window (char* windowName);
97  void init ();
98 
99  void setTitle (char* title);
100  void showall (); 
101  void open();
102  void close();
103  static gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data);
104};
105
106//! Frame is the class that handles frames
107/**
108 * A Frame is an object, that has a border and if you like a name on it.
109 * It can contain a Widget, which means that you can insert anything you like inside of a frame
110 */
111class Frame :public Container
112{
113 public:
114  Frame (char* frameName);
115  Frame (void);
116  void init(void);
117 
118  void setTitle (char* title);
119};
120
121//! EventBox is a Container that can Handle all Events happening inside of it.
122/**
123 * Example: if you have a picture, and you want it to catch mouse-clicks, you have to pack it inside a EventBox
124 */
125class EventBox : public Container
126{
127 public:
128  EventBox (char* eventBoxName);
129  EventBox (void);
130  void init(void);
131 
132  void setTitle (char* title);
133};
134
135//! A Box can contain multiple Widgets
136/**
137 * A Box can Contain multiple Widgets, that are ordered either horizontally or vertically
138 * I defined the standartbox to be horizontally.
139 * A Box is always filled left->right (horizontally) or up->down (vertically)
140 */
141class Box : public Packer
142{
143 public:
144  Box (void);
145  Box (char boxtype);
146  void init(char boxtype);
147
148  void fill (Widget* lowerWidget);
149
150};
151
152//! Image is the keeper of one Image
153/**
154 * Images are mighty cool.
155 * Images can help you lighten up the Programming process, and will give everyone a better impression of the Software.
156 */
157class Image : public Widget
158{
159 public:
160  Image (char* imgaename);
161  void init(void);
162};
163
164//! An Option is a Widget that contains something that may change its state.
165/**
166 * Options are the essence of a GUI, they: Configure, Start, Quit, Execute, and make it worth something
167 */
168class Option : public Widget
169{
170 public:
171  //virtual gint OptionChange (GtkWidget *widget, GdkEvent *event, gpointer data);
172  void init(void);
173
174  int value; //!< every option has a value either true or false (0,1) or something else like 25 for 25% of the volume
175  char* flag_name; //!< options have a flag name that will be appendet if you start the Program from the GUI.
176  char* flag_name_short; //!< like flag_name but shorter
177  int default_value; //!< A default value is good, for hiding a option if it is not needed. (hidden if value == default_value)
178  bool saveable;
179
180  void setFlagName (char* flagname, int defaultvalue);
181  void setFlagName (char* flagname, char* flagnameshort, int defaultvalue);
182  virtual void redraw () = 0; //!< A Option must be able to redraw itself.
183};
184
185//! Buttons can be pressed, and released.
186/**
187 * Buttons are mainly there for executing some action like Starting the Programm, or Quiting it.
188 */
189class Button : public Option
190{
191 public:
192  Button (char* buttonname);
193  void init(void);
194
195  void setTitle(char* title);
196 
197  void redraw();
198};
199
200//! CheckButtons are a key in configuring bool Variables
201/** CheckButtons can configure bool Variables like wireframe on/off, enable_sound etc.
202 */
203class CheckButton : public Option
204{
205 public:
206  CheckButton (char* buttonname);
207  static gint OptionChange (GtkWidget* widget, Widget* checkbutton);
208 
209  void init(void);
210  void setTitle(char* title);
211
212  bool isActive();
213  void redraw ();
214};
215
216//! Sliders are Options that can be modified in their value
217/**
218 * good for volume, brightness, etc.
219 */
220class Slider : public Option
221{
222 public:
223  Slider (char* slidername,int start, int end);
224  void init(int start, int end);
225
226  void setTitle(char* title);
227  void setValue(int value);
228
229  static gint OptionChange (GtkWidget* widget, Widget* slider);
230  void redraw();
231};
232
233//! A Menu is an Option that has a dropdown menu, where you can chose between different Items
234class Menu : public Option
235{
236 private:
237  GtkWidget* menu;
238  GtkWidget* item;
239  va_list itemlist;
240 
241 public:
242  Menu (char* menuname, ...);
243  void init(void);
244
245  void setTitle(char* title);
246
247  void addItem(char* itemName);
248  static gint OptionChange (GtkWidget* widget, Widget* menu);
249  void redraw();
250};
251
252//! A label is a Widget, that displays a text
253class Label : public Widget
254{
255 public:
256  Label ();
257  Label (char* text);
258  void init(void);
259 
260  void setText (char* text);
261  char* getText ();
262};
263
264//gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data);
265
266#endif /* _ORXONOX_GUI_GTK_H */
Note: See TracBrowser for help on using the repository browser.