From de0cc3ecffb236910d56f3474eb3c648e209638c Mon Sep 17 00:00:00 2001 From: James Crook Date: Sat, 22 Jul 2017 11:05:08 +0100 Subject: [PATCH] Bug 1699 - Selected keyboard prefs line unreadable in 3 of 4 themes on Mac The focus rect in key prefs is not very helpful. It was setting the background colour too, but that is now using system colours again. --- src/AColor.cpp | 40 +++++++++++++++++----------------------- src/AColor.h | 2 +- src/widgets/KeyView.cpp | 11 +++++++++-- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/AColor.cpp b/src/AColor.cpp index a82753aab..17ca28154 100644 --- a/src/AColor.cpp +++ b/src/AColor.cpp @@ -178,22 +178,8 @@ void AColor::DrawFocus(wxDC & dc, wxRect & rect) x2 = rect.GetRight(), y2 = rect.GetBottom(); -#ifdef __WXMAC__ - // Why must this be different? - // Otherwise nothing is visible if you do as for the - // other platforms. - UseThemeColour( &dc, clrTrackPanelText ); - - //dc.SetPen(wxPen(wxT("MEDIUM GREY"), 1, wxSOLID)); - //dc.SetLogicalFunction(wxCOPY); -#else - UseThemeColour( &dc, clrTrackPanelText ); - - //dc.SetPen(wxPen(wxT("MEDIUM GREY"), 0, wxSOLID)); - // this seems to be closer than what Windows does than wxINVERT although - // I'm still not sure if it's correct - //dc.SetLogicalFunction(wxAND_REVERSE); -#endif + // -1 for brush, so it just sets the pen colour, and does not change the brush. + UseThemeColour( &dc, -1, clrTrackPanelText ); wxCoord z; for ( z = x1 + 1; z < x2; z += 2 ) @@ -211,7 +197,6 @@ void AColor::DrawFocus(wxDC & dc, wxRect & rect) for ( z = y2 - shift; z > y1; z -= 2 ) dc.DrawPoint(x1, z); - dc.SetLogicalFunction(wxCOPY); } void AColor::Bevel(wxDC & dc, bool up, const wxRect & r) @@ -298,15 +283,24 @@ void AColor::BevelTrackInfo(wxDC & dc, bool up, const wxRect & r, bool highlight #endif } -void AColor::UseThemeColour( wxDC * dc, int iIndex, int index2 ) +// Set colour of and select brush and pen. +// Use -1 to omit brush or pen. +// If pen omitted, then the same colour as the brush will be used. +void AColor::UseThemeColour( wxDC * dc, int iBrush, int iPen ) { if (!inited) Init(); - wxColour col = theTheme.Colour( iIndex ); - spareBrush.SetColour( col ); - dc->SetBrush( spareBrush ); - if( index2 != -1) - col = theTheme.Colour( index2 ); + // do nothing if no colours set. + if( (iBrush != -1) && ( iPen !=-1)) + return; + wxColour col = wxColour(0,0,0); + if( iBrush !=-1 ){ + col = theTheme.Colour( iBrush ); + spareBrush.SetColour( col ); + dc->SetBrush( spareBrush ); + } + if( iPen != -1) + col = theTheme.Colour( iPen ); sparePen.SetColour( col ); dc->SetPen( sparePen ); } diff --git a/src/AColor.h b/src/AColor.h index fcc0a17c6..2b622646e 100644 --- a/src/AColor.h +++ b/src/AColor.h @@ -71,7 +71,7 @@ class AColor { static void BevelTrackInfo(wxDC & dc, bool up, const wxRect & r, bool highlight = false); static wxColour Blend(const wxColour & c1, const wxColour & c2); - static void UseThemeColour( wxDC * dc, int iIndex, int index2 =-1 ); + static void UseThemeColour( wxDC * dc, int iBrush, int iPen=-1 ); static void TrackPanelBackground(wxDC * dc, bool selected); static void Light(wxDC * dc, bool selected, bool highlight = false); diff --git a/src/widgets/KeyView.cpp b/src/widgets/KeyView.cpp index 36f8ab0df..8d35dcbdf 100644 --- a/src/widgets/KeyView.cpp +++ b/src/widgets/KeyView.cpp @@ -1080,15 +1080,22 @@ KeyView::OnDrawBackground(wxDC & dc, const wxRect & rect, size_t line) const if (FindFocus() == this) { // Focused lines get highlighted background + dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT))); - AColor::DrawFocus(dc, r); dc.DrawRectangle(r); + + // and they also get a dotted focus rect. This could just be left out. + // The focus rect does very little for us, as it is the same size as the + // rectangle itself. Consequently for themes that have black text it + // disappears. But on HiContrast you do get a dotted green border which + // may have some utility. + AColor::DrawFocus(dc, r); } else { // Non focused lines get a light background - dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE))); dc.SetPen(*wxTRANSPARENT_PEN); + dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE))); dc.DrawRectangle(r); } }