]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/msw/uxtheme.h
Allow building with wxUSE_PROTOCOL_FTP/HTTP == 0.
[wxWidgets.git] / include / wx / msw / uxtheme.h
index 666202b6785452dd04e8f56652a2ca267ec7ec99..13c77b2288cb4e3a1e81189b675a312dbbd9810f 100644 (file)
@@ -1,16 +1,24 @@
-/*
- * wxuxthem.h : wxWindows support for Microsoft Windows XP Theme library
- *                (uxtheme.dll)
- * Modified to work with almost all Win32 compilers
- * Compiler must support Unicode, the __cdecl calling convention, and the
- * __stdcall calling convention
- */
+///////////////////////////////////////////////////////////////////////////////
+// Name:        include/wx/msw/uxtheme.h
+// Purpose:     wxUxThemeEngine class: support for XP themes
+// Author:
+// Modified by:
+// Created:     2003
+// RCS-ID:      $Id$
+// Copyright:   (c) 2003 wxWidgets Dev-Team
+// License:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
 
 #ifndef _WX_UXTHEME_H_
 #define _WX_UXTHEME_H_
 
-// Use wxModule approach to initialization.
-#define WXU_USE_WXMODULE 1
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
+  #pragma interface "uxtheme.h"
+#endif
+
+#include "wx/defs.h"
+
+#include "wx/msw/wrapwin.h"
 
 #if wxUSE_UNICODE
 typedef struct _WXUOSVERSIONINFOEXW {
@@ -48,43 +56,33 @@ typedef struct _WXUOSVERSIONINFOEXA {
 #define LPWXUOSVERSIONINFOEX LPWXUOSVERSIONINFOEXA
 #endif
 
-typedef int WXUBOOL ;
-
-typedef struct tagWXURECT
-{
-    long    left;
-    long    top;
-    long    right;
-    long    bottom;
-} WXURECT ;
-
 typedef void* WXHTHEME;
 typedef long WXUHRESULT;
-typedef WXHTHEME (__stdcall *PFNWXUOPENTHEMEDATA)(WXHWND, const wchar_t *) ; 
-typedef WXUHRESULT (__stdcall *PFNWXUCLOSETHEMEDATA)(WXHTHEME) ;
-typedef WXUHRESULT (__stdcall *PFNWXUDRAWTHEMEBACKGROUND)(WXHTHEME, WXHDC, 
-    int, int, const WXURECT *, const WXURECT *) ;
+typedef WXHTHEME (__stdcall *PFNWXUOPENTHEMEDATA)(WXHWND, const wchar_t *);
+typedef WXUHRESULT (__stdcall *PFNWXUCLOSETHEMEDATA)(WXHTHEME);
+typedef WXUHRESULT (__stdcall *PFNWXUDRAWTHEMEBACKGROUND)(WXHTHEME, WXHDC,
+    int, int, const RECT *, const RECT *);
 #define WXU_DTT_GRAYED 0x1
-typedef WXUHRESULT (__stdcall *PFNWXUDRAWTHEMETEXT)(WXHTHEME, WXHDC, int, 
-    int, const wchar_t *, int, DWORD, 
-    DWORD, const WXURECT *) ;
-typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEBACKGROUNDCONTENTRECT)(WXHTHEME, WXHDC, 
-    int, int, const WXURECT *, WXURECT *) ;
-typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEBACKGROUNDEXTENT)(WXHTHEME, WXHDC, int, int, 
-    const WXURECT *, WXURECT *) ;
-
-typedef enum WXUTHEMESIZE
+typedef WXUHRESULT (__stdcall *PFNWXUDRAWTHEMETEXT)(WXHTHEME, WXHDC, int,
+    int, const wchar_t *, int, DWORD,
+    DWORD, const RECT *);
+typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEBACKGROUNDCONTENTRECT)(WXHTHEME, WXHDC,
+    int, int, const RECT *, RECT *);
+typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEBACKGROUNDEXTENT)(WXHTHEME, WXHDC, int, int,
+    const RECT *, RECT *);
+
+enum WXUTHEMESIZE
 {
     WXU_TS_MIN,             // minimum size
     WXU_TS_TRUE,            // size without stretching
-    WXU_TS_DRAW,            // size that theme mgr will use to draw part
+    WXU_TS_DRAW             // size that theme mgr will use to draw part
 };
 
 typedef struct tagWXUSIZE
 {
     long        cx;
     long        cy;
-} WXUSIZE ;
+} WXUSIZE;
 
 typedef struct tagWXUTEXTMETRIC
 {
@@ -110,14 +108,14 @@ typedef struct tagWXUTEXTMETRIC
     unsigned char tmCharSet;
 } WXUTEXTMETRIC;
 
-typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEPARTSIZE)(WXHTHEME, WXHDC, int, int, const WXURECT *, 
-    enum WXUTHEMESIZE, WXUSIZE *) ;
-typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMETEXTEXTENT)(WXHTHEME, WXHDC, int, int, const wchar_t *, 
-    int, WXDWORD, const WXURECT *, WXURECT *) ;
+typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEPARTSIZE)(WXHTHEME, WXHDC, int, int, const RECT *,
+    enum WXUTHEMESIZE, WXUSIZE *);
+typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMETEXTEXTENT)(WXHTHEME, WXHDC, int, int, const wchar_t *,
+    int, WXDWORD, const RECT *, RECT *);
 typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMETEXTMETRICS)(WXHTHEME, WXHDC,
     int, int, WXUTEXTMETRIC*);
 typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEBACKGROUNDREGION)(WXHTHEME, WXHDC,
-    int, int, const WXURECT *, WXHRGN *) ;
+    int, int, const RECT *, WXHRGN *);
 
 #define WXU_HTTB_BACKGROUNDSEG          0x0000
 #define WXU_HTTB_FIXEDBORDER            0x0002
@@ -134,26 +132,26 @@ typedef struct tagWXUPOINT
 {
     long x;
     long y;
-} WXUPOINT ;
+} WXUPOINT;
 
 typedef WXUHRESULT (__stdcall *PFNWXUHITTESTTHEMEBACKGROUND)(WXHTHEME, WXHDC, int,
-    int, WXDWORD, const WXURECT *, WXHRGN,
-    WXUPOINT, unsigned short *) ;
+    int, WXDWORD, const RECT *, WXHRGN,
+    WXUPOINT, unsigned short *);
 typedef WXUHRESULT (__stdcall *PFNWXUDRAWTHEMEEDGE)(WXHTHEME, WXHDC, int, int,
-    const WXURECT *, unsigned int, unsigned int, WXURECT *);
+    const RECT *, unsigned int, unsigned int, RECT *);
 typedef WXUHRESULT (__stdcall *PFNWXUDRAWTHEMEICON)(WXHTHEME, WXHDC, int, int,
-    const WXURECT *, WXHIMAGELIST, int) ;
-typedef WXUBOOL (__stdcall *PFNWXUISTHEMEPARTDEFINED)(WXHTHEME, int, int) ;
-typedef WXUBOOL (__stdcall *PFNWXUISTHEMEBACKGROUNDPARTIALLYTRANSPARENT)(WXHTHEME, int, int) ;
-typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMECOLOR)(WXHTHEME, int, int, int, WXCOLORREF;
+    const RECT *, WXHIMAGELIST, int);
+typedef BOOL (__stdcall *PFNWXUISTHEMEPARTDEFINED)(WXHTHEME, int, int);
+typedef BOOL (__stdcall *PFNWXUISTHEMEBACKGROUNDPARTIALLYTRANSPARENT)(WXHTHEME, int, int);
+typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMECOLOR)(WXHTHEME, int, int, int, WXCOLORREF*);
 typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEMETRIC)(WXHTHEME, WXHDC, int,
-    int, int, int *) ;
+    int, int, int *);
 typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMESTRING)(WXHTHEME, int,
-    int, int, wchar_t *, int) ;
-typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEBOOL)(WXHTHEME, int, int, int, WXUBOOL *) ;
-typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEINT)(WXHTHEME, int, int, int, int *) ;
-typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEENUMVALUE)(WXHTHEME, int, int, int, int *) ;
-typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEPOSITION)(WXHTHEME, int, int, int, WXUPOINT *) ;
+    int, int, wchar_t *, int);
+typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEBOOL)(WXHTHEME, int, int, int, BOOL *);
+typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEINT)(WXHTHEME, int, int, int, int *);
+typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEENUMVALUE)(WXHTHEME, int, int, int, int *);
+typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEPOSITION)(WXHTHEME, int, int, int, WXUPOINT *);
 typedef struct tagWXULOGFONT
 {
     long          lfHeight;
@@ -170,9 +168,9 @@ typedef struct tagWXULOGFONT
     unsigned char lfQuality;
     unsigned char lfPitchAndFamily;
     wchar_t       lfFaceName[32];
-} WXULOGFONT ;
-typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEFONT)(WXHTHEME, WXHDC, int, int, int, WXULOGFONT *) ;
-typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMERECT)(WXHTHEME, int, int, int, WXURECT *) ;
+} WXULOGFONT;
+typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEFONT)(WXHTHEME, WXHDC, int, int, int, WXULOGFONT *);
+typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMERECT)(WXHTHEME, int, int, int, RECT *);
 typedef struct _WXUMARGINS
 {
     int cxLeftWidth;      // width of left border that retains its size
@@ -181,7 +179,7 @@ typedef struct _WXUMARGINS
     int cyBottomHeight;   // height of bottom border that retains its size
 } WXUMARGINS, *PWXUMARGINS;
 typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEMARGINS)(WXHTHEME, WXHDC, int,
-    int, int, WXURECT *, WXUMARGINS *) ;
+    int, int, RECT *, WXUMARGINS *);
 
 #define WXU_MAX_INTLIST_COUNT 10
 typedef struct _WXUINTLIST
