X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3316192f0d8a79103271a48cf293a338ba817975..c6212697785a204cc7c474437dda09f54c727ebe:/src/msw/control.cpp?ds=inline diff --git a/src/msw/control.cpp b/src/msw/control.cpp index e71efd8f1e..056794b517 100644 --- a/src/msw/control.cpp +++ b/src/msw/control.cpp @@ -303,18 +303,6 @@ wxControl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) return attrs; } -// another version for the "composite", i.e. non simple controls -/* static */ wxVisualAttributes -wxControl::GetCompositeControlsDefaultAttributes(wxWindowVariant WXUNUSED(variant)) -{ - wxVisualAttributes attrs; - attrs.font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); - attrs.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); - attrs.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); - - return attrs; -} - // ---------------------------------------------------------------------------- // message handling // ---------------------------------------------------------------------------- @@ -379,7 +367,8 @@ WXHBRUSH wxControl::DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd) WXHBRUSH hbr = 0; if ( !colBg.Ok() ) { - hbr = MSWGetBgBrush(pDC, hWnd); + if ( wxWindow *win = wxFindWinFromHandle(hWnd) ) + hbr = win->MSWGetBgBrush(pDC); // if the control doesn't have any bg colour, foreground colour will be // ignored as the return value would be 0 -- so forcefully give it a @@ -388,12 +377,11 @@ WXHBRUSH wxControl::DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd) colBg = GetBackgroundColour(); } - // use the background colour override if a valid colour is given + // use the background colour override if a valid colour is given: this is + // used when the control is disabled to grey it out and also if colBg was + // set just above if ( colBg.Ok() ) { - ::SetBkColor(hdc, wxColourToRGB(colBg)); - - // draw children with the same colour as the parent wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBg); hbr = (WXHBRUSH)brush->GetResourceHandle(); } @@ -407,6 +395,17 @@ WXHBRUSH wxControl::DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd) ::SetTextColor(hdc, wxColourToRGB(GetForegroundColour())); } + // finally also set the background colour for text drawing: without this, + // the text in an edit control is drawn using the default background even + // if we return a valid brush + if ( colBg.IsOk() || m_hasBgCol ) + { + if ( !colBg.IsOk() ) + colBg = GetBackgroundColour(); + + ::SetBkColor(hdc, wxColourToRGB(colBg)); + } + return hbr; }