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