+void MyFrame::OnFind(wxCommandEvent& WXUNUSED(event))
+{
+ wxStopWatch sw;
+
+ const int itemCount = m_listCtrl->GetItemCount();
+ for ( int i = 0; i < itemCount; i++ )
+ m_listCtrl->FindItem(-1, i);
+
+ wxLogMessage("Calling Find() for all %d items took %ld ms",
+ itemCount, sw.Time());
+}
+
+void MyFrame::OnShowSelInfo(wxCommandEvent& WXUNUSED(event))
+{
+ int selCount = m_listCtrl->GetSelectedItemCount();
+ wxLogMessage(_T("%d items selected:"), selCount);
+
+ // don't show too many items
+ size_t shownCount = 0;
+
+ long item = m_listCtrl->GetNextItem(-1, wxLIST_NEXT_ALL,
+ wxLIST_STATE_SELECTED);
+ while ( item != -1 )
+ {
+ wxLogMessage(_T("\t%ld (%s)"),
+ item, m_listCtrl->GetItemText(item).c_str());
+
+ if ( ++shownCount > 10 )
+ {
+ wxLogMessage(_T("\t... more selected items snipped..."));
+ break;
+ }
+
+ item = m_listCtrl->GetNextItem(item, wxLIST_NEXT_ALL,
+ wxLIST_STATE_SELECTED);
+ }
+}
+
+void MyFrame::OnShowViewRect(wxCommandEvent& WXUNUSED(event))
+{
+ const wxRect r = m_listCtrl->GetViewRect();
+ wxLogMessage("View rect: (%d, %d)-(%d, %d)",
+ r.GetLeft(), r.GetTop(), r.GetRight(), r.GetBottom());
+}
+
+// ----------------------------------------------------------------------------
+// column order tests
+// ----------------------------------------------------------------------------
+
+#ifdef wxHAS_LISTCTRL_COLUMN_ORDER
+
+static wxString DumpIntArray(const wxArrayInt& a)
+{
+ wxString s("{ ");
+ const size_t count = a.size();
+ for ( size_t n = 0; n < count; n++ )
+ {
+ if ( n )
+ s += ", ";
+ s += wxString::Format("%lu", (unsigned long)a[n]);
+ }
+
+ s += " }";
+
+ return s;
+}
+
+void MyFrame::OnSetColOrder(wxCommandEvent& WXUNUSED(event))
+{
+ wxArrayInt order(3);
+ order[0] = 2;
+ order[1] = 0;
+ order[2] = 1;
+ if ( m_listCtrl->SetColumnsOrder(order) )
+ wxLogMessage("Column order set to %s", DumpIntArray(order));
+}
+
+void MyFrame::OnGetColOrder(wxCommandEvent& WXUNUSED(event))
+{
+ // show what GetColumnsOrder() returns
+ const wxArrayInt order = m_listCtrl->GetColumnsOrder();
+ wxString msg = "Columns order: " +
+ DumpIntArray(m_listCtrl->GetColumnsOrder()) + "\n";
+
+ int n;
+ const int count = m_listCtrl->GetColumnCount();
+
+ // show the results of GetColumnOrder() for each column
+ msg += "GetColumnOrder() results:\n";
+ for ( n = 0; n < count; n++ )
+ {
+ msg += wxString::Format(" %2d -> %2d\n",
+ n, m_listCtrl->GetColumnOrder(n));
+ }
+
+ // and the results of GetColumnIndexFromOrder() too
+ msg += "GetColumnIndexFromOrder() results:\n";
+ for ( n = 0; n < count; n++ )
+ {
+ msg += wxString::Format(" %2d -> %2d\n",
+ n, m_listCtrl->GetColumnIndexFromOrder(n));
+ }
+
+ wxLogMessage("%s", msg);
+}
+
+#endif // wxHAS_LISTCTRL_COLUMN_ORDER
+
+void MyFrame::OnShowColInfo(wxCommandEvent& WXUNUSED(event))
+{
+ int count = m_listCtrl->GetColumnCount();
+ wxLogMessage(wxT("%d columns:"), count);
+ for ( int c = 0; c < count; c++ )
+ {
+ wxLogMessage(wxT("\tcolumn %d has width %d"), c,
+ m_listCtrl->GetColumnWidth(c));
+ }
+}
+
+void MyFrame::OnUpdateShowColInfo(wxUpdateUIEvent& event)
+{
+ event.Enable( (m_listCtrl->GetWindowStyleFlag() & wxLC_REPORT) != 0 );
+}
+
+void MyFrame::OnToggleMultiSel(wxCommandEvent& WXUNUSED(event))
+{
+ long flags = m_listCtrl->GetWindowStyleFlag();
+ if ( flags & wxLC_SINGLE_SEL )
+ flags &= ~wxLC_SINGLE_SEL;
+ else
+ flags |= wxLC_SINGLE_SEL;
+
+ m_logWindow->WriteText(wxString::Format(wxT("Current selection mode: %sle\n"),
+ (flags & wxLC_SINGLE_SEL) ? _T("sing") : _T("multip")));
+
+ RecreateList(flags);
+}
+
+void MyFrame::OnUpdateToggleMultiSel(wxUpdateUIEvent& event)
+{
+ event.Check((m_listCtrl->GetWindowStyleFlag() & wxLC_SINGLE_SEL) == 0);
+}
+