Page 1 of 1

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

Posted: Tue Mar 10, 2020 12:50 pm
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?

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

Posted: Tue Mar 10, 2020 2:42 pm
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.

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

Posted: Thu Mar 12, 2020 12:38 pm
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

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

Posted: Thu Mar 12, 2020 2:08 pm
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.

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

Posted: Thu Mar 12, 2020 2:35 pm
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.

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

Posted: Thu Mar 12, 2020 2:44 pm
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.

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

Posted: Thu Mar 12, 2020 2:48 pm
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).