2005-07-03 18:32:22 +00:00
|
|
|
/*
|
|
|
|
* Win32 5.1 Theme metrics
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003 Kevin Koltzau
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-07-21 13:07:57 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-07-03 18:32:22 +00:00
|
|
|
*/
|
|
|
|
|
2011-09-20 13:08:36 +00:00
|
|
|
#include "uxthemep.h"
|
2005-07-03 18:32:22 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetThemeSysBool (UXTHEME.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetThemeSysBool(HTHEME hTheme, int iBoolID)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
PTHEME_PROPERTY tp;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
TRACE("(%p, %d)\n", hTheme, iBoolID);
|
|
|
|
SetLastError(0);
|
|
|
|
if(hTheme) {
|
2013-04-22 16:46:43 +00:00
|
|
|
PTHEME_CLASS ptc = (PTHEME_CLASS) hTheme;
|
|
|
|
|
|
|
|
if((tp = MSSTYLES_FindMetric(ptc->tf, TMT_BOOL, iBoolID))) {
|
2005-07-03 18:32:22 +00:00
|
|
|
hr = MSSTYLES_GetPropertyBool(tp, &ret);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
return ret;
|
|
|
|
else
|
|
|
|
SetLastError(hr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(iBoolID == TMT_FLATMENUS) {
|
|
|
|
if(SystemParametersInfoW(SPI_GETFLATMENU, 0, &ret, 0))
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
FIXME("Unknown bool id: %d\n", iBoolID);
|
|
|
|
SetLastError(STG_E_INVALIDPARAMETER);
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetThemeSysColor (UXTHEME.@)
|
|
|
|
*/
|
|
|
|
COLORREF WINAPI GetThemeSysColor(HTHEME hTheme, int iColorID)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
PTHEME_PROPERTY tp;
|
|
|
|
|
2013-04-22 16:46:43 +00:00
|
|
|
// TODO: Check if this is correct
|
|
|
|
if ( iColorID >= 0 && iColorID < 32)
|
|
|
|
iColorID += TMT_SCROLLBAR;
|
|
|
|
|
2005-07-03 18:32:22 +00:00
|
|
|
TRACE("(%p, %d)\n", hTheme, iColorID);
|
|
|
|
SetLastError(0);
|
|
|
|
if(hTheme) {
|
2013-04-22 16:46:43 +00:00
|
|
|
PTHEME_CLASS ptc = (PTHEME_CLASS) hTheme;
|
|
|
|
if((tp = MSSTYLES_FindMetric(ptc->tf, TMT_COLOR, iColorID))) {
|
2005-07-03 18:32:22 +00:00
|
|
|
COLORREF color;
|
|
|
|
hr = MSSTYLES_GetPropertyColor(tp, &color);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
return color;
|
|
|
|
else
|
|
|
|
SetLastError(hr);
|
|
|
|
}
|
|
|
|
}
|
2012-05-23 23:04:23 +00:00
|
|
|
return GetSysColor(iColorID);
|
2005-07-03 18:32:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetThemeSysColorBrush (UXTHEME.@)
|
|
|
|
*/
|
|
|
|
HBRUSH WINAPI GetThemeSysColorBrush(HTHEME hTheme, int iColorID)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %d)\n", hTheme, iColorID);
|
|
|
|
return CreateSolidBrush(GetThemeSysColor(hTheme, iColorID));
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetThemeSysFont (UXTHEME.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI GetThemeSysFont(HTHEME hTheme, int iFontID, LOGFONTW *plf)
|
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
PTHEME_PROPERTY tp;
|
|
|
|
|
|
|
|
TRACE("(%p, %d)\n", hTheme, iFontID);
|
|
|
|
if(hTheme) {
|
2013-04-22 16:46:43 +00:00
|
|
|
PTHEME_CLASS ptc = (PTHEME_CLASS) hTheme;
|
|
|
|
if((tp = MSSTYLES_FindMetric(ptc->tf, TMT_FONT, iFontID))) {
|
2005-07-03 18:32:22 +00:00
|
|
|
HDC hdc = GetDC(NULL);
|
|
|
|
hr = MSSTYLES_GetPropertyFont(tp, hdc, plf);
|
|
|
|
ReleaseDC(NULL, hdc);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(iFontID == TMT_ICONTITLEFONT) {
|
2012-05-23 23:04:23 +00:00
|
|
|
if(!SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(LOGFONTW), plf, 0))
|
2005-07-03 18:32:22 +00:00
|
|
|
return HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NONCLIENTMETRICSW ncm;
|
|
|
|
LOGFONTW *font = NULL;
|
|
|
|
ncm.cbSize = sizeof(NONCLIENTMETRICSW);
|
|
|
|
if(!SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSW), &ncm, 0))
|
|
|
|
return HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
switch(iFontID) {
|
|
|
|
case TMT_CAPTIONFONT: font = &ncm.lfCaptionFont; break;
|
|
|
|
case TMT_SMALLCAPTIONFONT: font = &ncm.lfSmCaptionFont; break;
|
|
|
|
case TMT_MENUFONT: font = &ncm.lfMenuFont; break;
|
|
|
|
case TMT_STATUSFONT: font = &ncm.lfStatusFont; break;
|
|
|
|
case TMT_MSGBOXFONT: font = &ncm.lfMessageFont; break;
|
|
|
|
default: FIXME("Unknown FontID: %d\n", iFontID); break;
|
|
|
|
}
|
2008-04-04 14:43:57 +00:00
|
|
|
if(font) *plf = *font;
|
2005-07-03 18:32:22 +00:00
|
|
|
else hr = STG_E_INVALIDPARAMETER;
|
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetThemeSysInt (UXTHEME.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI GetThemeSysInt(HTHEME hTheme, int iIntID, int *piValue)
|
|
|
|
{
|
|
|
|
PTHEME_PROPERTY tp;
|
2013-04-22 16:46:43 +00:00
|
|
|
PTHEME_CLASS ptc = (PTHEME_CLASS) hTheme;
|
2005-07-03 18:32:22 +00:00
|
|
|
|
|
|
|
TRACE("(%p, %d)\n", hTheme, iIntID);
|
|
|
|
if(!hTheme)
|
|
|
|
return E_HANDLE;
|
2006-07-21 13:07:57 +00:00
|
|
|
if(iIntID < TMT_FIRSTINT || iIntID > TMT_LASTINT) {
|
|
|
|
WARN("Unknown IntID: %d\n", iIntID);
|
2005-07-03 18:32:22 +00:00
|
|
|
return STG_E_INVALIDPARAMETER;
|
|
|
|
}
|
2013-04-22 16:46:43 +00:00
|
|
|
if((tp = MSSTYLES_FindMetric(ptc->tf , TMT_INT, iIntID)))
|
2005-07-03 18:32:22 +00:00
|
|
|
return MSSTYLES_GetPropertyInt(tp, piValue);
|
|
|
|
return E_PROP_ID_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetThemeSysSize (UXTHEME.@)
|
|
|
|
*/
|
|
|
|
int WINAPI GetThemeSysSize(HTHEME hTheme, int iSizeID)
|
|
|
|
{
|
|
|
|
PTHEME_PROPERTY tp;
|
|
|
|
int i, id = -1;
|
|
|
|
int metricMap[] = {
|
|
|
|
SM_CXVSCROLL, TMT_SCROLLBARWIDTH,
|
|
|
|
SM_CYHSCROLL, TMT_SCROLLBARHEIGHT,
|
|
|
|
SM_CXSIZE, TMT_CAPTIONBARWIDTH,
|
|
|
|
SM_CYSIZE, TMT_CAPTIONBARHEIGHT,
|
|
|
|
SM_CXFRAME, TMT_SIZINGBORDERWIDTH,
|
|
|
|
SM_CYFRAME, TMT_SIZINGBORDERWIDTH, /* There is no TMT_SIZINGBORDERHEIGHT, but this works in windows.. */
|
|
|
|
SM_CXSMSIZE, TMT_SMCAPTIONBARWIDTH,
|
|
|
|
SM_CYSMSIZE, TMT_SMCAPTIONBARHEIGHT,
|
|
|
|
SM_CXMENUSIZE, TMT_MENUBARWIDTH,
|
|
|
|
SM_CYMENUSIZE, TMT_MENUBARHEIGHT
|
|
|
|
};
|
|
|
|
|
|
|
|
if(hTheme) {
|
2013-04-22 16:46:43 +00:00
|
|
|
PTHEME_CLASS ptc = (PTHEME_CLASS) hTheme;
|
|
|
|
|
2005-07-03 18:32:22 +00:00
|
|
|
for(i=0; i<sizeof(metricMap)/sizeof(metricMap[0]); i+=2) {
|
|
|
|
if(metricMap[i] == iSizeID) {
|
|
|
|
id = metricMap[i+1];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetLastError(0);
|
|
|
|
if(id != -1) {
|
2013-04-22 16:46:43 +00:00
|
|
|
if((tp = MSSTYLES_FindMetric(ptc->tf, TMT_SIZE, id))) {
|
2005-07-03 18:32:22 +00:00
|
|
|
if(SUCCEEDED(MSSTYLES_GetPropertyInt(tp, &i))) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE("Size %d not found in theme, using system metric\n", iSizeID);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
SetLastError(STG_E_INVALIDPARAMETER);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2013-04-22 16:46:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
// TODO: Check if this is correct
|
|
|
|
// In windows for SM_CXFRAME this function returns what seems to be the non client metric iBorderWidth
|
|
|
|
if (iSizeID == SM_CXFRAME)
|
|
|
|
return GetSystemMetrics(SM_CXFRAME) - GetSystemMetrics(SM_CXDLGFRAME);
|
2005-07-03 18:32:22 +00:00
|
|
|
return GetSystemMetrics(iSizeID);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetThemeSysString (UXTHEME.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI GetThemeSysString(HTHEME hTheme, int iStringID,
|
|
|
|
LPWSTR pszStringBuff, int cchMaxStringChars)
|
|
|
|
{
|
|
|
|
PTHEME_PROPERTY tp;
|
2013-04-22 16:46:43 +00:00
|
|
|
PTHEME_CLASS ptc = (PTHEME_CLASS) hTheme;
|
2005-07-03 18:32:22 +00:00
|
|
|
|
|
|
|
TRACE("(%p, %d)\n", hTheme, iStringID);
|
|
|
|
if(!hTheme)
|
|
|
|
return E_HANDLE;
|
2006-07-21 13:07:57 +00:00
|
|
|
if(iStringID < TMT_FIRSTSTRING || iStringID > TMT_LASTSTRING) {
|
|
|
|
WARN("Unknown StringID: %d\n", iStringID);
|
2005-07-03 18:32:22 +00:00
|
|
|
return STG_E_INVALIDPARAMETER;
|
|
|
|
}
|
2013-04-22 16:46:43 +00:00
|
|
|
if((tp = MSSTYLES_FindMetric(ptc->tf, TMT_STRING, iStringID)))
|
2005-07-03 18:32:22 +00:00
|
|
|
return MSSTYLES_GetPropertyString(tp, pszStringBuff, cchMaxStringChars);
|
|
|
|
return E_PROP_ID_UNSUPPORTED;
|
|
|
|
}
|