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
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(uxtheme
);
39 /***********************************************************************
40 * GetThemeSysBool (UXTHEME.@)
42 BOOL WINAPI
GetThemeSysBool(HTHEME hTheme
, int iBoolID
)
48 TRACE("(%p, %d)\n", hTheme
, iBoolID
);
51 if((tp
= MSSTYLES_FindMetric(TMT_BOOL
, iBoolID
))) {
52 hr
= MSSTYLES_GetPropertyBool(tp
, &ret
);
59 if(iBoolID
== TMT_FLATMENUS
) {
60 if(SystemParametersInfoW(SPI_GETFLATMENU
, 0, &ret
, 0))
64 FIXME("Unknown bool id: %d\n", iBoolID
);
65 SetLastError(STG_E_INVALIDPARAMETER
);
70 /***********************************************************************
71 * GetThemeSysColor (UXTHEME.@)
73 COLORREF WINAPI
GetThemeSysColor(HTHEME hTheme
, int iColorID
)
78 TRACE("(%p, %d)\n", hTheme
, iColorID
);
81 if((tp
= MSSTYLES_FindMetric(TMT_COLOR
, iColorID
))) {
83 hr
= MSSTYLES_GetPropertyColor(tp
, &color
);
90 return GetSysColor(iColorID
);
93 /***********************************************************************
94 * GetThemeSysColorBrush (UXTHEME.@)
96 HBRUSH WINAPI
GetThemeSysColorBrush(HTHEME hTheme
, int iColorID
)
98 TRACE("(%p, %d)\n", hTheme
, iColorID
);
99 return CreateSolidBrush(GetThemeSysColor(hTheme
, iColorID
));
102 /***********************************************************************
103 * GetThemeSysFont (UXTHEME.@)
105 HRESULT WINAPI
GetThemeSysFont(HTHEME hTheme
, int iFontID
, LOGFONTW
*plf
)
110 TRACE("(%p, %d)\n", hTheme
, iFontID
);
112 if((tp
= MSSTYLES_FindMetric(TMT_FONT
, iFontID
))) {
113 HDC hdc
= GetDC(NULL
);
114 hr
= MSSTYLES_GetPropertyFont(tp
, hdc
, plf
);
115 ReleaseDC(NULL
, hdc
);
120 if(iFontID
== TMT_ICONTITLEFONT
) {
121 if(!SystemParametersInfoW(SPI_GETICONTITLELOGFONT
, sizeof(LOGFONTW
), plf
, 0))
122 return HRESULT_FROM_WIN32(GetLastError());
125 NONCLIENTMETRICSW ncm
;
126 LOGFONTW
*font
= NULL
;
127 ncm
.cbSize
= sizeof(NONCLIENTMETRICSW
);
128 if(!SystemParametersInfoW(SPI_GETNONCLIENTMETRICS
, sizeof(NONCLIENTMETRICSW
), &ncm
, 0))
129 return HRESULT_FROM_WIN32(GetLastError());
131 case TMT_CAPTIONFONT
: font
= &ncm
.lfCaptionFont
; break;
132 case TMT_SMALLCAPTIONFONT
: font
= &ncm
.lfSmCaptionFont
; break;
133 case TMT_MENUFONT
: font
= &ncm
.lfMenuFont
; break;
134 case TMT_STATUSFONT
: font
= &ncm
.lfStatusFont
; break;
135 case TMT_MSGBOXFONT
: font
= &ncm
.lfMessageFont
; break;
136 default: FIXME("Unknown FontID: %d\n", iFontID
); break;
138 if(font
) *plf
= *font
;
139 else hr
= STG_E_INVALIDPARAMETER
;
144 /***********************************************************************
145 * GetThemeSysInt (UXTHEME.@)
147 HRESULT WINAPI
GetThemeSysInt(HTHEME hTheme
, int iIntID
, int *piValue
)
151 TRACE("(%p, %d)\n", hTheme
, iIntID
);
154 if(iIntID
< TMT_FIRSTINT
|| iIntID
> TMT_LASTINT
) {
155 WARN("Unknown IntID: %d\n", iIntID
);
156 return STG_E_INVALIDPARAMETER
;
158 if((tp
= MSSTYLES_FindMetric(TMT_INT
, iIntID
)))
159 return MSSTYLES_GetPropertyInt(tp
, piValue
);
160 return E_PROP_ID_UNSUPPORTED
;
163 /***********************************************************************
164 * GetThemeSysSize (UXTHEME.@)
166 int WINAPI
GetThemeSysSize(HTHEME hTheme
, int iSizeID
)
171 SM_CXVSCROLL
, TMT_SCROLLBARWIDTH
,
172 SM_CYHSCROLL
, TMT_SCROLLBARHEIGHT
,
173 SM_CXSIZE
, TMT_CAPTIONBARWIDTH
,
174 SM_CYSIZE
, TMT_CAPTIONBARHEIGHT
,
175 SM_CXFRAME
, TMT_SIZINGBORDERWIDTH
,
176 SM_CYFRAME
, TMT_SIZINGBORDERWIDTH
, /* There is no TMT_SIZINGBORDERHEIGHT, but this works in windows.. */
177 SM_CXSMSIZE
, TMT_SMCAPTIONBARWIDTH
,
178 SM_CYSMSIZE
, TMT_SMCAPTIONBARHEIGHT
,
179 SM_CXMENUSIZE
, TMT_MENUBARWIDTH
,
180 SM_CYMENUSIZE
, TMT_MENUBARHEIGHT
184 for(i
=0; i
<sizeof(metricMap
)/sizeof(metricMap
[0]); i
+=2) {
185 if(metricMap
[i
] == iSizeID
) {
192 if((tp
= MSSTYLES_FindMetric(TMT_SIZE
, id
))) {
193 if(SUCCEEDED(MSSTYLES_GetPropertyInt(tp
, &i
))) {
197 TRACE("Size %d not found in theme, using system metric\n", iSizeID
);
200 SetLastError(STG_E_INVALIDPARAMETER
);
204 return GetSystemMetrics(iSizeID
);
207 /***********************************************************************
208 * GetThemeSysString (UXTHEME.@)
210 HRESULT WINAPI
GetThemeSysString(HTHEME hTheme
, int iStringID
,
211 LPWSTR pszStringBuff
, int cchMaxStringChars
)
215 TRACE("(%p, %d)\n", hTheme
, iStringID
);
218 if(iStringID
< TMT_FIRSTSTRING
|| iStringID
> TMT_LASTSTRING
) {
219 WARN("Unknown StringID: %d\n", iStringID
);
220 return STG_E_INVALIDPARAMETER
;
222 if((tp
= MSSTYLES_FindMetric(TMT_STRING
, iStringID
)))
223 return MSSTYLES_GetPropertyString(tp
, pszStringBuff
, cchMaxStringChars
);
224 return E_PROP_ID_UNSUPPORTED
;