]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/widgets/itemcontainer.cpp
fixing infinite recursion for rotated text, introduced in cleanup r57915
[wxWidgets.git] / samples / widgets / itemcontainer.cpp
index ad3aea3a5d97bb3befae27ae2079bea039f0663e..f8517a5374380c12945aab539fef18cf18893d46 100644 (file)
@@ -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"));
@@ -121,7 +121,7 @@ void ItemContainerWidgetsPage::StartTest(const wxString& label)
     wxLogMessage(_T("Test - %s:"), label.c_str());
 }
 
-void ItemContainerWidgetsPage::EndTest(const wxMaybeSortedArrayString& items)
+void ItemContainerWidgetsPage::EndTest(const wxArrayString& items)
 {
     const unsigned count = m_container->GetCount();
 
@@ -177,7 +177,7 @@ void ItemContainerWidgetsPage::EndTest(const wxMaybeSortedArrayString& items)
 }
 
 wxString
-ItemContainerWidgetsPage::DumpContainerData(const wxMaybeSortedArrayString& expected) const
+ItemContainerWidgetsPage::DumpContainerData(const wxArrayString& expected) const
 {
     wxString str;
     str << _T("Current content:\n");
@@ -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();
@@ -238,9 +252,9 @@ void ItemContainerWidgetsPage::OnButtonTestItemContainer(wxCommandEvent&)
                  GetWidget()->GetClassInfo()->GetClassName(),
                  (m_container->IsSorted() ? "Sorted" : "Unsorted"));
 
-    const wxMaybeSortedArrayString&
-        expected_result = m_container->IsSorted() ? m_itemsSorted
-                                                   : m_items;
+    const wxArrayString
+        expected_result = m_container->IsSorted() ? MakeArray(m_itemsSorted)
+                                                  : m_items;
 
     StartTest(_T("Append one item"));
     wxString item = m_items[0];
@@ -263,14 +277,14 @@ void ItemContainerWidgetsPage::OnButtonTestItemContainer(wxCommandEvent&)
     StartTest(_T("Append some items with data"));
     void **data = new void *[m_items.GetCount()];
     for ( i = 0; i < m_items.GetCount(); ++i )
-        data[i] = (void*)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 ( i = 0; i < m_items.GetCount(); ++i )
-        m_container->Append(m_items[i], (void*)i);
+        m_container->Append(m_items[i], wxUIntToPtr(i));
     EndTest(expected_result);
 
     StartTest(_T("Append some items with data objects, one by one"));
@@ -282,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);
     }
 }