1 | /****************************************************************************
|
---|
2 | ** $Id: border.h 2 2005-11-16 15:49:26Z dmik $
|
---|
3 | **
|
---|
4 | ** Definition of simple flow layout for custom layout example
|
---|
5 | **
|
---|
6 | ** Created : 979899
|
---|
7 | **
|
---|
8 | ** Copyright (C) 1997 by Trolltech AS. All rights reserved.
|
---|
9 | **
|
---|
10 | ** This file is part of an example program for Qt. This example
|
---|
11 | ** program may be used, distributed and modified without limitation.
|
---|
12 | **
|
---|
13 | *****************************************************************************/
|
---|
14 |
|
---|
15 | #ifndef BORDER_H
|
---|
16 | #define BORDER_H
|
---|
17 |
|
---|
18 | #include <qlayout.h>
|
---|
19 | #include <qptrlist.h>
|
---|
20 |
|
---|
21 | class BorderWidgetItem : public QWidgetItem
|
---|
22 | {
|
---|
23 | public:
|
---|
24 | BorderWidgetItem( QWidget *w )
|
---|
25 | : QWidgetItem( w )
|
---|
26 | {}
|
---|
27 |
|
---|
28 | void setGeometry( const QRect &r )
|
---|
29 | { widget()->setGeometry( r ); }
|
---|
30 |
|
---|
31 | };
|
---|
32 |
|
---|
33 | class BorderLayout : public QLayout
|
---|
34 | {
|
---|
35 | public:
|
---|
36 | enum Position {
|
---|
37 | West = 0,
|
---|
38 | North,
|
---|
39 | South,
|
---|
40 | East,
|
---|
41 | Center
|
---|
42 | };
|
---|
43 |
|
---|
44 | struct BorderLayoutStruct
|
---|
45 | {
|
---|
46 | BorderLayoutStruct( QLayoutItem *i, Position p ) {
|
---|
47 | item = i;
|
---|
48 | pos = p;
|
---|
49 | }
|
---|
50 |
|
---|
51 | QLayoutItem *item;
|
---|
52 | Position pos;
|
---|
53 | };
|
---|
54 |
|
---|
55 | enum SizeType {
|
---|
56 | Minimum = 0,
|
---|
57 | SizeHint
|
---|
58 | };
|
---|
59 |
|
---|
60 | BorderLayout( QWidget *parent, int border = 0, int autoBorder = -1,
|
---|
61 | const char *name = 0 )
|
---|
62 | : QLayout( parent, border, autoBorder, name ), cached( 0, 0 ), mcached( 0, 0 ),
|
---|
63 | sizeDirty( TRUE ), msizeDirty( TRUE )
|
---|
64 | {}
|
---|
65 |
|
---|
66 | BorderLayout( QLayout* parent, int autoBorder = -1, const char *name = 0 )
|
---|
67 | : QLayout( parent, autoBorder, name ), cached( 0, 0 ), mcached( 0, 0 ),
|
---|
68 | sizeDirty( TRUE ), msizeDirty( TRUE )
|
---|
69 | {}
|
---|
70 |
|
---|
71 | BorderLayout( int autoBorder = -1, const char *name = 0 )
|
---|
72 | : QLayout( autoBorder, name ), cached( 0, 0 ), mcached( 0, 0 ),
|
---|
73 | sizeDirty( TRUE ), msizeDirty( TRUE )
|
---|
74 | {}
|
---|
75 |
|
---|
76 | ~BorderLayout();
|
---|
77 |
|
---|
78 | void addItem( QLayoutItem *item );
|
---|
79 |
|
---|
80 | void addWidget( QWidget *widget, Position pos );
|
---|
81 | void add( QLayoutItem *item, Position pos );
|
---|
82 |
|
---|
83 | bool hasHeightForWidth() const;
|
---|
84 |
|
---|
85 | QSize sizeHint() const;
|
---|
86 | QSize minimumSize() const;
|
---|
87 |
|
---|
88 | QLayoutIterator iterator();
|
---|
89 |
|
---|
90 | QSizePolicy::ExpandData expanding() const;
|
---|
91 |
|
---|
92 | protected:
|
---|
93 | void setGeometry( const QRect &rect );
|
---|
94 |
|
---|
95 | private:
|
---|
96 | void doLayout( const QRect &rect, bool testonly = FALSE );
|
---|
97 | void calcSize( SizeType st );
|
---|
98 |
|
---|
99 | QPtrList<BorderLayoutStruct> list;
|
---|
100 | QSize cached, mcached;
|
---|
101 | bool sizeDirty, msizeDirty;
|
---|
102 |
|
---|
103 | };
|
---|
104 |
|
---|
105 | #endif
|
---|