Support switching to wxMSW dark mode in wxAuiToolBar

On Windows, enable dark mode switching for wxAuiToolBar by updating
m_themed upon system colour change.

Closes #26648.
This commit is contained in:
Steve Cornett
2026-06-30 22:29:27 +02:00
committed by Vadim Zeitlin
parent c5b9d2850e
commit 25d7cfefea
2 changed files with 13 additions and 6 deletions
+2
View File
@@ -79,6 +79,8 @@ public:
virtual int ShowDropDown(wxWindow* wnd,
const wxAuiToolBarItemArray& items) override;
virtual void UpdateColoursFromSystem() override;
private:
bool m_themed;
wxSize m_buttonSize;
+11 -6
View File
@@ -26,11 +26,8 @@
wxAuiMSWToolBarArt::wxAuiMSWToolBarArt()
{
// Theme colours don't work in dark theme, so don't use them in this case.
if ( wxUxThemeIsActive() && !wxMSWDarkMode::IsActive() )
if ( wxUxThemeIsActive() )
{
m_themed = true;
// Determine sizes from theme
wxWindow* window = static_cast<wxApp*>(wxApp::GetInstance())->GetTopWindow();
wxUxThemeHandle hTheme(window, L"Rebar");
@@ -51,8 +48,8 @@ wxAuiMSWToolBarArt::wxAuiMSWToolBarArt()
m_buttonSize = hThemeToolbar.GetTrueSize(TP_BUTTON);
}
else
m_themed = false;
UpdateColoursFromSystem();
}
wxAuiToolBarArt* wxAuiMSWToolBarArt::Clone()
@@ -432,4 +429,12 @@ int wxAuiMSWToolBarArt::ShowDropDown(wxWindow* wnd,
return wxAuiGenericToolBarArt::ShowDropDown(wnd, items);
}
void wxAuiMSWToolBarArt::UpdateColoursFromSystem()
{
wxAuiGenericToolBarArt::UpdateColoursFromSystem();
// Theme colours do not work in dark mode.
m_themed = wxUxThemeIsActive() && !wxMSWDarkMode::IsActive();
}
#endif // wxUSE_AUI