Sweden-Number/dlls/uxtheme/property.c

296 lines
9.8 KiB
C
Raw Normal View History

2003-12-04 21:55:30 +01:00
/*
* Win32 5.1 Theme properties
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
2003-12-04 21:55:30 +01:00
*/
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "wingdi.h"
#include "vfwmsgs.h"
2003-12-04 21:55:30 +01:00
#include "uxtheme.h"
#include "tmschema.h"
2003-12-04 21:55:30 +01:00
#include "msstyles.h"
2003-12-04 21:55:30 +01:00
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(uxtheme);
/***********************************************************************
* GetThemeBool (UXTHEME.@)
*/
HRESULT WINAPI GetThemeBool(HTHEME hTheme, int iPartId, int iStateId,
int iPropId, BOOL *pfVal)
{
PTHEME_PROPERTY tp;
TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
2003-12-04 21:55:30 +01:00
if(!hTheme)
return E_HANDLE;
if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_BOOL, iPropId)))
return E_PROP_ID_UNSUPPORTED;
2004-02-20 06:12:21 +01:00
return MSSTYLES_GetPropertyBool(tp, pfVal);
2003-12-04 21:55:30 +01:00
}
/***********************************************************************
* GetThemeColor (UXTHEME.@)
*/
HRESULT WINAPI GetThemeColor(HTHEME hTheme, int iPartId, int iStateId,
int iPropId, COLORREF *pColor)
{
PTHEME_PROPERTY tp;
TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
2003-12-04 21:55:30 +01:00
if(!hTheme)
return E_HANDLE;
if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_COLOR, iPropId)))
return E_PROP_ID_UNSUPPORTED;
2004-02-20 06:12:21 +01:00
return MSSTYLES_GetPropertyColor(tp, pColor);
2003-12-04 21:55:30 +01:00
}
/***********************************************************************
* GetThemeEnumValue (UXTHEME.@)
*/
HRESULT WINAPI GetThemeEnumValue(HTHEME hTheme, int iPartId, int iStateId,
int iPropId, int *piVal)
{
2004-02-20 06:12:21 +01:00
HRESULT hr;
WCHAR val[60];
PTHEME_PROPERTY tp;
TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
2003-12-04 21:55:30 +01:00
if(!hTheme)
return E_HANDLE;
if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_ENUM, iPropId)))
return E_PROP_ID_UNSUPPORTED;
2004-02-20 06:12:21 +01:00
hr = MSSTYLES_GetPropertyString(tp, val, ARRAY_SIZE(val));
2004-02-20 06:12:21 +01:00
if(FAILED(hr))
return hr;
if(!MSSTYLES_LookupEnum(val, iPropId, piVal))
return E_PROP_ID_UNSUPPORTED;
return S_OK;
2003-12-04 21:55:30 +01:00
}
/***********************************************************************
* GetThemeFilename (UXTHEME.@)
*/
HRESULT WINAPI GetThemeFilename(HTHEME hTheme, int iPartId, int iStateId,
int iPropId, LPWSTR pszThemeFilename,
int cchMaxBuffChars)
{
PTHEME_PROPERTY tp;
TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
2003-12-04 21:55:30 +01:00
if(!hTheme)
return E_HANDLE;
if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_FILENAME, iPropId)))
return E_PROP_ID_UNSUPPORTED;
2004-02-20 06:12:21 +01:00
return MSSTYLES_GetPropertyString(tp, pszThemeFilename, cchMaxBuffChars);
2003-12-04 21:55:30 +01:00
}
/***********************************************************************
* GetThemeFont (UXTHEME.@)
*/
HRESULT WINAPI GetThemeFont(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, int iPropId, LOGFONTW *pFont)
{
PTHEME_PROPERTY tp;
TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
2003-12-04 21:55:30 +01:00
if(!hTheme)
return E_HANDLE;
if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_FONT, iPropId)))
return E_PROP_ID_UNSUPPORTED;
2004-02-20 06:12:21 +01:00
return MSSTYLES_GetPropertyFont(tp, hdc, pFont);
2003-12-04 21:55:30 +01:00
}
/***********************************************************************
* GetThemeInt (UXTHEME.@)
*/
HRESULT WINAPI GetThemeInt(HTHEME hTheme, int iPartId, int iStateId,
int iPropId, int *piVal)
{
PTHEME_PROPERTY tp;
TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
2003-12-04 21:55:30 +01:00
if(!hTheme)
return E_HANDLE;
if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_INT, iPropId)))
return E_PROP_ID_UNSUPPORTED;
2004-02-20 06:12:21 +01:00
return MSSTYLES_GetPropertyInt(tp, piVal);
2003-12-04 21:55:30 +01:00
}
/***********************************************************************
* GetThemeIntList (UXTHEME.@)
*/
HRESULT WINAPI GetThemeIntList(HTHEME hTheme, int iPartId, int iStateId,
int iPropId, INTLIST *pIntList)
{
PTHEME_PROPERTY tp;
TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
2003-12-04 21:55:30 +01:00
if(!hTheme)
return E_HANDLE;
if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_INTLIST, iPropId)))
return E_PROP_ID_UNSUPPORTED;
2004-02-20 06:12:21 +01:00
return MSSTYLES_GetPropertyIntList(tp, pIntList);
2003-12-04 21:55:30 +01:00
}
/***********************************************************************
* GetThemePosition (UXTHEME.@)
*/
HRESULT WINAPI GetThemePosition(HTHEME hTheme, int iPartId, int iStateId,
int iPropId, POINT *pPoint)
{
PTHEME_PROPERTY tp;
TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
2003-12-04 21:55:30 +01:00
if(!hTheme)
return E_HANDLE;
if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_POSITION, iPropId)))
return E_PROP_ID_UNSUPPORTED;
2004-02-20 06:12:21 +01:00
return MSSTYLES_GetPropertyPosition(tp, pPoint);
2003-12-04 21:55:30 +01:00
}
/***********************************************************************
* GetThemeRect (UXTHEME.@)
*/
HRESULT WINAPI GetThemeRect(HTHEME hTheme, int iPartId, int iStateId,
int iPropId, RECT *pRect)
{
PTHEME_PROPERTY tp;
TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
2003-12-04 21:55:30 +01:00
if(!hTheme)
return E_HANDLE;
if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_RECT, iPropId)))
return E_PROP_ID_UNSUPPORTED;
2004-02-20 06:12:21 +01:00
return MSSTYLES_GetPropertyRect(tp, pRect);
2003-12-04 21:55:30 +01:00
}
/***********************************************************************
* GetThemeString (UXTHEME.@)
*/
HRESULT WINAPI GetThemeString(HTHEME hTheme, int iPartId, int iStateId,
int iPropId, LPWSTR pszBuff, int cchMaxBuffChars)
{
PTHEME_PROPERTY tp;
TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
2003-12-04 21:55:30 +01:00
if(!hTheme)
return E_HANDLE;
if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_STRING, iPropId)))
return E_PROP_ID_UNSUPPORTED;
2004-02-20 06:12:21 +01:00
return MSSTYLES_GetPropertyString(tp, pszBuff, cchMaxBuffChars);
2003-12-04 21:55:30 +01:00
}
/***********************************************************************
* GetThemeMargins (UXTHEME.@)
*/
HRESULT WINAPI GetThemeMargins(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, int iPropId, RECT *prc,
MARGINS *pMargins)
{
PTHEME_PROPERTY tp;
TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
memset (pMargins, 0, sizeof (MARGINS));
2003-12-04 21:55:30 +01:00
if(!hTheme)
return E_HANDLE;
if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_MARGINS, iPropId)))
return E_PROP_ID_UNSUPPORTED;
2004-02-20 06:12:21 +01:00
return MSSTYLES_GetPropertyMargins(tp, prc, pMargins);
2003-12-04 21:55:30 +01:00
}
/***********************************************************************
* GetThemeMetric (UXTHEME.@)
*/
HRESULT WINAPI GetThemeMetric(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, int iPropId, int *piVal)
{
2004-02-20 06:12:21 +01:00
PTHEME_PROPERTY tp;
WCHAR val[60];
HRESULT hr;
TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
2003-12-04 21:55:30 +01:00
if(!hTheme)
return E_HANDLE;
2004-02-20 06:12:21 +01:00
if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, 0, iPropId)))
return E_PROP_ID_UNSUPPORTED;
switch(tp->iPrimitiveType) {
case TMT_POSITION: /* Only the X coord is retrieved */
case TMT_MARGINS: /* Only the cxLeftWidth member is retrieved */
case TMT_INTLIST: /* Only the first int is retrieved */
case TMT_SIZE:
case TMT_INT:
return MSSTYLES_GetPropertyInt(tp, piVal);
case TMT_BOOL:
return MSSTYLES_GetPropertyBool(tp, piVal);
case TMT_COLOR:
return MSSTYLES_GetPropertyColor(tp, (COLORREF*)piVal);
case TMT_ENUM:
hr = MSSTYLES_GetPropertyString(tp, val, ARRAY_SIZE(val));
2004-02-20 06:12:21 +01:00
if(FAILED(hr))
return hr;
if(!MSSTYLES_LookupEnum(val, iPropId, piVal))
return E_PROP_ID_UNSUPPORTED;
return S_OK;
case TMT_FILENAME:
/* Windows does return a value for this, but its value doesn't make sense */
FIXME("Filename\n");
break;
}
return E_PROP_ID_UNSUPPORTED;
2003-12-04 21:55:30 +01:00
}
/***********************************************************************
* GetThemePropertyOrigin (UXTHEME.@)
*/
HRESULT WINAPI GetThemePropertyOrigin(HTHEME hTheme, int iPartId, int iStateId,
int iPropId, PROPERTYORIGIN *pOrigin)
{
PTHEME_PROPERTY tp;
TRACE("(%d, %d, %d)\n", iPartId, iStateId, iPropId);
2003-12-04 21:55:30 +01:00
if(!hTheme)
return E_HANDLE;
if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, 0, iPropId))) {
*pOrigin = PO_NOTFOUND;
return S_OK;
}
*pOrigin = tp->origin;
return S_OK;
2003-12-04 21:55:30 +01:00
}