Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/gui/src/lib/gui/gl_gui/glgui_widget.h @ 7893

Last change on this file since 7893 was 7893, checked in by bensch, 18 years ago

gui: InputLine appends

File size: 3.5 KB
Line 
1/*!
2 * @file glgui_widget.h
3 * The gl_widget of the openglGUI
4 */
5
6#ifndef _GLGUI_WIDGET_H
7#define _GLGUI_WIDGET_H
8
9#include "element_2d.h"
10#include "event.h"
11#include "material.h"
12
13#include "glincl.h"
14#include "signal_connector.h"
15
16// FORWARD DECLARATION
17class Material;
18
19namespace OrxGui
20{
21  typedef enum
22  {
23    Signal_click     = 0,
24    Signal_release,
25    Signal_rollOn,
26    Signal_rollOff,
27    Signal_open,
28    Signal_close,
29    Signal_destroy,
30
31    SignalCount,
32  } SignalType;
33
34
35  class GLGuiCursor;
36
37  //! if the Element should be visible by default.
38#define GLGUI_WIDGET_DEFAULT_VISIBLE       false
39
40  //! This is widget part of the openglGUI class
41  /**
42   * A widget is the main class of all the elements of th GUI.
43   */
44  class GLGuiWidget : public Element2D
45  {
46
47  private:
48
49  public:
50    GLGuiWidget();
51    virtual ~GLGuiWidget();
52
53    void show();
54    void hide();
55
56    /// INTERCONNECTIVITY
57    void connectSignal(SignalType signalType, BaseObject* obj, const Executor* signal);
58    void disconnectSignal(SignalType signalType);
59
60
61    /// FOCUS
62    /** @brief gives focus to this widget */
63    void giveFocus();
64    void breakFocus();
65    /** @returns true if the widget is focusable */
66    bool focusable() const { return this->_focusable; };
67    /** @param focusable sets if the Widget should be focusable */
68    void setFocusable(bool focusable = true) { this->_focusable = focusable; };
69    /** @returns true if the position is inside of the Widget. @param position the position to check */
70    bool focusOverWidget(const Vector2D& position) const;
71    /** @brief overloaded function, that returns true if the cursor is on top of the Widget */
72    bool focusOverWidget(const OrxGui::GLGuiCursor* const cursor) const;
73
74    /** @returns the currently focused Widget (NULL if none is selected) */
75    static GLGuiWidget* focused() { return GLGuiWidget::_focused; };
76
77
78    /// CLICK
79    void click();
80    void release();
81    bool clickable() const { return this->_clickable; };
82    void setClickable(bool clickable = true) { this->_clickable = clickable; };
83
84    virtual void update() {};
85    virtual void draw() const;
86
87
88    /// MATERIAL (looks)
89    Material& backMaterial() { return this->backMat; };
90    const Material& backMaterial() const { return this->backMat; };
91
92    Material& frontMaterial() { return this->frontMat; };
93    const Material& frontMaterial() const { return this->frontMat; };
94
95    /** @param the Event to process. @returns true if the Event has been consumed*/
96    virtual bool processEvent(const Event& event) { };
97
98
99
100  protected:
101        // if something was clickt on the GUI-widget.
102    virtual void clicked() {};
103    virtual void released() {};
104
105    virtual void receivedFocus() {};
106    virtual void removedFocus() {};
107
108    virtual void destroyed() {};
109
110
111    inline void startDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); };
112    inline void endDraw() const { glPopMatrix(); };
113
114  private:
115    void init();
116
117
118  protected:
119    Material                       backMat;
120    GLuint                         backModel;
121
122    Material                       frontMat;
123    GLuint                         frontModel;
124
125  private:
126    std::vector<SignalConnector>   widgetSignals;
127
128    bool                           _focusable;        //!< If this widget can receive focus.
129    bool                           _clickable;        //!< if this widget can be clicked upon.
130
131    bool                           _pushed;
132
133    static GLGuiWidget*            _focused;
134    static GLGuiWidget*            _inputGrabber;
135  };
136}
137#endif /* _GLGUI_WIDGET_H */
Note: See TracBrowser for help on using the repository browser.