GLWidget.h

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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 A base class for al GL Widgets.
00033 Defines the interface.
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         // The widgets implementation
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         // Accessors
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         // Width, height and position functions
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         // Helper Functions
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 Class that defines a GL Widget Condition.
00103 A condition is an expression that evaluates to true or false
00104 and determines if the associated widget should be drawn.
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_)

Generated on Mon Feb 16 15:14:45 2009 for Scorched3D by  doxygen 1.5.3