Commit 0d96bf1f authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

uxtheme: Support TrueSizeScalingType property.

parent 399ebdf8
...@@ -149,7 +149,8 @@ HRESULT WINAPI DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, ...@@ -149,7 +149,8 @@ HRESULT WINAPI DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId,
* *
* Select the image to use * Select the image to use
*/ */
static PTHEME_PROPERTY UXTHEME_SelectImage(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, BOOL glyph) static PTHEME_PROPERTY UXTHEME_SelectImage(HTHEME hTheme, HDC hdc, int iPartId, int iStateId,
const RECT *pRect, BOOL glyph, int *imageDpi)
{ {
PTHEME_PROPERTY tp; PTHEME_PROPERTY tp;
int imageselecttype = IST_NONE; int imageselecttype = IST_NONE;
...@@ -160,6 +161,9 @@ static PTHEME_PROPERTY UXTHEME_SelectImage(HTHEME hTheme, HDC hdc, int iPartId, ...@@ -160,6 +161,9 @@ static PTHEME_PROPERTY UXTHEME_SelectImage(HTHEME hTheme, HDC hdc, int iPartId,
else else
image = TMT_IMAGEFILE; image = TMT_IMAGEFILE;
if (imageDpi)
*imageDpi = 96;
if((tp=MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_FILENAME, image))) if((tp=MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_FILENAME, image)))
return tp; return tp;
GetThemeEnumValue(hTheme, iPartId, iStateId, TMT_IMAGESELECTTYPE, &imageselecttype); GetThemeEnumValue(hTheme, iPartId, iStateId, TMT_IMAGESELECTTYPE, &imageselecttype);
...@@ -172,6 +176,10 @@ static PTHEME_PROPERTY UXTHEME_SelectImage(HTHEME hTheme, HDC hdc, int iPartId, ...@@ -172,6 +176,10 @@ static PTHEME_PROPERTY UXTHEME_SelectImage(HTHEME hTheme, HDC hdc, int iPartId,
if(SUCCEEDED(GetThemeInt(hTheme, iPartId, iStateId, i + TMT_MINDPI1, &reqdpi))) { if(SUCCEEDED(GetThemeInt(hTheme, iPartId, iStateId, i + TMT_MINDPI1, &reqdpi))) {
if(reqdpi != 0 && screendpi >= reqdpi) { if(reqdpi != 0 && screendpi >= reqdpi) {
TRACE("Using %d DPI, image %d\n", reqdpi, i + TMT_IMAGEFILE1); TRACE("Using %d DPI, image %d\n", reqdpi, i + TMT_IMAGEFILE1);
if (imageDpi)
*imageDpi = reqdpi;
return MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_FILENAME, i + TMT_IMAGEFILE1); return MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_FILENAME, i + TMT_IMAGEFILE1);
} }
} }
...@@ -228,15 +236,18 @@ static PTHEME_PROPERTY UXTHEME_SelectImage(HTHEME hTheme, HDC hdc, int iPartId, ...@@ -228,15 +236,18 @@ static PTHEME_PROPERTY UXTHEME_SelectImage(HTHEME hTheme, HDC hdc, int iPartId,
* *
* Load image for part/state * Load image for part/state
*/ */
static HRESULT UXTHEME_LoadImage(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, BOOL glyph, static HRESULT UXTHEME_LoadImage(HTHEME hTheme, HDC hdc, int iPartId, int iStateId,
HBITMAP *hBmp, RECT *bmpRect, BOOL* hasImageAlpha) const RECT *pRect, BOOL glyph, HBITMAP *hBmp, RECT *bmpRect,
BOOL *hasImageAlpha, int *imageDpi)
{ {
int imagelayout = IL_HORIZONTAL; int imagelayout = IL_HORIZONTAL;
int imagecount = 1; int imagecount = 1;
int imagenum; int imagenum;
BITMAP bmp; BITMAP bmp;
WCHAR szPath[MAX_PATH]; WCHAR szPath[MAX_PATH];
PTHEME_PROPERTY tp = UXTHEME_SelectImage(hTheme, hdc, iPartId, iStateId, pRect, glyph); PTHEME_PROPERTY tp;
tp = UXTHEME_SelectImage(hTheme, hdc, iPartId, iStateId, pRect, glyph, imageDpi);
if(!tp) { if(!tp) {
FIXME("Couldn't determine image for part/state %d/%d, invalid theme?\n", iPartId, iStateId); FIXME("Couldn't determine image for part/state %d/%d, invalid theme?\n", iPartId, iStateId);
return E_PROP_ID_UNSUPPORTED; return E_PROP_ID_UNSUPPORTED;
...@@ -484,8 +495,8 @@ static HRESULT UXTHEME_DrawImageGlyph(HTHEME hTheme, HDC hdc, int iPartId, ...@@ -484,8 +495,8 @@ static HRESULT UXTHEME_DrawImageGlyph(HTHEME hTheme, HDC hdc, int iPartId,
POINT topleft; POINT topleft;
BOOL hasAlpha; BOOL hasAlpha;
hr = UXTHEME_LoadImage(hTheme, hdc, iPartId, iStateId, pRect, TRUE, hr = UXTHEME_LoadImage(hTheme, hdc, iPartId, iStateId, pRect, TRUE, &bmpSrc, &rcSrc, &hasAlpha,
&bmpSrc, &rcSrc, &hasAlpha); NULL);
if(FAILED(hr)) return hr; if(FAILED(hr)) return hr;
hdcSrc = CreateCompatibleDC(hdc); hdcSrc = CreateCompatibleDC(hdc);
if(!hdcSrc) { if(!hdcSrc) {
...@@ -554,30 +565,50 @@ static HRESULT get_image_part_size (HTHEME hTheme, HDC hdc, int iPartId, ...@@ -554,30 +565,50 @@ static HRESULT get_image_part_size (HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, RECT *prc, THEMESIZE eSize, int iStateId, RECT *prc, THEMESIZE eSize,
POINT *psz) POINT *psz)
{ {
int imageDpi, dstDpi;
HRESULT hr = S_OK; HRESULT hr = S_OK;
HBITMAP bmpSrc; HBITMAP bmpSrc;
RECT rcSrc; RECT rcSrc;
BOOL hasAlpha; BOOL hasAlpha;
hr = UXTHEME_LoadImage(hTheme, hdc, iPartId, iStateId, prc, FALSE, hr = UXTHEME_LoadImage(hTheme, hdc, iPartId, iStateId, prc, FALSE, &bmpSrc, &rcSrc, &hasAlpha,
&bmpSrc, &rcSrc, &hasAlpha); &imageDpi);
if (FAILED(hr)) return hr; if (FAILED(hr)) return hr;
switch (eSize) switch (eSize)
{ {
case TS_DRAW: case TS_DRAW:
{
int sizingType = ST_STRETCH, scalingType = TSST_NONE;
POINT srcSize;
srcSize.x = rcSrc.right - rcSrc.left;
srcSize.y = rcSrc.bottom - rcSrc.top;
GetThemeEnumValue(hTheme, iPartId, iStateId, TMT_SIZINGTYPE, &sizingType);
if (sizingType == ST_TRUESIZE)
{
GetThemeEnumValue(hTheme, iPartId, iStateId, TMT_TRUESIZESCALINGTYPE, &scalingType);
if (scalingType == TSST_DPI)
{
dstDpi = GetDeviceCaps(hdc, LOGPIXELSY);
if (dstDpi && dstDpi != imageDpi)
{
srcSize.x = MulDiv(srcSize.x, dstDpi, imageDpi);
srcSize.y = MulDiv(srcSize.y, dstDpi, imageDpi);
}
}
}
*psz = srcSize;
if (prc != NULL) if (prc != NULL)
{ {
POINT dstSize; POINT dstSize;
POINT srcSize;
int sizingtype = ST_STRETCH;
BOOL uniformsizing = FALSE; BOOL uniformsizing = FALSE;
dstSize.x = prc->right - prc->left; dstSize.x = prc->right - prc->left;
dstSize.y = prc->bottom - prc->top; dstSize.y = prc->bottom - prc->top;
srcSize.x = rcSrc.right-rcSrc.left;
srcSize.y = rcSrc.bottom-rcSrc.top;
GetThemeBool(hTheme, iPartId, iStateId, TMT_UNIFORMSIZING, &uniformsizing); GetThemeBool(hTheme, iPartId, iStateId, TMT_UNIFORMSIZING, &uniformsizing);
if(uniformsizing) { if(uniformsizing) {
/* Scale height and width equally */ /* Scale height and width equally */
...@@ -586,9 +617,9 @@ static HRESULT get_image_part_size (HTHEME hTheme, HDC hdc, int iPartId, ...@@ -586,9 +617,9 @@ static HRESULT get_image_part_size (HTHEME hTheme, HDC hdc, int iPartId,
else else
dstSize.x = MulDiv (srcSize.x, dstSize.y, srcSize.y); dstSize.x = MulDiv (srcSize.x, dstSize.y, srcSize.y);
} }
GetThemeEnumValue(hTheme, iPartId, iStateId, TMT_SIZINGTYPE, &sizingtype); if (sizingType == ST_TRUESIZE)
if(sizingtype == ST_TRUESIZE) { {
int truesizestretchmark = 100; int truesizestretchmark = 100;
/* Whatever TrueSizeStretchMark does - it does not seem to /* Whatever TrueSizeStretchMark does - it does not seem to
...@@ -599,13 +630,11 @@ static HRESULT get_image_part_size (HTHEME hTheme, HDC hdc, int iPartId, ...@@ -599,13 +630,11 @@ static HRESULT get_image_part_size (HTHEME hTheme, HDC hdc, int iPartId,
/* Only stretch when target exceeds source by truesizestretchmark percent */ /* Only stretch when target exceeds source by truesizestretchmark percent */
GetThemeInt(hTheme, iPartId, iStateId, TMT_TRUESIZESTRETCHMARK, &truesizestretchmark); GetThemeInt(hTheme, iPartId, iStateId, TMT_TRUESIZESTRETCHMARK, &truesizestretchmark);
#endif #endif
if(dstSize.x < 0 || dstSize.y < 0 || if (scalingType == TSST_SIZE || dstSize.x < 0 || dstSize.y < 0
(MulDiv(srcSize.x, 100, dstSize.x) > truesizestretchmark && || (MulDiv(srcSize.x, 100, dstSize.x) > truesizestretchmark
MulDiv(srcSize.y, 100, dstSize.y) > truesizestretchmark)) { && MulDiv(srcSize.y, 100, dstSize.y) > truesizestretchmark))
memcpy (psz, &dstSize, sizeof (SIZE)); {
} *psz = dstSize;
else {
memcpy (psz, &srcSize, sizeof (SIZE));
} }
} }
else else
...@@ -613,9 +642,10 @@ static HRESULT get_image_part_size (HTHEME hTheme, HDC hdc, int iPartId, ...@@ -613,9 +642,10 @@ static HRESULT get_image_part_size (HTHEME hTheme, HDC hdc, int iPartId,
psz->x = abs(dstSize.x); psz->x = abs(dstSize.x);
psz->y = abs(dstSize.y); psz->y = abs(dstSize.y);
} }
break;
} }
/* else fall through */
break;
}
case TS_MIN: case TS_MIN:
/* FIXME: couldn't figure how native uxtheme computes min size */ /* FIXME: couldn't figure how native uxtheme computes min size */
case TS_TRUE: case TS_TRUE:
...@@ -649,8 +679,8 @@ static HRESULT UXTHEME_DrawImageBackground(HTHEME hTheme, HDC hdc, int iPartId, ...@@ -649,8 +679,8 @@ static HRESULT UXTHEME_DrawImageBackground(HTHEME hTheme, HDC hdc, int iPartId,
COLORREF transparentcolor = 0; COLORREF transparentcolor = 0;
BOOL hasAlpha; BOOL hasAlpha;
hr = UXTHEME_LoadImage(hTheme, hdc, iPartId, iStateId, pRect, FALSE, hr = UXTHEME_LoadImage(hTheme, hdc, iPartId, iStateId, pRect, FALSE, &bmpSrc, &rcSrc, &hasAlpha,
&bmpSrc, &rcSrc, &hasAlpha); NULL);
if(FAILED(hr)) return hr; if(FAILED(hr)) return hr;
hdcSrc = CreateCompatibleDC(hdc); hdcSrc = CreateCompatibleDC(hdc);
if(!hdcSrc) { if(!hdcSrc) {
...@@ -2078,8 +2108,8 @@ BOOL WINAPI IsThemeBackgroundPartiallyTransparent(HTHEME hTheme, int iPartId, ...@@ -2078,8 +2108,8 @@ BOOL WINAPI IsThemeBackgroundPartiallyTransparent(HTHEME hTheme, int iPartId,
if (bgtype != BT_IMAGEFILE) return FALSE; if (bgtype != BT_IMAGEFILE) return FALSE;
if(FAILED (UXTHEME_LoadImage (hTheme, 0, iPartId, iStateId, &rect, FALSE, if (FAILED(UXTHEME_LoadImage(hTheme, 0, iPartId, iStateId, &rect, FALSE, &bmpSrc, &rcSrc,
&bmpSrc, &rcSrc, &hasAlpha))) &hasAlpha, NULL)))
return FALSE; return FALSE;
get_transparency (hTheme, iPartId, iStateId, hasAlpha, &transparent, get_transparency (hTheme, iPartId, iStateId, hasAlpha, &transparent,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment