X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ac10c957a501599358facf237ce037dd8fcbe908..e24b680c59e78f092c1be432b17b36f849065c36:/src/msw/stattext.cpp diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp index 89538fc884..466fb5484d 100644 --- a/src/msw/stattext.cpp +++ b/src/msw/stattext.cpp @@ -126,10 +126,35 @@ 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); + if (!hbr) + { + HDC hdc = (HDC)pDC; + wxColour bg = GetBackgroundColour(); + ::SetBkColor(hdc, wxColourToRGB(bg)); + wxBrush *brush = wxTheBrushList->FindOrCreateBrush(bg, wxSOLID); + hbr = (WXHBRUSH)brush->GetResourceHandle(); + } + } + return hbr; +} + wxSize wxStaticText::DoGetBestSize() const { wxClientDC dc(wx_const_cast(wxStaticText *, this)); - dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); + wxFont font(GetFont()); + if (!font.Ok()) + font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); + + dc.SetFont(font); wxCoord widthTextMax, heightTextTotal; dc.GetMultiLineTextExtent(GetLabel(), &widthTextMax, &heightTextTotal);