]> git.saurik.com Git - wxWidgets.git/commitdiff
return better fitting size from DoGetBestSize() for grids with few rows
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 6 Apr 2009 22:11:48 +0000 (22:11 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 6 Apr 2009 22:11:48 +0000 (22:11 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60046 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/propgrid/propgrid.cpp

index d111896c389c61569164471045b54d2f32fa30e2..b6758f21ebde88c364db434d7e902402124bd8c0 100644 (file)
@@ -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;
 }