Add possibility to iterate over all selected items in wxSelectionStore.

This is necessary for retrieving all the selected items at once: while doing
this is not recommended for a control with a potentially very large number of
items, it must be possible to allow using wxSelectionStore for wxDataViewCtrl
implementation as wxDataViewCtrl must implement its GetSelections() method.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77902 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-09-27 20:46:15 +00:00
parent f5941e4f83
commit d058c09e9f
3 changed files with 70 additions and 0 deletions

View File

@@ -45,12 +45,14 @@ private:
CPPUNIT_TEST( SelectRange );
CPPUNIT_TEST( SetItemCount );
CPPUNIT_TEST( Clear );
CPPUNIT_TEST( Iterate );
CPPUNIT_TEST_SUITE_END();
void SelectItem();
void SelectRange();
void SetItemCount();
void Clear();
void Iterate();
// NB: must be even
static const unsigned NUM_ITEMS;
@@ -131,3 +133,19 @@ void SelStoreTestCase::Clear()
CPPUNIT_ASSERT_EQUAL( 0u, m_store->GetSelectedCount() );
}
void SelStoreTestCase::Iterate()
{
m_store->SelectRange(NUM_ITEMS/2 - 1, NUM_ITEMS/2 + 1);
wxSelectionStore::IterationState cookie;
CPPUNIT_ASSERT_EQUAL(NUM_ITEMS/2 - 1, m_store->GetFirstSelectedItem(cookie));
CPPUNIT_ASSERT_EQUAL(NUM_ITEMS/2, m_store->GetNextSelectedItem(cookie));
CPPUNIT_ASSERT_EQUAL(NUM_ITEMS/2 + 1, m_store->GetNextSelectedItem(cookie));
CPPUNIT_ASSERT_EQUAL(wxSelectionStore::NO_SELECTION, m_store->GetNextSelectedItem(cookie));
m_store->SelectRange(0, NUM_ITEMS - 1);
m_store->SelectItem(0, false);
CPPUNIT_ASSERT_EQUAL(1, m_store->GetFirstSelectedItem(cookie));
}