1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 or version 3 as published by the Free
20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22 ** following information to ensure the GNU Lesser General Public License
23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 **
26 ** As a special exception, The Qt Company gives you certain additional
27 ** rights. These rights are described in The Qt Company LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 **
30 ** GNU General Public License Usage
31 ** Alternatively, this file may be used under the terms of the GNU
32 ** General Public License version 3.0 as published by the Free Software
33 ** Foundation and appearing in the file LICENSE.GPL included in the
34 ** packaging of this file.  Please review the following information to
35 ** ensure the GNU General Public License version 3.0 requirements will be
36 ** met: http://www.gnu.org/copyleft/gpl.html.
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QWIZARD_WIN_P_H
43 #define QWIZARD_WIN_P_H
44 
45 //
46 //  W A R N I N G
47 //  -------------
48 //
49 // This file is not part of the Qt API.  It exists purely as an
50 // implementation detail.  This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 
56 #ifndef QT_NO_WIZARD
57 #ifndef QT_NO_STYLE_WINDOWSVISTA
58 
59 #include <qt_windows.h>
60 #include <qobject.h>
61 #include <qwidget.h>
62 #include <qabstractbutton.h>
63 #include <QtGui/private/qwidget_p.h>
64 #include <QtGui/private/qstylehelper_p.h>
65 
66 QT_BEGIN_NAMESPACE
67 
68 class QVistaBackButton : public QAbstractButton
69 {
70 public:
71     QVistaBackButton(QWidget *widget);
72 
73     QSize sizeHint() const;
minimumSizeHint()74     inline QSize minimumSizeHint() const
75     { return sizeHint(); }
76 
77     void enterEvent(QEvent *event);
78     void leaveEvent(QEvent *event);
79     void paintEvent(QPaintEvent *event);
80 };
81 
82 class QWizard;
83 
84 class QVistaHelper : public QObject
85 {
86 public:
87     QVistaHelper(QWizard *wizard);
88     ~QVistaHelper();
89     enum TitleBarChangeType { NormalTitleBar, ExtendedTitleBar };
90     bool setDWMTitleBar(TitleBarChangeType type);
91     void setTitleBarIconAndCaptionVisible(bool visible);
92     void mouseEvent(QEvent *event);
93     bool handleWinEvent(MSG *message, long *result);
94     void resizeEvent(QResizeEvent *event);
95     void paintEvent(QPaintEvent *event);
backButton()96     QVistaBackButton *backButton() const { return backButton_; }
97     void disconnectBackButton();
hideBackButton()98     void hideBackButton() { if (backButton_) backButton_->hide(); }
99     void setWindowPosHack();
100     QColor basicWindowFrameColor();
101     enum VistaState { VistaAero, VistaBasic, Classic, Dirty };
102     static VistaState vistaState();
titleBarSize()103     static int titleBarSize() { return frameSize() + captionSize(); }
topPadding()104     static int topPadding() { // padding under text
105         return int(QStyleHelper::dpiScaled(
106                 QSysInfo::WindowsVersion >= QSysInfo::WV_WINDOWS7 ? 4 : 6));
107     }
108     static int topOffset();
109 
110 private:
111     static HFONT getCaptionFont(HANDLE hTheme);
112     bool drawTitleText(QPainter *painter, const QString &text, const QRect &rect, HDC hdc);
113     static bool drawBlackRect(const QRect &rect, HDC hdc);
114 
115     static int frameSize();
116     static int captionSize();
117 
backButtonSize()118     static int backButtonSize() { return int(QStyleHelper::dpiScaled(30)); }
iconSize()119     static int iconSize() { return 16; } // Standard Aero
glowSize()120     static int glowSize() { return 10; }
leftMargin()121     int leftMargin() { return backButton_->isVisible() ? backButtonSize() + iconSpacing : 0; }
122 
123     int titleOffset();
124     bool resolveSymbols();
125     void drawTitleBar(QPainter *painter);
126     void setMouseCursor(QPoint pos);
127     void collapseTopFrameStrut();
128     bool winEvent(MSG *message, long *result);
129     void mouseMoveEvent(QMouseEvent *event);
130     void mousePressEvent(QMouseEvent *event);
131     void mouseReleaseEvent(QMouseEvent *event);
132     bool eventFilter(QObject *obj, QEvent *event);
133 
134     static int instanceCount;
135     static bool is_vista;
136     static VistaState cachedVistaState;
137     static bool isCompositionEnabled();
138     static bool isThemeActive();
139     enum Changes { resizeTop, movePosition, noChange } change;
140     QPoint pressedPos;
141     bool pressed;
142     QRect rtTop;
143     QRect rtTitle;
144     QWizard *wizard;
145     QVistaBackButton *backButton_;
146 
147     int titleBarOffset;  // Extra spacing above the text
148     int iconSpacing;    // Space between button and icon
149     int textSpacing;    // Space between icon and text
150 };
151 
152 
153 QT_END_NAMESPACE
154 
155 #endif // QT_NO_STYLE_WINDOWSVISTA
156 #endif // QT_NO_WIZARD
157 #endif // QWIZARD_WIN_P_H
158