Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7422 was 7221, checked in by bensch, 19 years ago

orxonox/trunk: merged the std-branche back, it runs on windows and Linux

svn merge https://svn.orxonox.net/orxonox/branches/std . -r7202:HEAD

File size: 2.3 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 std::string& 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() {};
66    virtual void draw() const;
67
68    Material& backMaterial() { return this->backMat; };
69    Material& frontMaterial() { return this->frontMat; };
70
71  protected:
72    inline void startDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); };
73    inline void endDraw() const { glPopMatrix(); };
74
75  protected:
76    Material              backMat;
77    GLuint                backModel;
78
79    Material              frontMat;
80    GLuint                frontModel;
81
82  private:
83    Executor*             widgetSignals[GLGuiSignalCount];
84
85    bool                  focusable;        //!< If this widget can receive focus.
86    bool                  clickable;        //!< if this widget can be clicked upon.
87};
88
89#endif /* _GLGUI_WIDGET_H */
Note: See TracBrowser for help on using the repository browser.