2 * Win32 5.1 Theme metrics
4 * Copyright (C) 2003 Kevin Koltzau
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(uxtheme
);
37 /***********************************************************************
38 * GetThemeSysBool (UXTHEME.@)
40 BOOL WINAPI
GetThemeSysBool(HTHEME hTheme
, int iBoolID
)
46 TRACE("(%p, %d)\n", hTheme
, iBoolID
);
49 if((tp
= MSSTYLES_FindMetric(TMT_BOOL
, iBoolID
))) {
50 hr
= MSSTYLES_GetPropertyBool(tp
, &ret
);
57 if(iBoolID
== TMT_FLATMENUS
) {
58 if(SystemParametersInfoW(SPI_GETFLATMENU
, 0, &ret
, 0))
62 FIXME("Unknown bool id: %d\n", iBoolID
);
63 SetLastError(STG_E_INVALIDPARAMETER
);
68 /***********************************************************************
69 * GetThemeSysColor (UXTHEME.@)
71 COLORREF WINAPI
GetThemeSysColor(HTHEME hTheme
, int iColorID
)
76 TRACE("(%p, %d)\n", hTheme
, iColorID
);
79 if((tp
= MSSTYLES_FindMetric(TMT_COLOR
, iColorID
))) {
81 hr
= MSSTYLES_GetPropertyColor(tp
, &color
);
88 return GetSysColor(iColorID
);
91 /***********************************************************************
92 * GetThemeSysColorBrush (UXTHEME.@)
94 HBRUSH WINAPI
GetThemeSysColorBrush(HTHEME hTheme
, int iColorID
)
96 TRACE("(%p, %d)\n", hTheme
, iColorID
);
97 return CreateSolidBrush(GetThemeSysColor(hTheme
, iColorID
));
100 /***********************************************************************
101 * GetThemeSysFont (UXTHEME.@)
103 HRESULT WINAPI
GetThemeSysFont(HTHEME hTheme
, int iFontID
, LOGFONTW
*plf
)
108 TRACE("(%p, %d)\n", hTheme
, iFontID
);
110 if((tp
= MSSTYLES_FindMetric(TMT_FONT
, iFontID
))) {
111 HDC hdc
= GetDC(NULL
);
112 hr
= MSSTYLES_GetPropertyFont(tp
, hdc
, plf
);
113 ReleaseDC(NULL
, hdc
);
118 if(iFontID
== TMT_ICONTITLEFONT
) {
119 if(!SystemParametersInfoW(SPI_GETICONTITLELOGFONT
, sizeof(LOGFONTW
), plf
, 0))
120 return HRESULT_FROM_WIN32(GetLastError());
123 NONCLIENTMETRICSW ncm
;
124 LOGFONTW
*font
= NULL
;
125 ncm
.cbSize
= sizeof(NONCLIENTMETRICSW
);
126 if(!SystemParametersInfoW(SPI_GETNONCLIENTMETRICS
, sizeof(NONCLIENTMETRICSW
), &ncm
, 0))
127 return HRESULT_FROM_WIN32(GetLastError());
129 case TMT_CAPTIONFONT
: font
= &ncm
.lfCaptionFont
; break;
130 case TMT_SMALLCAPTIONFONT
: font
= &ncm
.lfSmCaptionFont
; break;
131 case TMT_MENUFONT
: font
= &ncm
.lfMenuFont
; break;
132 case TMT_STATUSFONT
: font
= &ncm
.lfStatusFont
; break;
133 case TMT_MSGBOXFONT
: font
= &ncm
.lfMessageFont
; break;
134 default: FIXME("Unknown FontID: %d\n", iFontID
); break;
136 if(font
) *plf
= *font
;
137 else hr
= STG_E_INVALIDPARAMETER
;
142 /***********************************************************************
143 * GetThemeSysInt (UXTHEME.@)
145 HRESULT WINAPI
GetThemeSysInt(HTHEME hTheme
, int iIntID
, int *piValue
)
149 TRACE("(%p, %d)\n", hTheme
, iIntID
);
152 if(iIntID
< TMT_FIRSTINT
|| iIntID
> TMT_LASTINT
) {
153 WARN("Unknown IntID: %d\n", iIntID
);
154 return STG_E_INVALIDPARAMETER
;
156 if((tp
= MSSTYLES_FindMetric(TMT_INT
, iIntID
)))
157 return MSSTYLES_GetPropertyInt(tp
, piValue
);
158 return E_PROP_ID_UNSUPPORTED
;
161 /***********************************************************************
162 * GetThemeSysSize (UXTHEME.@)
164 int WINAPI
GetThemeSysSize(HTHEME hTheme
, int iSizeID
)
166 static const int metricMap
[] = {
167 SM_CXVSCROLL
, TMT_SCROLLBARWIDTH
,
168 SM_CYHSCROLL
, TMT_SCROLLBARHEIGHT
,
169 SM_CXSIZE
, TMT_CAPTIONBARWIDTH
,
170 SM_CYSIZE
, TMT_CAPTIONBARHEIGHT
,
171 SM_CXFRAME
, TMT_SIZINGBORDERWIDTH
,
172 SM_CYFRAME
, TMT_SIZINGBORDERWIDTH
, /* There is no TMT_SIZINGBORDERHEIGHT, but this works in windows.. */
173 SM_CXSMSIZE
, TMT_SMCAPTIONBARWIDTH
,
174 SM_CYSMSIZE
, TMT_SMCAPTIONBARHEIGHT
,
175 SM_CXMENUSIZE
, TMT_MENUBARWIDTH
,
176 SM_CYMENUSIZE
, TMT_MENUBARHEIGHT
182 for(i
=0; i
<ARRAY_SIZE(metricMap
); i
+=2) {
183 if(metricMap
[i
] == iSizeID
) {
190 if((tp
= MSSTYLES_FindMetric(TMT_SIZE
, id
))) {
191 if(SUCCEEDED(MSSTYLES_GetPropertyInt(tp
, &i
))) {
195 TRACE("Size %d not found in theme, using system metric\n", iSizeID
);
198 SetLastError(STG_E_INVALIDPARAMETER
);
202 return GetSystemMetrics(iSizeID
);
205 /***********************************************************************
206 * GetThemeSysString (UXTHEME.@)
208 HRESULT WINAPI
GetThemeSysString(HTHEME hTheme
, int iStringID
,
209 LPWSTR pszStringBuff
, int cchMaxStringChars
)
213 TRACE("(%p, %d)\n", hTheme
, iStringID
);
216 if(iStringID
< TMT_FIRSTSTRING
|| iStringID
> TMT_LASTSTRING
) {
217 WARN("Unknown StringID: %d\n", iStringID
);
218 return STG_E_INVALIDPARAMETER
;
220 if((tp
= MSSTYLES_FindMetric(TMT_STRING
, iStringID
)))
221 return MSSTYLES_GetPropertyString(tp
, pszStringBuff
, cchMaxStringChars
);
222 return E_PROP_ID_UNSUPPORTED
;
225 /***********************************************************************
226 * GetThemeTransitionDuration (UXTHEME.@)
228 HRESULT WINAPI
GetThemeTransitionDuration(HTHEME hTheme
, int iPartId
, int iStateIdFrom
,
229 int iStateIdTo
, int iPropId
, DWORD
*pdwDuration
)
234 TRACE("(%p, %d, %d, %d, %d, %p)\n", hTheme
, iPartId
, iStateIdFrom
, iStateIdTo
, iPropId
,
237 if (!pdwDuration
|| iStateIdFrom
< 1 || iStateIdTo
< 1)
240 hr
= GetThemeIntList(hTheme
, iPartId
, 0, iPropId
, &intlist
);
243 if (hr
== E_PROP_ID_UNSUPPORTED
)
249 if (intlist
.iValueCount
< 1 || iStateIdFrom
> intlist
.iValues
[0]
250 || iStateIdTo
> intlist
.iValues
[0]
251 || intlist
.iValueCount
!= 1 + intlist
.iValues
[0] * intlist
.iValues
[0])
257 *pdwDuration
= intlist
.iValues
[1 + intlist
.iValues
[0] * (iStateIdFrom
- 1) + (iStateIdTo
- 1)];