From f7b4b3435bf7e8ec33459df8d6ce69a0c074f377 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 2 Jan 2001 15:35:46 +0000 Subject: [PATCH] patch adding DeselectXXX() functions from Roland Scholz git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9032 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/grid.h | 6 +++++ src/generic/grid.cpp | 46 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index 21ad06b098..2f8296cec4 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -1314,6 +1314,12 @@ public: bool IsSelection(); + // ------ deselection + // + void DeselectRow( int row ); + void DeselectCol( int col ); + void DeselectCell( int row, int col ); + void ClearSelection(); bool IsInSelection( int row, int col ); diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 0dae989bc8..7b2b3b3f43 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -8275,6 +8275,52 @@ void wxGrid::SelectAll() m_selection->SelectBlock( 0, 0, m_numRows-1, m_numCols-1 ); } +// +// ------ Cell, row and col deselection +// + +void wxGrid::DeselectRow( int row ) +{ + if ( m_selection->GetSelectionMode() == wxGrid::wxGridSelectRows ) + { + if ( m_selection->IsInSelection(row, 0 ) ) + m_selection->ToggleCellSelection( row, 0); + } + else + { + int nCols = GetNumberCols(); + for ( int i = 0; i < nCols ; i++ ) + { + if ( m_selection->IsInSelection(row, i ) ) + m_selection->ToggleCellSelection( row, i); + } + } +} + +void wxGrid::DeselectCol( int col ) +{ + if ( m_selection->GetSelectionMode() == wxGrid::wxGridSelectColumns ) + { + if ( m_selection->IsInSelection(0, col ) ) + m_selection->ToggleCellSelection( 0, col); + } + else + { + int nRows = GetNumberRows(); + for ( int i = 0; i < nRows ; i++ ) + { + if ( m_selection->IsInSelection(i, col ) ) + m_selection->ToggleCellSelection(i, col); + } + } +} + +void wxGrid::DeselectCell( int row, int col ) +{ + if ( m_selection->IsInSelection(row, col) ) + m_selection->ToggleCellSelection(row, col); +} + bool wxGrid::IsSelection() { return ( m_selection->IsSelection() || -- 2.47.2