wxListCtrl horizontal and vertical rules

77 views
Skip to first unread message

Andrea Asztalos

unread,
Jul 18, 2022, 10:34:14 PM7/18/22
to wx-users
Hello,

I'm using wxWidgets 3.2.0 on macOS (Intel) and was testing the listctrl sample application.

The change I made was requesting the horizontal and vertical rules in report mode:

void MyFrame::OnReportView(wxCommandEvent& WXUNUSED(event))
{
    RecreateList(wxLC_REPORT | wxLC_HRULES| wxLC_VRULES);
}

The attached image shows the wxListctrl: when rows are not selected neither the vertical nor the horizontal lines appear. The vertical lines appear only for the selected rows. On Windows, both lines appear without any selection when these flags are specified.
Could you please tell me if this is a macOS feature or a bug?

Thank you,
Andrea Asztalos
Screen Shot 2022-07-18 at 10.23.26 PM.png

Vadim Zeitlin

unread,
Jul 19, 2022, 4:08:59 PM7/19/22
to wx-u...@googlegroups.com
On Mon, 18 Jul 2022 19:34:14 -0700 (PDT) Andrea Asztalos wrote:

AA> I'm using wxWidgets 3.2.0 on macOS (Intel) and was testing the listctrl
AA> sample application.
AA>
AA> The change I made was requesting the horizontal and vertical rules in
AA> report mode:
AA>
AA> void MyFrame::OnReportView(wxCommandEvent& WXUNUSED(event))
AA> {
AA> RecreateList(wxLC_REPORT | wxLC_HRULES| wxLC_VRULES);
AA> }

You don't even need to modify the sample, you can already press Cmd-I in
it to toggle the rules.

AA> The attached image shows the wxListctrl: when rows are not selected neither
AA> the vertical nor the horizontal lines appear. The vertical lines appear
AA> only for the selected rows. On Windows, both lines appear without any
AA> selection when these flags are specified.
AA> Could you please tell me if this is a macOS feature or a bug?

It's a bug because we use wxSYS_COLOUR_3DLIGHT for the rules which happens
to be white under macOS, which is the same as the default wxListCtrl
background colour -- so the rules are effectively invisible. Unfortunately
I don't really know what would be the best way to fix this, i.e. whether
the value used for wxSYS_COLOUR_3DLIGHT is wrong, the default background
colour is wrong, or both are right and we just need to use some other
system colour for the rules.

If it can help, the rules are visible in the dark mode, so not only wx
supports dark mode under macOS, but it even supports it better than the
light one! :-/

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

Andrea Asztalos

unread,
Jul 21, 2022, 1:05:21 PM7/21/22
to wx-users
Thank you for your answer.

In https://github.com/wxWidgets/wxWidgets/blob/0a8f7233cc6fd55535ae36d7d96324e9eb755f2b/include/wx/generic/private/listctrl.h I tried out this replacement and worked well on macOS (at least for wxListCtrl):

// get the colour to be used for drawing the rules

    wxColour GetRuleColour() const

    {

        //return wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT);

        return *wxLIGHT_GREY;

    }

Could this change be potentially viable for Mac platforms?

Thank you,

Andrea 


Vadim Zeitlin

unread,
Jul 24, 2022, 1:06:50 PM7/24/22
to wx-u...@googlegroups.com
On Thu, 21 Jul 2022 10:05:21 -0700 (PDT) Andrea Asztalos wrote:

AA> In https://github.com/wxWidgets/wxWidgets/blob/0a8f7233cc6fd55535ae36d7d96324e9eb755f2b/include/wx/generic/private/listctrl.h
AA> I tried out this replacement and worked well on macOS (at least for
AA> wxListCtrl):
AA>
AA> // get the colour to be used for drawing the rules
AA>
AA> wxColour GetRuleColour() const
AA>
AA> {
AA>
AA> //return wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT);
AA>
AA> return *wxLIGHT_GREY;
AA>
AA> }
AA>
AA> Could this change be potentially viable for Mac platforms?

Unfortunately no, I don't think so. It probably wouldn't look well with
the dark themes and, in any case, hardcoding a colour is almost never the
right thing to do.

We need to either find a system colour which works well for macOS too (in
both light and dark themes) or, maybe, try to do something smarter, like
find a colour based on the background colour used by the control.
Unfortunately we still don't have any generic way to do something like
this, there was a long "API for finding contrasting colours" thread on
wx-dev about a year ago but it petered out without any solution.

For now I think the least intrusive and likely to break something else
change fixing this would be to use wxSYS_COLOUR_GRAYTEXT instead of
wxSYS_COLOUR_3DLIGHT: I believe that disabled text should be visible on the
default background, but shouldn't be visible as much as the normal text
colour, so it looks like a decent choice. It works for me both under Mac
and under Linux with a light and a dark theme, so I'm going to commit this
to master and, perhaps, it could be backported to 3.2 later if we don't
find any problems with it.

Andrea Asztalos

unread,
Jul 29, 2022, 1:26:39 PM7/29/22
to wx-users
Thank you Vadim for the explanation and for the fix.

>>  so I'm going to commit this
>>  to master and, perhaps, it could be backported to 3.2 later if we don't
>>  find any problems with it.

That would be great! We are still using 3.1.4 but are in the process of switching to 3.2.0.
The look of our app will benefit a lot from this change.

Best regards,
Andrea 
Reply all
Reply to author
Forward
0 new messages