If a MINSIZEn property is not present, fall back to actual size of nth
image to determine whether it is suitable.
This commit is contained in:
parent
41f2189417
commit
e53a7639d7
@ -187,11 +187,41 @@ static PTHEME_PROPERTY UXTHEME_SelectImage(HTHEME hTheme, HDC hdc, int iPartId,
|
|||||||
POINT size = {pRect->right-pRect->left, pRect->bottom-pRect->top};
|
POINT size = {pRect->right-pRect->left, pRect->bottom-pRect->top};
|
||||||
POINT reqsize;
|
POINT reqsize;
|
||||||
for(i=4; i>=0; i--) {
|
for(i=4; i>=0; i--) {
|
||||||
if(SUCCEEDED(GetThemePosition(hTheme, iPartId, iStateId, i + TMT_MINSIZE1, &reqsize))) {
|
PTHEME_PROPERTY fileProp =
|
||||||
if(reqsize.x >= size.x && reqsize.y >= size.y) {
|
MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_FILENAME, i + TMT_IMAGEFILE1);
|
||||||
TRACE("Using image size %ldx%ld, image %d\n", reqsize.x, reqsize.y, i + TMT_IMAGEFILE1);
|
if (!fileProp) continue;
|
||||||
return MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_FILENAME, i + TMT_IMAGEFILE1);
|
if(FAILED(GetThemePosition(hTheme, iPartId, iStateId, i + TMT_MINSIZE1, &reqsize))) {
|
||||||
|
/* fall back to size of Nth image */
|
||||||
|
WCHAR szPath[MAX_PATH];
|
||||||
|
int imagelayout = IL_HORIZONTAL;
|
||||||
|
int imagecount = 1;
|
||||||
|
int imagenum;
|
||||||
|
BITMAP bmp;
|
||||||
|
HBITMAP hBmp;
|
||||||
|
BOOL hasAlpha;
|
||||||
|
|
||||||
|
lstrcpynW(szPath, fileProp->lpValue,
|
||||||
|
min(fileProp->dwValueLen+1, sizeof(szPath)/sizeof(szPath[0])));
|
||||||
|
hBmp = MSSTYLES_LoadBitmap(hTheme, szPath, &hasAlpha);
|
||||||
|
if(!hBmp) continue;
|
||||||
|
|
||||||
|
GetThemeEnumValue(hTheme, iPartId, iStateId, TMT_IMAGELAYOUT, &imagelayout);
|
||||||
|
GetThemeInt(hTheme, iPartId, iStateId, TMT_IMAGECOUNT, &imagecount);
|
||||||
|
|
||||||
|
imagenum = max (min (imagecount, iStateId), 1) - 1;
|
||||||
|
GetObjectW(hBmp, sizeof(bmp), &bmp);
|
||||||
|
if(imagelayout == IL_VERTICAL) {
|
||||||
|
reqsize.x = bmp.bmWidth;
|
||||||
|
reqsize.y = bmp.bmHeight/imagecount;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
reqsize.x = bmp.bmWidth/imagecount;
|
||||||
|
reqsize.y = bmp.bmHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(reqsize.x <= size.x && reqsize.y <= size.y) {
|
||||||
|
TRACE("Using image size %ldx%ld, image %d\n", reqsize.x, reqsize.y, i + TMT_IMAGEFILE1);
|
||||||
|
return fileProp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* If an image couldnt be selected, choose the smallest one */
|
/* If an image couldnt be selected, choose the smallest one */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user