diff --git a/samples/listctrl/listtest.cpp b/samples/listctrl/listtest.cpp index a8d38f6520..6ce7a10cb0 100644 --- a/samples/listctrl/listtest.cpp +++ b/samples/listctrl/listtest.cpp @@ -44,6 +44,7 @@ #include "wx/sizer.h" #include "wx/sysopt.h" #include "wx/numdlg.h" +#include "wx/selstore.h" #include "listtest.h" @@ -1204,6 +1205,11 @@ void MyListCtrl::OnChecked(wxListEvent& event) { LogEvent(event, "OnChecked"); + if ( IsVirtual() ) + { + CheckItem(event.GetIndex(), true); + } + event.Skip(); } @@ -1211,6 +1217,11 @@ void MyListCtrl::OnUnChecked(wxListEvent& event) { LogEvent(event, "OnUnChecked"); + if ( IsVirtual() ) + { + CheckItem(event.GetIndex(), false); + } + event.Skip(); } @@ -1419,6 +1430,36 @@ wxString MyListCtrl::OnGetItemText(long item, long column) const } } +void MyListCtrl::CheckItem(long item, bool check) +{ + if ( IsVirtual() ) + { + m_checked.SelectItem(item, check); + RefreshItem(item); + } + else + { + wxListCtrl::CheckItem(item, check); + } +} + +bool MyListCtrl::IsItemChecked(long item) const +{ + if ( IsVirtual() ) + { + return m_checked.IsSelected(item); + } + else + { + return wxListCtrl::IsItemChecked(item); + } +} + +bool MyListCtrl::OnGetItemIsChecked(long item) const +{ + return IsItemChecked(item); +} + int MyListCtrl::OnGetItemColumnImage(long item, long column) const { if (!column) diff --git a/samples/listctrl/listtest.h b/samples/listctrl/listtest.h index e48b5292ef..dcdca2a55c 100644 --- a/samples/listctrl/listtest.h +++ b/samples/listctrl/listtest.h @@ -74,6 +74,9 @@ public: void OnRightClick(wxMouseEvent& event); + virtual void CheckItem(long item, bool check) wxOVERRIDE; + virtual bool IsItemChecked(long item) const wxOVERRIDE; + private: void ShowContextMenu(const wxPoint& pos); wxLog *m_logOld; @@ -83,11 +86,14 @@ private: void LogColEvent(const wxListEvent& event, const wxString& eventName); virtual wxString OnGetItemText(long item, long column) const wxOVERRIDE; + virtual bool OnGetItemIsChecked(long item) const wxOVERRIDE; virtual int OnGetItemColumnImage(long item, long column) const wxOVERRIDE; virtual wxItemAttr *OnGetItemAttr(long item) const wxOVERRIDE; long m_updated; + // checked boxes in virtual list + wxSelectionStore m_checked; wxDECLARE_NO_COPY_CLASS(MyListCtrl); wxDECLARE_EVENT_TABLE();