From 4a2942085a4d82e66b001c60e535f3a37808a0e8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 26 Apr 2012 15:38:17 +0200 Subject: [PATCH] Windows/Vista style: Fix painting of QGroupBox. QGroupBox in Vista style does not show a frame, currently. drawBackgroundDirectly should also be called if the paintDevice is a backing store. Task-number: QTBUG-25395 Change-Id: Ifa20802dea6c182904f68271ddd0d175007e4b0e Reviewed-by: Miikka Heikkinen Reviewed-by: Friedemann Kleint --- src/widgets/styles/qwindowsxpstyle.cpp | 45 ++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index 288863c..f9b7939 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include #include @@ -708,24 +709,36 @@ void QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData) bool complexXForm = painter->deviceTransform().type() > QTransform::TxTranslate; + // Access paintDevice via engine since the painter may + // return the clip device which can still be a widget device in case of grabWidget(). + bool translucentToplevel = false; - QPaintDevice *pdev = painter->device(); - if (pdev->devType() == QInternal::Widget) { - QWidget *win = ((QWidget *) pdev)->window(); - translucentToplevel = win->testAttribute(Qt::WA_TranslucentBackground); + const QPaintDevice *paintDevice = painter->device(); + if (paintDevice->devType() == QInternal::Widget) { + const QWidget *window = static_cast(paintDevice)->window(); + translucentToplevel = window->testAttribute(Qt::WA_TranslucentBackground); } - // Draw on backing store DC only for real widgets. - // Access paintDevice via engine since the painter may - // return the clip device which can still be a widget device in case of grabWidget(). - const bool useFallback = !themeData.widget - || painter->paintEngine()->paintDevice()->devType() != QInternal::Widget - || painter->opacity() != 1.0 || themeData.rotate - || complexXForm || themeData.mirrorVertically - || (themeData.mirrorHorizontally && pDrawThemeBackgroundEx == 0) - || translucentToplevel; - const HDC dc = useFallback ? HDC(0) : hdcForWidgetBackingStore(themeData.widget); - if (dc && !useFallback) { + bool canDrawDirectly = false; + if (themeData.widget && painter->opacity() == 1.0 && !themeData.rotate + && !complexXForm && !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(); + switch (enginePaintDevice->devType()) { + case QInternal::Widget: + canDrawDirectly = true; + break; + case QInternal::Image: + if (QBackingStore *bs = backingStoreForWidget(themeData.widget)) + if (bs->paintDevice() == enginePaintDevice) + canDrawDirectly = true; + } + } + + const HDC dc = canDrawDirectly ? hdcForWidgetBackingStore(themeData.widget) : HDC(0); + if (dc) { drawBackgroundDirectly(themeData); } else { drawBackgroundThruNativeBuffer(themeData); @@ -1961,7 +1974,7 @@ case PE_Frame: break; } - XPThemeData theme(0, p, themeNumber, partId, stateId, rect); + XPThemeData theme(widget, p, themeNumber, partId, stateId, rect); if (!theme.isValid()) { QWindowsStyle::drawPrimitive(pe, option, p, widget); return; -- 2.7.4