]> git.saurik.com Git - wxWidgets.git/commitdiff
fix best size caching
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 12 Dec 2008 16:31:39 +0000 (16:31 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 12 Dec 2008 16:31:39 +0000 (16:31 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57289 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/headerctrlg.cpp

index 4ec2a61120618eb18e1a8336d77d635297f63962..961c42b5d4e020af13aca5047d407992832097cc 100644 (file)
@@ -115,9 +115,14 @@ void wxHeaderCtrl::DoSetCount(unsigned int count)
 
         m_colIndices = colIndices;
     }
+    else // count didn't really change
+    {
+        return;
+    }
 
     m_numColumns = count;
 
+    InvalidateBestSize();
     Refresh();
 }
 
@@ -128,6 +133,8 @@ unsigned int wxHeaderCtrl::DoGetCount() const
 
 void wxHeaderCtrl::DoUpdate(unsigned int idx)
 {
+    InvalidateBestSize();
+
     // we need to refresh not only this column but also the ones after it in
     // case it was shown or hidden or its width changed -- it would be nice to
     // avoid doing this unnecessary by storing the old column width (TODO)
@@ -154,9 +161,11 @@ wxSize wxHeaderCtrl::DoGetBestSize() const
 {
     // the vertical size is rather arbitrary but it looks better if we leave
     // some space around the text
-    return wxSize(IsEmpty() ? wxHeaderCtrlBase::DoGetBestSize().x
-                            : GetColEnd(GetColumnCount() - 1),
-                  (7*GetCharHeight())/4);
+    const wxSize size(IsEmpty() ? wxHeaderCtrlBase::DoGetBestSize().x
+                                : GetColEnd(GetColumnCount() - 1),
+                      (7*GetCharHeight())/4);
+    CacheBestSize(size);
+    return size;
 }
 
 int wxHeaderCtrl::GetColStart(unsigned int idx) const