Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

gui: added timer class for a more exact time

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