1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the Qt3Support module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
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 | ** 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 have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef Q3DOCKAREA_H
|
---|
43 | #define Q3DOCKAREA_H
|
---|
44 |
|
---|
45 | #include <QtGui/qwidget.h>
|
---|
46 | #include <QtCore/qlist.h>
|
---|
47 | #include <Qt3Support/q3dockwindow.h>
|
---|
48 | #include <QtGui/qlayout.h>
|
---|
49 | #include <QtCore/qpointer.h>
|
---|
50 |
|
---|
51 | QT_BEGIN_HEADER
|
---|
52 |
|
---|
53 | QT_BEGIN_NAMESPACE
|
---|
54 |
|
---|
55 | QT_MODULE(Qt3SupportLight)
|
---|
56 |
|
---|
57 | #ifndef QT_NO_MAINWINDOW
|
---|
58 |
|
---|
59 | class QBoxLayout;
|
---|
60 | class Q3DockAreaLayout;
|
---|
61 | class QMouseEvent;
|
---|
62 | class Q3DockWindowResizeHandle;
|
---|
63 | class Q3DockAreaPrivate;
|
---|
64 | class QTextStream;
|
---|
65 |
|
---|
66 | class Q_COMPAT_EXPORT Q3DockAreaLayout : public QLayout
|
---|
67 | {
|
---|
68 | Q_OBJECT
|
---|
69 | friend class Q3DockArea;
|
---|
70 |
|
---|
71 | public:
|
---|
72 | Q3DockAreaLayout(QWidget* parent, Qt::Orientation o, QList<Q3DockWindow *> *wl, int space = -1, int margin = -1, const char *name = 0)
|
---|
73 | : QLayout(parent), orient(o), dirty(true), dockWindows(wl), parentWidget(parent)
|
---|
74 | {
|
---|
75 | if (space != -1)
|
---|
76 | setSpacing(space);
|
---|
77 | if (margin != -1)
|
---|
78 | setMargin(margin);
|
---|
79 | setObjectName(QString::fromAscii(name));
|
---|
80 | init();
|
---|
81 | }
|
---|
82 | ~Q3DockAreaLayout() {}
|
---|
83 |
|
---|
84 | void addItem(QLayoutItem *) {}
|
---|
85 | bool hasHeightForWidth() const;
|
---|
86 | int heightForWidth(int) const;
|
---|
87 | int widthForHeight(int) const;
|
---|
88 | QSize sizeHint() const;
|
---|
89 | QSize minimumSize() const;
|
---|
90 | QLayoutItem *itemAt(int) const;
|
---|
91 | QLayoutItem *takeAt(int);
|
---|
92 | int count() const;
|
---|
93 | Qt::Orientations expandingDirections() const { return Qt::Orientations(0); }
|
---|
94 | void invalidate();
|
---|
95 | Qt::Orientation orientation() const { return orient; }
|
---|
96 | QList<QRect> lineList() const { return lines; }
|
---|
97 | QList<Q3DockWindow *> lineStarts() const { return ls; }
|
---|
98 |
|
---|
99 | protected:
|
---|
100 | void setGeometry(const QRect&);
|
---|
101 |
|
---|
102 | private:
|
---|
103 | Q_DISABLE_COPY(Q3DockAreaLayout)
|
---|
104 |
|
---|
105 | void init();
|
---|
106 | int layoutItems(const QRect&, bool testonly = false);
|
---|
107 | Qt::Orientation orient;
|
---|
108 | bool dirty;
|
---|
109 | int cached_width, cached_height;
|
---|
110 | int cached_hfw, cached_wfh;
|
---|
111 | QList<Q3DockWindow *> *dockWindows;
|
---|
112 | QWidget *parentWidget;
|
---|
113 | QList<QRect> lines;
|
---|
114 | QList<Q3DockWindow *> ls;
|
---|
115 | };
|
---|
116 |
|
---|
117 | class Q_COMPAT_EXPORT Q3DockArea : public QWidget
|
---|
118 | {
|
---|
119 | Q_OBJECT
|
---|
120 | Q_ENUMS(HandlePosition)
|
---|
121 | Q_PROPERTY(Qt::Orientation orientation READ orientation)
|
---|
122 | Q_PROPERTY(int count READ count)
|
---|
123 | Q_PROPERTY(bool empty READ isEmpty)
|
---|
124 | Q_PROPERTY(HandlePosition handlePosition READ handlePosition)
|
---|
125 |
|
---|
126 | friend class Q3DockWindow;
|
---|
127 | friend class Q3DockWindowResizeHandle;
|
---|
128 | friend class Q3DockAreaLayout;
|
---|
129 |
|
---|
130 | public:
|
---|
131 | enum HandlePosition { Normal, Reverse };
|
---|
132 |
|
---|
133 | Q3DockArea(Qt::Orientation o, HandlePosition h = Normal, QWidget* parent=0, const char* name=0);
|
---|
134 | ~Q3DockArea();
|
---|
135 |
|
---|
136 | void moveDockWindow(Q3DockWindow *w, const QPoint &globalPos, const QRect &rect, bool swap);
|
---|
137 | void removeDockWindow(Q3DockWindow *w, bool makeFloating, bool swap, bool fixNewLines = true);
|
---|
138 | void moveDockWindow(Q3DockWindow *w, int index = -1);
|
---|
139 | bool hasDockWindow(Q3DockWindow *w, int *index = 0);
|
---|
140 |
|
---|
141 | void invalidNextOffset(Q3DockWindow *dw);
|
---|
142 |
|
---|
143 | Qt::Orientation orientation() const { return orient; }
|
---|
144 | HandlePosition handlePosition() const { return hPos; }
|
---|
145 |
|
---|
146 | bool eventFilter(QObject *, QEvent *);
|
---|
147 | bool isEmpty() const;
|
---|
148 | int count() const;
|
---|
149 | QList<Q3DockWindow *> dockWindowList() const;
|
---|
150 |
|
---|
151 | bool isDockWindowAccepted(Q3DockWindow *dw);
|
---|
152 | void setAcceptDockWindow(Q3DockWindow *dw, bool accept);
|
---|
153 |
|
---|
154 | public Q_SLOTS:
|
---|
155 | void lineUp(bool keepNewLines);
|
---|
156 |
|
---|
157 | private:
|
---|
158 | struct DockWindowData
|
---|
159 | {
|
---|
160 | int index;
|
---|
161 | int offset;
|
---|
162 | int line;
|
---|
163 | QSize fixedExtent;
|
---|
164 | QPointer<Q3DockArea> area;
|
---|
165 | };
|
---|
166 |
|
---|
167 | int findDockWindow(Q3DockWindow *w);
|
---|
168 | int lineOf(int index);
|
---|
169 | DockWindowData *dockWindowData(Q3DockWindow *w);
|
---|
170 | void dockWindow(Q3DockWindow *dockWindow, DockWindowData *data);
|
---|
171 | void updateLayout();
|
---|
172 | void invalidateFixedSizes();
|
---|
173 | int maxSpace(int hint, Q3DockWindow *dw);
|
---|
174 | void setFixedExtent(int d, Q3DockWindow *dw);
|
---|
175 | bool isLastDockWindow(Q3DockWindow *dw);
|
---|
176 |
|
---|
177 | private:
|
---|
178 | Q_DISABLE_COPY(Q3DockArea)
|
---|
179 |
|
---|
180 | Qt::Orientation orient;
|
---|
181 | QList<Q3DockWindow *> dockWindows;
|
---|
182 | Q3DockAreaLayout *layout;
|
---|
183 | HandlePosition hPos;
|
---|
184 | QList<Q3DockWindow *> forbiddenWidgets;
|
---|
185 | Q3DockAreaPrivate *d;
|
---|
186 | };
|
---|
187 |
|
---|
188 | #ifndef QT_NO_TEXTSTREAM
|
---|
189 | Q_COMPAT_EXPORT QTextStream &operator<<(QTextStream &, const Q3DockArea &);
|
---|
190 | Q_COMPAT_EXPORT QTextStream &operator>>(QTextStream &, Q3DockArea &);
|
---|
191 | #endif
|
---|
192 |
|
---|
193 | #endif // QT_NO_MAINWINDOW
|
---|
194 |
|
---|
195 | QT_END_NAMESPACE
|
---|
196 |
|
---|
197 | QT_END_HEADER
|
---|
198 |
|
---|
199 | #endif // Q3DOCKAREA_H
|
---|