Support Dark Mode for Status Bar

see #18146
This commit is contained in:
Stefan Csomor 2018-06-14 20:09:37 +02:00
parent 016a506eee
commit 5091d87825
2 changed files with 43 additions and 10 deletions

View File

@ -35,6 +35,8 @@ protected:
virtual void DrawField(wxDC& dc, int i, int textHeight) wxOVERRIDE;
virtual void DoUpdateStatusText(int number = 0) wxOVERRIDE;
virtual void InitColours();
private:
wxColour m_textActive, m_textInactive,
m_bgActiveFrom, m_bgActiveTo,

View File

@ -67,6 +67,13 @@ bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
// normal system font is too tall for fitting into the standard height
SetWindowVariant( wxWINDOW_VARIANT_SMALL );
InitColours();
return true;
}
void wxStatusBarMac::InitColours()
{
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101000
if ( !wxPlatformInfo::Get().CheckOSVersion(10, 10) )
{
@ -82,17 +89,41 @@ bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
else
#endif // MAC_OS_X_VERSION_MIN_REQUIRED < 101000
{
// 10.10 Yosemite and newer:
m_textActive = wxColour(0x40, 0x40, 0x40);
m_textInactive = wxColour(0x4B, 0x4B, 0x4B);
m_bgActiveFrom = wxColour(0xE9, 0xE7, 0xEA);
m_bgActiveTo = wxColour(0xCD, 0xCB, 0xCE);
m_borderActive = wxColour(0xBA, 0xB8, 0xBB);
m_borderInactive = wxColour(0xC3, 0xC3, 0xC3);
SetBackgroundColour(wxColour(0xF4, 0xF4, 0xF4)); // inactive bg
if (!wxPlatformInfo::Get().CheckOSVersion(10, 14))
{
// 10.10 Yosemite to 10.13 :
m_textActive = wxColour(0x40, 0x40, 0x40);
m_textInactive = wxColour(0x4B, 0x4B, 0x4B);
m_bgActiveFrom = wxColour(0xE9, 0xE7, 0xEA);
m_bgActiveTo = wxColour(0xCD, 0xCB, 0xCE);
m_borderActive = wxColour(0xBA, 0xB8, 0xBB);
m_borderInactive = wxColour(0xC3, 0xC3, 0xC3);
SetBackgroundColour(wxColour(0xF4, 0xF4, 0xF4)); // inactive bg
}
else
{
wxColour bg = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE);
m_textActive = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT);
m_textInactive = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
if ( bg.Red() < 128 )
{
// dark mode appearance
m_bgActiveFrom = wxColour(0x32, 0x32, 0x34);
m_bgActiveTo = wxColour(0x29, 0x29, 0x2A);
m_borderActive = wxColour(0x00, 0x00, 0x00);
m_borderInactive = wxColour(0x00, 0x00, 0x00);
}
else
{
m_bgActiveFrom = wxColour(0xE9, 0xE7, 0xEA);
m_bgActiveTo = wxColour(0xCD, 0xCB, 0xCE);
m_borderActive = wxColour(0xBA, 0xB8, 0xBB);
m_borderInactive = wxColour(0xC3, 0xC3, 0xC3);
}
SetBackgroundColour(bg); // inactive bg
}
}
return true;
}
void wxStatusBarMac::DrawFieldText(wxDC& dc, const wxRect& rect, int i, int textHeight)