[4838] | 1 | /*! |
---|
[5391] | 2 | * @file glgui_widget.h |
---|
| 3 | * The gl_widget of the openglGUI |
---|
| 4 | */ |
---|
[1853] | 5 | |
---|
[5362] | 6 | #ifndef _GLGUI_WIDGET_H |
---|
| 7 | #define _GLGUI_WIDGET_H |
---|
[1853] | 8 | |
---|
[5362] | 9 | #include "element_2d.h" |
---|
[5391] | 10 | #include "event.h" |
---|
[1853] | 11 | |
---|
[6295] | 12 | #include "material.h" |
---|
| 13 | |
---|
[5690] | 14 | #include "glincl.h" |
---|
| 15 | #include "executor/executor.h" |
---|
| 16 | |
---|
[4838] | 17 | // FORWARD DECLARATION |
---|
[5365] | 18 | class Material; |
---|
[3543] | 19 | |
---|
[5391] | 20 | typedef enum |
---|
| 21 | { |
---|
| 22 | GLGuiSignal_click = 0, |
---|
[6295] | 23 | GLGuiSignal_release, |
---|
| 24 | GLGuiSignal_rollOn, |
---|
| 25 | GLGuiSignal_rollOff, |
---|
| 26 | GLGuiSignal_open, |
---|
| 27 | GLGuiSignal_close, |
---|
| 28 | GLGuiSignal_destroy, |
---|
[5391] | 29 | |
---|
[6295] | 30 | GLGuiSignalCount, |
---|
[5391] | 31 | } GLGuiSignalType; |
---|
| 32 | |
---|
[5387] | 33 | //! if the Element should be visible by default. |
---|
| 34 | #define GLGUI_WIDGET_DEFAULT_VISIBLE false |
---|
| 35 | |
---|
[5384] | 36 | //! This is widget part of the openglGUI class |
---|
[5359] | 37 | /** |
---|
[5387] | 38 | * A widget is the main class of all the elements of th GUI. |
---|
| 39 | */ |
---|
[5362] | 40 | class GLGuiWidget : public Element2D { |
---|
[5366] | 41 | public: |
---|
| 42 | GLGuiWidget(); |
---|
| 43 | virtual ~GLGuiWidget(); |
---|
[2036] | 44 | |
---|
[5366] | 45 | void init(); |
---|
[5392] | 46 | /** @returns a new char-array containing a string with the options. Delete with delete[]; */ |
---|
| 47 | virtual char* save() {}; |
---|
| 48 | /** loads options of the Widget. @param loadString a string containing the Options */ |
---|
| 49 | virtual void load(const char* loadString) {}; |
---|
[1853] | 50 | |
---|
[5366] | 51 | void show(); |
---|
[6431] | 52 | void hide(); |
---|
[5364] | 53 | |
---|
[5690] | 54 | void connectSignal(GLGuiSignalType signalType, const Executor& signal); |
---|
[5392] | 55 | void disconnectSignal(GLGuiSignalType signalType); |
---|
[5391] | 56 | bool focusOverWidget(float x, float y); |
---|
[5364] | 57 | |
---|
[5391] | 58 | // if something was clickt on the GUI-widget. |
---|
| 59 | virtual void click(const Event& event) {}; |
---|
| 60 | virtual void release(const Event& event) {}; |
---|
| 61 | |
---|
| 62 | virtual void receiveFocus() {}; |
---|
| 63 | virtual void removeFocus() {}; |
---|
| 64 | |
---|
[6438] | 65 | virtual void update() {}; |
---|
[6287] | 66 | virtual void draw() const; |
---|
[1853] | 67 | |
---|
[5366] | 68 | protected: |
---|
[6287] | 69 | inline void startDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); }; |
---|
| 70 | inline void endDraw() const { glPopMatrix(); }; |
---|
| 71 | |
---|
[6295] | 72 | protected: |
---|
| 73 | Material backMat; |
---|
[5387] | 74 | GLuint backModel; |
---|
[3245] | 75 | |
---|
[6295] | 76 | Material frontMat; |
---|
[5387] | 77 | GLuint frontModel; |
---|
| 78 | |
---|
[5395] | 79 | private: |
---|
[5690] | 80 | Executor* widgetSignals[GLGuiSignalCount]; |
---|
[5391] | 81 | |
---|
[5387] | 82 | bool focusable; //!< If this widget can receive focus. |
---|
| 83 | bool clickable; //!< if this widget can be clicked upon. |
---|
[1853] | 84 | }; |
---|
| 85 | |
---|
[5362] | 86 | #endif /* _GLGUI_WIDGET_H */ |
---|