]> git.saurik.com Git - wxWidgets.git/commitdiff
refresh the grid after resetting the columns positions to the default order
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 14 Dec 2008 20:45:39 +0000 (20:45 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 14 Dec 2008 20:45:39 +0000 (20:45 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57339 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/generic/grid.h
src/generic/grid.cpp

index 8611b6ad6cfe967cf875534d1931bb46b8c30fe8..eb0932154ccc135cbe1f1c4170d0da234981d7db 100644 (file)
@@ -2289,10 +2289,9 @@ private:
     // the sorting indicator to effectively show
     void UpdateColumnSortingIndicator(int col);
 
-    // update column right positions after their order changed (does nothing if
-    // we only use the default widths as in this case m_colRights is not used
-    // neither)
-    void UpdateColumnRights();
+    // update the grid after changing the columns order (common part of
+    // SetColPos() and ResetColPos())
+    void RefreshAfterColPosChange();
 
 
     // return the position (not index) of the column at the given logical pixel
index c516ec9072213177d5a209b01d26bf1bcdc5eb74..95ffe3cd008199fdbe97960ea126d72ef0d5d12f 100644 (file)
@@ -6842,19 +6842,36 @@ void wxGrid::DoEndMoveCol(int pos)
     m_dragRowOrCol = -1;
 }
 
-void wxGrid::UpdateColumnRights()
+void wxGrid::RefreshAfterColPosChange()
 {
-    if ( m_colWidths.empty() )
-        return;
-
-    int colRight = 0;
-    for ( int colPos = 0; colPos < m_numCols; colPos++ )
+    // recalculate the column rights as the column positions have changed,
+    // unless we calculate them dynamically because all columns widths are the
+    // same and it's easy to do
+    if ( !m_colWidths.empty() )
     {
-        int colID = GetColAt( colPos );
+        int colRight = 0;
+        for ( int colPos = 0; colPos < m_numCols; colPos++ )
+        {
+            int colID = GetColAt( colPos );
+
+            colRight += m_colWidths[colID];
+            m_colRights[colID] = colRight;
+        }
+    }
 
-        colRight += m_colWidths[colID];
-        m_colRights[colID] = colRight;
+    // and make the changes visible
+    if ( m_useNativeHeader )
+    {
+        if ( m_colAt.empty() )
+            GetColHeader()->ResetColumnsOrder();
+        else
+            GetColHeader()->SetColumnsOrder(m_colAt);
+    }
+    else
+    {
+        m_colWindow->Refresh();
     }
+    m_gridWin->Refresh();
 }
 
 void wxGrid::SetColPos(int idx, int pos)
@@ -6869,25 +6886,14 @@ void wxGrid::SetColPos(int idx, int pos)
 
     wxHeaderCtrl::MoveColumnInOrderArray(m_colAt, idx, pos);
 
-    // also recalculate the column rights as the column positions have changed
-    UpdateColumnRights();
-
-    // and make the changes visible
-    if ( m_useNativeHeader )
-        GetColHeader()->SetColumnsOrder(m_colAt);
-    else
-        m_colWindow->Refresh();
-    m_gridWin->Refresh();
+    RefreshAfterColPosChange();
 }
 
 void wxGrid::ResetColPos()
 {
     m_colAt.clear();
 
-    if ( m_useNativeHeader )
-        GetColHeader()->ResetColumnsOrder();
-    else
-        m_colWindow->Refresh();
+    RefreshAfterColPosChange();
 }
 
 void wxGrid::EnableDragColMove( bool enable )