|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 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 QT_BEGIN_HEADER |
|
52 |
|
53 QT_BEGIN_NAMESPACE |
|
54 |
|
55 QT_MODULE(Declarative) |
|
56 |
|
57 class QDeclarativeAnchorsPrivate; |
|
58 class QDeclarativeAnchorLine; |
|
59 class Q_DECLARATIVE_EXPORT QDeclarativeAnchors : public QObject |
|
60 { |
|
61 Q_OBJECT |
|
62 |
|
63 Q_PROPERTY(QDeclarativeAnchorLine left READ left WRITE setLeft RESET resetLeft NOTIFY leftChanged) |
|
64 Q_PROPERTY(QDeclarativeAnchorLine right READ right WRITE setRight RESET resetRight NOTIFY rightChanged) |
|
65 Q_PROPERTY(QDeclarativeAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter NOTIFY horizontalCenterChanged) |
|
66 Q_PROPERTY(QDeclarativeAnchorLine top READ top WRITE setTop RESET resetTop NOTIFY topChanged) |
|
67 Q_PROPERTY(QDeclarativeAnchorLine bottom READ bottom WRITE setBottom RESET resetBottom NOTIFY bottomChanged) |
|
68 Q_PROPERTY(QDeclarativeAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter NOTIFY verticalCenterChanged) |
|
69 Q_PROPERTY(QDeclarativeAnchorLine baseline READ baseline WRITE setBaseline RESET resetBaseline NOTIFY baselineChanged) |
|
70 Q_PROPERTY(qreal margins READ margins WRITE setMargins NOTIFY marginsChanged) |
|
71 Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged) |
|
72 Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged) |
|
73 Q_PROPERTY(qreal horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged()) |
|
74 Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged) |
|
75 Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged) |
|
76 Q_PROPERTY(qreal verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged()) |
|
77 Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged()) |
|
78 Q_PROPERTY(QGraphicsObject *fill READ fill WRITE setFill RESET resetFill NOTIFY fillChanged) |
|
79 Q_PROPERTY(QGraphicsObject *centerIn READ centerIn WRITE setCenterIn RESET resetCenterIn NOTIFY centerInChanged) |
|
80 |
|
81 public: |
|
82 QDeclarativeAnchors(QObject *parent=0); |
|
83 QDeclarativeAnchors(QGraphicsObject *item, QObject *parent=0); |
|
84 virtual ~QDeclarativeAnchors(); |
|
85 |
|
86 enum Anchor { |
|
87 LeftAnchor = 0x01, |
|
88 RightAnchor = 0x02, |
|
89 TopAnchor = 0x04, |
|
90 BottomAnchor = 0x08, |
|
91 HCenterAnchor = 0x10, |
|
92 VCenterAnchor = 0x20, |
|
93 BaselineAnchor = 0x40, |
|
94 Horizontal_Mask = LeftAnchor | RightAnchor | HCenterAnchor, |
|
95 Vertical_Mask = TopAnchor | BottomAnchor | VCenterAnchor | BaselineAnchor |
|
96 }; |
|
97 Q_DECLARE_FLAGS(Anchors, Anchor) |
|
98 |
|
99 QDeclarativeAnchorLine left() const; |
|
100 void setLeft(const QDeclarativeAnchorLine &edge); |
|
101 void resetLeft(); |
|
102 |
|
103 QDeclarativeAnchorLine right() const; |
|
104 void setRight(const QDeclarativeAnchorLine &edge); |
|
105 void resetRight(); |
|
106 |
|
107 QDeclarativeAnchorLine horizontalCenter() const; |
|
108 void setHorizontalCenter(const QDeclarativeAnchorLine &edge); |
|
109 void resetHorizontalCenter(); |
|
110 |
|
111 QDeclarativeAnchorLine top() const; |
|
112 void setTop(const QDeclarativeAnchorLine &edge); |
|
113 void resetTop(); |
|
114 |
|
115 QDeclarativeAnchorLine bottom() const; |
|
116 void setBottom(const QDeclarativeAnchorLine &edge); |
|
117 void resetBottom(); |
|
118 |
|
119 QDeclarativeAnchorLine verticalCenter() const; |
|
120 void setVerticalCenter(const QDeclarativeAnchorLine &edge); |
|
121 void resetVerticalCenter(); |
|
122 |
|
123 QDeclarativeAnchorLine baseline() const; |
|
124 void setBaseline(const QDeclarativeAnchorLine &edge); |
|
125 void resetBaseline(); |
|
126 |
|
127 qreal leftMargin() const; |
|
128 void setLeftMargin(qreal); |
|
129 |
|
130 qreal rightMargin() const; |
|
131 void setRightMargin(qreal); |
|
132 |
|
133 qreal horizontalCenterOffset() const; |
|
134 void setHorizontalCenterOffset(qreal); |
|
135 |
|
136 qreal topMargin() const; |
|
137 void setTopMargin(qreal); |
|
138 |
|
139 qreal bottomMargin() const; |
|
140 void setBottomMargin(qreal); |
|
141 |
|
142 qreal margins() const; |
|
143 void setMargins(qreal); |
|
144 |
|
145 qreal verticalCenterOffset() const; |
|
146 void setVerticalCenterOffset(qreal); |
|
147 |
|
148 qreal baselineOffset() const; |
|
149 void setBaselineOffset(qreal); |
|
150 |
|
151 QGraphicsObject *fill() const; |
|
152 void setFill(QGraphicsObject *); |
|
153 void resetFill(); |
|
154 |
|
155 QGraphicsObject *centerIn() const; |
|
156 void setCenterIn(QGraphicsObject *); |
|
157 void resetCenterIn(); |
|
158 |
|
159 Anchors usedAnchors() const; |
|
160 |
|
161 void classBegin(); |
|
162 void componentComplete(); |
|
163 |
|
164 Q_SIGNALS: |
|
165 void leftChanged(); |
|
166 void rightChanged(); |
|
167 void topChanged(); |
|
168 void bottomChanged(); |
|
169 void verticalCenterChanged(); |
|
170 void horizontalCenterChanged(); |
|
171 void baselineChanged(); |
|
172 void fillChanged(); |
|
173 void centerInChanged(); |
|
174 void leftMarginChanged(); |
|
175 void rightMarginChanged(); |
|
176 void topMarginChanged(); |
|
177 void bottomMarginChanged(); |
|
178 void marginsChanged(); |
|
179 void verticalCenterOffsetChanged(); |
|
180 void horizontalCenterOffsetChanged(); |
|
181 void baselineOffsetChanged(); |
|
182 |
|
183 private: |
|
184 friend class QDeclarativeItem; |
|
185 friend class QDeclarativeGraphicsWidget; |
|
186 Q_DISABLE_COPY(QDeclarativeAnchors) |
|
187 Q_DECLARE_PRIVATE(QDeclarativeAnchors) |
|
188 Q_PRIVATE_SLOT(d_func(), void _q_widgetGeometryChanged()) |
|
189 Q_PRIVATE_SLOT(d_func(), void _q_widgetDestroyed(QObject *obj)) |
|
190 }; |
|
191 Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeAnchors::Anchors) |
|
192 |
|
193 QT_END_NAMESPACE |
|
194 |
|
195 QML_DECLARE_TYPE(QDeclarativeAnchors) |
|
196 |
|
197 QT_END_HEADER |
|
198 |
|
199 #endif |