summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qwindowsxpstyle.cpp
diff options
context:
space:
mode:
authorOlli Werwolff <qt-info@nokia.com>2011-08-17 09:59:08 +0200
committerOliver Wolff <oliver.wolff@nokia.com>2011-08-17 13:30:28 +0200
commitc402d35df807096b199c9f1adfcad4dfabb70697 (patch)
tree36adb85e0af509b6365527c6b8bafaa377b29484 /src/widgets/styles/qwindowsxpstyle.cpp
parenta957a88542ada1c960b2f1b17284c7d813284fc1 (diff)
Readded (and fixed) WindowsXP and -Vista styles
There are still issues in WindowsVista style and qwizard_win's icon will not be shown but these will be fixed in upcoming commits. Change-Id: I22705694f07bea7461333b053804a09bab661706 Reviewed-on: http://codereview.qt.nokia.com/3073 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'src/widgets/styles/qwindowsxpstyle.cpp')
-rw-r--r--src/widgets/styles/qwindowsxpstyle.cpp69
1 files changed, 56 insertions, 13 deletions
diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp
index ce5694c181..cbaf16989a 100644
--- a/src/widgets/styles/qwindowsxpstyle.cpp
+++ b/src/widgets/styles/qwindowsxpstyle.cpp
@@ -196,9 +196,12 @@ HRGN XPThemeData::mask(QWidget *widget)
return 0;
HRGN hrgn;
- QBackingStore *backingStore = widget->backingStore();
- QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
- HDC dc = static_cast<HDC>(nativeInterface->nativeResourceForBackingStore("getDC", backingStore));
+ HDC dc = 0;
+ if (widget) {
+ QBackingStore *backingStore = widget->backingStore();
+ QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
+ dc = static_cast<HDC>(nativeInterface->nativeResourceForBackingStore("getDC", backingStore));
+ }
RECT nativeRect = toRECT(rect);
pGetThemeBackgroundRegion(handle(), dc, partId, stateId, &nativeRect, &hrgn);
return hrgn;
@@ -212,6 +215,32 @@ QMap<QString,HTHEME> *QWindowsXPStylePrivate::handleMap = 0;
bool QWindowsXPStylePrivate::use_xp = false;
QBasicAtomicInt QWindowsXPStylePrivate::ref = Q_BASIC_ATOMIC_INITIALIZER(-1); // -1 based refcounting
+static void qt_add_rect(HRGN &winRegion, QRect r)
+{
+ HRGN rgn = CreateRectRgn(r.left(), r.top(), r.x() + r.width(), r.y() + r.height());
+ if (rgn) {
+ HRGN dest = CreateRectRgn(0,0,0,0);
+ int result = CombineRgn(dest, winRegion, rgn, RGN_OR);
+ if (result) {
+ DeleteObject(winRegion);
+ winRegion = dest;
+ }
+ DeleteObject(rgn);
+ }
+}
+
+static HRGN qt_hrgn_from_qregion(const QRegion &region)
+{
+ HRGN hRegion = CreateRectRgn(0,0,0,0);
+ if (region.rectCount() == 1) {
+ qt_add_rect(hRegion, region.boundingRect());
+ return hRegion;
+ }
+ foreach (const QRect &rect, region.rects())
+ qt_add_rect(hRegion, rect);
+ return hRegion;
+}
+
/* \internal
Checks if the theme engine can/should be used, or if we should
fall back to Windows style.
@@ -657,9 +686,13 @@ void QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData)
translucentToplevel = win->testAttribute(Qt::WA_TranslucentBackground);
}
- QBackingStore *backingStore = themeData.widget->backingStore();
- QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
- HDC dc = static_cast<HDC>(nativeInterface->nativeResourceForBackingStore("getDC", backingStore ));
+ HDC dc = 0;
+ if (themeData.widget) {
+ QBackingStore *backingStore = themeData.widget->backingStore();
+ QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
+ dc = static_cast<HDC>(nativeInterface->nativeResourceForBackingStore("getDC", backingStore ));
+ }
+
bool useFallback = dc == 0
|| painter->opacity() != 1.0
|| themeData.rotate
@@ -684,9 +717,12 @@ void QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData)
void QWindowsXPStylePrivate::drawBackgroundDirectly(XPThemeData &themeData)
{
QPainter *painter = themeData.painter;
- QBackingStore *backingStore= themeData.widget->backingStore();
- QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
- HDC dc = static_cast<HDC>(nativeInterface->nativeResourceForBackingStore("getDC", backingStore));
+ HDC dc = 0;
+ if (themeData.widget) {
+ QBackingStore *backingStore = themeData.widget->backingStore();
+ QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
+ dc = static_cast<HDC>(nativeInterface->nativeResourceForBackingStore("getDC", backingStore));
+ }
QPoint redirectionDelta(int(painter->deviceMatrix().dx()),
int(painter->deviceMatrix().dy()));
@@ -699,7 +735,8 @@ void QWindowsXPStylePrivate::drawBackgroundDirectly(XPThemeData &themeData)
sysRgn &= area;
if (painter->hasClipping())
sysRgn &= painter->clipRegion().translated(redirectionDelta);
- SelectClipRgn(dc, sysRgn.handle());
+ HRGN hrgn = qt_hrgn_from_qregion(sysRgn);
+ SelectClipRgn(dc, hrgn);
#ifdef DEBUG_XP_STYLE
printf("---[ DIRECT PAINTING ]------------------> Name(%-10s) Part(%d) State(%d)\n",
@@ -744,13 +781,17 @@ void QWindowsXPStylePrivate::drawBackgroundDirectly(XPThemeData &themeData)
}
// Set the clip region, if used..
- if (themeData.noBorder || themeData.noContent)
- SelectClipRgn(dc, extraClip.handle());
+ if (themeData.noBorder || themeData.noContent) {
+ DeleteObject(hrgn);
+ hrgn = qt_hrgn_from_qregion(extraClip);
+ SelectClipRgn(dc, hrgn);
+ }
}
pDrawThemeBackground(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawRECT), &(drawOptions.rcClip));
}
SelectClipRgn(dc, 0);
+ DeleteObject(hrgn);
}
/*! \internal
@@ -916,9 +957,11 @@ void QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa
} else {
// Set the clip region, if used..
if (addBorderContentClipping) {
- SelectClipRgn(dc, extraClip.handle());
+ 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);