Initial import from the monolithic Qt.
[profile/ivi/qtdeclarative.git] / src / declarative / graphicsitems / qdeclarativeanchors_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 **
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
14 ** this package.
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 **
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.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **
32 **
33 **
34 **
35 **
36 **
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     Q_PROPERTY(bool mirrored READ mirrored NOTIFY mirroredChanged REVISION 1)
83
84 public:
85     QDeclarativeAnchors(QObject *parent=0);
86     QDeclarativeAnchors(QGraphicsObject *item, QObject *parent=0);
87     virtual ~QDeclarativeAnchors();
88
89     enum Anchor {
90         LeftAnchor = 0x01,
91         RightAnchor = 0x02,
92         TopAnchor = 0x04,
93         BottomAnchor = 0x08,
94         HCenterAnchor = 0x10,
95         VCenterAnchor = 0x20,
96         BaselineAnchor = 0x40,
97         Horizontal_Mask = LeftAnchor | RightAnchor | HCenterAnchor,
98         Vertical_Mask = TopAnchor | BottomAnchor | VCenterAnchor | BaselineAnchor
99     };
100     Q_DECLARE_FLAGS(Anchors, Anchor)
101
102     QDeclarativeAnchorLine left() const;
103     void setLeft(const QDeclarativeAnchorLine &edge);
104     void resetLeft();
105
106     QDeclarativeAnchorLine right() const;
107     void setRight(const QDeclarativeAnchorLine &edge);
108     void resetRight();
109
110     QDeclarativeAnchorLine horizontalCenter() const;
111     void setHorizontalCenter(const QDeclarativeAnchorLine &edge);
112     void resetHorizontalCenter();
113
114     QDeclarativeAnchorLine top() const;
115     void setTop(const QDeclarativeAnchorLine &edge);
116     void resetTop();
117
118     QDeclarativeAnchorLine bottom() const;
119     void setBottom(const QDeclarativeAnchorLine &edge);
120     void resetBottom();
121
122     QDeclarativeAnchorLine verticalCenter() const;
123     void setVerticalCenter(const QDeclarativeAnchorLine &edge);
124     void resetVerticalCenter();
125
126     QDeclarativeAnchorLine baseline() const;
127     void setBaseline(const QDeclarativeAnchorLine &edge);
128     void resetBaseline();
129
130     qreal leftMargin() const;
131     void setLeftMargin(qreal);
132
133     qreal rightMargin() const;
134     void setRightMargin(qreal);
135
136     qreal horizontalCenterOffset() const;
137     void setHorizontalCenterOffset(qreal);
138
139     qreal topMargin() const;
140     void setTopMargin(qreal);
141
142     qreal bottomMargin() const;
143     void setBottomMargin(qreal);
144
145     qreal margins() const;
146     void setMargins(qreal);
147
148     qreal verticalCenterOffset() const;
149     void setVerticalCenterOffset(qreal);
150
151     qreal baselineOffset() const;
152     void setBaselineOffset(qreal);
153
154     QGraphicsObject *fill() const;
155     void setFill(QGraphicsObject *);
156     void resetFill();
157
158     QGraphicsObject *centerIn() const;
159     void setCenterIn(QGraphicsObject *);
160     void resetCenterIn();
161
162     Anchors usedAnchors() const;
163
164     void classBegin();
165     void componentComplete();
166
167     bool mirrored();
168
169 Q_SIGNALS:
170     void leftChanged();
171     void rightChanged();
172     void topChanged();
173     void bottomChanged();
174     void verticalCenterChanged();
175     void horizontalCenterChanged();
176     void baselineChanged();
177     void fillChanged();
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();
188
189 private:
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))
197 };
198 Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeAnchors::Anchors)
199
200 QT_END_NAMESPACE
201
202 QML_DECLARE_TYPE(QDeclarativeAnchors)
203
204 QT_END_HEADER
205
206 #endif