X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/95f913a9d6b8573a033d6beeecbba1227b3f17bb..04633c190f5a6eafe607a5712647aaa131522b1f:/samples/listctrl/listtest.cpp diff --git a/samples/listctrl/listtest.cpp b/samples/listctrl/listtest.cpp index dc9acf8eaa..4a23f885dd 100644 --- a/samples/listctrl/listtest.cpp +++ b/samples/listctrl/listtest.cpp @@ -78,6 +78,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(LIST_THAW, MyFrame::OnThaw) EVT_UPDATE_UI(LIST_SHOW_COL_INFO, MyFrame::OnUpdateShowColInfo) + EVT_UPDATE_UI(LIST_TOGGLE_MULTI_SEL, MyFrame::OnUpdateToggleMultiSel) END_EVENT_TABLE() BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl) @@ -266,6 +267,17 @@ void MyFrame::DoSize() m_logWindow->SetSize(0, y + 1, size.x, size.y - y); } +bool MyFrame::CheckNonVirtual() const +{ + if ( !m_listCtrl->HasFlag(wxLC_VIRTUAL) ) + return true; + + // "this" == whatever + wxLogWarning(_T("Can't do this in virtual view, sorry.")); + + return false; +} + void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) { Close(TRUE); @@ -312,6 +324,9 @@ void MyFrame::OnToggleFirstSel(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnDeselectAll(wxCommandEvent& WXUNUSED(event)) { + if ( !CheckNonVirtual() ) + return; + int n = m_listCtrl->GetItemCount(); for (int i = 0; i < n; i++) m_listCtrl->SetItemState(i,0,wxLIST_STATE_SELECTED); @@ -319,6 +334,9 @@ void MyFrame::OnDeselectAll(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnSelectAll(wxCommandEvent& WXUNUSED(event)) { + if ( !CheckNonVirtual() ) + return; + int n = m_listCtrl->GetItemCount(); for (int i = 0; i < n; i++) m_listCtrl->SetItemState(i,wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); @@ -574,6 +592,11 @@ void MyFrame::OnToggleMultiSel(wxCommandEvent& WXUNUSED(event)) RecreateList(flags); } +void MyFrame::OnUpdateToggleMultiSel(wxUpdateUIEvent& event) +{ + event.Check((m_listCtrl->GetWindowStyleFlag() & wxLC_SINGLE_SEL) == 0); +} + void MyFrame::OnSetFgColour(wxCommandEvent& WXUNUSED(event)) { m_listCtrl->SetForegroundColour(wxGetColourFromUser(this));