Commit 5e8a34f1 authored by Kevin Koltzau's avatar Kevin Koltzau Committed by Alexandre Julliard

Full implementation of OpenThemeData, CloseThemeData, and

IsThemePartDefined Export undocumented functions by ordinal only (to match Microsoft's uxtheme).
parent 5e86e9d5
......@@ -23,6 +23,26 @@
#define TMT_ENUM 200
#define MAX_THEME_APP_NAME 60
#define MAX_THEME_CLASS_NAME 60
typedef struct _THEME_PARTSTATE {
int iPartId;
int iStateId;
/* TODO: define part/state properties */
struct _THEME_PARTSTATE *next;
} THEME_PARTSTATE, *PTHEME_PARTSTATE;
typedef struct _THEME_CLASS {
WCHAR szAppName[MAX_THEME_APP_NAME];
WCHAR szClassName[MAX_THEME_CLASS_NAME];
PTHEME_PARTSTATE partstate;
struct _THEME_CLASS *overrides;
struct _THEME_CLASS *next;
} THEME_CLASS, *PTHEME_CLASS;
typedef struct _THEME_FILE {
DWORD dwRefCount;
HMODULE hTheme;
......@@ -31,11 +51,9 @@ typedef struct _THEME_FILE {
LPWSTR pszSelectedColor;
LPWSTR pszSelectedSize;
} THEME_FILE, *PTHEME_FILE;
typedef struct _THEME_CLASS {
/* TODO */
} THEME_CLASS, *PTHEME_CLASS;
PTHEME_CLASS classes;
} THEME_FILE, *PTHEME_FILE;
typedef struct _UXINI_FILE {
LPCWSTR lpIni;
......@@ -46,10 +64,14 @@ typedef struct _UXINI_FILE {
HRESULT MSSTYLES_OpenThemeFile(LPCWSTR lpThemeFile, LPCWSTR pszColorName, LPCWSTR pszSizeName, PTHEME_FILE *tf);
void MSSTYLES_CloseThemeFile(PTHEME_FILE tf);
HRESULT MSSTYLES_SetActiveTheme(PTHEME_FILE tf);
PTHEME_CLASS MSSTYLES_OpenThemeClass(LPCWSTR pszClassList);
PTHEME_CLASS MSSTYLES_OpenThemeClass(LPCWSTR pszAppName, LPCWSTR pszClassList);
HRESULT MSSTYLES_CloseThemeClass(PTHEME_CLASS tc);
BOOL MSSTYLES_LookupProperty(LPCWSTR pszPropertyName, DWORD *dwPrimitive, DWORD *dwId);
BOOL MSSTYLES_LookupEnum(LPCWSTR pszValueName, DWORD dwEnum, DWORD *dwValue);
BOOL MSSTYLES_LookupPartState(LPCWSTR pszClass, LPCWSTR pszPart, LPCWSTR pszState, int *iPartId, int *iStateId);
PUXINI_FILE MSSTYLES_GetThemeIni(PTHEME_FILE tf);
PTHEME_PARTSTATE MSSTYLES_FindPartState(PTHEME_CLASS tc, int iPartId, int iStateId);
PTHEME_CLASS MSSTYLES_FindClass(PTHEME_FILE tf, LPCWSTR pszAppName, LPCWSTR pszClassName);
PUXINI_FILE UXINI_LoadINI(PTHEME_FILE tf, LPCWSTR lpName);
void UXINI_CloseINI(PUXINI_FILE uf);
......
......@@ -29,6 +29,10 @@
#include "msstyles.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(uxtheme);
typedef struct _MSSTYLES_PROPERTY_MAP {
WORD dwPrimitiveType;
WORD dwPropertyID;
......@@ -1045,6 +1049,54 @@ static const MSSTYLES_CLASS_NAME mapClass[] = {
{classWindow, {'W','I','N','D','O','W','\0'}}
};
BOOL MSSTYLES_LookupPartState(LPCWSTR pszClass, LPCWSTR pszPart, LPCWSTR pszState, int *iPartId, int *iStateId)
{
int i;
const MSSTYLES_CLASS_MAP *map;
*iPartId = 0;
*iStateId = 0;
for(i=0; i<sizeof(mapClass)/sizeof(mapClass[0]); i++) {
if(!lstrcmpiW(mapClass[i].pszClass, pszClass)) {
map = mapClass[i].lpMap;
if(pszPart) {
do {
if(map->dwStateID == 0 && !lstrcmpiW(map->szName, pszPart)) {
*iPartId = map->dwPartID;
break;
}
} while(*((++map)->szName));
}
if(pszState) {
if(pszPart && *iPartId == 0) {
break;
}
do {
if(pszPart) {
if(map->dwPartID == *iPartId && !lstrcmpiW(map->szName, pszState)) {
*iStateId = map->dwStateID;
break;
}
}
else {
if(!lstrcmpiW(map->szName, pszState)) {
*iStateId = map->dwStateID;
break;
}
}
} while(*((++map)->szName));
}
break;
}
}
if(pszPart && *iPartId == 0) {
return FALSE;
}
if(pszState && *iStateId == 0) {
return FALSE;
}
return TRUE;
}
/**********************************************************************
* MSSTYLES_LookupProperty
......
......@@ -246,17 +246,62 @@ HRESULT WINAPI EnableTheming(BOOL fEnable)
}
/***********************************************************************
* UXTHEME_SetWindowProperty
*
* I'm using atoms as there may be large numbers of duplicated strings
* and they do the work of keeping memory down as a cause of that quite nicely
*/
HRESULT UXTHEME_SetWindowProperty(HWND hwnd, ATOM aProp, LPCWSTR pszValue)
{
ATOM oldValue = (ATOM)(size_t)RemovePropW(hwnd, MAKEINTATOMW(aProp));
if(oldValue)
DeleteAtom(oldValue);
if(pszValue) {
ATOM atValue = AddAtomW(pszValue);
if(!atValue
|| !SetPropW(hwnd, MAKEINTATOMW(aProp), (LPWSTR)MAKEINTATOMW(atValue))) {
HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
if(atValue) DeleteAtom(atValue);
return hr;
}
}
return S_OK;
}
LPWSTR UXTHEME_GetWindowProperty(HWND hwnd, ATOM aProp, LPWSTR pszBuffer, int dwLen)
{
ATOM atValue = (ATOM)(size_t)GetPropW(hwnd, MAKEINTATOMW(aProp));
if(atValue) {
if(GetAtomNameW(atValue, pszBuffer, dwLen))
return pszBuffer;
TRACE("property defined, but unable to get value\n");
}
return NULL;
}
/***********************************************************************
* OpenThemeData (UXTHEME.@)
*/
HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR pszClassList)
{
WCHAR szAppBuff[256];
WCHAR szClassBuff[256];
LPCWSTR pszAppName;
LPCWSTR pszUseClassList;
HTHEME hTheme;
TRACE("(%p,%s)\n", hwnd, debugstr_w(pszClassList));
if(!bThemeActive)
return NULL;
hTheme = MSSTYLES_OpenThemeClass(pszClassList);
pszAppName = UXTHEME_GetWindowProperty(hwnd, atSubAppName, szAppBuff, sizeof(szAppBuff)/sizeof(szAppBuff[0]));
/* If SetWindowTheme was used on the window, that overrides the class list passed to this function */
pszUseClassList = UXTHEME_GetWindowProperty(hwnd, atSubIdList, szClassBuff, sizeof(szClassBuff)/sizeof(szClassBuff[0]));
if(!pszUseClassList)
pszUseClassList = pszClassList;
hTheme = MSSTYLES_OpenThemeClass(pszAppName, pszUseClassList);
if(IsWindow(hwnd))
SetPropW(hwnd, MAKEINTATOMW(atWindowTheme), hTheme);
SetPropW(hwnd, MAKEINTATOMW(atWindowTheme), hTheme);
return hTheme;
}
......@@ -272,29 +317,6 @@ HTHEME WINAPI GetWindowTheme(HWND hwnd)
}
/***********************************************************************
* UXTHEME_SetWindowProperty
*
* I'm using atoms as there may be large numbers of duplicated strings
* and they do the work of keeping memory down as a cause of that quite nicely
*/
HRESULT UXTHEME_SetWindowProperty(HWND hwnd, ATOM aProp, LPCWSTR pszValue)
{
ATOM oldValue = (ATOM)(size_t)RemovePropW(hwnd, MAKEINTATOMW(aProp));
if(oldValue)
DeleteAtom(oldValue);
if(pszValue) {
ATOM atValue = AddAtomW(pszValue);
if(!atValue
|| !SetPropW(hwnd, MAKEINTATOMW(aProp), (LPWSTR)MAKEINTATOMW(atValue))) {
HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
if(atValue) DeleteAtom(atValue);
return hr;
}
}
return S_OK;
}
/***********************************************************************
* SetWindowTheme (UXTHEME.@)
*
* Persistent through the life of the window, even after themes change
......@@ -375,7 +397,9 @@ HRESULT WINAPI HitTestThemeBackground(HTHEME hTheme, HDC hdc, int iPartId,
*/
BOOL WINAPI IsThemePartDefined(HTHEME hTheme, int iPartId, int iStateId)
{
FIXME("%d %d: stub\n", iPartId, iStateId);
TRACE("(%p,%d,%d)\n", hTheme, iPartId, iStateId);
if(MSSTYLES_FindPartState(hTheme, iPartId, iStateId))
return TRUE;
return FALSE;
}
......
......@@ -61,6 +61,8 @@ PUXINI_FILE UXINI_LoadINI(PTHEME_FILE tf, LPCWSTR lpName) {
PUXINI_FILE uf;
DWORD dwIniSize;
TRACE("Loading resource INI %s\n", debugstr_w(lpName));
if((hrsc = FindResourceW(tf->hTheme, lpName, szTextFileResource))) {
if(!(lpThemesIni = (LPCWSTR)LoadResource(tf->hTheme, hrsc))) {
TRACE("%s resource not found\n", debugstr_w(lpName));
......@@ -155,11 +157,12 @@ LPCWSTR UXINI_GetNextLine(PUXINI_FILE uf, DWORD *dwLen)
lpLineStart = uf->lpCurLoc;
lpLineEnd = uf->lpCurLoc;
while(!UXINI_eof(uf) && *uf->lpCurLoc != '\n' && *uf->lpCurLoc != ';') lpLineEnd = uf->lpCurLoc++;
if(*uf->lpCurLoc == ';') lpLineEnd = uf->lpCurLoc++;
/* If comment was found, skip the rest of the line */
if(*uf->lpCurLoc == ';')
while(!UXINI_eof(uf) && *uf->lpCurLoc != '\n') uf->lpCurLoc++;
len = (lpLineEnd - lpLineStart);
if(len == 0)
if(*lpLineStart != ';' && len == 0)
return NULL;
} while(*lpLineStart == ';');
/* Remove whitespace from end of line */
......@@ -169,7 +172,7 @@ LPCWSTR UXINI_GetNextLine(PUXINI_FILE uf, DWORD *dwLen)
return lpLineStart;
}
void UXINI_UnGetToLine(PUXINI_FILE uf, LPCWSTR lpLine)
static inline void UXINI_UnGetToLine(PUXINI_FILE uf, LPCWSTR lpLine)
{
uf->lpCurLoc = lpLine;
}
......
# Undocumented functions - Names derived from debug symbols
1 stdcall QueryThemeServices()
2 stdcall OpenThemeFile(wstr wstr wstr ptr long)
3 stdcall CloseThemeFile(ptr)
4 stdcall ApplyTheme(ptr ptr ptr)
7 stdcall GetThemeDefaults(wstr wstr long wstr long)
8 stdcall EnumThemes(wstr ptr ptr)
9 stdcall EnumThemeColors(wstr wstr long wstr)
10 stdcall EnumThemeSizes(wstr wstr long wstr)
11 stdcall ParseThemeIniFile(wstr wstr ptr ptr)
13 stub DrawNCPreview
14 stub RegisterDefaultTheme
15 stub DumpLoadedThemeToTextFile
16 stub OpenThemeDataFromFile
17 stub OpenThemeFileFromData
18 stub GetThemeSysSize96
19 stub GetThemeSysFont96
20 stub SessionAllocate
21 stub SessionFree
22 stub ThemeHooksOn
23 stub ThemeHooksOff
24 stub AreThemeHooksActive
25 stub GetCurrentChangeNumber
26 stub GetNewChangeNumber
27 stub SetGlobalTheme
28 stub GetGlobalTheme
29 stub CheckThemeSignature
30 stub LoadTheme
31 stub InitUserTheme
32 stub InitUserRegistry
33 stub ReestablishServerConnection
34 stub ThemeHooksInstall
35 stub ThemeHooksRemove
36 stub RefreshThemeForTS
43 stub ClassicGetSystemMetrics
44 stub ClassicSystemParametersInfoA
45 stub ClassicSystemParametersInfoW
46 stub ClassicAdjustWindowRectEx
48 stub GetThemeParseErrorInfo
60 stub CreateThemeDataFromObjects
61 stub OpenThemeDataEx
62 stub ServerClearStockObjects
63 stub MarkSelection
1 stdcall -noname QueryThemeServices()
2 stdcall -noname OpenThemeFile(wstr wstr wstr ptr long)
3 stdcall -noname CloseThemeFile(ptr)
4 stdcall -noname ApplyTheme(ptr ptr ptr)
7 stdcall -noname GetThemeDefaults(wstr wstr long wstr long)
8 stdcall -noname EnumThemes(wstr ptr ptr)
9 stdcall -noname EnumThemeColors(wstr wstr long wstr)
10 stdcall -noname EnumThemeSizes(wstr wstr long wstr)
11 stdcall -noname ParseThemeIniFile(wstr wstr ptr ptr)
13 stub -noname DrawNCPreview
14 stub -noname RegisterDefaultTheme
15 stub -noname DumpLoadedThemeToTextFile
16 stub -noname OpenThemeDataFromFile
17 stub -noname OpenThemeFileFromData
18 stub -noname GetThemeSysSize96
19 stub -noname GetThemeSysFont96
20 stub -noname SessionAllocate
21 stub -noname SessionFree
22 stub -noname ThemeHooksOn
23 stub -noname ThemeHooksOff
24 stub -noname AreThemeHooksActive
25 stub -noname GetCurrentChangeNumber
26 stub -noname GetNewChangeNumber
27 stub -noname SetGlobalTheme
28 stub -noname GetGlobalTheme
29 stub -noname CheckThemeSignature
30 stub -noname LoadTheme
31 stub -noname InitUserTheme
32 stub -noname InitUserRegistry
33 stub -noname ReestablishServerConnection
34 stub -noname ThemeHooksInstall
35 stub -noname ThemeHooksRemove
36 stub -noname RefreshThemeForTS
43 stub -noname ClassicGetSystemMetrics
44 stub -noname ClassicSystemParametersInfoA
45 stub -noname ClassicSystemParametersInfoW
46 stub -noname ClassicAdjustWindowRectEx
48 stub -noname GetThemeParseErrorInfo
60 stub -noname CreateThemeDataFromObjects
61 stub -noname OpenThemeDataEx
62 stub -noname ServerClearStockObjects
63 stub -noname MarkSelection
# Standard functions
@ stdcall CloseThemeData(ptr)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment