dmime: Remove DECLSPEC_HIDDEN usage.
[wine.git] / dlls / uxtheme / property.c
blob188f13836e2120be0232da998245c7f80e376f76
1 /*
2 * Win32 5.1 Theme properties
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
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "wingdi.h"
27 #include "vfwmsgs.h"
28 #include "uxtheme.h"
29 #include "vssym32.h"
31 #include "msstyles.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(uxtheme);
37 /***********************************************************************
38 * GetThemeBool (UXTHEME.@)
40 HRESULT WINAPI GetThemeBool(HTHEME hTheme, int iPartId, int iStateId,
41 int iPropId, BOOL *pfVal)
43 PTHEME_PROPERTY tp;
45 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
46 if(!hTheme)
47 return E_HANDLE;
49 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_BOOL, iPropId)))
50 return E_PROP_ID_UNSUPPORTED;
51 return MSSTYLES_GetPropertyBool(tp, pfVal);
54 /***********************************************************************
55 * GetThemeColor (UXTHEME.@)
57 HRESULT WINAPI GetThemeColor(HTHEME hTheme, int iPartId, int iStateId,
58 int iPropId, COLORREF *pColor)
60 PTHEME_PROPERTY tp;
62 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
63 if(!hTheme)
64 return E_HANDLE;
66 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_COLOR, iPropId)))
67 return E_PROP_ID_UNSUPPORTED;
68 return MSSTYLES_GetPropertyColor(tp, pColor);
71 /***********************************************************************
72 * GetThemeEnumValue (UXTHEME.@)
74 HRESULT WINAPI GetThemeEnumValue(HTHEME hTheme, int iPartId, int iStateId,
75 int iPropId, int *piVal)
77 HRESULT hr;
78 WCHAR val[60];
79 PTHEME_PROPERTY tp;
81 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
82 if(!hTheme)
83 return E_HANDLE;
85 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_ENUM, iPropId)))
86 return E_PROP_ID_UNSUPPORTED;
88 hr = MSSTYLES_GetPropertyString(tp, val, ARRAY_SIZE(val));
89 if(FAILED(hr))
90 return hr;
91 if(!MSSTYLES_LookupEnum(val, iPropId, piVal))
92 return E_PROP_ID_UNSUPPORTED;
93 return S_OK;
96 /***********************************************************************
97 * GetThemeFilename (UXTHEME.@)
99 HRESULT WINAPI GetThemeFilename(HTHEME hTheme, int iPartId, int iStateId,
100 int iPropId, LPWSTR pszThemeFilename,
101 int cchMaxBuffChars)
103 PTHEME_PROPERTY tp;
105 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
106 if(!hTheme)
107 return E_HANDLE;
109 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_FILENAME, iPropId)))
110 return E_PROP_ID_UNSUPPORTED;
111 return MSSTYLES_GetPropertyString(tp, pszThemeFilename, cchMaxBuffChars);
114 /***********************************************************************
115 * GetThemeFont (UXTHEME.@)
117 HRESULT WINAPI GetThemeFont(HTHEME hTheme, HDC hdc, int iPartId,
118 int iStateId, int iPropId, LOGFONTW *pFont)
120 PTHEME_PROPERTY tp;
122 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
123 if(!hTheme)
124 return E_HANDLE;
126 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_FONT, iPropId)))
127 return E_PROP_ID_UNSUPPORTED;
128 return MSSTYLES_GetPropertyFont(tp, hdc, pFont);
131 /***********************************************************************
132 * GetThemeInt (UXTHEME.@)
134 HRESULT WINAPI GetThemeInt(HTHEME hTheme, int iPartId, int iStateId,
135 int iPropId, int *piVal)
137 PTHEME_PROPERTY tp;
139 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
140 if(!hTheme)
141 return E_HANDLE;
143 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_INT, iPropId)))
144 return E_PROP_ID_UNSUPPORTED;
145 return MSSTYLES_GetPropertyInt(tp, piVal);
148 /***********************************************************************
149 * GetThemeIntList (UXTHEME.@)
151 HRESULT WINAPI GetThemeIntList(HTHEME hTheme, int iPartId, int iStateId,
152 int iPropId, INTLIST *pIntList)
154 PTHEME_PROPERTY tp;
156 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
157 if(!hTheme)
158 return E_HANDLE;
160 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_INTLIST, iPropId)))
161 return E_PROP_ID_UNSUPPORTED;
162 return MSSTYLES_GetPropertyIntList(tp, pIntList);
165 /***********************************************************************
166 * GetThemePosition (UXTHEME.@)
168 HRESULT WINAPI GetThemePosition(HTHEME hTheme, int iPartId, int iStateId,
169 int iPropId, POINT *pPoint)
171 PTHEME_PROPERTY tp;
173 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
174 if(!hTheme)
175 return E_HANDLE;
177 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_POSITION, iPropId)))
178 return E_PROP_ID_UNSUPPORTED;
179 return MSSTYLES_GetPropertyPosition(tp, pPoint);
182 /***********************************************************************
183 * GetThemeRect (UXTHEME.@)
185 HRESULT WINAPI GetThemeRect(HTHEME hTheme, int iPartId, int iStateId,
186 int iPropId, RECT *pRect)
188 PTHEME_PROPERTY tp;
190 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
191 if(!hTheme)
192 return E_HANDLE;
194 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_RECT, iPropId)))
195 return E_PROP_ID_UNSUPPORTED;
196 return MSSTYLES_GetPropertyRect(tp, pRect);
199 /***********************************************************************
200 * GetThemeString (UXTHEME.@)
202 HRESULT WINAPI GetThemeString(HTHEME hTheme, int iPartId, int iStateId,
203 int iPropId, LPWSTR pszBuff, int cchMaxBuffChars)
205 PTHEME_PROPERTY tp;
207 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
208 if(!hTheme)
209 return E_HANDLE;
211 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_STRING, iPropId)))
212 return E_PROP_ID_UNSUPPORTED;
213 return MSSTYLES_GetPropertyString(tp, pszBuff, cchMaxBuffChars);
216 /***********************************************************************
217 * GetThemeMargins (UXTHEME.@)
219 HRESULT WINAPI GetThemeMargins(HTHEME hTheme, HDC hdc, int iPartId,
220 int iStateId, int iPropId, RECT *prc,
221 MARGINS *pMargins)
223 PTHEME_PROPERTY tp;
225 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
226 memset (pMargins, 0, sizeof (MARGINS));
227 if(!hTheme)
228 return E_HANDLE;
230 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_MARGINS, iPropId)))
231 return E_PROP_ID_UNSUPPORTED;
232 return MSSTYLES_GetPropertyMargins(tp, prc, pMargins);
235 /***********************************************************************
236 * GetThemeMetric (UXTHEME.@)
238 HRESULT WINAPI GetThemeMetric(HTHEME hTheme, HDC hdc, int iPartId,
239 int iStateId, int iPropId, int *piVal)
241 PTHEME_PROPERTY tp;
242 WCHAR val[60];
243 HRESULT hr;
245 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
246 if(!hTheme)
247 return E_HANDLE;
249 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, 0, iPropId)))
250 return E_PROP_ID_UNSUPPORTED;
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, ARRAY_SIZE(val));
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;
274 return E_PROP_ID_UNSUPPORTED;
277 /***********************************************************************
278 * GetThemePropertyOrigin (UXTHEME.@)
280 HRESULT WINAPI GetThemePropertyOrigin(HTHEME hTheme, int iPartId, int iStateId,
281 int iPropId, PROPERTYORIGIN *pOrigin)
283 PTHEME_PROPERTY tp;
285 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
286 if(!hTheme)
287 return E_HANDLE;
289 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, 0, iPropId))) {
290 *pOrigin = PO_NOTFOUND;
291 return S_OK;
293 *pOrigin = tp->origin;
294 return S_OK;