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