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
23 /***********************************************************************
24 * GetThemeSysBool (UXTHEME.@)
26 BOOL WINAPI
GetThemeSysBool(HTHEME hTheme
, int iBoolID
)
32 TRACE("(%p, %d)\n", hTheme
, iBoolID
);
35 PTHEME_CLASS ptc
= (PTHEME_CLASS
) hTheme
;
37 if((tp
= MSSTYLES_FindMetric(ptc
->tf
, TMT_BOOL
, iBoolID
))) {
38 hr
= MSSTYLES_GetPropertyBool(tp
, &ret
);
45 if(iBoolID
== TMT_FLATMENUS
) {
46 if(SystemParametersInfoW(SPI_GETFLATMENU
, 0, &ret
, 0))
50 FIXME("Unknown bool id: %d\n", iBoolID
);
51 SetLastError(STG_E_INVALIDPARAMETER
);
56 /***********************************************************************
57 * GetThemeSysColor (UXTHEME.@)
59 COLORREF WINAPI
GetThemeSysColor(HTHEME hTheme
, int iColorID
)
64 TRACE("(%p, %d)\n", hTheme
, iColorID
);
67 PTHEME_CLASS ptc
= (PTHEME_CLASS
) hTheme
;
68 if((tp
= MSSTYLES_FindMetric(ptc
->tf
, TMT_COLOR
, iColorID
+ TMT_FIRSTCOLOR
))) {
70 hr
= MSSTYLES_GetPropertyColor(tp
, &color
);
77 return GetSysColor(iColorID
);
80 /***********************************************************************
81 * GetThemeSysColorBrush (UXTHEME.@)
83 HBRUSH WINAPI
GetThemeSysColorBrush(HTHEME hTheme
, int iColorID
)
85 TRACE("(%p, %d)\n", hTheme
, iColorID
);
86 return CreateSolidBrush(GetThemeSysColor(hTheme
, iColorID
));
89 /***********************************************************************
90 * GetThemeSysFont (UXTHEME.@)
92 HRESULT WINAPI
GetThemeSysFont(HTHEME hTheme
, int iFontID
, LOGFONTW
*plf
)
97 TRACE("(%p, %d)\n", hTheme
, iFontID
);
99 PTHEME_CLASS ptc
= (PTHEME_CLASS
) hTheme
;
100 if((tp
= MSSTYLES_FindMetric(ptc
->tf
, TMT_FONT
, iFontID
))) {
101 HDC hdc
= GetDC(NULL
);
102 hr
= MSSTYLES_GetPropertyFont(tp
, hdc
, plf
);
103 ReleaseDC(NULL
, hdc
);
108 if(iFontID
== TMT_ICONTITLEFONT
) {
109 if(!SystemParametersInfoW(SPI_GETICONTITLELOGFONT
, sizeof(LOGFONTW
), plf
, 0))
110 return HRESULT_FROM_WIN32(GetLastError());
113 NONCLIENTMETRICSW ncm
;
114 LOGFONTW
*font
= NULL
;
115 ncm
.cbSize
= sizeof(NONCLIENTMETRICSW
);
116 if(!SystemParametersInfoW(SPI_GETNONCLIENTMETRICS
, sizeof(NONCLIENTMETRICSW
), &ncm
, 0))
117 return HRESULT_FROM_WIN32(GetLastError());
119 case TMT_CAPTIONFONT
: font
= &ncm
.lfCaptionFont
; break;
120 case TMT_SMALLCAPTIONFONT
: font
= &ncm
.lfSmCaptionFont
; break;
121 case TMT_MENUFONT
: font
= &ncm
.lfMenuFont
; break;
122 case TMT_STATUSFONT
: font
= &ncm
.lfStatusFont
; break;
123 case TMT_MSGBOXFONT
: font
= &ncm
.lfMessageFont
; break;
124 default: FIXME("Unknown FontID: %d\n", iFontID
); break;
126 if(font
) *plf
= *font
;
127 else hr
= STG_E_INVALIDPARAMETER
;
132 /***********************************************************************
133 * GetThemeSysInt (UXTHEME.@)
135 HRESULT WINAPI
GetThemeSysInt(HTHEME hTheme
, int iIntID
, int *piValue
)
138 PTHEME_CLASS ptc
= (PTHEME_CLASS
) hTheme
;
140 TRACE("(%p, %d)\n", hTheme
, iIntID
);
143 if(iIntID
< TMT_FIRSTINT
|| iIntID
> TMT_LASTINT
) {
144 WARN("Unknown IntID: %d\n", iIntID
);
145 return STG_E_INVALIDPARAMETER
;
147 if((tp
= MSSTYLES_FindMetric(ptc
->tf
, TMT_INT
, iIntID
)))
148 return MSSTYLES_GetPropertyInt(tp
, piValue
);
149 return E_PROP_ID_UNSUPPORTED
;
152 /***********************************************************************
153 * GetThemeSysSize (UXTHEME.@)
155 int WINAPI
GetThemeSysSize(HTHEME hTheme
, int iSizeID
)
160 SM_CXVSCROLL
, TMT_SCROLLBARWIDTH
,
161 SM_CYHSCROLL
, TMT_SCROLLBARHEIGHT
,
162 SM_CXSIZE
, TMT_CAPTIONBARWIDTH
,
163 SM_CYSIZE
, TMT_CAPTIONBARHEIGHT
,
164 SM_CXFRAME
, TMT_SIZINGBORDERWIDTH
,
165 SM_CYFRAME
, TMT_SIZINGBORDERWIDTH
, /* There is no TMT_SIZINGBORDERHEIGHT, but this works in windows.. */
166 SM_CXSMSIZE
, TMT_SMCAPTIONBARWIDTH
,
167 SM_CYSMSIZE
, TMT_SMCAPTIONBARHEIGHT
,
168 SM_CXMENUSIZE
, TMT_MENUBARWIDTH
,
169 SM_CYMENUSIZE
, TMT_MENUBARHEIGHT
173 PTHEME_CLASS ptc
= (PTHEME_CLASS
) hTheme
;
175 for(i
=0; i
<sizeof(metricMap
)/sizeof(metricMap
[0]); i
+=2) {
176 if(metricMap
[i
] == iSizeID
) {
183 if((tp
= MSSTYLES_FindMetric(ptc
->tf
, TMT_SIZE
, id
))) {
184 if(SUCCEEDED(MSSTYLES_GetPropertyInt(tp
, &i
))) {
188 TRACE("Size %d not found in theme, using system metric\n", iSizeID
);
191 SetLastError(STG_E_INVALIDPARAMETER
);
197 // TODO: Check if this is correct
198 // In windows for SM_CXFRAME this function returns what seems to be the non client metric iBorderWidth
199 if (iSizeID
== SM_CXFRAME
)
200 return GetSystemMetrics(SM_CXFRAME
) - GetSystemMetrics(SM_CXDLGFRAME
);
201 return GetSystemMetrics(iSizeID
);
204 /***********************************************************************
205 * GetThemeSysString (UXTHEME.@)
207 HRESULT WINAPI
GetThemeSysString(HTHEME hTheme
, int iStringID
,
208 LPWSTR pszStringBuff
, int cchMaxStringChars
)
211 PTHEME_CLASS ptc
= (PTHEME_CLASS
) hTheme
;
213 TRACE("(%p, %d)\n", hTheme
, iStringID
);
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(ptc
->tf
, TMT_STRING
, iStringID
)))
221 return MSSTYLES_GetPropertyString(tp
, pszStringBuff
, cchMaxStringChars
);
222 return E_PROP_ID_UNSUPPORTED
;
226 /***********************************************************************
227 * GetThemeTransitionDuration (UXTHEME.@)
229 HRESULT WINAPI
GetThemeTransitionDuration(HTHEME hTheme
, int iPartId
, int iStateIdFrom
,
230 int iStateIdTo
, int iPropId
, DWORD
*pdwDuration
)
232 FIXME("(%p, %u, %u, %u, %u, %p) stub\n", hTheme
, iPartId
, iStateIdFrom
, iStateIdTo
,
233 iPropId
, pdwDuration
);