Fix display of items without attributes in Cocoa wxDVC.

The attribute used for the last item was reused for the next item in the same
column unless it was overridden in the attribute of this item, fix this by
remembering the original attribute and using it if no attributes are
explicitly specified.

Also change the sample to show the items without attributes in a column with
attributes and make the label correspond to the attribute of the item.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62390 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-10-12 17:30:48 +00:00
parent a8afd748c7
commit 09a0ece0dc
3 changed files with 115 additions and 29 deletions

View File

@@ -418,10 +418,12 @@ void MyListModel::GetValueByRow( wxVariant &variant,
}
else if (col==2)
{
if (row >= m_array.GetCount())
variant = "plain";
else
variant = "blue/green/red";
static const char *labels[5] =
{
"blue", "green", "red", "bold cyan", "default",
};
variant = labels[row % 5];
}
}
@@ -431,11 +433,28 @@ bool MyListModel::GetAttrByRow( unsigned int row, unsigned int col,
if (col != 2)
return false;
if (row < m_array.GetCount())
// do what the labels defined above hint at
switch ( row % 5 )
{
attr.SetColour( (row%3) == 0 ? *wxBLUE :
((row%3) == 1 ? *wxGREEN : *wxRED) );
attr.SetItalic( (row%10) == 5 );
case 0:
attr.SetColour(*wxBLUE);
break;
case 1:
attr.SetColour(*wxGREEN);
break;
case 2:
attr.SetColour(*wxRED);
break;
case 3:
attr.SetColour(*wxCYAN);
attr.SetBold(true);
break;
case 4:
return false;
}
return true;