Incorporate GTK preferred size into best size for non-native controls

It may be better than the default GetBestSize() result. Fixes best size
of wxStaticBox when children are narrower than label, and minimum size for
controls using a scrolled window, such as wxTreeCtrl.
This commit is contained in:
Paul Cornett 2023-12-09 18:17:53 -08:00
parent 3af16cd063
commit 375fd2c630

View file

@ -78,15 +78,11 @@ wxSize wxControl::DoGetBestSize() const
// Do not return any arbitrary default value...
wxASSERT_MSG( m_widget, wxT("DoGetBestSize called before creation") );
wxSize best;
wxSize best(GTKGetPreferredSize(m_widget));
if (m_wxwindow)
{
// this is not a native control, size_request is likely to be (0,0)
best = wxControlBase::DoGetBestSize();
}
else
{
best = GTKGetPreferredSize(m_widget);
// For non-native controls, GTK preferred size may not be useful
best.IncTo(base_type::DoGetBestSize());
}
return best;