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 // TODO: Check if this is correct
65 if ( iColorID
>= 0 && iColorID
< 32)
66 iColorID
+= TMT_SCROLLBAR
;
68 TRACE("(%p, %d)\n", hTheme
, iColorID
);
71 PTHEME_CLASS ptc
= (PTHEME_CLASS
) hTheme
;
72 if((tp
= MSSTYLES_FindMetric(ptc
->tf
, TMT_COLOR
, iColorID
))) {
74 hr
= MSSTYLES_GetPropertyColor(tp
, &color
);
81 return GetSysColor(iColorID
);
84 /***********************************************************************
85 * GetThemeSysColorBrush (UXTHEME.@)
87 HBRUSH WINAPI
GetThemeSysColorBrush(HTHEME hTheme
, int iColorID
)
89 TRACE("(%p, %d)\n", hTheme
, iColorID
);
90 return CreateSolidBrush(GetThemeSysColor(hTheme
, iColorID
));
93 /***********************************************************************
94 * GetThemeSysFont (UXTHEME.@)
96 HRESULT WINAPI
GetThemeSysFont(HTHEME hTheme
, int iFontID
, LOGFONTW
*plf
)
101 TRACE("(%p, %d)\n", hTheme
, iFontID
);
103 PTHEME_CLASS ptc
= (PTHEME_CLASS
) hTheme
;
104 if((tp
= MSSTYLES_FindMetric(ptc
->tf
, TMT_FONT
, iFontID
))) {
105 HDC hdc
= GetDC(NULL
);
106 hr
= MSSTYLES_GetPropertyFont(tp
, hdc
, plf
);
107 ReleaseDC(NULL
, hdc
);
112 if(iFontID
== TMT_ICONTITLEFONT
) {
113 if(!SystemParametersInfoW(SPI_GETICONTITLELOGFONT
, sizeof(LOGFONTW
), plf
, 0))
114 return HRESULT_FROM_WIN32(GetLastError());
117 NONCLIENTMETRICSW ncm
;
118 LOGFONTW
*font
= NULL
;
119 ncm
.cbSize
= sizeof(NONCLIENTMETRICSW
);
120 if(!SystemParametersInfoW(SPI_GETNONCLIENTMETRICS
, sizeof(NONCLIENTMETRICSW
), &ncm
, 0))
121 return HRESULT_FROM_WIN32(GetLastError());
123 case TMT_CAPTIONFONT
: font
= &ncm
.lfCaptionFont
; break;
124 case TMT_SMALLCAPTIONFONT
: font
= &ncm
.lfSmCaptionFont
; break;
125 case TMT_MENUFONT
: font
= &ncm
.lfMenuFont
; break;
126 case TMT_STATUSFONT
: font
= &ncm
.lfStatusFont
; break;
127 case TMT_MSGBOXFONT
: font
= &ncm
.lfMessageFont
; break;
128 default: FIXME("Unknown FontID: %d\n", iFontID
); break;
130 if(font
) *plf
= *font
;
131 else hr
= STG_E_INVALIDPARAMETER
;
136 /***********************************************************************
137 * GetThemeSysInt (UXTHEME.@)
139 HRESULT WINAPI
GetThemeSysInt(HTHEME hTheme
, int iIntID
, int *piValue
)
142 PTHEME_CLASS ptc
= (PTHEME_CLASS
) hTheme
;
144 TRACE("(%p, %d)\n", hTheme
, iIntID
);
147 if(iIntID
< TMT_FIRSTINT
|| iIntID
> TMT_LASTINT
) {
148 WARN("Unknown IntID: %d\n", iIntID
);
149 return STG_E_INVALIDPARAMETER
;
151 if((tp
= MSSTYLES_FindMetric(ptc
->tf
, TMT_INT
, iIntID
)))
152 return MSSTYLES_GetPropertyInt(tp
, piValue
);
153 return E_PROP_ID_UNSUPPORTED
;
156 /***********************************************************************
157 * GetThemeSysSize (UXTHEME.@)
159 int WINAPI
GetThemeSysSize(HTHEME hTheme
, int iSizeID
)
164 SM_CXVSCROLL
, TMT_SCROLLBARWIDTH
,
165 SM_CYHSCROLL
, TMT_SCROLLBARHEIGHT
,
166 SM_CXSIZE
, TMT_CAPTIONBARWIDTH
,
167 SM_CYSIZE
, TMT_CAPTIONBARHEIGHT
,
168 SM_CXFRAME
, TMT_SIZINGBORDERWIDTH
,
169 SM_CYFRAME
, TMT_SIZINGBORDERWIDTH
, /* There is no TMT_SIZINGBORDERHEIGHT, but this works in windows.. */
170 SM_CXSMSIZE
, TMT_SMCAPTIONBARWIDTH
,
171 SM_CYSMSIZE
, TMT_SMCAPTIONBARHEIGHT
,
172 SM_CXMENUSIZE
, TMT_MENUBARWIDTH
,
173 SM_CYMENUSIZE
, TMT_MENUBARHEIGHT
177 PTHEME_CLASS ptc
= (PTHEME_CLASS
) hTheme
;
179 for(i
=0; i
<sizeof(metricMap
)/sizeof(metricMap
[0]); i
+=2) {
180 if(metricMap
[i
] == iSizeID
) {
187 if((tp
= MSSTYLES_FindMetric(ptc
->tf
, TMT_SIZE
, id
))) {
188 if(SUCCEEDED(MSSTYLES_GetPropertyInt(tp
, &i
))) {
192 TRACE("Size %d not found in theme, using system metric\n", iSizeID
);
195 SetLastError(STG_E_INVALIDPARAMETER
);
201 // TODO: Check if this is correct
202 // In windows for SM_CXFRAME this function returns what seems to be the non client metric iBorderWidth
203 if (iSizeID
== SM_CXFRAME
)
204 return GetSystemMetrics(SM_CXFRAME
) - GetSystemMetrics(SM_CXDLGFRAME
);
205 return GetSystemMetrics(iSizeID
);
208 /***********************************************************************
209 * GetThemeSysString (UXTHEME.@)
211 HRESULT WINAPI
GetThemeSysString(HTHEME hTheme
, int iStringID
,
212 LPWSTR pszStringBuff
, int cchMaxStringChars
)
215 PTHEME_CLASS ptc
= (PTHEME_CLASS
) hTheme
;
217 TRACE("(%p, %d)\n", hTheme
, iStringID
);
220 if(iStringID
< TMT_FIRSTSTRING
|| iStringID
> TMT_LASTSTRING
) {
221 WARN("Unknown StringID: %d\n", iStringID
);
222 return STG_E_INVALIDPARAMETER
;
224 if((tp
= MSSTYLES_FindMetric(ptc
->tf
, TMT_STRING
, iStringID
)))
225 return MSSTYLES_GetPropertyString(tp
, pszStringBuff
, cchMaxStringChars
);
226 return E_PROP_ID_UNSUPPORTED
;
230 /***********************************************************************
231 * GetThemeTransitionDuration (UXTHEME.@)
233 HRESULT WINAPI
GetThemeTransitionDuration(HTHEME hTheme
, int iPartId
, int iStateIdFrom
,
234 int iStateIdTo
, int iPropId
, DWORD
*pdwDuration
)
236 FIXME("(%p, %u, %u, %u, %u, %p) stub\n", hTheme
, iPartId
, iStateIdFrom
, iStateIdTo
,
237 iPropId
, pdwDuration
);