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.
This commit is contained in:
Artur Wieczorek 2015-09-11 18:47:49 +02:00 committed by Vadim Zeitlin
parent 7f08dbbf78
commit 865c8565af
4 changed files with 41 additions and 1 deletions

View File

@ -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).

View File

@ -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

View File

@ -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;

View File

@ -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_