ReactOS 0.4.16-dev-197-g92996da
metric.c
Go to the documentation of this file.
1/*
2 * Win32 5.1 Theme metrics
3 *
4 * Copyright (C) 2003 Kevin Koltzau
5 *
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.
10 *
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.
15 *
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
19 */
20
21#include "uxthemep.h"
22
23/***********************************************************************
24 * GetThemeSysBool (UXTHEME.@)
25 */
26BOOL WINAPI GetThemeSysBool(HTHEME hTheme, int iBoolID)
27{
28 HRESULT hr;
30 BOOL ret;
31 PTHEME_CLASS ptc = ValidateHandle(hTheme);
32
33 TRACE("(%p, %d)\n", hTheme, iBoolID);
34 SetLastError(0);
35 if(ptc) {
36 if((tp = MSSTYLES_FindMetric(ptc->tf, TMT_BOOL, iBoolID))) {
38 if(SUCCEEDED(hr))
39 return ret;
40 else
42 }
43 }
44 if(iBoolID == TMT_FLATMENUS) {
45 if(SystemParametersInfoW(SPI_GETFLATMENU, 0, &ret, 0))
46 return ret;
47 }
48 else {
49 FIXME("Unknown bool id: %d\n", iBoolID);
51 }
52 return FALSE;
53}
54
55/***********************************************************************
56 * GetThemeSysColor (UXTHEME.@)
57 */
59{
60 HRESULT hr;
62 PTHEME_CLASS ptc = ValidateHandle(hTheme);
63
64 TRACE("(%p, %d)\n", hTheme, iColorID);
65 SetLastError(0);
66 if(ptc) {
67 if((tp = MSSTYLES_FindMetric(ptc->tf, TMT_COLOR, iColorID + TMT_FIRSTCOLOR))) {
70 if(SUCCEEDED(hr))
71 return color;
72 else
74 }
75 }
76 return GetSysColor(iColorID);
77}
78
79/***********************************************************************
80 * GetThemeSysColorBrush (UXTHEME.@)
81 */
82HBRUSH WINAPI GetThemeSysColorBrush(HTHEME hTheme, int iColorID)
83{
84 TRACE("(%p, %d)\n", hTheme, iColorID);
85 return CreateSolidBrush(GetThemeSysColor(hTheme, iColorID));
86}
87
88/***********************************************************************
89 * GetThemeSysFont (UXTHEME.@)
90 */
91HRESULT WINAPI GetThemeSysFont(HTHEME hTheme, int iFontID, LOGFONTW *plf)
92{
93 HRESULT hr = S_OK;
95 PTHEME_CLASS ptc = ValidateHandle(hTheme);
96
97 TRACE("(%p, %d)\n", hTheme, iFontID);
98 if(ptc) {
99 if((tp = MSSTYLES_FindMetric(ptc->tf, TMT_FONT, iFontID))) {
100 HDC hdc = GetDC(NULL);
103 if(SUCCEEDED(hr))
104 return S_OK;
105 }
106 }
107 if(iFontID == TMT_ICONTITLEFONT) {
110 }
111 else {
112 NONCLIENTMETRICSW ncm;
113 LOGFONTW *font = NULL;
114 ncm.cbSize = sizeof(NONCLIENTMETRICSW);
115 if(!SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSW), &ncm, 0))
117 switch(iFontID) {
118 case TMT_CAPTIONFONT: font = &ncm.lfCaptionFont; break;
119 case TMT_SMALLCAPTIONFONT: font = &ncm.lfSmCaptionFont; break;
120 case TMT_MENUFONT: font = &ncm.lfMenuFont; break;
121 case TMT_STATUSFONT: font = &ncm.lfStatusFont; break;
122 case TMT_MSGBOXFONT: font = &ncm.lfMessageFont; break;
123 default: FIXME("Unknown FontID: %d\n", iFontID); break;
124 }
125 if(font) *plf = *font;
127 }
128 return hr;
129}
130
131/***********************************************************************
132 * GetThemeSysInt (UXTHEME.@)
133 */
134HRESULT WINAPI GetThemeSysInt(HTHEME hTheme, int iIntID, int *piValue)
135{
137 PTHEME_CLASS ptc = ValidateHandle(hTheme);
138
139 TRACE("(%p, %d)\n", hTheme, iIntID);
140 if(!ptc)
141 return E_HANDLE;
142 if(iIntID < TMT_FIRSTINT || iIntID > TMT_LASTINT) {
143 WARN("Unknown IntID: %d\n", iIntID);
145 }
146 if((tp = MSSTYLES_FindMetric(ptc->tf , TMT_INT, iIntID)))
147 return MSSTYLES_GetPropertyInt(tp, piValue);
149}
150
151/***********************************************************************
152 * GetThemeSysSize (UXTHEME.@)
153 */
154int WINAPI GetThemeSysSize(HTHEME hTheme, int iSizeID)
155{
157 int i, id = -1;
158 int metricMap[] = {
164 SM_CYFRAME, TMT_SIZINGBORDERWIDTH, /* There is no TMT_SIZINGBORDERHEIGHT, but this works in windows.. */
169 };
170 PTHEME_CLASS ptc = ValidateHandle(hTheme);
171
172 if(ptc) {
173 for(i=0; i<sizeof(metricMap)/sizeof(metricMap[0]); i+=2) {
174 if(metricMap[i] == iSizeID) {
175 id = metricMap[i+1];
176 break;
177 }
178 }
179 SetLastError(0);
180 if(id != -1) {
181 if((tp = MSSTYLES_FindMetric(ptc->tf, TMT_SIZE, id))) {
183 return i;
184 }
185 }
186 TRACE("Size %d not found in theme, using system metric\n", iSizeID);
187 }
188 else {
190 return 0;
191 }
192 }
193
194
195 // TODO: Check if this is correct
196 // In windows for SM_CXFRAME this function returns what seems to be the non client metric iBorderWidth
197 if (iSizeID == SM_CXFRAME)
199 return GetSystemMetrics(iSizeID);
200}
201
202/***********************************************************************
203 * GetThemeSysString (UXTHEME.@)
204 */
206 LPWSTR pszStringBuff, int cchMaxStringChars)
207{
209 PTHEME_CLASS ptc = ValidateHandle(hTheme);
210
211 TRACE("(%p, %d)\n", hTheme, iStringID);
212 if(!ptc)
213 return E_HANDLE;
214 if(iStringID < TMT_FIRSTSTRING || iStringID > TMT_LASTSTRING) {
215 WARN("Unknown StringID: %d\n", iStringID);
217 }
218 if((tp = MSSTYLES_FindMetric(ptc->tf, TMT_STRING, iStringID)))
219 return MSSTYLES_GetPropertyString(tp, pszStringBuff, cchMaxStringChars);
221}
222
223#ifndef __REACTOS__
224/***********************************************************************
225 * GetThemeTransitionDuration (UXTHEME.@)
226 */
227HRESULT WINAPI GetThemeTransitionDuration(HTHEME hTheme, int iPartId, int iStateIdFrom,
228 int iStateIdTo, int iPropId, DWORD *pdwDuration)
229{
230 FIXME("(%p, %u, %u, %u, %u, %p) stub\n", hTheme, iPartId, iStateIdFrom, iStateIdTo,
231 iPropId, pdwDuration);
232
233 return E_NOTIMPL;
234}
235#endif
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define E_NOTIMPL
Definition: ddrawi.h:99
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define SetLastError(x)
Definition: compat.h:752
LPVOID FASTCALL ValidateHandle(HANDLE hObject, UINT uType)
Definition: utils.c:377
COLORREF WINAPI GetThemeSysColor(HTHEME hTheme, int iColorID)
Definition: metric.c:58
HRESULT WINAPI GetThemeSysFont(HTHEME hTheme, int iFontID, LOGFONTW *plf)
Definition: metric.c:91
HBRUSH WINAPI GetThemeSysColorBrush(HTHEME hTheme, int iColorID)
Definition: metric.c:82
HRESULT WINAPI GetThemeTransitionDuration(HTHEME hTheme, int iPartId, int iStateIdFrom, int iStateIdTo, int iPropId, DWORD *pdwDuration)
Definition: metric.c:227
HRESULT WINAPI GetThemeSysInt(HTHEME hTheme, int iIntID, int *piValue)
Definition: metric.c:134
HRESULT WINAPI GetThemeSysString(HTHEME hTheme, int iStringID, LPWSTR pszStringBuff, int cchMaxStringChars)
Definition: metric.c:205
int WINAPI GetThemeSysSize(HTHEME hTheme, int iSizeID)
Definition: metric.c:154
BOOL WINAPI GetThemeSysBool(HTHEME hTheme, int iBoolID)
Definition: metric.c:26
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2996
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint color
Definition: glext.h:6243
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
HRESULT MSSTYLES_GetPropertyFont(PTHEME_PROPERTY tp, HDC hdc, LOGFONTW *pFont)
Definition: msstyles.c:1077
HRESULT MSSTYLES_GetPropertyBool(PTHEME_PROPERTY tp, BOOL *pfVal)
Definition: msstyles.c:994
HRESULT MSSTYLES_GetPropertyString(PTHEME_PROPERTY tp, LPWSTR pszBuff, int cchMaxBuffChars)
Definition: msstyles.c:1151
HRESULT MSSTYLES_GetPropertyColor(PTHEME_PROPERTY tp, COLORREF *pColor)
Definition: msstyles.c:1007
PTHEME_PROPERTY MSSTYLES_FindMetric(PTHEME_FILE tf, int iPropertyPrimitive, int iPropertyId)
Definition: msstyles.c:556
HRESULT MSSTYLES_GetPropertyInt(PTHEME_PROPERTY tp, int *piVal)
Definition: msstyles.c:1094
Definition: mk_font.cpp:20
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
struct _THEME_FILE * tf
Definition: uxthemep.h:61
#define TMT_FIRSTCOLOR
Definition: tmschema.h:236
#define TMT_LASTSTRING
Definition: tmschema.h:202
#define TMT_LASTINT
Definition: tmschema.h:196
#define E_PROP_ID_UNSUPPORTED
Definition: vfwmsgs.h:173
#define TMT_STRING
Definition: vssym32.h:135
#define TMT_INT
Definition: vssym32.h:136
#define TMT_SMALLCAPTIONFONT
Definition: vssym32.h:165
#define TMT_SMCAPTIONBARHEIGHT
Definition: vssym32.h:184
#define TMT_FLATMENUS
Definition: vssym32.h:175
#define TMT_SMCAPTIONBARWIDTH
Definition: vssym32.h:183
#define TMT_COLOR
Definition: vssym32.h:138
#define TMT_MENUBARWIDTH
Definition: vssym32.h:185
#define TMT_CAPTIONFONT
Definition: vssym32.h:164
#define TMT_CAPTIONBARHEIGHT
Definition: vssym32.h:182
#define TMT_SCROLLBARHEIGHT
Definition: vssym32.h:180
#define TMT_MENUFONT
Definition: vssym32.h:166
#define TMT_FONT
Definition: vssym32.h:144
#define TMT_SIZINGBORDERWIDTH
Definition: vssym32.h:178
#define TMT_MSGBOXFONT
Definition: vssym32.h:168
#define TMT_ICONTITLEFONT
Definition: vssym32.h:169
#define TMT_MENUBARHEIGHT
Definition: vssym32.h:186
#define TMT_BOOL
Definition: vssym32.h:137
#define TMT_STATUSFONT
Definition: vssym32.h:167
#define TMT_CAPTIONBARWIDTH
Definition: vssym32.h:181
#define TMT_SCROLLBARWIDTH
Definition: vssym32.h:179
#define TMT_SIZE
Definition: vssym32.h:141
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
DWORD COLORREF
Definition: windef.h:300
#define WINAPI
Definition: msvc.h:6
#define E_HANDLE
Definition: winerror.h:2850
#define STG_E_INVALIDPARAMETER
Definition: winerror.h:2580
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
DWORD WINAPI GetSysColor(_In_ int)
#define SM_CYSIZE
Definition: winuser.h:995
#define SM_CXVSCROLL
Definition: winuser.h:964
#define SM_CXFRAME
Definition: winuser.h:997
#define SPI_GETICONTITLELOGFONT
Definition: winuser.h:1383
#define SM_CXSIZE
Definition: winuser.h:994
#define SM_CYFRAME
Definition: winuser.h:999
#define SM_CYHSCROLL
Definition: winuser.h:965
#define SM_CXSMSIZE
Definition: winuser.h:1018
HDC WINAPI GetDC(_In_opt_ HWND)
#define SM_CXDLGFRAME
Definition: winuser.h:969
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define SM_CXMENUSIZE
Definition: winuser.h:1020
#define SM_CYSMSIZE
Definition: winuser.h:1019
#define SM_CYMENUSIZE
Definition: winuser.h:1021
int WINAPI GetSystemMetrics(_In_ int)
WCHAR * LPWSTR
Definition: xmlstorage.h:184