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
This commit is contained in:
Robin Dunn 2005-03-12 20:25:19 +00:00
parent a685a06c96
commit 1e255b00ce
3 changed files with 15 additions and 1 deletions

View File

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

View File

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

View File

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