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