behavior when gadget is being drawn.
| 618 | |
| 619 | // behavior when gadget is being drawn. |
| 620 | void UIListBox::OnDraw() { |
| 621 | bool use_scroll = !(m_Flags & UILB_NOSCROLL); |
| 622 | bool auto_select = ((m_Flags & UILB_AUTOSELECT) > 0); |
| 623 | UITextItem uarrow; |
| 624 | UITextItem darrow; |
| 625 | char arrowbuf[2]; |
| 626 | |
| 627 | if (m_Flags & UIF_BORDER) |
| 628 | ui_DrawBox(GR_WHITE, 0, 0, m_W, m_H); |
| 629 | |
| 630 | ui_SetTextClip(m_CX, m_CY, m_CX2, m_CY2); |
| 631 | |
| 632 | // draw all items in box that can be visible. |
| 633 | int x, y, i; |
| 634 | uint8_t alpha; |
| 635 | |
| 636 | x = m_TextOffX; |
| 637 | y = m_TextOffY; |
| 638 | |
| 639 | if (m_NumItems) { |
| 640 | snprintf(arrowbuf, sizeof(arrowbuf), "%c", UI_UP_ARROW_CHAR); |
| 641 | uarrow = UITextItem(arrowbuf, m_ItemList[m_Index]->get_color(), 255); |
| 642 | snprintf(arrowbuf, sizeof(arrowbuf), "%c", UI_DOWN_ARROW_CHAR); |
| 643 | darrow = UITextItem(arrowbuf, m_ItemList[m_Index]->get_color(), 255); |
| 644 | |
| 645 | // reset these |
| 646 | m_ShowUp = m_ShowDown = false; |
| 647 | |
| 648 | if (use_scroll) { |
| 649 | m_UpArrowY0 = y; |
| 650 | m_UpArrowY1 = y + uarrow.height(); |
| 651 | if (m_Index > 0) |
| 652 | uarrow.draw(m_TextOffX, m_UpArrowY0, IsDisabled() ? uiDrawFaded : uiDrawNormal); |
| 653 | m_ShowUp = true; |
| 654 | m_ArrowWidth = uarrow.width() + 2; |
| 655 | x = x + m_ArrowWidth; |
| 656 | } else |
| 657 | m_ArrowWidth = 0; |
| 658 | } |
| 659 | |
| 660 | alpha = m_Alpha; |
| 661 | |
| 662 | for (i = m_Index; i < m_NumItems; i++) { |
| 663 | // check to see if scroll arrow down needs to be drawn. |
| 664 | // if (m_SelectedIndex == i) { |
| 665 | // ui_DrawSetAlpha((alpha/4)+1); |
| 666 | // ui_DrawRect(m_HiliteColor, x,y,m_W-m_TextOffX,y+m_ItemList[i]->height()+2); |
| 667 | // } |
| 668 | |
| 669 | m_ItemList[i]->set_alpha((uint8_t)alpha); |
| 670 | if (m_SelectedIndex == i) { |
| 671 | ddgr_color old_color = m_ItemList[i]->get_color(); |
| 672 | m_ItemList[i]->set_color(m_SelectColor); |
| 673 | m_ItemList[i]->draw(x + 1, y + 1, IsDisabled() ? uiDrawFaded : uiDrawNormal); |
| 674 | if (!IsDisabled()) |
| 675 | m_ItemList[i]->draw(x + 1, y + 1, uiDrawAlphaSaturate); |
| 676 | m_ItemList[i]->set_color(old_color); |
| 677 | } else { |
nothing calls this directly
no test coverage detected