author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Wed, 21 Apr 2010 20:15:53 +0300 | |
branch | RCL_3 |
changeset 14 | c0432d11811c |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtGui module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#ifndef QMDIAREA_P_H |
|
43 |
#define QMDIAREA_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 |
#include "qmdiarea.h" |
|
57 |
#include "qmdisubwindow.h" |
|
58 |
||
59 |
#ifndef QT_NO_MDIAREA |
|
60 |
||
61 |
#include <QList> |
|
62 |
#include <QRect> |
|
63 |
#include <QPoint> |
|
64 |
#include <QtGui/qapplication.h> |
|
65 |
#include <private/qmdisubwindow_p.h> |
|
66 |
#include <private/qabstractscrollarea_p.h> |
|
67 |
||
68 |
QT_BEGIN_NAMESPACE |
|
69 |
||
70 |
namespace QMdi { |
|
71 |
class Rearranger |
|
72 |
{ |
|
73 |
public: |
|
74 |
enum Type { |
|
75 |
RegularTiler, |
|
76 |
SimpleCascader, |
|
77 |
IconTiler |
|
78 |
}; |
|
79 |
||
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() {} |
|
84 |
}; |
|
85 |
||
86 |
class RegularTiler : public Rearranger |
|
87 |
{ |
|
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; } |
|
93 |
}; |
|
94 |
||
95 |
class SimpleCascader : public Rearranger |
|
96 |
{ |
|
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; } |
|
102 |
}; |
|
103 |
||
104 |
class IconTiler : public Rearranger |
|
105 |
{ |
|
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; } |
|
111 |
}; |
|
112 |
||
113 |
class Placer |
|
114 |
{ |
|
115 |
public: |
|
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; |
|
120 |
virtual ~Placer() {} |
|
121 |
}; |
|
122 |
||
123 |
class MinOverlapPlacer : public Placer |
|
124 |
{ |
|
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); |
|
137 |
}; |
|
138 |
} // namespace QMdi |
|
139 |
||
140 |
class QMdiAreaTabBar; |
|
141 |
class QMdiAreaPrivate : public QAbstractScrollAreaPrivate |
|
142 |
{ |
|
143 |
Q_DECLARE_PUBLIC(QMdiArea) |
|
144 |
public: |
|
145 |
QMdiAreaPrivate(); |
|
146 |
||
147 |
// Variables. |
|
148 |
QMdi::Rearranger *cascader; |
|
149 |
QMdi::Rearranger *regularTiler; |
|
150 |
QMdi::Rearranger *iconTiler; |
|
151 |
QMdi::Placer *placer; |
|
152 |
#ifndef QT_NO_RUBBERBAND |
|
153 |
QRubberBand *rubberBand; |
|
154 |
#endif |
|
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; |
|
162 |
QBrush background; |
|
163 |
QMdiArea::WindowOrder activationOrder; |
|
164 |
QMdiArea::AreaOptions options; |
|
165 |
QMdiArea::ViewMode viewMode; |
|
166 |
#ifndef QT_NO_TABBAR |
|
167 |
bool documentMode; |
|
168 |
#endif |
|
169 |
#ifndef QT_NO_TABWIDGET |
|
170 |
QTabWidget::TabShape tabShape; |
|
171 |
QTabWidget::TabPosition tabPosition; |
|
172 |
#endif |
|
173 |
bool ignoreGeometryChange; |
|
174 |
bool ignoreWindowStateChange; |
|
175 |
bool isActivated; |
|
176 |
bool isSubWindowsTiled; |
|
177 |
bool showActiveWindowMaximized; |
|
178 |
bool tileCalledFromResizeEvent; |
|
179 |
bool updatesDisabledByUs; |
|
180 |
bool inViewModeChange; |
|
181 |
int indexToNextWindow; |
|
182 |
int indexToPreviousWindow; |
|
183 |
int indexToHighlighted; |
|
184 |
int indexToLastActiveTab; |
|
185 |
int resizeTimerId; |
|
186 |
int tabToPreviousTimerId; |
|
187 |
||
188 |
// Slots. |
|
189 |
void _q_deactivateAllWindows(QMdiSubWindow *aboutToActivate = 0); |
|
190 |
void _q_processWindowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState); |
|
191 |
void _q_currentTabChanged(int index); |
|
192 |
||
193 |
// Functions. |
|
194 |
void appendChild(QMdiSubWindow *child); |
|
195 |
void place(QMdi::Placer *placer, QMdiSubWindow *child); |
|
196 |
void rearrange(QMdi::Rearranger *rearranger); |
|
197 |
void arrangeMinimizedSubWindows(); |
|
198 |
void activateWindow(QMdiSubWindow *child); |
|
199 |
void activateCurrentWindow(); |
|
200 |
void activateHighlightedWindow(); |
|
201 |
void emitWindowActivated(QMdiSubWindow *child); |
|
202 |
void resetActiveWindow(QMdiSubWindow *child = 0); |
|
203 |
void updateActiveWindow(int removedIndex, bool activeRemoved); |
|
204 |
void updateScrollBars(); |
|
205 |
void internalRaise(QMdiSubWindow *child) const; |
|
206 |
bool scrollBarsEnabled() const; |
|
207 |
bool lastWindowAboutToBeDestroyed() const; |
|
208 |
void setChildActivationEnabled(bool enable = true, bool onlyNextActivationEvent = false) const; |
|
209 |
QRect resizeToMinimumTileSize(const QSize &minSubWindowSize, int subWindowCount); |
|
210 |
void scrollBarPolicyChanged(Qt::Orientation, Qt::ScrollBarPolicy); // reimp |
|
211 |
QMdiSubWindow *nextVisibleSubWindow(int increaseFactor, QMdiArea::WindowOrder, |
|
212 |
int removed = -1, int fromIndex = -1) const; |
|
213 |
void highlightNextSubWindow(int increaseFactor); |
|
214 |
QList<QMdiSubWindow *> subWindowList(QMdiArea::WindowOrder, bool reversed = false) const; |
|
215 |
void disconnectSubWindow(QObject *subWindow); |
|
216 |
void setViewMode(QMdiArea::ViewMode mode); |
|
217 |
#ifndef QT_NO_TABBAR |
|
218 |
void updateTabBarGeometry(); |
|
219 |
void refreshTabBar(); |
|
220 |
#endif |
|
221 |
||
222 |
inline void startResizeTimer() |
|
223 |
{ |
|
224 |
Q_Q(QMdiArea); |
|
225 |
if (resizeTimerId > 0) |
|
226 |
q->killTimer(resizeTimerId); |
|
227 |
resizeTimerId = q->startTimer(200); |
|
228 |
} |
|
229 |
||
230 |
inline void startTabToPreviousTimer() |
|
231 |
{ |
|
232 |
Q_Q(QMdiArea); |
|
233 |
if (tabToPreviousTimerId > 0) |
|
234 |
q->killTimer(tabToPreviousTimerId); |
|
235 |
tabToPreviousTimerId = q->startTimer(QApplication::keyboardInputInterval()); |
|
236 |
} |
|
237 |
||
238 |
inline bool windowStaysOnTop(QMdiSubWindow *subWindow) const |
|
239 |
{ |
|
240 |
if (!subWindow) |
|
241 |
return false; |
|
242 |
return subWindow->windowFlags() & Qt::WindowStaysOnTopHint; |
|
243 |
} |
|
244 |
||
245 |
inline bool isExplicitlyDeactivated(QMdiSubWindow *subWindow) const |
|
246 |
{ |
|
247 |
if (!subWindow) |
|
248 |
return true; |
|
249 |
return subWindow->d_func()->isExplicitlyDeactivated; |
|
250 |
} |
|
251 |
||
252 |
inline void setActive(QMdiSubWindow *subWindow, bool active = true, bool changeFocus = true) const |
|
253 |
{ |
|
254 |
if (subWindow) |
|
255 |
subWindow->d_func()->setActive(active, changeFocus); |
|
256 |
} |
|
257 |
||
258 |
#ifndef QT_NO_RUBBERBAND |
|
259 |
inline void showRubberBandFor(QMdiSubWindow *subWindow) |
|
260 |
{ |
|
261 |
if (!subWindow || !rubberBand) |
|
262 |
return; |
|
263 |
rubberBand->setGeometry(subWindow->geometry()); |
|
264 |
rubberBand->raise(); |
|
265 |
rubberBand->show(); |
|
266 |
} |
|
267 |
||
268 |
inline void hideRubberBand() |
|
269 |
{ |
|
270 |
if (rubberBand && rubberBand->isVisible()) |
|
271 |
rubberBand->hide(); |
|
272 |
indexToHighlighted = -1; |
|
273 |
} |
|
274 |
#endif // QT_NO_RUBBERBAND |
|
275 |
}; |
|
276 |
||
277 |
#endif // QT_NO_MDIAREA |
|
278 |
||
279 |
QT_END_NAMESPACE |
|
280 |
||
281 |
#endif // QMDIAREA_P_H |