diff --git a/src/generic/renderg.cpp b/src/generic/renderg.cpp index b078566e17..9cc9eebc32 100644 --- a/src/generic/renderg.cpp +++ b/src/generic/renderg.cpp @@ -884,7 +884,7 @@ void wxRendererGeneric::DrawGauge(wxWindow* win, } void -wxRendererGeneric::DrawItemText(wxWindow* win, +wxRendererGeneric::DrawItemText(wxWindow* WXUNUSED(win), wxDC& dc, const wxString& text, const wxRect& rect, @@ -909,17 +909,15 @@ wxRendererGeneric::DrawItemText(wxWindow* win, { textColour = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT); } - else // enabled but not selected - { - textColour = win->GetForegroundColour(); - } const wxString paintText = wxControl::Ellipsize(text, dc, ellipsizeMode, rect.GetWidth()); - // Draw text - dc.SetTextForeground(textColour); + // Draw text taking care not to change its colour if it had been set by the + // caller for a normal item to allow having items in non-default colours. + if ( textColour.IsOk() ) + dc.SetTextForeground(textColour); dc.SetTextBackground(wxTransparentColour); dc.DrawLabel(paintText, rect, align); } diff --git a/src/msw/renderer.cpp b/src/msw/renderer.cpp index b297a7c8e1..f0a81a82e4 100644 --- a/src/msw/renderer.cpp +++ b/src/msw/renderer.cpp @@ -617,6 +617,27 @@ int wxRendererMSW::GetHeaderButtonMargin(wxWindow *WXUNUSED(win)) #if wxUSE_UXTHEME +namespace +{ + +int GetListItemState(int flags) +{ + int itemState = (flags & wxCONTROL_CURRENT) ? LISS_HOT : LISS_NORMAL; + if ( flags & wxCONTROL_SELECTED ) + { + itemState = (flags & wxCONTROL_CURRENT) ? LISS_HOTSELECTED : LISS_SELECTED; + if ( !(flags & wxCONTROL_FOCUSED) ) + itemState = LISS_SELECTEDNOTFOCUS; + } + + if ( flags & wxCONTROL_DISABLED ) + itemState = LISS_DISABLED; + + return itemState; +} + +} // anonymous namespace + /* static */ wxRendererNative& wxRendererXP::Get() { @@ -943,13 +964,7 @@ wxRendererXP::DrawItemSelectionRect(wxWindow *win, { wxUxThemeHandle hTheme(win, L"LISTVIEW"); - int itemState = LISS_NORMAL; - if ( flags & wxCONTROL_SELECTED ) - itemState = LISS_SELECTED; - if ( !(flags & wxCONTROL_FOCUSED) ) - itemState = LISS_SELECTEDNOTFOCUS; - if ( flags & wxCONTROL_DISABLED ) - itemState |= LISS_DISABLED; + const int itemState = GetListItemState(flags); wxUxThemeEngine* const te = wxUxThemeEngine::Get(); if ( te->IsThemePartDefined(hTheme, LVP_LISTITEM, itemState) ) @@ -977,13 +992,7 @@ void wxRendererXP::DrawItemText(wxWindow* win, { wxUxThemeHandle hTheme(win, L"LISTVIEW"); - int itemState = LISS_NORMAL; - if ( flags & wxCONTROL_SELECTED ) - itemState = LISS_SELECTED; - if ( !(flags & wxCONTROL_FOCUSED) ) - itemState = LISS_SELECTEDNOTFOCUS; - if ( flags & wxCONTROL_DISABLED ) - itemState |= LISS_DISABLED; + const int itemState = GetListItemState(flags); wxUxThemeEngine* te = wxUxThemeEngine::Get(); if ( te->DrawThemeTextEx && // Might be not available if we're under XP