@@ -190,8 +188,9 @@ typedef struct _WXUINTLIST
     int iValues[WXU_MAX_INTLIST_COUNT];
 } WXUINTLIST, *PWXUINTLIST;
 typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEINTLIST)(WXHTHEME, int,
-       int, int, WXUINTLIST*) ;
-typedef enum WXUPROPERTYORIGIN
+    int, int, WXUINTLIST*);
+
+enum WXUPROPERTYORIGIN
 {
     WXU_PO_STATE,           // property was found in the state section
     WXU_PO_PART,            // property was found in the part section
@@ -199,37 +198,38 @@ typedef enum WXUPROPERTYORIGIN
     WXU_PO_GLOBAL,          // property was found in [globals] section
     WXU_PO_NOTFOUND         // property was not found
 };
+
 typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEPROPERTYORIGIN)(WXHTHEME, int,
-    int, int, enum WXUPROPERTYORIGIN *) ;
-typedef WXUHRESULT (__stdcall *PFNWXUSETWINDOWTHEME)(WXHWND, const wchar_t*, const wchar_t *) ;
-typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEFILENAME)(WXHTHEME, int, int, int, wchar_t *, int) ;
-typedef WXCOLORREF (__stdcall *PFNWXUGETTHEMESYSCOLOR)(WXHTHEME, int) ;
-typedef WXHBRUSH (__stdcall *PFNWXUGETTHEMESYSCOLORBRUSH)(WXHTHEME, int) ;
-typedef WXUBOOL (__stdcall *PFNWXUGETTHEMESYSBOOL)(WXHTHEME, int) ;
-typedef int (__stdcall *PFNWXUGETTHEMESYSSIZE)(WXHTHEME, int) ;
-typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMESYSFONT)(WXHTHEME, int, WXULOGFONT *) ;
-typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMESYSSTRING)(WXHTHEME, int, wchar_t *, int) ;
-typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMESYSINT)(WXHTHEME, int, int *) ;
-typedef WXUBOOL (__stdcall *PFNWXUISTHEMEACTIVE)() ;
-typedef WXUBOOL (__stdcall *PFNWXUISAPPTHEMED)() ;
-typedef WXHTHEME (__stdcall *PFNWXUGETWINDOWTHEME)(WXHWND) ;
+    int, int, enum WXUPROPERTYORIGIN *);
+typedef WXUHRESULT (__stdcall *PFNWXUSETWINDOWTHEME)(WXHWND, const wchar_t*, const wchar_t *);
+typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEFILENAME)(WXHTHEME, int, int, int, wchar_t *, int);
+typedef WXCOLORREF (__stdcall *PFNWXUGETTHEMESYSCOLOR)(WXHTHEME, int);
+typedef WXHBRUSH (__stdcall *PFNWXUGETTHEMESYSCOLORBRUSH)(WXHTHEME, int);
+typedef BOOL (__stdcall *PFNWXUGETTHEMESYSBOOL)(WXHTHEME, int);
+typedef int (__stdcall *PFNWXUGETTHEMESYSSIZE)(WXHTHEME, int);
+typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMESYSFONT)(WXHTHEME, int, WXULOGFONT *);
+typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMESYSSTRING)(WXHTHEME, int, wchar_t *, int);
+typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMESYSINT)(WXHTHEME, int, int *);
+typedef BOOL (__stdcall *PFNWXUISTHEMEACTIVE)();
+typedef BOOL (__stdcall *PFNWXUISAPPTHEMED)();
+typedef WXHTHEME (__stdcall *PFNWXUGETWINDOWTHEME)(WXHWND);
 
 #define WXU_ETDT_DISABLE        0x00000001
 #define WXU_ETDT_ENABLE         0x00000002
 #define WXU_ETDT_USETABTEXTURE  0x00000004
 #define WXU_ETDT_ENABLETAB      0x00000006
 
