1 | /* |
---|
2 | orxonox - the future of 3D-vertical-scrollers |
---|
3 | |
---|
4 | Copyright (C) 2004 orx |
---|
5 | |
---|
6 | This program 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, or (at your option) |
---|
9 | any later version. |
---|
10 | |
---|
11 | ### File Specific: |
---|
12 | main-programmer: Benjamin Grauer |
---|
13 | co-programmer: ... |
---|
14 | */ |
---|
15 | |
---|
16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GUI |
---|
17 | |
---|
18 | #include "glgui_table.h" |
---|
19 | |
---|
20 | namespace OrxGui |
---|
21 | { |
---|
22 | /** |
---|
23 | * @brief standard constructor |
---|
24 | */ |
---|
25 | GLGuiTable::GLGuiTable () |
---|
26 | { |
---|
27 | this->init(); |
---|
28 | } |
---|
29 | |
---|
30 | |
---|
31 | /** |
---|
32 | * @brief standard deconstructor |
---|
33 | */ |
---|
34 | GLGuiTable::~GLGuiTable() |
---|
35 | {} |
---|
36 | |
---|
37 | /** |
---|
38 | * @brief initializes the GUI-element |
---|
39 | */ |
---|
40 | void GLGuiTable::init() |
---|
41 | { |
---|
42 | this->setClassID(CL_GLGUI_TABLE, "GLGuiTable"); |
---|
43 | |
---|
44 | this->setFocusable(true); |
---|
45 | this->setClickable(true); |
---|
46 | |
---|
47 | this->resize(); |
---|
48 | } |
---|
49 | |
---|
50 | |
---|
51 | void GLGuiTable::setRowCount(unsigned int rowCount) |
---|
52 | { |
---|
53 | this->_headers.resize(rowCount); |
---|
54 | for (unsigned int i = 0; i < rowCount; i++) |
---|
55 | this->_entries[i].resize(rowCount); |
---|
56 | |
---|
57 | if (!this->isVisible()) |
---|
58 | this->hiding(); |
---|
59 | } |
---|
60 | |
---|
61 | void GLGuiTable::setColumnCount(unsigned int columnCount) |
---|
62 | { |
---|
63 | this->_entries.resize(columnCount); |
---|
64 | if (!this->isVisible()) |
---|
65 | this->hiding(); |
---|
66 | } |
---|
67 | |
---|
68 | |
---|
69 | void GLGuiTable::setHeader(unsigned int number, const std::string& headerName) |
---|
70 | { |
---|
71 | if (number >= this->_headers.size()) |
---|
72 | this->setColumnCount(number + 1); |
---|
73 | this->_headers[number].setText(headerName); |
---|
74 | } |
---|
75 | |
---|
76 | void GLGuiTable::setHeader(const std::vector<std::string>& headerNames) |
---|
77 | { |
---|
78 | for (unsigned int i = 0; i < headerNames.size(); ++i) |
---|
79 | this->setHeader(i, headerNames[i]); |
---|
80 | } |
---|
81 | |
---|
82 | void GLGuiTable::setEntry(unsigned int column, unsigned int row, const std::string& name) |
---|
83 | { |
---|
84 | if (column >= this->columnCount() ) |
---|
85 | this->setColumnCount(column + 1); |
---|
86 | if (row >= this->rowCount() ) |
---|
87 | this->setRowCount(row + 1); |
---|
88 | this->_entries[row][column].setText(name); |
---|
89 | } |
---|
90 | |
---|
91 | void GLGuiTable::setColumnWidth(unsigned int column, float size) |
---|
92 | { |
---|
93 | this->_headers[column].setLineWidth(size); |
---|
94 | for (unsigned int i = 0; i < this->rowCount(); ++i) |
---|
95 | this->_entries[i][column].setLineWidth(size); |
---|
96 | |
---|
97 | } |
---|
98 | |
---|
99 | void GLGuiTable::setRowHeight(unsigned int row, unsigned int size) |
---|
100 | {} |
---|
101 | |
---|
102 | |
---|
103 | |
---|
104 | |
---|
105 | /** |
---|
106 | * removes the focus from this Widget. |
---|
107 | */ |
---|
108 | void GLGuiTable::removedFocus() |
---|
109 | { |
---|
110 | GLGuiWidget::removedFocus(); |
---|
111 | } |
---|
112 | |
---|
113 | |
---|
114 | |
---|
115 | /** |
---|
116 | * @brief Processes an Event. |
---|
117 | * @param event The event to be processed |
---|
118 | * @return true if the event was catched. |
---|
119 | */ |
---|
120 | bool GLGuiTable::processEvent(const Event& event) |
---|
121 | { |
---|
122 | return false; |
---|
123 | } |
---|
124 | |
---|
125 | |
---|
126 | /** |
---|
127 | * @brief Resizes the Widget to the new Size-constraints. |
---|
128 | */ |
---|
129 | void GLGuiTable::resize() |
---|
130 | { |
---|
131 | GLGuiWidget::resize(); |
---|
132 | } |
---|
133 | |
---|
134 | void GLGuiTable::updateFrontColor() |
---|
135 | { |
---|
136 | for (unsigned int i = 0; i < this->rowCount(); ++i) |
---|
137 | { |
---|
138 | this->_headers[i].setColor(this->foregroundColor()); |
---|
139 | for (unsigned int j = 0; j < this->columnCount(); ++j) |
---|
140 | this->_entries[i][j].setColor(this->foregroundColor()); |
---|
141 | } |
---|
142 | } |
---|
143 | |
---|
144 | void GLGuiTable::hiding() |
---|
145 | { |
---|
146 | for (unsigned int i = 0; i < this->rowCount(); ++i) |
---|
147 | { |
---|
148 | this->_headers[i].setVisibility(false); |
---|
149 | for (unsigned int j = 0; j < this->columnCount(); ++j) |
---|
150 | this->_entries[i][j].setVisibility(false); |
---|
151 | } |
---|
152 | } |
---|
153 | |
---|
154 | void GLGuiTable::showing() |
---|
155 | { |
---|
156 | for (unsigned int i = 0; i < this->rowCount(); ++i) |
---|
157 | { |
---|
158 | this->_headers[i].setVisibility(true); |
---|
159 | for (unsigned int j = 0; j < this->columnCount(); ++j) |
---|
160 | this->_entries[i][j].setVisibility(true); |
---|
161 | } |
---|
162 | } |
---|
163 | |
---|
164 | /** |
---|
165 | * @brief ticks the Table |
---|
166 | * @param dt the time passed. |
---|
167 | */ |
---|
168 | void GLGuiTable::tick(float dt) |
---|
169 | {} |
---|
170 | |
---|
171 | /** |
---|
172 | * @brief draws the GLGuiTable |
---|
173 | */ |
---|
174 | void GLGuiTable::draw() const |
---|
175 | { |
---|
176 | this->beginDraw(); |
---|
177 | GLGuiWidget::draw(); |
---|
178 | |
---|
179 | // this->frontMaterial().select(); |
---|
180 | // GLGuiWidget::drawRect(this->frontRect()); |
---|
181 | |
---|
182 | this->endDraw(); |
---|
183 | } |
---|
184 | } |
---|