Fix text colour for items drawn using wxRenderer::DrawItemText()
After the addition and usage of DrawItemText() in
b7a89f8746 custom colors in wxDataViewCtrl where
ignored, restore the correct behavior (custom color for unselected items) by
avoiding changing the colour for the normal items in this function.
Closes #17164.
This commit is contained in:
committed by
Vadim Zeitlin
parent
44bcc3a723
commit
76a75ddc6a
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user