Prefer calling wxMSW dark mode support "unofficial" It's not "experimental" any longer, but we still want to make it clear that this isn't supported as well as standard mode. Closes #26752.
Make dark mode system colors more consistent with other platforms Assign values for wxSYS_COLOUR_3DLIGHT and wxSYS_COLOUR_BTNHIGHLIGHT consistent with Linux and macOS. Also stop using wxSYS_COLOUR_BTNHIGHLIGHT for rendering disabled text in wxGrid and wxGenericStaticText: it didn't look before and would be even worse after this change. Instead, just draw the text in "disabled" colour, without using drop shadow at all. Closes #26753.
Use system colors for generic calendar header Use system colors for generic calendar header instead of blue and gray. A separator line is drawn below the header. This makes the control look consistent with the Win32 and WinUI 3 controls. Custom header colors are not overwritten by system color change event. See #25552. Closes #26777.
| ... | ... | @@ -39,7 +39,7 @@ public: |
| 39 | 39 | |
| 40 | 40 | virtual AppearanceResult SetAppearance(Appearance appearance) override;
|
| 41 | 41 | |
| 42 | - // MSW-specific function to enable experimental dark mode support.
|
|
| 42 | + // MSW-specific function to enable unofficial dark mode support.
|
|
| 43 | 43 | //
|
| 44 | 44 | // If settings are specified, the function takes ownership of the pointer,
|
| 45 | 45 | // otherwise the defaults are used.
|
| ... | ... | @@ -1425,15 +1425,12 @@ public: |
| 1425 | 1425 | };
|
| 1426 | 1426 | |
| 1427 | 1427 | /**
|
| 1428 | - Enable experimental dark mode support for MSW applications.
|
|
| 1428 | + Enable unofficial dark mode support for MSW applications.
|
|
| 1429 | 1429 | |
| 1430 | 1430 | This function uses @e undocumented, and unsupported by Microsoft,
|
| 1431 | 1431 | functions to enable dark mode support for the desktop applications
|
| 1432 | 1432 | under Windows 10 versions later than v1809 (which includes Windows 10
|
| 1433 | - LTSC 2019) and all Windows 11 versions. Please note that dark mode
|
|
| 1434 | - testing under versions of Windows earlier than 20H1 (i.e. v2004) has
|
|
| 1435 | - been limited, make sure to test your application especially carefully
|
|
| 1436 | - if you target these versions and want to enable dark mode support.
|
|
| 1433 | + LTSC 2019) and all Windows 11 versions.
|
|
| 1437 | 1434 | |
| 1438 | 1435 | Note that dark mode can also be enabled by setting the "msw.dark-mode"
|
| 1439 | 1436 | @ref wxSystemOptions "system option" via an environment variable from
|
| ... | ... | @@ -83,7 +83,7 @@ |
| 83 | 83 | e.g. the Terminal font in small sizes is not and this option may be
|
| 84 | 84 | used if wider fonts selection is more important than higher quality.
|
| 85 | 85 | @flag{msw.dark-mode}
|
| 86 | - If set to 1, enable experimental support of dark mode if the system is
|
|
| 86 | + If set to 1, enable unofficial support of dark mode if the system is
|
|
| 87 | 87 | using it, i.e. this has the same effect as calling
|
| 88 | 88 | wxApp::MSWEnableDarkMode(). If set to 2, use dark mode unconditionally,
|
| 89 | 89 | as if this function were called with wxApp::DarkMode_Always argument.
|
| ... | ... | @@ -161,9 +161,6 @@ void wxGenericCalendarCtrl::InitColours() |
| 161 | 161 | |
| 162 | 162 | m_colHolidayFg = *wxRED;
|
| 163 | 163 | // don't set m_colHolidayBg - by default, same as our bg colour
|
| 164 | - |
|
| 165 | - m_colHeaderFg = *wxBLUE;
|
|
| 166 | - m_colHeaderBg = *wxLIGHT_GREY;
|
|
| 167 | 164 | }
|
| 168 | 165 | |
| 169 | 166 | bool wxGenericCalendarCtrl::Create(wxWindow *parent,
|
| ... | ... | @@ -802,14 +799,19 @@ void wxGenericCalendarCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) |
| 802 | 799 | wxCoord y = 0;
|
| 803 | 800 | wxCoord x0 = m_calendarWeekWidth;
|
| 804 | 801 | |
| 802 | + const wxColour colHeaderBg = m_colHeaderBg.IsOk() ? m_colHeaderBg :
|
|
| 803 | + wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
|
| 804 | + const wxColour colHeaderFg = m_colHeaderFg.IsOk() ? m_colHeaderFg :
|
|
| 805 | + wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
|
| 806 | + |
|
| 805 | 807 | if ( HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) )
|
| 806 | 808 | {
|
| 807 | 809 | // draw the sequential month-selector
|
| 808 | 810 | |
| 809 | 811 | dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT);
|
| 810 | - dc.SetTextForeground(*wxBLACK);
|
|
| 811 | - dc.SetBrush(wxBrush(m_colHeaderBg, wxBRUSHSTYLE_SOLID));
|
|
| 812 | - dc.SetPen(wxPen(m_colHeaderBg, 1, wxPENSTYLE_SOLID));
|
|
| 812 | + dc.SetTextForeground(colHeaderFg);
|
|
| 813 | + dc.SetBrush(wxBrush(colHeaderBg));
|
|
| 814 | + dc.SetPen(wxPen(colHeaderBg));
|
|
| 813 | 815 | dc.DrawRectangle(0, y, GetClientSize().x, m_heightRow);
|
| 814 | 816 | |
| 815 | 817 | // Get extent of month-name + year
|
| ... | ... | @@ -852,8 +854,8 @@ void wxGenericCalendarCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) |
| 852 | 854 | if ( IsDateInRange(ldpm) && ( ( ldpm.GetYear() == m_date.GetYear() ) ? true : AllowYearChange() ) )
|
| 853 | 855 | {
|
| 854 | 856 | m_leftArrowRect = wxRect(larrowx - rectx + 1, arrowy - recty, (arrowheight / 2) + 2 * rectx, (arrowheight + 2 * recty));
|
| 855 | - dc.SetBrush(*wxBLACK_BRUSH);
|
|
| 856 | - dc.SetPen(*wxBLACK_PEN);
|
|
| 857 | + dc.SetBrush(wxBrush(colHeaderFg));
|
|
| 858 | + dc.SetPen(wxPen(colHeaderFg));
|
|
| 857 | 859 | dc.DrawPolygon(3, leftarrow, larrowx , arrowy, wxWINDING_RULE);
|
| 858 | 860 | dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
| 859 | 861 | dc.DrawRectangle(m_leftArrowRect);
|
| ... | ... | @@ -862,8 +864,8 @@ void wxGenericCalendarCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) |
| 862 | 864 | if ( IsDateInRange(fdnm) && ( ( fdnm.GetYear() == m_date.GetYear() ) ? true : AllowYearChange() ) )
|
| 863 | 865 | {
|
| 864 | 866 | m_rightArrowRect = wxRect(rarrowx - rectx, arrowy - recty, (arrowheight / 2) + 2 * rectx, (arrowheight + 2 * recty));
|
| 865 | - dc.SetBrush(*wxBLACK_BRUSH);
|
|
| 866 | - dc.SetPen(*wxBLACK_PEN);
|
|
| 867 | + dc.SetBrush(wxBrush(colHeaderFg));
|
|
| 868 | + dc.SetPen(wxPen(colHeaderFg));
|
|
| 867 | 869 | dc.DrawPolygon(3, rightarrow, rarrowx , arrowy, wxWINDING_RULE);
|
| 868 | 870 | dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
| 869 | 871 | dc.DrawRectangle(m_rightArrowRect);
|
| ... | ... | @@ -881,9 +883,9 @@ void wxGenericCalendarCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) |
| 881 | 883 | #endif
|
| 882 | 884 | |
| 883 | 885 | dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT);
|
| 884 | - dc.SetTextForeground(m_colHeaderFg);
|
|
| 885 | - dc.SetBrush(wxBrush(m_colHeaderBg, wxBRUSHSTYLE_SOLID));
|
|
| 886 | - dc.SetPen(wxPen(m_colHeaderBg, 1, wxPENSTYLE_SOLID));
|
|
| 886 | + dc.SetTextForeground(colHeaderFg);
|
|
| 887 | + dc.SetBrush(wxBrush(colHeaderBg));
|
|
| 888 | + dc.SetPen(wxPen(colHeaderBg));
|
|
| 887 | 889 | dc.DrawRectangle(0, y, GetClientSize().x, m_heightRow);
|
| 888 | 890 | |
| 889 | 891 | bool startOnMonday = WeekStartsOnMonday();
|
| ... | ... | @@ -906,14 +908,23 @@ void wxGenericCalendarCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) |
| 906 | 908 | |
| 907 | 909 | y += m_heightRow;
|
| 908 | 910 | |
| 911 | + // Draw a horizontal line under the header.
|
|
| 912 | + dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_GRIDLINES)));
|
|
| 913 | + dc.DrawLine(0, y, GetClientSize().x, y);
|
|
| 914 | + |
|
| 909 | 915 | // draw column with calendar week nr
|
| 910 | 916 | if ( HasFlag( wxCAL_SHOW_WEEK_NUMBERS ) && IsExposed( 0, y, m_calendarWeekWidth, m_heightRow * 6 ))
|
| 911 | 917 | {
|
| 912 | - dc.SetTextForeground(*wxBLACK);
|
|
| 918 | + dc.SetTextForeground(colHeaderFg);
|
|
| 913 | 919 | dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT);
|
| 914 | - dc.SetBrush(wxBrush(m_colHeaderBg, wxBRUSHSTYLE_SOLID));
|
|
| 915 | - dc.SetPen(wxPen(m_colHeaderBg, 1, wxPENSTYLE_SOLID));
|
|
| 920 | + dc.SetBrush(wxBrush(colHeaderBg));
|
|
| 921 | + dc.SetPen(wxPen(colHeaderBg));
|
|
| 916 | 922 | dc.DrawRectangle( 0, y, m_calendarWeekWidth, m_heightRow * 6 );
|
| 923 | + |
|
| 924 | + // Draw a vertical line to the right of week numbers.
|
|
| 925 | + dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_GRIDLINES)));
|
|
| 926 | + dc.DrawLine(m_calendarWeekWidth, y, m_calendarWeekWidth, m_heightRow * 6);
|
|
| 927 | + |
|
| 917 | 928 | wxDateTime date = GetStartDate();
|
| 918 | 929 | for ( size_t i = 0; i < 6; ++i )
|
| 919 | 930 | {
|
| ... | ... | @@ -352,15 +352,23 @@ void wxGridHeaderLabelsRenderer::DrawLabel(const wxGrid& grid, |
| 352 | 352 | wxColour colText;
|
| 353 | 353 | if ( !grid.IsEnabled() )
|
| 354 | 354 | {
|
| 355 | - colText = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT);
|
|
| 356 | - dc.SetTextForeground(colText);
|
|
| 355 | + // Don't use 3D shadows in dark mode, also just as wxGenericStaticText.
|
|
| 356 | + if ( wxSystemSettings::GetAppearance().IsDark() )
|
|
| 357 | + {
|
|
| 358 | + colText = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
|
|
| 359 | + }
|
|
| 360 | + else
|
|
| 361 | + {
|
|
| 362 | + colText = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT);
|
|
| 363 | + dc.SetTextForeground(colText);
|
|
| 357 | 364 | |
| 358 | - wxRect rectShadow = rect;
|
|
| 359 | - rectShadow.Offset(1, 1);
|
|
| 360 | - grid.DrawTextRectangle(dc, value, rectShadow,
|
|
| 361 | - horizAlign, vertAlign, textOrientation);
|
|
| 365 | + wxRect rectShadow = rect;
|
|
| 366 | + rectShadow.Offset(1, 1);
|
|
| 367 | + grid.DrawTextRectangle(dc, value, rectShadow,
|
|
| 368 | + horizAlign, vertAlign, textOrientation);
|
|
| 362 | 369 | |
| 363 | - colText = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW);
|
|
| 370 | + colText = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW);
|
|
| 371 | + }
|
|
| 364 | 372 | }
|
| 365 | 373 | else
|
| 366 | 374 | {
|
| ... | ... | @@ -72,14 +72,24 @@ void wxGenericStaticText::OnPaint(wxPaintEvent& WXUNUSED(event)) |
| 72 | 72 | wxRect rect = GetClientRect();
|
| 73 | 73 | if ( !IsEnabled() )
|
| 74 | 74 | {
|
| 75 | - // draw shadow of the text
|
|
| 76 | - dc.SetTextForeground(
|
|
| 77 | - wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT));
|
|
| 78 | - wxRect rectShadow = rect;
|
|
| 79 | - rectShadow.Offset(1, 1);
|
|
| 80 | - DoDrawLabel(dc, rectShadow);
|
|
| 81 | - dc.SetTextForeground(
|
|
| 82 | - wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
|
|
| 75 | + // 3D shadow colours don't make sense in dark mode which has "flat"
|
|
| 76 | + // appearance, so use just a single "disabled" colour in it instead.
|
|
| 77 | + if ( wxSystemSettings::GetAppearance().IsDark() )
|
|
| 78 | + {
|
|
| 79 | + dc.SetTextForeground(
|
|
| 80 | + wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
|
|
| 81 | + }
|
|
| 82 | + else
|
|
| 83 | + {
|
|
| 84 | + // draw shadow of the text
|
|
| 85 | + dc.SetTextForeground(
|
|
| 86 | + wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT));
|
|
| 87 | + wxRect rectShadow = rect;
|
|
| 88 | + rectShadow.Offset(1, 1);
|
|
| 89 | + DoDrawLabel(dc, rectShadow);
|
|
| 90 | + dc.SetTextForeground(
|
|
| 91 | + wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
|
|
| 92 | + }
|
|
| 83 | 93 | }
|
| 84 | 94 | DoDrawLabel(dc, rect);
|
| 85 | 95 | }
|
| ... | ... | @@ -435,14 +435,14 @@ wxColour wxDarkModeSettings::GetColour(wxSystemColour index) |
| 435 | 435 | // Selected text background in File Open dialog
|
| 436 | 436 | return wxColour(isWindows10 ? 0xd77800 : 0xd47800);
|
| 437 | 437 | |
| 438 | + case wxSYS_COLOUR_3DLIGHT:
|
|
| 438 | 439 | case wxSYS_COLOUR_BTNHIGHLIGHT:
|
| 439 | - return wxColour(0x777777);
|
|
| 440 | + return wxColour(0x303030);
|
|
| 440 | 441 | |
| 441 | 442 | case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
|
| 442 | 443 | return wxColour(0xaaaaaa);
|
| 443 | 444 | |
| 444 | 445 | case wxSYS_COLOUR_3DDKSHADOW:
|
| 445 | - case wxSYS_COLOUR_3DLIGHT:
|
|
| 446 | 446 | case wxSYS_COLOUR_ACTIVEBORDER:
|
| 447 | 447 | case wxSYS_COLOUR_DESKTOP:
|
| 448 | 448 | case wxSYS_COLOUR_GRADIENTACTIVECAPTION:
|
—
View it on GitLab.
You're receiving this email because of your account on gitlab.com. Manage all notifications · Help