MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / draw

Method draw

src/Interface/TextButton.cpp:199–261  ·  view source on GitHub ↗

* Draws the labeled button. * The colors are inverted if the button is pressed. */

Source from the content-addressed store, hash-verified

197 * The colors are inverted if the button is pressed.
198 */
199void TextButton::draw()
200{
201 Surface::draw();
202 SDL_Rect square;
203
204 int mul = 1;
205 if (_contrast)
206 {
207 mul = 2;
208 }
209
210 int color = _color + 1 * mul;
211
212 square.x = 0;
213 square.y = 0;
214 square.w = getWidth();
215 square.h = getHeight();
216
217 for (int i = 0; i < 5; ++i)
218 {
219 drawRect(&square, color);
220
221 if (i % 2 == 0)
222 {
223 square.x++;
224 square.y++;
225 }
226 square.w--;
227 square.h--;
228
229 switch (i)
230 {
231 case 0:
232 color = _color + 5 * mul;
233 setPixel(square.w, 0, color);
234 break;
235 case 1:
236 color = _color + 2 * mul;
237 break;
238 case 2:
239 color = _color + 4 * mul;
240 setPixel(square.w+1, 1, color);
241 break;
242 case 3:
243 color = _color + 3 * mul;
244 break;
245 }
246 }
247
248 bool press;
249 if (_group == 0)
250 press = isButtonPressed();
251 else
252 press = (*_group == this);
253
254 if (press)
255 {
256 this->invert(_color + 3 * mul);

Callers 1

mousePressMethod · 0.45

Calls 3

invertMethod · 0.80
setInvertMethod · 0.45
blitMethod · 0.45

Tested by

no test coverage detected