From 4d2e6b7d987e1a8aa8a8b20a8505cf3f13baa1ac Mon Sep 17 00:00:00 2001 From: Frank Richter Date: Sun, 24 Jul 2005 17:09:58 +0000 Subject: [PATCH] GetThemeBackgroundContentRect() does not use the content margins alone, it also falls back to the border size or sizing margins, and if it can't find any possible margins at all, it returns the original rectangle. --- dlls/uxtheme/draw.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/dlls/uxtheme/draw.c b/dlls/uxtheme/draw.c index 24f9095def9..69e30c02e2a 100644 --- a/dlls/uxtheme/draw.c +++ b/dlls/uxtheme/draw.c @@ -876,15 +876,34 @@ HRESULT WINAPI GetThemeBackgroundContentRect(HTHEME hTheme, HDC hdc, int iPartId if(!hTheme) return E_HANDLE; + /* try content margins property... */ hr = GetThemeMargins(hTheme, hdc, iPartId, iStateId, TMT_CONTENTMARGINS, NULL, &margin); - if(FAILED(hr)) { - TRACE("Margins not found\n"); - return hr; + if(SUCCEEDED(hr)) { + pContentRect->left = pBoundingRect->left + margin.cxLeftWidth; + pContentRect->top = pBoundingRect->top + margin.cyTopHeight; + pContentRect->right = pBoundingRect->right - margin.cxRightWidth; + pContentRect->bottom = pBoundingRect->bottom - margin.cyBottomHeight; + } else { + /* otherwise, try to determine content rect from the background type and props */ + int bgtype = BT_BORDERFILL; + memcpy(pContentRect, pBoundingRect, sizeof(RECT)); + + GetThemeEnumValue(hTheme, iPartId, iStateId, TMT_BGTYPE, &bgtype); + if(bgtype == BT_BORDERFILL) { + int bordersize = 1; + + GetThemeInt(hTheme, iPartId, iStateId, TMT_BORDERSIZE, &bordersize); + InflateRect(pContentRect, -bordersize, -bordersize); + } else if ((bgtype == BT_IMAGEFILE) + && (SUCCEEDED(hr = GetThemeMargins(hTheme, hdc, iPartId, iStateId, + TMT_SIZINGMARGINS, NULL, &margin)))) { + pContentRect->left = pBoundingRect->left + margin.cxLeftWidth; + pContentRect->top = pBoundingRect->top + margin.cyTopHeight; + pContentRect->right = pBoundingRect->right - margin.cxRightWidth; + pContentRect->bottom = pBoundingRect->bottom - margin.cyBottomHeight; + } + /* If nothing was found, leave unchanged */ } - pContentRect->left = pBoundingRect->left + margin.cxLeftWidth; - pContentRect->top = pBoundingRect->top + margin.cyTopHeight; - pContentRect->right = pBoundingRect->right - margin.cxRightWidth; - pContentRect->bottom = pBoundingRect->bottom - margin.cyBottomHeight; TRACE("left:%ld,top:%ld,right:%ld,bottom:%ld\n", pContentRect->left, pContentRect->top, pContentRect->right, pContentRect->bottom);