source: trunk/src/gui/widgets/qdockarealayout_p.h@ 147

Last change on this file since 147 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 10.1 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QDOCKAREALAYOUT_P_H
43#define QDOCKAREALAYOUT_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 "QtCore/qrect.h"
57#include "QtCore/qpair.h"
58#include "QtCore/qlist.h"
59#include "QtCore/qvector.h"
60#include "QtGui/qlayout.h"
61
62#ifndef QT_NO_DOCKWIDGET
63
64QT_BEGIN_NAMESPACE
65
66class QLayoutItem;
67class QWidget;
68class QLayoutItem;
69class QDockAreaLayoutInfo;
70class QPlaceHolderItem;
71class QDockWidget;
72class QMainWindow;
73class QWidgetAnimator;
74class QMainWindowLayout;
75struct QLayoutStruct;
76class QTabBar;
77
78// The classes in this file represent the tree structure that represents all the docks
79// Also see the wiki internal documentation
80// At the root of the tree is: QDockAreaLayout, which handles all 4 sides, so there is only one.
81// For each side it has one QDockAreaLayoutInfo child. (See QDockAreaLayout::docks.)
82// The QDockAreaLayoutInfo have QDockAreaLayoutItems as children (See QDockAreaLayoutInfo::item_list),
83// which then has one QDockAreaLayoutInfo as a child. (QDockAreaLayoutItem::subInfo) or
84// a widgetItem if this is a node of the tree (QDockAreaLayoutItem::widgetItem)
85//
86// A path indetifies uniquely one object in this tree, the first number beeing the side and all the following
87// indexes into the QDockAreaLayoutInfo::item_list.
88
89struct QDockAreaLayoutItem
90{
91 enum ItemFlags { NoFlags = 0, GapItem = 1, KeepSize = 2 };
92
93 QDockAreaLayoutItem(QLayoutItem *_widgetItem = 0);
94 QDockAreaLayoutItem(QDockAreaLayoutInfo *_subinfo);
95 QDockAreaLayoutItem(QPlaceHolderItem *_placeHolderItem);
96 QDockAreaLayoutItem(const QDockAreaLayoutItem &other);
97 ~QDockAreaLayoutItem();
98
99 QDockAreaLayoutItem &operator = (const QDockAreaLayoutItem &other);
100
101 bool skip() const;
102 QSize minimumSize() const;
103 QSize maximumSize() const;
104 QSize sizeHint() const;
105 bool expansive(Qt::Orientation o) const;
106
107 QLayoutItem *widgetItem;
108 QDockAreaLayoutInfo *subinfo;
109 QPlaceHolderItem *placeHolderItem;
110 int pos;
111 int size;
112 uint flags;
113};
114
115class Q_AUTOTEST_EXPORT QPlaceHolderItem
116{
117public:
118 QPlaceHolderItem() : hidden(false), window(false) {}
119 QPlaceHolderItem(QWidget *w);
120
121 QString objectName;
122 bool hidden, window;
123 QRect topLevelRect;
124};
125
126class Q_AUTOTEST_EXPORT QDockAreaLayoutInfo
127{
128public:
129 QDockAreaLayoutInfo();
130 QDockAreaLayoutInfo(int _sep, QInternal::DockPosition _dockPos, Qt::Orientation _o,
131 int tbhape, QMainWindow *window);
132
133 QSize minimumSize() const;
134 QSize maximumSize() const;
135 QSize sizeHint() const;
136 QSize size() const;
137
138 bool insertGap(QList<int> path, QLayoutItem *dockWidgetItem);
139 QLayoutItem *plug(QList<int> path);
140 QLayoutItem *unplug(QList<int> path);
141 enum TabMode { NoTabs, AllowTabs, ForceTabs };
142 QList<int> gapIndex(const QPoint &pos, bool nestingEnabled,
143 TabMode tabMode) const;
144 void remove(QList<int> path);
145 void unnest(int index);
146 void split(int index, Qt::Orientation orientation, QLayoutItem *dockWidgetItem);
147 void tab(int index, QLayoutItem *dockWidgetItem);
148 QDockAreaLayoutItem &item(QList<int> path);
149 QDockAreaLayoutInfo *info(QList<int> path);
150 QDockAreaLayoutInfo *info(QWidget *widget);
151
152 enum { // sentinel values used to validate state data
153 SequenceMarker = 0xfc,
154 TabMarker = 0xfa,
155 WidgetMarker = 0xfb
156 };
157 void saveState(QDataStream &stream) const;
158 bool restoreState(QDataStream &stream, QList<QDockWidget*> &widgets, bool testing);
159
160 void fitItems();
161 bool expansive(Qt::Orientation o) const;
162 int changeSize(int index, int size, bool below);
163 QRect itemRect(int index) const;
164 QRect itemRect(QList<int> path) const;
165 QRect separatorRect(int index) const;
166 QRect separatorRect(QList<int> path) const;
167
168 void clear();
169 bool isEmpty() const;
170 QList<int> findSeparator(const QPoint &pos) const;
171 int next(int idx) const;
172 int prev(int idx) const;
173
174 QList<int> indexOf(QWidget *widget) const;
175 QList<int> indexOfPlaceHolder(const QString &objectName) const;
176
177 void apply(bool animate);
178
179 void paintSeparators(QPainter *p, QWidget *widget, const QRegion &clip,
180 const QPoint &mouse) const;
181 QRegion separatorRegion() const;
182 int separatorMove(int index, int delta, QVector<QLayoutStruct> *cache);
183
184 QLayoutItem *itemAt(int *x, int index) const;
185 QLayoutItem *takeAt(int *x, int index);
186 void deleteAllLayoutItems();
187
188 QMainWindowLayout *mainWindowLayout() const;
189
190 int sep;
191 QVector<QWidget*> separatorWidgets;
192 QInternal::DockPosition dockPos;
193 Qt::Orientation o;
194 QRect rect;
195 QMainWindow *mainWindow;
196 QList<QDockAreaLayoutItem> item_list;
197
198 void updateSeparatorWidgets() const;
199 QSet<QWidget*> usedSeparatorWidgets() const;
200
201#ifndef QT_NO_TABBAR
202 quintptr currentTabId() const;
203 void setCurrentTab(QWidget *widget);
204 void setCurrentTabId(quintptr id);
205 QRect tabContentRect() const;
206 bool tabbed;
207 QTabBar *tabBar;
208 QSize tabBarMin, tabBarHint;
209 int tabBarShape;
210 bool tabBarVisible;
211
212 void updateTabBar() const;
213 void setTabBarShape(int shape);
214 QSize tabBarMinimumSize() const;
215 QSize tabBarSizeHint() const;
216
217 QSet<QTabBar*> usedTabBars() const;
218#endif // QT_NO_TABBAR
219};
220
221class Q_AUTOTEST_EXPORT QDockAreaLayout
222{
223public:
224 enum { EmptyDropAreaSize = 80 }; // when a dock area is empty, how "wide" is it?
225
226 Qt::DockWidgetArea corners[4]; // use a Qt::Corner for indexing
227 QRect rect;
228 QLayoutItem *centralWidgetItem;
229 QMainWindow *mainWindow;
230 QRect centralWidgetRect;
231 QDockAreaLayout(QMainWindow *win);
232 QDockAreaLayoutInfo docks[4];
233 int sep; // separator extent
234 QVector<QWidget*> separatorWidgets;
235
236 bool isValid() const;
237
238 enum { DockWidgetStateMarker = 0xfd };
239 void saveState(QDataStream &stream) const;
240 bool restoreState(QDataStream &stream, const QList<QDockWidget*> &widgets, bool testing = false);
241
242 QList<int> indexOfPlaceHolder(const QString &objectName) const;
243 QList<int> indexOf(QWidget *dockWidget) const;
244 QList<int> gapIndex(const QPoint &pos) const;
245 QList<int> findSeparator(const QPoint &pos) const;
246
247 QDockAreaLayoutItem &item(QList<int> path);
248 QDockAreaLayoutInfo *info(QList<int> path);
249 const QDockAreaLayoutInfo *info(QList<int> path) const;
250 QDockAreaLayoutInfo *info(QWidget *widget);
251 QRect itemRect(QList<int> path) const;
252 QRect separatorRect(int index) const;
253 QRect separatorRect(QList<int> path) const;
254
255 bool insertGap(QList<int> path, QLayoutItem *dockWidgetItem);
256 QLayoutItem *plug(QList<int> path);
257 QLayoutItem *unplug(QList<int> path);
258 void remove(QList<int> path);
259
260 void fitLayout();
261
262 void clear();
263
264 QSize sizeHint() const;
265 QSize minimumSize() const;
266
267 void addDockWidget(QInternal::DockPosition pos, QDockWidget *dockWidget, Qt::Orientation orientation);
268 bool restoreDockWidget(QDockWidget *dockWidget);
269 void splitDockWidget(QDockWidget *after, QDockWidget *dockWidget,
270 Qt::Orientation orientation);
271 void tabifyDockWidget(QDockWidget *first, QDockWidget *second);
272
273 void apply(bool animate);
274
275 void paintSeparators(QPainter *p, QWidget *widget, const QRegion &clip,
276 const QPoint &mouse) const;
277 QRegion separatorRegion() const;
278 int separatorMove(QList<int> separator, const QPoint &origin, const QPoint &dest,
279 QVector<QLayoutStruct> *cache);
280 void updateSeparatorWidgets() const;
281
282 QLayoutItem *itemAt(int *x, int index) const;
283 QLayoutItem *takeAt(int *x, int index);
284 void deleteAllLayoutItems();
285
286 void getGrid(QVector<QLayoutStruct> *ver_struct_list,
287 QVector<QLayoutStruct> *hor_struct_list);
288 void setGrid(QVector<QLayoutStruct> *ver_struct_list,
289 QVector<QLayoutStruct> *hor_struct_list);
290
291 QRect gapRect(QList<int> path) const;
292
293 void keepSize(QDockWidget *w);
294
295 QSet<QTabBar*> usedTabBars() const;
296 QSet<QWidget*> usedSeparatorWidgets() const;
297};
298
299QT_END_NAMESPACE
300
301#endif // QT_NO_QDOCKWIDGET
302
303#endif // QDOCKAREALAYOUT_P_H
Note: See TracBrowser for help on using the repository browser.