Use correct colour for selected items in generic wxDVC.
wxDataViewCustomRenderer::RenderText() taking attributes must use correct colour for the selected items if no attribute is specified as it can be (and is) called directly and not only via the compatibility overload. This fixes the display of the selected items in the dataview sample broken by recent changes. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62417 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -134,7 +134,14 @@ public:
|
|||||||
int xoffset = 0);
|
int xoffset = 0);
|
||||||
|
|
||||||
// Overload using standard attributes
|
// Overload using standard attributes
|
||||||
void RenderText( const wxString &text, int xoffset, wxRect cell, wxDC *dc, int state );
|
void RenderText(const wxString& text,
|
||||||
|
int xoffset,
|
||||||
|
wxRect cell,
|
||||||
|
wxDC *dc,
|
||||||
|
int state)
|
||||||
|
{
|
||||||
|
RenderText(*dc, cell, wxALIGN_NOT, text, NULL, state, xoffset);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
|
||||||
|
@@ -704,30 +704,24 @@ wxDataViewCustomRenderer::wxDataViewCustomRenderer( const wxString &varianttype,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDataViewCustomRenderer::RenderText( const wxString &text, int xoffset,
|
|
||||||
wxRect cell, wxDC *dc, int state )
|
|
||||||
{
|
|
||||||
wxColour col = state & wxDATAVIEW_CELL_SELECTED
|
|
||||||
? wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT)
|
|
||||||
: GetOwner()->GetOwner()->GetForegroundColour();
|
|
||||||
|
|
||||||
wxDataViewItemAttr attr;
|
|
||||||
attr.SetColour(col);
|
|
||||||
RenderText(*dc, cell, wxALIGN_NOT, text, &attr, state, xoffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
wxDataViewCustomRenderer::RenderText(wxDC& dc,
|
wxDataViewCustomRenderer::RenderText(wxDC& dc,
|
||||||
const wxRect& rect,
|
const wxRect& rect,
|
||||||
int align,
|
int align,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
const wxDataViewItemAttr *attr,
|
const wxDataViewItemAttr *attr,
|
||||||
int WXUNUSED(state),
|
int state,
|
||||||
int xoffset)
|
int xoffset)
|
||||||
{
|
{
|
||||||
wxDCTextColourChanger changeFg(dc);
|
wxColour col;
|
||||||
if ( attr && attr->HasColour() )
|
if ( attr && attr->HasColour() )
|
||||||
changeFg.Set(attr->GetColour());
|
col = attr->GetColour();
|
||||||
|
else if ( state & wxDATAVIEW_CELL_SELECTED )
|
||||||
|
col = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
|
||||||
|
else // use default foreground
|
||||||
|
col = GetOwner()->GetOwner()->GetForegroundColour();
|
||||||
|
|
||||||
|
wxDCTextColourChanger changeFg(dc, col);
|
||||||
|
|
||||||
wxDCFontChanger changeFont(dc);
|
wxDCFontChanger changeFont(dc);
|
||||||
if ( attr && attr->HasFont() )
|
if ( attr && attr->HasFont() )
|
||||||
|
Reference in New Issue
Block a user