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