ReactOS  0.4.14-dev-293-g2b39b42
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  */
26 BOOL 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  */
58 COLORREF WINAPI GetThemeSysColor(HTHEME hTheme, int iColorID)
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  */
82 HBRUSH 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  */
91 HRESULT 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);
102  ReleaseDC(NULL, hdc);
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;
126  else hr = STG_E_INVALIDPARAMETER;
127  }
128  return hr;
129 }
130 
131 /***********************************************************************
132  * GetThemeSysInt (UXTHEME.@)
133  */
134 HRESULT 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);
144  return STG_E_INVALIDPARAMETER;
145  }
146  if((tp = MSSTYLES_FindMetric(ptc->tf , TMT_INT, iIntID)))
147  return MSSTYLES_GetPropertyInt(tp, piValue);
148  return E_PROP_ID_UNSUPPORTED;
149 }
150 
151 /***********************************************************************
152  * GetThemeSysSize (UXTHEME.@)
153  */
154 int 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  */
205 HRESULT WINAPI GetThemeSysString(HTHEME hTheme, int iStringID,
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);
216  return STG_E_INVALIDPARAMETER;
217  }
218  if((tp = MSSTYLES_FindMetric(ptc->tf, TMT_STRING, iStringID)))
219  return MSSTYLES_GetPropertyString(tp, pszStringBuff, cchMaxStringChars);
220  return E_PROP_ID_UNSUPPORTED;
221 }
222 
223 #ifndef __REACTOS__
224 /***********************************************************************
225  * GetThemeTransitionDuration (UXTHEME.@)
226  */
227 HRESULT 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
int WINAPI GetThemeSysSize(HTHEME hTheme, int iSizeID)
Definition: metric.c:154
PTHEME_PROPERTY MSSTYLES_FindMetric(PTHEME_FILE tf, int iPropertyPrimitive, int iPropertyId)
Definition: msstyles.c:556
#define SM_CYHSCROLL
Definition: winuser.h:952
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define SM_CYSIZE
Definition: winuser.h:982
#define E_HANDLE
Definition: winerror.h:2850
#define TMT_BOOL
Definition: vssym32.h:137
#define SM_CYMENUSIZE
Definition: winuser.h:1008
#define TMT_SCROLLBARWIDTH
Definition: vssym32.h:179
HRESULT hr
Definition: shlfolder.c:183
HDC WINAPI GetDC(_In_opt_ HWND)
Definition: mk_font.cpp:20
#define WARN(fmt,...)
Definition: debug.h:111
static HDC
Definition: imagelist.c:92
HRESULT WINAPI GetThemeSysInt(HTHEME hTheme, int iIntID, int *piValue)
Definition: metric.c:134
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define TMT_LASTINT
Definition: tmschema.h:196
#define TMT_MENUFONT
Definition: vssym32.h:166
#define SM_CYFRAME
Definition: winuser.h:986
#define SM_CXFRAME
Definition: winuser.h:984
DWORD WINAPI GetSysColor(_In_ int)
#define TMT_FIRSTCOLOR
Definition: tmschema.h:236
#define TMT_MSGBOXFONT
Definition: vssym32.h:168
HBRUSH WINAPI GetThemeSysColorBrush(HTHEME hTheme, int iColorID)
Definition: metric.c:82
#define TMT_CAPTIONFONT
Definition: vssym32.h:164
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 TMT_ICONTITLEFONT
Definition: vssym32.h:169
unsigned int BOOL
Definition: ntddk_ex.h:94
HRESULT WINAPI GetThemeSysFont(HTHEME hTheme, int iFontID, LOGFONTW *plf)
Definition: metric.c:91
GLuint color
Definition: glext.h:6243
#define TMT_SMCAPTIONBARHEIGHT
Definition: vssym32.h:184
#define TMT_STRING
Definition: vssym32.h:135
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define FIXME(fmt,...)
Definition: debug.h:110
#define TMT_MENUBARHEIGHT
Definition: vssym32.h:186
#define TMT_CAPTIONBARHEIGHT
Definition: vssym32.h:182
smooth NULL
Definition: ftsmooth.c:416
#define TMT_FONT
Definition: vssym32.h:144
HRESULT MSSTYLES_GetPropertyBool(PTHEME_PROPERTY tp, BOOL *pfVal)
Definition: msstyles.c:983
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2883
BOOL WINAPI SystemParametersInfoW(_In_ UINT, _In_ UINT, _Inout_opt_ PVOID, _In_ UINT)
#define SM_CYSMSIZE
Definition: winuser.h:1006
#define TRACE(s)
Definition: solgame.cpp:4
#define E_PROP_ID_UNSUPPORTED
Definition: vfwmsgs.h:173
LONG HRESULT
Definition: typedefs.h:77
#define SM_CXDLGFRAME
Definition: winuser.h:956
DWORD COLORREF
Definition: windef.h:285
#define WINAPI
Definition: msvc.h:8
#define SM_CXSMSIZE
Definition: winuser.h:1005
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
#define STG_E_INVALIDPARAMETER
Definition: winerror.h:2580
int ret
PTHEME_CLASS ValidateHandle(HTHEME hTheme)
Definition: system.c:717
COLORREF WINAPI GetThemeSysColor(HTHEME hTheme, int iColorID)
Definition: metric.c:58
HDC hdc
Definition: main.c:9
HRESULT MSSTYLES_GetPropertyColor(PTHEME_PROPERTY tp, COLORREF *pColor)
Definition: msstyles.c:996
#define S_OK
Definition: intsafe.h:59
#define TMT_SCROLLBARHEIGHT
Definition: vssym32.h:180
HRESULT MSSTYLES_GetPropertyFont(PTHEME_PROPERTY tp, HDC hdc, LOGFONTW *pFont)
Definition: msstyles.c:1066
#define TMT_INT
Definition: vssym32.h:136
HRESULT MSSTYLES_GetPropertyInt(PTHEME_PROPERTY tp, int *piVal)
Definition: msstyles.c:1083
#define E_NOTIMPL
Definition: ddrawi.h:99
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define SPI_GETICONTITLELOGFONT
Definition: winuser.h:1362
#define SM_CXVSCROLL
Definition: winuser.h:951
#define TMT_MENUBARWIDTH
Definition: vssym32.h:185
#define TMT_CAPTIONBARWIDTH
Definition: vssym32.h:181
#define TMT_FLATMENUS
Definition: vssym32.h:175
#define TMT_COLOR
Definition: vssym32.h:138
HRESULT WINAPI GetThemeTransitionDuration(HTHEME hTheme, int iPartId, int iStateIdFrom, int iStateIdTo, int iPropId, DWORD *pdwDuration)
Definition: metric.c:227
#define SM_CXSIZE
Definition: winuser.h:981
HRESULT WINAPI GetThemeSysString(HTHEME hTheme, int iStringID, LPWSTR pszStringBuff, int cchMaxStringChars)
Definition: metric.c:205
HRESULT MSSTYLES_GetPropertyString(PTHEME_PROPERTY tp, LPWSTR pszBuff, int cchMaxBuffChars)
Definition: msstyles.c:1140
#define TMT_SMCAPTIONBARWIDTH
Definition: vssym32.h:183
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define TMT_SMALLCAPTIONFONT
Definition: vssym32.h:165
BOOL WINAPI GetThemeSysBool(HTHEME hTheme, int iBoolID)
Definition: metric.c:26
#define TMT_LASTSTRING
Definition: tmschema.h:202
#define TMT_SIZINGBORDERWIDTH
Definition: vssym32.h:178
struct _THEME_FILE * tf
Definition: uxthemep.h:59
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define TMT_STATUSFONT
Definition: vssym32.h:167
#define TMT_SIZE
Definition: vssym32.h:141
#define SM_CXMENUSIZE
Definition: winuser.h:1007