1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtQuick module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QQUICKANCHORS_P_H
41#define QQUICKANCHORS_P_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists purely as an
48// implementation detail. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include <qqml.h>
55
56#include <QtCore/QObject>
57
58#include <private/qtquickglobal_p.h>
59
60QT_BEGIN_NAMESPACE
61
62class QQuickItem;
63class QQuickAnchorsPrivate;
64class QQuickAnchorLine;
65class Q_QUICK_PRIVATE_EXPORT QQuickAnchors : public QObject
66{
67 Q_OBJECT
68
69 Q_PROPERTY(QQuickAnchorLine left READ left WRITE setLeft RESET resetLeft NOTIFY leftChanged)
70 Q_PROPERTY(QQuickAnchorLine right READ right WRITE setRight RESET resetRight NOTIFY rightChanged)
71 Q_PROPERTY(QQuickAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter NOTIFY horizontalCenterChanged)
72 Q_PROPERTY(QQuickAnchorLine top READ top WRITE setTop RESET resetTop NOTIFY topChanged)
73 Q_PROPERTY(QQuickAnchorLine bottom READ bottom WRITE setBottom RESET resetBottom NOTIFY bottomChanged)
74 Q_PROPERTY(QQuickAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter NOTIFY verticalCenterChanged)
75 Q_PROPERTY(QQuickAnchorLine baseline READ baseline WRITE setBaseline RESET resetBaseline NOTIFY baselineChanged)
76 Q_PROPERTY(qreal margins READ margins WRITE setMargins NOTIFY marginsChanged)
77 Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin RESET resetLeftMargin NOTIFY leftMarginChanged)
78 Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin RESET resetRightMargin NOTIFY rightMarginChanged)
79 Q_PROPERTY(qreal horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged)
80 Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin RESET resetTopMargin NOTIFY topMarginChanged)
81 Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin RESET resetBottomMargin NOTIFY bottomMarginChanged)
82 Q_PROPERTY(qreal verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged)
83 Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged)
84 Q_PROPERTY(QQuickItem *fill READ fill WRITE setFill RESET resetFill NOTIFY fillChanged)
85 Q_PROPERTY(QQuickItem *centerIn READ centerIn WRITE setCenterIn RESET resetCenterIn NOTIFY centerInChanged)
86 Q_PROPERTY(bool alignWhenCentered READ alignWhenCentered WRITE setAlignWhenCentered NOTIFY centerAlignedChanged)
87 QML_ANONYMOUS
88
89public:
90 QQuickAnchors(QQuickItem *item, QObject *parent=nullptr);
91 ~QQuickAnchors() override;
92
93 enum Anchor
94#if defined(Q_CC_CLANG) || !defined(Q_CC_GNU) // meaning: clang and msvc, but NOT gcc proper (because, you know, Q_CC_CLANG implies Q_CC_GNU)
95 // Not specifying the enum base type will have MSVC 'interpret' it as signed instead of an unsigned bit-field.
96 // However, specifying the enum base type breaks many GCCs, which complain that it can't store all values in a 7 bit bitfield.
97 : uint
98#endif
99 {
100 InvalidAnchor = 0x0,
101 LeftAnchor = 0x01,
102 RightAnchor = 0x02,
103 TopAnchor = 0x04,
104 BottomAnchor = 0x08,
105 HCenterAnchor = 0x10,
106 VCenterAnchor = 0x20,
107 BaselineAnchor = 0x40,
108 Horizontal_Mask = LeftAnchor | RightAnchor | HCenterAnchor,
109 Vertical_Mask = TopAnchor | BottomAnchor | VCenterAnchor | BaselineAnchor
110 };
111 Q_DECLARE_FLAGS(Anchors, Anchor)
112 Q_FLAG(Anchors)
113
114 QQuickAnchorLine left() const;
115 void setLeft(const QQuickAnchorLine &edge);
116 void resetLeft();
117
118 QQuickAnchorLine right() const;
119 void setRight(const QQuickAnchorLine &edge);
120 void resetRight();
121
122 QQuickAnchorLine horizontalCenter() const;
123 void setHorizontalCenter(const QQuickAnchorLine &edge);
124 void resetHorizontalCenter();
125
126 QQuickAnchorLine top() const;
127 void setTop(const QQuickAnchorLine &edge);
128 void resetTop();
129
130 QQuickAnchorLine bottom() const;
131 void setBottom(const QQuickAnchorLine &edge);
132 void resetBottom();
133
134 QQuickAnchorLine verticalCenter() const;
135 void setVerticalCenter(const QQuickAnchorLine &edge);
136 void resetVerticalCenter();
137
138 QQuickAnchorLine baseline() const;
139 void setBaseline(const QQuickAnchorLine &edge);
140 void resetBaseline();
141
142 qreal leftMargin() const;
143 void setLeftMargin(qreal);
144 void resetLeftMargin();
145
146 qreal rightMargin() const;
147 void setRightMargin(qreal);
148 void resetRightMargin();
149
150 qreal horizontalCenterOffset() const;
151 void setHorizontalCenterOffset(qreal);
152
153 qreal topMargin() const;
154 void setTopMargin(qreal);
155 void resetTopMargin();
156
157 qreal bottomMargin() const;
158 void setBottomMargin(qreal);
159 void resetBottomMargin();
160
161 qreal margins() const;
162 void setMargins(qreal);
163
164 qreal verticalCenterOffset() const;
165 void setVerticalCenterOffset(qreal);
166
167 qreal baselineOffset() const;
168 void setBaselineOffset(qreal);
169
170 QQuickItem *fill() const;
171 void setFill(QQuickItem *);
172 void resetFill();
173
174 QQuickItem *centerIn() const;
175 void setCenterIn(QQuickItem *);
176 void resetCenterIn();
177
178 Anchors usedAnchors() const;
179 Qt::Orientations activeDirections() const;
180
181 bool mirrored();
182
183 bool alignWhenCentered() const;
184 void setAlignWhenCentered(bool);
185
186 void classBegin();
187 void componentComplete();
188
189Q_SIGNALS:
190 void leftChanged();
191 void rightChanged();
192 void topChanged();
193 void bottomChanged();
194 void verticalCenterChanged();
195 void horizontalCenterChanged();
196 void baselineChanged();
197 void fillChanged();
198 void centerInChanged();
199 void leftMarginChanged();
200 void rightMarginChanged();
201 void topMarginChanged();
202 void bottomMarginChanged();
203 void marginsChanged();
204 void verticalCenterOffsetChanged();
205 void horizontalCenterOffsetChanged();
206 void baselineOffsetChanged();
207 void centerAlignedChanged();
208
209private:
210 friend class QQuickItemPrivate;
211 Q_DISABLE_COPY(QQuickAnchors)
212 Q_DECLARE_PRIVATE(QQuickAnchors)
213};
214Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickAnchors::Anchors)
215
216QT_END_NAMESPACE
217
218QML_DECLARE_TYPE(QQuickAnchors)
219
220#endif // QQUICKANCHORS_P_H
221

source code of qtdeclarative/src/quick/items/qquickanchors_p.h