diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index f90fff3954..f8b524e6f4 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -2687,7 +2687,6 @@ private: void DoGridProcessTab(wxKeyboardState& kbdState); // common implementations of methods defined for both rows and columns - void DeselectLine(int line, const wxGridOperations& oper); bool DoEndDragResizeLine(const wxGridOperations& oper, wxGridWindow *gridWindow); int PosToLinePos(int pos, bool clipToMinMax, const wxGridOperations& oper, diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 1fed7a841d..6d56e2b556 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -10198,47 +10198,30 @@ void wxGrid::SelectAll() // cell, row and col deselection // ---------------------------------------------------------------------------- -void wxGrid::DeselectLine(int line, const wxGridOperations& oper) -{ - if ( !m_selection ) - return; - - const wxGridSelectionModes mode = m_selection->GetSelectionMode(); - if ( mode == oper.GetSelectionMode() || - mode == wxGrid::wxGridSelectRowsOrColumns ) - { - const wxGridCellCoords c(oper.MakeCoords(line, 0)); - if ( m_selection->IsInSelection(c) ) - m_selection->ToggleCellSelection(c); - } - else if ( mode != oper.Dual().GetSelectionMode() ) - { - const int nOther = oper.Dual().GetNumberOfLines(this, NULL); - for ( int i = 0; i < nOther; i++ ) - { - const wxGridCellCoords c(oper.MakeCoords(line, i)); - if ( m_selection->IsInSelection(c) ) - m_selection->ToggleCellSelection(c); - } - } - //else: can only select orthogonal lines so no lines in this direction - // could have been selected anyhow -} - void wxGrid::DeselectRow(int row) { - DeselectLine(row, wxGridRowOperations()); + wxCHECK_RET( row >= 0 && row < m_numRows, wxT("invalid row index") ); + + if ( m_selection ) + m_selection->DeselectBlock(wxGridBlockCoords(row, 0, row, m_numRows - 1)); } void wxGrid::DeselectCol(int col) { - DeselectLine(col, wxGridColumnOperations()); + wxCHECK_RET( col >= 0 && col < m_numCols, wxT("invalid column index") ); + + if ( m_selection ) + m_selection->DeselectBlock(wxGridBlockCoords(0, col, m_numCols - 1, col)); } void wxGrid::DeselectCell( int row, int col ) { - if ( m_selection && m_selection->IsInSelection(row, col) ) - m_selection->ToggleCellSelection(row, col); + wxCHECK_RET( row >= 0 && row < m_numRows && + col >= 0 && col < m_numCols, + wxT("invalid cell coords") ); + + if ( m_selection ) + m_selection->DeselectBlock(wxGridBlockCoords(row, col, row, col)); } bool wxGrid::IsSelection() const