[2588] | 1 | /*! |
---|
| 2 | \file orxonox_gui.h |
---|
| 3 | \brief Contains all Widgets and the Creation of the Gui |
---|
| 4 | */ |
---|
| 5 | |
---|
[1809] | 6 | #ifndef _ORXONOX_GUI_H |
---|
| 7 | #define _ORXONOX_GUI_H |
---|
| 8 | |
---|
| 9 | #include <stdlib.h> |
---|
| 10 | #include <string.h> |
---|
[2018] | 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> |
---|
[2024] | 23 | #include <gtk/gtkimage.h> |
---|
[2580] | 24 | #include <gtk/gtkeventbox.h> |
---|
[1809] | 25 | |
---|
[2588] | 26 | //! Class that creates the OrxonoxGui |
---|
[2018] | 27 | class OrxonoxGui |
---|
[1817] | 28 | { |
---|
[2018] | 29 | public: |
---|
| 30 | OrxonoxGui (int argc, char *argv[]); |
---|
| 31 | ~OrxonoxGui (); |
---|
| 32 | |
---|
| 33 | }; |
---|
| 34 | |
---|
[2588] | 35 | //! This is the topmost object that can be displayed all others are derived from it. |
---|
| 36 | |
---|
[2018] | 37 | class Widget |
---|
| 38 | { |
---|
[2586] | 39 | private: |
---|
[2018] | 40 | public: |
---|
[2605] | 41 | ~Widget (); |
---|
| 42 | |
---|
[2588] | 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. |
---|
[2586] | 45 | virtual void init(void); |
---|
[2588] | 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 |
---|
[2605] | 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; |
---|
[2018] | 52 | void connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *)); |
---|
| 53 | void connectSignal (char* event, gint (*signal)(GtkWidget*, Widget *)); |
---|
[2581] | 54 | void connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEvent*, void *)); |
---|
[2018] | 55 | void show (); |
---|
[2605] | 56 | void hide (); |
---|
| 57 | void setSize(int width, int height); |
---|
[2018] | 58 | |
---|
[2584] | 59 | void walkThrough (void (*function)(Widget*)); |
---|
| 60 | static void listOptions (Widget* widget); |
---|
| 61 | static void setOptions (Widget* widget); |
---|
| 62 | |
---|
[2018] | 63 | }; |
---|
| 64 | |
---|
[2605] | 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. |
---|
[2018] | 70 | |
---|
[2605] | 71 | void init(void); |
---|
| 72 | }; |
---|
| 73 | |
---|
[2588] | 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 | */ |
---|
[2605] | 80 | class Container : public Packer |
---|
[2018] | 81 | { |
---|
| 82 | private: |
---|
| 83 | int borderwidth; |
---|
| 84 | int policy; |
---|
[1817] | 85 | |
---|
[2018] | 86 | public: |
---|
[2586] | 87 | void init(void); |
---|
[2588] | 88 | // void setBorderWidth (int borderwidth); |
---|
| 89 | // virtual void setTitle (char* title) = 0; |
---|
[2018] | 90 | void fill (Widget *lowerWidget); |
---|
| 91 | }; |
---|
| 92 | |
---|
[2588] | 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 | */ |
---|
[2018] | 98 | class Window : public Container |
---|
| 99 | { |
---|
[2605] | 100 | private: |
---|
| 101 | bool isOpen; |
---|
[2018] | 102 | public: |
---|
| 103 | Window (char* windowName); |
---|
| 104 | Window (void); |
---|
[2586] | 105 | void init (); |
---|
[1817] | 106 | |
---|
[2018] | 107 | void setTitle (char* title); |
---|
[2588] | 108 | void showall (); |
---|
[2018] | 109 | static gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data); |
---|
[1817] | 110 | }; |
---|
| 111 | |
---|
[2588] | 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 | */ |
---|
[2018] | 117 | class Frame :public Container |
---|
| 118 | { |
---|
| 119 | public: |
---|
| 120 | Frame (char* frameName); |
---|
| 121 | Frame (void); |
---|
[2586] | 122 | void init(void); |
---|
[2018] | 123 | |
---|
| 124 | void setTitle (char* title); |
---|
| 125 | }; |
---|
| 126 | |
---|
[2588] | 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 | */ |
---|
[2580] | 131 | class EventBox : public Container |
---|
| 132 | { |
---|
| 133 | public: |
---|
| 134 | EventBox (char* eventBoxName); |
---|
| 135 | EventBox (void); |
---|
[2586] | 136 | void init(void); |
---|
| 137 | |
---|
[2580] | 138 | void setTitle (char* title); |
---|
| 139 | }; |
---|
| 140 | |
---|
[2588] | 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 | */ |
---|
[2605] | 147 | class Box : public Packer |
---|
[2018] | 148 | { |
---|
| 149 | public: |
---|
| 150 | Box (void); |
---|
| 151 | Box (char boxtype); |
---|
[2586] | 152 | void init(char boxtype); |
---|
[2018] | 153 | |
---|
| 154 | void fill (Widget* lowerWidget); |
---|
| 155 | |
---|
| 156 | }; |
---|
| 157 | |
---|
[2588] | 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 | */ |
---|
[2024] | 163 | class Image : public Widget |
---|
| 164 | { |
---|
| 165 | public: |
---|
| 166 | Image (char* imgaename); |
---|
[2586] | 167 | void init(void); |
---|
[2024] | 168 | }; |
---|
| 169 | |
---|
[2588] | 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 | */ |
---|
[2018] | 174 | class Option : public Widget |
---|
| 175 | { |
---|
| 176 | public: |
---|
| 177 | //virtual gint OptionChange (GtkWidget *widget, GdkEvent *event, gpointer data); |
---|
[2586] | 178 | void init(void); |
---|
| 179 | |
---|
[2588] | 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) |
---|
[2018] | 184 | |
---|
| 185 | void setFlagName (char* flagname, int defaultvalue); |
---|
| 186 | void setFlagName (char* flagname, char* flagnameshort, int defaultvalue); |
---|
[2588] | 187 | virtual void redraw () = 0; //!< A Option must be able to redraw itself. |
---|
[2018] | 188 | }; |
---|
| 189 | |
---|
[2588] | 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 | */ |
---|
[2018] | 194 | class Button : public Option |
---|
| 195 | { |
---|
| 196 | public: |
---|
| 197 | Button (char* buttonname); |
---|
[2586] | 198 | void init(void); |
---|
| 199 | |
---|
| 200 | void setTitle(char* title); |
---|
[2018] | 201 | |
---|
| 202 | void redraw(); |
---|
| 203 | }; |
---|
| 204 | |
---|
[2588] | 205 | //! CheckButtons are a key in configuring bool Variables |
---|
| 206 | /** CheckButtons can configure bool Variables like wireframe on/off, enable_sound etc. |
---|
| 207 | */ |
---|
[2018] | 208 | class CheckButton : public Option |
---|
| 209 | { |
---|
| 210 | public: |
---|
| 211 | CheckButton (char* buttonname); |
---|
| 212 | static gint OptionChange (GtkWidget* widget, Widget* checkbutton); |
---|
[2586] | 213 | |
---|
| 214 | void init(void); |
---|
| 215 | void setTitle(char* title); |
---|
| 216 | |
---|
[2018] | 217 | void redraw (); |
---|
| 218 | }; |
---|
| 219 | |
---|
[2588] | 220 | //! Sliders are Options that can be modified in their value |
---|
| 221 | /** |
---|
| 222 | * good for volume, brightness, etc. |
---|
| 223 | */ |
---|
[2018] | 224 | class Slider : public Option |
---|
| 225 | { |
---|
| 226 | public: |
---|
| 227 | Slider (char* slidername,int start, int end); |
---|
[2586] | 228 | void init(int start, int end); |
---|
| 229 | |
---|
| 230 | void setTitle(char* title); |
---|
| 231 | void setValue(int value); |
---|
| 232 | |
---|
[2018] | 233 | static gint OptionChange (GtkWidget* widget, Widget* slider); |
---|
| 234 | void redraw(); |
---|
| 235 | }; |
---|
| 236 | |
---|
[2588] | 237 | //! A Menu is an Option that has a dropdown menu, where you can chose between different Items |
---|
[2018] | 238 | class Menu : public Option |
---|
| 239 | { |
---|
[2587] | 240 | private: |
---|
| 241 | GtkWidget* menu; |
---|
| 242 | GtkWidget* item; |
---|
| 243 | va_list itemlist; |
---|
| 244 | |
---|
[2018] | 245 | public: |
---|
| 246 | Menu (char* menuname, ...); |
---|
[2587] | 247 | void init(void); |
---|
[2018] | 248 | |
---|
[2587] | 249 | void setTitle(char* title); |
---|
| 250 | |
---|
| 251 | void addItem(char* itemName); |
---|
[2018] | 252 | static gint OptionChange (GtkWidget* widget, Widget* menu); |
---|
| 253 | void redraw(); |
---|
| 254 | }; |
---|
| 255 | |
---|
[2588] | 256 | //! A label is a Widget, that displays a text |
---|
[2018] | 257 | class Label : public Widget |
---|
| 258 | { |
---|
| 259 | public: |
---|
| 260 | Label (); |
---|
| 261 | Label (char* text); |
---|
[2586] | 262 | void init(void); |
---|
[2018] | 263 | |
---|
| 264 | void setText (char * text); |
---|
| 265 | char* getText (); |
---|
| 266 | }; |
---|
| 267 | |
---|
| 268 | //gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data); |
---|
| 269 | |
---|
[1809] | 270 | #endif /* _ORXONOX_GUI_H */ |
---|