Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: new GUI-functionality

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 "material.h"
13
14#include "glincl.h"
15#include "executor/executor.h"
16
17// FORWARD DECLARATION
18class Material;
19
20typedef enum
21{
22  GLGuiSignal_click     = 0,
23  GLGuiSignal_release,
24  GLGuiSignal_rollOn,
25  GLGuiSignal_rollOff,
26  GLGuiSignal_open,
27  GLGuiSignal_close,
28  GLGuiSignal_destroy,
29
30  GLGuiSignalCount,
31} GLGuiSignalType;
32
33//! if the Element should be visible by default.
34#define GLGUI_WIDGET_DEFAULT_VISIBLE       false
35
36//! This is widget part of the openglGUI class
37/**
38 * A widget is the main class of all the elements of th GUI.
39 */
40class GLGuiWidget : public Element2D {
41  public:
42    GLGuiWidget();
43    virtual ~GLGuiWidget();
44
45    void init();
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) {};
50
51    void show();
52    void hide() {};
53
54    void connectSignal(GLGuiSignalType signalType, const Executor& signal);
55    void disconnectSignal(GLGuiSignalType signalType);
56    bool focusOverWidget(float x, float y);
57
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
65    virtual void update() = 0;
66    virtual void draw() const;
67
68  protected:
69    inline void startDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); };
70    inline void endDraw() const { glPopMatrix(); };
71
72  protected:
73    Material              backMat;
74    GLuint                backModel;
75
76    Material              frontMat;
77    GLuint                frontModel;
78
79  private:
80    Executor*             widgetSignals[GLGuiSignalCount];
81
82    bool                  focusable;        //!< If this widget can receive focus.
83    bool                  clickable;        //!< if this widget can be clicked upon.
84};
85
86#endif /* _GLGUI_WIDGET_H */
Note: See TracBrowser for help on using the repository browser.