-typedef WXUHRESULT (__stdcall *PFNWXUENABLETHEMEDIALOGTEXTURE)(WXHWND, WXDWORD) ;
-typedef WXUBOOL (__stdcall *PFNWXUISTHEMEDIALOGTEXTUREENABLED)(WXHWND) ;
+typedef WXUHRESULT (__stdcall *PFNWXUENABLETHEMEDIALOGTEXTURE)(WXHWND, WXDWORD);
+typedef BOOL (__stdcall *PFNWXUISTHEMEDIALOGTEXTUREENABLED)(WXHWND);
 
 #define WXU_STAP_ALLOW_NONCLIENT    1
 #define WXU_STAP_ALLOW_CONTROLS     2
 #define WXU_STAP_ALLOW_WEBCONTENT   4
 
-typedef WXDWORD (__stdcall *PFNWXUGETTHEMEAPPPROPERTIES)() ;
-typedef void (__stdcall *PFNWXUSETTHEMEAPPPROPERTIES)(WXDWORD) ;
-typedef WXUHRESULT (__stdcall *PFNWXUGETCURRENTTHEMENAME)(wchar_t *, int, 
-    wchar_t *, int, wchar_t *, int) ;
+typedef WXDWORD (__stdcall *PFNWXUGETTHEMEAPPPROPERTIES)();
+typedef void (__stdcall *PFNWXUSETTHEMEAPPPROPERTIES)(WXDWORD);
+typedef WXUHRESULT (__stdcall *PFNWXUGETCURRENTTHEMENAME)(wchar_t *, int,
+    wchar_t *, int, wchar_t *, int);
 
 #define WXU_SZ_THDOCPROP_DISPLAYNAME                L"DisplayName"
 #define WXU_SZ_THDOCPROP_CANONICALNAME              L"ThemeName"
@@ -237,84 +237,171 @@ typedef WXUHRESULT (__stdcall *PFNWXUGETCURRENTTHEMENAME)(wchar_t *, int,
 #define WXU_SZ_THDOCPROP_AUTHOR                     L"author"
 
 typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEDOCUMENTATIONPROPERTY)(const wchar_t *,
-    const wchar_t *, wchar_t *, int) ;
-typedef WXUHRESULT (__stdcall *PFNWXUDRAWTHEMEPARENTBACKGROUND)(WXHWND, WXHDC, WXURECT *) ;
-typedef WXUHRESULT (__stdcall *PFNWXUENABLETHEMING)(WXUBOOL) ;
+    const wchar_t *, wchar_t *, int);
+typedef WXUHRESULT (__stdcall *PFNWXUDRAWTHEMEPARENTBACKGROUND)(WXHWND, WXHDC, RECT *);
+typedef WXUHRESULT (__stdcall *PFNWXUENABLETHEMING)(BOOL);
 
