+ // Only needed to get the correct rect.x:
+ wxRect rect ( CellToRect( 0, m_dragRowOrCol ) );
+ rect.y = 0;
+ CalcScrolledPosition(rect.x, 0, &rect.x, &dummy);
+ rect.width = cw - rect.x;
+ rect.height = m_colLabelHeight;
+ m_colLabelWin->Refresh( true, &rect );
+ rect.height = ch;
+
+ // if there is a multicell block, paint all of it
+ if (m_table)
+ {
+ int i, cell_rows, cell_cols, subtract_cols = 0;
+ int topRow = YToRow(top);
+ int bottomRow = internalYToRow(top + cw);
+ if (topRow >= 0)
+ {
+ for (i=topRow; i<bottomRow; i++)
+ {
+ GetCellSize(i, m_dragRowOrCol, &cell_rows, &cell_cols);
+ if (cell_cols < subtract_cols)
+ subtract_cols = cell_cols;
+ }
+
+ rect.x = GetColLeft(m_dragRowOrCol + subtract_cols);
+ CalcScrolledPosition(rect.x, 0, &rect.x, &dummy);
+ rect.width = cw - rect.x;
+ }
+ }
+
+ m_gridWin->Refresh( false, &rect );
+ }
+
+ ShowCellEditControl();
+ }
+}
+
+void wxGrid::DoEndDragMoveCol()
+{
+ //The user clicked on the column but didn't actually drag
+ if ( m_dragLastPos < 0 )
+ {
+ m_colLabelWin->Refresh(); //Do this to "unpress" the column
+ return;
+ }
+
+ int newPos;
+ if ( m_moveToCol == -1 )
+ newPos = m_numCols - 1;
+ else
+ {
+ newPos = GetColPos( m_moveToCol );
+ if ( newPos > GetColPos( m_dragRowOrCol ) )
+ newPos--;
+ }
+
+ SetColPos( m_dragRowOrCol, newPos );
+}
+
+void wxGrid::SetColPos( int colID, int newPos )
+{
+ if ( m_colAt.IsEmpty() )
+ {
+ m_colAt.Alloc( m_numCols );
+
+ int i;
+ for ( i = 0; i < m_numCols; i++ )
+ {
+ m_colAt.Add( i );
+ }
+ }
+
+ int oldPos = GetColPos( colID );
+
+ //Reshuffle the m_colAt array
+ if ( newPos > oldPos )
+ {
+ int i;
+ for ( i = oldPos; i < newPos; i++ )
+ {
+ m_colAt[i] = m_colAt[i+1];
+ }
+ }
+ else
+ {
+ int i;
+ for ( i = oldPos; i > newPos; i-- )
+ {
+ m_colAt[i] = m_colAt[i-1];
+ }
+ }
+
+ m_colAt[newPos] = colID;
+
+ //Recalculate the column rights
+ if ( !m_colWidths.IsEmpty() )
+ {
+ int colRight = 0;
+ int colPos;
+ for ( colPos = 0; colPos < m_numCols; colPos++ )
+ {
+ int colID = GetColAt( colPos );
+
+ colRight += m_colWidths[colID];
+ m_colRights[colID] = colRight;
+ }
+ }
+
+ m_colLabelWin->Refresh();
+ m_gridWin->Refresh();
+}
+
+
+
+void wxGrid::EnableDragColMove( bool enable )
+{
+ if ( m_canDragColMove == enable )
+ return;
+
+ m_canDragColMove = enable;
+
+ if ( !m_canDragColMove )
+ {
+ m_colAt.Clear();
+
+ //Recalculate the column rights
+ if ( !m_colWidths.IsEmpty() )
+ {
+ int colRight = 0;
+ int colPos;
+ for ( colPos = 0; colPos < m_numCols; colPos++ )