Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk/gui: modularity improvement: taken the gtk-stuff out of the main GUI

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