-class wxUxThemeEngine
-{
-private:
-    wxUxThemeEngine() ;
+// ----------------------------------------------------------------------------
+// wxUxThemeEngine: provides all theme functions from uxtheme.dll
+// ----------------------------------------------------------------------------
+
+// we always define this class, even if wxUSE_UXTHEME == 0, but we just make it
+// empty in this case -- this allows to use it elsewhere without any #ifdefs
+#if wxUSE_UXTHEME
+    #include "wx/dynload.h"
 
+    #define wxUX_THEME_DECLARE(type, func) type func;
+#else
+    #define wxUX_THEME_DECLARE(type, func) type func(...) { return 0; }
+#endif
+
+class WXDLLEXPORT wxUxThemeEngine
+{
 public:
-    ~wxUxThemeEngine() ;
-    bool IsInitialized() const { return m_bIsInitialized ; }
+    // get the theme engine or NULL if themes are not available
+    static wxUxThemeEngine *Get();
+
+    // get the theme enging or NULL if themes are not available or not used for
+    // this application
+    static wxUxThemeEngine *GetIfActive();
+
+    // all uxtheme.dll functions
+    wxUX_THEME_DECLARE(PFNWXUOPENTHEMEDATA, OpenThemeData)
+    wxUX_THEME_DECLARE(PFNWXUCLOSETHEMEDATA, CloseThemeData)
+    wxUX_THEME_DECLARE(PFNWXUDRAWTHEMEBACKGROUND, DrawThemeBackground)
+    wxUX_THEME_DECLARE(PFNWXUDRAWTHEMETEXT, DrawThemeText)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMEBACKGROUNDCONTENTRECT, GetThemeBackgroundContentRect)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMEBACKGROUNDEXTENT, GetThemeBackgroundExtent)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMEPARTSIZE, GetThemePartSize)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMETEXTEXTENT, GetThemeTextExtent)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMETEXTMETRICS, GetThemeTextMetrics)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMEBACKGROUNDREGION, GetThemeBackgroundRegion)
+    wxUX_THEME_DECLARE(PFNWXUHITTESTTHEMEBACKGROUND, HitTestThemeBackground)
+    wxUX_THEME_DECLARE(PFNWXUDRAWTHEMEEDGE, DrawThemeEdge)
+    wxUX_THEME_DECLARE(PFNWXUDRAWTHEMEICON, DrawThemeIcon)
+    wxUX_THEME_DECLARE(PFNWXUISTHEMEPARTDEFINED, IsThemePartDefined)
+    wxUX_THEME_DECLARE(PFNWXUISTHEMEBACKGROUNDPARTIALLYTRANSPARENT, IsThemeBackgroundPartiallyTransparent)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMECOLOR, GetThemeColor)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMEMETRIC, GetThemeMetric)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMESTRING, GetThemeString)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMEBOOL, GetThemeBool)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMEINT, GetThemeInt)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMEENUMVALUE, GetThemeEnumValue)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMEPOSITION, GetThemePosition)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMEFONT, GetThemeFont)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMERECT, GetThemeRect)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMEMARGINS, GetThemeMargins)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMEINTLIST, GetThemeIntList)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMEPROPERTYORIGIN, GetThemePropertyOrigin)
+    wxUX_THEME_DECLARE(PFNWXUSETWINDOWTHEME, SetWindowTheme)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMEFILENAME, GetThemeFilename)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSCOLOR, GetThemeSysColor)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSCOLORBRUSH, GetThemeSysColorBrush)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSBOOL, GetThemeSysBool)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSSIZE, GetThemeSysSize)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSFONT, GetThemeSysFont)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSSTRING, GetThemeSysString)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMESYSINT, GetThemeSysInt)
+    wxUX_THEME_DECLARE(PFNWXUISTHEMEACTIVE, IsThemeActive)
+    wxUX_THEME_DECLARE(PFNWXUISAPPTHEMED, IsAppThemed)
+    wxUX_THEME_DECLARE(PFNWXUGETWINDOWTHEME, GetWindowTheme)
+    wxUX_THEME_DECLARE(PFNWXUENABLETHEMEDIALOGTEXTURE, EnableThemeDialogTexture)
+    wxUX_THEME_DECLARE(PFNWXUISTHEMEDIALOGTEXTUREENABLED, IsThemeDialogTextureEnabled)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMEAPPPROPERTIES, GetThemeAppProperties)
+    wxUX_THEME_DECLARE(PFNWXUSETTHEMEAPPPROPERTIES, SetThemeAppProperties)
+    wxUX_THEME_DECLARE(PFNWXUGETCURRENTTHEMENAME, GetCurrentThemeName)
+    wxUX_THEME_DECLARE(PFNWXUGETTHEMEDOCUMENTATIONPROPERTY, GetThemeDocumentationProperty)
+    wxUX_THEME_DECLARE(PFNWXUDRAWTHEMEPARENTBACKGROUND, DrawThemeParentBackground)
+    wxUX_THEME_DECLARE(PFNWXUENABLETHEMING, EnableTheming)
 
 private:
