wxListBox too short vertically for all its elements in OSX and GTK2

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
thoray
Knows some wx things
Knows some wx things
Posts: 31
Joined: Sun Oct 18, 2015 9:31 am

wxListBox too short vertically for all its elements in OSX and GTK2

Post by thoray » Tue Mar 10, 2020 12:50 pm

I add this code in a wxPanel:

Code: Select all

wxString strings[9] = {"a", "b", "c", "d", "e", "f", "g", "h", "i" };
m_listbox = new wxListBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 9, strings, wxLB_NEEDED_SB, wxDefaultValidator, wxListBoxNameStr);
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(m_listbox, 0, wxEXPAND);
this->SetSizer(sizer);
The end result is that in win64 m_listbox accurately assumes size required vertically by the 9 elements whereas on Linux GTK2 and Mac OS X the listbox is a few elements too short vertically and thus also has a scrollbar. I wonder is there something wrong with the code?

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3893
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxListBox too short vertically for all its elements in OSX and GTK2

Post by ONEEYEMAN » Tue Mar 10, 2020 2:42 pm

Hi,
Can you reproduce it in the minimal sample?

If you do - can you post the code as a patch here?

Thank you.

thoray
Knows some wx things
Knows some wx things
Posts: 31
Joined: Sun Oct 18, 2015 9:31 am

Re: wxListBox too short vertically for all its elements in OSX and GTK2

Post by thoray » Thu Mar 12, 2020 12:38 pm

Yes, I can reproduce it in the minimal sample:

Code: Select all

--- minimal.cpp	2020-03-12 14:20:28.886756494 +0200
+++ minimal2.cpp	2020-03-12 14:19:45.362540669 +0200
@@ -178,6 +178,13 @@
     CreateStatusBar(2);
     SetStatusText("Welcome to wxWidgets!");
 #endif // wxUSE_STATUSBAR
+
+wxString strings[9] = {"a", "b", "c", "d", "e", "f", "g", "h", "i" };
+wxListBox* m_listbox = new wxListBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 9, strings, wxLB_NEEDED_SB, wxDefaultValidator, wxListBoxNameStr);
+wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
+sizer->Add(m_listbox, 0, wxEXPAND);
+this->SetSizer(sizer);
+
 }
I made also this temporary fix which is added after wxListBox constructor before adding it to the sizer:

Code: Select all

#if __WXGTK__ or __WXOSX__
// HACK fix box is too short vertically for all its items
wxSize s = m_listbox->GetBestSize();
s.SetHeight(s.GetHeight()+20);
s.SetWidth(-1);
m_listbox->SetMinSize(s);
#endif

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3893
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxListBox too short vertically for all its elements in OSX and GTK2

Post by ONEEYEMAN » Thu Mar 12, 2020 2:08 pm

Hi,
You mentioned that you tested it with GTK2.
Could you try it against GTK+3?
Also - do you use an unmodified wxWidgets sources?
And you are not cross-compiling?
Finally - what OSX version are you trying to use? And what is the minimal OSX required from the configure line?

Thank you.

thoray
Knows some wx things
Knows some wx things
Posts: 31
Joined: Sun Oct 18, 2015 9:31 am

Re: wxListBox too short vertically for all its elements in OSX and GTK2

Post by thoray » Thu Mar 12, 2020 2:35 pm

The same issue in GTK+3 with unmodified git master. Native OS X Mojave 10.14, wx 3.1.3, Xcode 10.1 / SDK 10.14 minimum version 10.9. Not cross compiling.
Last edited by thoray on Thu Mar 12, 2020 2:45 pm, edited 1 time in total.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3893
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxListBox too short vertically for all its elements in OSX and GTK2

Post by ONEEYEMAN » Thu Mar 12, 2020 2:44 pm

Hi,
Could you please open a ticket at trac.wxwidgets.org?
You will need to register there (if you never did), making sure your usernamwe is one word without spaces.

Please attach your patch to the minimal sample and hopefully some one will be able to look at it.

Out of curiosity - did you try wx-3.1.3 (latest release)? Maybe its just a regression, in which case it will be simpler to track down.

Thank you.

thoray
Knows some wx things
Knows some wx things
Posts: 31
Joined: Sun Oct 18, 2015 9:31 am

Re: wxListBox too short vertically for all its elements in OSX and GTK2

Post by thoray » Thu Mar 12, 2020 2:48 pm

Ok I'l make a ticket. I tried 3.1.3, for OS X wx was 3.1.3 (I updated my answer above).

Post Reply