From 68666d929d326e38b8432eb924751a6dfd1fa333 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 8 Jul 2023 20:29:59 +0100 Subject: [PATCH] Invert wxSpinButton in dark mode in its own OnPaint() This doesn't change anything yet, as the same thing was done by wxWindow by default thanks to the overridden MSWShouldUseAutoDarkMode(), but this will be easier to customize in the upcoming commits. This commit is best viewed ignoring whitespace-only changes. --- src/msw/spinbutt.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/msw/spinbutt.cpp b/src/msw/spinbutt.cpp index ba2ab18109..74c76e4821 100644 --- a/src/msw/spinbutt.cpp +++ b/src/msw/spinbutt.cpp @@ -31,6 +31,7 @@ #include "wx/spinbutt.h" #include "wx/msw/private.h" +#include "wx/msw/private/darkmode.h" #ifndef UDM_SETRANGE32 #define UDM_SETRANGE32 (WM_USER+111) @@ -174,13 +175,16 @@ wxSize wxSpinButton::DoGetBestSize() const void wxSpinButton::OnPaint(wxPaintEvent& event) { - // We need to always paint this control explicitly instead of letting - // DefWndProc() do it, as this avoids whichever optimization the latter - // function does when WS_EX_COMPOSITED is on that result in not drawing - // parts of the control at all (see #23656). - wxPaintDC dc(this); + if ( !wxMSWDarkMode::PaintIfNecessary(GetHwnd(), m_oldWndProc) ) + { + // We need to always paint this control explicitly instead of letting + // DefWndProc() do it, as this avoids whichever optimization the latter + // function does when WS_EX_COMPOSITED is on that result in not drawing + // parts of the control at all (see #23656). + wxPaintDC dc(this); - wxSpinButtonBase::OnPaint(event); + wxSpinButtonBase::OnPaint(event); + } } // ----------------------------------------------------------------------------