| 6603 | */ |
| 6604 | |
| 6605 | void Item_ListBox_Paint(itemDef_t *item) |
| 6606 | { |
| 6607 | float x, y, size; |
| 6608 | int count, i, thumb; |
| 6609 | qhandle_t image; |
| 6610 | qhandle_t optionalImage; |
| 6611 | listBoxDef_t *listPtr = (listBoxDef_t*)item->typeData; |
| 6612 | |
| 6613 | // the listbox is horizontal or vertical and has a fixed size scroll bar going either direction |
| 6614 | // elements are enumerated from the DC and either text or image handles are acquired from the DC as well |
| 6615 | // textscale is used to size the text, textalignx and textaligny are used to size image elements |
| 6616 | // there is no clipping available so only the last completely visible item is painted |
| 6617 | count = DC->feederCount(item->special); |
| 6618 | |
| 6619 | if (listPtr->startPos > (count?count-1:count)) |
| 6620 | {//probably changed feeders, so reset |
| 6621 | listPtr->startPos = 0; |
| 6622 | } |
| 6623 | |
| 6624 | if (item->cursorPos > (count?count-1:count)) |
| 6625 | {//probably changed feeders, so reset |
| 6626 | item->cursorPos = 0; |
| 6627 | } |
| 6628 | // default is vertical if horizontal flag is not here |
| 6629 | if (item->window.flags & WINDOW_HORIZONTAL) |
| 6630 | { |
| 6631 | //JLF new variable (code just indented) |
| 6632 | if (!listPtr->scrollhidden) |
| 6633 | { |
| 6634 | // draw scrollbar in bottom of the window |
| 6635 | // bar |
| 6636 | if (Item_ListBox_MaxScroll(item) > 0) |
| 6637 | { |
| 6638 | x = item->window.rect.x + 1; |
| 6639 | y = item->window.rect.y + item->window.rect.h - SCROLLBAR_SIZE - 1; |
| 6640 | DC->drawHandlePic(x, y, SCROLLBAR_SIZE, SCROLLBAR_SIZE, DC->Assets.scrollBarArrowLeft); |
| 6641 | x += SCROLLBAR_SIZE - 1; |
| 6642 | size = item->window.rect.w - (SCROLLBAR_SIZE * 2); |
| 6643 | DC->drawHandlePic(x, y, size+1, SCROLLBAR_SIZE, DC->Assets.scrollBar); |
| 6644 | x += size - 1; |
| 6645 | DC->drawHandlePic(x, y, SCROLLBAR_SIZE, SCROLLBAR_SIZE, DC->Assets.scrollBarArrowRight); |
| 6646 | // thumb |
| 6647 | thumb = Item_ListBox_ThumbDrawPosition(item);//Item_ListBox_ThumbPosition(item); |
| 6648 | if (thumb > x - SCROLLBAR_SIZE - 1) |
| 6649 | { |
| 6650 | thumb = x - SCROLLBAR_SIZE - 1; |
| 6651 | } |
| 6652 | DC->drawHandlePic(thumb, y, SCROLLBAR_SIZE, SCROLLBAR_SIZE, DC->Assets.scrollBarThumb); |
| 6653 | } |
| 6654 | else if (listPtr->startPos > 0) |
| 6655 | { |
| 6656 | listPtr->startPos = 0; |
| 6657 | } |
| 6658 | } |
| 6659 | //JLF end |
| 6660 | // |
| 6661 | listPtr->endPos = listPtr->startPos; |
| 6662 | size = item->window.rect.w - 2; |
no test coverage detected