author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 19 Feb 2010 23:40:16 +0200 | |
branch | RCL_3 |
changeset 4 | 3b1da2848fc7 |
parent 0 | 1918ee327afb |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the Qt3Support 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 |
#include "q3grid.h" |
|
43 |
#include "qlayout.h" |
|
44 |
#include "qapplication.h" |
|
45 |
||
46 |
QT_BEGIN_NAMESPACE |
|
47 |
||
48 |
/*! |
|
49 |
\class Q3Grid |
|
50 |
\brief The Q3Grid widget provides simple geometry management of its children. |
|
51 |
||
52 |
\compat |
|
53 |
||
54 |
The grid places its widgets either in columns or in rows depending |
|
55 |
on its orientation. |
|
56 |
||
57 |
The number of rows \e or columns is defined in the constructor. |
|
58 |
All the grid's children will be placed and sized in accordance |
|
59 |
with their sizeHint() and sizePolicy(). |
|
60 |
||
61 |
Use setMargin() to add space around the grid itself, and |
|
62 |
setSpacing() to add space between the widgets. |
|
63 |
||
64 |
\sa Q3VBox Q3HBox QGridLayout |
|
65 |
*/ |
|
66 |
||
67 |
/*! |
|
68 |
\typedef Q3Grid::Direction |
|
69 |
\internal |
|
70 |
*/ |
|
71 |
||
72 |
/*! |
|
73 |
Constructs a grid widget with parent \a parent, called \a name. |
|
74 |
If \a orient is \c Horizontal, \a n specifies the number of |
|
75 |
columns. If \a orient is \c Vertical, \a n specifies the number of |
|
76 |
rows. The widget flags \a f are passed to the Q3Frame constructor. |
|
77 |
*/ |
|
78 |
Q3Grid::Q3Grid(int n, Qt::Orientation orient, QWidget *parent, const char *name, |
|
79 |
Qt::WindowFlags f) |
|
80 |
: Q3Frame(parent, name, f) |
|
81 |
{ |
|
82 |
int nCols, nRows; |
|
83 |
if (orient == Qt::Horizontal) { |
|
84 |
nCols = n; |
|
85 |
nRows = -1; |
|
86 |
} else { |
|
87 |
nCols = -1; |
|
88 |
nRows = n; |
|
89 |
} |
|
90 |
(new QGridLayout(this, nRows, nCols, 0, 0, name))->setAutoAdd(true); |
|
91 |
} |
|
92 |
||
93 |
||
94 |
||
95 |
/*! |
|
96 |
Constructs a grid widget with parent \a parent, called \a name. |
|
97 |
\a n specifies the number of columns. The widget flags \a f are |
|
98 |
passed to the Q3Frame constructor. |
|
99 |
*/ |
|
100 |
Q3Grid::Q3Grid(int n, QWidget *parent, const char *name, Qt::WindowFlags f) |
|
101 |
: Q3Frame(parent, name, f) |
|
102 |
{ |
|
103 |
(new QGridLayout(this, -1, n, 0, 0, name))->setAutoAdd(true); |
|
104 |
} |
|
105 |
||
106 |
||
107 |
/*! |
|
108 |
Sets the spacing between the child widgets to \a space. |
|
109 |
*/ |
|
110 |
||
111 |
void Q3Grid::setSpacing(int space) |
|
112 |
{ |
|
113 |
if (layout()) |
|
114 |
layout()->setSpacing(space); |
|
115 |
} |
|
116 |
||
117 |
||
118 |
/*!\reimp |
|
119 |
*/ |
|
120 |
void Q3Grid::frameChanged() |
|
121 |
{ |
|
122 |
if (layout()) |
|
123 |
layout()->setMargin(frameWidth()); |
|
124 |
} |
|
125 |
||
126 |
||
127 |
/*! |
|
128 |
\reimp |
|
129 |
*/ |
|
130 |
||
131 |
QSize Q3Grid::sizeHint() const |
|
132 |
{ |
|
133 |
QWidget *mThis = (QWidget*)this; |
|
134 |
QApplication::sendPostedEvents(mThis, QEvent::ChildInserted); |
|
135 |
return Q3Frame::sizeHint(); |
|
136 |
} |
|
137 |
||
138 |
QT_END_NAMESPACE |