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

Method draw

src/Interface/TextEdit.cpp:299–339  ·  view source on GitHub ↗

* Adds a flashing | caret to the text * to show when it's focused and editable. */

Source from the content-addressed store, hash-verified

297 * to show when it's focused and editable.
298 */
299void TextEdit::draw()
300{
301 Surface::draw();
302 _text->setText(_value);
303 if (Options::keyboardMode == KEYBOARD_OFF)
304 {
305 std::wstring newValue = _value;
306 if (_isFocused && _blink)
307 {
308 newValue += _ascii;
309 _text->setText(newValue);
310 }
311 }
312 clear();
313 _text->blit(this);
314 if (Options::keyboardMode == KEYBOARD_ON)
315 {
316 if (_isFocused && _blink)
317 {
318 int x = 0;
319 switch (_text->getAlign())
320 {
321 case ALIGN_LEFT:
322 x = 0;
323 break;
324 case ALIGN_CENTER:
325 x = (_text->getWidth() - _text->getTextWidth()) / 2;
326 break;
327 case ALIGN_RIGHT:
328 x = _text->getWidth() - _text->getTextWidth();
329 break;
330 }
331 for (size_t i = 0; i < _caretPos; ++i)
332 {
333 x += _text->getFont()->getCharSize(_value[i]).w;
334 }
335 _caret->setX(x);
336 _caret->blit(this);
337 }
338 }
339}
340
341/**
342 * Checks if adding a certain character to

Callers

nothing calls this directly

Calls 8

getAlignMethod · 0.80
getTextWidthMethod · 0.80
getCharSizeMethod · 0.80
setTextMethod · 0.45
blitMethod · 0.45
getWidthMethod · 0.45
getFontMethod · 0.45
setXMethod · 0.45

Tested by

no test coverage detected