Set correct foreground default in wxControl::DoMSWControlColor().

Instead of hard-coding GetSysColor(COLOR_WINDOWTEXT), use
GetForegroundColour() which will call GetDefaultAttributes() to retrieve the
default foreground appropriate for this control.

This also allows to make the code simpler by calling SetTextColor() only once.

See #1691.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61860 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-09-08 12:23:28 +00:00
parent 52c5093f76
commit 3316192f0d

View File

@@ -375,10 +375,6 @@ bool wxControl::MSWOnNotify(int idCtrl,
WXHBRUSH wxControl::DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd) WXHBRUSH wxControl::DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd)
{ {
HDC hdc = (HDC)pDC; HDC hdc = (HDC)pDC;
if ( m_hasFgCol )
{
::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
}
WXHBRUSH hbr = 0; WXHBRUSH hbr = 0;
if ( !colBg.Ok() ) if ( !colBg.Ok() )
@@ -402,12 +398,14 @@ WXHBRUSH wxControl::DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd)
hbr = (WXHBRUSH)brush->GetResourceHandle(); hbr = (WXHBRUSH)brush->GetResourceHandle();
} }
// if we use custom background, we should set foreground ourselves too // always set the foreground colour if we changed the background, whether
if ( hbr && !m_hasFgCol ) // m_hasFgCol is true or not: if it true, we must do it, of course, but
// even if it isn't, we must set the default foreground explicitly as by
// default just the simple black is used
if ( hbr )
{ {
::SetTextColor(hdc, ::GetSysColor(COLOR_WINDOWTEXT)); ::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
} }
//else: already set above
return hbr; return hbr;
} }