From 552639c3590e793023539078bd97aa8b1ba2c2d3 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 29 Aug 2014 16:53:31 +0200 Subject: Windows XP, Vista styles: Share dynamically resolved theme functions. Extract a struct containing the function pointers and derive QWindowsXPStylePrivate from it, so that both styles can use them. Remove duplicated variables. Task-number: QTBUG-38858 Change-Id: I7c2c665b5930c56ffdf33c5185720f71517d146c Reviewed-by: Alessandro Portale --- src/widgets/styles/qwindowsxpstyle_p_p.h | 60 +++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) (limited to 'src/widgets/styles/qwindowsxpstyle_p_p.h') diff --git a/src/widgets/styles/qwindowsxpstyle_p_p.h b/src/widgets/styles/qwindowsxpstyle_p_p.h index 7327fa5581..190055b24b 100644 --- a/src/widgets/styles/qwindowsxpstyle_p_p.h +++ b/src/widgets/styles/qwindowsxpstyle_p_p.h @@ -282,7 +282,65 @@ struct ThemeMapData { hasAlphaChannel(false), wasAlphaSwapped(false), hadInvalidAlpha(false) {} }; -class QWindowsXPStylePrivate : public QWindowsStylePrivate +struct QWindowsUxThemeLib { + typedef bool (WINAPI *PtrIsAppThemed)(); + typedef bool (WINAPI *PtrIsThemeActive)(); + typedef HTHEME (WINAPI *PtrOpenThemeData)(HWND hwnd, LPCWSTR pszClassList); + typedef HRESULT (WINAPI *PtrCloseThemeData)(HTHEME hTheme); + typedef HRESULT (WINAPI *PtrDrawThemeBackground)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, OPTIONAL const RECT *pClipRect); + typedef HRESULT (WINAPI *PtrDrawThemeBackgroundEx)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, OPTIONAL const DTBGOPTS *pOptions); + typedef HRESULT (WINAPI *PtrGetCurrentThemeName)(OUT LPWSTR pszThemeFileName, int cchMaxNameChars, OUT OPTIONAL LPWSTR pszColorBuff, int cchMaxColorChars, OUT OPTIONAL LPWSTR pszSizeBuff, int cchMaxSizeChars); + typedef HRESULT (WINAPI *PtrGetThemeDocumentationProperty)(LPCWSTR pszThemeName, LPCWSTR pszPropertyName, OUT LPWSTR pszValueBuff, int cchMaxValChars); + typedef HRESULT (WINAPI *PtrGetThemeBool)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT BOOL *pfVal); + typedef HRESULT (WINAPI *PtrGetThemeColor)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT COLORREF *pColor); + typedef HRESULT (WINAPI *PtrGetThemeEnumValue)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT int *piVal); + typedef HRESULT (WINAPI *PtrGetThemeFilename)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT LPWSTR pszThemeFileName, int cchMaxBuffChars); + typedef HRESULT (WINAPI *PtrGetThemeFont)(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, int iStateId, int iPropId, OUT LOGFONT *pFont); + typedef HRESULT (WINAPI *PtrGetThemeInt)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT int *piVal); + typedef HRESULT (WINAPI *PtrGetThemeIntList)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT INTLIST *pIntList); + typedef HRESULT (WINAPI *PtrGetThemeMargins)(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, int iStateId, int iPropId, OPTIONAL RECT *prc, OUT MARGINS *pMargins); + typedef HRESULT (WINAPI *PtrGetThemeMetric)(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, int iStateId, int iPropId, OUT int *piVal); + typedef HRESULT (WINAPI *PtrGetThemePartSize)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, OPTIONAL RECT *prc, enum THEMESIZE eSize, OUT SIZE *psz); + typedef HRESULT (WINAPI *PtrGetThemePosition)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT POINT *pPoint); + typedef HRESULT (WINAPI *PtrGetThemePropertyOrigin)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT enum PROPERTYORIGIN *pOrigin); + typedef HRESULT (WINAPI *PtrGetThemeRect)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT RECT *pRect); + typedef HRESULT (WINAPI *PtrGetThemeString)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT LPWSTR pszBuff, int cchMaxBuffChars); + typedef HRESULT (WINAPI *PtrGetThemeBackgroundRegion)(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, int iStateId, const RECT *pRect, OUT HRGN *pRegion); + typedef BOOL (WINAPI *PtrIsThemeBackgroundPartiallyTransparent)(HTHEME hTheme, int iPartId, int iStateId); + typedef HRESULT (WINAPI *PtrSetWindowTheme)(HWND hwnd, LPCWSTR pszSubAppName, LPCWSTR pszSubIdList); + typedef HRESULT (WINAPI *PtrGetThemeTransitionDuration)(HTHEME hTheme, int iPartId, int iStateFromId, int iStateToId, int iPropId, int *pDuration); + + static bool resolveSymbols(); + + static PtrIsAppThemed pIsAppThemed; + static PtrIsThemeActive pIsThemeActive; + static PtrOpenThemeData pOpenThemeData; + static PtrCloseThemeData pCloseThemeData; + static PtrDrawThemeBackground pDrawThemeBackground; + static PtrDrawThemeBackgroundEx pDrawThemeBackgroundEx; + static PtrGetCurrentThemeName pGetCurrentThemeName; + static PtrGetThemeBool pGetThemeBool; + static PtrGetThemeColor pGetThemeColor; + static PtrGetThemeEnumValue pGetThemeEnumValue; + static PtrGetThemeFilename pGetThemeFilename; + static PtrGetThemeFont pGetThemeFont; + static PtrGetThemeInt pGetThemeInt; + static PtrGetThemeIntList pGetThemeIntList; + static PtrGetThemeMargins pGetThemeMargins; + static PtrGetThemeMetric pGetThemeMetric; + static PtrGetThemePartSize pGetThemePartSize; + static PtrGetThemePosition pGetThemePosition; + static PtrGetThemePropertyOrigin pGetThemePropertyOrigin; + static PtrGetThemeRect pGetThemeRect; + static PtrGetThemeString pGetThemeString; + static PtrGetThemeBackgroundRegion pGetThemeBackgroundRegion; + static PtrGetThemeDocumentationProperty pGetThemeDocumentationProperty; + static PtrIsThemeBackgroundPartiallyTransparent pIsThemeBackgroundPartiallyTransparent; + static PtrSetWindowTheme pSetWindowTheme; + static PtrGetThemeTransitionDuration pGetThemeTransitionDuration; // Windows Vista onwards. +}; + +class QWindowsXPStylePrivate : public QWindowsStylePrivate, public QWindowsUxThemeLib { Q_DECLARE_PUBLIC(QWindowsXPStyle) public: -- cgit v1.2.3