From 9cd3ab5ebd0a05230e044a9479517fe5be1a3fcd Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 14 Jul 2020 17:34:24 +0200 Subject: [PATCH] Improve wxGenericTreeCtrl colours/fonts updating on theme change Don't override user-specified colours neither, previously we only did it for the font for some reason. Also do override the colours and the font when the theme changes, which didn't happen after the previous commit because calling SetOwnXXX() changes m_hasXXX to true, so we need to explicitly reset it back. --- src/generic/treectlg.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index ec53ebf4a0..7bae8ce932 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -1007,11 +1007,30 @@ void wxGenericTreeCtrl::EnableBellOnNoMatch( bool on ) void wxGenericTreeCtrl::InitVisualAttributes() { + // We want to use the default system colours/fonts here unless the user + // explicitly configured something different. We also need to reset the + // various m_hasXXX variables to false to prevent them from being left set + // to "true", as otherwise we wouldn't update the colours/fonts the next + // time the system colours change. const wxVisualAttributes attr(GetDefaultAttributes()); - SetOwnForegroundColour(attr.colFg); - SetOwnBackgroundColour(attr.colBg); - if (!m_hasFont) + if ( !m_hasFgCol ) + { + SetOwnForegroundColour(attr.colFg); + m_hasFgCol = false; + } + + if ( !m_hasBgCol ) + { + SetOwnBackgroundColour(attr.colBg); + m_hasBgCol = false; + } + + if ( !m_hasFont ) + { SetOwnFont(attr.font); + m_hasFont = false; + } + m_hilightBrush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); m_hilightUnfocusedBrush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));