00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #if !defined(AFX_GLWIDGET_H__3F7BC394_576B_4ADF_8771_7D97EB3AF314__INCLUDED_)
00022 #define AFX_GLWIDGET_H__3F7BC394_576B_4ADF_8771_7D97EB3AF314__INCLUDED_
00023
00024 #include <engine/MetaClass.h>
00025 #include <common/KeyboardHistory.h>
00026
00027 class XMLNode;
00028 class ToolTip;
00029 class GLWPanel;
00030
00031
00032
00033
00034
00035 class GLWidget : public MetaClass
00036 {
00037 public:
00038 GLWidget(float x = 0.0f, float y = 0.0f,
00039 float w = 0.0f, float h = 0.0f);
00040 virtual ~GLWidget();
00041
00042
00043 virtual void draw();
00044 virtual void simulate(float frameTime);
00045 virtual void mouseDown(int button, float x, float y, bool &skipRest);
00046 virtual void mouseUp(int button, float x, float y, bool &skipRest);
00047 virtual void mouseDrag(int button, float mx, float my, float x, float y, bool &skipRest);
00048 virtual void keyDown(char *buffer, unsigned int keyState,
00049 KeyboardHistory::HistoryElement *history, int hisCount,
00050 bool &skipRest);
00051 virtual void mouseWheel(float x, float y, float z, bool &skipRest);
00052 virtual void display();
00053 virtual void hide();
00054
00055
00056 unsigned int getId() { return id_; }
00057 virtual bool initFromXML(XMLNode *node);
00058 virtual void setToolTip(ToolTip *tooltip) { tooltip_ = tooltip; }
00059 virtual void setParent(GLWPanel *parent);
00060 virtual GLWPanel *getParent() { return parent_; }
00061 virtual void layout();
00062 void setVisible(bool visible) { visible_ = visible; }
00063 bool getVisible() { return visible_; }
00064 void setUserData(void *data) { userData_ = data; }
00065 void *getUserData() { return userData_; }
00066
00067 virtual const char *getName() { return name_.c_str(); }
00068 virtual void setName(const std::string &name) { name_ = name; }
00069
00070
00071 virtual float getX() { return x_; }
00072 virtual float getY() { return y_; }
00073 virtual float getW() { return w_; }
00074 virtual float getH() { return h_; }
00075 virtual void setX(float x) { x_ = x; }
00076 virtual void setY(float y) { y_ = y; }
00077 virtual void setW(float w) { w_ = w; }
00078 virtual void setH(float h) { h_ = h; }
00079
00080
00081 static bool inBox(float posX, float posY, float x, float y, float w, float h);
00082 static void drawRoundBox(float x, float y, float w, float h, float size);
00083 static void drawShadedRoundBox(float x, float y, float w, float h, float size, bool depressed);
00084 static void drawCircle(int startA, int endA, float posX, float posY, float size);
00085 static void drawWholeCircle(bool cap = false);
00086 static void drawBox(float x, float y, float w, float h, bool depressed);
00087
00088 protected:
00089 static unsigned int nextId_;
00090 std::string name_;
00091 unsigned int id_;
00092 float x_, y_, w_, h_;
00093 ToolTip *tooltip_;
00094 bool tooltipTransparent_;
00095 bool visible_;
00096 GLWPanel *parent_;
00097 void *userData_;
00098
00099 };
00100
00101
00102
00103
00104
00105
00106 class GLWCondition : public MetaClass
00107 {
00108 public:
00109 GLWCondition();
00110 virtual ~GLWCondition();
00111
00112 virtual bool getResult(GLWidget *widget) = 0;
00113 virtual bool initFromXML(XMLNode *node);
00114 };
00115
00116 #endif // !defined(AFX_GLWIDGET_H__3F7BC394_576B_4ADF_8771_7D97EB3AF314__INCLUDED_)