winecfg: Update Portuguese translation.
[wine/testsucceed.git] / dlls / uxtheme / property.c
blob146649e85f620220e205d549f03f6d860d4bb3e0
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"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(uxtheme);
39 /***********************************************************************
40 * GetThemeBool (UXTHEME.@)
42 HRESULT WINAPI GetThemeBool(HTHEME hTheme, int iPartId, int iStateId,
43 int iPropId, BOOL *pfVal)
45 PTHEME_PROPERTY tp;
47 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
48 if(!hTheme)
49 return E_HANDLE;
51 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_BOOL, iPropId)))
52 return E_PROP_ID_UNSUPPORTED;
53 return MSSTYLES_GetPropertyBool(tp, pfVal);
56 /***********************************************************************
57 * GetThemeColor (UXTHEME.@)
59 HRESULT WINAPI GetThemeColor(HTHEME hTheme, int iPartId, int iStateId,
60 int iPropId, COLORREF *pColor)
62 PTHEME_PROPERTY tp;
64 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
65 if(!hTheme)
66 return E_HANDLE;
68 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_COLOR, iPropId)))
69 return E_PROP_ID_UNSUPPORTED;
70 return MSSTYLES_GetPropertyColor(tp, pColor);
73 /***********************************************************************
74 * GetThemeEnumValue (UXTHEME.@)
76 HRESULT WINAPI GetThemeEnumValue(HTHEME hTheme, int iPartId, int iStateId,
77 int iPropId, int *piVal)
79 HRESULT hr;
80 WCHAR val[60];
81 PTHEME_PROPERTY tp;
83 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
84 if(!hTheme)
85 return E_HANDLE;
87 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_ENUM, iPropId)))
88 return E_PROP_ID_UNSUPPORTED;
90 hr = MSSTYLES_GetPropertyString(tp, val, sizeof(val)/sizeof(val[0]));
91 if(FAILED(hr))
92 return hr;
93 if(!MSSTYLES_LookupEnum(val, iPropId, piVal))
94 return E_PROP_ID_UNSUPPORTED;
95 return S_OK;
98 /***********************************************************************
99 * GetThemeFilename (UXTHEME.@)
101 HRESULT WINAPI GetThemeFilename(HTHEME hTheme, int iPartId, int iStateId,
102 int iPropId, LPWSTR pszThemeFilename,
103 int cchMaxBuffChars)
105 PTHEME_PROPERTY tp;
107 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
108 if(!hTheme)
109 return E_HANDLE;
111 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_FILENAME, iPropId)))
112 return E_PROP_ID_UNSUPPORTED;
113 return MSSTYLES_GetPropertyString(tp, pszThemeFilename, cchMaxBuffChars);
116 /***********************************************************************
117 * GetThemeFont (UXTHEME.@)
119 HRESULT WINAPI GetThemeFont(HTHEME hTheme, HDC hdc, int iPartId,
120 int iStateId, int iPropId, LOGFONTW *pFont)
122 PTHEME_PROPERTY tp;
124 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
125 if(!hTheme)
126 return E_HANDLE;
128 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_FONT, iPropId)))
129 return E_PROP_ID_UNSUPPORTED;
130 return MSSTYLES_GetPropertyFont(tp, hdc, pFont);
133 /***********************************************************************
134 * GetThemeInt (UXTHEME.@)
136 HRESULT WINAPI GetThemeInt(HTHEME hTheme, int iPartId, int iStateId,
137 int iPropId, int *piVal)
139 PTHEME_PROPERTY tp;
141 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
142 if(!hTheme)
143 return E_HANDLE;
145 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_INT, iPropId)))
146 return E_PROP_ID_UNSUPPORTED;
147 return MSSTYLES_GetPropertyInt(tp, piVal);
150 /***********************************************************************
151 * GetThemeIntList (UXTHEME.@)
153 HRESULT WINAPI GetThemeIntList(HTHEME hTheme, int iPartId, int iStateId,
154 int iPropId, INTLIST *pIntList)
156 PTHEME_PROPERTY tp;
158 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
159 if(!hTheme)
160 return E_HANDLE;
162 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_INTLIST, iPropId)))
163 return E_PROP_ID_UNSUPPORTED;
164 return MSSTYLES_GetPropertyIntList(tp, pIntList);
167 /***********************************************************************
168 * GetThemePosition (UXTHEME.@)
170 HRESULT WINAPI GetThemePosition(HTHEME hTheme, int iPartId, int iStateId,
171 int iPropId, POINT *pPoint)
173 PTHEME_PROPERTY tp;
175 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
176 if(!hTheme)
177 return E_HANDLE;
179 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_POSITION, iPropId)))
180 return E_PROP_ID_UNSUPPORTED;
181 return MSSTYLES_GetPropertyPosition(tp, pPoint);
184 /***********************************************************************
185 * GetThemeRect (UXTHEME.@)
187 HRESULT WINAPI GetThemeRect(HTHEME hTheme, int iPartId, int iStateId,
188 int iPropId, RECT *pRect)
190 PTHEME_PROPERTY tp;
192 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
193 if(!hTheme)
194 return E_HANDLE;
196 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_RECT, iPropId)))
197 return E_PROP_ID_UNSUPPORTED;
198 return MSSTYLES_GetPropertyRect(tp, pRect);
201 /***********************************************************************
202 * GetThemeString (UXTHEME.@)
204 HRESULT WINAPI GetThemeString(HTHEME hTheme, int iPartId, int iStateId,
205 int iPropId, LPWSTR pszBuff, int cchMaxBuffChars)
207 PTHEME_PROPERTY tp;
209 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
210 if(!hTheme)
211 return E_HANDLE;
213 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_FILENAME, iPropId)))
214 return E_PROP_ID_UNSUPPORTED;
215 return MSSTYLES_GetPropertyString(tp, pszBuff, cchMaxBuffChars);
218 /***********************************************************************
219 * GetThemeMargins (UXTHEME.@)
221 HRESULT WINAPI GetThemeMargins(HTHEME hTheme, HDC hdc, int iPartId,
222 int iStateId, int iPropId, RECT *prc,
223 MARGINS *pMargins)
225 PTHEME_PROPERTY tp;
227 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
228 memset (pMargins, 0, sizeof (MARGINS));
229 if(!hTheme)
230 return E_HANDLE;
232 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_MARGINS, iPropId)))
233 return E_PROP_ID_UNSUPPORTED;
234 return MSSTYLES_GetPropertyMargins(tp, prc, pMargins);
237 /***********************************************************************
238 * GetThemeMetric (UXTHEME.@)
240 HRESULT WINAPI GetThemeMetric(HTHEME hTheme, HDC hdc, int iPartId,
241 int iStateId, int iPropId, int *piVal)
243 PTHEME_PROPERTY tp;
244 WCHAR val[60];
245 HRESULT hr;
247 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
248 if(!hTheme)
249 return E_HANDLE;
251 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, 0, iPropId)))
252 return E_PROP_ID_UNSUPPORTED;
253 switch(tp->iPrimitiveType) {
254 case TMT_POSITION: /* Only the X coord is retrieved */
255 case TMT_MARGINS: /* Only the cxLeftWidth member is retrieved */
256 case TMT_INTLIST: /* Only the first int is retrieved */
257 case TMT_SIZE:
258 case TMT_INT:
259 return MSSTYLES_GetPropertyInt(tp, piVal);
260 case TMT_BOOL:
261 return MSSTYLES_GetPropertyBool(tp, piVal);
262 case TMT_COLOR:
263 return MSSTYLES_GetPropertyColor(tp, (COLORREF*)piVal);
264 case TMT_ENUM:
265 hr = MSSTYLES_GetPropertyString(tp, val, sizeof(val)/sizeof(val[0]));
266 if(FAILED(hr))
267 return hr;
268 if(!MSSTYLES_LookupEnum(val, iPropId, piVal))
269 return E_PROP_ID_UNSUPPORTED;
270 return S_OK;
271 case TMT_FILENAME:
272 /* Windows does return a value for this, but its value doesn't make sense */
273 FIXME("Filename\n");
274 break;
276 return E_PROP_ID_UNSUPPORTED;
279 /***********************************************************************
280 * GetThemePropertyOrigin (UXTHEME.@)
282 HRESULT WINAPI GetThemePropertyOrigin(HTHEME hTheme, int iPartId, int iStateId,
283 int iPropId, PROPERTYORIGIN *pOrigin)
285 PTHEME_PROPERTY tp;
287 TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
288 if(!hTheme)
289 return E_HANDLE;
291 if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, 0, iPropId))) {
292 *pOrigin = PO_NOTFOUND;
293 return S_OK;
295 *pOrigin = tp->origin;
296 return S_OK;