Improve wxDataViewCtrl selection rendering in wxOSX

Check NSCell's backgroundStyle property to determine whether the row's
content should be rendered normally or in the appearance for selected
rows, instead of previously used isHighlighted. The latter reports the
row as selected even if the control doesn't have focus and the selection
is therefore rendered in light gray rather than blue. In that case, e.g.
reducing colors of the text is not necessary and native controls don't
do it either.

This change makes the behavior match the native one and only renders
highlighted appearance if the row background is blue/dark.

This also matches wxDATAVIEW_CELL_SELECTED to dark background rather
than being selected. This is consistent with its purpose (alternative
appearance) as well as with what the generic wxDataViewCtrl
implementation does.
This commit is contained in:
Václav Slavík 2016-11-21 17:57:03 +01:00
parent 7c730334a2
commit e9c1f43925

View File

@ -1213,7 +1213,7 @@ outlineView:(NSOutlineView*)outlineView
dc.SetGraphicsContext(gc);
int state = 0;
if ( [self isHighlighted] )
if ( [self backgroundStyle] == NSBackgroundStyleDark )
state |= wxDATAVIEW_CELL_SELECTED;
renderer->WXCallRender(wxFromNSRect(controlView, cellFrame), &dc, state);
@ -2836,7 +2836,7 @@ void wxDataViewRenderer::SetAttr(const wxDataViewItemAttr& attr)
//else: can't change font if the cell doesn't have any
}
if ( attr.HasColour() && ![cell isHighlighted] )
if ( attr.HasColour() && [cell backgroundStyle] == NSBackgroundStyleLight )
{
// we can set font for any cell but only NSTextFieldCell provides
// a method for setting text colour so check that this method is
@ -2945,7 +2945,7 @@ bool wxDataViewTextRenderer::MacRender()
[par release];
}
if ( [cell isHighlighted] )
if ( [cell backgroundStyle] == NSBackgroundStyleDark )
{
[str removeAttribute:NSForegroundColorAttributeName range:NSMakeRange(0, [str length])];
[str removeAttribute:NSBackgroundColorAttributeName range:NSMakeRange(0, [str length])];