Windows Vista Style: Fix drawing of buttons in message boxes.
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>
Wed, 25 Jan 2012 11:31:50 +0000 (12:31 +0100)
committerQt by Nokia <qt-info@nokia.com>
Wed, 25 Jan 2012 17:00:10 +0000 (18:00 +0100)
Do not use the HDC of the backing store when drawing to an image
(as opposed to 4.8, where the HDC of the paint engine was used).
This causes 'ghost buttons' to appear in the dialog box at 0,0.

Change-Id: I301b66abf4447a65ee144f09655b68efaf18700d
Reviewed-by: Oliver Wolff <oliver.wolff@nokia.com>
src/widgets/styles/qwindowsvistastyle.cpp
src/widgets/styles/qwindowsxpstyle.cpp
src/widgets/styles/qwindowsxpstyle_p.h

index 09aec2f..252740c 100644 (file)
@@ -1010,12 +1010,12 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
                             QPainter startPainter(&startImage);
                             stateId = PBS_DEFAULTED;
                             XPThemeData theme(widget, &startPainter, name, partId, stateId, rect);
-                            d->drawBackground(theme);
+                            d->drawBackground(theme, true); // Do not draw on HDC of backing store.
 
                             QPainter alternatePainter(&alternateImage);
                             theme.stateId = PBS_DEFAULTED_ANIMATING;
                             theme.painter = &alternatePainter;
-                            d->drawBackground(theme);
+                            d->drawBackground(theme, true); // Do not draw on HDC of backing store.
                             pulse->setPrimaryImage(startImage);
                             pulse->setAlternateImage(alternateImage);
                             pulse->setStartTime(QTime::currentTime());
index eaeb336..c112e62 100644 (file)
@@ -665,7 +665,7 @@ bool QWindowsXPStylePrivate::swapAlphaChannel(const QRect &rect, bool allPixels)
             - Theme part is flipped (mirrored horizontally)
         else use drawBackgroundDirectly().
 */
-void QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData)
+void QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData, bool forceFallback)
 {
     if (themeData.rect.isEmpty())
         return;
@@ -693,14 +693,13 @@ void QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData)
         dc = static_cast<HDC>(nativeInterface->nativeResourceForBackingStore("getDC", backingStore ));
     }
 
-    bool useFallback = dc == 0
+    const bool useFallback = forceFallback || dc == 0
                        || painter->opacity() != 1.0
                        || themeData.rotate
                        || complexXForm
                        || themeData.mirrorVertically
                        || (themeData.mirrorHorizontally && pDrawThemeBackgroundEx == 0)
                        || translucentToplevel;
-
     if (!useFallback)
         drawBackgroundDirectly(themeData);
     else
index 154fe33..44dc8e8 100644 (file)
@@ -312,7 +312,7 @@ public:
     QRegion region(XPThemeData &themeData);
 
     void setTransparency(QWidget *widget, XPThemeData &themeData);
-    void drawBackground(XPThemeData &themeData);
+    void drawBackground(XPThemeData &themeData, bool forceFallback = false);
     void drawBackgroundThruNativeBuffer(XPThemeData &themeData);
     void drawBackgroundDirectly(XPThemeData &themeData);