Demonstrate checkboxes in virtual wxListCtrl
This commit is contained in:
@@ -44,6 +44,7 @@
|
|||||||
#include "wx/sizer.h"
|
#include "wx/sizer.h"
|
||||||
#include "wx/sysopt.h"
|
#include "wx/sysopt.h"
|
||||||
#include "wx/numdlg.h"
|
#include "wx/numdlg.h"
|
||||||
|
#include "wx/selstore.h"
|
||||||
|
|
||||||
#include "listtest.h"
|
#include "listtest.h"
|
||||||
|
|
||||||
@@ -1204,6 +1205,11 @@ void MyListCtrl::OnChecked(wxListEvent& event)
|
|||||||
{
|
{
|
||||||
LogEvent(event, "OnChecked");
|
LogEvent(event, "OnChecked");
|
||||||
|
|
||||||
|
if ( IsVirtual() )
|
||||||
|
{
|
||||||
|
CheckItem(event.GetIndex(), true);
|
||||||
|
}
|
||||||
|
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1211,6 +1217,11 @@ void MyListCtrl::OnUnChecked(wxListEvent& event)
|
|||||||
{
|
{
|
||||||
LogEvent(event, "OnUnChecked");
|
LogEvent(event, "OnUnChecked");
|
||||||
|
|
||||||
|
if ( IsVirtual() )
|
||||||
|
{
|
||||||
|
CheckItem(event.GetIndex(), false);
|
||||||
|
}
|
||||||
|
|
||||||
event.Skip();
|
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
|
int MyListCtrl::OnGetItemColumnImage(long item, long column) const
|
||||||
{
|
{
|
||||||
if (!column)
|
if (!column)
|
||||||
|
@@ -74,6 +74,9 @@ public:
|
|||||||
|
|
||||||
void OnRightClick(wxMouseEvent& event);
|
void OnRightClick(wxMouseEvent& event);
|
||||||
|
|
||||||
|
virtual void CheckItem(long item, bool check) wxOVERRIDE;
|
||||||
|
virtual bool IsItemChecked(long item) const wxOVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ShowContextMenu(const wxPoint& pos);
|
void ShowContextMenu(const wxPoint& pos);
|
||||||
wxLog *m_logOld;
|
wxLog *m_logOld;
|
||||||
@@ -83,11 +86,14 @@ private:
|
|||||||
void LogColEvent(const wxListEvent& event, const wxString& eventName);
|
void LogColEvent(const wxListEvent& event, const wxString& eventName);
|
||||||
|
|
||||||
virtual wxString OnGetItemText(long item, long column) const wxOVERRIDE;
|
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 int OnGetItemColumnImage(long item, long column) const wxOVERRIDE;
|
||||||
virtual wxItemAttr *OnGetItemAttr(long item) const wxOVERRIDE;
|
virtual wxItemAttr *OnGetItemAttr(long item) const wxOVERRIDE;
|
||||||
|
|
||||||
long m_updated;
|
long m_updated;
|
||||||
|
|
||||||
|
// checked boxes in virtual list
|
||||||
|
wxSelectionStore m_checked;
|
||||||
|
|
||||||
wxDECLARE_NO_COPY_CLASS(MyListCtrl);
|
wxDECLARE_NO_COPY_CLASS(MyListCtrl);
|
||||||
wxDECLARE_EVENT_TABLE();
|
wxDECLARE_EVENT_TABLE();
|
||||||
|
Reference in New Issue
Block a user