1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
|
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QMDISUBWINDOW_P_H
#define QMDISUBWINDOW_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include "qmdisubwindow.h"
#ifndef QT_NO_MDIAREA
#include <QStyle>
#include <QStyleOptionTitleBar>
#include <QMenuBar>
#include <QSizeGrip>
#include <QPointer>
#include <QDebug>
#include <private/qwidget_p.h>
QT_BEGIN_NAMESPACE
class QVBoxLayout;
class QMouseEvent;
namespace QMdi {
template<typename T>
class ControlElement : public T
{
public:
ControlElement(QMdiSubWindow *child) : T(child, 0)
{
Q_ASSERT(child);
mdiChild = child;
}
void *qt_metacast(const char *classname)
{
if (classname && strcmp(classname, "ControlElement") == 0)
return this;
return 0;
}
QPointer<QMdiSubWindow> mdiChild;
};
class ControlContainer : public QObject
{
public:
ControlContainer(QMdiSubWindow *mdiChild);
~ControlContainer();
#ifndef QT_NO_MENUBAR
void showButtonsInMenuBar(QMenuBar *menuBar);
void removeButtonsFromMenuBar(QMenuBar *menuBar = 0);
QMenuBar *menuBar() const { return m_menuBar; }
#endif
void updateWindowIcon(const QIcon &windowIcon);
QWidget *controllerWidget() const { return m_controllerWidget; }
QWidget *systemMenuLabel() const { return m_menuLabel; }
private:
QPointer<QWidget> previousLeft;
QPointer<QWidget> previousRight;
#ifndef QT_NO_MENUBAR
QPointer<QMenuBar> m_menuBar;
#endif
QPointer<QWidget> m_controllerWidget;
QPointer<QWidget> m_menuLabel;
QPointer<QMdiSubWindow> mdiChild;
};
} // namespace QMdi
class QMdiSubWindowPrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QMdiSubWindow)
public:
// Enums and typedefs.
enum Operation {
None,
Move,
TopResize,
BottomResize,
LeftResize,
RightResize,
TopLeftResize,
TopRightResize,
BottomLeftResize,
BottomRightResize
};
enum ChangeFlag {
HMove = 0x01,
VMove = 0x02,
HResize = 0x04,
VResize = 0x08,
HResizeReverse = 0x10,
VResizeReverse = 0x20
};
enum WindowStateAction {
RestoreAction,
MoveAction,
ResizeAction,
MinimizeAction,
MaximizeAction,
StayOnTopAction,
CloseAction,
/* Add new states _above_ this line! */
NumWindowStateActions
};
struct OperationInfo {
uint changeFlags;
Qt::CursorShape cursorShape;
QRegion region;
bool hover;
OperationInfo(uint changeFlags, Qt::CursorShape cursorShape, bool hover = true)
: changeFlags(changeFlags),
cursorShape(cursorShape),
hover(hover)
{}
};
typedef QMap<Operation, OperationInfo> OperationInfoMap;
QMdiSubWindowPrivate();
// Variables.
QPointer<QWidget> baseWidget;
QPointer<QWidget> restoreFocusWidget;
QPointer<QMdi::ControlContainer> controlContainer;
#ifndef QT_NO_SIZEGRIP
QPointer<QSizeGrip> sizeGrip;
#endif
#ifndef QT_NO_RUBBERBAND
QRubberBand *rubberBand;
#endif
QPoint mousePressPosition;
QRect oldGeometry;
QSize internalMinimumSize;
QSize userMinimumSize;
QSize restoreSize;
bool resizeEnabled;
bool moveEnabled;
bool isInInteractiveMode;
#ifndef QT_NO_RUBBERBAND
bool isInRubberBandMode;
#endif
bool isShadeMode;
bool ignoreWindowTitleChange;
bool ignoreNextActivationEvent;
bool activationEnabled;
bool isShadeRequestFromMinimizeMode;
bool isMaximizeMode;
bool isWidgetHiddenByUs;
bool isActive;
bool isExplicitlyDeactivated;
int keyboardSingleStep;
int keyboardPageStep;
int resizeTimerId;
Operation currentOperation;
QStyle::SubControl hoveredSubControl;
QStyle::SubControl activeSubControl;
Qt::FocusReason focusInReason;
OperationInfoMap operationMap;
QPointer<QMenu> systemMenu;
#ifndef QT_NO_ACTIONS
QPointer<QAction> actions[NumWindowStateActions];
#endif
QMdiSubWindow::SubWindowOptions options;
QString lastChildWindowTitle;
QPalette titleBarPalette;
QString windowTitle;
QFont font;
QIcon menuIcon;
QStyleOptionTitleBar cachedStyleOptions;
QString originalTitle;
// Slots.
void _q_updateStaysOnTopHint();
void _q_enterInteractiveMode();
void _q_processFocusChanged(QWidget *old, QWidget *now);
// Functions.
void leaveInteractiveMode();
void removeBaseWidget();
void initOperationMap();
#ifndef QT_NO_MENU
void createSystemMenu();
#endif
void updateCursor();
void updateDirtyRegions();
void updateGeometryConstraints();
void updateMask();
void setNewGeometry(const QPoint &pos);
void setMinimizeMode();
void setNormalMode();
void setMaximizeMode();
void setActive(bool activate, bool changeFocus = true);
void processClickedSubControl();
QRegion getRegion(Operation operation) const;
Operation getOperation(const QPoint &pos) const;
QStyleOptionTitleBar titleBarOptions() const;
void ensureWindowState(Qt::WindowState state);
int titleBarHeight(const QStyleOptionTitleBar &options) const;
void sizeParameters(int *margin, int *minWidth) const;
bool drawTitleBarWhenMaximized() const;
#ifndef QT_NO_MENUBAR
QMenuBar *menuBar() const;
void showButtonsInMenuBar(QMenuBar *menuBar);
void removeButtonsFromMenuBar();
#endif
void updateWindowTitle(bool requestFromChild);
#ifndef QT_NO_RUBBERBAND
void enterRubberBandMode();
void leaveRubberBandMode();
#endif
QPalette desktopPalette() const;
void updateActions();
void setFocusWidget();
void restoreFocus();
void setWindowFlags(Qt::WindowFlags windowFlags);
void setVisible(WindowStateAction, bool visible = true);
#ifndef QT_NO_ACTION
void setEnabled(WindowStateAction, bool enable = true);
#ifndef QT_NO_MENU
void addToSystemMenu(WindowStateAction, const QString &text, const char *slot);
#endif
#endif // QT_NO_ACTION
QSize iconSize() const;
#ifndef QT_NO_SIZEGRIP
void setSizeGrip(QSizeGrip *sizeGrip);
void setSizeGripVisible(bool visible = true) const;
#endif
void updateInternalWindowTitle();
QString originalWindowTitle();
void setNewWindowTitle();
inline int titleBarHeight() const
{
Q_Q(const QMdiSubWindow);
if (!parent || q->windowFlags() & Qt::FramelessWindowHint
|| (q->isMaximized() && !drawTitleBarWhenMaximized())) {
return 0;
}
QStyleOptionTitleBar options = titleBarOptions();
int height = options.rect.height();
if (hasBorder(options))
height += q->isMinimized() ? 8 : 4;
return height;
}
inline QStyle::SubControl getSubControl(const QPoint &pos) const
{
Q_Q(const QMdiSubWindow);
QStyleOptionTitleBar titleBarOptions = this->titleBarOptions();
return q->style()->hitTestComplexControl(QStyle::CC_TitleBar, &titleBarOptions, pos, q);
}
inline void setNewGeometry(QRect *geometry)
{
Q_Q(QMdiSubWindow);
Q_ASSERT(parent);
geometry->setSize(geometry->size().expandedTo(internalMinimumSize));
#ifndef QT_NO_RUBBERBAND
if (isInRubberBandMode)
rubberBand->setGeometry(*geometry);
else
#endif
q->setGeometry(*geometry);
}
inline bool hasBorder(const QStyleOptionTitleBar &options) const
{
Q_Q(const QMdiSubWindow);
return !q->style()->styleHint(QStyle::SH_TitleBar_NoBorder, &options, q);
}
inline bool autoRaise() const
{
Q_Q(const QMdiSubWindow);
return q->style()->styleHint(QStyle::SH_TitleBar_AutoRaise, 0, q);
}
inline bool isResizeOperation() const
{
return currentOperation != None && currentOperation != Move;
}
inline bool isMoveOperation() const
{
return currentOperation == Move;
}
};
#endif // QT_NO_MDIAREA
QT_END_NAMESPACE
#endif // QMDISUBWINDOW_P_H
|