1
/****************************************************************************
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the QtGui module of the Qt Toolkit.
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 Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
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 as published by the Free Software
20
** Foundation and appearing in the file LICENSE.LGPL included in the
21
** packaging of this file. Please review the following information to
22
** ensure the GNU Lesser General Public License version 2.1 requirements
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25
** In addition, as a special exception, Digia gives you certain additional
26
** rights. These rights are described in the Digia Qt LGPL Exception
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29
** GNU General Public License Usage
30
** Alternatively, this file may be used under the terms of the GNU
31
** General Public License version 3.0 as published by the Free Software
32
** Foundation and appearing in the file LICENSE.GPL included in the
33
** packaging of this file. Please review the following information to
34
** ensure the GNU General Public License version 3.0 requirements will be
35
** met: http://www.gnu.org/copyleft/gpl.html.
40
****************************************************************************/
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.
57
#include "qmdisubwindow.h"
64
#include <QtWidgets/qapplication.h>
65
#include <private/qmdisubwindow_p.h>
66
#include <private/qabstractscrollarea_p.h>
80
// Rearranges widgets relative to domain.
81
virtual void rearrange(QList<QWidget *> &widgets, const QRect &domain) const = 0;
82
virtual Type type() const = 0;
83
virtual ~Rearranger() {}
86
class RegularTiler : public Rearranger
88
// Rearranges widgets according to a regular tiling pattern
89
// covering the entire domain.
90
// Both positions and sizes may change.
91
void rearrange(QList<QWidget *> &widgets, const QRect &domain) const;
92
inline Type type() const { return Rearranger::RegularTiler; }
95
class SimpleCascader : public Rearranger
97
// Rearranges widgets according to a simple, regular cascading pattern.
98
// Widgets are resized to minimumSize.
99
// Both positions and sizes may change.
100
void rearrange(QList<QWidget *> &widgets, const QRect &domain) const;
101
inline Type type() const { return Rearranger::SimpleCascader; }
104
class IconTiler : public Rearranger
106
// Rearranges icons (assumed to be the same size) according to a regular
107
// tiling pattern filling up the domain from the bottom.
108
// Only positions may change.
109
void rearrange(QList<QWidget *> &widgets, const QRect &domain) const;
110
inline Type type() const { return Rearranger::IconTiler; }
116
// Places the rectangle defined by 'size' relative to 'rects' and 'domain'.
117
// Returns the position of the resulting rectangle.
118
virtual QPoint place(
119
const QSize &size, const QList<QRect> &rects, const QRect &domain) const = 0;
123
class MinOverlapPlacer : public Placer
125
QPoint place(const QSize &size, const QList<QRect> &rects, const QRect &domain) const;
126
static int accumulatedOverlap(const QRect &source, const QList<QRect> &rects);
127
static QRect findMinOverlapRect(const QList<QRect> &source, const QList<QRect> &rects);
128
static void getCandidatePlacements(
129
const QSize &size, const QList<QRect> &rects, const QRect &domain,
130
QList<QRect> &candidates);
131
static QPoint findBestPlacement(
132
const QRect &domain, const QList<QRect> &rects, QList<QRect> &source);
133
static void findNonInsiders(
134
const QRect &domain, QList<QRect> &source, QList<QRect> &result);
135
static void findMaxOverlappers(
136
const QRect &domain, const QList<QRect> &source, QList<QRect> &result);
140
class QMdiAreaTabBar;
141
class QMdiAreaPrivate : public QAbstractScrollAreaPrivate
143
Q_DECLARE_PUBLIC(QMdiArea)
148
QMdi::Rearranger *cascader;
149
QMdi::Rearranger *regularTiler;
150
QMdi::Rearranger *iconTiler;
151
QMdi::Placer *placer;
152
#ifndef QT_NO_RUBBERBAND
153
QRubberBand *rubberBand;
155
QMdiAreaTabBar *tabBar;
156
QList<QMdi::Rearranger *> pendingRearrangements;
157
QList< QPointer<QMdiSubWindow> > pendingPlacements;
158
QList< QPointer<QMdiSubWindow> > childWindows;
159
QList<int> indicesToActivatedChildren;
160
QPointer<QMdiSubWindow> active;
161
QPointer<QMdiSubWindow> aboutToBecomeActive;
163
QMdiArea::WindowOrder activationOrder;
164
QMdiArea::AreaOptions options;
165
QMdiArea::ViewMode viewMode;
171
#ifndef QT_NO_TABWIDGET
172
QTabWidget::TabShape tabShape;
173
QTabWidget::TabPosition tabPosition;
175
bool ignoreGeometryChange;
176
bool ignoreWindowStateChange;
178
bool isSubWindowsTiled;
179
bool showActiveWindowMaximized;
180
bool tileCalledFromResizeEvent;
181
bool updatesDisabledByUs;
182
bool inViewModeChange;
183
int indexToNextWindow;
184
int indexToPreviousWindow;
185
int indexToHighlighted;
186
int indexToLastActiveTab;
188
int tabToPreviousTimerId;
191
void _q_deactivateAllWindows(QMdiSubWindow *aboutToActivate = 0);
192
void _q_processWindowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState);
193
void _q_currentTabChanged(int index);
194
void _q_closeTab(int index);
195
void _q_moveTab(int from, int to);
198
void appendChild(QMdiSubWindow *child);
199
void place(QMdi::Placer *placer, QMdiSubWindow *child);
200
void rearrange(QMdi::Rearranger *rearranger);
201
void arrangeMinimizedSubWindows();
202
void activateWindow(QMdiSubWindow *child);
203
void activateCurrentWindow();
204
void activateHighlightedWindow();
205
void emitWindowActivated(QMdiSubWindow *child);
206
void resetActiveWindow(QMdiSubWindow *child = 0);
207
void updateActiveWindow(int removedIndex, bool activeRemoved);
208
void updateScrollBars();
209
void internalRaise(QMdiSubWindow *child) const;
210
bool scrollBarsEnabled() const;
211
bool lastWindowAboutToBeDestroyed() const;
212
void setChildActivationEnabled(bool enable = true, bool onlyNextActivationEvent = false) const;
213
QRect resizeToMinimumTileSize(const QSize &minSubWindowSize, int subWindowCount);
214
void scrollBarPolicyChanged(Qt::Orientation, Qt::ScrollBarPolicy); // reimp
215
QMdiSubWindow *nextVisibleSubWindow(int increaseFactor, QMdiArea::WindowOrder,
216
int removed = -1, int fromIndex = -1) const;
217
void highlightNextSubWindow(int increaseFactor);
218
QList<QMdiSubWindow *> subWindowList(QMdiArea::WindowOrder, bool reversed = false) const;
219
void disconnectSubWindow(QObject *subWindow);
220
void setViewMode(QMdiArea::ViewMode mode);
222
void updateTabBarGeometry();
223
void refreshTabBar();
226
inline void startResizeTimer()
229
if (resizeTimerId > 0)
230
q->killTimer(resizeTimerId);
231
resizeTimerId = q->startTimer(200);
234
inline void startTabToPreviousTimer()
237
if (tabToPreviousTimerId > 0)
238
q->killTimer(tabToPreviousTimerId);
239
tabToPreviousTimerId = q->startTimer(QApplication::keyboardInputInterval());
242
inline bool windowStaysOnTop(QMdiSubWindow *subWindow) const
246
return subWindow->windowFlags() & Qt::WindowStaysOnTopHint;
249
inline bool isExplicitlyDeactivated(QMdiSubWindow *subWindow) const
253
return subWindow->d_func()->isExplicitlyDeactivated;
256
inline void setActive(QMdiSubWindow *subWindow, bool active = true, bool changeFocus = true) const
259
subWindow->d_func()->setActive(active, changeFocus);
262
#ifndef QT_NO_RUBBERBAND
263
inline void showRubberBandFor(QMdiSubWindow *subWindow)
265
if (!subWindow || !rubberBand)
267
rubberBand->setGeometry(subWindow->geometry());
272
inline void hideRubberBand()
274
if (rubberBand && rubberBand->isVisible())
276
indexToHighlighted = -1;
278
#endif // QT_NO_RUBBERBAND
281
#endif // QT_NO_MDIAREA
285
#endif // QMDIAREA_P_H