Initial import from qtquick2.
[profile/ivi/qtdeclarative.git] / src / declarative / items / qsganchors_p.h
1 // Commit: 2c7cab4172f1acc86fd49345a2847417e162f2c3
2 /****************************************************************************
3 **
4 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
5 ** All rights reserved.
6 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 **
8 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 **
10 ** $QT_BEGIN_LICENSE:LGPL$
11 ** No Commercial Usage
12 ** This file contains pre-release code and may not be distributed.
13 ** You may use this file in accordance with the terms and conditions
14 ** contained in the Technology Preview License Agreement accompanying
15 ** this package.
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 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **
33 **
34 **
35 **
36 **
37 **
38 **
39 ** $QT_END_LICENSE$
40 **
41 ****************************************************************************/
42
43 #ifndef QSGANCHORS_P_H
44 #define QSGANCHORS_P_H
45
46 #include <qdeclarative.h>
47
48 #include <QtCore/QObject>
49
50 #include <private/qdeclarativeglobal_p.h>
51
52 QT_BEGIN_HEADER
53
54 QT_BEGIN_NAMESPACE
55
56 QT_MODULE(Declarative)
57
58 class QSGItem;
59 class QSGAnchorsPrivate;
60 class QSGAnchorLine;
61 class Q_DECLARATIVE_PRIVATE_EXPORT QSGAnchors : public QObject
62 {
63     Q_OBJECT
64
65     Q_PROPERTY(QSGAnchorLine left READ left WRITE setLeft RESET resetLeft NOTIFY leftChanged)
66     Q_PROPERTY(QSGAnchorLine right READ right WRITE setRight RESET resetRight NOTIFY rightChanged)
67     Q_PROPERTY(QSGAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter NOTIFY horizontalCenterChanged)
68     Q_PROPERTY(QSGAnchorLine top READ top WRITE setTop RESET resetTop NOTIFY topChanged)
69     Q_PROPERTY(QSGAnchorLine bottom READ bottom WRITE setBottom RESET resetBottom NOTIFY bottomChanged)
70     Q_PROPERTY(QSGAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter NOTIFY verticalCenterChanged)
71     Q_PROPERTY(QSGAnchorLine 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(QSGItem *fill READ fill WRITE setFill RESET resetFill NOTIFY fillChanged)
81     Q_PROPERTY(QSGItem *centerIn READ centerIn WRITE setCenterIn RESET resetCenterIn NOTIFY centerInChanged)
82     Q_PROPERTY(bool mirrored READ mirrored NOTIFY mirroredChanged)
83
84 public:
85     QSGAnchors(QSGItem *item, QObject *parent=0);
86     virtual ~QSGAnchors();
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     QSGAnchorLine left() const;
102     void setLeft(const QSGAnchorLine &edge);
103     void resetLeft();
104
105     QSGAnchorLine right() const;
106     void setRight(const QSGAnchorLine &edge);
107     void resetRight();
108
109     QSGAnchorLine horizontalCenter() const;
110     void setHorizontalCenter(const QSGAnchorLine &edge);
111     void resetHorizontalCenter();
112
113     QSGAnchorLine top() const;
114     void setTop(const QSGAnchorLine &edge);
115     void resetTop();
116
117     QSGAnchorLine bottom() const;
118     void setBottom(const QSGAnchorLine &edge);
119     void resetBottom();
120
121     QSGAnchorLine verticalCenter() const;
122     void setVerticalCenter(const QSGAnchorLine &edge);
123     void resetVerticalCenter();
124
125     QSGAnchorLine baseline() const;
126     void setBaseline(const QSGAnchorLine &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     QSGItem *fill() const;
154     void setFill(QSGItem *);
155     void resetFill();
156
157     QSGItem *centerIn() const;
158     void setCenterIn(QSGItem *);
159     void resetCenterIn();
160
161     Anchors usedAnchors() const;
162
163     bool mirrored();
164
165     void classBegin();
166     void componentComplete();
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     void mirroredChanged();
187
188 private:
189     friend class QSGItemPrivate;
190     Q_DISABLE_COPY(QSGAnchors)
191     Q_DECLARE_PRIVATE(QSGAnchors)
192 };
193 Q_DECLARE_OPERATORS_FOR_FLAGS(QSGAnchors::Anchors)
194
195 QT_END_NAMESPACE
196
197 QML_DECLARE_TYPE(QSGAnchors)
198
199 QT_END_HEADER
200
201 #endif // QSGANCHORS_P_H