+ // Remove single cells contained in newly selected block.
+ if ( m_selectionMode == wxGrid::wxGridSelectCells )
+ {
+ count = m_cellSelection.GetCount();
+ for ( n = 0; n < count; n++ )
+ {
+ wxGridCellCoords& coords = m_cellSelection[n];
+ if ( BlockContainsCell( topRow, leftCol, bottomRow, rightCol,
+ coords.GetRow(), coords.GetCol() ) )
+ {
+ m_cellSelection.RemoveAt(n);
+ n--;
+ count--;
+ }
+ }
+ }
+
+ // If a block containing the selection is already selected, return,
+ // if a block contained in the selection is found, remove it.
+
+ count = m_blockSelectionTopLeft.GetCount();
+ for ( n = 0; n < count; n++ )
+ {
+ wxGridCellCoords& coords1 = m_blockSelectionTopLeft[n];
+ wxGridCellCoords& coords2 = m_blockSelectionBottomRight[n];
+
+ switch ( BlockContain( coords1.GetRow(), coords1.GetCol(),
+ coords2.GetRow(), coords2.GetCol(),
+ topRow, leftCol, bottomRow, rightCol ) )
+ {
+ case 1:
+ return;
+
+ case -1:
+ m_blockSelectionTopLeft.RemoveAt(n);
+ m_blockSelectionBottomRight.RemoveAt(n);
+ n--;
+ count--;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ // If a row containing the selection is already selected, return,
+ // if a row contained in newly selected block is found, remove it.