wxListView item padding on mac os

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
ryans123
In need of some credit
In need of some credit
Posts: 3
Joined: Mon Dec 26, 2022 10:37 pm

wxListView item padding on mac os

Post by ryans123 »

I am using wxListView in a cross-platform app. On Windows and Linux it looks fine, but on Mac OS the column text has no padding. I'm having trouble finding how to fix it. Note the text in the first column is right on the edge of the window with no padding:
Screenshot 2022-12-26 at 2.40.53 PM.png
How do I set the padding for the column text?

I'm on Mac OS X Ventura 13.1, using Clang 14.0.0 arm64-apple-darwin22.1.0, wxWidgets from vcpkg list says:
wxwidgets:arm64-osx 3.2.1#2 Widget toolkit and tools library for creating gr...
wxwidgets[debug-support]:arm64-osx Enable wxWidgets debugging support hooks even fo...
wxwidgets[sound]:arm64-osx Build wxSound support

I believe I am using all defaults for the list view:

Code: Select all

void MyFrame::BuildListView()
{
    listView = new wxListView(this);
    listView->AppendColumn("Col0");
    listView->AppendColumn("Col1");
    listView->AppendColumn("Col2");
    listView->SetColumnWidth(0, 90);
    listView->SetColumnWidth(1, 100);
    listView->SetColumnWidth(2, 150);

    auto listViewSizer = new wxBoxSizer(wxVERTICAL);
    listViewSizer->Add(listView, 1, wxALL | wxEXPAND, 0);
    this->SetSizerAndFit(listViewSizer);
}
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxListView item padding on mac os

Post by doublemax »

ryans123 wrote: Mon Dec 26, 2022 10:56 pm

Code: Select all

    listViewSizer->Add(listView, 1, wxALL | wxEXPAND, 0);
Use a border size > 0 (last parameter)
Use the source, Luke!
ryans123
In need of some credit
In need of some credit
Posts: 3
Joined: Mon Dec 26, 2022 10:37 pm

Re: wxListView item padding on mac os

Post by ryans123 »

Thanks for the response. That seems good as a workaround. Another workaround is to add a first column with small fixed width and don't put any values in that column. They both have some drawbacks and situations where they are not perfect, for example I also notice that the column values are to the left of the column header text. Also the fact that they are needed for mac os and not windows nor linux.

Is this kind of thing considered a bug when it is needed on one platform and not others?
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxListView item padding on mac os

Post by doublemax »

ryans123 wrote: Thu Dec 29, 2022 4:46 pm Is this kind of thing considered a bug when it is needed on one platform and not others?
Not in my opinion, but if you disagree, you can open an issue at https://github.com/wxWidgets/wxWidgets/issues
Use the source, Luke!
ryans123
In need of some credit
In need of some credit
Posts: 3
Joined: Mon Dec 26, 2022 10:37 pm

Re: wxListView item padding on mac os

Post by ryans123 »

Here are two screenshots to compare Windows and Mac, to make it easier to visualize, and also to add a text box for comparison:

Windows:
win-wx-list-view.png
win-wx-list-view.png (9.33 KiB) Viewed 861 times
Mac:
mac-wx-list-view.png
mac-wx-list-view.png (22.5 KiB) Viewed 861 times
The text box has some padding on both platforms, but not the wxListView.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxListView item padding on mac os

Post by ONEEYEMAN »

Hi,
As doublemax pointed out - open an issue at wxWidgets GitHub repository.
This is user forum, made for users by users. No core devs come here.

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxListView item padding on mac os

Post by doublemax »

On a side note: You shouldn't put controls directly onto the wxFrame. Add a single wxPanel to the wxFrame, then add the controls onto the wxPanel. That gets rid of the ugly dark background.
Use the source, Luke!
Post Reply