fix setting colour for a listctrl item (merged from 2.2)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10044 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
bf505d2855
commit
233d02951f
@ -658,31 +658,40 @@ bool wxListCtrl::SetItem(wxListItem& info)
|
|||||||
LV_ITEM item;
|
LV_ITEM item;
|
||||||
wxConvertToMSWListItem(this, info, item);
|
wxConvertToMSWListItem(this, info, item);
|
||||||
|
|
||||||
|
item.cchTextMax = 0;
|
||||||
|
if ( !ListView_SetItem(GetHwnd(), &item) )
|
||||||
|
{
|
||||||
|
wxLogDebug(_T("ListView_SetItem() failed"));
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// we need to update the item immediately to show the new image
|
||||||
|
bool updateNow = (info.m_mask & wxLIST_MASK_IMAGE) != 0;
|
||||||
|
|
||||||
// check whether it has any custom attributes
|
// check whether it has any custom attributes
|
||||||
if ( info.HasAttributes() )
|
if ( info.HasAttributes() )
|
||||||
{
|
{
|
||||||
|
wxListItemAttr *attr = (wxListItemAttr *)m_attrs.Get(item.iItem);
|
||||||
|
|
||||||
wxListItemAttr *attr;
|
if ( attr == NULL )
|
||||||
attr = (wxListItemAttr*) m_attrs.Get(item.iItem);
|
|
||||||
|
|
||||||
if (attr == NULL)
|
|
||||||
|
|
||||||
m_attrs.Put(item.iItem, (wxObject *)new wxListItemAttr(*info.GetAttributes()));
|
m_attrs.Put(item.iItem, (wxObject *)new wxListItemAttr(*info.GetAttributes()));
|
||||||
|
else
|
||||||
else *attr = *info.GetAttributes();
|
*attr = *info.GetAttributes();
|
||||||
|
|
||||||
m_hasAnyAttr = TRUE;
|
m_hasAnyAttr = TRUE;
|
||||||
|
|
||||||
|
// if the colour has changed, we must redraw the item
|
||||||
|
updateNow = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
item.cchTextMax = 0;
|
if ( updateNow )
|
||||||
bool ok = ListView_SetItem(GetHwnd(), &item) != 0;
|
|
||||||
if ( ok && (info.m_mask & wxLIST_MASK_IMAGE) )
|
|
||||||
{
|
{
|
||||||
// make the change visible
|
// we need this to make the change visible right now
|
||||||
ListView_Update(GetHwnd(), item.iItem);
|
ListView_Update(GetHwnd(), item.iItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ok;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
long wxListCtrl::SetItem(long index, int col, const wxString& label, int imageId)
|
long wxListCtrl::SetItem(long index, int col, const wxString& label, int imageId)
|
||||||
|
Loading…
Reference in New Issue
Block a user