/*! \file orxonox_gui_gtk.h \brief Contains all th different Widgets. */ #ifndef _ORXONOX_GUI_GTK_H #define _ORXONOX_GUI_GTK_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include //! This is the topmost object that can be displayed all others are derived from it. class Widget { private: public: ~Widget (); Widget* next; //!< next always points to the next Widget in the list. Every Widget has a next one, or has NULL as next GtkWidget* widget; //!< widget is the gtk_widget that the specific Object Contains. void init(void); 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 /** \briefdefines isOption states */ enum option { containerType = -2, boxType = -1, nothingType = 0, boolType = 1, intType = 2}; char* label; //!< The name of the Widget. Some do display it, Options need it to save; gulong connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *)); gulong connectSignal (char* event, gint (*signal)(GtkWidget*, Widget *)); gulong connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEvent*, void *)); gulong connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEventKey*, void *)); void disconnectSignal (gulong signalID); void show (); void hide (); void setSize(int width, int height); void walkThrough (void (*function)(Widget*)); static void listOptions (Widget* widget); static void setOptions (Widget* widget); static gint doNothingSignal (GtkWidget *widget, GdkEvent* event, void* nothing); }; //! This is a Packer Object, which has the ability to Pack other Widgets into itself. class Packer : public Widget { public: Widget* down; //!< this points to the Widget below this. char* groupName; //!< For each Packer you can specify a Groupname under which the lowerWidgets will be saved. void init(void); void setGroupName (char* name); char* getGroupName (void); }; //! This is a Container Class, it can contain one sub-Widget: down. /** * A Container is a Widget that can hold a subWidget in addition to a next-Widget. * The Container can by itself not be displayed created or used. * The derived classes of Container can be displayed */ class Container : public Packer { private: int borderwidth; int policy; public: void init(void); // void setBorderWidth (int borderwidth); // virtual void setTitle (char* title) = 0; void fill (Widget *lowerWidget); }; //! Window is the class that creates new Windows, and handels them /** * A Window is a class derived from Container that contains a window-widget. * It has the ability to hold one sub-object */ class Window : public Container { private: bool isOpen; public: static Window* mainWindow; static void addWindow(Window* windowToAdd); Window (void); Window (char* windowName); void init (); void setTitle (char* title); void showall (); void open(); void close(); static gint windowOpen (GtkWidget *widget, GdkEvent* event, void* window); static gint windowClose (GtkWidget *widget, GdkEvent* event, void* window); static gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data); }; //! Frame is the class that handles frames /** * A Frame is an object, that has a border and if you like a name on it. * It can contain a Widget, which means that you can insert anything you like inside of a frame */ class Frame :public Container { public: Frame (char* frameName); Frame (void); void init(void); void setTitle (char* title); }; //! EventBox is a Container that can Handle all Events happening inside of it. /** * Example: if you have a picture, and you want it to catch mouse-clicks, you have to pack it inside a EventBox */ class EventBox : public Container { public: EventBox (char* eventBoxName); EventBox (void); void init(void); void setTitle (char* title); }; //! A Box can contain multiple Widgets /** * A Box can Contain multiple Widgets, that are ordered either horizontally or vertically * I defined the standartbox to be horizontally. * A Box is always filled left->right (horizontally) or up->down (vertically) */ class Box : public Packer { public: Box (void); Box (char boxtype); void init(char boxtype); void fill (Widget* lowerWidget); }; //! Image is the keeper of one Image /** * Images are mighty cool. * Images can help you lighten up the Programming process, and will give everyone a better impression of the Software. */ class Image : public Widget { public: Image (char* imgaename); void init(void); }; //! An Option is a Widget that contains something that may change its state. /** * Options are the essence of a GUI, they: Configure, Start, Quit, Execute, and make it worth something */ class Option : public Widget { public: //virtual gint OptionChange (GtkWidget *widget, GdkEvent *event, gpointer data); void init(void); int value; //!< every option has a value either true or false (0,1) or something else like 25 for 25% of the volume char* flagName; //!< options have a flag name that will be appendet if you start the Program from the GUI. char* flagNameShort; //!< like flag_name but shorter int defaultValue; //!< A default value is good, for hiding a option if it is not needed. (hidden if value == default_value) bool saveable; //! Options can be Saved. void setFlagName (char* flagname, int defaultvalue); void setFlagName (char* flagname, char* flagnameshort, int defaultvalue); virtual void redraw () = 0; //!< A Option must be able to redraw itself. }; //! Buttons can be pressed, and released. /** * Buttons are mainly there for executing some action like Starting the Programm, or Quiting it. */ class Button : public Option { public: Button (char* buttonname); void init(void); void setTitle(char* title); void redraw(); }; //! CheckButtons are a key in configuring bool Variables /** CheckButtons can configure bool Variables like wireframe on/off, enable_sound etc. */ class CheckButton : public Option { public: CheckButton (char* buttonname); static gint OptionChange (GtkWidget* widget, Widget* checkbutton); void init(void); void setTitle(char* title); bool isActive(); void redraw (); }; //! Sliders are Options that can be modified in their value /** * good for volume, brightness, etc. */ class Slider : public Option { public: Slider (char* slidername,int start, int end); void init(int start, int end); void setTitle(char* title); void setValue(int value); static gint OptionChange (GtkWidget* widget, Widget* slider); void redraw(); }; //! A Menu is an Option that has a dropdown menu, where you can chose between different Items class Menu : public Option { private: GtkWidget* menu; GtkWidget* item; va_list itemlist; public: Menu (char* menuname, ...); void init(void); void setTitle(char* title); void addItem(char* itemName); static gint OptionChange (GtkWidget* widget, Widget* menu); void redraw(); }; //! A CharLabel is a simple Label, that holds a char*, and will be updated, if changed. class OptionLabel : public Option { public: OptionLabel(char* text); void init(void); void setTitle(char* title); void redraw(); }; //! A label is a Widget, that displays a text class Label : public Widget { public: Label (); Label (char* text); void init(void); void setText (char* text); char* getText (); }; //gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data); #endif /* _ORXONOX_GUI_GTK_H */