1 //////////////////////////////////////////////////////////////////////////////// 2 // Scorched3D (c) 2000-2011 3 // 4 // This file is part of Scorched3D. 5 // 6 // Scorched3D is free software; you can redistribute it and/or modify 7 // it under the terms of the GNU General Public License as published by 8 // the Free Software Foundation; either version 2 of the License, or 9 // (at your option) any later version. 10 // 11 // Scorched3D is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU General Public License for more details. 15 // 16 // You should have received a copy of the GNU General Public License along 17 // with this program; if not, write to the Free Software Foundation, Inc., 18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 //////////////////////////////////////////////////////////////////////////////// 20 21 #if !defined(AFX_GLWPANEL_H__6619410E_0A6B_459B_8A38_11024F49A6E3__INCLUDED_) 22 #define AFX_GLWPANEL_H__6619410E_0A6B_459B_8A38_11024F49A6E3__INCLUDED_ 23 24 #include <list> 25 #include <GLW/GLWidget.h> 26 27 /** 28 A container widget for other widgets. 29 Also controls how widgets are layed out. 30 **/ 31 class GLWPanel : public GLWidget 32 { 33 public: 34 enum LayoutFlags 35 { 36 SpaceRight = 1, 37 SpaceLeft = 2, 38 SpaceTop = 4, 39 SpaceBottom = 8, 40 SpaceAll = 16, 41 AlignLeft = 32, 42 AlignRight = 64, 43 AlignCenterLeftRight = 128, 44 AlignTop = 256, 45 AlignBottom = 512, 46 AlignCenterTopBottom = 1024 47 }; 48 enum LayoutType 49 { 50 LayoutNone, 51 LayoutHorizontal, 52 LayoutVerticle, 53 LayoutGrid 54 }; 55 56 struct GLWPanelEntry 57 { 58 GLWPanelEntry(GLWidget *widget, GLWCondition *con, 59 unsigned int flags, float width); 60 61 GLWidget *widget; 62 GLWCondition *condition; 63 float leftSpace; 64 float rightSpace; 65 float topSpace; 66 float bottomSpace; 67 unsigned flags; 68 }; 69 70 GLWPanel(float x = 0.0f, float y = 0.0f, 71 float w = 0.0f, float h = 0.0f, 72 bool depressed = false, 73 bool visible = true, 74 bool ridge = false); 75 virtual ~GLWPanel(); 76 77 virtual void simulate(float frameTime); 78 virtual void draw(); 79 virtual void mouseDown(int button, float x, float y, bool &skipRest); 80 virtual void mouseUp(int button, float x, float y, bool &skipRest); 81 virtual void mouseDrag(int button, float mx, float my, float x, float y, bool &skipRest); 82 virtual void keyDown(char *buffer, unsigned int keyState, 83 KeyboardHistory::HistoryElement *history, int hisCount, 84 bool &skipRest); 85 virtual void mouseWheel(float x, float y, float z, bool &skipRest); 86 virtual void display(); 87 virtual void hide(); 88 89 virtual bool initFromXML(XMLNode *node); 90 virtual void saveSettings(XMLNode *node); 91 virtual void loadSettings(XMLNode *node, bool resetPositions); 92 virtual void clear(); 93 virtual void layout(); 94 95 virtual void setLayout(unsigned int layout); 96 virtual unsigned int getLayout(); 97 virtual void setGridWidth(unsigned int grid); 98 virtual unsigned int getGridWidth(); 99 100 GLWidget *addWidget(GLWidget *widget, GLWCondition *condition = 0, 101 unsigned int flags = 0, 102 float width = 0.0f); getWidgets()103 std::list<GLWPanelEntry> &getWidgets() { return widgets_; } 104 GLWidget *getWidgetByName(const char *name); 105 106 REGISTER_CLASS_HEADER(GLWPanel); 107 108 // Accessors getDrawPanel()109 bool &getDrawPanel() { return drawPanel_; } 110 111 protected: 112 std::list<GLWPanelEntry> widgets_; 113 bool depressed_; 114 bool drawPanel_; 115 bool ridge_; 116 unsigned int layout_; 117 unsigned int gridWidth_; 118 119 }; 120 121 #endif // !defined(AFX_GLWPANEL_H__6619410E_0A6B_459B_8A38_11024F49A6E3__INCLUDED_) 122