* Adds a flashing | caret to the text * to show when it's focused and editable. */
| 297 | * to show when it's focused and editable. |
| 298 | */ |
| 299 | void 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 |
nothing calls this directly
no test coverage detected