diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2016-04-06 09:41:54 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2016-04-06 18:29:01 +0000 |
commit | 1e69d4e3ac4263776ae13095dec213b24c51e22f (patch) | |
tree | 142bcf12533afd1f2544a664286359ce14df2dc5 | |
parent | e4e62496ac62deab0e8f6ae9f064cf153b31d2fa (diff) |
Refactor QWindowsXPStylePrivate::drawBackground() and helpers.
Pass the DC obtained drawBackground() to drawBackgroundDirectly(),
saving a call to hdcForWidgetBackingStore() to find it.
Pass the error code from the Win32 API DrawThemeBackground()
to the calling functions.
Change-Id: I1c25241f53d87e4429ad924f7b2e29da215d7e4f
Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
-rw-r--r-- | src/widgets/styles/qwindowsxpstyle.cpp | 14 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsxpstyle_p_p.h | 2 |
2 files changed, 7 insertions, 9 deletions
diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index 88b1b41f15..2c98ebb740 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -774,7 +774,7 @@ bool QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData) const HDC dc = canDrawDirectly ? hdcForWidgetBackingStore(themeData.widget) : HDC(0); const bool result = dc - ? drawBackgroundDirectly(themeData, qRound(aditionalDevicePixelRatio)) + ? drawBackgroundDirectly(dc, themeData, qRound(aditionalDevicePixelRatio)) : drawBackgroundThruNativeBuffer(themeData, qRound(aditionalDevicePixelRatio)); painter->restore(); return result; @@ -804,12 +804,9 @@ static QRegion scaleRegion(const QRegion ®ion, int factor) Do not use this if you need to perform other transformations on the resulting data. */ -bool QWindowsXPStylePrivate::drawBackgroundDirectly(XPThemeData &themeData, int additionalDevicePixelRatio) +bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeData, int additionalDevicePixelRatio) { QPainter *painter = themeData.painter; - HDC dc = 0; - if (themeData.widget) - dc = hdcForWidgetBackingStore(themeData.widget); QPoint redirectionDelta(int(painter->deviceMatrix().dx()), int(painter->deviceMatrix().dy())); @@ -841,8 +838,9 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(XPThemeData &themeData, int | (themeData.noContent ? DTBG_OMITCONTENT : 0) | (themeData.mirrorHorizontally ? DTBG_MIRRORDC : 0); + HRESULT result = S_FALSE; if (pDrawThemeBackgroundEx != 0) { - pDrawThemeBackgroundEx(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawRECT), &drawOptions); + 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 @@ -876,11 +874,11 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(XPThemeData &themeData, int } } - pDrawThemeBackground(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawRECT), &(drawOptions.rcClip)); + result = pDrawThemeBackground(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawRECT), &(drawOptions.rcClip)); } SelectClipRgn(dc, 0); DeleteObject(hrgn); - return true; + return SUCCEEDED(result); } /*! \internal diff --git a/src/widgets/styles/qwindowsxpstyle_p_p.h b/src/widgets/styles/qwindowsxpstyle_p_p.h index 240a338c3f..d75c064369 100644 --- a/src/widgets/styles/qwindowsxpstyle_p_p.h +++ b/src/widgets/styles/qwindowsxpstyle_p_p.h @@ -388,7 +388,7 @@ public: void setTransparency(QWidget *widget, XPThemeData &themeData); bool drawBackground(XPThemeData &themeData); bool drawBackgroundThruNativeBuffer(XPThemeData &themeData, int aditionalDevicePixelRatio); - bool drawBackgroundDirectly(XPThemeData &themeData, int aditionalDevicePixelRatio); + bool drawBackgroundDirectly(HDC dc, XPThemeData &themeData, int aditionalDevicePixelRatio); bool hasAlphaChannel(const QRect &rect); bool fixAlphaChannel(const QRect &rect); |