-    bool m_bIsInitialized ;
-    HINSTANCE m_hInstUXThemeDLL ;
+    // construcor is private as only Get() can create us and is also trivial as
+    // everything really happens in Initialize()
+    wxUxThemeEngine() { }
 
-public:
-    static wxUxThemeEngine* wxInitUxThemeEngine() ;
-protected:
-    void ResetFunctionPointers() ;
-public:
-    PFNWXUOPENTHEMEDATA m_pfnOpenThemeData ;
-    PFNWXUCLOSETHEMEDATA m_pfnCloseThemeData ;
-    PFNWXUDRAWTHEMEBACKGROUND m_pfnDrawThemeBackground ;
-    PFNWXUDRAWTHEMETEXT m_pfnDrawThemeText ;
-    PFNWXUGETTHEMEBACKGROUNDCONTENTRECT m_pfnGetThemeBackgroundContentRect ;
-    PFNWXUGETTHEMEBACKGROUNDEXTENT m_pfnGetThemeBackgroundExtent ;
-    PFNWXUGETTHEMEPARTSIZE m_pfnGetThemePartSize ;
-    PFNWXUGETTHEMETEXTEXTENT m_pfnGetThemeTextExtent ;
-    PFNWXUGETTHEMETEXTMETRICS m_pfnGetThemeTextMetrics ;
-    PFNWXUGETTHEMEBACKGROUNDREGION m_pfnGetThemeBackgroundRegion ;
-    PFNWXUHITTESTTHEMEBACKGROUND m_pfnHitTestThemeBackground ;
-    PFNWXUDRAWTHEMEEDGE m_pfnDrawThemeEdge ;
-    PFNWXUDRAWTHEMEICON m_pfnDrawThemeIcon ;
-    PFNWXUISTHEMEPARTDEFINED m_pfnIsThemePartDefined ;
-    PFNWXUISTHEMEBACKGROUNDPARTIALLYTRANSPARENT m_pfnIsThemeBackgroundPartiallyTransparent ;
-    PFNWXUGETTHEMECOLOR m_pfnGetThemeColor ;
-    PFNWXUGETTHEMEMETRIC m_pfnGetThemeMetric ;
-    PFNWXUGETTHEMESTRING m_pfnGetThemeString ;
-    PFNWXUGETTHEMEBOOL m_pfnGetThemeBool ;
-    PFNWXUGETTHEMEINT m_pfnGetThemeInt ;
-    PFNWXUGETTHEMEENUMVALUE m_pfnGetThemeEnumValue ;
-    PFNWXUGETTHEMEPOSITION m_pfnGetThemePosition ;
-    PFNWXUGETTHEMEFONT m_pfnGetThemeFont ;
-    PFNWXUGETTHEMERECT m_pfnGetThemeRect ;
-    PFNWXUGETTHEMEMARGINS m_pfnGetThemeMargins ;
-    PFNWXUGETTHEMEINTLIST m_pfnGetThemeIntList ;
-    PFNWXUGETTHEMEPROPERTYORIGIN m_pfnGetThemePropertyOrigin ;
-    PFNWXUSETWINDOWTHEME m_pfnSetWindowTheme ;
-    PFNWXUGETTHEMEFILENAME m_pfnGetThemeFilename ;
-    PFNWXUGETTHEMESYSCOLOR m_pfnGetThemeSysColor ;
-    PFNWXUGETTHEMESYSCOLORBRUSH m_pfnGetThemeSysColorBrush ;
-    PFNWXUGETTHEMESYSBOOL m_pfnGetThemeSysBool ;
-    PFNWXUGETTHEMESYSSIZE m_pfnGetThemeSysSize ;
-    PFNWXUGETTHEMESYSFONT m_pfnGetThemeSysFont ;
-    PFNWXUGETTHEMESYSSTRING m_pfnGetThemeSysString ;
-    PFNWXUGETTHEMESYSINT m_pfnGetThemeSysInt ;
-    PFNWXUISTHEMEACTIVE m_pfnIsThemeActive ;
-    PFNWXUISAPPTHEMED m_pfnIsAppThemed ;
-    PFNWXUGETWINDOWTHEME m_pfnGetWindowTheme ;
-    PFNWXUENABLETHEMEDIALOGTEXTURE m_pfnEnableThemeDialogTexture ;
-    PFNWXUISTHEMEDIALOGTEXTUREENABLED m_pfnIsThemeDialogTextureEnabled ;
-    PFNWXUGETTHEMEAPPPROPERTIES m_pfnGetThemeAppProperties ;
-    PFNWXUSETTHEMEAPPPROPERTIES m_pfnSetThemeAppProperties ;
-    PFNWXUGETCURRENTTHEMENAME m_pfnGetCurrentThemeName ;
-    PFNWXUGETTHEMEDOCUMENTATIONPROPERTY m_pfnGetThemeDocumentationProperty ;
-    PFNWXUDRAWTHEMEPARENTBACKGROUND m_pfnDrawThemeParentBackground ;
-    PFNWXUENABLETHEMING m_pfnEnableTheming ;
+    // destructor is private as only Get() and wxUxThemeModule delete us, it is
+    // not virtual as we're not supposed to be derived from
+    ~wxUxThemeEngine() { }
+
+#if wxUSE_UXTHEME
+    // initialize the theme engine: load the DLL, resolve the functions
+    //
+    // return true if we can be used, false if themes are not available
+    bool Initialize();
+
+
+    // uxtheme.dll
+    wxDynamicLibrary m_dllUxTheme;
+
+
+    // the one and only theme engine, initially NULL
+    static wxUxThemeEngine *ms_themeEngine;
+
+    // this is a bool which initially has the value -1 meaning "unknown"
+    static int ms_isThemeEngineAvailable;
+
+    // it must be able to delete us
+    friend class wxUxThemeModule;
+#endif // wxUSE_UXTHEME
+
+    DECLARE_NO_COPY_CLASS(wxUxThemeEngine)
 };
 
