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
|
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** 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, Nokia gives you certain additional
** rights. These rights are described in the Nokia 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.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QMDIAREA_P_H
#define QMDIAREA_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 "qmdiarea.h"
#include "qmdisubwindow.h"
#ifndef QT_NO_MDIAREA
#include <QList>
#include <QRect>
#include <QPoint>
#include <QtGui/qapplication.h>
#include <private/qmdisubwindow_p.h>
#include <private/qabstractscrollarea_p.h>
QT_BEGIN_NAMESPACE
namespace QMdi {
class Rearranger
{
public:
enum Type {
RegularTiler,
SimpleCascader,
IconTiler
};
// Rearranges widgets relative to domain.
virtual void rearrange(QList<QWidget *> &widgets, const QRect &domain) const = 0;
virtual Type type() const = 0;
virtual ~Rearranger() {}
};
class RegularTiler : public Rearranger
{
// Rearranges widgets according to a regular tiling pattern
// covering the entire domain.
// Both positions and sizes may change.
void rearrange(QList<QWidget *> &widgets, const QRect &domain) const;
inline Type type() const { return Rearranger::RegularTiler; }
};
class SimpleCascader : public Rearranger
{
// Rearranges widgets according to a simple, regular cascading pattern.
// Widgets are resized to minimumSize.
// Both positions and sizes may change.
void rearrange(QList<QWidget *> &widgets, const QRect &domain) const;
inline Type type() const { return Rearranger::SimpleCascader; }
};
class IconTiler : public Rearranger
{
// Rearranges icons (assumed to be the same size) according to a regular
// tiling pattern filling up the domain from the bottom.
// Only positions may change.
void rearrange(QList<QWidget *> &widgets, const QRect &domain) const;
inline Type type() const { return Rearranger::IconTiler; }
};
class Placer
{
public:
// Places the rectangle defined by 'size' relative to 'rects' and 'domain'.
// Returns the position of the resulting rectangle.
virtual QPoint place(
const QSize &size, const QList<QRect> &rects, const QRect &domain) const = 0;
virtual ~Placer() {}
};
class MinOverlapPlacer : public Placer
{
QPoint place(const QSize &size, const QList<QRect> &rects, const QRect &domain) const;
static int accumulatedOverlap(const QRect &source, const QList<QRect> &rects);
static QRect findMinOverlapRect(const QList<QRect> &source, const QList<QRect> &rects);
static void getCandidatePlacements(
const QSize &size, const QList<QRect> &rects, const QRect &domain,
QList<QRect> &candidates);
static QPoint findBestPlacement(
const QRect &domain, const QList<QRect> &rects, QList<QRect> &source);
static void findNonInsiders(
const QRect &domain, QList<QRect> &source, QList<QRect> &result);
static void findMaxOverlappers(
const QRect &domain, const QList<QRect> &source, QList<QRect> &result);
};
} // namespace QMdi
class QMdiAreaTabBar;
class QMdiAreaPrivate : public QAbstractScrollAreaPrivate
{
Q_DECLARE_PUBLIC(QMdiArea)
public:
QMdiAreaPrivate();
// Variables.
QMdi::Rearranger *cascader;
QMdi::Rearranger *regularTiler;
QMdi::Rearranger *iconTiler;
QMdi::Placer *placer;
#ifndef QT_NO_RUBBERBAND
QRubberBand *rubberBand;
#endif
QMdiAreaTabBar *tabBar;
QList<QMdi::Rearranger *> pendingRearrangements;
QList< QPointer<QMdiSubWindow> > pendingPlacements;
QList< QPointer<QMdiSubWindow> > childWindows;
QList<int> indicesToActivatedChildren;
QPointer<QMdiSubWindow> active;
QPointer<QMdiSubWindow> aboutToBecomeActive;
QBrush background;
QMdiArea::WindowOrder activationOrder;
QMdiArea::AreaOptions options;
QMdiArea::ViewMode viewMode;
#ifndef QT_NO_TABBAR
bool documentMode;
#endif
#ifndef QT_NO_TABWIDGET
QTabWidget::TabShape tabShape;
QTabWidget::TabPosition tabPosition;
#endif
bool ignoreGeometryChange;
bool ignoreWindowStateChange;
bool isActivated;
bool isSubWindowsTiled;
bool showActiveWindowMaximized;
bool tileCalledFromResizeEvent;
bool updatesDisabledByUs;
bool inViewModeChange;
int indexToNextWindow;
int indexToPreviousWindow;
int indexToHighlighted;
int indexToLastActiveTab;
int resizeTimerId;
int tabToPreviousTimerId;
// Slots.
void _q_deactivateAllWindows(QMdiSubWindow *aboutToActivate = 0);
void _q_processWindowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState);
void _q_currentTabChanged(int index);
// Functions.
void appendChild(QMdiSubWindow *child);
void place(QMdi::Placer *placer, QMdiSubWindow *child);
void rearrange(QMdi::Rearranger *rearranger);
void arrangeMinimizedSubWindows();
void activateWindow(QMdiSubWindow *child);
void activateCurrentWindow();
void activateHighlightedWindow();
void emitWindowActivated(QMdiSubWindow *child);
void resetActiveWindow(QMdiSubWindow *child = 0);
void updateActiveWindow(int removedIndex, bool activeRemoved);
void updateScrollBars();
void internalRaise(QMdiSubWindow *child) const;
bool scrollBarsEnabled() const;
bool lastWindowAboutToBeDestroyed() const;
void setChildActivationEnabled(bool enable = true, bool onlyNextActivationEvent = false) const;
QRect resizeToMinimumTileSize(const QSize &minSubWindowSize, int subWindowCount);
void scrollBarPolicyChanged(Qt::Orientation, Qt::ScrollBarPolicy); // reimp
QMdiSubWindow *nextVisibleSubWindow(int increaseFactor, QMdiArea::WindowOrder,
int removed = -1, int fromIndex = -1) const;
void highlightNextSubWindow(int increaseFactor);
QList<QMdiSubWindow *> subWindowList(QMdiArea::WindowOrder, bool reversed = false) const;
void disconnectSubWindow(QObject *subWindow);
void setViewMode(QMdiArea::ViewMode mode);
#ifndef QT_NO_TABBAR
void updateTabBarGeometry();
void refreshTabBar();
#endif
inline void startResizeTimer()
{
Q_Q(QMdiArea);
if (resizeTimerId > 0)
q->killTimer(resizeTimerId);
resizeTimerId = q->startTimer(200);
}
inline void startTabToPreviousTimer()
{
Q_Q(QMdiArea);
if (tabToPreviousTimerId > 0)
q->killTimer(tabToPreviousTimerId);
tabToPreviousTimerId = q->startTimer(QApplication::keyboardInputInterval());
}
inline bool windowStaysOnTop(QMdiSubWindow *subWindow) const
{
if (!subWindow)
return false;
return subWindow->windowFlags() & Qt::WindowStaysOnTopHint;
}
inline bool isExplicitlyDeactivated(QMdiSubWindow *subWindow) const
{
if (!subWindow)
return true;
return subWindow->d_func()->isExplicitlyDeactivated;
}
inline void setActive(QMdiSubWindow *subWindow, bool active = true, bool changeFocus = true) const
{
if (subWindow)
subWindow->d_func()->setActive(active, changeFocus);
}
#ifndef QT_NO_RUBBERBAND
inline void showRubberBandFor(QMdiSubWindow *subWindow)
{
if (!subWindow || !rubberBand)
return;
rubberBand->setGeometry(subWindow->geometry());
rubberBand->raise();
rubberBand->show();
}
inline void hideRubberBand()
{
if (rubberBand && rubberBand->isVisible())
rubberBand->hide();
indexToHighlighted = -1;
}
#endif // QT_NO_RUBBERBAND
};
#endif // QT_NO_MDIAREA
QT_END_NAMESPACE
#endif // QMDIAREA_P_H
|