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
34 #include "uxthemedll.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(uxtheme);
40 /***********************************************************************
41 * GetThemeSysBool (UXTHEME.@)
43 BOOL WINAPI GetThemeSysBool(HTHEME hTheme, int iBoolID)
49 TRACE("(%p, %d)\n", hTheme, iBoolID);
52 if((tp = MSSTYLES_FindMetric(TMT_BOOL, iBoolID))) {
53 hr = MSSTYLES_GetPropertyBool(tp, &ret);
60 if(iBoolID == TMT_FLATMENUS) {
61 if(SystemParametersInfoW(SPI_GETFLATMENU, 0, &ret, 0))
65 FIXME("Unknown bool id: %d\n", iBoolID);
66 SetLastError(STG_E_INVALIDPARAMETER);
71 /***********************************************************************
72 * GetThemeSysColor (UXTHEME.@)
74 COLORREF WINAPI GetThemeSysColor(HTHEME hTheme, int iColorID)
79 TRACE("(%p, %d)\n", hTheme, iColorID);
82 if((tp = MSSTYLES_FindMetric(TMT_COLOR, iColorID))) {
84 hr = MSSTYLES_GetPropertyColor(tp, &color);
91 return GetSysColor(iColorID - TMT_FIRSTCOLOR);
94 /***********************************************************************
95 * GetThemeSysColorBrush (UXTHEME.@)
97 HBRUSH WINAPI GetThemeSysColorBrush(HTHEME hTheme, int iColorID)
99 TRACE("(%p, %d)\n", hTheme, iColorID);
100 return CreateSolidBrush(GetThemeSysColor(hTheme, iColorID));
103 /***********************************************************************
104 * GetThemeSysFont (UXTHEME.@)
106 HRESULT WINAPI GetThemeSysFont(HTHEME hTheme, int iFontID, LOGFONTW *plf)
111 TRACE("(%p, %d)\n", hTheme, iFontID);
113 if((tp = MSSTYLES_FindMetric(TMT_FONT, iFontID))) {
114 HDC hdc = GetDC(NULL);
115 hr = MSSTYLES_GetPropertyFont(tp, hdc, plf);
116 ReleaseDC(NULL, hdc);
121 if(iFontID == TMT_ICONTITLEFONT) {
122 if(!SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(LOGFONTW), &plf, 0))
123 return HRESULT_FROM_WIN32(GetLastError());
126 NONCLIENTMETRICSW ncm;
127 LOGFONTW *font = NULL;
128 ncm.cbSize = sizeof(NONCLIENTMETRICSW);
129 if(!SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSW), &ncm, 0))
130 return HRESULT_FROM_WIN32(GetLastError());
132 case TMT_CAPTIONFONT: font = &ncm.lfCaptionFont; break;
133 case TMT_SMALLCAPTIONFONT: font = &ncm.lfSmCaptionFont; break;
134 case TMT_MENUFONT: font = &ncm.lfMenuFont; break;
135 case TMT_STATUSFONT: font = &ncm.lfStatusFont; break;
136 case TMT_MSGBOXFONT: font = &ncm.lfMessageFont; break;
137 default: FIXME("Unknown FontID: %d\n", iFontID); break;
139 if(font) CopyMemory(plf, font, sizeof(LOGFONTW));
140 else hr = STG_E_INVALIDPARAMETER;
145 /***********************************************************************
146 * GetThemeSysInt (UXTHEME.@)
148 HRESULT WINAPI GetThemeSysInt(HTHEME hTheme, int iIntID, int *piValue)
152 TRACE("(%p, %d)\n", hTheme, iIntID);
155 if(iIntID < TMT_FIRSTINT || iIntID > TMT_LASTINT) {
156 WARN("Unknown IntID: %d\n", iIntID);
157 return STG_E_INVALIDPARAMETER;
159 if((tp = MSSTYLES_FindMetric(TMT_INT, iIntID)))
160 return MSSTYLES_GetPropertyInt(tp, piValue);
161 return E_PROP_ID_UNSUPPORTED;
164 /***********************************************************************
165 * GetThemeSysSize (UXTHEME.@)
167 int WINAPI GetThemeSysSize(HTHEME hTheme, int iSizeID)
172 SM_CXVSCROLL, TMT_SCROLLBARWIDTH,
173 SM_CYHSCROLL, TMT_SCROLLBARHEIGHT,
174 SM_CXSIZE, TMT_CAPTIONBARWIDTH,
175 SM_CYSIZE, TMT_CAPTIONBARHEIGHT,
176 SM_CXFRAME, TMT_SIZINGBORDERWIDTH,
177 SM_CYFRAME, TMT_SIZINGBORDERWIDTH, /* There is no TMT_SIZINGBORDERHEIGHT, but this works in windows.. */
178 SM_CXSMSIZE, TMT_SMCAPTIONBARWIDTH,
179 SM_CYSMSIZE, TMT_SMCAPTIONBARHEIGHT,
180 SM_CXMENUSIZE, TMT_MENUBARWIDTH,
181 SM_CYMENUSIZE, TMT_MENUBARHEIGHT
185 for(i=0; i<sizeof(metricMap)/sizeof(metricMap[0]); i+=2) {
186 if(metricMap[i] == iSizeID) {
193 if((tp = MSSTYLES_FindMetric(TMT_SIZE, id))) {
194 if(SUCCEEDED(MSSTYLES_GetPropertyInt(tp, &i))) {
198 TRACE("Size %d not found in theme, using system metric\n", iSizeID);
201 SetLastError(STG_E_INVALIDPARAMETER);
205 return GetSystemMetrics(iSizeID);
208 /***********************************************************************
209 * GetThemeSysString (UXTHEME.@)
211 HRESULT WINAPI GetThemeSysString(HTHEME hTheme, int iStringID,
212 LPWSTR pszStringBuff, int cchMaxStringChars)
216 TRACE("(%p, %d)\n", hTheme, iStringID);
219 if(iStringID < TMT_FIRSTSTRING || iStringID > TMT_LASTSTRING) {
220 WARN("Unknown StringID: %d\n", iStringID);
221 return STG_E_INVALIDPARAMETER;
223 if((tp = MSSTYLES_FindMetric(TMT_STRING, iStringID)))
224 return MSSTYLES_GetPropertyString(tp, pszStringBuff, cchMaxStringChars);
225 return E_PROP_ID_UNSUPPORTED;