Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/gui/gl_gui/glgui_widget.h @ 6287

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

orxonox/trunk: some gui-work

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