1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #ifndef BASICLAYOUTS_H
34 #define BASICLAYOUTS_H
36 #include <qlayoutobject.h>
37 #include <QHBoxLayout>
44 QT_MODULE(Declarative)
45 class QBoxLayoutObject : public QLayoutObject
49 Q_PROPERTY(QDeclarativeListProperty<QWidget> children READ children)
51 Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin)
52 Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin)
53 Q_PROPERTY(int leftMargin READ leftMargin WRITE setLeftMargin)
54 Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin)
55 Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
57 Q_CLASSINFO("DefaultProperty", "children")
59 QBoxLayoutObject(QObject *parent=0);
60 explicit QBoxLayoutObject(QBoxLayout *, QObject *parent=0);
61 virtual QLayout *layout() const;
63 QDeclarativeListProperty<QWidget> children() {
64 return QDeclarativeListProperty<QWidget>(this, 0, children_append, 0, 0, children_clear);
68 friend class WidgetList;
69 void addWidget(QWidget *);
72 static void children_append(QDeclarativeListProperty<QWidget> *property, QWidget *widget) {
73 static_cast<QBoxLayoutObject*>(property->object)->addWidget(widget);
76 static void children_clear(QDeclarativeListProperty<QWidget> *property) {
77 static_cast<QBoxLayoutObject*>(property->object)->clearWidget();
82 _layout->getContentsMargins(&mLeft, &mTop, &mRight, &mBottom);
87 _layout->setContentsMargins(mLeft, mTop, mRight, mBottom);
96 void setTopMargin(int margin)
109 void setBottomMargin(int margin)
122 void setLeftMargin(int margin)
135 void setRightMargin(int margin)
144 return _layout->spacing();
147 void setSpacing(int spacing)
149 _layout->setSpacing(spacing);
154 int mTop, mLeft, mBottom, mRight;
158 class QHBoxLayoutObject : public QBoxLayoutObject
162 QHBoxLayoutObject(QObject *parent=0);
165 class QVBoxLayoutObject : public QBoxLayoutObject
169 QVBoxLayoutObject(QObject *parent=0);
174 QML_DECLARE_TYPE(QBoxLayoutObject)
175 QML_DECLARE_TYPE(QHBoxLayoutObject)
176 QML_DECLARE_TYPE(QVBoxLayoutObject)
181 static void registerDeclarativeTypes();
186 #endif // BASICLAYOUTS_H