comctl32/button: Correctly place parts for themed group boxes.

Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zhiyi Zhang 2021-11-05 14:34:58 +08:00 committed by Alexandre Julliard
parent 4f912012a9
commit 7c9cacd47f

View file

@ -2855,11 +2855,12 @@ cleanup:
static void GB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, int state, UINT dtFlags, BOOL focused) static void GB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, int state, UINT dtFlags, BOOL focused)
{ {
RECT bgRect, textRect, contentRect; RECT clientRect, contentRect, imageRect, textRect, bgRect;
WCHAR *text = get_button_text(infoPtr); HRGN region, textRegion = NULL;
LOGFONTW lf; LOGFONTW lf;
HFONT font, hPrevFont = NULL; HFONT font, hPrevFont = NULL;
BOOL created_font = FALSE; BOOL created_font = FALSE;
TEXTMETRICW textMetric;
HRESULT hr = GetThemeFont(theme, hDC, BP_GROUPBOX, state, TMT_FONT, &lf); HRESULT hr = GetThemeFont(theme, hDC, BP_GROUPBOX, state, TMT_FONT, &lf);
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
@ -2875,37 +2876,41 @@ static void GB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in
SelectObject(hDC, infoPtr->font); SelectObject(hDC, infoPtr->font);
} }
GetClientRect(infoPtr->hwnd, &bgRect); GetClientRect(infoPtr->hwnd, &clientRect);
textRect = bgRect; GetThemeBackgroundContentRect(theme, hDC, BP_GROUPBOX, state, &clientRect, &contentRect);
region = set_control_clipping(hDC, &clientRect);
if (text) bgRect = contentRect;
GetTextMetricsW(hDC, &textMetric);
bgRect.top += (textMetric.tmHeight / 2) - 1;
InflateRect(&contentRect, -7, 1);
dtFlags = BUTTON_CalcLayoutRects(infoPtr, hDC, &contentRect, &imageRect, &textRect);
if (dtFlags != (UINT)-1 && !show_image_only(infoPtr))
{ {
SIZE textExtent; textRegion = CreateRectRgnIndirect(&textRect);
GetTextExtentPoint32W(hDC, text, lstrlenW(text), &textExtent); ExtSelectClipRgn(hDC, textRegion, RGN_DIFF);
bgRect.top += (textExtent.cy / 2);
textRect.left += 10;
textRect.bottom = textRect.top + textExtent.cy;
textRect.right = textRect.left + textExtent.cx + 4;
ExcludeClipRect(hDC, textRect.left, textRect.top, textRect.right, textRect.bottom);
} }
GetThemeBackgroundContentRect(theme, hDC, BP_GROUPBOX, state, &bgRect, &contentRect);
ExcludeClipRect(hDC, contentRect.left, contentRect.top, contentRect.right, contentRect.bottom);
if (IsThemeBackgroundPartiallyTransparent(theme, BP_GROUPBOX, state)) if (IsThemeBackgroundPartiallyTransparent(theme, BP_GROUPBOX, state))
DrawThemeParentBackground(infoPtr->hwnd, hDC, NULL); DrawThemeParentBackground(infoPtr->hwnd, hDC, NULL);
DrawThemeBackground(theme, hDC, BP_GROUPBOX, state, &bgRect, NULL); DrawThemeBackground(theme, hDC, BP_GROUPBOX, state, &bgRect, NULL);
SelectClipRgn(hDC, NULL); if (dtFlags != (UINT)-1)
if (text)
{ {
InflateRect(&textRect, -2, 0); contentRect.left--;
DrawThemeText(theme, hDC, BP_GROUPBOX, state, text, lstrlenW(text), 0, 0, &textRect); contentRect.right++;
heap_free(text); contentRect.bottom++;
if (textRegion)
{
SelectClipRgn(hDC, textRegion);
DeleteObject(textRegion);
}
BUTTON_DrawThemedLabel(infoPtr, hDC, dtFlags, &imageRect, &textRect, theme, BP_GROUPBOX, state);
} }
SelectClipRgn(hDC, region);
if (region) DeleteObject(region);
if (created_font) DeleteObject(font); if (created_font) DeleteObject(font);
if (hPrevFont) SelectObject(hDC, hPrevFont); if (hPrevFont) SelectObject(hDC, hPrevFont);
} }