1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
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.
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.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
42 #ifndef QDECLARATIVEANCHORS_H
43 #define QDECLARATIVEANCHORS_H
45 #include "qdeclarativeitem.h"
47 #include <qdeclarative.h>
49 #include <QtCore/QObject>
51 #include <private/qdeclarativeglobal_p.h>
57 QT_MODULE(Declarative)
59 class QDeclarativeAnchorsPrivate;
60 class QDeclarativeAnchorLine;
61 class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeAnchors : public QObject
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 Q_PROPERTY(bool mirrored READ mirrored NOTIFY mirroredChanged REVISION 1)
85 QDeclarativeAnchors(QObject *parent=0);
86 QDeclarativeAnchors(QGraphicsObject *item, QObject *parent=0);
87 virtual ~QDeclarativeAnchors();
96 BaselineAnchor = 0x40,
97 Horizontal_Mask = LeftAnchor | RightAnchor | HCenterAnchor,
98 Vertical_Mask = TopAnchor | BottomAnchor | VCenterAnchor | BaselineAnchor
100 Q_DECLARE_FLAGS(Anchors, Anchor)
102 QDeclarativeAnchorLine left() const;
103 void setLeft(const QDeclarativeAnchorLine &edge);
106 QDeclarativeAnchorLine right() const;
107 void setRight(const QDeclarativeAnchorLine &edge);
110 QDeclarativeAnchorLine horizontalCenter() const;
111 void setHorizontalCenter(const QDeclarativeAnchorLine &edge);
112 void resetHorizontalCenter();
114 QDeclarativeAnchorLine top() const;
115 void setTop(const QDeclarativeAnchorLine &edge);
118 QDeclarativeAnchorLine bottom() const;
119 void setBottom(const QDeclarativeAnchorLine &edge);
122 QDeclarativeAnchorLine verticalCenter() const;
123 void setVerticalCenter(const QDeclarativeAnchorLine &edge);
124 void resetVerticalCenter();
126 QDeclarativeAnchorLine baseline() const;
127 void setBaseline(const QDeclarativeAnchorLine &edge);
128 void resetBaseline();
130 qreal leftMargin() const;
131 void setLeftMargin(qreal);
133 qreal rightMargin() const;
134 void setRightMargin(qreal);
136 qreal horizontalCenterOffset() const;
137 void setHorizontalCenterOffset(qreal);
139 qreal topMargin() const;
140 void setTopMargin(qreal);
142 qreal bottomMargin() const;
143 void setBottomMargin(qreal);
145 qreal margins() const;
146 void setMargins(qreal);
148 qreal verticalCenterOffset() const;
149 void setVerticalCenterOffset(qreal);
151 qreal baselineOffset() const;
152 void setBaselineOffset(qreal);
154 QGraphicsObject *fill() const;
155 void setFill(QGraphicsObject *);
158 QGraphicsObject *centerIn() const;
159 void setCenterIn(QGraphicsObject *);
160 void resetCenterIn();
162 Anchors usedAnchors() const;
165 void componentComplete();
173 void bottomChanged();
174 void verticalCenterChanged();
175 void horizontalCenterChanged();
176 void baselineChanged();
178 void centerInChanged();
179 void leftMarginChanged();
180 void rightMarginChanged();
181 void topMarginChanged();
182 void bottomMarginChanged();
183 void marginsChanged();
184 void verticalCenterOffsetChanged();
185 void horizontalCenterOffsetChanged();
186 void baselineOffsetChanged();
187 Q_REVISION(1) void mirroredChanged();
190 friend class QDeclarativeItem;
191 friend class QDeclarativeItemPrivate;
192 friend class QDeclarativeGraphicsWidget;
193 Q_DISABLE_COPY(QDeclarativeAnchors)
194 Q_DECLARE_PRIVATE(QDeclarativeAnchors)
195 Q_PRIVATE_SLOT(d_func(), void _q_widgetGeometryChanged())
196 Q_PRIVATE_SLOT(d_func(), void _q_widgetDestroyed(QObject *obj))
198 Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeAnchors::Anchors)
202 QML_DECLARE_TYPE(QDeclarativeAnchors)