Fix invisible captions in high contrast mode

Don't use black text on dark background.

Closes #16186.
This commit is contained in:
Zane U. Ji 2014-04-12 20:18:47 +08:00 committed by Vadim Zeitlin
parent f74379c751
commit 71dfb3b414
4 changed files with 30 additions and 17 deletions

View File

@ -141,6 +141,7 @@ All (GUI):
- Fix a crash when using animated GIFs in wxHtmlListBox.
- Use platform-specific stock icons for wxEditableListBox buttons.
- Add support for the events from multimedia keys (Jens Göpfert).
- Improve wxAUI appearance in high contrast themes (Zane U. Ji).
wxGTK:

View File

@ -289,6 +289,8 @@ protected:
wxFont m_normalFont;
wxFont m_selectedFont;
wxFont m_measuringFont;
wxColour m_normalTextColour;
wxColour m_selectedTextColour;
wxPen m_normalBkPen;
wxPen m_selectedBkPen;
wxBrush m_normalBkBrush;

View File

@ -172,26 +172,21 @@ wxAuiDefaultDockArt::wxAuiDefaultDockArt()
}
m_baseColour = baseColour;
wxColor darker1Colour = baseColour.ChangeLightness(85);
wxColor darker2Colour = baseColour.ChangeLightness(75);
wxColor darker3Colour = baseColour.ChangeLightness(60);
//wxColor darker4Colour = baseColour.ChangeLightness(50);
wxColor darker5Colour = baseColour.ChangeLightness(40);
m_activeCaptionColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
m_activeCaptionGradientColour = wxAuiLightContrastColour(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
m_activeCaptionTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
m_inactiveCaptionColour = darker1Colour;
m_inactiveCaptionGradientColour = baseColour.ChangeLightness(97);
m_inactiveCaptionTextColour = *wxBLACK;
m_activeCaptionColour = wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION);
m_activeCaptionGradientColour = wxSystemSettings::GetColour(wxSYS_COLOUR_GRADIENTACTIVECAPTION);
m_activeCaptionTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT);
m_inactiveCaptionColour = wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTION);
m_inactiveCaptionGradientColour = wxSystemSettings::GetColour(wxSYS_COLOUR_GRADIENTINACTIVECAPTION);
m_inactiveCaptionTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTIONTEXT);
m_sashBrush = wxBrush(baseColour);
m_backgroundBrush = wxBrush(baseColour);
m_gripperBrush = wxBrush(baseColour);
m_borderPen = wxPen(darker2Colour);
m_gripperPen1 = wxPen(darker5Colour);
m_gripperPen2 = wxPen(darker3Colour);
m_borderPen = wxPen(baseColour.ChangeLightness(75));
m_gripperPen1 = wxPen(baseColour.ChangeLightness(40));
m_gripperPen2 = wxPen(baseColour.ChangeLightness(60));
m_gripperPen3 = *wxWHITE_PEN;
#ifdef __WXMAC__

View File

@ -74,6 +74,11 @@ wxBitmap wxAuiBitmapFromBits(const unsigned char bits[], int w, int h,
wxString wxAuiChopText(wxDC& dc, const wxString& text, int max_size);
inline bool IsDarkColour(const wxColour& c)
{
return (c.Red() + c.Green() + c.Blue()) * c.Alpha() * 2 < 3 * 255 * 255;
}
static void DrawButtons(wxDC& dc,
const wxRect& _rect,
const wxBitmap& bmp,
@ -416,6 +421,7 @@ void wxAuiGenericTabArt::DrawTab(wxDC& dc,
int drawn_tab_height = border_points[0].y - border_points[1].y;
wxColour text_colour;
if (page.active)
{
// draw active tab
@ -431,6 +437,8 @@ void wxAuiGenericTabArt::DrawTab(wxDC& dc,
dc.SetBrush(*wxWHITE_BRUSH);
dc.DrawRectangle(r.x+2, r.y+1, r.width-3, r.height-4);
text_colour = *wxBLACK;
// these two points help the rounded corners appear more antialiased
dc.SetPen(wxPen(m_activeColour));
dc.DrawPoint(r.x+2, r.y+1);
@ -464,9 +472,11 @@ void wxAuiGenericTabArt::DrawTab(wxDC& dc,
r.height--;
// -- draw top gradient fill for glossy look
wxColor top_color = m_baseColour;
wxColor bottom_color = top_color.ChangeLightness(160);
dc.GradientFillLinear(r, bottom_color, top_color, wxNORTH);
wxColor top_color = m_baseColour.ChangeLightness(160);
wxColor bottom_color = m_baseColour;
dc.GradientFillLinear(r, top_color, bottom_color, wxSOUTH);
text_colour = IsDarkColour(bottom_color) ? *wxWHITE : *wxBLACK;
r.y += r.height;
r.y--;
@ -532,6 +542,7 @@ void wxAuiGenericTabArt::DrawTab(wxDC& dc,
tab_width - (text_offset-tab_x) - close_button_width);
// draw tab text
dc.SetTextForeground(text_colour);
dc.DrawText(draw_text,
text_offset,
drawn_tab_yoff + (drawn_tab_height)/2 - (texty/2) - 1);
@ -863,6 +874,9 @@ wxAuiSimpleTabArt::wxAuiSimpleTabArt()
wxColour normaltabColour = baseColour;
wxColour selectedtabColour = *wxWHITE;
m_normalTextColour = IsDarkColour(baseColour) ? *wxWHITE : *wxBLACK;
m_selectedTextColour = *wxBLACK;
m_bkBrush = wxBrush(backgroundColour);
m_normalBkBrush = wxBrush(normaltabColour);
m_normalBkPen = wxPen(normaltabColour);
@ -1084,6 +1098,7 @@ void wxAuiSimpleTabArt::DrawTab(wxDC& dc,
tab_width - (text_offset-tab_x) - close_button_width);
// draw tab text
dc.SetTextForeground(page.active ? m_selectedTextColour : m_normalTextColour);
dc.DrawText(draw_text,
text_offset,
(tab_y + tab_height)/2 - (texty/2) + 1);