author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 15 Mar 2010 12:43:09 +0200 | |
branch | RCL_3 |
changeset 6 | dee5afe5301f |
parent 4 | 3b1da2848fc7 |
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 "q3hbox.h" |
|
43 |
#include "qlayout.h" |
|
44 |
#include "qapplication.h" |
|
45 |
||
46 |
QT_BEGIN_NAMESPACE |
|
47 |
||
48 |
/*! |
|
49 |
\class Q3HBox |
|
50 |
\brief The Q3HBox widget provides horizontal geometry management |
|
51 |
for its child widgets. |
|
52 |
||
53 |
\compat |
|
54 |
||
55 |
All the horizontal box's child widgets will be placed alongside |
|
56 |
each other and sized according to their sizeHint()s. |
|
57 |
||
58 |
Use setMargin() to add space around the edges, and use |
|
59 |
setSpacing() to add space between the widgets. Use |
|
60 |
setStretchFactor() if you want the widgets to be different sizes |
|
61 |
in proportion to one another. (See \link layout.html |
|
62 |
Layouts\endlink for more information on stretch factors.) |
|
63 |
||
64 |
\img qhbox-m.png Q3HBox |
|
65 |
||
66 |
\sa QHBoxLayout Q3VBox Q3Grid |
|
67 |
*/ |
|
68 |
||
69 |
||
70 |
/*! |
|
71 |
Constructs an hbox widget with parent \a parent, called \a name. |
|
72 |
The parent, name and widget flags, \a f, are passed to the Q3Frame |
|
73 |
constructor. |
|
74 |
*/ |
|
75 |
Q3HBox::Q3HBox(QWidget *parent, const char *name, Qt::WindowFlags f) |
|
76 |
:Q3Frame(parent, name, f) |
|
77 |
{ |
|
78 |
(new QHBoxLayout(this, frameWidth(), frameWidth(), name))->setAutoAdd(true); |
|
79 |
} |
|
80 |
||
81 |
||
82 |
/*! |
|
83 |
Constructs a horizontal hbox if \a horizontal is TRUE, otherwise |
|
84 |
constructs a vertical hbox (also known as a vbox). |
|
85 |
||
86 |
This constructor is provided for the QVBox class. You should never |
|
87 |
need to use it directly. |
|
88 |
||
89 |
The \a parent, \a name and widget flags, \a f, are passed to the |
|
90 |
Q3Frame constructor. |
|
91 |
*/ |
|
92 |
||
93 |
Q3HBox::Q3HBox(bool horizontal, QWidget *parent , const char *name, Qt::WindowFlags f) |
|
94 |
:Q3Frame(parent, name, f) |
|
95 |
{ |
|
96 |
(new QBoxLayout(this, horizontal ? QBoxLayout::LeftToRight : QBoxLayout::Down, |
|
97 |
frameWidth(), frameWidth(), name))->setAutoAdd(true); |
|
98 |
} |
|
99 |
||
100 |
/*!\reimp |
|
101 |
*/ |
|
102 |
void Q3HBox::frameChanged() |
|
103 |
{ |
|
104 |
if (layout()) |
|
105 |
layout()->setMargin(frameWidth()); |
|
106 |
} |
|
107 |
||
108 |
||
109 |
/*! |
|
110 |
Sets the spacing between the child widgets to \a space. |
|
111 |
*/ |
|
112 |
||
113 |
void Q3HBox::setSpacing(int space) |
|
114 |
{ |
|
115 |
if (layout()) |
|
116 |
layout()->setSpacing(space); |
|
117 |
} |
|
118 |
||
119 |
||
120 |
/*! |
|
121 |
\reimp |
|
122 |
*/ |
|
123 |
||
124 |
QSize Q3HBox::sizeHint() const |
|
125 |
{ |
|
126 |
QWidget *mThis = (QWidget*)this; |
|
127 |
QApplication::sendPostedEvents(mThis, QEvent::ChildInserted); |
|
128 |
return Q3Frame::sizeHint(); |
|
129 |
} |
|
130 |
||
131 |
/*! |
|
132 |
Sets the stretch factor of widget \a w to \a stretch. Returns true if |
|
133 |
\a w is found. Otherwise returns false. |
|
134 |
||
135 |
\sa QBoxLayout::setStretchFactor() \link layout.html Layouts\endlink |
|
136 |
*/ |
|
137 |
bool Q3HBox::setStretchFactor(QWidget* w, int stretch) |
|
138 |
{ |
|
139 |
QApplication::sendPostedEvents(this, QEvent::ChildInserted); |
|
140 |
if (QBoxLayout *lay = qobject_cast<QBoxLayout *>(layout())) |
|
141 |
return lay->setStretchFactor(w, stretch); |
|
142 |
return false; |
|
143 |
} |
|
144 |
||
145 |
QT_END_NAMESPACE |