wined3d: Pass a wined3d_device_context to wined3d_cs_emit_blt_sub_resource().
[wine/zf.git] / dlls / uxtheme / metric.c
blob2d5a09d0256a8d63133a9c72977cf901fa4f6608
1 /*
2 * Win32 5.1 Theme metrics
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 "wingdi.h"
26 #include "winuser.h"
27 #include "vfwmsgs.h"
28 #include "uxtheme.h"
29 #include "tmschema.h"
31 #include "msstyles.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(uxtheme);
37 /***********************************************************************
38 * GetThemeSysBool (UXTHEME.@)
40 BOOL WINAPI GetThemeSysBool(HTHEME hTheme, int iBoolID)
42 HRESULT hr;
43 PTHEME_PROPERTY tp;
44 BOOL ret;
46 TRACE("(%p, %d)\n", hTheme, iBoolID);
47 SetLastError(0);
48 if(hTheme) {
49 if((tp = MSSTYLES_FindMetric(TMT_BOOL, iBoolID))) {
50 hr = MSSTYLES_GetPropertyBool(tp, &ret);
51 if(SUCCEEDED(hr))
52 return ret;
53 else
54 SetLastError(hr);
57 if(iBoolID == TMT_FLATMENUS) {
58 if(SystemParametersInfoW(SPI_GETFLATMENU, 0, &ret, 0))
59 return ret;
61 else {
62 FIXME("Unknown bool id: %d\n", iBoolID);
63 SetLastError(STG_E_INVALIDPARAMETER);
65 return FALSE;
68 /***********************************************************************
69 * GetThemeSysColor (UXTHEME.@)
71 COLORREF WINAPI GetThemeSysColor(HTHEME hTheme, int iColorID)
73 HRESULT hr;
74 PTHEME_PROPERTY tp;
76 TRACE("(%p, %d)\n", hTheme, iColorID);
77 SetLastError(0);
78 if(hTheme) {
79 if((tp = MSSTYLES_FindMetric(TMT_COLOR, iColorID))) {
80 COLORREF color;
81 hr = MSSTYLES_GetPropertyColor(tp, &color);
82 if(SUCCEEDED(hr))
83 return color;
84 else
85 SetLastError(hr);
88 return GetSysColor(iColorID);
91 /***********************************************************************
92 * GetThemeSysColorBrush (UXTHEME.@)
94 HBRUSH WINAPI GetThemeSysColorBrush(HTHEME hTheme, int iColorID)
96 TRACE("(%p, %d)\n", hTheme, iColorID);
97 return CreateSolidBrush(GetThemeSysColor(hTheme, iColorID));
100 /***********************************************************************
101 * GetThemeSysFont (UXTHEME.@)
103 HRESULT WINAPI GetThemeSysFont(HTHEME hTheme, int iFontID, LOGFONTW *plf)
105 HRESULT hr = S_OK;
106 PTHEME_PROPERTY tp;
108 TRACE("(%p, %d)\n", hTheme, iFontID);
109 if(hTheme) {
110 if((tp = MSSTYLES_FindMetric(TMT_FONT, iFontID))) {
111 HDC hdc = GetDC(NULL);
112 hr = MSSTYLES_GetPropertyFont(tp, hdc, plf);
113 ReleaseDC(NULL, hdc);
114 if(SUCCEEDED(hr))
115 return S_OK;
118 if(iFontID == TMT_ICONTITLEFONT) {
119 if(!SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(LOGFONTW), plf, 0))
120 return HRESULT_FROM_WIN32(GetLastError());
122 else {
123 NONCLIENTMETRICSW ncm;
124 LOGFONTW *font = NULL;
125 ncm.cbSize = sizeof(NONCLIENTMETRICSW);
126 if(!SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSW), &ncm, 0))
127 return HRESULT_FROM_WIN32(GetLastError());
128 switch(iFontID) {
129 case TMT_CAPTIONFONT: font = &ncm.lfCaptionFont; break;
130 case TMT_SMALLCAPTIONFONT: font = &ncm.lfSmCaptionFont; break;
131 case TMT_MENUFONT: font = &ncm.lfMenuFont; break;
132 case TMT_STATUSFONT: font = &ncm.lfStatusFont; break;
133 case TMT_MSGBOXFONT: font = &ncm.lfMessageFont; break;
134 default: FIXME("Unknown FontID: %d\n", iFontID); break;
136 if(font) *plf = *font;
137 else hr = STG_E_INVALIDPARAMETER;
139 return hr;
142 /***********************************************************************
143 * GetThemeSysInt (UXTHEME.@)
145 HRESULT WINAPI GetThemeSysInt(HTHEME hTheme, int iIntID, int *piValue)
147 PTHEME_PROPERTY tp;
149 TRACE("(%p, %d)\n", hTheme, iIntID);
150 if(!hTheme)
151 return E_HANDLE;
152 if(iIntID < TMT_FIRSTINT || iIntID > TMT_LASTINT) {
153 WARN("Unknown IntID: %d\n", iIntID);
154 return STG_E_INVALIDPARAMETER;
156 if((tp = MSSTYLES_FindMetric(TMT_INT, iIntID)))
157 return MSSTYLES_GetPropertyInt(tp, piValue);
158 return E_PROP_ID_UNSUPPORTED;
161 /***********************************************************************
162 * GetThemeSysSize (UXTHEME.@)
164 int WINAPI GetThemeSysSize(HTHEME hTheme, int iSizeID)
166 static const int metricMap[] = {
167 SM_CXVSCROLL, TMT_SCROLLBARWIDTH,
168 SM_CYHSCROLL, TMT_SCROLLBARHEIGHT,
169 SM_CXSIZE, TMT_CAPTIONBARWIDTH,
170 SM_CYSIZE, TMT_CAPTIONBARHEIGHT,
171 SM_CXFRAME, TMT_SIZINGBORDERWIDTH,
172 SM_CYFRAME, TMT_SIZINGBORDERWIDTH, /* There is no TMT_SIZINGBORDERHEIGHT, but this works in windows.. */
173 SM_CXSMSIZE, TMT_SMCAPTIONBARWIDTH,
174 SM_CYSMSIZE, TMT_SMCAPTIONBARHEIGHT,
175 SM_CXMENUSIZE, TMT_MENUBARWIDTH,
176 SM_CYMENUSIZE, TMT_MENUBARHEIGHT
178 PTHEME_PROPERTY tp;
179 int i, id = -1;
181 if(hTheme) {
182 for(i=0; i<ARRAY_SIZE(metricMap); i+=2) {
183 if(metricMap[i] == iSizeID) {
184 id = metricMap[i+1];
185 break;
188 SetLastError(0);
189 if(id != -1) {
190 if((tp = MSSTYLES_FindMetric(TMT_SIZE, id))) {
191 if(SUCCEEDED(MSSTYLES_GetPropertyInt(tp, &i))) {
192 return i;
195 TRACE("Size %d not found in theme, using system metric\n", iSizeID);
197 else {
198 SetLastError(STG_E_INVALIDPARAMETER);
199 return 0;
202 return GetSystemMetrics(iSizeID);
205 /***********************************************************************
206 * GetThemeSysString (UXTHEME.@)
208 HRESULT WINAPI GetThemeSysString(HTHEME hTheme, int iStringID,
209 LPWSTR pszStringBuff, int cchMaxStringChars)
211 PTHEME_PROPERTY tp;
213 TRACE("(%p, %d)\n", hTheme, iStringID);
214 if(!hTheme)
215 return E_HANDLE;
216 if(iStringID < TMT_FIRSTSTRING || iStringID > TMT_LASTSTRING) {
217 WARN("Unknown StringID: %d\n", iStringID);
218 return STG_E_INVALIDPARAMETER;
220 if((tp = MSSTYLES_FindMetric(TMT_STRING, iStringID)))
221 return MSSTYLES_GetPropertyString(tp, pszStringBuff, cchMaxStringChars);
222 return E_PROP_ID_UNSUPPORTED;
225 /***********************************************************************
226 * GetThemeTransitionDuration (UXTHEME.@)
228 HRESULT WINAPI GetThemeTransitionDuration(HTHEME hTheme, int iPartId, int iStateIdFrom,
229 int iStateIdTo, int iPropId, DWORD *pdwDuration)
231 FIXME("(%p, %u, %u, %u, %u, %p) stub\n", hTheme, iPartId, iStateIdFrom, iStateIdTo,
232 iPropId, pdwDuration);
234 return E_NOTIMPL;