There were two related problems: first, any attempts to set the
background colour for the cells without values were simply ignored
because we didn't call wxDataViewModel::GetAttr() at all from
PrepareForItem() in this case and, second, PrepareForItem() itself was
not called when repainting the control neither, resulting in the
existing attribute being reused for the items without values, meaning
that they used the last background colour that was set instead of at
least not using any background at all.
Fix both of the problems for the generic version. Unfortunately the GTK
one still doesn't allow setting the background for the empty cells, but
at least when not doing it the code now consistently leaves them without
any background.
The following code can be added to MyMusicTreeModel in the dataview
sample for testing this:
--------------------------------- >8 --------------------------------------
bool GetAttr( const wxDataViewItem& item, unsigned int col, wxDataViewItemAttr& attr) const override
{
if (col != 1)
return false;
if (IsContainer(item))
{
if (item != m_pop)
return false;
attr.SetBackgroundColour(*wxYELLOW);
}
else
{
attr.SetColour(*wxYELLOW);
attr.SetBackgroundColour(*wxLIGHT_GREY);
}
return true;
}
--------------------------------- >8 --------------------------------------
Closes#23708, #23902.