1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the QtDeclarative module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
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 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QDECLARATIVELAYOUTS_H
|
---|
43 | #define QDECLARATIVELAYOUTS_H
|
---|
44 |
|
---|
45 | #include "qdeclarativeitem.h"
|
---|
46 |
|
---|
47 | #include <private/qdeclarativestate_p.h>
|
---|
48 | #include <private/qpodvector_p.h>
|
---|
49 |
|
---|
50 | #include <QtCore/QObject>
|
---|
51 | #include <QtCore/QString>
|
---|
52 |
|
---|
53 | QT_BEGIN_HEADER
|
---|
54 |
|
---|
55 | QT_BEGIN_NAMESPACE
|
---|
56 |
|
---|
57 | QT_MODULE(Declarative)
|
---|
58 | class QDeclarativeBasePositionerPrivate;
|
---|
59 |
|
---|
60 | class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeBasePositioner : public QDeclarativeItem
|
---|
61 | {
|
---|
62 | Q_OBJECT
|
---|
63 |
|
---|
64 | Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
|
---|
65 | Q_PROPERTY(QDeclarativeTransition *move READ move WRITE setMove NOTIFY moveChanged)
|
---|
66 | Q_PROPERTY(QDeclarativeTransition *add READ add WRITE setAdd NOTIFY addChanged)
|
---|
67 | public:
|
---|
68 | enum PositionerType { None = 0x0, Horizontal = 0x1, Vertical = 0x2, Both = 0x3 };
|
---|
69 | QDeclarativeBasePositioner(PositionerType, QDeclarativeItem *parent);
|
---|
70 | ~QDeclarativeBasePositioner();
|
---|
71 |
|
---|
72 | int spacing() const;
|
---|
73 | void setSpacing(int);
|
---|
74 |
|
---|
75 | QDeclarativeTransition *move() const;
|
---|
76 | void setMove(QDeclarativeTransition *);
|
---|
77 |
|
---|
78 | QDeclarativeTransition *add() const;
|
---|
79 | void setAdd(QDeclarativeTransition *);
|
---|
80 |
|
---|
81 | protected:
|
---|
82 | QDeclarativeBasePositioner(QDeclarativeBasePositionerPrivate &dd, PositionerType at, QDeclarativeItem *parent);
|
---|
83 | virtual void componentComplete();
|
---|
84 | virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
|
---|
85 | void finishApplyTransitions();
|
---|
86 |
|
---|
87 | Q_SIGNALS:
|
---|
88 | void spacingChanged();
|
---|
89 | void moveChanged();
|
---|
90 | void addChanged();
|
---|
91 |
|
---|
92 | protected Q_SLOTS:
|
---|
93 | void prePositioning();
|
---|
94 | void graphicsWidgetGeometryChanged();
|
---|
95 |
|
---|
96 | protected:
|
---|
97 | virtual void doPositioning(QSizeF *contentSize)=0;
|
---|
98 | virtual void reportConflictingAnchors()=0;
|
---|
99 | class PositionedItem {
|
---|
100 | public :
|
---|
101 | PositionedItem(QGraphicsObject *i) : item(i), isNew(false), isVisible(true) {}
|
---|
102 | bool operator==(const PositionedItem &other) const { return other.item == item; }
|
---|
103 | QGraphicsObject *item;
|
---|
104 | bool isNew;
|
---|
105 | bool isVisible;
|
---|
106 | };
|
---|
107 |
|
---|
108 | QPODVector<PositionedItem,8> positionedItems;
|
---|
109 | void positionX(int,const PositionedItem &target);
|
---|
110 | void positionY(int,const PositionedItem &target);
|
---|
111 |
|
---|
112 | private:
|
---|
113 | Q_DISABLE_COPY(QDeclarativeBasePositioner)
|
---|
114 | Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeBasePositioner)
|
---|
115 | };
|
---|
116 |
|
---|
117 | class Q_AUTOTEST_EXPORT QDeclarativeColumn : public QDeclarativeBasePositioner
|
---|
118 | {
|
---|
119 | Q_OBJECT
|
---|
120 | public:
|
---|
121 | QDeclarativeColumn(QDeclarativeItem *parent=0);
|
---|
122 | protected:
|
---|
123 | virtual void doPositioning(QSizeF *contentSize);
|
---|
124 | virtual void reportConflictingAnchors();
|
---|
125 | private:
|
---|
126 | Q_DISABLE_COPY(QDeclarativeColumn)
|
---|
127 | };
|
---|
128 |
|
---|
129 | class Q_AUTOTEST_EXPORT QDeclarativeRow: public QDeclarativeBasePositioner
|
---|
130 | {
|
---|
131 | Q_OBJECT
|
---|
132 | public:
|
---|
133 | QDeclarativeRow(QDeclarativeItem *parent=0);
|
---|
134 | protected:
|
---|
135 | virtual void doPositioning(QSizeF *contentSize);
|
---|
136 | virtual void reportConflictingAnchors();
|
---|
137 | private:
|
---|
138 | Q_DISABLE_COPY(QDeclarativeRow)
|
---|
139 | };
|
---|
140 |
|
---|
141 | class Q_AUTOTEST_EXPORT QDeclarativeGrid : public QDeclarativeBasePositioner
|
---|
142 | {
|
---|
143 | Q_OBJECT
|
---|
144 | Q_PROPERTY(int rows READ rows WRITE setRows NOTIFY rowsChanged)
|
---|
145 | Q_PROPERTY(int columns READ columns WRITE setColumns NOTIFY columnsChanged)
|
---|
146 | Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
|
---|
147 |
|
---|
148 | public:
|
---|
149 | QDeclarativeGrid(QDeclarativeItem *parent=0);
|
---|
150 |
|
---|
151 | int rows() const {return m_rows;}
|
---|
152 | void setRows(const int rows);
|
---|
153 |
|
---|
154 | int columns() const {return m_columns;}
|
---|
155 | void setColumns(const int columns);
|
---|
156 |
|
---|
157 | Q_ENUMS(Flow)
|
---|
158 | enum Flow { LeftToRight, TopToBottom };
|
---|
159 | Flow flow() const;
|
---|
160 | void setFlow(Flow);
|
---|
161 |
|
---|
162 | Q_SIGNALS:
|
---|
163 | void rowsChanged();
|
---|
164 | void columnsChanged();
|
---|
165 | void flowChanged();
|
---|
166 |
|
---|
167 | protected:
|
---|
168 | virtual void doPositioning(QSizeF *contentSize);
|
---|
169 | virtual void reportConflictingAnchors();
|
---|
170 |
|
---|
171 | private:
|
---|
172 | int m_rows;
|
---|
173 | int m_columns;
|
---|
174 | Flow m_flow;
|
---|
175 | Q_DISABLE_COPY(QDeclarativeGrid)
|
---|
176 | };
|
---|
177 |
|
---|
178 | class QDeclarativeFlowPrivate;
|
---|
179 | class Q_AUTOTEST_EXPORT QDeclarativeFlow: public QDeclarativeBasePositioner
|
---|
180 | {
|
---|
181 | Q_OBJECT
|
---|
182 | Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
|
---|
183 | public:
|
---|
184 | QDeclarativeFlow(QDeclarativeItem *parent=0);
|
---|
185 |
|
---|
186 | Q_ENUMS(Flow)
|
---|
187 | enum Flow { LeftToRight, TopToBottom };
|
---|
188 | Flow flow() const;
|
---|
189 | void setFlow(Flow);
|
---|
190 |
|
---|
191 | Q_SIGNALS:
|
---|
192 | void flowChanged();
|
---|
193 |
|
---|
194 | protected:
|
---|
195 | virtual void doPositioning(QSizeF *contentSize);
|
---|
196 | virtual void reportConflictingAnchors();
|
---|
197 | protected:
|
---|
198 | QDeclarativeFlow(QDeclarativeFlowPrivate &dd, QDeclarativeItem *parent);
|
---|
199 | private:
|
---|
200 | Q_DISABLE_COPY(QDeclarativeFlow)
|
---|
201 | Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeFlow)
|
---|
202 | };
|
---|
203 |
|
---|
204 |
|
---|
205 | QT_END_NAMESPACE
|
---|
206 |
|
---|
207 | QML_DECLARE_TYPE(QDeclarativeColumn)
|
---|
208 | QML_DECLARE_TYPE(QDeclarativeRow)
|
---|
209 | QML_DECLARE_TYPE(QDeclarativeGrid)
|
---|
210 | QML_DECLARE_TYPE(QDeclarativeFlow)
|
---|
211 |
|
---|
212 | QT_END_HEADER
|
---|
213 |
|
---|
214 | #endif
|
---|