Add wxRendererNative::DrawItemText() for list-like controls
Add a new method that should be used for drawing the elements of list-like
controls (i.e. wx{List,Tree,DataView}Ctrl and similar).
Implement it for wxMSW natively and provide a straightforward generic fallback
for the other ports.
See #16414.
This commit is contained in:
committed by
Vadim Zeitlin
parent
ba4bfc5414
commit
b7a89f8746
@@ -138,6 +138,13 @@ public:
|
||||
|
||||
virtual void DrawGauge(wxWindow* win, wxDC& dc, const wxRect& rect, int value, int max, int flags = 0) wxOVERRIDE;
|
||||
|
||||
virtual void DrawItemText(wxWindow* win,
|
||||
wxDC& dc,
|
||||
const wxString& text,
|
||||
const wxRect& rect,
|
||||
int align = wxALIGN_LEFT | wxALIGN_TOP,
|
||||
int flags = 0) wxOVERRIDE;
|
||||
|
||||
virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win) wxOVERRIDE;
|
||||
|
||||
virtual wxRendererVersion GetVersion() const wxOVERRIDE
|
||||
@@ -832,6 +839,46 @@ void wxRendererGeneric::DrawGauge(wxWindow* win,
|
||||
dc.DrawRectangle(progRect);
|
||||
}
|
||||
|
||||
void
|
||||
wxRendererGeneric::DrawItemText(wxWindow* win,
|
||||
wxDC& dc,
|
||||
const wxString& text,
|
||||
const wxRect& rect,
|
||||
int align,
|
||||
int flags)
|
||||
{
|
||||
// Determine text color
|
||||
wxColour textColour;
|
||||
if ( flags & wxCONTROL_SELECTED )
|
||||
{
|
||||
if ( flags & wxCONTROL_FOCUSED )
|
||||
{
|
||||
textColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
|
||||
}
|
||||
else // !focused
|
||||
{
|
||||
textColour = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXTEXT);
|
||||
}
|
||||
}
|
||||
else if ( flags & wxCONTROL_DISABLED )
|
||||
{
|
||||
textColour = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
|
||||
}
|
||||
else // enabled but not selected
|
||||
{
|
||||
textColour = win->GetForegroundColour();
|
||||
}
|
||||
|
||||
const wxString paintText = wxControl::Ellipsize(text, dc,
|
||||
wxELLIPSIZE_END,
|
||||
rect.GetWidth());
|
||||
|
||||
// Draw text
|
||||
dc.SetTextForeground(textColour);
|
||||
dc.SetTextBackground(wxTransparentColour);
|
||||
dc.DrawLabel(paintText, rect, align);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// A module to allow cleanup of generic renderer.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user