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: 48
Joined: Sun Oct 18, 2015 9:31 am

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

Post by thoray »

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: 7458
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 »

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: 48
Joined: Sun Oct 18, 2015 9:31 am

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

Post by thoray »

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: 7458
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 »

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: 48
Joined: Sun Oct 18, 2015 9:31 am

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

Post by thoray »

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: 7458
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 »

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: 48
Joined: Sun Oct 18, 2015 9:31 am

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

Post by thoray »

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