msvcrt: Add _atoldbl.
[wine/wine-kai.git] / dlls / uxtheme / property.c
blob7e52e6fbcb6431b7d058632609320d4ea43a4693
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 "config.h"
23 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "wingdi.h"
29 #include "vfwmsgs.h"
30 #include "uxtheme.h"
31 #include "tmschema.h"
33 #include "msstyles.h"
34 #include "uxthemedll.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(uxtheme);
40 /***********************************************************************
41 * GetThemeBool (UXTHEME.@)
43 HRESULT WINAPI GetThemeBool(HTHEME hTheme, int iPartId, int iStateId,
44 int iPropId, BOOL *pfVal)
46 PTHEME_PROPERTY tp;
48 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
49 if(!hTheme)
50 return E_HANDLE;
52 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_BOOL, iPropId)))
53 return E_PROP_ID_UNSUPPORTED;
54 return MSSTYLES_GetPropertyBool(tp, pfVal);
57 /***********************************************************************
58 * GetThemeColor (UXTHEME.@)
60 HRESULT WINAPI GetThemeColor(HTHEME hTheme, int iPartId, int iStateId,
61 int iPropId, COLORREF *pColor)
63 PTHEME_PROPERTY tp;
65 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
66 if(!hTheme)
67 return E_HANDLE;
69 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_COLOR, iPropId)))
70 return E_PROP_ID_UNSUPPORTED;
71 return MSSTYLES_GetPropertyColor(tp, pColor);
74 /***********************************************************************
75 * GetThemeEnumValue (UXTHEME.@)
77 HRESULT WINAPI GetThemeEnumValue(HTHEME hTheme, int iPartId, int iStateId,
78 int iPropId, int *piVal)
80 HRESULT hr;
81 WCHAR val[60];
82 PTHEME_PROPERTY tp;
84 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
85 if(!hTheme)
86 return E_HANDLE;
88 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_ENUM, iPropId)))
89 return E_PROP_ID_UNSUPPORTED;
91 hr = MSSTYLES_GetPropertyString(tp, val, sizeof(val)/sizeof(val[0]));
92 if(FAILED(hr))
93 return hr;
94 if(!MSSTYLES_LookupEnum(val, iPropId, piVal))
95 return E_PROP_ID_UNSUPPORTED;
96 return S_OK;
99 /***********************************************************************
100 * GetThemeFilename (UXTHEME.@)
102 HRESULT WINAPI GetThemeFilename(HTHEME hTheme, int iPartId, int iStateId,
103 int iPropId, LPWSTR pszThemeFilename,
104 int cchMaxBuffChars)
106 PTHEME_PROPERTY tp;
108 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
109 if(!hTheme)
110 return E_HANDLE;
112 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_FILENAME, iPropId)))
113 return E_PROP_ID_UNSUPPORTED;
114 return MSSTYLES_GetPropertyString(tp, pszThemeFilename, cchMaxBuffChars);
117 /***********************************************************************
118 * GetThemeFont (UXTHEME.@)
120 HRESULT WINAPI GetThemeFont(HTHEME hTheme, HDC hdc, int iPartId,
121 int iStateId, int iPropId, LOGFONTW *pFont)
123 PTHEME_PROPERTY tp;
125 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
126 if(!hTheme)
127 return E_HANDLE;
129 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_FONT, iPropId)))
130 return E_PROP_ID_UNSUPPORTED;
131 return MSSTYLES_GetPropertyFont(tp, hdc, pFont);
134 /***********************************************************************
135 * GetThemeInt (UXTHEME.@)
137 HRESULT WINAPI GetThemeInt(HTHEME hTheme, int iPartId, int iStateId,
138 int iPropId, int *piVal)
140 PTHEME_PROPERTY tp;
142 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
143 if(!hTheme)
144 return E_HANDLE;
146 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_INT, iPropId)))
147 return E_PROP_ID_UNSUPPORTED;
148 return MSSTYLES_GetPropertyInt(tp, piVal);
151 /***********************************************************************
152 * GetThemeIntList (UXTHEME.@)
154 HRESULT WINAPI GetThemeIntList(HTHEME hTheme, int iPartId, int iStateId,
155 int iPropId, INTLIST *pIntList)
157 PTHEME_PROPERTY tp;
159 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
160 if(!hTheme)
161 return E_HANDLE;
163 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_INTLIST, iPropId)))
164 return E_PROP_ID_UNSUPPORTED;
165 return MSSTYLES_GetPropertyIntList(tp, pIntList);
168 /***********************************************************************
169 * GetThemePosition (UXTHEME.@)
171 HRESULT WINAPI GetThemePosition(HTHEME hTheme, int iPartId, int iStateId,
172 int iPropId, POINT *pPoint)
174 PTHEME_PROPERTY tp;
176 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
177 if(!hTheme)
178 return E_HANDLE;
180 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_POSITION, iPropId)))
181 return E_PROP_ID_UNSUPPORTED;
182 return MSSTYLES_GetPropertyPosition(tp, pPoint);
185 /***********************************************************************
186 * GetThemeRect (UXTHEME.@)
188 HRESULT WINAPI GetThemeRect(HTHEME hTheme, int iPartId, int iStateId,
189 int iPropId, RECT *pRect)
191 PTHEME_PROPERTY tp;
193 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
194 if(!hTheme)
195 return E_HANDLE;
197 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_RECT, iPropId)))
198 return E_PROP_ID_UNSUPPORTED;
199 return MSSTYLES_GetPropertyRect(tp, pRect);
202 /***********************************************************************
203 * GetThemeString (UXTHEME.@)
205 HRESULT WINAPI GetThemeString(HTHEME hTheme, int iPartId, int iStateId,
206 int iPropId, LPWSTR pszBuff, int cchMaxBuffChars)
208 PTHEME_PROPERTY tp;
210 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
211 if(!hTheme)
212 return E_HANDLE;
214 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_FILENAME, iPropId)))
215 return E_PROP_ID_UNSUPPORTED;
216 return MSSTYLES_GetPropertyString(tp, pszBuff, cchMaxBuffChars);
219 /***********************************************************************
220 * GetThemeMargins (UXTHEME.@)
222 HRESULT WINAPI GetThemeMargins(HTHEME hTheme, HDC hdc, int iPartId,
223 int iStateId, int iPropId, RECT *prc,
224 MARGINS *pMargins)
226 PTHEME_PROPERTY tp;
228 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
229 memset (pMargins, 0, sizeof (MARGINS));
230 if(!hTheme)
231 return E_HANDLE;
233 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_MARGINS, iPropId)))
234 return E_PROP_ID_UNSUPPORTED;
235 return MSSTYLES_GetPropertyMargins(tp, prc, pMargins);
238 /***********************************************************************
239 * GetThemeMetric (UXTHEME.@)
241 HRESULT WINAPI GetThemeMetric(HTHEME hTheme, HDC hdc, int iPartId,
242 int iStateId, int iPropId, int *piVal)
244 PTHEME_PROPERTY tp;
245 WCHAR val[60];
246 HRESULT hr;
248 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
249 if(!hTheme)
250 return E_HANDLE;
252 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, 0, iPropId)))
253 return E_PROP_ID_UNSUPPORTED;
254 switch(tp->iPrimitiveType) {
255 case TMT_POSITION: /* Only the X coord is retrieved */
256 case TMT_MARGINS: /* Only the cxLeftWidth member is retrieved */
257 case TMT_INTLIST: /* Only the first int is retrieved */
258 case TMT_SIZE:
259 case TMT_INT:
260 return MSSTYLES_GetPropertyInt(tp, piVal);
261 case TMT_BOOL:
262 return MSSTYLES_GetPropertyBool(tp, piVal);
263 case TMT_COLOR:
264 return MSSTYLES_GetPropertyColor(tp, (COLORREF*)piVal);
265 case TMT_ENUM:
266 hr = MSSTYLES_GetPropertyString(tp, val, sizeof(val)/sizeof(val[0]));
267 if(FAILED(hr))
268 return hr;
269 if(!MSSTYLES_LookupEnum(val, iPropId, piVal))
270 return E_PROP_ID_UNSUPPORTED;
271 return S_OK;
272 case TMT_FILENAME:
273 /* Windows does return a value for this, but its value doesn't make sense */
274 FIXME("Filename\n");
275 break;
277 return E_PROP_ID_UNSUPPORTED;
280 /***********************************************************************
281 * GetThemePropertyOrigin (UXTHEME.@)
283 HRESULT WINAPI GetThemePropertyOrigin(HTHEME hTheme, int iPartId, int iStateId,
284 int iPropId, PROPERTYORIGIN *pOrigin)
286 PTHEME_PROPERTY tp;
288 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
289 if(!hTheme)
290 return E_HANDLE;
292 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, 0, iPropId))) {
293 *pOrigin = PO_NOTFOUND;
294 return S_OK;
296 *pOrigin = tp->origin;
297 return S_OK;