source: trunk/doc/html/qlayout-h.html@ 190

Last change on this file since 190 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 15.4 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/include/qlayout.h:1 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>qlayout.h Include File</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>qlayout.h</h1>
33
34<p>This is the verbatim text of the qlayout.h include file. It is provided only for illustration; the copyright remains with Trolltech.
35<hr>
36<pre>
37/****************************************************************************
38** $Id: qlayout-h.html 2051 2007-02-21 10:04:20Z chehrlic $
39**
40** Definition of layout classes
41**
42** Created : 960416
43**
44** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
45**
46** This file is part of the kernel module of the Qt GUI Toolkit.
47**
48** This file may be distributed under the terms of the Q Public License
49** as defined by Trolltech ASA of Norway and appearing in the file
50** LICENSE.QPL included in the packaging of this file.
51**
52** This file may be distributed and/or modified under the terms of the
53** GNU General Public License version 2 as published by the Free Software
54** Foundation and appearing in the file LICENSE.GPL included in the
55** packaging of this file.
56**
57** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
58** licenses may use this file in accordance with the Qt Commercial License
59** Agreement provided with the Software.
60**
61** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
62** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
63**
64** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
65** information about Qt Commercial License Agreements.
66** See http://www.trolltech.com/qpl/ for QPL licensing information.
67** See http://www.trolltech.com/gpl/ for GPL licensing information.
68**
69** Contact info@trolltech.com if any conditions of this licensing are
70** not clear to you.
71**
72**********************************************************************/
73
74#ifndef QLAYOUT_H
75#define QLAYOUT_H
76
77#ifndef QT_H
78#include "qobject.h"
79#include "qsizepolicy.h"
80#include "qwidget.h"
81#endif // QT_H
82
83#include &lt;limits.h&gt;
84
85#ifndef QT_NO_LAYOUT
86
87#if 0
88Q_OBJECT
89#endif
90
91static const int QLAYOUTSIZE_MAX = INT_MAX/256/16;
92
93class QGridLayoutBox;
94class QGridLayoutData;
95class QLayout;
96class QLayoutItem;
97struct QLayoutData;
98class QMenuBar;
99class QSpacerItem;
100class QWidget;
101
102class Q_EXPORT QGLayoutIterator : public QShared
103{
104public:
105 virtual ~QGLayoutIterator();
106 virtual QLayoutItem *next() = 0;
107 virtual QLayoutItem *current() = 0;
108 virtual QLayoutItem *takeCurrent() = 0;
109};
110
111class Q_EXPORT QLayoutIterator
112{
113public:
114 QLayoutIterator( QGLayoutIterator *i ) : it( i ) { }
115 QLayoutIterator( const QLayoutIterator &amp;i ) : it( i.it ) {
116 if ( it )
117 it-&gt;ref();
118 }
119 ~QLayoutIterator() { if ( it &amp;&amp; it-&gt;deref() ) delete it; }
120 QLayoutIterator &amp;operator=( const QLayoutIterator &amp;i ) {
121 if ( i.it )
122 i.it-&gt;ref();
123 if ( it &amp;&amp; it-&gt;deref() )
124 delete it;
125 it = i.it;
126 return *this;
127 }
128 QLayoutItem *operator++() { return it ? it-&gt;next() : 0; }
129 QLayoutItem *current() { return it ? it-&gt;current() : 0; }
130 QLayoutItem *takeCurrent() { return it ? it-&gt;takeCurrent() : 0; }
131 void deleteCurrent();
132
133private:
134 QGLayoutIterator *it;
135};
136
137class Q_EXPORT QLayoutItem
138{
139public:
140 QLayoutItem( int alignment = 0 ) : align( alignment ) { }
141 virtual ~QLayoutItem();
142 virtual QSize sizeHint() const = 0;
143 virtual QSize minimumSize() const = 0;
144 virtual QSize maximumSize() const = 0;
145 virtual QSizePolicy::ExpandData expanding() const = 0;
146 virtual void setGeometry( const QRect&amp; ) = 0;
147 virtual QRect geometry() const = 0;
148 virtual bool isEmpty() const = 0;
149 virtual bool hasHeightForWidth() const;
150 virtual int heightForWidth( int ) const;
151 // ### add minimumHeightForWidth( int ) in Qt 4.0
152 virtual void invalidate();
153
154 virtual QWidget *widget();
155 virtual QLayoutIterator iterator();
156 virtual QLayout *layout();
157 virtual QSpacerItem *spacerItem();
158
159 int alignment() const { return align; }
160 virtual void setAlignment( int a );
161
162protected:
163 int align;
164};
165
166class Q_EXPORT QSpacerItem : public QLayoutItem
167{
168public:
169 QSpacerItem( int w, int h,
170 QSizePolicy::SizeType hData = QSizePolicy::Minimum,
171 QSizePolicy::SizeType vData = QSizePolicy::Minimum )
172 : width( w ), height( h ), sizeP( hData, vData ) { }
173 void changeSize( int w, int h,
174 QSizePolicy::SizeType hData = QSizePolicy::Minimum,
175 QSizePolicy::SizeType vData = QSizePolicy::Minimum );
176 QSize sizeHint() const;
177 QSize minimumSize() const;
178 QSize maximumSize() const;
179 QSizePolicy::ExpandData expanding() const;
180 bool isEmpty() const;
181 void setGeometry( const QRect&amp; );
182 QRect geometry() const;
183 QSpacerItem *spacerItem();
184
185private:
186 int width;
187 int height;
188 QSizePolicy sizeP;
189 QRect rect;
190};
191
192class Q_EXPORT QWidgetItem : public QLayoutItem
193{
194public:
195 QWidgetItem( QWidget *w ) : wid( w ) { }
196 QSize sizeHint() const;
197 QSize minimumSize() const;
198 QSize maximumSize() const;
199 QSizePolicy::ExpandData expanding() const;
200 bool isEmpty() const;
201 void setGeometry( const QRect&amp; );
202 QRect geometry() const;
203 virtual QWidget *widget();
204
205 bool hasHeightForWidth() const;
206 int heightForWidth( int ) const;
207
208private:
209 QWidget *wid;
210};
211
212class Q_EXPORT QLayout : public QObject, public QLayoutItem
213{
214 Q_OBJECT
215 Q_ENUMS( ResizeMode )
216 Q_PROPERTY( int margin READ margin WRITE setMargin )
217 Q_PROPERTY( int spacing READ spacing WRITE setSpacing )
218 Q_PROPERTY( ResizeMode resizeMode READ resizeMode WRITE setResizeMode )
219
220public:
221 // ### Qt 4.0: put 'Auto' first in enum
222 enum ResizeMode { FreeResize, Minimum, Fixed, Auto };
223
224 QLayout( QWidget *parent, int margin = 0, int spacing = -1,
225 const char *name = 0 );
226 QLayout( QLayout *parentLayout, int spacing = -1, const char *name = 0 );
227 QLayout( int spacing = -1, const char *name = 0 );
228 ~QLayout();
229
230 int margin() const { return outsideBorder; }
231 int spacing() const { return insideSpacing; }
232
233 virtual void setMargin( int );
234 virtual void setSpacing( int );
235
236 int defaultBorder() const { return insideSpacing; }
237 void freeze( int w, int h );
238 void freeze() { setResizeMode( Fixed ); }
239
240 void setResizeMode( ResizeMode );
241 ResizeMode resizeMode() const;
242
243#ifndef QT_NO_MENUBAR
244 virtual void setMenuBar( QMenuBar *w );
245 QMenuBar *menuBar() const { return menubar; }
246#endif
247
248 QWidget *mainWidget();
249 bool isTopLevel() const { return topLevel; }
250
251 virtual void setAutoAdd( bool );
252 bool autoAdd() const { return autoNewChild; }
253
254 void invalidate();
255 QRect geometry() const;
256 bool activate();
257
258 void add( QWidget *w ) { addItem( new QWidgetItem(w) ); }
259 virtual void addItem( QLayoutItem * ) = 0;
260
261 void remove( QWidget *w );
262 void removeItem( QLayoutItem * );
263
264 QSizePolicy::ExpandData expanding() const;
265 QSize minimumSize() const;
266 QSize maximumSize() const;
267 void setGeometry( const QRect&amp; ) = 0;
268 QLayoutIterator iterator() = 0;
269 bool isEmpty() const;
270
271 int totalHeightForWidth( int w ) const;
272 QSize totalMinimumSize() const;
273 QSize totalMaximumSize() const;
274 QSize totalSizeHint() const;
275 QLayout *layout();
276
277 bool supportsMargin() const { return marginImpl; }
278
279 void setEnabled( bool );
280 bool isEnabled() const;
281
282protected:
283 bool eventFilter( QObject *, QEvent * );
284 void childEvent( QChildEvent *e );
285 void addChildLayout( QLayout *l );
286 void deleteAllItems();
287
288 void setSupportsMargin( bool );
289 QRect alignmentRect( const QRect&amp; ) const;
290
291private:
292 void setWidgetLayout( QWidget *, QLayout * );
293 void init();
294 int insideSpacing;
295 int outsideBorder;
296 uint topLevel : 1;
297 uint enabled : 1;
298 uint autoNewChild : 1;
299 uint frozen : 1;
300 uint activated : 1;
301 uint marginImpl : 1;
302 uint autoMinimum : 1;
303 uint autoResizeMode : 1;
304 QRect rect;
305 QLayoutData *extraData;
306#ifndef QT_NO_MENUBAR
307 QMenuBar *menubar;
308#endif
309
310private:
311#if defined(Q_DISABLE_COPY)
312 QLayout( const QLayout &amp; );
313 QLayout &amp;operator=( const QLayout &amp; );
314#endif
315
316 static void propagateSpacing( QLayout *layout );
317};
318
319inline void QLayoutIterator::deleteCurrent()
320{
321 delete takeCurrent();
322}
323
324class Q_EXPORT QGridLayout : public QLayout
325{
326 Q_OBJECT
327public:
328 QGridLayout( QWidget *parent, int nRows = 1, int nCols = 1, int border = 0,
329 int spacing = -1, const char *name = 0 );
330 QGridLayout( int nRows = 1, int nCols = 1, int spacing = -1,
331 const char *name = 0 );
332 QGridLayout( QLayout *parentLayout, int nRows = 1, int nCols = 1,
333 int spacing = -1, const char *name = 0 );
334 ~QGridLayout();
335
336 QSize sizeHint() const;
337 QSize minimumSize() const;
338 QSize maximumSize() const;
339
340 // ### remove 'virtual' in 4.0 (or add 'virtual' to set{Row,Col}Spacing())
341 virtual void setRowStretch( int row, int stretch );
342 virtual void setColStretch( int col, int stretch );
343 int rowStretch( int row ) const;
344 int colStretch( int col ) const;
345
346 void setRowSpacing( int row, int minSize );
347 void setColSpacing( int col, int minSize );
348 int rowSpacing( int row ) const;
349 int colSpacing( int col ) const;
350
351 int numRows() const;
352 int numCols() const;
353 QRect cellGeometry( int row, int col ) const;
354
355 bool hasHeightForWidth() const;
356 int heightForWidth( int ) const;
357 int minimumHeightForWidth( int ) const;
358
359 QSizePolicy::ExpandData expanding() const;
360 void invalidate();
361
362 void addItem( QLayoutItem * );
363 void addItem( QLayoutItem *item, int row, int col );
364 void addMultiCell( QLayoutItem *, int fromRow, int toRow,
365 int fromCol, int toCol, int align = 0 );
366
367 void addWidget( QWidget *, int row, int col, int align = 0 );
368 void addMultiCellWidget( QWidget *, int fromRow, int toRow,
369 int fromCol, int toCol, int align = 0 );
370 void addLayout( QLayout *layout, int row, int col);
371 void addMultiCellLayout( QLayout *layout, int fromRow, int toRow,
372 int fromCol, int toCol, int align = 0 );
373 void addRowSpacing( int row, int minsize );
374 void addColSpacing( int col, int minsize );
375
376 void expand( int rows, int cols );
377
378 enum Corner { TopLeft, TopRight, BottomLeft, BottomRight };
379 void setOrigin( Corner );
380 Corner origin() const;
381 QLayoutIterator iterator();
382 void setGeometry( const QRect&amp; );
383
384protected:
385 bool findWidget( QWidget* w, int *r, int *c );
386 void add( QLayoutItem*, int row, int col );
387
388private:
389#if defined(Q_DISABLE_COPY)
390 QGridLayout( const QGridLayout &amp; );
391 QGridLayout &amp;operator=( const QGridLayout &amp; );
392#endif
393
394 void init( int rows, int cols );
395 QGridLayoutData *data;
396};
397
398class QBoxLayoutData;
399class QDockWindow;
400
401class Q_EXPORT QBoxLayout : public QLayout
402{
403 Q_OBJECT
404public:
405 enum Direction { LeftToRight, RightToLeft, TopToBottom, BottomToTop,
406 Down = TopToBottom, Up = BottomToTop };
407
408 QBoxLayout( QWidget *parent, Direction, int border = 0, int spacing = -1,
409 const char *name = 0 );
410 QBoxLayout( QLayout *parentLayout, Direction, int spacing = -1,
411 const char *name = 0 );
412 QBoxLayout( Direction, int spacing = -1, const char *name = 0 );
413 ~QBoxLayout();
414
415 void addItem( QLayoutItem * );
416
417 Direction direction() const { return dir; }
418 void setDirection( Direction );
419
420 void addSpacing( int size );
421 void addStretch( int stretch = 0 );
422 void addWidget( QWidget *, int stretch = 0, int alignment = 0 );
423 void addLayout( QLayout *layout, int stretch = 0 );
424 void addStrut( int );
425
426 void insertSpacing( int index, int size );
427 void insertStretch( int index, int stretch = 0 );
428 void insertWidget( int index, QWidget *widget, int stretch = 0,
429 int alignment = 0 );
430 void insertLayout( int index, QLayout *layout, int stretch = 0 );
431
432 bool setStretchFactor( QWidget*, int stretch );
433 bool setStretchFactor( QLayout *l, int stretch );
434
435 QSize sizeHint() const;
436 QSize minimumSize() const;
437 QSize maximumSize() const;
438
439 bool hasHeightForWidth() const;
440 int heightForWidth( int ) const;
441 int minimumHeightForWidth( int ) const;
442
443 QSizePolicy::ExpandData expanding() const;
444 void invalidate();
445 QLayoutIterator iterator();
446 void setGeometry( const QRect&amp; );
447
448 int findWidget( QWidget* w );
449
450protected:
451 void insertItem( int index, QLayoutItem * );
452
453private:
454 friend class QDockWindow;
455#if defined(Q_DISABLE_COPY)
456 QBoxLayout( const QBoxLayout &amp; );
457 QBoxLayout &amp;operator=( const QBoxLayout &amp; );
458#endif
459
460 void setupGeom();
461 void calcHfw( int );
462 QBoxLayoutData *data;
463 Direction dir;
464 QBoxLayout *createTmpCopy();
465};
466
467class Q_EXPORT QHBoxLayout : public QBoxLayout
468{
469 Q_OBJECT
470public:
471 QHBoxLayout( QWidget *parent, int border = 0,
472 int spacing = -1, const char *name = 0 );
473 QHBoxLayout( QLayout *parentLayout,
474 int spacing = -1, const char *name = 0 );
475 QHBoxLayout( int spacing = -1, const char *name = 0 );
476
477 ~QHBoxLayout();
478
479private: // Disabled copy constructor and operator=
480#if defined(Q_DISABLE_COPY)
481 QHBoxLayout( const QHBoxLayout &amp; );
482 QHBoxLayout &amp;operator=( const QHBoxLayout &amp; );
483#endif
484};
485
486class Q_EXPORT QVBoxLayout : public QBoxLayout
487{
488 Q_OBJECT
489public:
490 QVBoxLayout( QWidget *parent, int border = 0,
491 int spacing = -1, const char *name = 0 );
492 QVBoxLayout( QLayout *parentLayout,
493 int spacing = -1, const char *name = 0 );
494 QVBoxLayout( int spacing = -1, const char *name = 0 );
495
496 ~QVBoxLayout();
497
498private: // Disabled copy constructor and operator=
499#if defined(Q_DISABLE_COPY)
500 QVBoxLayout( const QVBoxLayout &amp; );
501 QVBoxLayout &amp;operator=( const QVBoxLayout &amp; );
502#endif
503};
504
505#endif // QT_NO_LAYOUT
506#endif // QLAYOUT_H
507</pre>
508<!-- eof -->
509<p><address><hr><div align=center>
510<table width=100% cellspacing=0 border=0><tr>
511<td>Copyright &copy; 2007
512<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
513<td align=right><div align=right>Qt 3.3.8</div>
514</table></div></address></body>
515</html>
Note: See TracBrowser for help on using the repository browser.