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
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"
[1853]11
[5690]12#include "glincl.h"
13#include "executor/executor.h"
14
[4838]15// FORWARD DECLARATION
[5365]16class Material;
[3543]17
[5391]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
[5387]31//! if the Element should be visible by default.
32#define GLGUI_WIDGET_DEFAULT_VISIBLE       false
33
[5384]34//! This is widget part of the openglGUI class
[5359]35/**
[5387]36 * A widget is the main class of all the elements of th GUI.
37 */
[5362]38class GLGuiWidget : public Element2D {
[5366]39  public:
40    GLGuiWidget();
41    virtual ~GLGuiWidget();
[2036]42
[5366]43    void init();
[5392]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) {};
[1853]48
[5366]49    void show();
[5456]50    void hide() {};
[5364]51
[5690]52    void connectSignal(GLGuiSignalType signalType, const Executor& signal);
[5392]53    void disconnectSignal(GLGuiSignalType signalType);
[5391]54    bool focusOverWidget(float x, float y);
[5364]55
[5391]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
[5366]63    virtual void update() = 0;
[6287]64    virtual void draw() const;
[1853]65
[5366]66  protected:
[6287]67    inline void startDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); };
68    inline void endDraw() const { glPopMatrix(); };
69
70  private:
[5387]71    Material*             backMat;
72    GLuint                backModel;
[3245]73
[5387]74    Material*             frontMat;
75    GLuint                frontModel;
76
[5395]77  private:
[5690]78    Executor*             widgetSignals[GLGuiSignalCount];
[5391]79
[5387]80    bool                  focusable;        //!< If this widget can receive focus.
81    bool                  clickable;        //!< if this widget can be clicked upon.
[1853]82};
83
[5362]84#endif /* _GLGUI_WIDGET_H */
Note: See TracBrowser for help on using the repository browser.