|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
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 QLAYOUT_H |
|
43 #define QLAYOUT_H |
|
44 |
|
45 #include <QtCore/qobject.h> |
|
46 #include <QtGui/qlayoutitem.h> |
|
47 #include <QtGui/qsizepolicy.h> |
|
48 #include <QtCore/qrect.h> |
|
49 #include <QtCore/qmargins.h> |
|
50 |
|
51 #include <limits.h> |
|
52 |
|
53 QT_BEGIN_HEADER |
|
54 |
|
55 QT_BEGIN_NAMESPACE |
|
56 |
|
57 QT_MODULE(Gui) |
|
58 |
|
59 class QLayout; |
|
60 class QSize; |
|
61 |
|
62 #ifdef QT3_SUPPORT |
|
63 class Q_GUI_EXPORT QLayoutIterator |
|
64 { |
|
65 public: |
|
66 inline QT3_SUPPORT_CONSTRUCTOR QLayoutIterator(QLayout *i) : layout(i), index(0) {} |
|
67 inline QLayoutIterator(const QLayoutIterator &i) |
|
68 : layout(i.layout), index(i.index) {} |
|
69 inline QLayoutIterator &operator=(const QLayoutIterator &i) { |
|
70 layout = i.layout; |
|
71 index = i.index; |
|
72 return *this; |
|
73 } |
|
74 inline QT3_SUPPORT QLayoutItem *operator++(); |
|
75 inline QT3_SUPPORT QLayoutItem *current(); |
|
76 inline QT3_SUPPORT QLayoutItem *takeCurrent(); |
|
77 inline QT3_SUPPORT void deleteCurrent(); |
|
78 |
|
79 private: |
|
80 // hack to avoid deprecated warning |
|
81 friend class QLayout; |
|
82 inline QLayoutIterator(QLayout *i, bool) : layout(i), index(0) {} |
|
83 QLayout *layout; |
|
84 int index; |
|
85 }; |
|
86 #endif |
|
87 |
|
88 class QLayoutPrivate; |
|
89 |
|
90 class Q_GUI_EXPORT QLayout : public QObject, public QLayoutItem |
|
91 { |
|
92 Q_OBJECT |
|
93 Q_DECLARE_PRIVATE(QLayout) |
|
94 |
|
95 Q_ENUMS(SizeConstraint) |
|
96 Q_PROPERTY(int margin READ margin WRITE setMargin) |
|
97 Q_PROPERTY(int spacing READ spacing WRITE setSpacing) |
|
98 Q_PROPERTY(SizeConstraint sizeConstraint READ sizeConstraint WRITE setSizeConstraint) |
|
99 public: |
|
100 enum SizeConstraint { |
|
101 SetDefaultConstraint, |
|
102 SetNoConstraint, |
|
103 SetMinimumSize, |
|
104 SetFixedSize, |
|
105 SetMaximumSize, |
|
106 SetMinAndMaxSize |
|
107 #if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN) |
|
108 , Auto = SetDefaultConstraint, |
|
109 FreeResize = SetNoConstraint, |
|
110 Minimum = SetMinimumSize, |
|
111 Fixed = SetFixedSize |
|
112 #endif |
|
113 }; |
|
114 |
|
115 QLayout(QWidget *parent); |
|
116 QLayout(); |
|
117 ~QLayout(); |
|
118 |
|
119 int margin() const; |
|
120 int spacing() const; |
|
121 |
|
122 void setMargin(int); |
|
123 void setSpacing(int); |
|
124 |
|
125 void setContentsMargins(int left, int top, int right, int bottom); |
|
126 void setContentsMargins(const QMargins &margins); |
|
127 void getContentsMargins(int *left, int *top, int *right, int *bottom) const; |
|
128 QMargins contentsMargins() const; |
|
129 QRect contentsRect() const; |
|
130 |
|
131 bool setAlignment(QWidget *w, Qt::Alignment alignment); |
|
132 bool setAlignment(QLayout *l, Qt::Alignment alignment); |
|
133 #ifdef Q_NO_USING_KEYWORD |
|
134 inline void setAlignment(Qt::Alignment alignment) { QLayoutItem::setAlignment(alignment); } |
|
135 #else |
|
136 using QLayoutItem::setAlignment; |
|
137 #endif |
|
138 |
|
139 void setSizeConstraint(SizeConstraint); |
|
140 SizeConstraint sizeConstraint() const; |
|
141 #ifdef QT3_SUPPORT |
|
142 inline QT3_SUPPORT void setResizeMode(SizeConstraint s) {setSizeConstraint(s);} |
|
143 inline QT3_SUPPORT SizeConstraint resizeMode() const {return sizeConstraint();} |
|
144 #endif |
|
145 void setMenuBar(QWidget *w); |
|
146 QWidget *menuBar() const; |
|
147 |
|
148 QWidget *parentWidget() const; |
|
149 |
|
150 void invalidate(); |
|
151 QRect geometry() const; |
|
152 bool activate(); |
|
153 void update(); |
|
154 |
|
155 void addWidget(QWidget *w); |
|
156 virtual void addItem(QLayoutItem *) = 0; |
|
157 |
|
158 void removeWidget(QWidget *w); |
|
159 void removeItem(QLayoutItem *); |
|
160 |
|
161 Qt::Orientations expandingDirections() const; |
|
162 QSize minimumSize() const; |
|
163 QSize maximumSize() const; |
|
164 virtual void setGeometry(const QRect&); |
|
165 virtual QLayoutItem *itemAt(int index) const = 0; |
|
166 virtual QLayoutItem *takeAt(int index) = 0; |
|
167 virtual int indexOf(QWidget *) const; |
|
168 virtual int count() const = 0; |
|
169 bool isEmpty() const; |
|
170 |
|
171 int totalHeightForWidth(int w) const; |
|
172 QSize totalMinimumSize() const; |
|
173 QSize totalMaximumSize() const; |
|
174 QSize totalSizeHint() const; |
|
175 QLayout *layout(); |
|
176 |
|
177 void setEnabled(bool); |
|
178 bool isEnabled() const; |
|
179 |
|
180 #ifdef QT3_SUPPORT |
|
181 QT3_SUPPORT void freeze(int w=0, int h=0); |
|
182 QT3_SUPPORT bool isTopLevel() const; |
|
183 #endif |
|
184 |
|
185 static QSize closestAcceptableSize(const QWidget *w, const QSize &s); |
|
186 |
|
187 protected: |
|
188 void widgetEvent(QEvent *); |
|
189 void childEvent(QChildEvent *e); |
|
190 void addChildLayout(QLayout *l); |
|
191 void addChildWidget(QWidget *w); |
|
192 #ifdef QT3_SUPPORT |
|
193 QT3_SUPPORT void deleteAllItems(); |
|
194 #endif |
|
195 |
|
196 QRect alignmentRect(const QRect&) const; |
|
197 protected: |
|
198 QLayout(QLayoutPrivate &d, QLayout*, QWidget*); |
|
199 |
|
200 private: |
|
201 Q_DISABLE_COPY(QLayout) |
|
202 |
|
203 static void activateRecursiveHelper(QLayoutItem *item); |
|
204 |
|
205 friend class QApplicationPrivate; |
|
206 friend class QWidget; |
|
207 |
|
208 #ifdef QT3_SUPPORT |
|
209 public: |
|
210 QT3_SUPPORT_CONSTRUCTOR QLayout(QWidget *parent, int margin, int spacing = -1, |
|
211 const char *name = 0); |
|
212 QT3_SUPPORT_CONSTRUCTOR QLayout(QLayout *parentLayout, int spacing = -1, const char *name = 0); |
|
213 QT3_SUPPORT_CONSTRUCTOR QLayout(int spacing, const char *name = 0); |
|
214 inline QT3_SUPPORT QWidget *mainWidget() const { return parentWidget(); } |
|
215 inline QT3_SUPPORT void remove(QWidget *w) { removeWidget(w); } |
|
216 inline QT3_SUPPORT void add(QWidget *w) { addWidget(w); } |
|
217 |
|
218 QT3_SUPPORT void setAutoAdd(bool a); |
|
219 QT3_SUPPORT bool autoAdd() const; |
|
220 inline QT3_SUPPORT QLayoutIterator iterator() { return QLayoutIterator(this,true); } |
|
221 |
|
222 inline QT3_SUPPORT int defaultBorder() const { return spacing(); } |
|
223 #endif |
|
224 }; |
|
225 |
|
226 #ifdef QT3_SUPPORT |
|
227 inline QLayoutItem *QLayoutIterator::operator++() { return layout->itemAt(++index); } |
|
228 inline QLayoutItem *QLayoutIterator::current() { return layout->itemAt(index); } |
|
229 inline QLayoutItem *QLayoutIterator::takeCurrent() { return layout->takeAt(index); } |
|
230 inline void QLayoutIterator::deleteCurrent() { delete layout->takeAt(index); } |
|
231 #endif |
|
232 |
|
233 //### support old includes |
|
234 #if 1 //def QT3_SUPPORT |
|
235 QT_BEGIN_INCLUDE_NAMESPACE |
|
236 #include <QtGui/qboxlayout.h> |
|
237 #include <QtGui/qgridlayout.h> |
|
238 QT_END_INCLUDE_NAMESPACE |
|
239 #endif |
|
240 |
|
241 QT_END_NAMESPACE |
|
242 |
|
243 QT_END_HEADER |
|
244 |
|
245 #endif // QLAYOUT_H |