]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/headerctrlg.cpp
force doxygen autolink wrt wxLanguage enum
[wxWidgets.git] / src / generic / headerctrlg.cpp
index f1a98083c2a933480181e9075da2a33de59ec30b..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
@@ -473,28 +482,7 @@ wxArrayInt wxHeaderCtrl::DoGetColumnsOrder() const
 
 void wxHeaderCtrl::DoMoveCol(unsigned int idx, unsigned int pos)
 {
-    const unsigned count = m_colIndices.size();
-
-    wxArrayInt colIndices;
-    colIndices.reserve(count);
-    for ( unsigned n = 0; n < count; n++ )
-    {
-        // NB: order of checks is important for this to work when the new
-        //     column position is the same as the old one
-
-        // insert the column at its new position
-        if ( colIndices.size() == pos )
-            colIndices.push_back(idx);
-
-        // delete the column from its old position
-        const unsigned idxOld = m_colIndices[n];
-        if ( idxOld == idx )
-            continue;
-
-        colIndices.push_back(idxOld);
-    }
-
-    m_colIndices = colIndices;
+    MoveColumnInOrderArray(m_colIndices, idx, pos);
 
     Refresh();
 }