source: vendor/trolltech/current/src/widgets/qhbox.cpp

Last change on this file was 2, checked in by dmik, 20 years ago

Imported xplatform parts of the official release 3.3.1 from Trolltech

  • Property svn:keywords set to Id
File size: 4.2 KB
Line 
1/****************************************************************************
2** $Id: qhbox.cpp 2 2005-11-16 15:49:26Z dmik $
3**
4** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
5**
6** This file is part of the widgets module of the Qt GUI Toolkit.
7**
8** This file may be distributed under the terms of the Q Public License
9** as defined by Trolltech AS of Norway and appearing in the file
10** LICENSE.QPL included in the packaging of this file.
11**
12** This file may be distributed and/or modified under the terms of the
13** GNU General Public License version 2 as published by the Free Software
14** Foundation and appearing in the file LICENSE.GPL included in the
15** packaging of this file.
16**
17** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
18** licenses may use this file in accordance with the Qt Commercial License
19** Agreement provided with the Software.
20**
21** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
22** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23**
24** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
25** information about Qt Commercial License Agreements.
26** See http://www.trolltech.com/qpl/ for QPL licensing information.
27** See http://www.trolltech.com/gpl/ for GPL licensing information.
28**
29** Contact info@trolltech.com if any conditions of this licensing are
30** not clear to you.
31**
32**********************************************************************/
33
34#include "qhbox.h"
35#ifndef QT_NO_HBOX
36#include "qlayout.h"
37#include "qapplication.h"
38#include "qobjectlist.h"
39
40
41/*!
42 \class QHBox qhbox.h
43 \brief The QHBox widget provides horizontal geometry management
44 for its child widgets.
45
46 \ingroup organizers
47 \ingroup geomanagement
48 \ingroup appearance
49
50 All the horizontal box's child widgets will be placed alongside
51 each other and sized according to their sizeHint()s.
52
53 Use setMargin() to add space around the edges, and use
54 setSpacing() to add space between the widgets. Use
55 setStretchFactor() if you want the widgets to be different sizes
56 in proportion to one another. (See \link layout.html
57 Layouts\endlink for more information on stretch factors.)
58
59 \img qhbox-m.png QHBox
60
61 \sa QHBoxLayout QVBox QGrid
62*/
63
64
65/*!
66 Constructs an hbox widget with parent \a parent, called \a name.
67 The parent, name and widget flags, \a f, are passed to the QFrame
68 constructor.
69*/
70QHBox::QHBox( QWidget *parent, const char *name, WFlags f )
71 :QFrame( parent, name, f )
72{
73 lay = new QHBoxLayout( this, frameWidth(), frameWidth(), name );
74 lay->setAutoAdd( TRUE );
75}
76
77
78/*!
79 Constructs a horizontal hbox if \a horizontal is TRUE, otherwise
80 constructs a vertical hbox (also known as a vbox).
81
82 This constructor is provided for the QVBox class. You should never
83 need to use it directly.
84
85 The \a parent, \a name and widget flags, \a f, are passed to the
86 QFrame constructor.
87*/
88
89QHBox::QHBox( bool horizontal, QWidget *parent , const char *name, WFlags f )
90 :QFrame( parent, name, f )
91{
92 lay = new QBoxLayout( this,
93 horizontal ? QBoxLayout::LeftToRight : QBoxLayout::Down,
94 frameWidth(), frameWidth(), name );
95 lay->setAutoAdd( TRUE );
96}
97
98/*!\reimp
99 */
100void QHBox::frameChanged()
101{
102 if ( !layout() )
103 return;
104 layout()->setMargin( frameWidth() );
105}
106
107
108/*!
109 Sets the spacing between the child widgets to \a space.
110*/
111
112void QHBox::setSpacing( int space )
113{
114 if ( layout() ) // ### why not use this->lay?
115 layout()->setSpacing( space );
116}
117
118
119/*!
120 \reimp
121*/
122
123QSize QHBox::sizeHint() const
124{
125 QWidget *mThis = (QWidget*)this;
126 QApplication::sendPostedEvents( mThis, QEvent::ChildInserted );
127 return QFrame::sizeHint();
128}
129
130/*!
131 Sets the stretch factor of widget \a w to \a stretch. Returns TRUE if
132 \a w is found. Otherwise returns FALSE.
133
134 \sa QBoxLayout::setStretchFactor() \link layout.html Layouts\endlink
135*/
136bool QHBox::setStretchFactor( QWidget* w, int stretch )
137{
138 QWidget *mThis = (QWidget*)this;
139 QApplication::sendPostedEvents( mThis, QEvent::ChildInserted );
140 return lay->setStretchFactor( w, stretch );
141}
142#endif
Note: See TracBrowser for help on using the repository browser.