-extern wxUxThemeEngine* g_pThemeEngine ;
+#if wxUSE_UXTHEME
 
-BOOL wxCanUseInitThemeEngine() ;
+/* static */ inline wxUxThemeEngine *wxUxThemeEngine::GetIfActive()
+{
+    wxUxThemeEngine *engine = Get();
+    return engine && engine->IsAppThemed() && engine->IsThemeActive()
+                ? engine
+                : NULL;
+}
 
-#if !defined(WXU_USE_WXMODULE)
-BOOL wxUxInitThemeEngine() ;
-#endif
+#else // !wxUSE_UXTHEME
 
-#endif
+/* static */ inline wxUxThemeEngine *wxUxThemeEngine::Get()
+{
+    return NULL;
+}
+
+/* static */ inline wxUxThemeEngine *wxUxThemeEngine::GetIfActive()
+{
+    return NULL;
+}
+
+#endif // wxUSE_UXTHEME/!wxUSE_UXTHEME
+
+// ----------------------------------------------------------------------------
+// wxUxThemeHandle: encapsulates ::Open/CloseThemeData()
+// ----------------------------------------------------------------------------
+
+class wxUxThemeHandle
+{
+public:
+    wxUxThemeHandle(wxWindow *win, const wchar_t *classes)
+    {
+        wxUxThemeEngine *engine = wxUxThemeEngine::Get();
+
+        m_hTheme =
+            engine ? (WXHTHEME)engine->OpenThemeData(win->GetHWND(), classes)
+                   : NULL;
+    }
+
+    operator WXHTHEME() const { return m_hTheme; }
+
+    ~wxUxThemeHandle()
+    {
+        if ( m_hTheme )
+        {
+            wxUxThemeEngine::Get()->CloseThemeData(m_hTheme);
+        }
+    }
+
+private:
+    WXHTHEME m_hTheme;
+
+    DECLARE_NO_COPY_CLASS(wxUxThemeHandle)
+};
+
+#endif // _WX_UXTHEME_H_