* Calculates the starting X position for a line of text. * @param line The line number (0 = first, etc). * @return The X position in pixels. */
| 461 | * @return The X position in pixels. |
| 462 | */ |
| 463 | int Text::getLineX(int line) const |
| 464 | { |
| 465 | int x = 0; |
| 466 | switch (_lang->getTextDirection()) |
| 467 | { |
| 468 | case DIRECTION_LTR: |
| 469 | switch (_align) |
| 470 | { |
| 471 | case ALIGN_LEFT: |
| 472 | break; |
| 473 | case ALIGN_CENTER: |
| 474 | x = (int)ceil((getWidth() + _font->getSpacing() - _lineWidth[line]) / 2.0); |
| 475 | break; |
| 476 | case ALIGN_RIGHT: |
| 477 | x = getWidth() - 1 - _lineWidth[line]; |
| 478 | break; |
| 479 | } |
| 480 | break; |
| 481 | case DIRECTION_RTL: |
| 482 | switch (_align) |
| 483 | { |
| 484 | case ALIGN_LEFT: |
| 485 | x = getWidth() - 1; |
| 486 | break; |
| 487 | case ALIGN_CENTER: |
| 488 | x = getWidth() - (int)ceil((getWidth() + _font->getSpacing() - _lineWidth[line]) / 2.0); |
| 489 | break; |
| 490 | case ALIGN_RIGHT: |
| 491 | x = _lineWidth[line]; |
| 492 | break; |
| 493 | } |
| 494 | break; |
| 495 | } |
| 496 | return x; |
| 497 | } |
| 498 | |
| 499 | namespace |
| 500 | { |
nothing calls this directly
no test coverage detected