Demonstrate checkboxes in virtual wxListCtrl

This commit is contained in:
Maarten Bent
2019-05-05 14:26:39 +02:00
parent c20060745f
commit dd23722432
2 changed files with 47 additions and 0 deletions

View File

@@ -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)