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.
oldstable
Frank Richter 2005-07-24 17:09:58 +00:00 committed by Alexandre Julliard
parent 06153098b8
commit 4d2e6b7d98
1 changed files with 26 additions and 7 deletions

View File

@ -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);