[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
---|
[2] | 6 | **
|
---|
| 7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 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 | **
|
---|
[561] | 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.
|
---|
[2] | 27 | **
|
---|
| 28 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
[561] | 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at [email protected].
|
---|
[2] | 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | #ifndef QFORMLAYOUT_H
|
---|
| 43 | #define QFORMLAYOUT_H
|
---|
| 44 |
|
---|
| 45 | #include <QtGui/QLayout>
|
---|
| 46 |
|
---|
| 47 | QT_BEGIN_HEADER
|
---|
| 48 |
|
---|
| 49 | QT_BEGIN_NAMESPACE
|
---|
| 50 |
|
---|
| 51 | QT_MODULE(Gui)
|
---|
| 52 |
|
---|
| 53 | class QFormLayoutPrivate;
|
---|
| 54 |
|
---|
| 55 | class Q_GUI_EXPORT QFormLayout : public QLayout
|
---|
| 56 | {
|
---|
| 57 | Q_OBJECT
|
---|
| 58 | Q_ENUMS(FormStyle FieldGrowthPolicy RowWrapPolicy ItemRole)
|
---|
| 59 | Q_DECLARE_PRIVATE(QFormLayout)
|
---|
| 60 | Q_PROPERTY(FieldGrowthPolicy fieldGrowthPolicy READ fieldGrowthPolicy WRITE setFieldGrowthPolicy RESET resetFieldGrowthPolicy)
|
---|
| 61 | Q_PROPERTY(RowWrapPolicy rowWrapPolicy READ rowWrapPolicy WRITE setRowWrapPolicy RESET resetRowWrapPolicy)
|
---|
| 62 | Q_PROPERTY(Qt::Alignment labelAlignment READ labelAlignment WRITE setLabelAlignment RESET resetLabelAlignment)
|
---|
| 63 | Q_PROPERTY(Qt::Alignment formAlignment READ formAlignment WRITE setFormAlignment RESET resetFormAlignment)
|
---|
| 64 | Q_PROPERTY(int horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing)
|
---|
| 65 | Q_PROPERTY(int verticalSpacing READ verticalSpacing WRITE setVerticalSpacing)
|
---|
| 66 |
|
---|
| 67 | public:
|
---|
| 68 | enum FieldGrowthPolicy {
|
---|
| 69 | FieldsStayAtSizeHint,
|
---|
| 70 | ExpandingFieldsGrow,
|
---|
| 71 | AllNonFixedFieldsGrow
|
---|
| 72 | };
|
---|
| 73 |
|
---|
| 74 | enum RowWrapPolicy {
|
---|
| 75 | DontWrapRows,
|
---|
| 76 | WrapLongRows,
|
---|
| 77 | WrapAllRows
|
---|
| 78 | };
|
---|
| 79 |
|
---|
| 80 | enum ItemRole {
|
---|
| 81 | LabelRole = 0,
|
---|
| 82 | FieldRole = 1,
|
---|
| 83 | SpanningRole = 2
|
---|
| 84 | };
|
---|
| 85 |
|
---|
| 86 | explicit QFormLayout(QWidget *parent = 0);
|
---|
| 87 | ~QFormLayout();
|
---|
| 88 |
|
---|
| 89 | void setFieldGrowthPolicy(FieldGrowthPolicy policy);
|
---|
| 90 | FieldGrowthPolicy fieldGrowthPolicy() const;
|
---|
| 91 | void setRowWrapPolicy(RowWrapPolicy policy);
|
---|
| 92 | RowWrapPolicy rowWrapPolicy() const;
|
---|
| 93 | void setLabelAlignment(Qt::Alignment alignment);
|
---|
| 94 | Qt::Alignment labelAlignment() const;
|
---|
| 95 | void setFormAlignment(Qt::Alignment alignment);
|
---|
| 96 | Qt::Alignment formAlignment() const;
|
---|
| 97 |
|
---|
| 98 | void setHorizontalSpacing(int spacing);
|
---|
| 99 | int horizontalSpacing() const;
|
---|
| 100 | void setVerticalSpacing(int spacing);
|
---|
| 101 | int verticalSpacing() const;
|
---|
| 102 |
|
---|
| 103 | int spacing() const;
|
---|
| 104 | void setSpacing(int);
|
---|
| 105 |
|
---|
| 106 | void addRow(QWidget *label, QWidget *field);
|
---|
| 107 | void addRow(QWidget *label, QLayout *field);
|
---|
| 108 | void addRow(const QString &labelText, QWidget *field);
|
---|
| 109 | void addRow(const QString &labelText, QLayout *field);
|
---|
| 110 | void addRow(QWidget *widget);
|
---|
| 111 | void addRow(QLayout *layout);
|
---|
| 112 |
|
---|
| 113 | void insertRow(int row, QWidget *label, QWidget *field);
|
---|
| 114 | void insertRow(int row, QWidget *label, QLayout *field);
|
---|
| 115 | void insertRow(int row, const QString &labelText, QWidget *field);
|
---|
| 116 | void insertRow(int row, const QString &labelText, QLayout *field);
|
---|
| 117 | void insertRow(int row, QWidget *widget);
|
---|
| 118 | void insertRow(int row, QLayout *layout);
|
---|
| 119 |
|
---|
| 120 | void setItem(int row, ItemRole role, QLayoutItem *item);
|
---|
| 121 | void setWidget(int row, ItemRole role, QWidget *widget);
|
---|
| 122 | void setLayout(int row, ItemRole role, QLayout *layout);
|
---|
| 123 |
|
---|
| 124 | QLayoutItem *itemAt(int row, ItemRole role) const;
|
---|
| 125 | void getItemPosition(int index, int *rowPtr, ItemRole *rolePtr) const;
|
---|
| 126 | void getWidgetPosition(QWidget *widget, int *rowPtr, ItemRole *rolePtr) const;
|
---|
| 127 | void getLayoutPosition(QLayout *layout, int *rowPtr, ItemRole *rolePtr) const;
|
---|
| 128 | QWidget *labelForField(QWidget *field) const;
|
---|
| 129 | QWidget *labelForField(QLayout *field) const;
|
---|
| 130 |
|
---|
| 131 | // reimplemented from QLayout
|
---|
| 132 | void addItem(QLayoutItem *item);
|
---|
| 133 | QLayoutItem *itemAt(int index) const;
|
---|
| 134 | QLayoutItem *takeAt(int index);
|
---|
| 135 |
|
---|
| 136 | void setGeometry(const QRect &rect);
|
---|
| 137 | QSize minimumSize() const;
|
---|
| 138 | QSize sizeHint() const;
|
---|
| 139 | void invalidate();
|
---|
| 140 |
|
---|
| 141 | bool hasHeightForWidth() const;
|
---|
| 142 | int heightForWidth(int width) const;
|
---|
| 143 | Qt::Orientations expandingDirections() const;
|
---|
| 144 | int count() const;
|
---|
| 145 |
|
---|
| 146 | int rowCount() const;
|
---|
| 147 |
|
---|
| 148 | #if 0
|
---|
| 149 | void dump() const;
|
---|
| 150 | #endif
|
---|
| 151 |
|
---|
| 152 | private:
|
---|
| 153 | void resetFieldGrowthPolicy();
|
---|
| 154 | void resetRowWrapPolicy();
|
---|
| 155 | void resetLabelAlignment();
|
---|
| 156 | void resetFormAlignment();
|
---|
| 157 | };
|
---|
| 158 |
|
---|
| 159 | QT_END_NAMESPACE
|
---|
| 160 |
|
---|
| 161 | QT_END_HEADER
|
---|
| 162 |
|
---|
| 163 | #endif
|
---|