ReactOS 0.4.16-dev-106-g10b08aa
property.c
Go to the documentation of this file.
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 */
26HRESULT WINAPI GetThemeBool(HTHEME hTheme, int iPartId, int iStateId,
27 int iPropId, BOOL *pfVal)
28{
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)))
39 return MSSTYLES_GetPropertyBool(tp, pfVal);
40}
41
42/***********************************************************************
43 * GetThemeColor (UXTHEME.@)
44 */
45HRESULT WINAPI GetThemeColor(HTHEME hTheme, int iPartId, int iStateId,
46 int iPropId, COLORREF *pColor)
47{
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)))
57 return MSSTYLES_GetPropertyColor(tp, pColor);
58}
59
60/***********************************************************************
61 * GetThemeEnumValue (UXTHEME.@)
62 */
63HRESULT WINAPI GetThemeEnumValue(HTHEME hTheme, int iPartId, int iStateId,
64 int iPropId, int *piVal)
65{
66 HRESULT hr;
67 WCHAR val[60];
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)))
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))
83 return S_OK;
84}
85
86/***********************************************************************
87 * GetThemeFilename (UXTHEME.@)
88 */
89HRESULT WINAPI GetThemeFilename(HTHEME hTheme, int iPartId, int iStateId,
90 int iPropId, LPWSTR pszThemeFilename,
91 int cchMaxBuffChars)
92{
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)))
102 return MSSTYLES_GetPropertyString(tp, pszThemeFilename, cchMaxBuffChars);
103}
104
105/***********************************************************************
106 * GetThemeFont (UXTHEME.@)
107 */
109 int iStateId, int iPropId, LOGFONTW *pFont)
110{
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)))
120 return MSSTYLES_GetPropertyFont(tp, hdc, pFont);
121}
122
123/***********************************************************************
124 * GetThemeInt (UXTHEME.@)
125 */
126HRESULT WINAPI GetThemeInt(HTHEME hTheme, int iPartId, int iStateId,
127 int iPropId, int *piVal)
128{
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)))
138 return MSSTYLES_GetPropertyInt(tp, piVal);
139}
140
141/***********************************************************************
142 * GetThemeIntList (UXTHEME.@)
143 */
144HRESULT WINAPI GetThemeIntList(HTHEME hTheme, int iPartId, int iStateId,
145 int iPropId, INTLIST *pIntList)
146{
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)))
156 return MSSTYLES_GetPropertyIntList(tp, pIntList);
157}
158
159/***********************************************************************
160 * GetThemePosition (UXTHEME.@)
161 */
162HRESULT WINAPI GetThemePosition(HTHEME hTheme, int iPartId, int iStateId,
163 int iPropId, POINT *pPoint)
164{
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)))
174 return MSSTYLES_GetPropertyPosition(tp, pPoint);
175}
176
177/***********************************************************************
178 * GetThemeRect (UXTHEME.@)
179 */
180HRESULT WINAPI GetThemeRect(HTHEME hTheme, int iPartId, int iStateId,
181 int iPropId, RECT *pRect)
182{
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)))
192 return MSSTYLES_GetPropertyRect(tp, pRect);
193}
194
195/***********************************************************************
196 * GetThemeString (UXTHEME.@)
197 */
198HRESULT WINAPI GetThemeString(HTHEME hTheme, int iPartId, int iStateId,
199 int iPropId, LPWSTR pszBuff, int cchMaxBuffChars)
200{
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)))
210 return MSSTYLES_GetPropertyString(tp, pszBuff, cchMaxBuffChars);
211}
212
213/***********************************************************************
214 * GetThemeMargins (UXTHEME.@)
215 */
217 int iStateId, int iPropId, RECT *prc,
218 MARGINS *pMargins)
219{
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)))
230 return MSSTYLES_GetPropertyMargins(tp, prc, pMargins);
231}
232
233/***********************************************************************
234 * GetThemeMetric (UXTHEME.@)
235 */
237 int iStateId, int iPropId, int *piVal)
238{
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)))
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))
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 }
275}
276
277/***********************************************************************
278 * GetThemePropertyOrigin (UXTHEME.@)
279 */
280HRESULT WINAPI GetThemePropertyOrigin(HTHEME hTheme, int iPartId, int iStateId,
281 int iPropId, PROPERTYORIGIN *pOrigin)
282{
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}
#define FIXME(fmt,...)
Definition: precomp.h:53
LPVOID FASTCALL ValidateHandle(HANDLE hObject, UINT uType)
Definition: utils.c:377
HRESULT WINAPI GetThemeMetric(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, int iPropId, int *piVal)
Definition: property.c:236
HRESULT WINAPI GetThemePosition(HTHEME hTheme, int iPartId, int iStateId, int iPropId, POINT *pPoint)
Definition: property.c:162
HRESULT WINAPI GetThemeIntList(HTHEME hTheme, int iPartId, int iStateId, int iPropId, INTLIST *pIntList)
Definition: property.c:144
HRESULT WINAPI GetThemeRect(HTHEME hTheme, int iPartId, int iStateId, int iPropId, RECT *pRect)
Definition: property.c:180
HRESULT WINAPI GetThemeBool(HTHEME hTheme, int iPartId, int iStateId, int iPropId, BOOL *pfVal)
Definition: property.c:26
HRESULT WINAPI GetThemeFont(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, int iPropId, LOGFONTW *pFont)
Definition: property.c:108
HRESULT WINAPI GetThemeInt(HTHEME hTheme, int iPartId, int iStateId, int iPropId, int *piVal)
Definition: property.c:126
HRESULT WINAPI GetThemePropertyOrigin(HTHEME hTheme, int iPartId, int iStateId, int iPropId, PROPERTYORIGIN *pOrigin)
Definition: property.c:280
HRESULT WINAPI GetThemeMargins(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, int iPropId, RECT *prc, MARGINS *pMargins)
Definition: property.c:216
HRESULT WINAPI GetThemeEnumValue(HTHEME hTheme, int iPartId, int iStateId, int iPropId, int *piVal)
Definition: property.c:63
HRESULT WINAPI GetThemeFilename(HTHEME hTheme, int iPartId, int iStateId, int iPropId, LPWSTR pszThemeFilename, int cchMaxBuffChars)
Definition: property.c:89
HRESULT WINAPI GetThemeString(HTHEME hTheme, int iPartId, int iStateId, int iPropId, LPWSTR pszBuff, int cchMaxBuffChars)
Definition: property.c:198
HRESULT WINAPI GetThemeColor(HTHEME hTheme, int iPartId, int iStateId, int iPropId, COLORREF *pColor)
Definition: property.c:45
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2996
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint GLfloat * val
Definition: glext.h:7180
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
PTHEME_PROPERTY MSSTYLES_FindProperty(PTHEME_CLASS tc, int iPartId, int iStateId, int iPropertyPrimitive, int iPropertyId)
Definition: msstyles.c:835
HRESULT MSSTYLES_GetPropertyFont(PTHEME_PROPERTY tp, HDC hdc, LOGFONTW *pFont)
Definition: msstyles.c:1077
HRESULT MSSTYLES_GetPropertyBool(PTHEME_PROPERTY tp, BOOL *pfVal)
Definition: msstyles.c:994
HRESULT MSSTYLES_GetPropertyString(PTHEME_PROPERTY tp, LPWSTR pszBuff, int cchMaxBuffChars)
Definition: msstyles.c:1151
HRESULT MSSTYLES_GetPropertyMargins(PTHEME_PROPERTY tp, RECT *prc, MARGINS *pMargins)
Definition: msstyles.c:1182
HRESULT MSSTYLES_GetPropertyColor(PTHEME_PROPERTY tp, COLORREF *pColor)
Definition: msstyles.c:1007
HRESULT MSSTYLES_GetPropertyIntList(PTHEME_PROPERTY tp, INTLIST *pIntList)
Definition: msstyles.c:1108
HRESULT MSSTYLES_GetPropertyRect(PTHEME_PROPERTY tp, RECT *pRect)
Definition: msstyles.c:1162
HRESULT MSSTYLES_GetPropertyPosition(PTHEME_PROPERTY tp, POINT *pPoint)
Definition: msstyles.c:1127
HRESULT MSSTYLES_GetPropertyInt(PTHEME_PROPERTY tp, int *piVal)
Definition: msstyles.c:1094
_Out_ LPRECT prc
Definition: ntgdi.h:1658
#define memset(x, y, z)
Definition: compat.h:39
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
Definition: misc.c:279
BOOL MSSTYLES_LookupEnum(LPCWSTR pszValueName, int dwEnum, int *dwValue)
Definition: stylemap.c:1126
#define TMT_ENUM
Definition: uxthemep.h:32
#define E_PROP_ID_UNSUPPORTED
Definition: vfwmsgs.h:173
#define TMT_STRING
Definition: vssym32.h:135
#define TMT_INT
Definition: vssym32.h:136
#define TMT_COLOR
Definition: vssym32.h:138
#define TMT_MARGINS
Definition: vssym32.h:139
#define TMT_POSITION
Definition: vssym32.h:142
#define TMT_INTLIST
Definition: vssym32.h:145
#define TMT_FONT
Definition: vssym32.h:144
#define TMT_FILENAME
Definition: vssym32.h:140
#define TMT_BOOL
Definition: vssym32.h:137
#define TMT_RECT
Definition: vssym32.h:143
#define TMT_SIZE
Definition: vssym32.h:141
DWORD COLORREF
Definition: windef.h:300
#define WINAPI
Definition: msvc.h:6
#define E_HANDLE
Definition: winerror.h:2850
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184