diff options
author | Morten Engvoldsen <morten.engvoldsen@nokia.com> | 2010-07-09 13:21:37 (GMT) |
---|---|---|
committer | Morten Engvoldsen <morten.engvoldsen@nokia.com> | 2010-07-09 13:21:37 (GMT) |
commit | ba771d504c9f8a33ede5a0a55ca0ac37396d83b6 (patch) | |
tree | e64195e4a0626ff8a02275f5eb3500c5c173fa2e | |
parent | c50d351df3b7fe2f0d10444c1080b6a8c9833e0f (diff) | |
parent | 54e3221555997d26d59b880e3e153f1fc979505d (diff) | |
download | Qt-ba771d504c9f8a33ede5a0a55ca0ac37396d83b6.zip Qt-ba771d504c9f8a33ede5a0a55ca0ac37396d83b6.tar.gz Qt-ba771d504c9f8a33ede5a0a55ca0ac37396d83b6.tar.bz2 |
Merge branch '4.7' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7
-rw-r--r-- | src/gui/dialogs/qwizard_win.cpp | 42 | ||||
-rw-r--r-- | src/gui/dialogs/qwizard_win_p.h | 21 |
2 files changed, 43 insertions, 20 deletions
diff --git a/src/gui/dialogs/qwizard_win.cpp b/src/gui/dialogs/qwizard_win.cpp index e406cba..ad8801a 100644 --- a/src/gui/dialogs/qwizard_win.cpp +++ b/src/gui/dialogs/qwizard_win.cpp @@ -180,7 +180,8 @@ QVistaBackButton::QVistaBackButton(QWidget *widget) QSize QVistaBackButton::sizeHint() const { ensurePolished(); - int width = 32, height = 32; + int size = int(QStyleHelper::dpiScaled(32)); + int width = size, height = size; /* HANDLE theme = pOpenThemeData(0, L"Navigation"); SIZE size; @@ -213,8 +214,8 @@ void QVistaBackButton::paintEvent(QPaintEvent *) HANDLE theme = pOpenThemeData(0, L"Navigation"); //RECT rect; RECT clipRect; - int xoffset = QWidget::mapToParent(r.topLeft()).x(); - int yoffset = QWidget::mapToParent(r.topLeft()).y(); + int xoffset = QWidget::mapToParent(r.topLeft()).x() - 1; + int yoffset = QWidget::mapToParent(r.topLeft()).y() - 1; clipRect.top = r.top() + yoffset; clipRect.bottom = r.bottom() + yoffset; @@ -245,6 +246,11 @@ QVistaHelper::QVistaHelper(QWizard *wizard) is_vista = resolveSymbols(); if (is_vista) backButton_ = new QVistaBackButton(wizard); + + // Handle diff between Windows 7 and Vista + iconSpacing = QStyleHelper::dpiScaled(7); + textSpacing = QSysInfo::WindowsVersion >= QSysInfo::WV_WINDOWS7 ? + iconSpacing : QStyleHelper::dpiScaled(20); } QVistaHelper::~QVistaHelper() @@ -308,18 +314,15 @@ bool QVistaHelper::setDWMTitleBar(TitleBarChangeType type) void QVistaHelper::drawTitleBar(QPainter *painter) { - if (vistaState() == VistaAero) - drawBlackRect( - QRect(0, 0, wizard->width(), titleBarSize() + topOffset()), - painter->paintEngine()->getDC()); + HDC hdc = painter->paintEngine()->getDC(); + if (vistaState() == VistaAero) + drawBlackRect(QRect(0, 0, wizard->width(), + titleBarSize() + topOffset()), hdc); Q_ASSERT(backButton_); const int btnTop = backButton_->mapToParent(QPoint()).y(); const int btnHeight = backButton_->size().height(); - const int verticalCenter = (btnTop + btnHeight / 2); - - wizard->windowIcon().paint( - painter, QRect(leftMargin(), verticalCenter - iconSize() / 2, iconSize(), iconSize())); + const int verticalCenter = (btnTop + btnHeight / 2) - 1; const QString text = wizard->window()->windowTitle(); const QFont font = QApplication::font("QWorkspaceTitleBar"); @@ -327,14 +330,25 @@ void QVistaHelper::drawTitleBar(QPainter *painter) const QRect brect = fontMetrics.boundingRect(text); int textHeight = brect.height(); int textWidth = brect.width(); + int glowOffset = 0; + if (vistaState() == VistaAero) { textHeight += 2 * glowSize(); textWidth += 2 * glowSize(); + glowOffset = glowSize(); } + drawTitleText( painter, text, - QRect(titleOffset(), verticalCenter - textHeight / 2, textWidth, textHeight), - painter->paintEngine()->getDC()); + QRect(titleOffset() - glowOffset, verticalCenter - textHeight / 2, textWidth, textHeight), + hdc); + + if (!wizard->windowIcon().isNull()) { + QRect rect(leftMargin(), verticalCenter - iconSize() / 2, iconSize(), iconSize()); + HICON hIcon = wizard->windowIcon().pixmap(iconSize()).toWinHICON(); + DrawIconEx(hdc, rect.left(), rect.top(), hIcon, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT); + DestroyIcon(hIcon); + } } void QVistaHelper::setTitleBarIconAndCaptionVisible(bool visible) @@ -734,7 +748,7 @@ bool QVistaHelper::resolveSymbols() int QVistaHelper::titleOffset() { - int iconOffset = wizard ->windowIcon().isNull() ? 0 : iconSize() + padding(); + int iconOffset = wizard ->windowIcon().isNull() ? 0 : iconSize() + textSpacing; return leftMargin() + iconOffset; } diff --git a/src/gui/dialogs/qwizard_win_p.h b/src/gui/dialogs/qwizard_win_p.h index 5f3b6c2..caf018d 100644 --- a/src/gui/dialogs/qwizard_win_p.h +++ b/src/gui/dialogs/qwizard_win_p.h @@ -61,6 +61,7 @@ #include <qwidget.h> #include <qabstractbutton.h> #include <QtGui/private/qwidget_p.h> +#include <QtGui/private/qstylehelper_p.h> QT_BEGIN_NAMESPACE @@ -100,9 +101,14 @@ public: enum VistaState { VistaAero, VistaBasic, Classic, Dirty }; static VistaState vistaState(); static int titleBarSize() { return frameSize() + captionSize(); } - static int topPadding() { return 8; } - static int topOffset() { return titleBarSize() + (vistaState() == VistaAero ? 13 : 3); } - + static int topPadding() { // padding under text + return int(QStyleHelper::dpiScaled( + QSysInfo::WindowsVersion >= QSysInfo::WV_WINDOWS7 ? 4 : 6)); + } + static int topOffset() { + static int aeroOffset = QSysInfo::WindowsVersion >= QSysInfo::WV_WINDOWS7 ? + QStyleHelper::dpiScaled(4) : QStyleHelper::dpiScaled(13); + return (titleBarSize() + (vistaState() == VistaAero ? aeroOffset : 3)); } private: static HFONT getCaptionFont(HANDLE hTheme); bool drawTitleText(QPainter *painter, const QString &text, const QRect &rect, HDC hdc); @@ -111,11 +117,10 @@ private: static int frameSize() { return GetSystemMetrics(SM_CYSIZEFRAME); } static int captionSize() { return GetSystemMetrics(SM_CYCAPTION); } - static int backButtonSize() { return 31; } // ### should be queried from back button itself + static int backButtonSize() { return int(QStyleHelper::dpiScaled(30)); } static int iconSize() { return 16; } // Standard Aero - static int padding() { return 7; } // Standard Aero - static int leftMargin() { return backButtonSize() + padding(); } static int glowSize() { return 10; } + int leftMargin() { return backButton_->isVisible() ? backButtonSize() + iconSpacing : 0; } int titleOffset(); bool resolveSymbols(); @@ -139,6 +144,10 @@ private: QRect rtTitle; QWizard *wizard; QVistaBackButton *backButton_; + + int titleBarOffset; // Extra spacing above the text + int iconSpacing; // Space between button and icon + int textSpacing; // Space between icon and text }; |