1 /****************************************************************************
2 **
3 ** DQt - D bindings for the Qt Toolkit
4 **
5 ** GNU Lesser General Public License Usage
6 ** This file may be used under the terms of the GNU Lesser
7 ** General Public License version 3 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
9 ** packaging of this file. Please review the following information to
10 ** ensure the GNU Lesser General Public License version 3 requirements
11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
12 **
13 ****************************************************************************/
14 module qt.widgets.formlayout;
15 extern(C++):
16 
17 import qt.config;
18 import qt.core.namespace;
19 import qt.core.rect;
20 import qt.core.size;
21 import qt.core.string;
22 import qt.helpers;
23 import qt.widgets.layout;
24 import qt.widgets.layoutitem;
25 import qt.widgets.widget;
26 
27 /+ QT_REQUIRE_CONFIG(formlayout); +/
28 
29 
30 
31 extern(C++, class) struct QFormLayoutPrivate;
32 
33 class /+ Q_WIDGETS_EXPORT +/ QFormLayout : QLayout
34 {
35     mixin(Q_OBJECT);
36     /+ Q_DECLARE_PRIVATE(QFormLayout) +/
37     /+ Q_PROPERTY(FieldGrowthPolicy fieldGrowthPolicy READ fieldGrowthPolicy WRITE setFieldGrowthPolicy RESET resetFieldGrowthPolicy)
38     Q_PROPERTY(RowWrapPolicy rowWrapPolicy READ rowWrapPolicy WRITE setRowWrapPolicy RESET resetRowWrapPolicy)
39     Q_PROPERTY(Qt::Alignment labelAlignment READ labelAlignment WRITE setLabelAlignment RESET resetLabelAlignment)
40     Q_PROPERTY(Qt::Alignment formAlignment READ formAlignment WRITE setFormAlignment RESET resetFormAlignment)
41     Q_PROPERTY(int horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing)
42     Q_PROPERTY(int verticalSpacing READ verticalSpacing WRITE setVerticalSpacing) +/
43 
44 public:
45     enum FieldGrowthPolicy {
46         FieldsStayAtSizeHint,
47         ExpandingFieldsGrow,
48         AllNonFixedFieldsGrow
49     }
50     /+ Q_ENUM(FieldGrowthPolicy) +/
51 
52     enum RowWrapPolicy {
53         DontWrapRows,
54         WrapLongRows,
55         WrapAllRows
56     }
57     /+ Q_ENUM(RowWrapPolicy) +/
58 
59     enum ItemRole {
60         LabelRole = 0,
61         FieldRole = 1,
62         SpanningRole = 2
63     }
64     /+ Q_ENUM(ItemRole) +/
65 
66     struct TakeRowResult {
67         QLayoutItem labelItem;
68         QLayoutItem fieldItem;
69     }
70 
71     /+ explicit +/this(QWidget parent = null);
72     ~this();
73 
74     final void setFieldGrowthPolicy(FieldGrowthPolicy policy);
75     final FieldGrowthPolicy fieldGrowthPolicy() const;
76     final void setRowWrapPolicy(RowWrapPolicy policy);
77     final RowWrapPolicy rowWrapPolicy() const;
78     final void setLabelAlignment(/+ Qt:: +/qt.core.namespace.Alignment alignment);
79     final /+ Qt:: +/qt.core.namespace.Alignment labelAlignment() const;
80     final void setFormAlignment(/+ Qt:: +/qt.core.namespace.Alignment alignment);
81     final /+ Qt:: +/qt.core.namespace.Alignment formAlignment() const;
82 
83     final void setHorizontalSpacing(int spacing);
84     final int horizontalSpacing() const;
85     final void setVerticalSpacing(int spacing);
86     final int verticalSpacing() const;
87 
88 //    final int spacing() const;
89 //    final void setSpacing(int);
90 
91     final void addRow(QWidget label, QWidget field);
92     final void addRow(QWidget label, QLayout field);
93     final void addRow(ref const(QString) labelText, QWidget field);
94     final void addRow(ref const(QString) labelText, QLayout field);
95     final void addRow(QWidget widget);
96     final void addRow(QLayout layout);
97 
98     final void insertRow(int row, QWidget label, QWidget field);
99     final void insertRow(int row, QWidget label, QLayout field);
100     final void insertRow(int row, ref const(QString) labelText, QWidget field);
101     final void insertRow(int row, ref const(QString) labelText, QLayout field);
102     final void insertRow(int row, QWidget widget);
103     final void insertRow(int row, QLayout layout);
104 
105     final void removeRow(int row);
106     final void removeRow(QWidget widget);
107     final void removeRow(QLayout layout);
108 
109     final TakeRowResult takeRow(int row);
110     final TakeRowResult takeRow(QWidget widget);
111     final TakeRowResult takeRow(QLayout layout);
112 
113     final void setItem(int row, ItemRole role, QLayoutItem item);
114     final void setWidget(int row, ItemRole role, QWidget widget);
115     final void setLayout(int row, ItemRole role, QLayout layout);
116 
117     final QLayoutItem itemAt(int row, ItemRole role) const;
118     final void getItemPosition(int index, int* rowPtr, ItemRole* rolePtr) const;
119     final void getWidgetPosition(QWidget widget, int* rowPtr, ItemRole* rolePtr) const;
120     final void getLayoutPosition(QLayout layout, int* rowPtr, ItemRole* rolePtr) const;
121     final QWidget labelForField(QWidget field) const;
122     final QWidget labelForField(QLayout field) const;
123 
124     // reimplemented from QLayout
125     override void addItem(QLayoutItem item);
126     override QLayoutItem itemAt(int index) const;
127     override QLayoutItem takeAt(int index);
128 
129     override void setGeometry(ref const(QRect) rect);
130     override QSize minimumSize() const;
131     override QSize sizeHint() const;
132     override void invalidate();
133 
134     override bool hasHeightForWidth() const;
135     override int heightForWidth(int width) const;
136     override /+ Qt:: +/qt.core.namespace.Orientations expandingDirections() const;
137     override int count() const;
138 
139     final int rowCount() const;
140 
141 /+ #if 0
142     void dump() const;
143 #endif +/
144 
145 private:
146     final void resetFieldGrowthPolicy();
147     final void resetRowWrapPolicy();
148     final void resetLabelAlignment();
149     final void resetFormAlignment();
150 }
151 
152 /+ Q_DECLARE_TYPEINFO(QFormLayout::TakeRowResult, Q_PRIMITIVE_TYPE); +/
153