Change default selected font color. Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
tgg_splash
Earned a small fee
Earned a small fee
Posts: 24
Joined: Thu Jan 04, 2018 8:05 am

Change default selected font color.

Post by tgg_splash »

I am using wxDataViewCtrl to display a table.When the row or wxDataViewItem is selected, the font color becomes white. I found that wxDataViewCustomRenderBase use the static class wxSysSettings::GetColor to get a default color. Is there any way to change the font color without modifing wxWidgets ' src code.
Thanks, wxWidgets 3.0.4, visual studio 2015, Windows 7.

Code: Select all

	///
	/// call stack: 
	/// wxDataViewMainWindow::OnPaint
	/// wxDataViewCustomRenderBase::WXCallRender 
	///
    // set up the DC attributes

    // override custom foreground with the standard one for the selected items
    // because we currently don't allow changing the selection background and
    // custom colours may be unreadable on it
    wxColour col;
    if ( state & wxDATAVIEW_CELL_SELECTED )
        col = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
    else if ( m_attr.HasColour() )
        col = m_attr.GetColour();
    else // use default foreground
        col = GetOwner()->GetOwner()->GetForegroundColour();

    wxDCTextColourChanger changeFg(*dc, col);

    wxDCFontChanger changeFont(*dc);
    if ( m_attr.HasFont() )
        changeFont.Set(m_attr.GetEffectiveFont(dc->GetFont()));

    Render(rectItem, dc, state);
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7478
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Change default selected font color.

Post by ONEEYEMAN »

Hi,
Which data you display in order to use custom renderer?
But to answer you question - sis you try to override "virtual bool wxDataViewCustomRenderer::Render()"?

Thank you.
tgg_splash
Earned a small fee
Earned a small fee
Posts: 24
Joined: Thu Jan 04, 2018 8:05 am

Re: Change default selected font color.

Post by tgg_splash »

ONEEYEMAN wrote:Hi,
Which data you display in order to use custom renderer?
But to answer you question - sis you try to override "virtual bool wxDataViewCustomRenderer::Render()"?

Thank you.
The column I use my derived renderer is ok. However, it is not smart to replace default renderer with my derived renderer, there would be too much work. Well, there is no way to change the default color without changing the source of wxWidgets. Fortunately, after asking PM, there is no need to face the problem.
Post Reply