Merge branch 'msw-themed-borders'

Fix border drawing when using some non-standard MSW themes.

See https://github.com/wxWidgets/wxWidgets/pull/1105

Closes https://github.com/wxWidgets/wxWidgets/pull/1141
This commit is contained in:
Vadim Zeitlin
2019-01-16 21:42:01 +01:00

View File

@@ -3738,20 +3738,25 @@ wxWindowMSW::MSWHandleMessage(WXLRESULT *result,
hTheme,
GetHdcOf(*impl),
EP_EDITTEXT,
ETS_NORMAL,
IsEnabled() ? ETS_NORMAL : ETS_DISABLED,
rect,
&rcClient) == S_OK )
&rcClient) != S_OK )
{
InflateRect(&rcClient, -1, -1);
if (wParam)
csparam->rgrc[0] = rcClient;
else
*((RECT*)lParam) = rcClient;
// WVR_REDRAW triggers a bug whereby child windows are moved up and left,
// so don't use.
// rc.result = WVR_REDRAW;
// If GetThemeBackgroundContentRect() failed, as can
// happen with at least some custom themes, just use
// the original client rectangle.
rcClient = *rect;
}
InflateRect(&rcClient, -1, -1);
if (wParam)
csparam->rgrc[0] = rcClient;
else
*((RECT*)lParam) = rcClient;
// WVR_REDRAW triggers a bug whereby child windows are moved up and left,
// so don't use.
// rc.result = WVR_REDRAW;
}
}
break;
@@ -3774,28 +3779,37 @@ wxWindowMSW::MSWHandleMessage(WXLRESULT *result,
wxCopyRectToRECT(GetSize(), rcBorder);
RECT rcClient;
::GetThemeBackgroundContentRect(
hTheme, GetHdcOf(*impl), EP_EDITTEXT, ETS_NORMAL, &rcBorder, &rcClient);
const int nState = IsEnabled() ? ETS_NORMAL : ETS_DISABLED;
if ( ::GetThemeBackgroundContentRect
(
hTheme,
GetHdcOf(*impl),
EP_EDITTEXT,
nState,
&rcBorder,
&rcClient
) != S_OK )
{
// As above in WM_NCCALCSIZE, fall back on something
// reasonable for themes which don't implement this
// function.
rcClient = rcBorder;
}
InflateRect(&rcClient, -1, -1);
::ExcludeClipRect(GetHdcOf(*impl), rcClient.left, rcClient.top,
rcClient.right, rcClient.bottom);
// Make sure the background is in a proper state
if (::IsThemeBackgroundPartiallyTransparent(hTheme, EP_EDITTEXT, ETS_NORMAL))
if (::IsThemeBackgroundPartiallyTransparent(hTheme, EP_EDITTEXT, nState))
{
::DrawThemeParentBackground(GetHwnd(), GetHdcOf(*impl), &rcBorder);
}
// Draw the border
int nState;
if ( !IsEnabled() )
nState = ETS_DISABLED;
// should we check this?
//else if ( ::GetWindowLong(GetHwnd(), GWL_STYLE) & ES_READONLY)
// nState = ETS_READONLY;
else
nState = ETS_NORMAL;
::DrawThemeBackground(hTheme, GetHdcOf(*impl), EP_EDITTEXT, nState, &rcBorder, NULL);
}
}