| 395 | } |
| 396 | |
| 397 | void CListBox::OnDraw(float alpha) |
| 398 | { |
| 399 | const int w = GLOB_ENGINE->Width2D(); |
| 400 | const int h = GLOB_ENGINE->Height2D(); |
| 401 | |
| 402 | float xx = toInt(_x * w) + 0.5; |
| 403 | float yy = toInt(_y * h) + 0.5; |
| 404 | float ww = toInt(_w * w); |
| 405 | float hh = toInt(_h * h); |
| 406 | |
| 407 | PackedColor ftColor = ModAlpha(_ftColor, alpha); |
| 408 | PackedColor selColor = ModAlpha(_selColor, alpha); |
| 409 | |
| 410 | // draw list |
| 411 | DrawRect(xx, yy, xx + ww, yy + hh, ftColor); |
| 412 | |
| 413 | // draw scrollbar |
| 414 | Rect2DFloat rect(_x, _y, _w, _h); |
| 415 | if (GetSize() > _showStrings) |
| 416 | { |
| 417 | _scrollbar.Enable(true); |
| 418 | _scrollbar.SetPosition((_x + _w - sbWidth) * _scale, _y * _scale, sbWidth * _scale, _h * _scale); |
| 419 | _scrollbar.SetRange(0, GetSize(), _showStrings); |
| 420 | _scrollbar.SetPos(_topString); |
| 421 | _scrollbar.OnDraw(alpha); |
| 422 | rect.w -= sbWidth; |
| 423 | } |
| 424 | else |
| 425 | { |
| 426 | _scrollbar.Enable(false); |
| 427 | } |
| 428 | int i = toIntFloor(_topString); |
| 429 | float top = _y - (_topString - i) * _rowHeight; |
| 430 | bool canSelect = IsEnabled() /* && !IsReadOnly()*/; |
| 431 | while (top < _y + _h && i < GetSize()) |
| 432 | { |
| 433 | DrawItem(alpha, i, i == GetCurSel() && canSelect, top, rect); |
| 434 | top += _rowHeight; |
| 435 | i++; |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | void CListBox::DrawItem(float alpha, int i, bool selected, float top, Rect2DFloat& rect) |
| 440 | { |
nothing calls this directly
no test coverage detected