From: Robin Dunn Date: Sat, 12 Mar 2005 20:25:19 +0000 (+0000) Subject: Allow wxStaticText to have a custom fg without a custom bg X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1e255b00ced5114d9b599cd66cd9d737686cec94 Allow wxStaticText to have a custom fg without a custom bg git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32780 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/msw/control.h b/include/wx/msw/control.h index d00396b335..ab32c80c76 100644 --- a/include/wx/msw/control.h +++ b/include/wx/msw/control.h @@ -133,7 +133,7 @@ protected: // common part of the 3 functions above: pass wxNullColour to use the // appropriate background colour (meaning ours or our parents) or a fixed // one - WXHBRUSH DoMSWControlColor(WXHDC pDC, wxColour colBg); + virtual WXHBRUSH DoMSWControlColor(WXHDC pDC, wxColour colBg); // another WM_CTLCOLOR-related function: override this to return the brush // which should be used to paint the control background by default diff --git a/include/wx/msw/stattext.h b/include/wx/msw/stattext.h index 0ceef4c977..6f6016f11c 100644 --- a/include/wx/msw/stattext.h +++ b/include/wx/msw/stattext.h @@ -51,6 +51,7 @@ protected: int sizeFlags = wxSIZE_AUTO); virtual wxSize DoGetBestSize() const; virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const; + virtual WXHBRUSH DoMSWControlColor(WXHDC pDC, wxColour colBg); DECLARE_DYNAMIC_CLASS_NO_COPY(wxStaticText) }; diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp index 124d9e471d..518a7677fd 100644 --- a/src/msw/stattext.cpp +++ b/src/msw/stattext.cpp @@ -126,6 +126,19 @@ WXDWORD wxStaticText::MSWGetStyle(long style, WXDWORD *exstyle) const return msStyle; } +WXHBRUSH wxStaticText::DoMSWControlColor(WXHDC pDC, wxColour colBg) +{ + // If this control has a non-standard fg colour but still has the standard + // bg then we need to also give it a non-standard bg otherwise the fg + // setting has no effect. + WXHBRUSH hbr = wxControl::DoMSWControlColor(pDC, colBg); + if (!hbr && m_hasFgCol) + { + hbr = MSWGetBgBrushForChild(pDC, this); + } + return hbr; +} + wxSize wxStaticText::DoGetBestSize() const { wxClientDC dc(wx_const_cast(wxStaticText *, this));