Changeset 9656 in orxonox.OLD for trunk/src/lib/gui/gl/glgui_box.cc
- Timestamp:
- Aug 4, 2006, 11:01:28 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/gui/gl/glgui_box.cc
r9110 r9656 18 18 #include "glgui_box.h" 19 19 #include <cassert> 20 #include "debug.h" 20 21 21 22 namespace OrxGui … … 36 37 */ 37 38 GLGuiBox::~GLGuiBox() 38 {} 39 { 40 // unpack all the widgets. 41 while(!this->_children.empty()) 42 { 43 /// not deleting children here. 44 this->_children.front()->setParentWidget(NULL); 45 this->_children.pop_front(); 46 } 47 } 39 48 40 49 /** … … 49 58 { 50 59 assert (widget != NULL); 51 52 this->children.push_back(widget); 60 this->_children.push_back(widget); 61 62 this->packing(widget); 63 } 64 65 66 void GLGuiBox::pack(GLGuiWidget* widget, std::list<GLGuiWidget*>::iterator pos) 67 { 68 this->_children.insert(pos, widget); 69 this->packing(widget); 70 } 71 72 void GLGuiBox::pack(GLGuiWidget* widget, unsigned int position) 73 { 74 if (this->_children.empty()) 75 this->pack(widget); 76 77 unsigned int pos = 0; 78 std::list<GLGuiWidget*>::iterator it = this->_children.begin(); 79 80 for (; pos < position; ++pos) 81 { 82 if (this->_children.end() == ++it) 83 { 84 PRINTF(2)("Reached end of packing list, without getting to the designated position %d (i am at %d)\n", position, pos); 85 this->pack(widget); 86 } 87 } 88 this->_children.insert(it, widget); 89 this->packing(widget); 90 } 91 92 void GLGuiBox::pack(GLGuiWidget* widget, const GLGuiWidget* widgetPointer) 93 { 94 assert (widget != NULL && widgetPointer != NULL); 95 96 std::list<GLGuiWidget*>::iterator it = this->_children.begin(); 97 for (; it != this->_children.end(); ++it) 98 { 99 if (widgetPointer == *it) 100 { 101 this->_children.insert(it, widget); 102 this->packing(widget); 103 return; 104 } 105 } 106 PRINTF(2)("WidgetPointer %p not found, inserting at the end\n", widgetPointer); 107 this->pack(widget); 108 } 109 110 void GLGuiBox::packFront(GLGuiWidget* widget) 111 { 112 this->_children.push_front(widget); 113 this->packing(widget); 114 } 115 116 void GLGuiBox::packBack(GLGuiWidget* widget) 117 { 118 this->pack(widget); 119 } 120 121 void GLGuiBox::packing(GLGuiWidget* widget) 122 { 53 123 widget->setParentWidget(this); 54 55 124 this->resize(); 56 125 } 57 126 58 59 127 void GLGuiBox::unpack(GLGuiWidget* widget) 60 128 { 61 129 assert(widget != NULL); 62 130 63 std:: vector<GLGuiWidget*>::iterator delWidget = std::find(this->children.begin(), this->children.end(), widget);64 if (delWidget != this-> children.end())131 std::list<GLGuiWidget*>::iterator delWidget = std::find(this->_children.begin(), this->_children.end(), widget); 132 if (delWidget != this->_children.end()) 65 133 { 66 134 (*delWidget)->setParentWidget(NULL); 67 this-> children.erase(delWidget);135 this->_children.erase(delWidget); 68 136 } 69 137 this->resize(); … … 72 140 void GLGuiBox::clear() 73 141 { 74 this-> children.clear();142 this->_children.clear(); 75 143 this->resize(); 76 144 } … … 78 146 void GLGuiBox::showAll() 79 147 { 80 std:: vector<GLGuiWidget*>::iterator itC = this->children.begin();81 while (itC != this-> children.end())148 std::list<GLGuiWidget*>::iterator itC = this->_children.begin(); 149 while (itC != this->_children.end()) 82 150 { 83 151 if ((*itC)->isA(CL_GLGUI_CONTAINER)) … … 93 161 void GLGuiBox::hideAll() 94 162 { 95 std:: vector<GLGuiWidget*>::iterator itC = this->children.begin();96 while (itC != this-> children.end())163 std::list<GLGuiWidget*>::iterator itC = this->_children.begin(); 164 while (itC != this->_children.end()) 97 165 { 98 166 if ((*itC)->isA(CL_GLGUI_CONTAINER)) … … 112 180 float height = borderTop(); 113 181 float width = 0.0f; 114 std:: vector<GLGuiWidget*>::iterator widget;182 std::list<GLGuiWidget*>::iterator widget; 115 183 116 184 // find out how big the Widgets are. 117 for (widget = this-> children.begin(); widget != this->children.end(); ++widget)185 for (widget = this->_children.begin(); widget != this->_children.end(); ++widget) 118 186 { 119 187 (*widget)->setRelCoor2D(borderLeft(), height); … … 131 199 float height = borderTop(); 132 200 float width = borderLeft(); 133 std:: vector<GLGuiWidget*>::iterator widget;201 std::list<GLGuiWidget*>::iterator widget; 134 202 135 203 // find out how big the Widgets are. 136 for (widget = this-> children.begin(); widget != this->children.end(); ++widget)204 for (widget = this->_children.begin(); widget != this->_children.end(); ++widget) 137 205 { 138 206 (*widget)->setRelCoor2D(width, borderTop()); … … 149 217 150 218 // resize everything. 151 //for (widget = this-> children.begin(); widget != this->children.end(); ++widget)219 //for (widget = this->_children.begin(); widget != this->_children.end(); ++widget) 152 220 //{} 153 221 }
Note: See TracChangeset
for help on using the changeset viewer.