1 /*
2 * Win32 5.1 Theme properties
3 *
4 * Copyright (C) 2003 Kevin Koltzau
5 *
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.
10 *
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.
15 *
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
19 */
20
21 #include "uxthemep.h"
22
23 /***********************************************************************
24 * GetThemeBool (UXTHEME.@)
25 */
GetThemeBool(HTHEME hTheme,int iPartId,int iStateId,int iPropId,BOOL * pfVal)26 HRESULT WINAPI GetThemeBool(HTHEME hTheme, int iPartId, int iStateId,
27 int iPropId, BOOL *pfVal)
28 {
29 PTHEME_PROPERTY tp;
30 PTHEME_CLASS pClass = ValidateHandle(hTheme);
31
32 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
33
34 if(!pClass)
35 return E_HANDLE;
36
37 if(!(tp = MSSTYLES_FindProperty(pClass, iPartId, iStateId, TMT_BOOL, iPropId)))
38 return E_PROP_ID_UNSUPPORTED;
39 return MSSTYLES_GetPropertyBool(tp, pfVal);
40 }
41
42 /***********************************************************************
43 * GetThemeColor (UXTHEME.@)
44 */
GetThemeColor(HTHEME hTheme,int iPartId,int iStateId,int iPropId,COLORREF * pColor)45 HRESULT WINAPI GetThemeColor(HTHEME hTheme, int iPartId, int iStateId,
46 int iPropId, COLORREF *pColor)
47 {
48 PTHEME_PROPERTY tp;
49 PTHEME_CLASS pClass = ValidateHandle(hTheme);
50
51 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
52 if(!pClass)
53 return E_HANDLE;
54
55 if(!(tp = MSSTYLES_FindProperty(pClass, iPartId, iStateId, TMT_COLOR, iPropId)))
56 return E_PROP_ID_UNSUPPORTED;
57 return MSSTYLES_GetPropertyColor(tp, pColor);
58 }
59
60 /***********************************************************************
61 * GetThemeEnumValue (UXTHEME.@)
62 */
GetThemeEnumValue(HTHEME hTheme,int iPartId,int iStateId,int iPropId,int * piVal)63 HRESULT WINAPI GetThemeEnumValue(HTHEME hTheme, int iPartId, int iStateId,
64 int iPropId, int *piVal)
65 {
66 HRESULT hr;
67 WCHAR val[60];
68 PTHEME_PROPERTY tp;
69 PTHEME_CLASS pClass = ValidateHandle(hTheme);
70
71 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
72 if(!pClass)
73 return E_HANDLE;
74
75 if(!(tp = MSSTYLES_FindProperty(pClass, iPartId, iStateId, TMT_ENUM, iPropId)))
76 return E_PROP_ID_UNSUPPORTED;
77
78 hr = MSSTYLES_GetPropertyString(tp, val, sizeof(val)/sizeof(val[0]));
79 if(FAILED(hr))
80 return hr;
81 if(!MSSTYLES_LookupEnum(val, iPropId, piVal))
82 return E_PROP_ID_UNSUPPORTED;
83 return S_OK;
84 }
85
86 /***********************************************************************
87 * GetThemeFilename (UXTHEME.@)
88 */
GetThemeFilename(HTHEME hTheme,int iPartId,int iStateId,int iPropId,LPWSTR pszThemeFilename,int cchMaxBuffChars)89 HRESULT WINAPI GetThemeFilename(HTHEME hTheme, int iPartId, int iStateId,
90 int iPropId, LPWSTR pszThemeFilename,
91 int cchMaxBuffChars)
92 {
93 PTHEME_PROPERTY tp;
94 PTHEME_CLASS pClass = ValidateHandle(hTheme);
95
96 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
97 if(!pClass)
98 return E_HANDLE;
99
100 if(!(tp = MSSTYLES_FindProperty(pClass, iPartId, iStateId, TMT_FILENAME, iPropId)))
101 return E_PROP_ID_UNSUPPORTED;
102 return MSSTYLES_GetPropertyString(tp, pszThemeFilename, cchMaxBuffChars);
103 }
104
105 /***********************************************************************
106 * GetThemeFont (UXTHEME.@)
107 */
GetThemeFont(HTHEME hTheme,HDC hdc,int iPartId,int iStateId,int iPropId,LOGFONTW * pFont)108 HRESULT WINAPI GetThemeFont(HTHEME hTheme, HDC hdc, int iPartId,
109 int iStateId, int iPropId, LOGFONTW *pFont)
110 {
111 PTHEME_PROPERTY tp;
112 PTHEME_CLASS pClass = ValidateHandle(hTheme);
113
114 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
115 if(!pClass)
116 return E_HANDLE;
117
118 if(!(tp = MSSTYLES_FindProperty(pClass, iPartId, iStateId, TMT_FONT, iPropId)))
119 return E_PROP_ID_UNSUPPORTED;
120 return MSSTYLES_GetPropertyFont(tp, hdc, pFont);
121 }
122
123 /***********************************************************************
124 * GetThemeInt (UXTHEME.@)
125 */
GetThemeInt(HTHEME hTheme,int iPartId,int iStateId,int iPropId,int * piVal)126 HRESULT WINAPI GetThemeInt(HTHEME hTheme, int iPartId, int iStateId,
127 int iPropId, int *piVal)
128 {
129 PTHEME_PROPERTY tp;
130 PTHEME_CLASS pClass = ValidateHandle(hTheme);
131
132 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
133 if(!pClass)
134 return E_HANDLE;
135
136 if(!(tp = MSSTYLES_FindProperty(pClass, iPartId, iStateId, TMT_INT, iPropId)))
137 return E_PROP_ID_UNSUPPORTED;
138 return MSSTYLES_GetPropertyInt(tp, piVal);
139 }
140
141 /***********************************************************************
142 * GetThemeIntList (UXTHEME.@)
143 */
GetThemeIntList(HTHEME hTheme,int iPartId,int iStateId,int iPropId,INTLIST * pIntList)144 HRESULT WINAPI GetThemeIntList(HTHEME hTheme, int iPartId, int iStateId,
145 int iPropId, INTLIST *pIntList)
146 {
147 PTHEME_PROPERTY tp;
148 PTHEME_CLASS pClass = ValidateHandle(hTheme);
149
150 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
151 if(!pClass)
152 return E_HANDLE;
153
154 if(!(tp = MSSTYLES_FindProperty(pClass, iPartId, iStateId, TMT_INTLIST, iPropId)))
155 return E_PROP_ID_UNSUPPORTED;
156 return MSSTYLES_GetPropertyIntList(tp, pIntList);
157 }
158
159 /***********************************************************************
160 * GetThemePosition (UXTHEME.@)
161 */
GetThemePosition(HTHEME hTheme,int iPartId,int iStateId,int iPropId,POINT * pPoint)162 HRESULT WINAPI GetThemePosition(HTHEME hTheme, int iPartId, int iStateId,
163 int iPropId, POINT *pPoint)
164 {
165 PTHEME_PROPERTY tp;
166 PTHEME_CLASS pClass = ValidateHandle(hTheme);
167
168 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
169 if(!pClass)
170 return E_HANDLE;
171
172 if(!(tp = MSSTYLES_FindProperty(pClass, iPartId, iStateId, TMT_POSITION, iPropId)))
173 return E_PROP_ID_UNSUPPORTED;
174 return MSSTYLES_GetPropertyPosition(tp, pPoint);
175 }
176
177 /***********************************************************************
178 * GetThemeRect (UXTHEME.@)
179 */
GetThemeRect(HTHEME hTheme,int iPartId,int iStateId,int iPropId,RECT * pRect)180 HRESULT WINAPI GetThemeRect(HTHEME hTheme, int iPartId, int iStateId,
181 int iPropId, RECT *pRect)
182 {
183 PTHEME_PROPERTY tp;
184 PTHEME_CLASS pClass = ValidateHandle(hTheme);
185
186 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
187 if(!pClass)
188 return E_HANDLE;
189
190 if(!(tp = MSSTYLES_FindProperty(pClass, iPartId, iStateId, TMT_RECT, iPropId)))
191 return E_PROP_ID_UNSUPPORTED;
192 return MSSTYLES_GetPropertyRect(tp, pRect);
193 }
194
195 /***********************************************************************
196 * GetThemeString (UXTHEME.@)
197 */
GetThemeString(HTHEME hTheme,int iPartId,int iStateId,int iPropId,LPWSTR pszBuff,int cchMaxBuffChars)198 HRESULT WINAPI GetThemeString(HTHEME hTheme, int iPartId, int iStateId,
199 int iPropId, LPWSTR pszBuff, int cchMaxBuffChars)
200 {
201 PTHEME_PROPERTY tp;
202 PTHEME_CLASS pClass = ValidateHandle(hTheme);
203
204 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
205 if(!pClass)
206 return E_HANDLE;
207
208 if(!(tp = MSSTYLES_FindProperty(pClass, iPartId, iStateId, TMT_STRING, iPropId)))
209 return E_PROP_ID_UNSUPPORTED;
210 return MSSTYLES_GetPropertyString(tp, pszBuff, cchMaxBuffChars);
211 }
212
213 /***********************************************************************
214 * GetThemeMargins (UXTHEME.@)
215 */
GetThemeMargins(HTHEME hTheme,HDC hdc,int iPartId,int iStateId,int iPropId,RECT * prc,MARGINS * pMargins)216 HRESULT WINAPI GetThemeMargins(HTHEME hTheme, HDC hdc, int iPartId,
217 int iStateId, int iPropId, RECT *prc,
218 MARGINS *pMargins)
219 {
220 PTHEME_PROPERTY tp;
221 PTHEME_CLASS pClass = ValidateHandle(hTheme);
222
223 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
224 memset (pMargins, 0, sizeof (MARGINS));
225 if(!pClass)
226 return E_HANDLE;
227
228 if(!(tp = MSSTYLES_FindProperty(pClass, iPartId, iStateId, TMT_MARGINS, iPropId)))
229 return E_PROP_ID_UNSUPPORTED;
230 return MSSTYLES_GetPropertyMargins(tp, prc, pMargins);
231 }
232
233 /***********************************************************************
234 * GetThemeMetric (UXTHEME.@)
235 */
GetThemeMetric(HTHEME hTheme,HDC hdc,int iPartId,int iStateId,int iPropId,int * piVal)236 HRESULT WINAPI GetThemeMetric(HTHEME hTheme, HDC hdc, int iPartId,
237 int iStateId, int iPropId, int *piVal)
238 {
239 PTHEME_PROPERTY tp;
240 WCHAR val[60];
241 HRESULT hr;
242 PTHEME_CLASS pClass = ValidateHandle(hTheme);
243
244 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
245 if(!pClass)
246 return E_HANDLE;
247
248 if(!(tp = MSSTYLES_FindProperty(pClass, iPartId, iStateId, 0, iPropId)))
249 return E_PROP_ID_UNSUPPORTED;
250
251 switch(tp->iPrimitiveType) {
252 case TMT_POSITION: /* Only the X coord is retrieved */
253 case TMT_MARGINS: /* Only the cxLeftWidth member is retrieved */
254 case TMT_INTLIST: /* Only the first int is retrieved */
255 case TMT_SIZE:
256 case TMT_INT:
257 return MSSTYLES_GetPropertyInt(tp, piVal);
258 case TMT_BOOL:
259 return MSSTYLES_GetPropertyBool(tp, piVal);
260 case TMT_COLOR:
261 return MSSTYLES_GetPropertyColor(tp, (COLORREF*)piVal);
262 case TMT_ENUM:
263 hr = MSSTYLES_GetPropertyString(tp, val, sizeof(val)/sizeof(val[0]));
264 if(FAILED(hr))
265 return hr;
266 if(!MSSTYLES_LookupEnum(val, iPropId, piVal))
267 return E_PROP_ID_UNSUPPORTED;
268 return S_OK;
269 case TMT_FILENAME:
270 /* Windows does return a value for this, but its value doesn't make sense */
271 FIXME("Filename\n");
272 break;
273 }
274 return E_PROP_ID_UNSUPPORTED;
275 }
276
277 /***********************************************************************
278 * GetThemePropertyOrigin (UXTHEME.@)
279 */
GetThemePropertyOrigin(HTHEME hTheme,int iPartId,int iStateId,int iPropId,PROPERTYORIGIN * pOrigin)280 HRESULT WINAPI GetThemePropertyOrigin(HTHEME hTheme, int iPartId, int iStateId,
281 int iPropId, PROPERTYORIGIN *pOrigin)
282 {
283 PTHEME_PROPERTY tp;
284 PTHEME_CLASS pClass = ValidateHandle(hTheme);
285
286 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
287 if(!pClass)
288 return E_HANDLE;
289
290 if(!(tp = MSSTYLES_FindProperty(pClass, iPartId, iStateId, 0, iPropId))) {
291 *pOrigin = PO_NOTFOUND;
292 return S_OK;
293 }
294 *pOrigin = tp->origin;
295 return S_OK;
296 }
297