Cleanup QWizard Windows implementation
Since DWM composition is now always enabled and can't be disabled, The code for VistaBasic style is now dead code in reality, just remove them. Change-Id: Iab2ba9b11ed573b240814ab5e26dec656de42ed2 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
97b32fa0b6
commit
4e52a4c7e3
@ -328,8 +328,7 @@ void QWizardHeader::setup(const QWizardLayoutInfo &info, const QString &title,
|
|||||||
{
|
{
|
||||||
bool modern = ((info.wizStyle == QWizard::ModernStyle)
|
bool modern = ((info.wizStyle == QWizard::ModernStyle)
|
||||||
#if QT_CONFIG(style_windowsvista)
|
#if QT_CONFIG(style_windowsvista)
|
||||||
|| ((info.wizStyle == QWizard::AeroStyle
|
|| vistaDisabled()
|
||||||
&& QVistaHelper::vistaState() == QVistaHelper::Classic) || vistaDisabled())
|
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -535,7 +534,6 @@ public:
|
|||||||
void updatePixmap(QWizard::WizardPixmap which);
|
void updatePixmap(QWizard::WizardPixmap which);
|
||||||
#if QT_CONFIG(style_windowsvista)
|
#if QT_CONFIG(style_windowsvista)
|
||||||
bool vistaDisabled() const;
|
bool vistaDisabled() const;
|
||||||
bool isVistaThemeEnabled(QVistaHelper::VistaState state) const;
|
|
||||||
bool handleAeroStyleChange();
|
bool handleAeroStyleChange();
|
||||||
#endif
|
#endif
|
||||||
bool isVistaThemeEnabled() const;
|
bool isVistaThemeEnabled() const;
|
||||||
@ -604,7 +602,7 @@ public:
|
|||||||
QPointer<QShortcut> vistaNextShortcut;
|
QPointer<QShortcut> vistaNextShortcut;
|
||||||
# endif
|
# endif
|
||||||
bool vistaInitPending = true;
|
bool vistaInitPending = true;
|
||||||
QVistaHelper::VistaState vistaState = QVistaHelper::Dirty;
|
bool vistaDirty = true;
|
||||||
bool vistaStateChanged = false;
|
bool vistaStateChanged = false;
|
||||||
bool inHandleAeroStyleChange = false;
|
bool inHandleAeroStyleChange = false;
|
||||||
#endif
|
#endif
|
||||||
@ -888,7 +886,7 @@ QWizardLayoutInfo QWizardPrivate::layoutInfoForCurrentPage()
|
|||||||
info.wizStyle = wizStyle;
|
info.wizStyle = wizStyle;
|
||||||
if (info.wizStyle == QWizard::AeroStyle
|
if (info.wizStyle == QWizard::AeroStyle
|
||||||
#if QT_CONFIG(style_windowsvista)
|
#if QT_CONFIG(style_windowsvista)
|
||||||
&& (QVistaHelper::vistaState() == QVistaHelper::Classic || vistaDisabled())
|
&& vistaDisabled()
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
info.wizStyle = QWizard::ModernStyle;
|
info.wizStyle = QWizard::ModernStyle;
|
||||||
@ -1520,13 +1518,6 @@ bool QWizardPrivate::vistaDisabled() const
|
|||||||
return v.isValid() && v.toBool();
|
return v.isValid() && v.toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QWizardPrivate::isVistaThemeEnabled(QVistaHelper::VistaState state) const
|
|
||||||
{
|
|
||||||
return wizStyle == QWizard::AeroStyle
|
|
||||||
&& QVistaHelper::vistaState() == state
|
|
||||||
&& !vistaDisabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QWizardPrivate::handleAeroStyleChange()
|
bool QWizardPrivate::handleAeroStyleChange()
|
||||||
{
|
{
|
||||||
Q_Q(QWizard);
|
Q_Q(QWizard);
|
||||||
@ -1550,25 +1541,17 @@ bool QWizardPrivate::handleAeroStyleChange()
|
|||||||
if (isVistaThemeEnabled()) {
|
if (isVistaThemeEnabled()) {
|
||||||
const int topOffset = vistaHelper->topOffset(q);
|
const int topOffset = vistaHelper->topOffset(q);
|
||||||
const int topPadding = vistaHelper->topPadding(q);
|
const int topPadding = vistaHelper->topPadding(q);
|
||||||
if (isVistaThemeEnabled(QVistaHelper::VistaAero)) {
|
if (isWindow) {
|
||||||
if (isWindow) {
|
vistaHelper->setDWMTitleBar(QVistaHelper::ExtendedTitleBar);
|
||||||
vistaHelper->setDWMTitleBar(QVistaHelper::ExtendedTitleBar);
|
q->installEventFilter(vistaHelper);
|
||||||
q->installEventFilter(vistaHelper);
|
|
||||||
}
|
|
||||||
q->setMouseTracking(true);
|
|
||||||
antiFlickerWidget->move(0, vistaHelper->titleBarSize() + topOffset);
|
|
||||||
vistaHelper->backButton()->move(
|
|
||||||
0, topOffset // ### should ideally work without the '+ 1'
|
|
||||||
- qMin(topOffset, topPadding + 1));
|
|
||||||
vistaMargins = true;
|
|
||||||
vistaHelper->backButton()->show();
|
|
||||||
} else {
|
|
||||||
if (isWindow)
|
|
||||||
vistaHelper->setDWMTitleBar(QVistaHelper::NormalTitleBar);
|
|
||||||
q->setMouseTracking(true);
|
|
||||||
antiFlickerWidget->move(0, topOffset);
|
|
||||||
vistaHelper->backButton()->move(0, -1); // ### should ideally work with (0, 0)
|
|
||||||
}
|
}
|
||||||
|
q->setMouseTracking(true);
|
||||||
|
antiFlickerWidget->move(0, vistaHelper->titleBarSize() + topOffset);
|
||||||
|
vistaHelper->backButton()->move(
|
||||||
|
0, topOffset // ### should ideally work without the '+ 1'
|
||||||
|
- qMin(topOffset, topPadding + 1));
|
||||||
|
vistaMargins = true;
|
||||||
|
vistaHelper->backButton()->show();
|
||||||
if (isWindow)
|
if (isWindow)
|
||||||
vistaHelper->setTitleBarIconAndCaptionVisible(false);
|
vistaHelper->setTitleBarIconAndCaptionVisible(false);
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
@ -1597,8 +1580,7 @@ bool QWizardPrivate::handleAeroStyleChange()
|
|||||||
bool QWizardPrivate::isVistaThemeEnabled() const
|
bool QWizardPrivate::isVistaThemeEnabled() const
|
||||||
{
|
{
|
||||||
#if QT_CONFIG(style_windowsvista)
|
#if QT_CONFIG(style_windowsvista)
|
||||||
return isVistaThemeEnabled(QVistaHelper::VistaAero)
|
return wizStyle == QWizard::AeroStyle && !vistaDisabled();
|
||||||
|| isVistaThemeEnabled(QVistaHelper::VistaBasic);
|
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
@ -1755,13 +1737,6 @@ void QWizardAntiFlickerWidget::paintEvent(QPaintEvent *)
|
|||||||
painter.fillRect(0, buttonLayoutTop, width(), height() - buttonLayoutTop, brush);
|
painter.fillRect(0, buttonLayoutTop, width(), height() - buttonLayoutTop, brush);
|
||||||
painter.setPen(QPen(QBrush(QColor(223, 223, 223)), 0)); // ### hardcoded for now
|
painter.setPen(QPen(QBrush(QColor(223, 223, 223)), 0)); // ### hardcoded for now
|
||||||
painter.drawLine(0, buttonLayoutTop, width(), buttonLayoutTop);
|
painter.drawLine(0, buttonLayoutTop, width(), buttonLayoutTop);
|
||||||
if (wizardPrivate->isVistaThemeEnabled(QVistaHelper::VistaBasic)) {
|
|
||||||
if (window()->isActiveWindow())
|
|
||||||
painter.setPen(QPen(QBrush(QColor(169, 191, 214)), 0)); // ### hardcoded for now
|
|
||||||
else
|
|
||||||
painter.setPen(QPen(QBrush(QColor(182, 193, 204)), 0)); // ### hardcoded for now
|
|
||||||
painter.drawLine(0, 0, width(), 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -3171,12 +3146,7 @@ bool QWizard::event(QEvent *event)
|
|||||||
#if QT_CONFIG(style_windowsvista)
|
#if QT_CONFIG(style_windowsvista)
|
||||||
else if (event->type() == QEvent::Show && d->vistaInitPending) {
|
else if (event->type() == QEvent::Show && d->vistaInitPending) {
|
||||||
d->vistaInitPending = false;
|
d->vistaInitPending = false;
|
||||||
// Do not force AeroStyle when in Classic theme.
|
d->wizStyle = AeroStyle;
|
||||||
// Note that d->handleAeroStyleChange() needs to be called in any case as it does some
|
|
||||||
// necessary initialization, like ensures that the Aero specific back button is hidden if
|
|
||||||
// Aero theme isn't active.
|
|
||||||
if (QVistaHelper::vistaState() != QVistaHelper::Classic)
|
|
||||||
d->wizStyle = AeroStyle;
|
|
||||||
d->handleAeroStyleChange();
|
d->handleAeroStyleChange();
|
||||||
}
|
}
|
||||||
else if (d->isVistaThemeEnabled()) {
|
else if (d->isVistaThemeEnabled()) {
|
||||||
@ -3206,8 +3176,7 @@ void QWizard::resizeEvent(QResizeEvent *event)
|
|||||||
#if QT_CONFIG(style_windowsvista)
|
#if QT_CONFIG(style_windowsvista)
|
||||||
if (d->isVistaThemeEnabled()) {
|
if (d->isVistaThemeEnabled()) {
|
||||||
heightOffset = d->vistaHelper->topOffset(this);
|
heightOffset = d->vistaHelper->topOffset(this);
|
||||||
if (d->isVistaThemeEnabled(QVistaHelper::VistaAero))
|
heightOffset += d->vistaHelper->titleBarSize();
|
||||||
heightOffset += d->vistaHelper->titleBarSize();
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
d->antiFlickerWidget->resize(event->size().width(), event->size().height() - heightOffset);
|
d->antiFlickerWidget->resize(event->size().width(), event->size().height() - heightOffset);
|
||||||
@ -3234,11 +3203,6 @@ void QWizard::paintEvent(QPaintEvent * event)
|
|||||||
}
|
}
|
||||||
#if QT_CONFIG(style_windowsvista)
|
#if QT_CONFIG(style_windowsvista)
|
||||||
else if (d->isVistaThemeEnabled()) {
|
else if (d->isVistaThemeEnabled()) {
|
||||||
if (d->isVistaThemeEnabled(QVistaHelper::VistaBasic)) {
|
|
||||||
QPainter painter(this);
|
|
||||||
QColor color = d->vistaHelper->basicWindowFrameColor();
|
|
||||||
painter.fillRect(0, 0, width(), QVistaHelper::topOffset(this), color);
|
|
||||||
}
|
|
||||||
d->vistaHelper->paintEvent(event);
|
d->vistaHelper->paintEvent(event);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -3257,12 +3221,12 @@ bool QWizard::nativeEvent(const QByteArray &eventType, void *message, qintptr *r
|
|||||||
if (d->isVistaThemeEnabled() && eventType == "windows_generic_MSG") {
|
if (d->isVistaThemeEnabled() && eventType == "windows_generic_MSG") {
|
||||||
MSG *windowsMessage = static_cast<MSG *>(message);
|
MSG *windowsMessage = static_cast<MSG *>(message);
|
||||||
const bool winEventResult = d->vistaHelper->handleWinEvent(windowsMessage, result);
|
const bool winEventResult = d->vistaHelper->handleWinEvent(windowsMessage, result);
|
||||||
if (QVistaHelper::vistaState() != d->vistaState) {
|
if (d->vistaDirty) {
|
||||||
// QTBUG-78300: When Qt::AA_NativeWindows is set, delay further
|
// QTBUG-78300: When Qt::AA_NativeWindows is set, delay further
|
||||||
// window creation until after the platform window creation events.
|
// window creation until after the platform window creation events.
|
||||||
if (windowsMessage->message == WM_GETICON) {
|
if (windowsMessage->message == WM_GETICON) {
|
||||||
d->vistaStateChanged = true;
|
d->vistaStateChanged = true;
|
||||||
d->vistaState = QVistaHelper::vistaState();
|
d->vistaDirty = false;
|
||||||
setWizardStyle(AeroStyle);
|
setWizardStyle(AeroStyle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,9 +33,7 @@ Q_DECLARE_METATYPE(QMargins)
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
int QVistaHelper::instanceCount = 0;
|
|
||||||
int QVistaHelper::m_devicePixelRatio = 1;
|
int QVistaHelper::m_devicePixelRatio = 1;
|
||||||
QVistaHelper::VistaState QVistaHelper::cachedVistaState = QVistaHelper::Dirty;
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
** QVistaBackButton
|
** QVistaBackButton
|
||||||
@ -118,18 +116,14 @@ QVistaHelper::QVistaHelper(QWizard *wizard)
|
|||||||
, backButton_(0)
|
, backButton_(0)
|
||||||
{
|
{
|
||||||
QVistaHelper::m_devicePixelRatio = wizard->devicePixelRatio();
|
QVistaHelper::m_devicePixelRatio = wizard->devicePixelRatio();
|
||||||
if (instanceCount++ == 0)
|
|
||||||
cachedVistaState = Dirty;
|
|
||||||
backButton_ = new QVistaBackButton(wizard);
|
backButton_ = new QVistaBackButton(wizard);
|
||||||
backButton_->hide();
|
backButton_->hide();
|
||||||
|
|
||||||
iconSpacing = QStyleHelper::dpiScaled(7, wizard);
|
iconSpacing = QStyleHelper::dpiScaled(7, wizard);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVistaHelper::~QVistaHelper()
|
QVistaHelper::~QVistaHelper() = default;
|
||||||
{
|
|
||||||
--instanceCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QVistaHelper::updateCustomMargins(bool vistaMargins)
|
void QVistaHelper::updateCustomMargins(bool vistaMargins)
|
||||||
{
|
{
|
||||||
@ -150,24 +144,6 @@ void QVistaHelper::updateCustomMargins(bool vistaMargins)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QVistaHelper::isCompositionEnabled()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QVistaHelper::isThemeActive()
|
|
||||||
{
|
|
||||||
return IsThemeActive();
|
|
||||||
}
|
|
||||||
|
|
||||||
QVistaHelper::VistaState QVistaHelper::vistaState()
|
|
||||||
{
|
|
||||||
if (instanceCount == 0 || cachedVistaState == Dirty)
|
|
||||||
cachedVistaState =
|
|
||||||
isCompositionEnabled() ? VistaAero : isThemeActive() ? VistaBasic : Classic;
|
|
||||||
return cachedVistaState;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QVistaHelper::disconnectBackButton()
|
void QVistaHelper::disconnectBackButton()
|
||||||
{
|
{
|
||||||
if (backButton_) // Leave QStyleSheetStyle's connections on destroyed() intact.
|
if (backButton_) // Leave QStyleSheetStyle's connections on destroyed() intact.
|
||||||
@ -188,18 +164,16 @@ QColor QVistaHelper::basicWindowFrameColor()
|
|||||||
|
|
||||||
bool QVistaHelper::setDWMTitleBar(TitleBarChangeType type)
|
bool QVistaHelper::setDWMTitleBar(TitleBarChangeType type)
|
||||||
{
|
{
|
||||||
bool value = false;
|
MARGINS mar = {0, 0, 0, 0};
|
||||||
if (vistaState() == VistaAero) {
|
if (type == NormalTitleBar)
|
||||||
MARGINS mar = {0, 0, 0, 0};
|
mar.cyTopHeight = 0;
|
||||||
if (type == NormalTitleBar)
|
else
|
||||||
mar.cyTopHeight = 0;
|
mar.cyTopHeight = (titleBarSize() + topOffset(wizard)) * QVistaHelper::m_devicePixelRatio;
|
||||||
else
|
if (const HWND wizardHandle = wizardHWND()) {
|
||||||
mar.cyTopHeight = (titleBarSize() + topOffset(wizard)) * QVistaHelper::m_devicePixelRatio;
|
if (SUCCEEDED(DwmExtendFrameIntoClientArea(wizardHandle, &mar)))
|
||||||
if (const HWND wizardHandle = wizardHWND())
|
return true;
|
||||||
if (SUCCEEDED(DwmExtendFrameIntoClientArea(wizardHandle, &mar)))
|
|
||||||
value = true;
|
|
||||||
}
|
}
|
||||||
return value;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &);
|
Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &);
|
||||||
@ -235,7 +209,7 @@ void QVistaHelper::drawTitleBar(QPainter *painter)
|
|||||||
const bool isWindow = wizard->isWindow();
|
const bool isWindow = wizard->isWindow();
|
||||||
const HDC hdc = QVistaHelper::backingStoreDC(wizard, &origin);
|
const HDC hdc = QVistaHelper::backingStoreDC(wizard, &origin);
|
||||||
|
|
||||||
if (vistaState() == VistaAero && isWindow)
|
if (isWindow)
|
||||||
drawBlackRect(QRect(0, 0, wizard->width(),
|
drawBlackRect(QRect(0, 0, wizard->width(),
|
||||||
titleBarSize() + topOffset(wizard)), hdc);
|
titleBarSize() + topOffset(wizard)), hdc);
|
||||||
// The button is positioned in QWizardPrivate::handleAeroStyleChange(),
|
// The button is positioned in QWizardPrivate::handleAeroStyleChange(),
|
||||||
@ -250,15 +224,9 @@ void QVistaHelper::drawTitleBar(QPainter *painter)
|
|||||||
font = QApplication::font("QMdiSubWindowTitleBar");
|
font = QApplication::font("QMdiSubWindowTitleBar");
|
||||||
const QFontMetrics fontMetrics(font);
|
const QFontMetrics fontMetrics(font);
|
||||||
const QRect brect = fontMetrics.boundingRect(text);
|
const QRect brect = fontMetrics.boundingRect(text);
|
||||||
int textHeight = brect.height();
|
const int glowOffset = glowSize(wizard);
|
||||||
int textWidth = brect.width();
|
int textHeight = brect.height() + 2 * glowOffset;
|
||||||
int glowOffset = 0;
|
int textWidth = brect.width() + 2 * glowOffset;
|
||||||
|
|
||||||
if (vistaState() == VistaAero) {
|
|
||||||
glowOffset = glowSize(wizard);
|
|
||||||
textHeight += 2 * glowOffset;
|
|
||||||
textWidth += 2 * glowOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int titleLeft = (wizard->layoutDirection() == Qt::LeftToRight
|
const int titleLeft = (wizard->layoutDirection() == Qt::LeftToRight
|
||||||
? titleOffset() - glowOffset
|
? titleOffset() - glowOffset
|
||||||
@ -365,11 +333,8 @@ void QVistaHelper::mouseEvent(QEvent *event)
|
|||||||
|
|
||||||
bool QVistaHelper::handleWinEvent(MSG *message, qintptr *result)
|
bool QVistaHelper::handleWinEvent(MSG *message, qintptr *result)
|
||||||
{
|
{
|
||||||
if (message->message == WM_THEMECHANGED || message->message == WM_DWMCOMPOSITIONCHANGED)
|
|
||||||
cachedVistaState = Dirty;
|
|
||||||
|
|
||||||
bool status = false;
|
bool status = false;
|
||||||
if (wizard->wizardStyle() == QWizard::AeroStyle && vistaState() == VistaAero) {
|
if (wizard->wizardStyle() == QWizard::AeroStyle) {
|
||||||
status = winEvent(message, result);
|
status = winEvent(message, result);
|
||||||
if (message->message == WM_NCPAINT)
|
if (message->message == WM_NCPAINT)
|
||||||
wizard->update();
|
wizard->update();
|
||||||
@ -382,8 +347,6 @@ void QVistaHelper::resizeEvent(QResizeEvent * event)
|
|||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
rtTop = QRect (0, 0, wizard->width(), frameSize());
|
rtTop = QRect (0, 0, wizard->width(), frameSize());
|
||||||
int height = captionSize() + topOffset(wizard);
|
int height = captionSize() + topOffset(wizard);
|
||||||
if (vistaState() == VistaBasic)
|
|
||||||
height -= titleBarSize();
|
|
||||||
rtTitle = QRect (0, frameSize(), wizard->width(), height);
|
rtTitle = QRect (0, frameSize(), wizard->width(), height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,7 +385,7 @@ void QVistaHelper::mouseMoveEvent(QMouseEvent *event)
|
|||||||
}
|
}
|
||||||
wizard->setGeometry(rect);
|
wizard->setGeometry(rect);
|
||||||
|
|
||||||
} else if (vistaState() == VistaAero) {
|
} else {
|
||||||
setMouseCursor(event->pos());
|
setMouseCursor(event->pos());
|
||||||
}
|
}
|
||||||
event->ignore();
|
event->ignore();
|
||||||
@ -440,11 +403,10 @@ void QVistaHelper::mousePressEvent(QMouseEvent *event)
|
|||||||
if (rtTitle.contains(event->pos())) {
|
if (rtTitle.contains(event->pos())) {
|
||||||
change = movePosition;
|
change = movePosition;
|
||||||
} else if (rtTop.contains(event->pos()))
|
} else if (rtTop.contains(event->pos()))
|
||||||
change = (vistaState() == VistaAero) ? resizeTop : movePosition;
|
change = resizeTop;
|
||||||
|
|
||||||
if (change != noChange) {
|
if (change != noChange) {
|
||||||
if (vistaState() == VistaAero)
|
setMouseCursor(event->pos());
|
||||||
setMouseCursor(event->pos());
|
|
||||||
pressed = true;
|
pressed = true;
|
||||||
pressedPos = event->pos();
|
pressedPos = event->pos();
|
||||||
} else {
|
} else {
|
||||||
@ -458,8 +420,7 @@ void QVistaHelper::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
if (pressed) {
|
if (pressed) {
|
||||||
pressed = false;
|
pressed = false;
|
||||||
wizard->releaseMouse();
|
wizard->releaseMouse();
|
||||||
if (vistaState() == VistaAero)
|
setMouseCursor(event->pos());
|
||||||
setMouseCursor(event->pos());
|
|
||||||
}
|
}
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
@ -547,90 +508,83 @@ HWND QVistaHelper::wizardHWND() const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QVistaHelper::drawTitleText(QPainter *painter, const QString &text, const QRect &rect, HDC hdc)
|
void QVistaHelper::drawTitleText(QPainter *painter, const QString &text, const QRect &rect, HDC hdc)
|
||||||
{
|
{
|
||||||
bool value = false;
|
Q_UNUSED(painter);
|
||||||
if (vistaState() == VistaAero) {
|
|
||||||
const QRect rectDp = QRect(rect.topLeft() * QVistaHelper::m_devicePixelRatio,
|
|
||||||
rect.size() * QVistaHelper::m_devicePixelRatio);
|
|
||||||
const HANDLE hTheme = OpenThemeData(GetDesktopWindow(), L"WINDOW");
|
|
||||||
if (!hTheme) return false;
|
|
||||||
// Set up a memory DC and bitmap that we'll draw into
|
|
||||||
HDC dcMem;
|
|
||||||
HBITMAP bmp;
|
|
||||||
BITMAPINFO dib;
|
|
||||||
ZeroMemory(&dib, sizeof(dib));
|
|
||||||
dcMem = CreateCompatibleDC(hdc);
|
|
||||||
|
|
||||||
dib.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
const QRect rectDp = QRect(rect.topLeft() * QVistaHelper::m_devicePixelRatio,
|
||||||
dib.bmiHeader.biWidth = rectDp.width();
|
rect.size() * QVistaHelper::m_devicePixelRatio);
|
||||||
dib.bmiHeader.biHeight = -rectDp.height();
|
const HANDLE hTheme = OpenThemeData(GetDesktopWindow(), L"WINDOW");
|
||||||
dib.bmiHeader.biPlanes = 1;
|
if (!hTheme)
|
||||||
dib.bmiHeader.biBitCount = 32;
|
return;
|
||||||
dib.bmiHeader.biCompression = BI_RGB;
|
// Set up a memory DC and bitmap that we'll draw into
|
||||||
|
HDC dcMem;
|
||||||
|
HBITMAP bmp;
|
||||||
|
BITMAPINFO dib;
|
||||||
|
ZeroMemory(&dib, sizeof(dib));
|
||||||
|
dcMem = CreateCompatibleDC(hdc);
|
||||||
|
|
||||||
bmp = CreateDIBSection(hdc, &dib, DIB_RGB_COLORS, NULL, NULL, 0);
|
dib.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
|
dib.bmiHeader.biWidth = rectDp.width();
|
||||||
|
dib.bmiHeader.biHeight = -rectDp.height();
|
||||||
|
dib.bmiHeader.biPlanes = 1;
|
||||||
|
dib.bmiHeader.biBitCount = 32;
|
||||||
|
dib.bmiHeader.biCompression = BI_RGB;
|
||||||
|
|
||||||
// Set up the DC
|
bmp = CreateDIBSection(hdc, &dib, DIB_RGB_COLORS, NULL, NULL, 0);
|
||||||
const LOGFONT captionLogFont = getCaptionLogFont(hTheme);
|
|
||||||
const HFONT hCaptionFont = CreateFontIndirect(&captionLogFont);
|
|
||||||
auto hOldBmp = reinterpret_cast<HBITMAP>(SelectObject(dcMem, (HGDIOBJ) bmp));
|
|
||||||
auto hOldFont = reinterpret_cast<HFONT>(SelectObject(dcMem, (HGDIOBJ) hCaptionFont));
|
|
||||||
|
|
||||||
// Draw the text!
|
// Set up the DC
|
||||||
DTTOPTS dto;
|
const LOGFONT captionLogFont = getCaptionLogFont(hTheme);
|
||||||
memset(&dto, 0, sizeof(dto));
|
const HFONT hCaptionFont = CreateFontIndirect(&captionLogFont);
|
||||||
dto.dwSize = sizeof(dto);
|
auto hOldBmp = reinterpret_cast<HBITMAP>(SelectObject(dcMem, (HGDIOBJ) bmp));
|
||||||
const UINT uFormat = DT_SINGLELINE|DT_CENTER|DT_VCENTER|DT_NOPREFIX;
|
auto hOldFont = reinterpret_cast<HFONT>(SelectObject(dcMem, (HGDIOBJ) hCaptionFont));
|
||||||
RECT rctext ={0,0, rectDp.width(), rectDp.height()};
|
|
||||||
|
|
||||||
dto.dwFlags = DTT_COMPOSITED|DTT_GLOWSIZE;
|
// Draw the text!
|
||||||
dto.iGlowSize = glowSize(wizard);
|
DTTOPTS dto;
|
||||||
|
memset(&dto, 0, sizeof(dto));
|
||||||
|
dto.dwSize = sizeof(dto);
|
||||||
|
const UINT uFormat = DT_SINGLELINE|DT_CENTER|DT_VCENTER|DT_NOPREFIX;
|
||||||
|
RECT rctext ={0,0, rectDp.width(), rectDp.height()};
|
||||||
|
|
||||||
DrawThemeTextEx(hTheme, dcMem, 0, 0, reinterpret_cast<LPCWSTR>(text.utf16()), -1, uFormat, &rctext, &dto );
|
dto.dwFlags = DTT_COMPOSITED|DTT_GLOWSIZE;
|
||||||
BitBlt(hdc, rectDp.left(), rectDp.top(), rectDp.width(), rectDp.height(), dcMem, 0, 0, SRCCOPY);
|
dto.iGlowSize = glowSize(wizard);
|
||||||
SelectObject(dcMem, (HGDIOBJ) hOldBmp);
|
|
||||||
SelectObject(dcMem, (HGDIOBJ) hOldFont);
|
DrawThemeTextEx(hTheme, dcMem, 0, 0, reinterpret_cast<LPCWSTR>(text.utf16()), -1, uFormat, &rctext, &dto );
|
||||||
DeleteObject(bmp);
|
BitBlt(hdc, rectDp.left(), rectDp.top(), rectDp.width(), rectDp.height(), dcMem, 0, 0, SRCCOPY);
|
||||||
DeleteObject(hCaptionFont);
|
SelectObject(dcMem, (HGDIOBJ) hOldBmp);
|
||||||
DeleteDC(dcMem);
|
SelectObject(dcMem, (HGDIOBJ) hOldFont);
|
||||||
//ReleaseDC(hwnd, hdc);
|
DeleteObject(bmp);
|
||||||
} else if (vistaState() == VistaBasic) {
|
DeleteObject(hCaptionFont);
|
||||||
painter->drawText(rect, text);
|
DeleteDC(dcMem);
|
||||||
}
|
//ReleaseDC(hwnd, hdc);
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QVistaHelper::drawBlackRect(const QRect &rect, HDC hdc)
|
void QVistaHelper::drawBlackRect(const QRect &rect, HDC hdc)
|
||||||
{
|
{
|
||||||
bool value = false;
|
// Set up a memory DC and bitmap that we'll draw into
|
||||||
if (vistaState() == VistaAero) {
|
const QRect rectDp = QRect(rect.topLeft() * QVistaHelper::m_devicePixelRatio,
|
||||||
// Set up a memory DC and bitmap that we'll draw into
|
|
||||||
const QRect rectDp = QRect(rect.topLeft() * QVistaHelper::m_devicePixelRatio,
|
|
||||||
rect.size() * QVistaHelper::m_devicePixelRatio);
|
rect.size() * QVistaHelper::m_devicePixelRatio);
|
||||||
HDC dcMem;
|
HDC dcMem;
|
||||||
HBITMAP bmp;
|
HBITMAP bmp;
|
||||||
BITMAPINFO dib;
|
BITMAPINFO dib;
|
||||||
ZeroMemory(&dib, sizeof(dib));
|
ZeroMemory(&dib, sizeof(dib));
|
||||||
dcMem = CreateCompatibleDC(hdc);
|
dcMem = CreateCompatibleDC(hdc);
|
||||||
|
|
||||||
dib.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
dib.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
dib.bmiHeader.biWidth = rectDp.width();
|
dib.bmiHeader.biWidth = rectDp.width();
|
||||||
dib.bmiHeader.biHeight = -rectDp.height();
|
dib.bmiHeader.biHeight = -rectDp.height();
|
||||||
dib.bmiHeader.biPlanes = 1;
|
dib.bmiHeader.biPlanes = 1;
|
||||||
dib.bmiHeader.biBitCount = 32;
|
dib.bmiHeader.biBitCount = 32;
|
||||||
dib.bmiHeader.biCompression = BI_RGB;
|
dib.bmiHeader.biCompression = BI_RGB;
|
||||||
|
|
||||||
bmp = CreateDIBSection(hdc, &dib, DIB_RGB_COLORS, NULL, NULL, 0);
|
bmp = CreateDIBSection(hdc, &dib, DIB_RGB_COLORS, NULL, NULL, 0);
|
||||||
auto hOldBmp = reinterpret_cast<HBITMAP>(SelectObject(dcMem, (HGDIOBJ) bmp));
|
auto hOldBmp = reinterpret_cast<HBITMAP>(SelectObject(dcMem, (HGDIOBJ) bmp));
|
||||||
|
|
||||||
BitBlt(hdc, rectDp.left(), rectDp.top(), rectDp.width(), rectDp.height(), dcMem, 0, 0, SRCCOPY);
|
BitBlt(hdc, rectDp.left(), rectDp.top(), rectDp.width(), rectDp.height(), dcMem, 0, 0, SRCCOPY);
|
||||||
SelectObject(dcMem, (HGDIOBJ) hOldBmp);
|
SelectObject(dcMem, (HGDIOBJ) hOldBmp);
|
||||||
|
|
||||||
DeleteObject(bmp);
|
DeleteObject(bmp);
|
||||||
DeleteDC(dcMem);
|
DeleteDC(dcMem);
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int QVistaHelper::frameSizeDp()
|
int QVistaHelper::frameSizeDp()
|
||||||
@ -661,8 +615,6 @@ int QVistaHelper::glowSize(const QPaintDevice *device)
|
|||||||
|
|
||||||
int QVistaHelper::topOffset(const QPaintDevice *device)
|
int QVistaHelper::topOffset(const QPaintDevice *device)
|
||||||
{
|
{
|
||||||
if (vistaState() != VistaAero)
|
|
||||||
return titleBarSize() + 3;
|
|
||||||
static const int aeroOffset = QStyleHelper::dpiScaled(13, device);
|
static const int aeroOffset = QStyleHelper::dpiScaled(13, device);
|
||||||
return aeroOffset + titleBarSize();
|
return aeroOffset + titleBarSize();
|
||||||
}
|
}
|
||||||
|
@ -64,8 +64,6 @@ public:
|
|||||||
void disconnectBackButton();
|
void disconnectBackButton();
|
||||||
void hideBackButton() { if (backButton_) backButton_->hide(); }
|
void hideBackButton() { if (backButton_) backButton_->hide(); }
|
||||||
QColor basicWindowFrameColor();
|
QColor basicWindowFrameColor();
|
||||||
enum VistaState { VistaAero, VistaBasic, Classic, Dirty };
|
|
||||||
static VistaState vistaState();
|
|
||||||
static int titleBarSize() { return QVistaHelper::titleBarSizeDp() / QVistaHelper::m_devicePixelRatio; }
|
static int titleBarSize() { return QVistaHelper::titleBarSizeDp() / QVistaHelper::m_devicePixelRatio; }
|
||||||
static int titleBarSizeDp() { return QVistaHelper::frameSizeDp() + QVistaHelper::captionSizeDp(); }
|
static int titleBarSizeDp() { return QVistaHelper::frameSizeDp() + QVistaHelper::captionSizeDp(); }
|
||||||
static int topPadding(const QPaintDevice *device) { // padding under text
|
static int topPadding(const QPaintDevice *device) { // padding under text
|
||||||
@ -77,8 +75,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
HWND wizardHWND() const;
|
HWND wizardHWND() const;
|
||||||
bool drawTitleText(QPainter *painter, const QString &text, const QRect &rect, HDC hdc);
|
void drawTitleText(QPainter *painter, const QString &text, const QRect &rect, HDC hdc);
|
||||||
static bool drawBlackRect(const QRect &rect, HDC hdc);
|
static void drawBlackRect(const QRect &rect, HDC hdc);
|
||||||
|
|
||||||
static int frameSize() { return QVistaHelper::frameSizeDp() / QVistaHelper::m_devicePixelRatio; }
|
static int frameSize() { return QVistaHelper::frameSizeDp() / QVistaHelper::m_devicePixelRatio; }
|
||||||
static int frameSizeDp();
|
static int frameSizeDp();
|
||||||
@ -102,10 +100,6 @@ private:
|
|||||||
void mouseReleaseEvent(QMouseEvent *event);
|
void mouseReleaseEvent(QMouseEvent *event);
|
||||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
|
|
||||||
static int instanceCount;
|
|
||||||
static VistaState cachedVistaState;
|
|
||||||
static bool isCompositionEnabled();
|
|
||||||
static bool isThemeActive();
|
|
||||||
enum Changes { resizeTop, movePosition, noChange } change;
|
enum Changes { resizeTop, movePosition, noChange } change;
|
||||||
QPoint pressedPos;
|
QPoint pressedPos;
|
||||||
bool pressed;
|
bool pressed;
|
||||||
|
Loading…
Reference in New Issue
Block a user