mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-08-18 09:30:13 +08:00
Add function to detect DarkMode_DarkTheme
To detect whether DarkMode_DarkTheme is available, use a dedicated function rather than wxCheckOsVersion, for improved readability. No changes in behaviour. Closes #26817.
This commit is contained in:
committed by
Vadim Zeitlin
parent
6ae88f1474
commit
dee9c72e16
@@ -80,6 +80,10 @@ HandleMenuMessage(WXLRESULT* result,
|
||||
|
||||
void NotifySysColorChange();
|
||||
|
||||
// Return true if the DarkMode_DarkTheme theme is available. This theme was
|
||||
// added in Windows 11 25H2 (build 26200).
|
||||
bool HasDarkTheme();
|
||||
|
||||
} // namespace wxMSWDarkMode
|
||||
|
||||
namespace wxMSWImpl
|
||||
|
||||
+3
-4
@@ -217,7 +217,7 @@ void wxChoice::MSWGetDarkModeSupport(MSWDarkModeSupport& support) const
|
||||
// Theme DarkMode_DarkTheme looks good, so use it if available. Theme
|
||||
// "CFD" works well on older Windows versions although the border is a bit
|
||||
// light.
|
||||
if ( wxCheckOsVersion(10, 0, 26200) )
|
||||
if ( wxMSWDarkMode::HasDarkTheme() )
|
||||
support.themeName = L"DarkMode_DarkTheme";
|
||||
else
|
||||
support.themeName = L"CFD";
|
||||
@@ -232,10 +232,9 @@ void wxChoice::MSWSetDarkOrLightMode(SetMode setmode)
|
||||
if ( ::GetComboBoxInfo(GetHwnd(), &info) && info.hwndList )
|
||||
{
|
||||
// The default theme does not look good on starting with Windows 11
|
||||
// build 26300.8553. DarkMode_DarkTheme looks OK and is available
|
||||
// starting with Windows 11 25H2 (build 26200), but is always dark, so
|
||||
// build 26300.8553. DarkMode_DarkTheme looks OK, but is always dark, so
|
||||
// don't use it in light mode or the scrollbar would be dark in it too.
|
||||
if ( wxMSWDarkMode::IsActive() && wxCheckOsVersion(10, 0, 26200) )
|
||||
if ( wxMSWDarkMode::IsActive() && wxMSWDarkMode::HasDarkTheme() )
|
||||
wxMSWDarkMode::AllowForWindow(info.hwndList, L"DarkMode_DarkTheme");
|
||||
else
|
||||
wxMSWDarkMode::AllowForWindow(info.hwndList);
|
||||
|
||||
@@ -846,6 +846,11 @@ void NotifySysColorChange()
|
||||
gs_hasChanged = true;
|
||||
}
|
||||
|
||||
bool HasDarkTheme()
|
||||
{
|
||||
return wxCheckOsVersion(10, 0, 26200);
|
||||
}
|
||||
|
||||
} // namespace wxMSWDarkMode
|
||||
|
||||
void wxMSWImpl::PaintScrollBarCorner(HWND hwnd)
|
||||
@@ -964,6 +969,11 @@ void NotifySysColorChange()
|
||||
{
|
||||
}
|
||||
|
||||
bool HasDarkTheme()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace wxMSWDarkMode
|
||||
|
||||
void wxMSWImpl::PaintScrollBarCorner(HWND WXUNUSED(hwnd))
|
||||
|
||||
+2
-2
@@ -98,7 +98,7 @@ wxGauge::~wxGauge()
|
||||
|
||||
void wxGauge::MSWGetDarkModeSupport(MSWDarkModeSupport& support) const
|
||||
{
|
||||
if ( wxCheckOsVersion(10, 0, 26200) )
|
||||
if ( wxMSWDarkMode::HasDarkTheme() )
|
||||
{
|
||||
support.themeName = L"DarkMode_DarkTheme";
|
||||
support.themeId = L"Progress";
|
||||
@@ -113,7 +113,7 @@ void wxGauge::MSWSetDarkOrLightMode(SetMode setmode)
|
||||
|
||||
// Adjust colours unless we use DarkMode_DarkTheme in
|
||||
// MSWGetDarkModeSupport().
|
||||
if ( !wxCheckOsVersion(10, 0, 26200) )
|
||||
if ( !wxMSWDarkMode::HasDarkTheme() )
|
||||
{
|
||||
// Disable visual styles so colour messages take effect.
|
||||
::SetWindowTheme(m_hWnd, L"", L"");
|
||||
|
||||
+3
-3
@@ -29,6 +29,7 @@
|
||||
#endif
|
||||
|
||||
#include "wx/msw/private.h"
|
||||
#include "wx/msw/private/darkmode.h"
|
||||
#include "wx/msw/dc.h"
|
||||
|
||||
#include <windowsx.h>
|
||||
@@ -176,9 +177,8 @@ WXDWORD wxListBox::MSWGetStyle(long style, WXDWORD *exstyle) const
|
||||
void wxListBox::MSWGetDarkModeSupport(MSWDarkModeSupport& support) const
|
||||
{
|
||||
// The default theme does not look good on starting with Windows 11
|
||||
// build 26300.8553. DarkMode_DarkTheme looks OK and was available
|
||||
// starting with Windows 11 build 26200.
|
||||
if ( wxCheckOsVersion(10, 0, 26200) )
|
||||
// build 26300.8553. DarkMode_DarkTheme looks OK.
|
||||
if ( wxMSWDarkMode::HasDarkTheme() )
|
||||
support.themeName = L"DarkMode_DarkTheme";
|
||||
else
|
||||
wxListBoxBase::MSWGetDarkModeSupport(support);
|
||||
|
||||
Reference in New Issue
Block a user