From: Vadim Zeitlin Date: Mon, 6 Apr 2009 22:11:48 +0000 (+0000) Subject: return better fitting size from DoGetBestSize() for grids with few rows X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/916533c0dc8c44e5f060cb1d8e0746e9e96e5ab8?ds=sidebyside return better fitting size from DoGetBestSize() for grids with few rows git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60046 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index d111896c38..b6758f21eb 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -825,11 +825,17 @@ void wxPropertyGrid::SetExtraStyle( long exStyle ) // returns the best acceptable minimal size wxSize wxPropertyGrid::DoGetBestSize() const { - int hei = 15; - if ( m_lineHeight > hei ) - hei = m_lineHeight; - wxSize sz = wxSize( 60, hei+40 ); + int lineHeight = wxMax(15, m_lineHeight); + // don't make the grid too tall (limit height to 10 items) but don't + // make it too small neither + int numLines = wxMin + ( + wxMax(m_pState->m_properties->GetChildCount(), 3), + 10 + ); + + const wxSize sz = wxSize(60, lineHeight*numLines + 40); CacheBestSize(sz); return sz; }