X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a236aa2058ccf3d36e9cafc20fa7375080c4be50..41f6f17d01562aa09bdbcc6b02241b62f1d06b75:/samples/widgets/itemcontainer.cpp diff --git a/samples/widgets/itemcontainer.cpp b/samples/widgets/itemcontainer.cpp index c46a738d08..f8517a5374 100644 --- a/samples/widgets/itemcontainer.cpp +++ b/samples/widgets/itemcontainer.cpp @@ -68,7 +68,7 @@ private: ItemContainerWidgetsPage::ItemContainerWidgetsPage(WidgetsBookCtrl *book, wxImageList *image_list, - char* icon[]) + const char *const icon[]) : WidgetsPage(book, image_list, icon), m_trackedDataObjects(0) { m_items.Add(_T("This")); @@ -229,6 +229,20 @@ bool ItemContainerWidgetsPage::VerifyClientData(wxUIntPtr i, const wxString& str return true; } +/* static */ +wxArrayString +ItemContainerWidgetsPage::MakeArray(const wxSortedArrayString& sorted) +{ + wxArrayString a; + + const size_t count = sorted.size(); + a.reserve(count); + for ( size_t n = 0; n < count; n++ ) + a.push_back(sorted[n]); + + return a; +} + void ItemContainerWidgetsPage::OnButtonTestItemContainer(wxCommandEvent&) { m_container = GetContainer(); @@ -239,8 +253,8 @@ void ItemContainerWidgetsPage::OnButtonTestItemContainer(wxCommandEvent&) (m_container->IsSorted() ? "Sorted" : "Unsorted")); const wxArrayString - & expected_result = m_container->IsSorted() ? m_itemsSorted - : m_items; + expected_result = m_container->IsSorted() ? MakeArray(m_itemsSorted) + : m_items; StartTest(_T("Append one item")); wxString item = m_items[0]; @@ -253,7 +267,8 @@ void ItemContainerWidgetsPage::OnButtonTestItemContainer(wxCommandEvent&) StartTest(_T("Append some items with data objects")); wxClientData **objects = new wxClientData *[m_items.GetCount()]; - for ( unsigned i = 0; i < m_items.GetCount(); ++i ) + unsigned i; + for ( i = 0; i < m_items.GetCount(); ++i ) objects[i] = CreateClientData(i); m_container->Append(m_items, objects); EndTest(expected_result); @@ -261,19 +276,19 @@ void ItemContainerWidgetsPage::OnButtonTestItemContainer(wxCommandEvent&) StartTest(_T("Append some items with data")); void **data = new void *[m_items.GetCount()]; - for ( unsigned i = 0; i < m_items.GetCount(); ++i ) - data[i] = (void*)i; + for ( i = 0; i < m_items.GetCount(); ++i ) + data[i] = wxUIntToPtr(i); m_container->Append(m_items, data); EndTest(expected_result); delete[] data; StartTest(_T("Append some items with data, one by one")); - for ( unsigned i = 0; i < m_items.GetCount(); ++i ) - m_container->Append(m_items[i], (void*)i); + for ( i = 0; i < m_items.GetCount(); ++i ) + m_container->Append(m_items[i], wxUIntToPtr(i)); EndTest(expected_result); StartTest(_T("Append some items with data objects, one by one")); - for ( unsigned i = 0; i < m_items.GetCount(); ++i ) + for ( i = 0; i < m_items.GetCount(); ++i ) m_container->Append(m_items[i], CreateClientData(i)); EndTest(expected_result); @@ -281,7 +296,7 @@ void ItemContainerWidgetsPage::OnButtonTestItemContainer(wxCommandEvent&) { StartTest(_T("Insert in reverse order with data, one by one")); for ( unsigned i = m_items.GetCount(); i; --i ) - m_container->Insert(m_items[i - 1], 0, (void*)(i - 1)); + m_container->Insert(m_items[i - 1], 0, wxUIntToPtr(i - 1)); EndTest(expected_result); } }