bool wxMenuItem::MSWMustUseOwnerDrawn() { // MIIM_BITMAP only works under WinME/2000+ so we always use owner // drawn item under the previous versions and we also have to use // them in any case if the item has custom colours or font static const wxWinVersion winver = wxGetWinVersion(); bool mustUseOwnerDrawn = winver < wxWinVersion_98 || GetTextColour().IsOk() || GetBackgroundColour().IsOk() || GetFont().IsOk(); // Windows XP or earlier don't display menu bitmaps bigger than // standard size correctly (they're truncated), so we must use // owner-drawn items to show them correctly there. OTOH Win7 // doesn't seem to have any problems with even very large bitmaps // so don't use owner-drawn items unnecessarily there (Vista wasn't // actually tested but I assume it works as 7 rather than as XP). if ( !mustUseOwnerDrawn && winver < wxWinVersion_Vista ) { const wxBitmap& bmpUnchecked = GetBitmap(false), bmpChecked = GetBitmap(true); if ( (bmpUnchecked.IsOk() && IsGreaterThanStdSize(bmpUnchecked)) || (bmpChecked.IsOk() && IsGreaterThanStdSize(bmpChecked)) ) { mustUseOwnerDrawn = true; } } return mustUseOwnerDrawn; }
void wxCustomStatusBarArt::DrawText(wxDC& dc, wxCoord x, wxCoord y, const wxString& text) { dc.SetTextForeground(GetTextShadowColour()); dc.DrawText(text, x, y - 1); dc.SetTextForeground(GetTextColour()); dc.DrawText(text, x, y); }
// Our variation of InsertItem, so we can do magical things! long wxAdvancedListCtrl::ALCInsertItem(const wxString &Text) { wxListItem ListItem; ListItem.m_itemId = InsertItem(GetItemCount(), Text, -1); ColourListItem(ListItem.m_itemId); SetItem(ListItem); // wxWidgets bug: Required for sorting colours correctly SetItemTextColour(ListItem.m_itemId, GetTextColour()); return ListItem.m_itemId; }
// Equality test bool wxTextAttr::operator== (const wxTextAttr& attr) const { return GetFlags() == attr.GetFlags() && (!HasTextColour() || (GetTextColour() == attr.GetTextColour())) && (!HasBackgroundColour() || (GetBackgroundColour() == attr.GetBackgroundColour())) && (!HasAlignment() || (GetAlignment() == attr.GetAlignment())) && (!HasLeftIndent() || (GetLeftIndent() == attr.GetLeftIndent() && GetLeftSubIndent() == attr.GetLeftSubIndent())) && (!HasRightIndent() || (GetRightIndent() == attr.GetRightIndent())) && (!HasTabs() || (TabsEq(GetTabs(), attr.GetTabs()))) && (!HasParagraphSpacingAfter() || (GetParagraphSpacingAfter() == attr.GetParagraphSpacingAfter())) && (!HasParagraphSpacingBefore() || (GetParagraphSpacingBefore() == attr.GetParagraphSpacingBefore())) && (!HasLineSpacing() || (GetLineSpacing() == attr.GetLineSpacing())) && (!HasCharacterStyleName() || (GetCharacterStyleName() == attr.GetCharacterStyleName())) && (!HasParagraphStyleName() || (GetParagraphStyleName() == attr.GetParagraphStyleName())) && (!HasListStyleName() || (GetListStyleName() == attr.GetListStyleName())) && (!HasBulletStyle() || (GetBulletStyle() == attr.GetBulletStyle())) && (!HasBulletText() || (GetBulletText() == attr.GetBulletText())) && (!HasBulletNumber() || (GetBulletNumber() == attr.GetBulletNumber())) && (GetBulletFont() == attr.GetBulletFont()) && (!HasBulletName() || (GetBulletName() == attr.GetBulletName())) && (!HasTextEffects() || (GetTextEffects() == attr.GetTextEffects() && GetTextEffectFlags() == attr.GetTextEffectFlags())) && (!HasOutlineLevel() || (GetOutlineLevel() == attr.GetOutlineLevel())) && (!HasFontSize() || (GetFontSize() == attr.GetFontSize())) && (!HasFontItalic() || (GetFontStyle() == attr.GetFontStyle())) && (!HasFontWeight() || (GetFontWeight() == attr.GetFontWeight())) && (!HasFontUnderlined() || (GetFontUnderlined() == attr.GetFontUnderlined())) && (!HasFontStrikethrough() || (GetFontStrikethrough() == attr.GetFontStrikethrough())) && (!HasFontFaceName() || (GetFontFaceName() == attr.GetFontFaceName())) && (!HasFontEncoding() || (GetFontEncoding() == attr.GetFontEncoding())) && (!HasFontFamily() || (GetFontFamily() == attr.GetFontFamily())) && (!HasURL() || (GetURL() == attr.GetURL())); }
void wxMenuItem::GetColourToUse(wxODStatus stat, wxColour& colText, wxColour& colBack) const { #if wxUSE_UXTHEME wxUxThemeEngine* theme = MenuDrawData::GetUxThemeEngine(); if ( theme ) { wxUxThemeHandle hTheme(GetMenu()->GetWindow(), L"MENU"); if ( stat & wxODDisabled) { wxRGBToColour(colText, theme->GetThemeSysColor(hTheme, COLOR_GRAYTEXT)); } else { colText = GetTextColour(); if ( !colText.IsOk() ) wxRGBToColour(colText, theme->GetThemeSysColor(hTheme, COLOR_MENUTEXT)); } if ( stat & wxODSelected ) { wxRGBToColour(colBack, theme->GetThemeSysColor(hTheme, COLOR_HIGHLIGHT)); } else { colBack = GetBackgroundColour(); if ( !colBack.IsOk() ) wxRGBToColour(colBack, theme->GetThemeSysColor(hTheme, COLOR_MENU)); } } else #endif // wxUSE_UXTHEME { wxOwnerDrawn::GetColourToUse(stat, colText, colBack); } }
// Partial equality test taking flags into account bool wxTextAttr::EqPartial(const wxTextAttr& attr, int flags) const { if ((flags & wxTEXT_ATTR_TEXT_COLOUR) && GetTextColour() != attr.GetTextColour()) return false; if ((flags & wxTEXT_ATTR_BACKGROUND_COLOUR) && GetBackgroundColour() != attr.GetBackgroundColour()) return false; if ((flags & wxTEXT_ATTR_FONT_FACE) && GetFontFaceName() != attr.GetFontFaceName()) return false; if ((flags & wxTEXT_ATTR_FONT_SIZE) && GetFontSize() != attr.GetFontSize()) return false; if ((flags & wxTEXT_ATTR_FONT_WEIGHT) && GetFontWeight() != attr.GetFontWeight()) return false; if ((flags & wxTEXT_ATTR_FONT_ITALIC) && GetFontStyle() != attr.GetFontStyle()) return false; if ((flags & wxTEXT_ATTR_FONT_UNDERLINE) && GetFontUnderlined() != attr.GetFontUnderlined()) return false; if ((flags & wxTEXT_ATTR_FONT_ENCODING) && GetFontEncoding() != attr.GetFontEncoding()) return false; if ((flags & wxTEXT_ATTR_FONT_FAMILY) && GetFontFamily() != attr.GetFontFamily()) return false; if ((flags & wxTEXT_ATTR_URL) && GetURL() != attr.GetURL()) return false; if ((flags & wxTEXT_ATTR_ALIGNMENT) && GetAlignment() != attr.GetAlignment()) return false; if ((flags & wxTEXT_ATTR_LEFT_INDENT) && ((GetLeftIndent() != attr.GetLeftIndent()) || (GetLeftSubIndent() != attr.GetLeftSubIndent()))) return false; if ((flags & wxTEXT_ATTR_RIGHT_INDENT) && (GetRightIndent() != attr.GetRightIndent())) return false; if ((flags & wxTEXT_ATTR_PARA_SPACING_AFTER) && (GetParagraphSpacingAfter() != attr.GetParagraphSpacingAfter())) return false; if ((flags & wxTEXT_ATTR_PARA_SPACING_BEFORE) && (GetParagraphSpacingBefore() != attr.GetParagraphSpacingBefore())) return false; if ((flags & wxTEXT_ATTR_LINE_SPACING) && (GetLineSpacing() != attr.GetLineSpacing())) return false; if ((flags & wxTEXT_ATTR_CHARACTER_STYLE_NAME) && (GetCharacterStyleName() != attr.GetCharacterStyleName())) return false; if ((flags & wxTEXT_ATTR_PARAGRAPH_STYLE_NAME) && (GetParagraphStyleName() != attr.GetParagraphStyleName())) return false; if ((flags & wxTEXT_ATTR_LIST_STYLE_NAME) && (GetListStyleName() != attr.GetListStyleName())) return false; if ((flags & wxTEXT_ATTR_BULLET_STYLE) && (GetBulletStyle() != attr.GetBulletStyle())) return false; if ((flags & wxTEXT_ATTR_BULLET_NUMBER) && (GetBulletNumber() != attr.GetBulletNumber())) return false; if ((flags & wxTEXT_ATTR_BULLET_TEXT) && (GetBulletText() != attr.GetBulletText()) && (GetBulletFont() != attr.GetBulletFont())) return false; if ((flags & wxTEXT_ATTR_BULLET_NAME) && (GetBulletName() != attr.GetBulletName())) return false; if ((flags & wxTEXT_ATTR_TABS) && !TabsEq(GetTabs(), attr.GetTabs())) return false; if ((flags & wxTEXT_ATTR_PAGE_BREAK) && (HasPageBreak() != attr.HasPageBreak())) return false; if (flags & wxTEXT_ATTR_EFFECTS) { if (HasTextEffects() != attr.HasTextEffects()) return false; if (!BitlistsEqPartial(GetTextEffects(), attr.GetTextEffects(), attr.GetTextEffectFlags())) return false; } if ((flags & wxTEXT_ATTR_OUTLINE_LEVEL) && (GetOutlineLevel() != attr.GetOutlineLevel())) return false; return true; }
void wxFlatButton::OnPaint(wxPaintEvent& event) { wxUnusedVar(event); wxAutoBufferedPaintDC paintDC(this); wxGCDC gdc; GetGCDC(paintDC, gdc); wxRect clientRect = GetClientRect(); // Draw the background gdc.SetPen(GetBarBgColour(m_theme)); gdc.SetBrush(GetBarBgColour(m_theme)); gdc.DrawRectangle(clientRect); switch(m_state) { case kStateHover: { if(!IsChecked()) { // Hover gdc.SetBrush(GetBgHoverColour()); gdc.SetPen(m_penHoverOuterColour); gdc.DrawRoundedRectangle(clientRect, BTN_RADIUS); clientRect.Deflate(1); gdc.SetBrush(*wxTRANSPARENT_BRUSH); gdc.SetPen(m_penHoverColourInner); gdc.DrawRoundedRectangle(clientRect, BTN_RADIUS); // gdc.SetPen(m_penHoverColourInner); // gdc.DrawLine(clientRect.GetBottomLeft(), clientRect.GetTopLeft()); // gdc.DrawLine(clientRect.GetTopLeft(), clientRect.GetTopRight()); // // gdc.SetPen(m_penHoverOuterColour); // gdc.DrawLine(clientRect.GetTopRight(), clientRect.GetBottomRight()); // gdc.DrawLine(clientRect.GetBottomRight(), clientRect.GetBottomLeft()); } break; } case kStateNormal: { // do nothing gdc.SetBrush(GetBgColour()); gdc.SetPen(GetPenNormalColour()); gdc.DrawRoundedRectangle(clientRect, BTN_RADIUS); break; } case kStatePressed: { // Pressed gdc.SetBrush(GetBgPressedColour()); gdc.SetPen(GetPenPressedColour()); gdc.DrawRoundedRectangle(clientRect, BTN_RADIUS); // gdc.SetBrush(GetBgPressedColour()); // gdc.DrawRectangle(clientRect); // // gdc.SetPen(m_penHoverOuterColour); // gdc.DrawLine(clientRect.GetBottomLeft(), clientRect.GetTopLeft()); // gdc.DrawLine(clientRect.GetTopLeft(), clientRect.GetTopRight()); // // gdc.SetPen(m_penHoverColourInner); // gdc.DrawLine(clientRect.GetTopRight(), clientRect.GetBottomRight()); // gdc.DrawLine(clientRect.GetBottomRight(), clientRect.GetBottomLeft()); break; } } // Draw text gdc.SetFont(GetTextFont()); if(!IsEnabled()) { gdc.SetTextForeground(GetTextColourDisabled()); gdc.DrawLabel( m_text, m_bmpDisabled, clientRect, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL, m_accelIndex); } else { gdc.SetTextForeground(GetTextColour()); gdc.DrawLabel(m_text, m_bmp, clientRect, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL, m_accelIndex); } }
// Partial equality test. Only returns false if an attribute doesn't match. bool wxTextAttr::EqPartial(const wxTextAttr& attr, bool weakTest) const { int flags = attr.GetFlags(); if (!weakTest && ((!HasTextColour() && attr.HasTextColour()) || (!HasBackgroundColour() && attr.HasBackgroundColour()) || (!HasFontFaceName() && attr.HasFontFaceName()) || (!HasFontSize() && attr.HasFontSize()) || (!HasFontWeight() && attr.HasFontWeight()) || (!HasFontItalic() && attr.HasFontItalic()) || (!HasFontUnderlined() && attr.HasFontUnderlined()) || (!HasFontStrikethrough() && attr.HasFontStrikethrough()) || (!HasFontEncoding() && attr.HasFontEncoding()) || (!HasFontFamily() && attr.HasFontFamily()) || (!HasURL() && attr.HasURL()) || (!HasAlignment() && attr.HasAlignment()) || (!HasLeftIndent() && attr.HasLeftIndent()) || (!HasParagraphSpacingAfter() && attr.HasParagraphSpacingAfter()) || (!HasParagraphSpacingBefore() && attr.HasParagraphSpacingBefore()) || (!HasLineSpacing() && attr.HasLineSpacing()) || (!HasCharacterStyleName() && attr.HasCharacterStyleName()) || (!HasParagraphStyleName() && attr.HasParagraphStyleName()) || (!HasListStyleName() && attr.HasListStyleName()) || (!HasBulletStyle() && attr.HasBulletStyle()) || (!HasBulletNumber() && attr.HasBulletNumber()) || (!HasBulletText() && attr.HasBulletText()) || (!HasBulletName() && attr.HasBulletName()) || (!HasTabs() && attr.HasTabs()) || (!HasTextEffects() && attr.HasTextEffects()) || (!HasOutlineLevel() && attr.HasOutlineLevel()))) { return false; } if (HasTextColour() && attr.HasTextColour() && GetTextColour() != attr.GetTextColour()) return false; if (HasBackgroundColour() && attr.HasBackgroundColour() && GetBackgroundColour() != attr.GetBackgroundColour()) return false; if (HasFontFaceName() && attr.HasFontFaceName() && GetFontFaceName() != attr.GetFontFaceName()) return false; // This checks whether the two objects have the same font size dimension (px versus pt) if (HasFontSize() && attr.HasFontSize() && (flags & wxTEXT_ATTR_FONT) != (GetFlags() & wxTEXT_ATTR_FONT)) return false; if (HasFontPointSize() && attr.HasFontPointSize() && GetFontSize() != attr.GetFontSize()) return false; if (HasFontPixelSize() && attr.HasFontPixelSize() && GetFontSize() != attr.GetFontSize()) return false; if (HasFontWeight() && attr.HasFontWeight() && GetFontWeight() != attr.GetFontWeight()) return false; if (HasFontItalic() && attr.HasFontItalic() && GetFontStyle() != attr.GetFontStyle()) return false; if (HasFontUnderlined() && attr.HasFontUnderlined() && GetFontUnderlined() != attr.GetFontUnderlined()) return false; if (HasFontStrikethrough() && attr.HasFontStrikethrough() && GetFontStrikethrough() != attr.GetFontStrikethrough()) return false; if (HasFontEncoding() && attr.HasFontEncoding() && GetFontEncoding() != attr.GetFontEncoding()) return false; if (HasFontFamily() && attr.HasFontFamily() && GetFontFamily() != attr.GetFontFamily()) return false; if (HasURL() && attr.HasURL() && GetURL() != attr.GetURL()) return false; if (HasAlignment() && attr.HasAlignment() && GetAlignment() != attr.GetAlignment()) return false; if (HasLeftIndent() && attr.HasLeftIndent() && ((GetLeftIndent() != attr.GetLeftIndent()) || (GetLeftSubIndent() != attr.GetLeftSubIndent()))) return false; if (HasRightIndent() && attr.HasRightIndent() && (GetRightIndent() != attr.GetRightIndent())) return false; if (HasParagraphSpacingAfter() && attr.HasParagraphSpacingAfter() && (GetParagraphSpacingAfter() != attr.GetParagraphSpacingAfter())) return false; if (HasParagraphSpacingBefore() && attr.HasParagraphSpacingBefore() && (GetParagraphSpacingBefore() != attr.GetParagraphSpacingBefore())) return false; if (HasLineSpacing() && attr.HasLineSpacing() && (GetLineSpacing() != attr.GetLineSpacing())) return false; if (HasCharacterStyleName() && attr.HasCharacterStyleName() && (GetCharacterStyleName() != attr.GetCharacterStyleName())) return false; if (HasParagraphStyleName() && attr.HasParagraphStyleName() && (GetParagraphStyleName() != attr.GetParagraphStyleName())) return false; if (HasListStyleName() && attr.HasListStyleName() && (GetListStyleName() != attr.GetListStyleName())) return false; if (HasBulletStyle() && attr.HasBulletStyle() && (GetBulletStyle() != attr.GetBulletStyle())) return false; if (HasBulletNumber() && attr.HasBulletNumber() && (GetBulletNumber() != attr.GetBulletNumber())) return false; if (HasBulletText() && attr.HasBulletText() && (GetBulletText() != attr.GetBulletText()) && (GetBulletFont() != attr.GetBulletFont())) return false; if (HasBulletName() && attr.HasBulletName() && (GetBulletName() != attr.GetBulletName())) return false; if (HasTabs() && attr.HasTabs() && !TabsEq(GetTabs(), attr.GetTabs())) return false; if ((HasPageBreak() != attr.HasPageBreak())) return false; if (HasTextEffects() && attr.HasTextEffects()) { if (!BitlistsEqPartial(GetTextEffects(), attr.GetTextEffects(), attr.GetTextEffectFlags())) return false; } if (HasOutlineLevel() && attr.HasOutlineLevel() && (GetOutlineLevel() != attr.GetOutlineLevel())) return false; return true; }
void wxFlatButton::OnPaint(wxPaintEvent& event) { wxUnusedVar(event); wxAutoBufferedPaintDC paintDC(this); PrepareDC(paintDC); wxGCDC gdc; GetGCDC(paintDC, gdc); wxRect clientRect = GetClientRect(); // Draw the background gdc.SetPen(GetBarBgColour(m_theme)); gdc.SetBrush(GetBarBgColour(m_theme)); gdc.DrawRectangle(clientRect); switch(m_state) { case kStateHover: { // do nothing gdc.SetBrush(GetBgColour()); gdc.SetPen(GetPenNormalColour()); gdc.DrawRoundedRectangle(clientRect, BTN_RADIUS); break; } case kStateNormal: { break; } case kStatePressed: { // Pressed gdc.SetBrush(GetBgPressedColour()); gdc.SetPen(GetPenPressedColour()); gdc.DrawRoundedRectangle(clientRect, BTN_RADIUS); break; } } // Draw text gdc.SetFont(GetTextFont()); wxColour textColour = IsEnabled() ? GetTextColour() : GetTextColourDisabled(); wxBitmap bmp = IsEnabled() ? m_bmp : m_bmpDisabled; wxCoord textY; wxCoord bmpY; wxCoord totalLen = 0; const int spacer = 2; if(bmp.IsOk()) { // we got a bitmap totalLen += bmp.GetScaledWidth(); } wxSize textSize; if(!m_text.IsEmpty()) { textSize = gdc.GetTextExtent(m_text); totalLen += spacer; totalLen += textSize.x; } wxCoord offset = (clientRect.GetWidth() - totalLen) / 2; bmpY = (clientRect.GetHeight() - bmp.GetScaledHeight()) / 2; textY = (clientRect.GetHeight() - textSize.y) / 2; if(bmp.IsOk()) { gdc.DrawBitmap(bmp, offset, bmpY); offset += bmp.GetScaledWidth(); offset += spacer; } if(!m_text.IsEmpty()) { gdc.DrawText(m_text, offset, textY); offset += textSize.x; offset += spacer; } }
void Font::drawStandardText(FLOAT baseX, FLOAT baseY, LPCTSTR lpchText, int cchText, FN_DRAWGLYPH fnDrawText) { LPCWSTR lpchStr = charToUnicode(lpchText, cchText); D3DCOLOR fontColour = GetTextColour(); BYTE fontAlpha = GetTextAlpha(); if (m_fontEffect & KG3DFONT_STYLE_PROJECTION) { SetTextColor(m_fontProjectionColor); drawNormalText(baseX + (m_fontProjectionWeight << 1), baseY + m_fontProjectionWeight, lpchStr, fnDrawText); } if (m_fontEffect & KG3DFONT_STYLE_BORDER) { SetTextColor(m_fontBorderColor); if (1 == m_fontBorderWeight) { for (int y = -m_fontBorderWeight; y <= m_fontBorderWeight; ++ y) { for (int x = -m_fontBorderWeight; x <= m_fontBorderWeight; ++ x) { if ((0 == x) && (0 == y)) { continue ; } drawNormalText(baseX + x, baseY + y, lpchStr, fnDrawText); } } } else { int xBegin = -m_fontBorderWeight + 1; int xEnd = m_fontBorderWeight - 1; for (int x = xBegin; x <= xEnd; ++ x) drawNormalText(baseX + x, baseY - m_fontBorderWeight, lpchStr, fnDrawText); for (int x = xBegin; x <= xEnd; ++ x) drawNormalText(baseX + x, baseY + m_fontBorderWeight, lpchStr, fnDrawText); int yBegin = -m_fontBorderWeight + 1; int yEnd = m_fontBorderWeight - 1; for (int y = yBegin; y <= yEnd; ++ y) { for (int x = -m_fontBorderWeight; x <= m_fontBorderWeight; ++ x) { if ((0 == x) && (0 == y)) { continue ; } drawNormalText(baseX + x, baseY + y, lpchStr, fnDrawText); } } } } SetTextAlpha(fontAlpha); SetTextColor(fontColour); drawNormalText(baseX, baseY, lpchStr, fnDrawText); }
COLORREF CColourPicker::GetColour() { return (m_nSelectionMode == CP_MODE_TEXT)? GetTextColour(): GetBkColour(); }
void wxSwitcherItems::PaintItems(wxDC& dc, wxWindow* win) { wxColour backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); wxColour standardTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); wxColour selectionColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); wxColour selectionOutlineColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); wxColour selectionTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT); wxFont standardFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); wxFont groupFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); groupFont.SetWeight(wxFONTWEIGHT_BOLD); if (GetBackgroundColour().Ok()) backgroundColour = GetBackgroundColour(); if (GetTextColour().Ok()) standardTextColour = GetTextColour(); if (GetSelectionColour().Ok()) selectionColour = GetSelectionColour(); if (GetSelectionOutlineColour().Ok()) selectionOutlineColour = GetSelectionOutlineColour(); if (GetSelectionTextColour().Ok()) selectionTextColour = GetSelectionTextColour(); if (GetItemFont().Ok()) { standardFont = GetItemFont(); groupFont = wxFont(standardFont.GetPointSize(), standardFont.GetFamily(), standardFont.GetStyle(), wxFONTWEIGHT_BOLD, standardFont.GetUnderlined(), standardFont.GetFaceName()); } int textMarginX = wxSWITCHER_TEXT_MARGIN_X; dc.SetLogicalFunction(wxCOPY); dc.SetBrush(wxBrush(backgroundColour)); dc.SetPen(*wxTRANSPARENT_PEN); dc.DrawRectangle(win->GetClientRect()); dc.SetBackgroundMode(wxTRANSPARENT); size_t i; for (i = 0; i < m_items.GetCount(); i++) { wxSwitcherItem& item = m_items[i]; bool selected = ((int) i == m_selection); if (selected) { dc.SetPen(wxPen(selectionOutlineColour)); dc.SetBrush(wxBrush(selectionColour)); dc.DrawRectangle(item.GetRect()); } wxRect clippingRect(item.GetRect()); clippingRect.Deflate(1, 1); dc.SetClippingRegion(clippingRect); if (selected) dc.SetTextForeground(selectionTextColour); else if (item.GetTextColour().Ok()) dc.SetTextForeground(item.GetTextColour()); else dc.SetTextForeground(standardTextColour); if (item.GetFont().Ok()) dc.SetFont(item.GetFont()); else { if (item.GetIsGroup()) dc.SetFont(groupFont); else dc.SetFont(standardFont); } int w, h; dc.GetTextExtent(item.GetTitle(), & w, & h); int x = item.GetRect().x; x += textMarginX; if (!item.GetIsGroup()) { if (item.GetBitmap().Ok() && item.GetBitmap().GetWidth() <= 16 && item.GetBitmap().GetHeight() <= 16) { dc.DrawBitmap(item.GetBitmap(), x, item.GetRect().y + (item.GetRect().height - item.GetBitmap().GetHeight()) / 2, true); } x += 16; x += textMarginX; } int y = item.GetRect().y + (item.GetRect().height - h)/2; dc.DrawText(item.GetTitle(), x, y); dc.DestroyClippingRegion(); } }