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