Windows Vista Style: Fix drawing of buttons in message boxes.

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>
This commit is contained in:
Friedemann Kleint 2012-01-25 12:31:50 +01:00 committed by Qt by Nokia
parent 45690f7567
commit b37969bb5d
3 changed files with 5 additions and 6 deletions

View File

@ -1010,12 +1010,12 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
QPainter startPainter(&startImage); QPainter startPainter(&startImage);
stateId = PBS_DEFAULTED; stateId = PBS_DEFAULTED;
XPThemeData theme(widget, &startPainter, name, partId, stateId, rect); 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); QPainter alternatePainter(&alternateImage);
theme.stateId = PBS_DEFAULTED_ANIMATING; theme.stateId = PBS_DEFAULTED_ANIMATING;
theme.painter = &alternatePainter; theme.painter = &alternatePainter;
d->drawBackground(theme); d->drawBackground(theme, true); // Do not draw on HDC of backing store.
pulse->setPrimaryImage(startImage); pulse->setPrimaryImage(startImage);
pulse->setAlternateImage(alternateImage); pulse->setAlternateImage(alternateImage);
pulse->setStartTime(QTime::currentTime()); pulse->setStartTime(QTime::currentTime());

View File

@ -665,7 +665,7 @@ bool QWindowsXPStylePrivate::swapAlphaChannel(const QRect &rect, bool allPixels)
- Theme part is flipped (mirrored horizontally) - Theme part is flipped (mirrored horizontally)
else use drawBackgroundDirectly(). else use drawBackgroundDirectly().
*/ */
void QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData) void QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData, bool forceFallback)
{ {
if (themeData.rect.isEmpty()) if (themeData.rect.isEmpty())
return; return;
@ -693,14 +693,13 @@ void QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData)
dc = static_cast<HDC>(nativeInterface->nativeResourceForBackingStore("getDC", backingStore )); dc = static_cast<HDC>(nativeInterface->nativeResourceForBackingStore("getDC", backingStore ));
} }
bool useFallback = dc == 0 const bool useFallback = forceFallback || dc == 0
|| painter->opacity() != 1.0 || painter->opacity() != 1.0
|| themeData.rotate || themeData.rotate
|| complexXForm || complexXForm
|| themeData.mirrorVertically || themeData.mirrorVertically
|| (themeData.mirrorHorizontally && pDrawThemeBackgroundEx == 0) || (themeData.mirrorHorizontally && pDrawThemeBackgroundEx == 0)
|| translucentToplevel; || translucentToplevel;
if (!useFallback) if (!useFallback)
drawBackgroundDirectly(themeData); drawBackgroundDirectly(themeData);
else else

View File

@ -312,7 +312,7 @@ public:
QRegion region(XPThemeData &themeData); QRegion region(XPThemeData &themeData);
void setTransparency(QWidget *widget, XPThemeData &themeData); void setTransparency(QWidget *widget, XPThemeData &themeData);
void drawBackground(XPThemeData &themeData); void drawBackground(XPThemeData &themeData, bool forceFallback = false);
void drawBackgroundThruNativeBuffer(XPThemeData &themeData); void drawBackgroundThruNativeBuffer(XPThemeData &themeData);
void drawBackgroundDirectly(XPThemeData &themeData); void drawBackgroundDirectly(XPThemeData &themeData);