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