From 2d9c0e97c580cff977d75760dc0d82c5852eec2c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 30 Jul 2003 22:31:20 +0000 Subject: [PATCH] [start of] cleanup uxtheme support code git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22397 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/uxtheme.h | 289 ++++++++++++++++++-------------- src/msw/uxtheme.cpp | 349 ++++++++++++++------------------------- 2 files changed, 288 insertions(+), 350 deletions(-) diff --git a/include/wx/msw/uxtheme.h b/include/wx/msw/uxtheme.h index f239045c8a..6de85262a9 100644 --- a/include/wx/msw/uxtheme.h +++ b/include/wx/msw/uxtheme.h @@ -1,20 +1,22 @@ -/* - * 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 wxWindows Dev-Team +// License: wxWindows license +/////////////////////////////////////////////////////////////////////////////// #ifndef _WX_UXTHEME_H_ #define _WX_UXTHEME_H_ #ifdef __GNUG__ - #pragma interface "uxtheme.cpp" + #pragma interface "uxtheme.h" #endif -// Use wxModule approach to initialization. -#define WXU_USE_WXMODULE 1 +#include "wx/defs.h" #if wxUSE_UNICODE typedef struct _WXUOSVERSIONINFOEXW { @@ -52,7 +54,7 @@ typedef struct _WXUOSVERSIONINFOEXA { #define LPWXUOSVERSIONINFOEX LPWXUOSVERSIONINFOEXA #endif -typedef int WXUBOOL ; +typedef int WXUBOOL; typedef struct tagWXURECT { @@ -60,22 +62,22 @@ typedef struct tagWXURECT long top; long right; long bottom; -} WXURECT ; +} WXURECT; typedef void* WXHTHEME; typedef long WXUHRESULT; -typedef WXHTHEME (__stdcall *PFNWXUOPENTHEMEDATA)(WXHWND, const wchar_t *) ; -typedef WXUHRESULT (__stdcall *PFNWXUCLOSETHEMEDATA)(WXHTHEME) ; +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 *) ; + int, int, const WXURECT *, const WXURECT *); #define WXU_DTT_GRAYED 0x1 typedef WXUHRESULT (__stdcall *PFNWXUDRAWTHEMETEXT)(WXHTHEME, WXHDC, int, int, const wchar_t *, int, DWORD, - DWORD, const WXURECT *) ; + DWORD, const WXURECT *); typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEBACKGROUNDCONTENTRECT)(WXHTHEME, WXHDC, - int, int, const WXURECT *, WXURECT *) ; + int, int, const WXURECT *, WXURECT *); typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEBACKGROUNDEXTENT)(WXHTHEME, WXHDC, int, int, - const WXURECT *, WXURECT *) ; + const WXURECT *, WXURECT *); enum WXUTHEMESIZE { @@ -88,7 +90,7 @@ typedef struct tagWXUSIZE { long cx; long cy; -} WXUSIZE ; +} WXUSIZE; typedef struct tagWXUTEXTMETRIC { @@ -115,13 +117,13 @@ typedef struct tagWXUTEXTMETRIC } WXUTEXTMETRIC; typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEPARTSIZE)(WXHTHEME, WXHDC, int, int, const WXURECT *, - enum WXUTHEMESIZE, WXUSIZE *) ; + enum WXUTHEMESIZE, WXUSIZE *); typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMETEXTEXTENT)(WXHTHEME, WXHDC, int, int, const wchar_t *, - int, WXDWORD, const WXURECT *, WXURECT *) ; + int, WXDWORD, const WXURECT *, WXURECT *); typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMETEXTMETRICS)(WXHTHEME, WXHDC, int, int, WXUTEXTMETRIC*); typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEBACKGROUNDREGION)(WXHTHEME, WXHDC, - int, int, const WXURECT *, WXHRGN *) ; + int, int, const WXURECT *, WXHRGN *); #define WXU_HTTB_BACKGROUNDSEG 0x0000 #define WXU_HTTB_FIXEDBORDER 0x0002 @@ -138,26 +140,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 *) ; + WXUPOINT, unsigned short *); typedef WXUHRESULT (__stdcall *PFNWXUDRAWTHEMEEDGE)(WXHTHEME, WXHDC, int, int, const WXURECT *, unsigned int, unsigned int, WXURECT *); 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 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*); 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, 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 *); typedef struct tagWXULOGFONT { long lfHeight; @@ -174,9 +176,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, WXURECT *); typedef struct _WXUMARGINS { int cxLeftWidth; // width of left border that retains its size @@ -185,7 +187,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, WXURECT *, WXUMARGINS *); #define WXU_MAX_INTLIST_COUNT 10 typedef struct _WXUINTLIST @@ -194,7 +196,7 @@ typedef struct _WXUINTLIST int iValues[WXU_MAX_INTLIST_COUNT]; } WXUINTLIST, *PWXUINTLIST; typedef WXUHRESULT (__stdcall *PFNWXUGETTHEMEINTLIST)(WXHTHEME, int, - int, int, WXUINTLIST*) ; + int, int, WXUINTLIST*); enum WXUPROPERTYORIGIN { @@ -206,36 +208,36 @@ enum WXUPROPERTYORIGIN }; 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 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); #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 WXUBOOL (__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 WXDWORD (__stdcall *PFNWXUGETTHEMEAPPPROPERTIES)(); +typedef void (__stdcall *PFNWXUSETTHEMEAPPPROPERTIES)(WXDWORD); typedef WXUHRESULT (__stdcall *PFNWXUGETCURRENTTHEMENAME)(wchar_t *, int, - wchar_t *, int, wchar_t *, int) ; + wchar_t *, int, wchar_t *, int); #define WXU_SZ_THDOCPROP_DISPLAYNAME L"DisplayName" #define WXU_SZ_THDOCPROP_CANONICALNAME L"ThemeName" @@ -243,85 +245,120 @@ 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, WXURECT *); +typedef WXUHRESULT (__stdcall *PFNWXUENABLETHEMING)(WXUBOOL); + +// ---------------------------------------------------------------------------- +// 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 { -private: - wxUxThemeEngine() ; - public: - ~wxUxThemeEngine() ; - bool IsInitialized() const { return m_bIsInitialized ; } + // get the theme engine or NULL if themes are not available + static wxUxThemeEngine *Get(); + + // 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() ; - static wxUxThemeEngine* Get() ; -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); }; -WXDLLEXPORT_DATA(extern wxUxThemeEngine*) g_pThemeEngine ; +#if !wxUSE_UXTHEME -WXDLLEXPORT BOOL wxCanUseInitThemeEngine() ; +/* static */ inline wxUxThemeEngine *wxUxThemeEngine::Get() +{ + return NULL; +} -#if !defined(WXU_USE_WXMODULE) -WXDLLEXPORT BOOL wxUxInitThemeEngine() ; -#endif +#endif // !wxUSE_UXTHEME -#endif +#endif // _WX_UXTHEME_H_ diff --git a/src/msw/uxtheme.cpp b/src/msw/uxtheme.cpp index ae90474c7b..e41159bad0 100644 --- a/src/msw/uxtheme.cpp +++ b/src/msw/uxtheme.cpp @@ -1,15 +1,26 @@ -/* - * 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: src/msw/uxtheme.cpp +// Purpose: implements wxUxThemeEngine class: support for XP themes +// Author: +// Modified by: +// Created: 2003 +// RCS-ID: $Id$ +// Copyright: (c) 2003 wxWindows Dev-Team +// License: wxWindows license +/////////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ #ifdef __GNUG__ -#pragma implementation "uxtheme.h" + #pragma implementation "uxtheme.h" #endif +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -17,6 +28,8 @@ #pragma hdrstop #endif +#if wxUSE_UXTHEME + #ifndef WX_PRECOMP #include "wx/app.h" #include "wx/toplevel.h" @@ -26,250 +39,138 @@ #include "wx/module.h" -#if wxUSE_UXTHEME - #include "wx/msw/wrapwin.h" #include "wx/msw/uxtheme.h" #include "wx/msw/private.h" -#include "wx/app.h" // for GetComCtl32Version -wxUxThemeEngine* g_pThemeEngine = ((wxUxThemeEngine*)NULL) ; +// ============================================================================ +// wxUxThemeModule +// ============================================================================ -BOOL wxCanUseInitThemeEngine() -{ - WXUOSVERSIONINFOEX wxuosex ; - memset((void*)&wxuosex, 0, sizeof(WXUOSVERSIONINFOEX)) ; - wxuosex.dwOSVersionInfoSize = sizeof(WXUOSVERSIONINFOEX) ; - if(!GetVersionEx((LPOSVERSIONINFO)&wxuosex)) - { - wxuosex.dwOSVersionInfoSize = sizeof(OSVERSIONINFO) ; - if(!GetVersionEx((LPOSVERSIONINFO)&wxuosex)) - { - return FALSE ; - } - } - if ((wxuosex.dwMajorVersion == 5) && (wxuosex.dwMinorVersion > 0)) - { - return (wxTheApp->GetComCtl32Version() >= 600) ; - } - else - { - return FALSE ; - } -} - -wxUxThemeEngine* wxUxThemeEngine::wxInitUxThemeEngine() -{ - wxUxThemeEngine* pThemeEngine = new wxUxThemeEngine ; - return pThemeEngine ; -} - -wxUxThemeEngine* wxUxThemeEngine::Get() -{ - return g_pThemeEngine; -} - -#ifdef WXU_USE_WXMODULE +// this module is responsable for deleting the theme engine class wxUxThemeModule : public wxModule { - DECLARE_DYNAMIC_CLASS(wxUxThemeModule) public: + virtual bool OnInit() { return true; } virtual void OnExit() { - if((wxCanUseInitThemeEngine()) && (g_pThemeEngine)) + if ( wxUxThemeEngine::ms_themeEngine ) { - delete g_pThemeEngine ; - g_pThemeEngine = ((wxUxThemeEngine*)NULL) ; + // this is probably not necessary right now but try to be careful + // and avoid the problems which we might have if someone ever + // decides to show a message box using the theme engine from + // wxUxThemeEngine dtor (e.g. from wxDynamicLibrary dtor...) or + // something like this + wxUxThemeEngine *themeEngine = wxUxThemeEngine::ms_themeEngine; + wxUxThemeEngine::ms_themeEngine = NULL; + wxUxThemeEngine::ms_isThemeEngineAvailable = false; + + delete themeEngine; } } - virtual bool OnInit() - { - if(!wxCanUseInitThemeEngine()) - { - g_pThemeEngine = ((wxUxThemeEngine*)NULL) ; - return TRUE ; - } - g_pThemeEngine = wxUxThemeEngine::wxInitUxThemeEngine() ; - if(!g_pThemeEngine) - { - return FALSE ; - } - else if(!g_pThemeEngine->IsInitialized()) - { - OnExit() ; - return FALSE ; - } - return TRUE ; - } + DECLARE_DYNAMIC_CLASS(wxUxThemeModule) }; IMPLEMENT_DYNAMIC_CLASS(wxUxThemeModule, wxModule) -#else -static void __cdecl wxUxThemeEngineOnExit() + +// ============================================================================ +// wxUxThemeEngine implementation +// ============================================================================ + +wxUxThemeEngine *wxUxThemeEngine::ms_themeEngine = NULL; +int wxUxThemeEngine::ms_isThemeEngineAvailable = -1; // unknown + +wxUxThemeEngine* wxUxThemeEngine::Get() { - if(g_pThemeEngine) + // we assume that themes are only used in the main thread hence no need for + // critical section here + if ( ms_isThemeEngineAvailable == -1 ) { - delete g_pThemeEngine ; - g_pThemeEngine = ((wxUxThemeEngine*)NULL) ; + // we're called or the first time, check if the themes are available + ms_themeEngine = new wxUxThemeEngine; + if ( !ms_themeEngine->Initialize() ) + { + // can't use themes, probably because the system doesn't support + // them, don't do it again + delete ms_themeEngine; + ms_themeEngine = NULL; + + ms_isThemeEngineAvailable = false; + } + else // initialized ok + { + ms_isThemeEngineAvailable = true; + } } + + return ms_themeEngine; } -BOOL wxUxInitThemeEngine() +bool wxUxThemeEngine::Initialize() { - if(!wxCanUseInitThemeEngine()) - { - return TRUE ; - } - g_pThemeEngine = wxUxThemeEngine::wxInitUxThemeEngine() ; - if(!g_pThemeEngine) - { - return FALSE ; - } - else if(!g_pThemeEngine->IsInitialized()) - { - wxUxThemeEngineOnExit() ; - return FALSE ; - } + if ( !m_dllUxTheme.Load(_T("uxtheme.dll")) ) + return false; - if(atexit(wxUxThemeEngineOnExit) != 0) - { - wxUxThemeEngineOnExit() ; - return FALSE ; - } +#define RESOLVE_UXTHEME_FUNCTION(type, funcname) \ + funcname = (type)m_dllUxTheme.GetSymbol(_T(#funcname)); \ + if ( !funcname ) \ + return false - return TRUE ; -} -#endif + RESOLVE_UXTHEME_FUNCTION(PFNWXUOPENTHEMEDATA, OpenThemeData); + RESOLVE_UXTHEME_FUNCTION(PFNWXUCLOSETHEMEDATA, CloseThemeData); + RESOLVE_UXTHEME_FUNCTION(PFNWXUDRAWTHEMEBACKGROUND, DrawThemeBackground); + RESOLVE_UXTHEME_FUNCTION(PFNWXUDRAWTHEMETEXT, DrawThemeText); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEBACKGROUNDCONTENTRECT, GetThemeBackgroundContentRect); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEBACKGROUNDEXTENT, GetThemeBackgroundExtent); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEPARTSIZE, GetThemePartSize); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMETEXTEXTENT, GetThemeTextExtent); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMETEXTMETRICS, GetThemeTextMetrics); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEBACKGROUNDREGION, GetThemeBackgroundRegion); + RESOLVE_UXTHEME_FUNCTION(PFNWXUHITTESTTHEMEBACKGROUND, HitTestThemeBackground); + RESOLVE_UXTHEME_FUNCTION(PFNWXUDRAWTHEMEEDGE, DrawThemeEdge); + RESOLVE_UXTHEME_FUNCTION(PFNWXUDRAWTHEMEICON, DrawThemeIcon); + RESOLVE_UXTHEME_FUNCTION(PFNWXUISTHEMEPARTDEFINED, IsThemePartDefined); + RESOLVE_UXTHEME_FUNCTION(PFNWXUISTHEMEBACKGROUNDPARTIALLYTRANSPARENT, IsThemeBackgroundPartiallyTransparent); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMECOLOR, GetThemeColor); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEMETRIC, GetThemeMetric); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMESTRING, GetThemeString); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEBOOL, GetThemeBool); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEINT, GetThemeInt); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEENUMVALUE, GetThemeEnumValue); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEPOSITION, GetThemePosition); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEFONT, GetThemeFont); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMERECT, GetThemeRect); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEMARGINS, GetThemeMargins); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEINTLIST, GetThemeIntList); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEPROPERTYORIGIN, GetThemePropertyOrigin); + RESOLVE_UXTHEME_FUNCTION(PFNWXUSETWINDOWTHEME, SetWindowTheme); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEFILENAME, GetThemeFilename); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMESYSCOLOR, GetThemeSysColor); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMESYSCOLORBRUSH, GetThemeSysColorBrush); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMESYSBOOL, GetThemeSysBool); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMESYSSIZE, GetThemeSysSize); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMESYSFONT, GetThemeSysFont); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMESYSSTRING, GetThemeSysString); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMESYSINT, GetThemeSysInt); + RESOLVE_UXTHEME_FUNCTION(PFNWXUISTHEMEACTIVE, IsThemeActive); + RESOLVE_UXTHEME_FUNCTION(PFNWXUISAPPTHEMED, IsAppThemed); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETWINDOWTHEME, GetWindowTheme); + RESOLVE_UXTHEME_FUNCTION(PFNWXUENABLETHEMEDIALOGTEXTURE, EnableThemeDialogTexture); + RESOLVE_UXTHEME_FUNCTION(PFNWXUISTHEMEDIALOGTEXTUREENABLED, IsThemeDialogTextureEnabled); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEAPPPROPERTIES, GetThemeAppProperties); + RESOLVE_UXTHEME_FUNCTION(PFNWXUSETTHEMEAPPPROPERTIES, SetThemeAppProperties); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETCURRENTTHEMENAME, GetCurrentThemeName); + RESOLVE_UXTHEME_FUNCTION(PFNWXUGETTHEMEDOCUMENTATIONPROPERTY, GetThemeDocumentationProperty); + RESOLVE_UXTHEME_FUNCTION(PFNWXUDRAWTHEMEPARENTBACKGROUND, DrawThemeParentBackground); + RESOLVE_UXTHEME_FUNCTION(PFNWXUENABLETHEMING, EnableTheming); -#define WXU_GET_FN_PTR(hmod, type, pfunc, funcname) if(hmod != ((HINSTANCE)NULL)) { \ - pfunc = (type)::GetProcAddress(hmod, funcname) ; \ - if(pfunc == ((type)NULL)) \ - { \ - ::FreeLibrary(hmod) ; \ - hmod = ((HINSTANCE)NULL) ; \ - } \ +#undef RESOLVE_UXTHEME_FUNCTION + + return true; } -wxUxThemeEngine::wxUxThemeEngine() -{ - m_hInstUXThemeDLL = ::LoadLibraryA("uxtheme.dll") ; - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUOPENTHEMEDATA, m_pfnOpenThemeData, "OpenThemeData") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUCLOSETHEMEDATA, m_pfnCloseThemeData, "CloseThemeData") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUDRAWTHEMEBACKGROUND, m_pfnDrawThemeBackground, "DrawThemeBackground") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUDRAWTHEMETEXT, m_pfnDrawThemeText, "DrawThemeText") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMEBACKGROUNDCONTENTRECT, m_pfnGetThemeBackgroundContentRect, "GetThemeBackgroundContentRect") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMEBACKGROUNDEXTENT, m_pfnGetThemeBackgroundExtent, "GetThemeBackgroundExtent") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMEPARTSIZE, m_pfnGetThemePartSize, "GetThemePartSize") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMETEXTEXTENT, m_pfnGetThemeTextExtent, "GetThemeTextExtent") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMETEXTMETRICS, m_pfnGetThemeTextMetrics, "GetThemeTextMetrics") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMEBACKGROUNDREGION, m_pfnGetThemeBackgroundRegion, "GetThemeBackgroundRegion") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUHITTESTTHEMEBACKGROUND, m_pfnHitTestThemeBackground, "HitTestThemeBackground") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUDRAWTHEMEEDGE, m_pfnDrawThemeEdge, "DrawThemeEdge") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUDRAWTHEMEICON, m_pfnDrawThemeIcon, "DrawThemeIcon") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUISTHEMEPARTDEFINED, m_pfnIsThemePartDefined, "IsThemePartDefined") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUISTHEMEBACKGROUNDPARTIALLYTRANSPARENT, m_pfnIsThemeBackgroundPartiallyTransparent, "IsThemeBackgroundPartiallyTransparent") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMECOLOR, m_pfnGetThemeColor, "GetThemeColor") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMEMETRIC, m_pfnGetThemeMetric, "GetThemeMetric") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMESTRING, m_pfnGetThemeString, "GetThemeString") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMEBOOL, m_pfnGetThemeBool, "GetThemeBool") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMEINT, m_pfnGetThemeInt, "GetThemeInt") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMEENUMVALUE, m_pfnGetThemeEnumValue, "GetThemeEnumValue") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMEPOSITION, m_pfnGetThemePosition, "GetThemePosition") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMEFONT, m_pfnGetThemeFont, "GetThemeFont") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMERECT, m_pfnGetThemeRect, "GetThemeRect") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMEMARGINS, m_pfnGetThemeMargins, "GetThemeMargins") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMEINTLIST, m_pfnGetThemeIntList, "GetThemeIntList") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMEPROPERTYORIGIN, m_pfnGetThemePropertyOrigin, "GetThemePropertyOrigin") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUSETWINDOWTHEME, m_pfnSetWindowTheme, "SetWindowTheme") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMEFILENAME, m_pfnGetThemeFilename, "GetThemeFilename") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMESYSCOLOR, m_pfnGetThemeSysColor, "GetThemeSysColor") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMESYSCOLORBRUSH, m_pfnGetThemeSysColorBrush, "GetThemeSysColorBrush") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMESYSBOOL, m_pfnGetThemeSysBool, "GetThemeSysBool") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMESYSSIZE, m_pfnGetThemeSysSize, "GetThemeSysSize") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMESYSFONT, m_pfnGetThemeSysFont, "GetThemeSysFont") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMESYSSTRING, m_pfnGetThemeSysString, "GetThemeSysString") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMESYSINT, m_pfnGetThemeSysInt, "GetThemeSysInt") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUISTHEMEACTIVE, m_pfnIsThemeActive, "IsThemeActive") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUISAPPTHEMED, m_pfnIsAppThemed, "IsAppThemed") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETWINDOWTHEME, m_pfnGetWindowTheme, "GetWindowTheme") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUENABLETHEMEDIALOGTEXTURE, m_pfnEnableThemeDialogTexture, "EnableThemeDialogTexture") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUISTHEMEDIALOGTEXTUREENABLED, m_pfnIsThemeDialogTextureEnabled, "IsThemeDialogTextureEnabled") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMEAPPPROPERTIES, m_pfnGetThemeAppProperties, "GetThemeAppProperties") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUSETTHEMEAPPPROPERTIES, m_pfnSetThemeAppProperties, "SetThemeAppProperties") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETCURRENTTHEMENAME, m_pfnGetCurrentThemeName, "GetCurrentThemeName") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUGETTHEMEDOCUMENTATIONPROPERTY, m_pfnGetThemeDocumentationProperty, "GetThemeDocumentationProperty") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUDRAWTHEMEPARENTBACKGROUND, m_pfnDrawThemeParentBackground, "DrawThemeParentBackground") - WXU_GET_FN_PTR (m_hInstUXThemeDLL, PFNWXUENABLETHEMING, m_pfnEnableTheming, "EnableTheming") - m_bIsInitialized = (m_hInstUXThemeDLL != ((HINSTANCE)NULL)) ; - if(!m_bIsInitialized) - { - ResetFunctionPointers() ; - } -} - -void wxUxThemeEngine::ResetFunctionPointers() -{ - m_pfnOpenThemeData = ((PFNWXUOPENTHEMEDATA)NULL) ; - m_pfnCloseThemeData = ((PFNWXUCLOSETHEMEDATA)NULL) ; - m_pfnDrawThemeBackground = ((PFNWXUDRAWTHEMEBACKGROUND)NULL) ; - m_pfnDrawThemeText = ((PFNWXUDRAWTHEMETEXT)NULL) ; - m_pfnGetThemeBackgroundContentRect = ((PFNWXUGETTHEMEBACKGROUNDCONTENTRECT)NULL) ; - m_pfnGetThemeBackgroundExtent = ((PFNWXUGETTHEMEBACKGROUNDEXTENT)NULL) ; - m_pfnGetThemePartSize = ((PFNWXUGETTHEMEPARTSIZE)NULL) ; - m_pfnGetThemeTextExtent = ((PFNWXUGETTHEMETEXTEXTENT)NULL) ; - m_pfnGetThemeTextMetrics = ((PFNWXUGETTHEMETEXTMETRICS)NULL) ; - m_pfnGetThemeBackgroundRegion = ((PFNWXUGETTHEMEBACKGROUNDREGION)NULL) ; - m_pfnHitTestThemeBackground = ((PFNWXUHITTESTTHEMEBACKGROUND)NULL) ; - m_pfnDrawThemeEdge = ((PFNWXUDRAWTHEMEEDGE)NULL) ; - m_pfnDrawThemeIcon = ((PFNWXUDRAWTHEMEICON)NULL) ; - m_pfnIsThemePartDefined = ((PFNWXUISTHEMEPARTDEFINED)NULL) ; - m_pfnIsThemeBackgroundPartiallyTransparent = ((PFNWXUISTHEMEBACKGROUNDPARTIALLYTRANSPARENT)NULL) ; - m_pfnGetThemeColor = ((PFNWXUGETTHEMECOLOR)NULL) ; - m_pfnGetThemeMetric = ((PFNWXUGETTHEMEMETRIC)NULL) ; - m_pfnGetThemeString = ((PFNWXUGETTHEMESTRING)NULL) ; - m_pfnGetThemeBool = ((PFNWXUGETTHEMEBOOL)NULL) ; - m_pfnGetThemeInt = ((PFNWXUGETTHEMEINT)NULL) ; - m_pfnGetThemeEnumValue = ((PFNWXUGETTHEMEENUMVALUE)NULL) ; - m_pfnGetThemePosition = ((PFNWXUGETTHEMEPOSITION)NULL) ; - m_pfnGetThemeFont = ((PFNWXUGETTHEMEFONT)NULL) ; - m_pfnGetThemeRect = ((PFNWXUGETTHEMERECT)NULL) ; - m_pfnGetThemeMargins = ((PFNWXUGETTHEMEMARGINS)NULL) ; - m_pfnGetThemeIntList = ((PFNWXUGETTHEMEINTLIST)NULL) ; - m_pfnGetThemePropertyOrigin = ((PFNWXUGETTHEMEPROPERTYORIGIN)NULL) ; - m_pfnSetWindowTheme = ((PFNWXUSETWINDOWTHEME)NULL) ; - m_pfnGetThemeFilename = ((PFNWXUGETTHEMEFILENAME)NULL) ; - m_pfnGetThemeSysColor = ((PFNWXUGETTHEMESYSCOLOR)NULL) ; - m_pfnGetThemeSysColorBrush = ((PFNWXUGETTHEMESYSCOLORBRUSH)NULL) ; - m_pfnGetThemeSysBool = ((PFNWXUGETTHEMESYSBOOL)NULL) ; - m_pfnGetThemeSysSize = ((PFNWXUGETTHEMESYSSIZE)NULL) ; - m_pfnGetThemeSysFont = ((PFNWXUGETTHEMESYSFONT)NULL) ; - m_pfnGetThemeSysString = ((PFNWXUGETTHEMESYSSTRING)NULL) ; - m_pfnGetThemeSysInt = ((PFNWXUGETTHEMESYSINT)NULL) ; - m_pfnIsThemeActive = ((PFNWXUISTHEMEACTIVE)NULL) ; - m_pfnIsAppThemed = ((PFNWXUISAPPTHEMED)NULL) ; - m_pfnGetWindowTheme = ((PFNWXUGETWINDOWTHEME)NULL) ; - m_pfnEnableThemeDialogTexture = ((PFNWXUENABLETHEMEDIALOGTEXTURE)NULL) ; - m_pfnIsThemeDialogTextureEnabled = ((PFNWXUISTHEMEDIALOGTEXTUREENABLED)NULL) ; - m_pfnGetThemeAppProperties = ((PFNWXUGETTHEMEAPPPROPERTIES)NULL) ; - m_pfnSetThemeAppProperties = ((PFNWXUSETTHEMEAPPPROPERTIES)NULL) ; - m_pfnGetCurrentThemeName = ((PFNWXUGETCURRENTTHEMENAME)NULL) ; - m_pfnGetThemeDocumentationProperty = ((PFNWXUGETTHEMEDOCUMENTATIONPROPERTY)NULL) ; - m_pfnDrawThemeParentBackground = ((PFNWXUDRAWTHEMEPARENTBACKGROUND)NULL) ; - m_pfnEnableTheming = ((PFNWXUENABLETHEMING)NULL) ; -} - -wxUxThemeEngine::~wxUxThemeEngine() -{ - if(m_hInstUXThemeDLL != ((HINSTANCE)NULL)) - { - ::FreeLibrary(m_hInstUXThemeDLL) ; - } - ResetFunctionPointers() ; -} - -#endif - // wxUSE_UXTHEME +#endif // wxUSE_UXTHEME