From: Rémi Bernon rbernon@codeweavers.com
--- dlls/uxtheme/msstyles.c | 6 ++++++ dlls/uxtheme/msstyles.h | 24 +++++++++++++++++++++- dlls/uxtheme/property.c | 8 ++++---- dlls/uxtheme/stylemap.c | 45 ++++++++++++++++++----------------------- 4 files changed, 53 insertions(+), 30 deletions(-)
diff --git a/dlls/uxtheme/msstyles.c b/dlls/uxtheme/msstyles.c index cfd21a48989..4dcd87d3d0b 100644 --- a/dlls/uxtheme/msstyles.c +++ b/dlls/uxtheme/msstyles.c @@ -1435,6 +1435,12 @@ HRESULT MSSTYLES_GetPropertyString(PTHEME_PROPERTY tp, LPWSTR pszBuff, int cchMa return S_OK; }
+HRESULT MSSTYLES_GetPropertyStringUpper(PTHEME_PROPERTY tp, LPWSTR pszBuff, int cchMaxBuffChars) +{ + strupperW(pszBuff, tp->lpValue, min(tp->dwValueLen+1, cchMaxBuffChars)); + return S_OK; +} + /*********************************************************************** * MSSTYLES_GetPropertyRect * diff --git a/dlls/uxtheme/msstyles.h b/dlls/uxtheme/msstyles.h index 98e1aa045d6..2c75f7b00aa 100644 --- a/dlls/uxtheme/msstyles.h +++ b/dlls/uxtheme/msstyles.h @@ -21,6 +21,8 @@ #ifndef __WINE_MSSTYLES_H #define __WINE_MSSTYLES_H
+#include "winternl.h" + #define TMT_ENUM 200
#define MAX_THEME_APP_NAME 60 @@ -93,7 +95,7 @@ HRESULT MSSTYLES_SetActiveTheme(PTHEME_FILE tf, BOOL setMetrics) DECLSPEC_HIDDEN PTHEME_CLASS MSSTYLES_OpenThemeClass(LPCWSTR pszAppName, LPCWSTR pszClassList, UINT dpi) DECLSPEC_HIDDEN; HRESULT MSSTYLES_CloseThemeClass(PTHEME_CLASS tc) DECLSPEC_HIDDEN; BOOL MSSTYLES_LookupProperty(LPCWSTR pszPropertyName, int *dwPrimitive, int *dwId) DECLSPEC_HIDDEN; -BOOL MSSTYLES_LookupEnum(LPCWSTR pszValueName, int dwEnum, int *dwValue) DECLSPEC_HIDDEN; +BOOL MSSTYLES_LookupEnum(const WCHAR *enum_name, int enum_type, int *enum_value) DECLSPEC_HIDDEN; BOOL MSSTYLES_LookupPartState(LPCWSTR pszClass, LPCWSTR pszPart, LPCWSTR pszState, int *iPartId, int *iStateId) DECLSPEC_HIDDEN; PUXINI_FILE MSSTYLES_GetThemeIni(PTHEME_FILE tf) DECLSPEC_HIDDEN; UINT MSSTYLES_GetThemeDPI(PTHEME_CLASS tc) DECLSPEC_HIDDEN; @@ -110,6 +112,7 @@ HRESULT MSSTYLES_GetPropertyInt(PTHEME_PROPERTY tp, int *piVal) DECLSPEC_HIDDEN; HRESULT MSSTYLES_GetPropertyIntList(PTHEME_PROPERTY tp, INTLIST *pIntList) DECLSPEC_HIDDEN; HRESULT MSSTYLES_GetPropertyPosition(PTHEME_PROPERTY tp, POINT *pPoint) DECLSPEC_HIDDEN; HRESULT MSSTYLES_GetPropertyString(PTHEME_PROPERTY tp, LPWSTR pszBuff, int cchMaxBuffChars) DECLSPEC_HIDDEN; +HRESULT MSSTYLES_GetPropertyStringUpper(PTHEME_PROPERTY tp, LPWSTR pszBuff, int cchMaxBuffChars) DECLSPEC_HIDDEN; HRESULT MSSTYLES_GetPropertyRect(PTHEME_PROPERTY tp, RECT *pRect) DECLSPEC_HIDDEN; HRESULT MSSTYLES_GetPropertyMargins(PTHEME_PROPERTY tp, RECT *prc, MARGINS *pMargins) DECLSPEC_HIDDEN;
@@ -120,4 +123,23 @@ BOOL UXINI_FindSection(PUXINI_FILE uf, LPCWSTR lpName) DECLSPEC_HIDDEN; LPCWSTR UXINI_GetNextValue(PUXINI_FILE uf, DWORD *dwNameLen, LPCWSTR *lpValue, DWORD *dwValueLen) DECLSPEC_HIDDEN; BOOL UXINI_FindValue(PUXINI_FILE uf, LPCWSTR lpName, LPCWSTR *lpValue, DWORD *dwValueLen) DECLSPEC_HIDDEN;
+static inline WCHAR toupperW(WCHAR c) +{ + if (c >= 'a' && c <= 'z') return c - 'a' + 'A'; + else if (c > 127) return RtlUpcaseUnicodeChar(c); + else return c; +} + +static inline WCHAR *strupperW(WCHAR *dst, const WCHAR *src, DWORD count) +{ + WCHAR *d = dst; + while ((count > 1) && *src) + { + count--; + *d++ = toupperW(*src++); + } + if (count) *d = 0; + return dst; +} + #endif diff --git a/dlls/uxtheme/property.c b/dlls/uxtheme/property.c index 188f13836e2..13b3d576393 100644 --- a/dlls/uxtheme/property.c +++ b/dlls/uxtheme/property.c @@ -85,10 +85,10 @@ HRESULT WINAPI GetThemeEnumValue(HTHEME hTheme, int iPartId, int iStateId, if(!(tp = MSSTYLES_FindProperty(hTheme, iPartId, iStateId, TMT_ENUM, iPropId))) return E_PROP_ID_UNSUPPORTED;
- hr = MSSTYLES_GetPropertyString(tp, val, ARRAY_SIZE(val)); + hr = MSSTYLES_GetPropertyStringUpper(tp, val, ARRAY_SIZE(val)); if(FAILED(hr)) return hr; - if(!MSSTYLES_LookupEnum(val, iPropId, piVal)) + if (!MSSTYLES_LookupEnum(val, iPropId, piVal)) return E_PROP_ID_UNSUPPORTED; return S_OK; } @@ -260,10 +260,10 @@ HRESULT WINAPI GetThemeMetric(HTHEME hTheme, HDC hdc, int iPartId, case TMT_COLOR: return MSSTYLES_GetPropertyColor(tp, (COLORREF*)piVal); case TMT_ENUM: - hr = MSSTYLES_GetPropertyString(tp, val, ARRAY_SIZE(val)); + hr = MSSTYLES_GetPropertyStringUpper(tp, val, ARRAY_SIZE(val)); if(FAILED(hr)) return hr; - if(!MSSTYLES_LookupEnum(val, iPropId, piVal)) + if (!MSSTYLES_LookupEnum(val, iPropId, piVal)) return E_PROP_ID_UNSUPPORTED; return S_OK; case TMT_FILENAME: diff --git a/dlls/uxtheme/stylemap.c b/dlls/uxtheme/stylemap.c index e1973305076..6fdf7f894ce 100644 --- a/dlls/uxtheme/stylemap.c +++ b/dlls/uxtheme/stylemap.c @@ -35,11 +35,12 @@ typedef struct _MSSTYLES_PROPERTY_MAP { WCHAR szPropertyName[24]; } MSSTYLES_PROPERTY_MAP, *PMSSTYLES_PROPERTY_MAP;
-typedef struct _MSSTYLES_ENUM_MAP { - WORD dwEnum; - WORD dwValue; - WCHAR szValueName[18]; -} MSSTYLES_ENUM_MAP, *PMSSTYLES_ENUM_MAP; +struct enum_desc +{ + WORD enum_type; + WORD enum_value; + WCHAR enum_name[18]; +};
typedef struct _MSSTYLES_CLASS_MAP { WORD dwPartID; @@ -266,7 +267,8 @@ static const MSSTYLES_PROPERTY_MAP mapProperty[] = { * Map strings to enumeration values * Enum,Value,ValueName */ -static const MSSTYLES_ENUM_MAP mapEnum[] = { +static const struct enum_desc enum_descs[] = +{ {TMT_BGTYPE, BT_IMAGEFILE, L"IMAGEFILE"}, {TMT_BGTYPE, BT_BORDERFILL, L"BORDERFILL"}, {TMT_BGTYPE, BT_NONE, L"NONE"}, @@ -1511,31 +1513,24 @@ BOOL MSSTYLES_LookupProperty(LPCWSTR pszPropertyName, int *dwPrimitive, int *dwI return FALSE; }
-/********************************************************************** - * MSSTYLES_LookupEnum - * - * Lookup the value for an enumeration - * - * PARAMS - * pszValueName Value name to lookup - * dwEnum Enumeration property ID to search - * dwValue Location to store value - * - * RETURNS - * FALSE if value is not found, TRUE otherwise - */ -BOOL MSSTYLES_LookupEnum(LPCWSTR pszValueName, int dwEnum, int *dwValue) +/* enum_name must be upper case */ +BOOL MSSTYLES_LookupEnum(const WCHAR *enum_name, int enum_type, int *enum_value) { - DWORD item = 0; + const struct enum_desc *item = enum_descs; + /* Locate the enum block */ - while(*mapEnum[item].szValueName && mapEnum[item].dwEnum != dwEnum) item++; + while (*item->enum_name && item->enum_type != enum_type) item++; + /* Now find the value in that block */ - while(*mapEnum[item].szValueName && mapEnum[item].dwEnum == dwEnum) { - if(!lstrcmpiW(mapEnum[item].szValueName, pszValueName)) { - if(dwValue) *dwValue = mapEnum[item].dwValue; + while (*item->enum_name && item->enum_type == enum_type) + { + if (!wcscmp(item->enum_name, enum_name)) + { + if (enum_value) *enum_value = item->enum_value; return TRUE; } item++; } + return FALSE; }