void clRowEntry::RenderText(wxWindow* win, wxDC& dc, const clColours& colours, const wxString& text, int x, int y, size_t col) { if(IsHighlight()) { const clMatchResult& hi = GetHighlightInfo(); Str3Arr_t arr; if(!hi.Get(col, arr)) { RenderTextSimple(win, dc, colours, text, x, y, col); return; } #ifdef __WXMSW__ const wxColour& defaultTextColour = m_tree->IsNativeTheme() ? colours.GetItemTextColour() : (IsSelected() ? colours.GetSelItemTextColour() : colours.GetItemTextColour()); #else const wxColour& defaultTextColour = IsSelected() ? colours.GetSelItemTextColour() : colours.GetItemTextColour(); #endif const wxColour& matchBgColour = colours.GetMatchedItemBgText(); const wxColour& matchTextColour = colours.GetMatchedItemText(); int xx = x; wxRect rowRect = GetItemRect(); for(size_t i = 0; i < arr.size(); ++i) { wxString str = arr[i]; bool is_match = (i == 1); // the middle entry is always the matched string wxSize sz = dc.GetTextExtent(str); rowRect.SetX(xx); rowRect.SetWidth(sz.GetWidth()); if(is_match) { // draw a match rectangle dc.SetPen(matchBgColour); dc.SetBrush(matchBgColour); dc.SetTextForeground(matchTextColour); dc.DrawRoundedRectangle(rowRect, 3.0); } else { dc.SetTextForeground(defaultTextColour); } dc.DrawText(str, xx, y); xx += sz.GetWidth(); } } else { // No match RenderTextSimple(win, dc, colours, text, x, y, col); } }
void GUI_ListBox::Draw(SURFHANDLE surf, RECT &drawablerect, int xoffset, int yoffset) { BLITDATA blitdata; calculateBlitData(xoffset + rect.left, yoffset + rect.top, drawablerect, blitdata); //width or height == 0 indicates that the element is completely outside its //parents rect, so no need to draw. if (blitdata.width > 0 && blitdata.height > 0) { //draw background and frame oapiBlt(surf, src, &blitdata.tgtrect, &blitdata.srcrect, SURF_PREDEF_CK); } //find printable rect ( RECT printableRect = _R(rect.left + xoffset + style->MarginLeft(), rect.top + yoffset + style->MarginTop(), rect.right + xoffset - scrlBarWidth - style->MarginLeft(), rect.bottom + yoffset - style->MarginBottom()); //draw entries SetSelected(selected); int posInDrawList = 0; //notes the position in the currently visible list as opposed to the entire list auto s = cState(); for (UINT i = scrollbar->GetScrollPos(); i < s->entries.size() && int(i) < scrollbar->GetScrollPos() + nLines; ++i, ++posInDrawList) { int tgty = printableRect.top + (posInDrawList * (font->GetfHeight() + lineSpace)); if (!s->noSelect && !s->selectBox && selected == i || s->selectBox && IsHighlight(i)) { font->Print(surf, s->entries[i], printableRect.left, tgty, printableRect, true, listJustification); } else { font->Print(surf, s->entries[i], printableRect.left, tgty, printableRect, false, listJustification); } } }