From 865c8565af71280e328a2af0f331c8cb9f424fcf Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Fri, 11 Sep 2015 18:47:49 +0200 Subject: [PATCH] Fixed setting colours of wxSlider and wxRadioBox in wxMSW. Sibling windows (like labels and radio buttons) need to be explicitly refreshed when foreground or background colour is changed. This is implemented by invoking newly implemented method wxSubwindows::Refresh every time the colour of the control is changed. Note: Setting foreground colour of wxRadioBox still doesn't work correctly when themes are enabled. Closes #17142. --- docs/changes.txt | 2 ++ include/wx/msw/radiobox.h | 2 ++ include/wx/msw/slider.h | 2 ++ include/wx/msw/subwin.h | 36 +++++++++++++++++++++++++++++++++++- 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index d444e3f67a..e9f5597b1f 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -85,6 +85,8 @@ All (GUI): - Add wxAppProgressIndicator for MSW (Chaobin Zhang) and OS X (Tobias Taschner). - Add wxEVT_MAGNIFY mouse event (Joost Nieuwenhuijse). - Add wxProcess::Activate(). +- Fix setting colours of labels in wxSlider. +- Fix setting background colour of wxRadioBox buttons. - Add wxTopLevelWindow::Enable{Maximize,Minimize}Button() (John Roberts). - Make results of wxDC::DrawEllipticArc() consistent across all platforms. - XRC handler for wxAuiToolBar added (Kinaou Hervé, David Hart). diff --git a/include/wx/msw/radiobox.h b/include/wx/msw/radiobox.h index 3c11d52842..58f6ee8ac9 100644 --- a/include/wx/msw/radiobox.h +++ b/include/wx/msw/radiobox.h @@ -100,6 +100,8 @@ public: virtual void SetFocus(); virtual bool SetFont(const wxFont& font); virtual bool ContainsHWND(WXHWND hWnd) const; + virtual bool SetForegroundColour(const wxColour& colour); + virtual bool SetBackgroundColour(const wxColour& colour); #if wxUSE_TOOLTIPS virtual bool HasToolTips() const; #endif // wxUSE_TOOLTIPS diff --git a/include/wx/msw/slider.h b/include/wx/msw/slider.h index 03f58c3fd4..7579e834f1 100644 --- a/include/wx/msw/slider.h +++ b/include/wx/msw/slider.h @@ -91,6 +91,8 @@ public: virtual bool Show(bool show = true); virtual bool Enable(bool show = true); virtual bool SetFont(const wxFont& font); + virtual bool SetForegroundColour(const wxColour& colour); + virtual bool SetBackgroundColour(const wxColour& colour); virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const; diff --git a/include/wx/msw/subwin.h b/include/wx/msw/subwin.h index 85fdb68186..b38d2037ad 100644 --- a/include/wx/msw/subwin.h +++ b/include/wx/msw/subwin.h @@ -128,6 +128,18 @@ public: } } + // add all windows to update region to force redraw + void Refresh() + { + for ( size_t n = 0; n < m_count; n++ ) + { + if ( m_hwnds[n] ) + { + ::InvalidateRect(m_hwnds[n], NULL, FALSE /* don't erase bg */); + } + } + } + // find the bounding box for all windows wxRect GetBoundingBox() const { @@ -212,7 +224,29 @@ private: subwins->SetFont(font); \ \ return true; \ - } + } \ + \ + bool cname::SetForegroundColour(const wxColour& colour) \ + { \ + if ( !base::SetForegroundColour(colour) ) \ + return false; \ + \ + if ( subwins ) \ + subwins->Refresh(); \ + \ + return true; \ + } \ + \ + bool cname::SetBackgroundColour(const wxColour& colour) \ + { \ + if ( !base::SetBackgroundColour(colour) ) \ + return false; \ + \ + if ( subwins ) \ + subwins->Refresh(); \ + \ + return true; \ + } \ #endif // _WX_MSW_SUBWIN_H_