From 684571809d170c3b5ea62adb36e2fe78cbefcaca Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 8 Feb 2004 15:16:21 +0000 Subject: [PATCH] don't try O(N) actions in virtual view, this gives impression that the sample hangs (as in bug 857038) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25640 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/listctrl/listtest.cpp | 17 +++++++++++++++++ samples/listctrl/listtest.h | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/samples/listctrl/listtest.cpp b/samples/listctrl/listtest.cpp index dc9acf8eaa..c9462339dd 100644 --- a/samples/listctrl/listtest.cpp +++ b/samples/listctrl/listtest.cpp @@ -266,6 +266,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 +323,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 +333,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); diff --git a/samples/listctrl/listtest.h b/samples/listctrl/listtest.h index 97a719b7dc..b3efd7c148 100644 --- a/samples/listctrl/listtest.h +++ b/samples/listctrl/listtest.h @@ -133,6 +133,11 @@ private: void InitWithIconItems(bool withText, bool sameIcon = FALSE); void InitWithVirtualItems(); + // return true if the control is not in virtual view, give an error message + // and return false if it is + bool CheckNonVirtual() const; + + wxLog *m_logOld; DECLARE_NO_COPY_CLASS(MyFrame) -- 2.45.2