Simplify wxGridSelectionRange to provide only iterators

This class was a strange hybrid of a container/view/range and iterator,
as it both provided begin()/end() container-like methods and
iterator-like methods for dereferencing/advancing.

Simplify this by removing the latter part and making this class really
just a range, with its own iterator class in order to avoid leaking the
exact type of the iterator used in the API.

Note that while it's now completely trivial, it is still useful as it
isolates the application code from the vector used to store the selected
blocks currently and will allow to change internal representation in the
future without breaking the existing code.
This commit is contained in:
Vadim Zeitlin
2020-04-04 19:22:02 +02:00
parent 7231a6a855
commit 0a5a904d8d
3 changed files with 97 additions and 60 deletions

View File

@@ -524,18 +524,16 @@ TEST_CASE_METHOD(GridTestCase, "Grid::Selection", "[grid]")
CHECK(!m_grid->IsInSelection(3, 0));
}
TEST_CASE_METHOD(GridTestCase, "Grid::SelectionIterator", "[grid]")
TEST_CASE_METHOD(GridTestCase, "Grid::SelectionRange", "[grid]")
{
CHECK(!m_grid->GetSelectionRange().Valid());
const wxGridSelectionRange empty = m_grid->GetSelectionRange();
CHECK( empty.begin() == empty.end() );
m_grid->SelectBlock(1, 0, 3, 1);
wxGridSelectionRange sel = m_grid->GetSelectionRange();
CHECK(sel.Valid());
CHECK(sel.GetBlockCoords() == wxGridBlockCoords(1, 0, 3, 1));
sel.Next();
CHECK(!sel.Valid());
REQUIRE( sel.begin() != sel.end() );
CHECK( *sel.begin() == wxGridBlockCoords(1, 0, 3, 1) );
#if __cplusplus >= 201103L || wxCHECK_VISUALC_VERSION(10)
m_grid->SelectBlock(4, 0, 7, 1, true);