summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2016-05-13 09:12:19 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2016-05-17 14:34:45 +0000
commitaf6b700bb8b8e73406e07d0544300706dd1e6f41 (patch)
tree340875987663795f99cedad72047aca3947b4ff8
parent3eb3007e9c75eea81a2b20749dc61ca31c9bc699 (diff)
QtWidgets: Increase Windows API level to 0x600 (Windows Vista).
Define WINVER, _WIN32_WINNT for MinGW in win.pri. Directly link to uxtheme and dwmapi and remove dynamic loading of functions that are present in Windows Vista onwards. Remove duplicated declarations of constants that are now present in the SDKs. Task-number: QTBUG-51673 Change-Id: I695a6673d7250b2788fd2f20aebd222fcabb0d47 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r--src/widgets/dialogs/qwizard_win.cpp252
-rw-r--r--src/widgets/dialogs/qwizard_win_p.h2
-rw-r--r--src/widgets/kernel/win.pri4
-rw-r--r--src/widgets/styles/qwindowsstyle.cpp27
-rw-r--r--src/widgets/styles/qwindowsvistastyle.cpp62
-rw-r--r--src/widgets/styles/qwindowsxpstyle.cpp291
-rw-r--r--src/widgets/styles/qwindowsxpstyle_p_p.h163
-rw-r--r--src/widgets/util/qsystemtrayicon_win.cpp10
8 files changed, 134 insertions, 677 deletions
diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp
index 8bc5ba7f56..9d8e7c4b66 100644
--- a/src/widgets/dialogs/qwizard_win.cpp
+++ b/src/widgets/dialogs/qwizard_win.cpp
@@ -41,7 +41,6 @@
#ifndef QT_NO_STYLE_WINDOWSVISTA
#include "qwizard_win_p.h"
-#include <private/qsystemlibrary_p.h>
#include <private/qapplication_p.h>
#include <qpa/qplatformnativeinterface.h>
#include "qwizard.h"
@@ -54,112 +53,19 @@
#include <QtWidgets/QDesktopWidget>
#include <uxtheme.h>
+#include <vssym32.h>
+#include <dwmapi.h>
Q_DECLARE_METATYPE(QMargins)
-QT_BEGIN_NAMESPACE
+#ifndef WM_DWMCOMPOSITIONCHANGED
+# define WM_DWMCOMPOSITIONCHANGED 0x031E
+#endif
-//DWM related
-typedef struct { //MARGINS
- int cxLeftWidth; // width of left border that retains its size
- int cxRightWidth; // width of right border that retains its size
- int cyTopHeight; // height of top border that retains its size
- int cyBottomHeight; // height of bottom border that retains its size
-} WIZ_MARGINS;
-typedef struct { //DTTOPTS
- DWORD dwSize;
- DWORD dwFlags;
- COLORREF crText;
- COLORREF crBorder;
- COLORREF crShadow;
- int eTextShadowType;
- POINT ptShadowOffset;
- int iBorderSize;
- int iFontPropId;
- int iColorPropId;
- int iStateId;
- BOOL fApplyOverlay;
- int iGlowSize;
-} WIZ_DTTOPTS;
-
-typedef struct {
- DWORD dwFlags;
- DWORD dwMask;
-} WIZ_WTA_OPTIONS;
-
-#define WIZ_WM_THEMECHANGED 0x031A
-#define WIZ_WM_DWMCOMPOSITIONCHANGED 0x031E
-
-enum WIZ_WINDOWTHEMEATTRIBUTETYPE {
- WIZ_WTA_NONCLIENT = 1
-};
-
-#define WIZ_WTNCA_NODRAWCAPTION 0x00000001
-#define WIZ_WTNCA_NODRAWICON 0x00000002
-
-#define WIZ_DT_CENTER 0x00000001 //DT_CENTER
-#define WIZ_DT_VCENTER 0x00000004
-#define WIZ_DT_SINGLELINE 0x00000020
-#define WIZ_DT_NOPREFIX 0x00000800
-
-enum WIZ_NAVIGATIONPARTS { //NAVIGATIONPARTS
- WIZ_NAV_BACKBUTTON = 1,
- WIZ_NAV_FORWARDBUTTON = 2,
- WIZ_NAV_MENUBUTTON = 3,
-};
-
-enum WIZ_NAV_BACKBUTTONSTATES { //NAV_BACKBUTTONSTATES
- WIZ_NAV_BB_NORMAL = 1,
- WIZ_NAV_BB_HOT = 2,
- WIZ_NAV_BB_PRESSED = 3,
- WIZ_NAV_BB_DISABLED = 4,
-};
-
-#define WIZ_TMT_CAPTIONFONT (801) //TMT_CAPTIONFONT
-#define WIZ_DTT_COMPOSITED (1UL << 13) //DTT_COMPOSITED
-#define WIZ_DTT_GLOWSIZE (1UL << 11) //DTT_GLOWSIZE
-
-#define WIZ_WM_NCMOUSELEAVE 674 //WM_NCMOUSELEAVE
-
-#define WIZ_WP_CAPTION 1 //WP_CAPTION
-#define WIZ_CS_ACTIVE 1 //CS_ACTIVE
-#define WIZ_TMT_FILLCOLORHINT 3821 //TMT_FILLCOLORHINT
-#define WIZ_TMT_BORDERCOLORHINT 3822 //TMT_BORDERCOLORHINT
-
-typedef BOOL (WINAPI *PtrDwmDefWindowProc)(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *plResult);
-typedef HRESULT (WINAPI *PtrDwmIsCompositionEnabled)(BOOL* pfEnabled);
-typedef HRESULT (WINAPI *PtrDwmExtendFrameIntoClientArea)(HWND hWnd, const WIZ_MARGINS* pMarInset);
-typedef HRESULT (WINAPI *PtrSetWindowThemeAttribute)(HWND hwnd, enum WIZ_WINDOWTHEMEATTRIBUTETYPE eAttribute, PVOID pvAttribute, DWORD cbAttribute);
-
-static PtrDwmDefWindowProc pDwmDefWindowProc = 0;
-static PtrDwmIsCompositionEnabled pDwmIsCompositionEnabled = 0;
-static PtrDwmExtendFrameIntoClientArea pDwmExtendFrameIntoClientArea = 0;
-static PtrSetWindowThemeAttribute pSetWindowThemeAttribute = 0;
-
-//Theme related
-typedef bool (WINAPI *PtrIsAppThemed)();
-typedef bool (WINAPI *PtrIsThemeActive)();
-typedef HANDLE (WINAPI *PtrOpenThemeData)(HWND hwnd, LPCWSTR pszClassList);
-typedef HRESULT (WINAPI *PtrCloseThemeData)(HANDLE hTheme);
-typedef HRESULT (WINAPI *PtrGetThemeSysFont)(HANDLE hTheme, int iFontId, LOGFONTW *plf);
-typedef HRESULT (WINAPI *PtrDrawThemeTextEx)(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int cchText, DWORD dwTextFlags, LPRECT pRect, const WIZ_DTTOPTS *pOptions);
-typedef HRESULT (WINAPI *PtrDrawThemeBackground)(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, OPTIONAL const RECT *pClipRect);
-typedef HRESULT (WINAPI *PtrGetThemePartSize)(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, OPTIONAL RECT *prc, enum THEMESIZE eSize, OUT SIZE *psz);
-typedef HRESULT (WINAPI *PtrGetThemeColor)(HANDLE hTheme, int iPartId, int iStateId, int iPropId, OUT COLORREF *pColor);
-
-static PtrIsAppThemed pIsAppThemed = 0;
-static PtrIsThemeActive pIsThemeActive = 0;
-static PtrOpenThemeData pOpenThemeData = 0;
-static PtrCloseThemeData pCloseThemeData = 0;
-static PtrGetThemeSysFont pGetThemeSysFont = 0;
-static PtrDrawThemeTextEx pDrawThemeTextEx = 0;
-static PtrDrawThemeBackground pDrawThemeBackground = 0;
-static PtrGetThemePartSize pGetThemePartSize = 0;
-static PtrGetThemeColor pGetThemeColor = 0;
+QT_BEGIN_NAMESPACE
int QVistaHelper::instanceCount = 0;
int QVistaHelper::m_devicePixelRatio = 1;
-bool QVistaHelper::is_vista = false;
QVistaHelper::VistaState QVistaHelper::cachedVistaState = QVistaHelper::Dirty;
/******************************************************************************
@@ -179,14 +85,6 @@ QSize QVistaBackButton::sizeHint() const
ensurePolished();
int size = int(QStyleHelper::dpiScaled(32));
int width = size, height = size;
-/*
- HANDLE theme = pOpenThemeData(0, L"Navigation");
- SIZE size;
- if (pGetThemePartSize(theme, 0, WIZ_NAV_BACKBUTTON, WIZ_NAV_BB_NORMAL, 0, TS_TRUE, &size) == S_OK) {
- width = size.cx;
- height = size.cy;
- }
-*/
return QSize(width, height);
}
@@ -208,7 +106,7 @@ void QVistaBackButton::paintEvent(QPaintEvent *)
{
QPainter p(this);
QRect r = rect();
- HANDLE theme = pOpenThemeData(0, L"Navigation");
+ const HANDLE theme = OpenThemeData(0, L"Navigation");
//RECT rect;
QPoint origin;
const HDC hdc = QVistaHelper::backingStoreDC(parentWidget(), &origin);
@@ -225,19 +123,17 @@ void QVistaBackButton::paintEvent(QPaintEvent *)
clipRect.left = rDp.left() + xoffsetDp;
clipRect.right = rDp.right() + xoffsetDp;
- int state = WIZ_NAV_BB_NORMAL;
+ int state = NAV_BB_NORMAL;
if (!isEnabled())
- state = WIZ_NAV_BB_DISABLED;
+ state = NAV_BB_DISABLED;
else if (isDown())
- state = WIZ_NAV_BB_PRESSED;
+ state = NAV_BB_PRESSED;
else if (underMouse())
- state = WIZ_NAV_BB_HOT;
-
- WIZ_NAVIGATIONPARTS buttonType = (layoutDirection() == Qt::LeftToRight
- ? WIZ_NAV_BACKBUTTON
- : WIZ_NAV_FORWARDBUTTON);
+ state = NAV_BB_HOT;
- pDrawThemeBackground(theme, hdc, buttonType, state, &clipRect, &clipRect);
+ DrawThemeBackground(theme, hdc,
+ layoutDirection() == Qt::LeftToRight ? NAV_BACKBUTTON : NAV_FORWARDBUTTON,
+ state, &clipRect, &clipRect);
}
/******************************************************************************
@@ -251,13 +147,10 @@ QVistaHelper::QVistaHelper(QWizard *wizard)
, backButton_(0)
{
QVistaHelper::m_devicePixelRatio = wizard->devicePixelRatio();
- is_vista = resolveSymbols();
if (instanceCount++ == 0)
cachedVistaState = Dirty;
- if (is_vista) {
- backButton_ = new QVistaBackButton(wizard);
- backButton_->hide();
- }
+ backButton_ = new QVistaBackButton(wizard);
+ backButton_->hide();
// Handle diff between Windows 7 and Vista
iconSpacing = QStyleHelper::dpiScaled(7);
@@ -292,20 +185,13 @@ void QVistaHelper::updateCustomMargins(bool vistaMargins)
bool QVistaHelper::isCompositionEnabled()
{
- bool value = is_vista;
- if (is_vista) {
- HRESULT hr;
- BOOL bEnabled;
-
- hr = pDwmIsCompositionEnabled(&bEnabled);
- value = (SUCCEEDED(hr) && bEnabled);
- }
- return value;
+ BOOL bEnabled;
+ return SUCCEEDED(DwmIsCompositionEnabled(&bEnabled)) && bEnabled;
}
bool QVistaHelper::isThemeActive()
{
- return is_vista && pIsThemeActive();
+ return IsThemeActive();
}
QVistaHelper::VistaState QVistaHelper::vistaState()
@@ -326,11 +212,9 @@ QColor QVistaHelper::basicWindowFrameColor()
{
DWORD rgb;
HWND handle = QApplicationPrivate::getHWNDForWidget(QApplication::desktop());
- HANDLE hTheme = pOpenThemeData(handle, L"WINDOW");
- pGetThemeColor(
- hTheme, WIZ_WP_CAPTION, WIZ_CS_ACTIVE,
- wizard->isActiveWindow() ? WIZ_TMT_FILLCOLORHINT : WIZ_TMT_BORDERCOLORHINT,
- &rgb);
+ const HANDLE hTheme = OpenThemeData(handle, L"WINDOW");
+ GetThemeColor(hTheme, WP_CAPTION, CS_ACTIVE,
+ wizard->isActiveWindow() ? TMT_FILLCOLORHINT : TMT_BORDERCOLORHINT, &rgb);
BYTE r = GetRValue(rgb);
BYTE g = GetGValue(rgb);
BYTE b = GetBValue(rgb);
@@ -341,13 +225,13 @@ bool QVistaHelper::setDWMTitleBar(TitleBarChangeType type)
{
bool value = false;
if (vistaState() == VistaAero) {
- WIZ_MARGINS mar = {0, 0, 0, 0};
+ MARGINS mar = {0, 0, 0, 0};
if (type == NormalTitleBar)
mar.cyTopHeight = 0;
else
mar.cyTopHeight = (titleBarSize() + topOffset()) * QVistaHelper::m_devicePixelRatio;
if (const HWND wizardHandle = wizardHWND())
- if (SUCCEEDED(pDwmExtendFrameIntoClientArea(wizardHandle, &mar)))
+ if (SUCCEEDED(DwmExtendFrameIntoClientArea(wizardHandle, &mar)))
value = true;
}
return value;
@@ -359,7 +243,7 @@ static LOGFONT getCaptionLogFont(HANDLE hTheme)
{
LOGFONT result = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0 } };
- if (!hTheme || FAILED(pGetThemeSysFont(hTheme, WIZ_TMT_CAPTIONFONT, &result))) {
+ if (!hTheme || FAILED(GetThemeSysFont(hTheme, TMT_CAPTIONFONT, &result))) {
NONCLIENTMETRICS ncm;
ncm.cbSize = sizeof(NONCLIENTMETRICS);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, false);
@@ -370,10 +254,8 @@ static LOGFONT getCaptionLogFont(HANDLE hTheme)
static bool getCaptionQFont(int dpi, QFont *result)
{
- if (!pOpenThemeData)
- return false;
const HANDLE hTheme =
- pOpenThemeData(QApplicationPrivate::getHWNDForWidget(QApplication::desktop()), L"WINDOW");
+ OpenThemeData(QApplicationPrivate::getHWNDForWidget(QApplication::desktop()), L"WINDOW");
if (!hTheme)
return false;
// Call into QWindowsNativeInterface to convert the LOGFONT into a QFont.
@@ -448,16 +330,14 @@ void QVistaHelper::drawTitleBar(QPainter *painter)
void QVistaHelper::setTitleBarIconAndCaptionVisible(bool visible)
{
- if (is_vista) {
- WIZ_WTA_OPTIONS opt;
- opt.dwFlags = WIZ_WTNCA_NODRAWICON | WIZ_WTNCA_NODRAWCAPTION;
- if (visible)
- opt.dwMask = 0;
- else
- opt.dwMask = WIZ_WTNCA_NODRAWICON | WIZ_WTNCA_NODRAWCAPTION;
- if (const HWND handle = wizardHWND())
- pSetWindowThemeAttribute(handle, WIZ_WTA_NONCLIENT, &opt, sizeof(WIZ_WTA_OPTIONS));
- }
+ WTA_OPTIONS opt;
+ opt.dwFlags = WTNCA_NODRAWICON | WTNCA_NODRAWCAPTION;
+ if (visible)
+ opt.dwMask = 0;
+ else
+ opt.dwMask = WTNCA_NODRAWICON | WTNCA_NODRAWCAPTION;
+ if (const HWND handle = wizardHWND())
+ SetWindowThemeAttribute(handle, WTA_NONCLIENT, &opt, sizeof(WTA_OPTIONS));
}
bool QVistaHelper::winEvent(MSG* msg, long* result)
@@ -466,7 +346,7 @@ bool QVistaHelper::winEvent(MSG* msg, long* result)
case WM_NCHITTEST: {
LRESULT lResult;
// Perform hit testing using DWM
- if (pDwmDefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam, &lResult)) {
+ if (DwmDefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam, &lResult)) {
// DWM returned a hit, no further processing necessary
*result = lResult;
} else {
@@ -485,7 +365,7 @@ bool QVistaHelper::winEvent(MSG* msg, long* result)
default:
LRESULT lResult;
// Pass to DWM to handle
- if (pDwmDefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam, &lResult))
+ if (DwmDefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam, &lResult))
*result = lResult;
// If the message wasn't handled by DWM, continue processing it as normal
else
@@ -524,7 +404,7 @@ void QVistaHelper::mouseEvent(QEvent *event)
bool QVistaHelper::handleWinEvent(MSG *message, long *result)
{
- if (message->message == WIZ_WM_THEMECHANGED || message->message == WIZ_WM_DWMCOMPOSITIONCHANGED)
+ if (message->message == WM_THEMECHANGED || message->message == WM_DWMCOMPOSITIONCHANGED)
cachedVistaState = Dirty;
bool status = false;
@@ -707,7 +587,7 @@ bool QVistaHelper::drawTitleText(QPainter *painter, const QString &text, const Q
const QRect rectDp = QRect(rect.topLeft() * QVistaHelper::m_devicePixelRatio,
rect.size() * QVistaHelper::m_devicePixelRatio);
HWND handle = QApplicationPrivate::getHWNDForWidget(QApplication::desktop());
- HANDLE hTheme = pOpenThemeData(handle, L"WINDOW");
+ const HANDLE hTheme = OpenThemeData(handle, L"WINDOW");
if (!hTheme) return false;
// Set up a memory DC and bitmap that we'll draw into
HDC dcMem;
@@ -732,15 +612,16 @@ bool QVistaHelper::drawTitleText(QPainter *painter, const QString &text, const Q
HFONT hOldFont = (HFONT)SelectObject(dcMem, (HGDIOBJ) hCaptionFont);
// Draw the text!
- WIZ_DTTOPTS dto;
- dto.dwSize = sizeof(WIZ_DTTOPTS);
- const UINT uFormat = WIZ_DT_SINGLELINE|WIZ_DT_CENTER|WIZ_DT_VCENTER|WIZ_DT_NOPREFIX;
+ DTTOPTS dto;
+ memset(&dto, 0, sizeof(dto));
+ dto.dwSize = sizeof(dto);
+ const UINT uFormat = DT_SINGLELINE|DT_CENTER|DT_VCENTER|DT_NOPREFIX;
RECT rctext ={0,0, rectDp.width(), rectDp.height()};
- dto.dwFlags = WIZ_DTT_COMPOSITED|WIZ_DTT_GLOWSIZE;
+ dto.dwFlags = DTT_COMPOSITED|DTT_GLOWSIZE;
dto.iGlowSize = glowSize();
- pDrawThemeTextEx(hTheme, dcMem, 0, 0, (LPCWSTR)text.utf16(), -1, uFormat, &rctext, &dto );
+ DrawThemeTextEx(hTheme, dcMem, 0, 0, reinterpret_cast<LPCWSTR>(text.utf16()), -1, uFormat, &rctext, &dto );
BitBlt(hdc, rectDp.left(), rectDp.top(), rectDp.width(), rectDp.height(), dcMem, 0, 0, SRCCOPY);
SelectObject(dcMem, (HGDIOBJ) hOldBmp);
SelectObject(dcMem, (HGDIOBJ) hOldFont);
@@ -813,51 +694,6 @@ int QVistaHelper::captionSizeDp()
return GetSystemMetrics(SM_CYCAPTION);
}
-bool QVistaHelper::resolveSymbols()
-{
- static bool tried = false;
- if (!tried) {
- tried = true;
- QSystemLibrary dwmLib(L"dwmapi");
- pDwmIsCompositionEnabled =
- (PtrDwmIsCompositionEnabled)dwmLib.resolve("DwmIsCompositionEnabled");
- if (pDwmIsCompositionEnabled) {
- pDwmDefWindowProc = (PtrDwmDefWindowProc)dwmLib.resolve("DwmDefWindowProc");
- pDwmExtendFrameIntoClientArea =
- (PtrDwmExtendFrameIntoClientArea)dwmLib.resolve("DwmExtendFrameIntoClientArea");
- }
- QSystemLibrary themeLib(L"uxtheme");
- pIsAppThemed = (PtrIsAppThemed)themeLib.resolve("IsAppThemed");
- if (pIsAppThemed) {
- pDrawThemeBackground = (PtrDrawThemeBackground)themeLib.resolve("DrawThemeBackground");
- pGetThemePartSize = (PtrGetThemePartSize)themeLib.resolve("GetThemePartSize");
- pGetThemeColor = (PtrGetThemeColor)themeLib.resolve("GetThemeColor");
- pIsThemeActive = (PtrIsThemeActive)themeLib.resolve("IsThemeActive");
- pOpenThemeData = (PtrOpenThemeData)themeLib.resolve("OpenThemeData");
- pCloseThemeData = (PtrCloseThemeData)themeLib.resolve("CloseThemeData");
- pGetThemeSysFont = (PtrGetThemeSysFont)themeLib.resolve("GetThemeSysFont");
- pDrawThemeTextEx = (PtrDrawThemeTextEx)themeLib.resolve("DrawThemeTextEx");
- pSetWindowThemeAttribute = (PtrSetWindowThemeAttribute)themeLib.resolve("SetWindowThemeAttribute");
- }
- }
-
- return (
- pDwmIsCompositionEnabled != 0
- && pDwmDefWindowProc != 0
- && pDwmExtendFrameIntoClientArea != 0
- && pIsAppThemed != 0
- && pDrawThemeBackground != 0
- && pGetThemePartSize != 0
- && pGetThemeColor != 0
- && pIsThemeActive != 0
- && pOpenThemeData != 0
- && pCloseThemeData != 0
- && pGetThemeSysFont != 0
- && pDrawThemeTextEx != 0
- && pSetWindowThemeAttribute != 0
- );
-}
-
int QVistaHelper::titleOffset()
{
int iconOffset = wizard ->windowIcon().isNull() ? 0 : iconSize() + textSpacing;
diff --git a/src/widgets/dialogs/qwizard_win_p.h b/src/widgets/dialogs/qwizard_win_p.h
index 42b4dee784..c0aa6f7bc4 100644
--- a/src/widgets/dialogs/qwizard_win_p.h
+++ b/src/widgets/dialogs/qwizard_win_p.h
@@ -126,7 +126,6 @@ private:
int leftMargin() { return backButton_->isVisible() ? backButtonSize() + iconSpacing : 0; }
int titleOffset();
- bool resolveSymbols();
void drawTitleBar(QPainter *painter);
void setMouseCursor(QPoint pos);
void collapseTopFrameStrut();
@@ -137,7 +136,6 @@ private:
bool eventFilter(QObject *obj, QEvent *event);
static int instanceCount;
- static bool is_vista;
static VistaState cachedVistaState;
static bool isCompositionEnabled();
static bool isThemeActive();
diff --git a/src/widgets/kernel/win.pri b/src/widgets/kernel/win.pri
index a3121287b3..7cef2d14a8 100644
--- a/src/widgets/kernel/win.pri
+++ b/src/widgets/kernel/win.pri
@@ -2,4 +2,6 @@
# --------------------------------------------------------------------
INCLUDEPATH += ../3rdparty/wintab
-!winrt: LIBS_PRIVATE *= -lshell32
+!winrt: LIBS_PRIVATE *= -lshell32 -luxtheme -ldwmapi
+# Override MinGW's definition in _mingw.h
+mingw: DEFINES += WINVER=0x600 _WIN32_WINNT=0x0600
diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp
index e0e9d0f6f1..7ce9bbc273 100644
--- a/src/widgets/styles/qwindowsstyle.cpp
+++ b/src/widgets/styles/qwindowsstyle.cpp
@@ -42,7 +42,6 @@
#if !defined(QT_NO_STYLE_WINDOWS) || defined(QT_PLUGIN)
-#include <private/qsystemlibrary_p.h>
#include "qapplication.h"
#include "qbitmap.h"
#include "qdrawutil.h" // for now
@@ -87,26 +86,7 @@ QT_END_INCLUDE_NAMESPACE
# define COLOR_GRADIENTINACTIVECAPTION 28
# endif
-
-typedef struct
-{
- DWORD cbSize;
- HICON hIcon;
- int iSysImageIndex;
- int iIcon;
- WCHAR szPath[MAX_PATH];
-} QSHSTOCKICONINFO;
-
-#define _SHGFI_SMALLICON 0x000000001
-#define _SHGFI_LARGEICON 0x000000000
-#define _SHGFI_ICON 0x000000100
-#define _SIID_SHIELD 77
-
-typedef HRESULT (WINAPI *PtrSHGetStockIconInfo)(int siid, int uFlags, QSHSTOCKICONINFO *psii);
-static PtrSHGetStockIconInfo pSHGetStockIconInfo = 0;
-
Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &);
-Q_GUI_EXPORT QPixmap qt_pixmapFromWinHICON(HICON icon);
#endif //Q_OS_WIN
QT_BEGIN_INCLUDE_NAMESPACE
@@ -122,13 +102,6 @@ enum QSliderDirection { SlUp, SlDown, SlLeft, SlRight };
QWindowsStylePrivate::QWindowsStylePrivate()
: alt_down(false), menuBarTimer(0)
{
-#if defined(Q_OS_WIN)
- if ((QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
- && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))) {
- QSystemLibrary shellLib(QLatin1String("shell32"));
- pSHGetStockIconInfo = (PtrSHGetStockIconInfo)shellLib.resolve("SHGetStockIconInfo");
- }
-#endif
}
qreal QWindowsStylePrivate::appDevicePixelRatio()
diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp
index dce0a93e10..83820016aa 100644
--- a/src/widgets/styles/qwindowsvistastyle.cpp
+++ b/src/widgets/styles/qwindowsvistastyle.cpp
@@ -43,7 +43,6 @@
#include <qwindow.h>
#include <private/qstyleanimation_p.h>
#include <private/qstylehelper_p.h>
-#include <private/qsystemlibrary_p.h>
#include <private/qapplication_p.h>
#include <qpa/qplatformnativeinterface.h>
@@ -88,8 +87,7 @@ bool QWindowsVistaStylePrivate::useVista()
{
return (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
&& (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))
- && QWindowsVistaStylePrivate::useXP()
- && QWindowsVistaStylePrivate::pGetThemeTransitionDuration != Q_NULLPTR;
+ && QWindowsVistaStylePrivate::useXP();
}
/* \internal
@@ -356,13 +354,13 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
HTHEME theme;
int partId;
- int duration;
+ DWORD duration;
int fromState = 0;
int toState = 0;
//translate state flags to UXTHEME states :
if (element == PE_FrameLineEdit) {
- theme = QWindowsXPStylePrivate::pOpenThemeData(0, L"Edit");
+ theme = OpenThemeData(0, L"Edit");
partId = EP_EDITBORDER_NOSCROLL;
if (oldState & State_MouseOver)
@@ -380,7 +378,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
toState = ETS_NORMAL;
} else {
- theme = QWindowsXPStylePrivate::pOpenThemeData(0, L"Button");
+ theme = OpenThemeData(0, L"Button");
if (element == PE_IndicatorRadioButton)
partId = BP_RADIOBUTTON;
else if (element == PE_IndicatorCheckBox)
@@ -393,9 +391,9 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
}
// Retrieve the transition time between the states from the system.
- if (theme && QWindowsXPStylePrivate::pGetThemeTransitionDuration(theme, partId, fromState, toState,
- TMT_TRANSITIONDURATIONS, &duration) == S_OK)
- {
+ if (theme
+ && SUCCEEDED(GetThemeTransitionDuration(theme, partId, fromState, toState,
+ TMT_TRANSITIONDURATIONS, &duration))) {
t->setDuration(duration);
}
t->setStartTime(QTime::currentTime());
@@ -513,7 +511,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
EP_EDITBORDER_HVSCROLL, stateId, option->rect);
// Since EP_EDITBORDER_HVSCROLL does not us borderfill, theme.noContent cannot be used for clipping
int borderSize = 1;
- QWindowsXPStylePrivate::pGetThemeInt(theme.handle(), theme.partId, theme.stateId, TMT_BORDERSIZE, &borderSize);
+ GetThemeInt(theme.handle(), theme.partId, theme.stateId, TMT_BORDERSIZE, &borderSize);
QRegion clipRegion = option->rect;
QRegion content = option->rect.adjusted(borderSize, borderSize, -borderSize, -borderSize);
clipRegion ^= content;
@@ -548,22 +546,18 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
return;
}
int bgType;
- QWindowsXPStylePrivate::pGetThemeEnumValue( theme.handle(),
- partId,
- stateId,
- TMT_BGTYPE,
- &bgType);
+ GetThemeEnumValue(theme.handle(), partId, stateId, TMT_BGTYPE, &bgType);
if( bgType == BT_IMAGEFILE ) {
d->drawBackground(theme);
} else {
QBrush fillColor = option->palette.brush(QPalette::Base);
if (!isEnabled) {
PROPERTYORIGIN origin = PO_NOTFOUND;
- QWindowsXPStylePrivate::pGetThemePropertyOrigin(theme.handle(), theme.partId, theme.stateId, TMT_FILLCOLOR, &origin);
+ GetThemePropertyOrigin(theme.handle(), theme.partId, theme.stateId, TMT_FILLCOLOR, &origin);
// Use only if the fill property comes from our part
if ((origin == PO_PART || origin == PO_STATE)) {
COLORREF bgRef;
- QWindowsXPStylePrivate::pGetThemeColor(theme.handle(), partId, stateId, TMT_FILLCOLOR, &bgRef);
+ GetThemeColor(theme.handle(), partId, stateId, TMT_FILLCOLOR, &bgRef);
fillColor = QBrush(qRgb(GetRValue(bgRef), GetGValue(bgRef), GetBValue(bgRef)));
}
}
@@ -899,12 +893,12 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
t->setEndImage(endImage);
- int duration = 0;
- HTHEME theme = QWindowsXPStylePrivate::pOpenThemeData(0, L"Button");
+ DWORD duration = 0;
+ const HTHEME theme = OpenThemeData(0, L"Button");
int fromState = buttonStateId(oldState, BP_PUSHBUTTON);
int toState = buttonStateId(option->state, BP_PUSHBUTTON);
- if (QWindowsXPStylePrivate::pGetThemeTransitionDuration(theme, BP_PUSHBUTTON, fromState, toState, TMT_TRANSITIONDURATIONS, &duration) == S_OK)
+ if (GetThemeTransitionDuration(theme, BP_PUSHBUTTON, fromState, toState, TMT_TRANSITIONDURATIONS, &duration) == S_OK)
t->setDuration(duration);
else
t->setDuration(0);
@@ -1456,7 +1450,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
// We cannot currently get the correct selection color for "explorer style" views
COLORREF cref = 0;
XPThemeData theme(d->treeViewHelper(), 0, QLatin1String("LISTVIEW"), 0, 0);
- unsigned int res = pGetThemeColor(theme.handle(), LVP_LISTITEM, LISS_SELECTED, TMT_TEXTCOLOR, &cref);
+ unsigned int res = GetThemeColor(theme.handle(), LVP_LISTITEM, LISS_SELECTED, TMT_TEXTCOLOR, &cref);
QColor textColor(GetRValue(cref), GetGValue(cref), GetBValue(cref));
*/
QPalette palette = vopt->palette;
@@ -1925,7 +1919,7 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption
case SE_PushButtonContents:
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
MARGINS borderSize;
- HTHEME theme = QWindowsXPStylePrivate::pOpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : 0, L"Button");
+ const HTHEME theme = OpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : 0, L"Button");
if (theme) {
int stateId = PBS_NORMAL;
if (!(option->state & State_Enabled))
@@ -1940,15 +1934,7 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption
int border = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget);
rect = option->rect.adjusted(border, border, -border, -border);
- int result = QWindowsXPStylePrivate::pGetThemeMargins(theme,
- NULL,
- BP_PUSHBUTTON,
- stateId,
- TMT_CONTENTMARGINS,
- NULL,
- &borderSize);
-
- if (result == S_OK) {
+ if (SUCCEEDED(GetThemeMargins(theme, NULL, BP_PUSHBUTTON, stateId, TMT_CONTENTMARGINS, NULL, &borderSize))) {
rect.adjust(borderSize.cxLeftWidth, borderSize.cyTopHeight,
-borderSize.cxRightWidth, -borderSize.cyBottomHeight);
rect = visualRect(option->direction, option->rect, rect);
@@ -2318,14 +2304,12 @@ void QWindowsVistaStyle::polish(QWidget *widget)
//we do not have to care about unpolishing
widget->setContentsMargins(3, 0, 4, 0);
COLORREF bgRef;
- HTHEME theme = QWindowsXPStylePrivate::pOpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : 0, L"TOOLTIP");
- if (theme) {
- if (QWindowsXPStylePrivate::pGetThemeColor(theme, TTP_STANDARD, TTSS_NORMAL, TMT_TEXTCOLOR, &bgRef) == S_OK) {
- QColor textColor = QColor::fromRgb(bgRef);
- QPalette pal;
- pal.setColor(QPalette::All, QPalette::ToolTipText, textColor);
- widget->setPalette(pal);
- }
+ HTHEME theme = OpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : 0, L"TOOLTIP");
+ if (theme && SUCCEEDED(GetThemeColor(theme, TTP_STANDARD, TTSS_NORMAL, TMT_TEXTCOLOR, &bgRef))) {
+ QColor textColor = QColor::fromRgb(bgRef);
+ QPalette pal;
+ pal.setColor(QPalette::All, QPalette::ToolTipText, textColor);
+ widget->setPalette(pal);
}
} else if (qobject_cast<QMessageBox *> (widget)) {
widget->setAttribute(Qt::WA_StyledBackground);
diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp
index b39cecbd73..916210ad09 100644
--- a/src/widgets/styles/qwindowsxpstyle.cpp
+++ b/src/widgets/styles/qwindowsxpstyle.cpp
@@ -47,7 +47,6 @@
#include <qpa/qplatformnativeinterface.h>
#include <private/qstylehelper_p.h>
#include <private/qwidget_p.h>
-#include <private/qsystemlibrary_p.h>
#include <qpainter.h>
#include <qpaintengine.h>
#include <qwidget.h>
@@ -76,78 +75,6 @@
QT_BEGIN_NAMESPACE
-// Runtime resolved theme engine function calls
-
-QWindowsUxThemeLib::PtrIsAppThemed QWindowsUxThemeLib::pIsAppThemed = Q_NULLPTR;
-QWindowsUxThemeLib::PtrIsThemeActive QWindowsUxThemeLib::pIsThemeActive = Q_NULLPTR;
-QWindowsUxThemeLib::PtrOpenThemeData QWindowsUxThemeLib::pOpenThemeData = Q_NULLPTR;
-QWindowsUxThemeLib::PtrCloseThemeData QWindowsUxThemeLib::pCloseThemeData = Q_NULLPTR;
-QWindowsUxThemeLib::PtrDrawThemeBackground QWindowsUxThemeLib::pDrawThemeBackground = Q_NULLPTR;
-QWindowsUxThemeLib::PtrDrawThemeBackgroundEx QWindowsUxThemeLib::pDrawThemeBackgroundEx = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetCurrentThemeName QWindowsUxThemeLib::pGetCurrentThemeName = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeBool QWindowsUxThemeLib::pGetThemeBool = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeColor QWindowsUxThemeLib::pGetThemeColor = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeEnumValue QWindowsUxThemeLib::pGetThemeEnumValue = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeFilename QWindowsUxThemeLib::pGetThemeFilename = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeFont QWindowsUxThemeLib::pGetThemeFont = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeInt QWindowsUxThemeLib::pGetThemeInt = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeIntList QWindowsUxThemeLib::pGetThemeIntList = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeMargins QWindowsUxThemeLib::pGetThemeMargins = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeMetric QWindowsUxThemeLib::pGetThemeMetric = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemePartSize QWindowsUxThemeLib::pGetThemePartSize = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemePosition QWindowsUxThemeLib::pGetThemePosition = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemePropertyOrigin QWindowsUxThemeLib::pGetThemePropertyOrigin = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeRect QWindowsUxThemeLib::pGetThemeRect = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeString QWindowsUxThemeLib::pGetThemeString = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeBackgroundRegion QWindowsUxThemeLib::pGetThemeBackgroundRegion = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeDocumentationProperty QWindowsUxThemeLib::pGetThemeDocumentationProperty = Q_NULLPTR;
-QWindowsUxThemeLib::PtrIsThemeBackgroundPartiallyTransparent
- QWindowsUxThemeLib::pIsThemeBackgroundPartiallyTransparent = Q_NULLPTR;
-QWindowsUxThemeLib::PtrSetWindowTheme QWindowsUxThemeLib::pSetWindowTheme = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeTransitionDuration QWindowsUxThemeLib::pGetThemeTransitionDuration = Q_NULLPTR;
-
-bool QWindowsUxThemeLib::resolveSymbols()
-{
- static bool tried = false;
- if (tried)
- return pIsAppThemed != Q_NULLPTR;
- tried = true;
- QSystemLibrary themeLib(QLatin1String("uxtheme"));
- if (!themeLib.load())
- return false;
- pIsAppThemed = (PtrIsAppThemed)themeLib.resolve("IsAppThemed");
- if (!pIsAppThemed)
- return false;
- pIsThemeActive = (PtrIsThemeActive )themeLib.resolve("IsThemeActive");
- pGetThemePartSize = (PtrGetThemePartSize )themeLib.resolve("GetThemePartSize");
- pOpenThemeData = (PtrOpenThemeData )themeLib.resolve("OpenThemeData");
- pCloseThemeData = (PtrCloseThemeData )themeLib.resolve("CloseThemeData");
- pDrawThemeBackground = (PtrDrawThemeBackground )themeLib.resolve("DrawThemeBackground");
- pDrawThemeBackgroundEx = (PtrDrawThemeBackgroundEx )themeLib.resolve("DrawThemeBackgroundEx");
- pGetCurrentThemeName = (PtrGetCurrentThemeName )themeLib.resolve("GetCurrentThemeName");
- pGetThemeBool = (PtrGetThemeBool )themeLib.resolve("GetThemeBool");
- pGetThemeColor = (PtrGetThemeColor )themeLib.resolve("GetThemeColor");
- pGetThemeEnumValue = (PtrGetThemeEnumValue )themeLib.resolve("GetThemeEnumValue");
- pGetThemeFilename = (PtrGetThemeFilename )themeLib.resolve("GetThemeFilename");
- pGetThemeFont = (PtrGetThemeFont )themeLib.resolve("GetThemeFont");
- pGetThemeInt = (PtrGetThemeInt )themeLib.resolve("GetThemeInt");
- pGetThemeIntList = (PtrGetThemeIntList )themeLib.resolve("GetThemeIntList");
- pGetThemeMargins = (PtrGetThemeMargins )themeLib.resolve("GetThemeMargins");
- pGetThemeMetric = (PtrGetThemeMetric )themeLib.resolve("GetThemeMetric");
- pGetThemePartSize = (PtrGetThemePartSize )themeLib.resolve("GetThemePartSize");
- pGetThemePosition = (PtrGetThemePosition )themeLib.resolve("GetThemePosition");
- pGetThemePropertyOrigin = (PtrGetThemePropertyOrigin)themeLib.resolve("GetThemePropertyOrigin");
- pGetThemeRect = (PtrGetThemeRect )themeLib.resolve("GetThemeRect");
- pGetThemeString = (PtrGetThemeString )themeLib.resolve("GetThemeString");
- pGetThemeBackgroundRegion = (PtrGetThemeBackgroundRegion )themeLib.resolve("GetThemeBackgroundRegion");
- pGetThemeDocumentationProperty = (PtrGetThemeDocumentationProperty )themeLib.resolve("GetThemeDocumentationProperty");
- pIsThemeBackgroundPartiallyTransparent = (PtrIsThemeBackgroundPartiallyTransparent)themeLib.resolve("IsThemeBackgroundPartiallyTransparent");
- pSetWindowTheme = (PtrSetWindowTheme )themeLib.resolve("SetWindowTheme");
- if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA)
- pGetThemeTransitionDuration = (PtrGetThemeTransitionDuration)themeLib.resolve("GetThemeTransitionDuration");
- return true;
-}
-
// General const values
static const int windowsItemFrame = 2; // menu item frame width
static const int windowsItemHMargin = 3; // menu item hor text margin
@@ -231,7 +158,7 @@ RECT XPThemeData::toRECT(const QRect &qr)
*/
HRGN XPThemeData::mask(QWidget *widget)
{
- if (!QWindowsXPStylePrivate::pIsThemeBackgroundPartiallyTransparent(handle(), partId, stateId))
+ if (!IsThemeBackgroundPartiallyTransparent(handle(), partId, stateId))
return 0;
HRGN hrgn;
@@ -239,7 +166,7 @@ HRGN XPThemeData::mask(QWidget *widget)
if (widget)
dc = hdcForWidgetBackingStore(widget);
RECT nativeRect = toRECT(rect);
- QWindowsXPStylePrivate::pGetThemeBackgroundRegion(handle(), dc, partId, stateId, &nativeRect, &hrgn);
+ GetThemeBackgroundRegion(handle(), dc, partId, stateId, &nativeRect, &hrgn);
return hrgn;
}
@@ -285,8 +212,7 @@ bool QWindowsXPStylePrivate::useXP(bool update)
{
if (!update)
return use_xp;
- return (use_xp = QWindowsUxThemeLib::resolveSymbols() && pIsThemeActive()
- && (pIsAppThemed() || !QApplication::instance()));
+ return use_xp = IsThemeActive() && (IsAppThemed() || !QApplication::instance());
}
/* \internal
@@ -366,7 +292,7 @@ bool QWindowsXPStylePrivate::initVistaTreeViewTheming()
qWarning("Unable to create the treeview helper window.");
return false;
}
- if (FAILED(QWindowsXPStylePrivate::pSetWindowTheme(m_vistaTreeViewHelper, L"explorer", NULL))) {
+ if (FAILED(SetWindowTheme(m_vistaTreeViewHelper, L"explorer", NULL))) {
qErrnoWarning("SetWindowTheme() failed.");
cleanupVistaTreeViewTheming();
return false;
@@ -391,7 +317,7 @@ void QWindowsXPStylePrivate::cleanupHandleMap()
{
for (int i = 0; i < NThemes; ++i)
if (m_themes[i]) {
- pCloseThemeData(m_themes[i]);
+ CloseThemeData(m_themes[i]);
m_themes[i] = 0;
}
QWindowsXPStylePrivate::cleanupVistaTreeViewTheming();
@@ -407,7 +333,7 @@ HTHEME QWindowsXPStylePrivate::createTheme(int theme, HWND hwnd)
const wchar_t *name = themeNames[theme];
if (theme == VistaTreeViewTheme && QWindowsXPStylePrivate::initVistaTreeViewTheming())
hwnd = QWindowsXPStylePrivate::m_vistaTreeViewHelper;
- m_themes[theme] = pOpenThemeData(hwnd, name);
+ m_themes[theme] = OpenThemeData(hwnd, name);
if (Q_UNLIKELY(!m_themes[theme]))
qErrnoWarning("OpenThemeData() failed for theme %d (%s).",
theme, qPrintable(themeName(theme)));
@@ -505,48 +431,6 @@ const QPixmap *QWindowsXPStylePrivate::tabBody(QWidget *widget)
}
/*! \internal
- Returns \c true if all the necessary theme engine symbols were
- resolved.
-*/
-bool QWindowsXPStylePrivate::resolveSymbols()
-{
- static bool tried = false;
- if (!tried) {
- tried = true;
- QSystemLibrary themeLib(QLatin1String("uxtheme"));
- pIsAppThemed = (PtrIsAppThemed)themeLib.resolve("IsAppThemed");
- if (pIsAppThemed) {
- pIsThemeActive = (PtrIsThemeActive )themeLib.resolve("IsThemeActive");
- pGetThemePartSize = (PtrGetThemePartSize )themeLib.resolve("GetThemePartSize");
- pOpenThemeData = (PtrOpenThemeData )themeLib.resolve("OpenThemeData");
- pCloseThemeData = (PtrCloseThemeData )themeLib.resolve("CloseThemeData");
- pDrawThemeBackground = (PtrDrawThemeBackground )themeLib.resolve("DrawThemeBackground");
- pDrawThemeBackgroundEx = (PtrDrawThemeBackgroundEx )themeLib.resolve("DrawThemeBackgroundEx");
- pGetCurrentThemeName = (PtrGetCurrentThemeName )themeLib.resolve("GetCurrentThemeName");
- pGetThemeBool = (PtrGetThemeBool )themeLib.resolve("GetThemeBool");
- pGetThemeColor = (PtrGetThemeColor )themeLib.resolve("GetThemeColor");
- pGetThemeEnumValue = (PtrGetThemeEnumValue )themeLib.resolve("GetThemeEnumValue");
- pGetThemeFilename = (PtrGetThemeFilename )themeLib.resolve("GetThemeFilename");
- pGetThemeFont = (PtrGetThemeFont )themeLib.resolve("GetThemeFont");
- pGetThemeInt = (PtrGetThemeInt )themeLib.resolve("GetThemeInt");
- pGetThemeIntList = (PtrGetThemeIntList )themeLib.resolve("GetThemeIntList");
- pGetThemeMargins = (PtrGetThemeMargins )themeLib.resolve("GetThemeMargins");
- pGetThemeMetric = (PtrGetThemeMetric )themeLib.resolve("GetThemeMetric");
- pGetThemePartSize = (PtrGetThemePartSize )themeLib.resolve("GetThemePartSize");
- pGetThemePosition = (PtrGetThemePosition )themeLib.resolve("GetThemePosition");
- pGetThemePropertyOrigin = (PtrGetThemePropertyOrigin)themeLib.resolve("GetThemePropertyOrigin");
- pGetThemeRect = (PtrGetThemeRect )themeLib.resolve("GetThemeRect");
- pGetThemeString = (PtrGetThemeString )themeLib.resolve("GetThemeString");
- pGetThemeBackgroundRegion = (PtrGetThemeBackgroundRegion )themeLib.resolve("GetThemeBackgroundRegion");
- pGetThemeDocumentationProperty = (PtrGetThemeDocumentationProperty )themeLib.resolve("GetThemeDocumentationProperty");
- pIsThemeBackgroundPartiallyTransparent = (PtrIsThemeBackgroundPartiallyTransparent)themeLib.resolve("IsThemeBackgroundPartiallyTransparent");
- }
- }
-
- return pIsAppThemed != 0;
-}
-
-/*! \internal
Returns a native buffer (DIB section) of at least the size of
( \a x , \a y ). The buffer has a 32 bit depth, to not lose
the alpha values on proper alpha-pixmaps.
@@ -614,8 +498,8 @@ HBITMAP QWindowsXPStylePrivate::buffer(int w, int h)
*/
bool QWindowsXPStylePrivate::isTransparent(XPThemeData &themeData)
{
- return pIsThemeBackgroundPartiallyTransparent(themeData.handle(), themeData.partId,
- themeData.stateId);
+ return IsThemeBackgroundPartiallyTransparent(themeData.handle(), themeData.partId,
+ themeData.stateId);
}
@@ -626,9 +510,10 @@ QRegion QWindowsXPStylePrivate::region(XPThemeData &themeData)
{
HRGN hRgn = 0;
RECT rect = themeData.toRECT(themeData.rect);
- if (!SUCCEEDED(pGetThemeBackgroundRegion(themeData.handle(), bufferHDC(), themeData.partId,
- themeData.stateId, &rect, &hRgn)))
+ if (!SUCCEEDED(GetThemeBackgroundRegion(themeData.handle(), bufferHDC(), themeData.partId,
+ themeData.stateId, &rect, &hRgn))) {
return QRegion();
+ }
HRGN dest = CreateRectRgn(0, 0, 0, 0);
const bool success = CombineRgn(dest, hRgn, 0, RGN_COPY) != ERROR;
@@ -822,7 +707,6 @@ bool QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData)
bool canDrawDirectly = false;
if (themeData.widget && painter->opacity() == 1.0 && !themeData.rotate
&& tt != ComplexTransform && !themeData.mirrorVertically
- && (!themeData.mirrorHorizontally || pDrawThemeBackgroundEx)
&& !translucentToplevel) {
// Draw on backing store DC only for real widgets or backing store images.
const QPaintDevice *enginePaintDevice = painter->paintEngine()->paintDevice();
@@ -904,44 +788,7 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeDa
| (themeData.noContent ? DTBG_OMITCONTENT : 0)
| (themeData.mirrorHorizontally ? DTBG_MIRRORDC : 0);
- HRESULT result = S_FALSE;
- if (pDrawThemeBackgroundEx != 0) {
- result = pDrawThemeBackgroundEx(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawRECT), &drawOptions);
- } else {
- // We are running on a system where the uxtheme.dll does not have
- // the DrawThemeBackgroundEx function, so we need to clip away
- // borders or contents manually. All flips and mirrors uses the
- // fallback implementation
-
- int borderSize = 0;
- PROPERTYORIGIN origin = PO_NOTFOUND;
- pGetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, TMT_BORDERSIZE, &origin);
- pGetThemeInt(themeData.handle(), themeData.partId, themeData.stateId, TMT_BORDERSIZE, &borderSize);
-
- // Clip away border region
- QRegion extraClip = sysRgn;
- if ((origin == PO_CLASS || origin == PO_PART || origin == PO_STATE) && borderSize > 0) {
- if (themeData.noBorder) {
- // extraClip &= area is already done
- drawRECT = themeData.toRECT(area.adjusted(-borderSize, -borderSize, borderSize, borderSize));
- }
-
- // Clip away content region
- if (themeData.noContent) {
- QRegion content = area.adjusted(borderSize, borderSize, -borderSize, -borderSize);
- extraClip ^= content;
- }
-
- // Set the clip region, if used..
- if (themeData.noBorder || themeData.noContent) {
- DeleteObject(hrgn);
- hrgn = qt_hrgn_from_qregion(extraClip);
- SelectClipRgn(dc, hrgn);
- }
- }
-
- result = pDrawThemeBackground(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawRECT), &(drawOptions.rcClip));
- }
+ const HRESULT result = DrawThemeBackgroundEx(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawRECT), &drawOptions);
SelectClipRgn(dc, 0);
DeleteObject(hrgn);
return SUCCEEDED(result);
@@ -1020,17 +867,17 @@ bool QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa
BOOL tmt_borderonly = false;
COLORREF tmt_transparentcolor = 0x0;
PROPERTYORIGIN proporigin = PO_NOTFOUND;
- pGetThemeBool(themeData.handle(), themeData.partId, themeData.stateId, TMT_BORDERONLY, &tmt_borderonly);
- pGetThemeColor(themeData.handle(), themeData.partId, themeData.stateId, TMT_TRANSPARENTCOLOR, &tmt_transparentcolor);
- pGetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, TMT_CAPTIONMARGINS, &proporigin);
+ GetThemeBool(themeData.handle(), themeData.partId, themeData.stateId, TMT_BORDERONLY, &tmt_borderonly);
+ GetThemeColor(themeData.handle(), themeData.partId, themeData.stateId, TMT_TRANSPARENTCOLOR, &tmt_transparentcolor);
+ GetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, TMT_CAPTIONMARGINS, &proporigin);
partIsTransparent = isTransparent(themeData);
potentialInvalidAlpha = false;
- pGetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, TMT_GLYPHTYPE, &proporigin);
+ GetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, TMT_GLYPHTYPE, &proporigin);
if (proporigin == PO_PART || proporigin == PO_STATE) {
int tmt_glyphtype = GT_NONE;
- pGetThemeEnumValue(themeData.handle(), themeData.partId, themeData.stateId, TMT_GLYPHTYPE, &tmt_glyphtype);
+ GetThemeEnumValue(themeData.handle(), themeData.partId, themeData.stateId, TMT_GLYPHTYPE, &tmt_glyphtype);
potentialInvalidAlpha = partIsTransparent && tmt_glyphtype == GT_IMAGEGLYPH;
}
@@ -1060,8 +907,8 @@ bool QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa
int borderSize = 0;
PROPERTYORIGIN origin = PO_NOTFOUND;
- pGetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, TMT_BORDERSIZE, &origin);
- pGetThemeInt(themeData.handle(), themeData.partId, themeData.stateId, TMT_BORDERSIZE, &borderSize);
+ GetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, TMT_BORDERSIZE, &origin);
+ GetThemeInt(themeData.handle(), themeData.partId, themeData.stateId, TMT_BORDERSIZE, &borderSize);
// Clip away border region
if ((origin == PO_CLASS || origin == PO_PART || origin == PO_STATE) && borderSize > 0) {
@@ -1094,8 +941,6 @@ bool QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa
// Difference between area and rect
int dx = area.x() - rect.x();
int dy = area.y() - rect.y();
- int dr = area.right() - rect.right();
- int db = area.bottom() - rect.bottom();
// Adjust so painting rect starts from Origo
rect.moveTo(0,0);
@@ -1108,24 +953,8 @@ bool QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa
| (themeData.noContent ? DTBG_OMITCONTENT : 0);
// Drawing the part into the backing store
- if (pDrawThemeBackgroundEx != 0) {
- RECT rect(themeData.toRECT(area));
- pDrawThemeBackgroundEx(themeData.handle(), dc, themeData.partId, themeData.stateId, &rect, &drawOptions);
- } else {
- // Set the clip region, if used..
- if (addBorderContentClipping) {
- HRGN hrgn = qt_hrgn_from_qregion(extraClip);
- SelectClipRgn(dc, hrgn);
- // Compensate for the noBorder area difference (noContent has the same area)
- drawOptions.rcClip = themeData.toRECT(rect.adjusted(dx, dy, dr, db));
- DeleteObject(hrgn);
- }
-
- pDrawThemeBackground(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawOptions.rcClip), 0);
-
- if (addBorderContentClipping)
- SelectClipRgn(dc, 0);
- }
+ RECT wRect(themeData.toRECT(area));
+ DrawThemeBackgroundEx(themeData.handle(), dc, themeData.partId, themeData.stateId, &wRect, &drawOptions);
// If not cached, analyze the buffer data to figure
// out alpha type, and if it contains data
@@ -1342,12 +1171,12 @@ void QWindowsXPStyle::polish(QWidget *widget)
// Get text color for group box labels
COLORREF cref;
XPThemeData theme(widget, 0, QWindowsXPStylePrivate::ButtonTheme, 0, 0);
- QWindowsXPStylePrivate::pGetThemeColor(theme.handle(), BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR, &cref);
+ GetThemeColor(theme.handle(), BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR, &cref);
d->groupBoxTextColor = qRgb(GetRValue(cref), GetGValue(cref), GetBValue(cref));
- QWindowsXPStylePrivate::pGetThemeColor(theme.handle(), BP_GROUPBOX, GBS_DISABLED, TMT_TEXTCOLOR, &cref);
+ GetThemeColor(theme.handle(), BP_GROUPBOX, GBS_DISABLED, TMT_TEXTCOLOR, &cref);
d->groupBoxTextColorDisabled = qRgb(GetRValue(cref), GetGValue(cref), GetBValue(cref));
// Where does this color come from?
- //pGetThemeColor(theme.handle(), TKP_TICS, TSS_NORMAL, TMT_COLOR, &cref);
+ //GetThemeColor(theme.handle(), TKP_TICS, TSS_NORMAL, TMT_COLOR, &cref);
d->sliderTickColor = qRgb(165, 162, 148);
d->hasInitColors = true;
}
@@ -1469,15 +1298,7 @@ QRect QWindowsXPStyle::subElementRect(SubElement sr, const QStyleOption *option,
int border = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget);
rect = option->rect.adjusted(border, border, -border, -border);
- int result = QWindowsXPStylePrivate::pGetThemeMargins(theme,
- NULL,
- BP_PUSHBUTTON,
- stateId,
- TMT_CONTENTMARGINS,
- NULL,
- &borderSize);
-
- if (result == S_OK) {
+ if (SUCCEEDED(GetThemeMargins(theme, NULL, BP_PUSHBUTTON, stateId, TMT_CONTENTMARGINS, NULL, &borderSize))) {
rect.adjust(borderSize.cxLeftWidth, borderSize.cyTopHeight,
-borderSize.cxRightWidth, -borderSize.cyBottomHeight);
rect = visualRect(option->direction, option->rect, rect);
@@ -1664,14 +1485,14 @@ case PE_Frame:
else
stateId = ETS_NORMAL;
int fillType;
- if (QWindowsXPStylePrivate::pGetThemeEnumValue(theme.handle(), partId, stateId, TMT_BGTYPE, &fillType) == S_OK) {
+ if (GetThemeEnumValue(theme.handle(), partId, stateId, TMT_BGTYPE, &fillType) == S_OK) {
if (fillType == BT_BORDERFILL) {
COLORREF bcRef;
- QWindowsXPStylePrivate::pGetThemeColor(theme.handle(), partId, stateId, TMT_BORDERCOLOR, &bcRef);
+ GetThemeColor(theme.handle(), partId, stateId, TMT_BORDERCOLOR, &bcRef);
QColor bordercolor(qRgb(GetRValue(bcRef), GetGValue(bcRef), GetBValue(bcRef)));
QPen oldPen = p->pen();
// int borderSize = 1;
- // pGetThemeInt(theme.handle(), partId, stateId, TMT_BORDERCOLOR, &borderSize);
+ // GetThemeInt(theme.handle(), partId, stateId, TMT_BORDERCOLOR, &borderSize);
// Inner white border
p->setPen(QPen(option->palette.base().color(), 1));
@@ -1730,11 +1551,7 @@ case PE_Frame:
return;
}
int bgType;
- QWindowsXPStylePrivate::pGetThemeEnumValue( theme.handle(),
- partId,
- stateId,
- TMT_BGTYPE,
- &bgType);
+ GetThemeEnumValue(theme.handle(), partId, stateId, TMT_BGTYPE, &bgType);
if( bgType == BT_IMAGEFILE ) {
theme.mirrorHorizontally = hMirrored;
theme.mirrorVertically = vMirrored;
@@ -1747,11 +1564,11 @@ case PE_Frame:
if (!isEnabled) {
PROPERTYORIGIN origin = PO_NOTFOUND;
- QWindowsXPStylePrivate::pGetThemePropertyOrigin(theme.handle(), theme.partId, theme.stateId, TMT_FILLCOLOR, &origin);
+ GetThemePropertyOrigin(theme.handle(), theme.partId, theme.stateId, TMT_FILLCOLOR, &origin);
// Use only if the fill property comes from our part
if ((origin == PO_PART || origin == PO_STATE)) {
COLORREF bgRef;
- QWindowsXPStylePrivate::pGetThemeColor(theme.handle(), partId, stateId, TMT_FILLCOLOR, &bgRef);
+ GetThemeColor(theme.handle(), partId, stateId, TMT_FILLCOLOR, &bgRef);
fillColor = QBrush(qRgb(GetRValue(bgRef), GetGValue(bgRef), GetBValue(bgRef)));
}
}
@@ -1777,7 +1594,7 @@ case PE_Frame:
wchar_t themeFileName[maxlength];
wchar_t themeColor[maxlength];
// Due to a a scaling issue with the XP Silver theme, tab gradients are not used with it
- if (QWindowsXPStylePrivate::pGetCurrentThemeName(themeFileName, maxlength, themeColor, maxlength, NULL, 0) == S_OK) {
+ if (GetCurrentThemeName(themeFileName, maxlength, themeColor, maxlength, NULL, 0) == S_OK) {
wchar_t *offset = 0;
if ((offset = wcsrchr(themeFileName, QChar(QLatin1Char('\\')).unicode())) != NULL) {
offset++;
@@ -2564,10 +2381,10 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op
= p->fontMetrics().elidedText(dwOpt->title, Qt::ElideRight, titleRect.width());
int result = TST_NONE;
- QWindowsXPStylePrivate::pGetThemeEnumValue(theme.handle(), WP_SMALLCAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWTYPE, &result);
+ GetThemeEnumValue(theme.handle(), WP_SMALLCAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWTYPE, &result);
if (result != TST_NONE) {
COLORREF textShadowRef;
- QWindowsXPStylePrivate::pGetThemeColor(theme.handle(), WP_SMALLCAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWCOLOR, &textShadowRef);
+ GetThemeColor(theme.handle(), WP_SMALLCAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWCOLOR, &textShadowRef);
QColor textShadow = qRgb(GetRValue(textShadowRef), GetGValue(textShadowRef), GetBValue(textShadowRef));
p->setPen(textShadow);
drawItemText(p, titleRect.adjusted(1, 1, 1, 1),
@@ -3163,10 +2980,10 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
QRect ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarLabel, widget);
int result = TST_NONE;
- QWindowsXPStylePrivate::pGetThemeEnumValue(theme.handle(), WP_CAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWTYPE, &result);
+ GetThemeEnumValue(theme.handle(), WP_CAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWTYPE, &result);
if (result != TST_NONE) {
COLORREF textShadowRef;
- QWindowsXPStylePrivate::pGetThemeColor(theme.handle(), WP_CAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWCOLOR, &textShadowRef);
+ GetThemeColor(theme.handle(), WP_CAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWCOLOR, &textShadowRef);
QColor textShadow = qRgb(GetRValue(textShadowRef), GetGValue(textShadowRef), GetBValue(textShadowRef));
p->setPen(textShadow);
p->drawText(ir.x() + 3, ir.y() + 2, ir.width() - 1, ir.height(),
@@ -4197,7 +4014,7 @@ void QWindowsXPStylePrivate::dumpNativeDIB(int w, int h)
static void showProperty(XPThemeData &themeData, const PropPair &prop)
{
PROPERTYORIGIN origin = PO_NOTFOUND;
- pGetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &origin);
+ GetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &origin);
const char *originStr;
switch(origin) {
case PO_STATE:
@@ -4222,35 +4039,35 @@ static void showProperty(XPThemeData &themeData, const PropPair &prop)
case TMT_STRING:
{
wchar_t buffer[512];
- pGetThemeString(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, buffer, 512);
+ GetThemeString(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, buffer, 512);
printf(" (%sString) %-20S: %S\n", originStr, prop.propName, buffer);
}
break;
case TMT_ENUM:
{
int result = -1;
- pGetThemeEnumValue(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
+ GetThemeEnumValue(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
printf(" (%sEnum) %-20S: %d\n", originStr, prop.propName, result);
}
break;
case TMT_INT:
{
int result = -1;
- pGetThemeInt(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
+ GetThemeInt(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
printf(" (%sint) %-20S: %d\n", originStr, prop.propName, result);
}
break;
case TMT_BOOL:
{
BOOL result = false;
- pGetThemeBool(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
+ GetThemeBool(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
printf(" (%sbool) %-20S: %d\n", originStr, prop.propName, result);
}
break;
case TMT_COLOR:
{
COLORREF result = 0;
- pGetThemeColor(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
+ GetThemeColor(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
printf(" (%scolor) %-20S: 0x%08X\n", originStr, prop.propName, result);
}
break;
@@ -4258,7 +4075,7 @@ static void showProperty(XPThemeData &themeData, const PropPair &prop)
{
MARGINS result;
memset(&result, 0, sizeof(result));
- pGetThemeMargins(themeData.handle(), 0, themeData.partId, themeData.stateId, prop.propValue, 0, &result);
+ GetThemeMargins(themeData.handle(), 0, themeData.partId, themeData.stateId, prop.propValue, 0, &result);
printf(" (%smargins) %-20S: (%d, %d, %d, %d)\n", originStr,
prop.propName, result.cxLeftWidth, result.cyTopHeight, result.cxRightWidth, result.cyBottomHeight);
}
@@ -4266,7 +4083,7 @@ static void showProperty(XPThemeData &themeData, const PropPair &prop)
case TMT_FILENAME:
{
wchar_t buffer[512];
- pGetThemeFilename(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, buffer, 512);
+ GetThemeFilename(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, buffer, 512);
printf(" (%sfilename)%-20S: %S\n", originStr, prop.propName, buffer);
}
break;
@@ -4278,9 +4095,9 @@ static void showProperty(XPThemeData &themeData, const PropPair &prop)
memset(&result1, 0, sizeof(result1));
memset(&result2, 0, sizeof(result2));
memset(&result3, 0, sizeof(result3));
- pGetThemePartSize(themeData.handle(), 0, themeData.partId, themeData.stateId, 0, TS_MIN, &result1);
- pGetThemePartSize(themeData.handle(), 0, themeData.partId, themeData.stateId, 0, TS_TRUE, &result2);
- pGetThemePartSize(themeData.handle(), 0, themeData.partId, themeData.stateId, 0, TS_DRAW, &result3);
+ GetThemePartSize(themeData.handle(), 0, themeData.partId, themeData.stateId, 0, TS_MIN, &result1);
+ GetThemePartSize(themeData.handle(), 0, themeData.partId, themeData.stateId, 0, TS_TRUE, &result2);
+ GetThemePartSize(themeData.handle(), 0, themeData.partId, themeData.stateId, 0, TS_DRAW, &result3);
printf(" (%ssize) %-20S: Min (%d, %d), True(%d, %d), Draw(%d, %d)\n", originStr, prop.propName,
result1.cx, result1.cy, result2.cx, result2.cy, result3.cx, result3.cy);
}
@@ -4289,7 +4106,7 @@ static void showProperty(XPThemeData &themeData, const PropPair &prop)
{
POINT result;
memset(&result, 0, sizeof(result));
- pGetThemePosition(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
+ GetThemePosition(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
printf(" (%sPosition)%-20S: (%d, %d)\n", originStr, prop.propName, result.x, result.y);
}
break;
@@ -4297,7 +4114,7 @@ static void showProperty(XPThemeData &themeData, const PropPair &prop)
{
RECT result;
memset(&result, 0, sizeof(result));
- pGetThemeRect(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
+ GetThemeRect(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
printf(" (%sRect) %-20S: (%d, %d, %d, %d)\n", originStr, prop.propName, result.left, result.top, result.right, result.bottom);
}
break;
@@ -4305,7 +4122,7 @@ static void showProperty(XPThemeData &themeData, const PropPair &prop)
{
LOGFONT result;
memset(&result, 0, sizeof(result));
- pGetThemeFont(themeData.handle(), 0, themeData.partId, themeData.stateId, prop.propValue, &result);
+ GetThemeFont(themeData.handle(), 0, themeData.partId, themeData.stateId, prop.propValue, &result);
printf(" (%sFont) %-20S: %S height(%d) width(%d) weight(%d)\n", originStr, prop.propName,
result.lfFaceName, result.lfHeight, result.lfWidth, result.lfWeight);
}
@@ -4314,7 +4131,7 @@ static void showProperty(XPThemeData &themeData, const PropPair &prop)
{
INTLIST result;
memset(&result, 0, sizeof(result));
- pGetThemeIntList(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
+ GetThemeIntList(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
printf(" (%sInt list)%-20S: { ", originStr, prop.propName);
for (int i = 0; i < result.iValueCount; ++i)
printf("%d ", result.iValues[i]);
@@ -4366,7 +4183,7 @@ void QWindowsXPStylePrivate::showProperties(XPThemeData &themeData)
for (int j = 0; j < all_props.count(); ++j) {
PropPair prop = all_props.at(j);
wchar_t buf[500];
- pGetThemeDocumentationProperty(themeName, prop.propName, buf, 500);
+ GetThemeDocumentationProperty(themeName, prop.propName, buf, 500);
printf("%3d: (%4d) %-20S %S\n", j, prop.propValue, prop.propName, buf);
}
}
@@ -4376,7 +4193,7 @@ void QWindowsXPStylePrivate::showProperties(XPThemeData &themeData)
for (int j = 0; j < all_props.count(); ++j) {
PropPair prop = all_props.at(j);
PROPERTYORIGIN origin = PO_NOTFOUND;
- pGetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &origin);
+ GetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &origin);
if (origin == PO_GLOBAL) {
showProperty(themeData, prop);
}
@@ -4387,7 +4204,7 @@ void QWindowsXPStylePrivate::showProperties(XPThemeData &themeData)
for (int j = 0; j < all_props.count(); ++j) {
PropPair prop = all_props.at(j);
PROPERTYORIGIN origin = PO_NOTFOUND;
- pGetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &origin);
+ GetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &origin);
if (origin != PO_NOTFOUND)
{
showProperty(themeData, prop);
diff --git a/src/widgets/styles/qwindowsxpstyle_p_p.h b/src/widgets/styles/qwindowsxpstyle_p_p.h
index 8ee4d1a641..91d60c8e82 100644
--- a/src/widgets/styles/qwindowsxpstyle_p_p.h
+++ b/src/widgets/styles/qwindowsxpstyle_p_p.h
@@ -57,101 +57,12 @@
#include <qt_windows.h>
#include <uxtheme.h>
-
-#if WINVER >= 0x0600
#include <vssym32.h>
-#else
-#include <tmschema.h>
-#endif
#include <limits.h>
QT_BEGIN_NAMESPACE
-// Older Platform SDKs do not have the extended DrawThemeBackgroundEx
-// function. We add the needed parts here, and use the extended
-// function dynamically, if available in uxtheme.dll. Else, we revert
-// back to using the DrawThemeBackground function.
-#ifndef DTBG_OMITBORDER
-# ifndef DTBG_CLIPRECT
-# define DTBG_CLIPRECT 0x00000001
-# endif
-# ifndef DTBG_DRAWSOLID
-# define DTBG_DRAWSOLID 0x00000002
-# endif
-# ifndef DTBG_OMITBORDER
-# define DTBG_OMITBORDER 0x00000004
-# endif
-# ifndef DTBG_OMITCONTENT
-# define DTBG_OMITCONTENT 0x00000008
-# endif
-# ifndef DTBG_COMPUTINGREGION
-# define DTBG_COMPUTINGREGION 0x00000010
-# endif
-# ifndef DTBG_MIRRORDC
-# define DTBG_MIRRORDC 0x00000020
-# endif
- typedef struct _DTBGOPTS
- {
- DWORD dwSize;
- DWORD dwFlags;
- RECT rcClip;
- } DTBGOPTS, *PDTBGOPTS;
-#endif // _DTBGOPTS
-
-// Undefined for some compile environments
-#ifndef TMT_TEXTCOLOR
-# define TMT_TEXTCOLOR 3803
-#endif
-#ifndef TMT_BORDERCOLORHINT
-# define TMT_BORDERCOLORHINT 3822
-#endif
-#ifndef TMT_BORDERSIZE
-# define TMT_BORDERSIZE 2403
-#endif
-#ifndef TMT_BORDERONLY
-# define TMT_BORDERONLY 2203
-#endif
-#ifndef TMT_TRANSPARENTCOLOR
-# define TMT_TRANSPARENTCOLOR 3809
-#endif
-#ifndef TMT_CAPTIONMARGINS
-# define TMT_CAPTIONMARGINS 3603
-#endif
-#ifndef TMT_CONTENTMARGINS
-# define TMT_CONTENTMARGINS 3602
-#endif
-#ifndef TMT_SIZINGMARGINS
-# define TMT_SIZINGMARGINS 3601
-#endif
-#ifndef TMT_GLYPHTYPE
-# define TMT_GLYPHTYPE 4012
-#endif
-#ifndef TMT_BGTYPE
-# define TMT_BGTYPE 4001
-#endif
-#ifndef TMT_TEXTSHADOWTYPE
-# define TMT_TEXTSHADOWTYPE 4010
-#endif
-#ifndef TMT_BORDERCOLOR
-# define TMT_BORDERCOLOR 3801
-#endif
-#ifndef BT_IMAGEFILE
-# define BT_IMAGEFILE 0
-#endif
-#ifndef BT_BORDERFILL
-# define BT_BORDERFILL 1
-#endif
-#ifndef BT_NONE
-# define BT_NONE 2
-#endif
-#ifndef TMT_FILLCOLOR
-# define TMT_FILLCOLOR 3802
-#endif
-#ifndef TMT_PROGRESSCHUNKSIZE
-# define TMT_PROGRESSCHUNKSIZE 2411
-#endif
-
// TMT_TEXTSHADOWCOLOR is wrongly defined in mingw
#if TMT_TEXTSHADOWCOLOR != 3818
#undef TMT_TEXTSHADOWCOLOR
@@ -161,13 +72,6 @@ QT_BEGIN_NAMESPACE
# define TST_NONE 0
#endif
-#ifndef GT_NONE
-# define GT_NONE 0
-#endif
-#ifndef GT_IMAGEGLYPH
-# define GT_IMAGEGLYPH 1
-#endif
-
// These defines are missing from the tmschema, but still exist as
// states for their parts
#ifndef MINBS_INACTIVE
@@ -278,65 +182,7 @@ struct ThemeMapData {
hasAlphaChannel(false), wasAlphaSwapped(false), hadInvalidAlpha(false) {}
};
-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
+class QWindowsXPStylePrivate : public QWindowsStylePrivate
{
Q_DECLARE_PUBLIC(QWindowsXPStyle)
public:
@@ -385,7 +231,6 @@ public:
HDC bufferHDC()
{ return bufferDC;}
- static bool resolveSymbols();
static bool useXP(bool update = false);
static QRect scrollBarGripperBounds(QStyle::State flags, const QWidget *widget, XPThemeData *theme);
@@ -443,7 +288,7 @@ inline QSizeF XPThemeData::size()
QSizeF result(0, 0);
if (isValid()) {
SIZE size;
- if (SUCCEEDED(QWindowsXPStylePrivate::pGetThemePartSize(handle(), 0, partId, stateId, 0, TS_TRUE, &size)))
+ if (SUCCEEDED(GetThemePartSize(handle(), 0, partId, stateId, 0, TS_TRUE, &size)))
result = QSize(size.cx, size.cy);
}
return result;
@@ -455,7 +300,7 @@ inline QMarginsF XPThemeData::margins(const QRect &qRect, int propId)
if (isValid()) {
MARGINS margins;
RECT rect = XPThemeData::toRECT(qRect);
- if (SUCCEEDED(QWindowsXPStylePrivate::pGetThemeMargins(handle(), 0, partId, stateId, propId, &rect, &margins)))
+ if (SUCCEEDED(GetThemeMargins(handle(), 0, partId, stateId, propId, &rect, &margins)))
result = QMargins(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight);
}
return result;
@@ -466,7 +311,7 @@ inline QMarginsF XPThemeData::margins(int propId)
QMarginsF result(0, 0, 0 ,0);
if (isValid()) {
MARGINS margins;
- if (SUCCEEDED(QWindowsXPStylePrivate::pGetThemeMargins(handle(), 0, partId, stateId, propId, NULL, &margins)))
+ if (SUCCEEDED(GetThemeMargins(handle(), 0, partId, stateId, propId, NULL, &margins)))
result = QMargins(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight);
}
return result;
diff --git a/src/widgets/util/qsystemtrayicon_win.cpp b/src/widgets/util/qsystemtrayicon_win.cpp
index f34714c016..3acf1fa777 100644
--- a/src/widgets/util/qsystemtrayicon_win.cpp
+++ b/src/widgets/util/qsystemtrayicon_win.cpp
@@ -200,7 +200,7 @@ QSystemTrayIconSys::QSystemTrayIconSys(HWND hwnd, QSystemTrayIcon *object)
MYWM_TASKBARCREATED = RegisterWindowMessage(L"TaskbarCreated");
}
- // Allow the WM_TASKBARCREATED message through the UIPI filter on Windows Vista and higher
+ // Allow the WM_TASKBARCREATED message through the UIPI filter on Windows 7 and higher
static PtrChangeWindowMessageFilterEx pChangeWindowMessageFilterEx =
(PtrChangeWindowMessageFilterEx)QSystemLibrary::resolve(QLatin1String("user32"), "ChangeWindowMessageFilterEx");
@@ -208,13 +208,14 @@ QSystemTrayIconSys::QSystemTrayIconSys(HWND hwnd, QSystemTrayIcon *object)
// Call the safer ChangeWindowMessageFilterEx API if available (Windows 7 onwards)
pChangeWindowMessageFilterEx(m_hwnd, MYWM_TASKBARCREATED, Q_MSGFLT_ALLOW, 0);
} else {
+ // Call the deprecated ChangeWindowMessageFilter API otherwise (Vista onwards)
+ // May 2016: Still resolved at runtime since the definition is not present in MinGW 4.9.
+ // TODO: Replace by direct invocation when upgrading MinGW.
static PtrChangeWindowMessageFilter pChangeWindowMessageFilter =
(PtrChangeWindowMessageFilter)QSystemLibrary::resolve(QLatin1String("user32"), "ChangeWindowMessageFilter");
- if (pChangeWindowMessageFilter) {
- // Call the deprecated ChangeWindowMessageFilter API otherwise
+ if (pChangeWindowMessageFilter)
pChangeWindowMessageFilter(MYWM_TASKBARCREATED, Q_MSGFLT_ALLOW);
- }
}
}
@@ -413,6 +414,7 @@ QRect QSystemTrayIconSys::findIconGeometry(UINT iconId)
UINT uID;
};
+ // Windows 7 onwards.
static PtrShell_NotifyIconGetRect Shell_NotifyIconGetRect =
(PtrShell_NotifyIconGetRect)QSystemLibrary::resolve(QLatin1String("shell32"),
"Shell_NotifyIconGetRect");