added support for item attributes in virtual list control
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10972 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -657,6 +657,22 @@ void MyListCtrl::OnListKeyDown(wxListEvent& event)
|
||||
{
|
||||
switch ( event.GetCode() )
|
||||
{
|
||||
case 'c':
|
||||
{
|
||||
wxListItem info;
|
||||
info.m_itemId = event.GetIndex();
|
||||
GetItem(info);
|
||||
|
||||
wxListItemAttr *attr = info.GetAttributes();
|
||||
if ( !attr || !attr->HasTextColour() )
|
||||
{
|
||||
info.SetTextColour(*wxCYAN);
|
||||
|
||||
SetItem(info);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WXK_DELETE:
|
||||
DeleteItem(event.GetIndex());
|
||||
|
||||
@@ -708,6 +724,11 @@ int MyListCtrl::OnGetItemImage(long item) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
wxListItemAttr *MyListCtrl::OnGetItemAttr(long item) const
|
||||
{
|
||||
return item % 2 ? NULL : (wxListItemAttr *)&m_attr;
|
||||
}
|
||||
|
||||
void MyListCtrl::InsertItemInReportView(int i)
|
||||
{
|
||||
wxString buf;
|
||||
|
@@ -19,9 +19,13 @@ public:
|
||||
class MyListCtrl: public wxListCtrl
|
||||
{
|
||||
public:
|
||||
MyListCtrl(wxWindow *parent, const wxWindowID id, const wxPoint& pos,
|
||||
const wxSize& size, long style):
|
||||
wxListCtrl(parent, id, pos, size, style)
|
||||
MyListCtrl(wxWindow *parent,
|
||||
const wxWindowID id,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style)
|
||||
: wxListCtrl(parent, id, pos, size, style),
|
||||
m_attr(*wxCYAN, *wxLIGHT_GREY, wxNullFont)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -49,6 +53,9 @@ private:
|
||||
|
||||
virtual wxString OnGetItemText(long item, long column) const;
|
||||
virtual int OnGetItemImage(long item) const;
|
||||
virtual wxListItemAttr *OnGetItemAttr(long item) const;
|
||||
|
||||
wxListItemAttr m_attr;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
Reference in New Issue
Block a user