Let wxGrid::GetSelectionBlockTopLeft/BottomRight work in any mode

These functions used to work in any mode until the changes of 02509cbc39
(Refactor wxGridSelection to store selection as blocks only, 2020-03-03)
and should continue to do so, if only for compatibility.
This commit is contained in:
Vadim Zeitlin 2021-10-26 19:51:26 +01:00
parent 9b820b74b2
commit c28c7edbb4
2 changed files with 10 additions and 7 deletions

View File

@ -746,10 +746,6 @@ wxGridCellCoordsArray wxGridSelection::GetCellSelection() const
wxGridCellCoordsArray wxGridSelection::GetBlockSelectionTopLeft() const wxGridCellCoordsArray wxGridSelection::GetBlockSelectionTopLeft() const
{ {
// return blocks only in wxGridSelectCells selection mode
if ( m_selectionMode != wxGrid::wxGridSelectCells )
return wxGridCellCoordsArray();
wxGridCellCoordsArray coords; wxGridCellCoordsArray coords;
const size_t count = m_selection.size(); const size_t count = m_selection.size();
coords.reserve(count); coords.reserve(count);
@ -762,9 +758,6 @@ wxGridCellCoordsArray wxGridSelection::GetBlockSelectionTopLeft() const
wxGridCellCoordsArray wxGridSelection::GetBlockSelectionBottomRight() const wxGridCellCoordsArray wxGridSelection::GetBlockSelectionBottomRight() const
{ {
if ( m_selectionMode != wxGrid::wxGridSelectCells )
return wxGridCellCoordsArray();
wxGridCellCoordsArray coords; wxGridCellCoordsArray coords;
const size_t count = m_selection.size(); const size_t count = m_selection.size();
coords.reserve(count); coords.reserve(count);

View File

@ -1163,6 +1163,16 @@ TEST_CASE_METHOD(GridTestCase, "Grid::SelectionMode", "[grid]")
CHECK( m_grid->IsInSelection(5, 1) ); CHECK( m_grid->IsInSelection(5, 1) );
CHECK( !m_grid->IsInSelection(3, 1) ); CHECK( !m_grid->IsInSelection(3, 1) );
// Check that top left/bottom right selection functions still work in row
// selection mode.
wxGridCellCoordsArray arr = m_grid->GetSelectionBlockTopLeft();
REQUIRE( arr.size() == 1 );
CHECK( arr[0] == wxGridCellCoords(5, 0) );
arr = m_grid->GetSelectionBlockBottomRight();
REQUIRE( arr.size() == 1 );
CHECK( arr[0] == wxGridCellCoords(5, 1) );
//Test row selection be selecting a single cell and checking the whole //Test row selection be selecting a single cell and checking the whole
//row is selected //row is selected
m_grid->ClearSelection(); m_grid->ClearSelection();