1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the QtDeclarative 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 http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://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 2.1 or version 3 as published by the Free
20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22 ** following information to ensure the GNU Lesser General Public License
23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 **
26 ** As a special exception, The Qt Company gives you certain additional
27 ** rights. These rights are described in The Qt Company LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 **
30 ** GNU General Public License Usage
31 ** Alternatively, this file may be used under the terms of the GNU
32 ** General Public License version 3.0 as published by the Free Software
33 ** Foundation and appearing in the file LICENSE.GPL included in the
34 ** packaging of this file.  Please review the following information to
35 ** ensure the GNU General Public License version 3.0 requirements will be
36 ** met: http://www.gnu.org/copyleft/gpl.html.
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QDECLARATIVEANCHORS_H
43 #define QDECLARATIVEANCHORS_H
44 
45 #include "qdeclarativeitem.h"
46 
47 #include <qdeclarative.h>
48 
49 #include <QtCore/QObject>
50 
51 #include <private/qdeclarativeglobal_p.h>
52 
53 QT_BEGIN_HEADER
54 
55 QT_BEGIN_NAMESPACE
56 
57 QT_MODULE(Declarative)
58 
59 class QDeclarativeAnchorsPrivate;
60 class QDeclarativeAnchorLine;
61 class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeAnchors : public QObject
62 {
63     Q_OBJECT
64 
65     Q_PROPERTY(QDeclarativeAnchorLine left READ left WRITE setLeft RESET resetLeft NOTIFY leftChanged)
66     Q_PROPERTY(QDeclarativeAnchorLine right READ right WRITE setRight RESET resetRight NOTIFY rightChanged)
67     Q_PROPERTY(QDeclarativeAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter NOTIFY horizontalCenterChanged)
68     Q_PROPERTY(QDeclarativeAnchorLine top READ top WRITE setTop RESET resetTop NOTIFY topChanged)
69     Q_PROPERTY(QDeclarativeAnchorLine bottom READ bottom WRITE setBottom RESET resetBottom NOTIFY bottomChanged)
70     Q_PROPERTY(QDeclarativeAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter NOTIFY verticalCenterChanged)
71     Q_PROPERTY(QDeclarativeAnchorLine baseline READ baseline WRITE setBaseline RESET resetBaseline NOTIFY baselineChanged)
72     Q_PROPERTY(qreal margins READ margins WRITE setMargins NOTIFY marginsChanged)
73     Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged)
74     Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged)
75     Q_PROPERTY(qreal horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged)
76     Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged)
77     Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged)
78     Q_PROPERTY(qreal verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged)
79     Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged)
80     Q_PROPERTY(QGraphicsObject *fill READ fill WRITE setFill RESET resetFill NOTIFY fillChanged)
81     Q_PROPERTY(QGraphicsObject *centerIn READ centerIn WRITE setCenterIn RESET resetCenterIn NOTIFY centerInChanged)
82 
83 public:
84     QDeclarativeAnchors(QObject *parent=0);
85     QDeclarativeAnchors(QGraphicsObject *item, QObject *parent=0);
86     virtual ~QDeclarativeAnchors();
87 
88     enum Anchor {
89         LeftAnchor = 0x01,
90         RightAnchor = 0x02,
91         TopAnchor = 0x04,
92         BottomAnchor = 0x08,
93         HCenterAnchor = 0x10,
94         VCenterAnchor = 0x20,
95         BaselineAnchor = 0x40,
96         Horizontal_Mask = LeftAnchor | RightAnchor | HCenterAnchor,
97         Vertical_Mask = TopAnchor | BottomAnchor | VCenterAnchor | BaselineAnchor
98     };
99     Q_DECLARE_FLAGS(Anchors, Anchor)
100 
101     QDeclarativeAnchorLine left() const;
102     void setLeft(const QDeclarativeAnchorLine &edge);
103     void resetLeft();
104 
105     QDeclarativeAnchorLine right() const;
106     void setRight(const QDeclarativeAnchorLine &edge);
107     void resetRight();
108 
109     QDeclarativeAnchorLine horizontalCenter() const;
110     void setHorizontalCenter(const QDeclarativeAnchorLine &edge);
111     void resetHorizontalCenter();
112 
113     QDeclarativeAnchorLine top() const;
114     void setTop(const QDeclarativeAnchorLine &edge);
115     void resetTop();
116 
117     QDeclarativeAnchorLine bottom() const;
118     void setBottom(const QDeclarativeAnchorLine &edge);
119     void resetBottom();
120 
121     QDeclarativeAnchorLine verticalCenter() const;
122     void setVerticalCenter(const QDeclarativeAnchorLine &edge);
123     void resetVerticalCenter();
124 
125     QDeclarativeAnchorLine baseline() const;
126     void setBaseline(const QDeclarativeAnchorLine &edge);
127     void resetBaseline();
128 
129     qreal leftMargin() const;
130     void setLeftMargin(qreal);
131 
132     qreal rightMargin() const;
133     void setRightMargin(qreal);
134 
135     qreal horizontalCenterOffset() const;
136     void setHorizontalCenterOffset(qreal);
137 
138     qreal topMargin() const;
139     void setTopMargin(qreal);
140 
141     qreal bottomMargin() const;
142     void setBottomMargin(qreal);
143 
144     qreal margins() const;
145     void setMargins(qreal);
146 
147     qreal verticalCenterOffset() const;
148     void setVerticalCenterOffset(qreal);
149 
150     qreal baselineOffset() const;
151     void setBaselineOffset(qreal);
152 
153     QGraphicsObject *fill() const;
154     void setFill(QGraphicsObject *);
155     void resetFill();
156 
157     QGraphicsObject *centerIn() const;
158     void setCenterIn(QGraphicsObject *);
159     void resetCenterIn();
160 
161     Anchors usedAnchors() const;
162 
163     void classBegin();
164     void componentComplete();
165 
166     bool mirrored();
167 
168 Q_SIGNALS:
169     void leftChanged();
170     void rightChanged();
171     void topChanged();
172     void bottomChanged();
173     void verticalCenterChanged();
174     void horizontalCenterChanged();
175     void baselineChanged();
176     void fillChanged();
177     void centerInChanged();
178     void leftMarginChanged();
179     void rightMarginChanged();
180     void topMarginChanged();
181     void bottomMarginChanged();
182     void marginsChanged();
183     void verticalCenterOffsetChanged();
184     void horizontalCenterOffsetChanged();
185     void baselineOffsetChanged();
186 
187 private:
188     friend class QDeclarativeItem;
189     friend class QDeclarativeItemPrivate;
190     friend class QDeclarativeGraphicsWidget;
191     Q_DISABLE_COPY(QDeclarativeAnchors)
192     Q_DECLARE_PRIVATE(QDeclarativeAnchors)
193     Q_PRIVATE_SLOT(d_func(), void _q_widgetGeometryChanged())
194     Q_PRIVATE_SLOT(d_func(), void _q_widgetDestroyed(QObject *obj))
195 };
196 Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeAnchors::Anchors)
197 
198 QT_END_NAMESPACE
199 
200 QML_DECLARE_TYPE(QDeclarativeAnchors)
201 
202 QT_END_HEADER
203 
204 #endif
205