=============== idEditField::Draw =============== */
| 534 | =============== |
| 535 | */ |
| 536 | void idEditField::Draw( int x, int y, int width, bool showCursor, const idMaterial *shader ) { |
| 537 | int len; |
| 538 | int drawLen; |
| 539 | int prestep; |
| 540 | int cursorChar; |
| 541 | char str[MAX_EDIT_LINE]; |
| 542 | int size; |
| 543 | |
| 544 | size = SMALLCHAR_WIDTH; |
| 545 | |
| 546 | drawLen = widthInChars; |
| 547 | len = strlen( buffer ) + 1; |
| 548 | |
| 549 | // guarantee that cursor will be visible |
| 550 | if ( len <= drawLen ) { |
| 551 | prestep = 0; |
| 552 | } else { |
| 553 | if ( scroll + drawLen > len ) { |
| 554 | scroll = len - drawLen; |
| 555 | if ( scroll < 0 ) { |
| 556 | scroll = 0; |
| 557 | } |
| 558 | } |
| 559 | prestep = scroll; |
| 560 | |
| 561 | // Skip color code |
| 562 | if ( idStr::IsColor( buffer + prestep ) ) { |
| 563 | prestep += 2; |
| 564 | } |
| 565 | if ( prestep > 0 && idStr::IsColor( buffer + prestep - 1 ) ) { |
| 566 | prestep++; |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | if ( prestep + drawLen > len ) { |
| 571 | drawLen = len - prestep; |
| 572 | } |
| 573 | |
| 574 | // extract <drawLen> characters from the field at <prestep> |
| 575 | if ( drawLen >= MAX_EDIT_LINE ) { |
| 576 | common->Error( "drawLen >= MAX_EDIT_LINE" ); |
| 577 | } |
| 578 | |
| 579 | memcpy( str, buffer + prestep, drawLen ); |
| 580 | str[ drawLen ] = 0; |
| 581 | |
| 582 | // draw it |
| 583 | renderSystem->DrawSmallStringExt( x, y, str, colorWhite, false, shader ); |
| 584 | |
| 585 | // draw the cursor |
| 586 | if ( !showCursor ) { |
| 587 | return; |
| 588 | } |
| 589 | |
| 590 | if ( (int)( com_ticNumber >> 4 ) & 1 ) { |
| 591 | return; // off blink |
| 592 | } |
| 593 |
nothing calls this directly
no test coverage detected