Changeset 8616 in orxonox.OLD for branches/gui
- Timestamp:
- Jun 20, 2006, 12:51:20 PM (18 years ago)
- Location:
- branches/gui/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/src/lib/gui/gl/glgui.h
r8145 r8616 16 16 #include "glgui_button.h" 17 17 #include "glgui_checkbutton.h" 18 //#include "glgui_colorselector.h"19 18 #include "glgui_pushbutton.h" 20 19 #include "glgui_slider.h" … … 22 21 #include "glgui_inputline.h" 23 22 #include "glgui_textfield.h" 23 #include "glgui_table.h" 24 24 #include "glgui_image.h" 25 25 -
branches/gui/src/lib/gui/gl/glgui_table.cc
r8615 r8616 17 17 18 18 #include "glgui_table.h" 19 #include "debug.h" 19 20 20 21 namespace OrxGui … … 23 24 * @brief standard constructor 24 25 */ 25 GLGuiTable::GLGuiTable ( )26 GLGuiTable::GLGuiTable (unsigned int rows, unsigned int columns) 26 27 { 27 28 this->init(); 29 this->setRowCount(rows); 30 this->setColumnCount(columns); 28 31 } 29 32 … … 51 54 void GLGuiTable::setRowCount(unsigned int rowCount) 52 55 { 53 this->_headers.resize(rowCount); 54 for (unsigned int i = 0; i < rowCount; i++) 55 this->_entries[i].resize(rowCount); 56 57 unsigned int currentRowCount = this->rowCount(); 58 this->_entries.resize(rowCount); 59 for (unsigned int i = currentRowCount; i < this->rowCount(); ++i) 60 this->_entries[i].resize(columnCount(), LimitedWidthText("fonts/final_frontier.ttf", 20)); 61 62 assert(this->checkIntegrity()); 63 this->debug(); 56 64 57 65 if (!this->isVisible()) … … 61 69 void GLGuiTable::setColumnCount(unsigned int columnCount) 62 70 { 63 this->_entries.resize(columnCount); 71 this->_headers.resize(columnCount, LimitedWidthText("fonts/final_frontier.ttf", 20)); 72 for (unsigned int i = 0; i < rowCount(); i++) 73 this->_entries[i].resize(columnCount, LimitedWidthText("fonts/final_frontier.ttf", 20)); 74 75 assert(this->checkIntegrity()); 76 this->debug(); 77 64 78 if (!this->isVisible()) 65 79 this->hiding(); … … 69 83 void GLGuiTable::setHeader(unsigned int number, const std::string& headerName) 70 84 { 71 if (number >= this-> _headers.size())85 if (number >= this->columnCount()) 72 86 this->setColumnCount(number + 1); 73 87 this->_headers[number].setText(headerName); … … 97 111 } 98 112 113 /// TODO. 99 114 void GLGuiTable::setRowHeight(unsigned int row, unsigned int size) 100 115 {} 101 116 102 117 … … 134 149 void GLGuiTable::updateFrontColor() 135 150 { 136 for (unsigned int i = 0; i < this-> rowCount(); ++i)151 for (unsigned int i = 0; i < this->columnCount(); ++i) 137 152 { 138 153 this->_headers[i].setColor(this->foregroundColor()); 139 for (unsigned int j = 0; j < this-> columnCount(); ++j)140 this->_entries[ i][j].setColor(this->foregroundColor());154 for (unsigned int j = 0; j < this->rowCount(); ++j) 155 this->_entries[j][i].setColor(this->foregroundColor()); 141 156 } 142 157 } … … 144 159 void GLGuiTable::hiding() 145 160 { 146 for (unsigned int i = 0; i < this-> rowCount(); ++i)161 for (unsigned int i = 0; i < this->columnCount(); ++i) 147 162 { 148 163 this->_headers[i].setVisibility(false); 149 for (unsigned int j = 0; j < this-> columnCount(); ++j)150 this->_entries[ i][j].setVisibility(false);164 for (unsigned int j = 0; j < this->rowCount(); ++j) 165 this->_entries[j][i].setVisibility(false); 151 166 } 152 167 } … … 154 169 void GLGuiTable::showing() 155 170 { 156 for (unsigned int i = 0; i < this-> rowCount(); ++i)171 for (unsigned int i = 0; i < this->columnCount(); ++i) 157 172 { 158 173 this->_headers[i].setVisibility(true); 159 for (unsigned int j = 0; j < this->columnCount(); ++j) 160 this->_entries[i][j].setVisibility(true); 161 } 162 } 174 for (unsigned int j = 0; j < this->rowCount(); ++j) 175 this->_entries[j][i].setVisibility(true); 176 } 177 } 178 163 179 164 180 /** … … 182 198 this->endDraw(); 183 199 } 200 201 void GLGuiTable::debug() const 202 { 203 PRINT(0)("Table: Size = %dx%d\n", this->rowCount(), this->columnCount()); 204 205 for (unsigned int i = 0; i < this->rowCount(); ++i) 206 PRINT(0)("line %d: columns %d\n", i, this->_entries[i].size()); 207 } 208 209 210 bool GLGuiTable::checkIntegrity() const 211 { 212 bool retVal = true; 213 if (rowCount() != this->_entries.size()) 214 { 215 PRINTF(1)("ROW COUNT WRONG (is %d should be %d)\n", rowCount(), this->_entries.size()); 216 retVal = false; 217 } 218 if (columnCount() != this->_headers.size()) 219 { 220 PRINTF(1)("COLUMN COUNT WRONG (is %d should be %d)\n", columnCount(), this->_headers.size()); 221 retVal = false; 222 } 223 for (unsigned int i = 0; i < this->rowCount(); ++i) 224 if (this->_entries[i].size() != this->columnCount()) 225 { 226 PRINTF(1)("COLUMN-COUNT OF ROW %d WRONG (is %d should be %d)\n", i, this->_entries[i].size(), this->columnCount()); 227 retVal = false; 228 } 229 return retVal; 230 } 231 184 232 } -
branches/gui/src/lib/gui/gl/glgui_table.h
r8615 r8616 27 27 28 28 public: 29 GLGuiTable( );29 GLGuiTable(unsigned int rows, unsigned int columns); 30 30 virtual ~GLGuiTable(); 31 31 32 unsigned int rowCount() const { return this->_entries.size(); }; 32 33 unsigned int columnCount() const { return this->_headers.size(); }; 33 unsigned int rowCount() const { return this->_entries.size(); };34 //const std::vector<std::string>& headers() const { return this->_headers; };35 //const std::vector<std::vector<std::string> >& entries() const { return this->_entries; };36 34 37 35 void setRowCount(unsigned int rowCount); … … 50 48 51 49 50 void debug() const; 51 52 52 protected: 53 53 virtual void removedFocus(); … … 64 64 void init(); 65 65 66 bool checkIntegrity() const; 67 66 68 private: 67 69 typedef std::vector<LimitedWidthText> TableTextList; -
branches/gui/src/story_entities/simple_game_menu.cc
r8583 r8616 123 123 slider->setValue(slider->min()); 124 124 box->pack(slider); 125 126 127 OrxGui::GLGuiTable* table = new OrxGui::GLGuiTable(3, 3); 128 std::vector<std::string> headers; 129 headers.push_back("1"); 130 headers.push_back("2"); 131 headers.push_back("3"); 132 table->setHeader(headers); 133 134 135 box->pack(table); 125 136 } 126 137 box->setAbsCoor2D(50, 200);
Note: See TracChangeset
for help on using the changeset viewer.