+
+ if ( m_selectionMode != wxGrid::wxGridSelectCells )
+ {
+ // if changing form row to column selection
+ // or vice versa, clear the selection.
+ if ( selmode != wxGrid::wxGridSelectCells )
+ ClearSelection();
+
+ m_selectionMode = selmode;
+ }
+ else
+ {
+ // if changing from cell selection to something else,
+ // promote selected cells/blocks to whole rows/columns.
+ size_t n;
+ while ( ( n = m_cellSelection.GetCount() ) > 0 )
+ {
+ n--;
+ wxGridCellCoords& coords = m_cellSelection[n];
+ int row = coords.GetRow();
+ int col = coords.GetCol();
+ m_cellSelection.RemoveAt(n);
+ if (selmode == wxGrid::wxGridSelectRows)
+ SelectRow( row );
+ else // selmode == wxGridSelectColumns)
+ SelectCol( col );
+ }
+
+ for (n = 0; n < m_blockSelectionTopLeft.GetCount(); n++)
+ // Note that m_blockSelectionTopLeft's size may be changing!
+ {
+ wxGridCellCoords& coords = m_blockSelectionTopLeft[n];
+ int topRow = coords.GetRow();
+ int leftCol = coords.GetCol();
+ coords = m_blockSelectionBottomRight[n];
+ int bottomRow = coords.GetRow();
+ int rightCol = coords.GetCol();
+ if (selmode == wxGrid::wxGridSelectRows)
+ {
+ if (leftCol != 0 || rightCol != m_grid->GetNumberCols() - 1 )
+ {
+ m_blockSelectionTopLeft.RemoveAt(n);
+ m_blockSelectionBottomRight.RemoveAt(n);
+ SelectBlock( topRow, 0,
+ bottomRow, m_grid->GetNumberCols() - 1,
+ false, false, false, false, false );
+ }
+ }
+ else // selmode == wxGridSelectColumns)
+ {
+ if (topRow != 0 || bottomRow != m_grid->GetNumberRows() - 1 )
+ {
+ m_blockSelectionTopLeft.RemoveAt(n);
+ m_blockSelectionBottomRight.RemoveAt(n);
+ SelectBlock( 0, leftCol,
+ m_grid->GetNumberRows() - 1, rightCol,
+ false, false, false, false, false );
+ }
+ }
+ }
+ m_selectionMode = selmode;
+ }
+}
+
+void wxGridSelection::SelectRow( int row,
+ bool ControlDown, bool ShiftDown,
+ bool AltDown, bool MetaDown )
+{
+ if ( m_selectionMode == wxGrid::wxGridSelectColumns )
+ return;
+ size_t count, n;