X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/355f240724ba1a4d9b4c7fc07766aa16883e436e..a333120784e3b3af222c4dd95ed383288bd1a2e0:/samples/listctrl/listtest.cpp diff --git a/samples/listctrl/listtest.cpp b/samples/listctrl/listtest.cpp index fed6bae9f8..dc9acf8eaa 100644 --- a/samples/listctrl/listtest.cpp +++ b/samples/listctrl/listtest.cpp @@ -114,11 +114,14 @@ static const int NUM_ITEMS = 30; // number of items in icon/small icon view static const int NUM_ICONS = 9; -int wxCALLBACK MyCompareFunction(long item1, long item2, long sortData) +int wxCALLBACK MyCompareFunction(long item1, long item2, long WXUNUSED(sortData)) { // inverse the order - if (item1 < item2) return -1; - if (item1 > item2) return 1; + if (item1 < item2) + return -1; + if (item1 > item2) + return 1; + return 0; } @@ -246,6 +249,13 @@ MyFrame::~MyFrame() } void MyFrame::OnSize(wxSizeEvent& event) +{ + DoSize(); + + event.Skip(); +} + +void MyFrame::DoSize() { if ( !m_logWindow ) return; @@ -254,8 +264,6 @@ void MyFrame::OnSize(wxSizeEvent& event) wxCoord y = (2*size.y)/3; m_listCtrl->SetSize(0, 0, size.x, y); m_logWindow->SetSize(0, y + 1, size.x, size.y - y); - - event.Skip(); } void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) @@ -271,14 +279,14 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) dialog.ShowModal(); } -void MyFrame::OnFreeze(wxCommandEvent& event) +void MyFrame::OnFreeze(wxCommandEvent& WXUNUSED(event)) { wxLogMessage(_T("Freezing the control")); m_listCtrl->Freeze(); } -void MyFrame::OnThaw(wxCommandEvent& event) +void MyFrame::OnThaw(wxCommandEvent& WXUNUSED(event)) { wxLogMessage(_T("Thawing the control")); @@ -299,7 +307,7 @@ void MyFrame::OnFocusLast(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnToggleFirstSel(wxCommandEvent& WXUNUSED(event)) { - m_listCtrl->SetItemState(0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); + m_listCtrl->SetItemState(0, (~m_listCtrl->GetItemState(0, wxLIST_STATE_SELECTED) ) & wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); } void MyFrame::OnDeselectAll(wxCommandEvent& WXUNUSED(event)) @@ -362,9 +370,7 @@ void MyFrame::RecreateList(long flags, bool withText) } } -#ifdef __WXMSW__ - SendSizeEvent(); -#endif + DoSize(); m_logWindow->Clear(); } @@ -512,7 +518,7 @@ void MyFrame::OnSort(wxCommandEvent& WXUNUSED(event)) sw.Time())); } -void MyFrame::OnShowSelInfo(wxCommandEvent& event) +void MyFrame::OnShowSelInfo(wxCommandEvent& WXUNUSED(event)) { int selCount = m_listCtrl->GetSelectedItemCount(); wxLogMessage(_T("%d items selected:"), selCount); @@ -538,7 +544,7 @@ void MyFrame::OnShowSelInfo(wxCommandEvent& event) } } -void MyFrame::OnShowColInfo(wxCommandEvent& event) +void MyFrame::OnShowColInfo(wxCommandEvent& WXUNUSED(event)) { int count = m_listCtrl->GetColumnCount(); wxLogMessage(wxT("%d columns:"), count); @@ -713,7 +719,9 @@ void MyListCtrl::OnBeginLabelEdit(wxListEvent& event) void MyListCtrl::OnEndLabelEdit(wxListEvent& event) { - wxLogMessage( wxT("OnEndLabelEdit: %s"), event.m_item.m_text.c_str()); + wxLogMessage( wxT("OnEndLabelEdit: %s"), + event.IsEditCancelled() ? _T("[cancelled]") + : event.m_item.m_text.c_str()); } void MyListCtrl::OnDeleteItem(wxListEvent& event) @@ -906,7 +914,7 @@ wxString MyListCtrl::OnGetItemText(long item, long column) const return wxString::Format(_T("Column %ld of item %ld"), column, item); } -int MyListCtrl::OnGetItemImage(long item) const +int MyListCtrl::OnGetItemImage(long WXUNUSED(item)) const { return 0; }