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
This commit is contained in:
parent
055898b8f0
commit
684571809d
@ -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);
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user