Page 1 of 1

wxDataViewListCtrl: Change the background color for selectedrows?

Posted: Thu Jan 25, 2018 8:47 pm
by ColleenKobe
I've created a wxDataViewListCtrl. When the program runs, some rows will have active data, and some rows will have "inactive" data.

Is there a way that I can change the background color of the inactive rows to gray? Assume the background color would "key off" one of the fields. I do know about the wxDV_HORIZ_RULES, but that's every other row no matter what the contents of the row are.

Thanks!

Colleen

Re: wxDataViewListCtrl: Change the background color for selectedrows?

Posted: Thu Jan 25, 2018 9:33 pm
by ONEEYEMAN
Hi,
Didi you look at the 'dataview' sample?

Thank you.

Re: wxDataViewListCtrl: Change the background color for selectedrows?

Posted: Fri Jan 26, 2018 3:57 pm
by ColleenKobe
Thank you for answering, OneEyeMan.

Yes, I looked at the wxDataViewCtrl sample. There was a tab there showing a wxDataViewListCtrl, but all the rows had a white background.

There was also a tab called MyListModel with different colors of text, but the row backgrounds were also all white.

Colleen

Re: wxDataViewListCtrl: Change the background color for selectedrows?

Posted: Fri Jan 26, 2018 4:57 pm
by doublemax
As usual, a look into the sources reveals the ultimate truth... ;)

Under Windows wxDVC uses wxRendererNative::Get().DrawItemSelectionRect() to draw the cell background...

Code: Select all

    wxBrush brush;
    if ( flags & wxCONTROL_SELECTED )
    {
        if ( flags & wxCONTROL_FOCUSED )
        {
            brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
        }
        else // !focused
        {
            brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
        }
    }
    else // !selected
    {
        brush = *wxTRANSPARENT_BRUSH;
    }
... and that uses system colors for the background with no simple way to override them.

Re: wxDataViewListCtrl: Change the background color for selectedrows?

Posted: Mon Jan 29, 2018 12:58 pm
by ColleenKobe
Doublemax,

Thank you for investigating the background color issue for me. I wouldn't have known where to START looking.

It sounds like changing the background color in a wxDataViewListCtrl involves more time and energy than the results warrant. Too bad, but OK.

Thanks again!

Colleen