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 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QDECLARATIVELAYOUTS_H
43 #define QDECLARATIVELAYOUTS_H
45 #include "qdeclarativeimplicitsizeitem_p.h"
47 #include <QtQuick1/private/qdeclarativestate_p.h>
48 #include <private/qpodvector_p.h>
50 #include <QtCore/QObject>
51 #include <QtCore/QString>
57 QT_MODULE(Declarative)
58 class QDeclarative1BasePositionerPrivate;
60 class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarative1BasePositioner : public QDeclarative1ImplicitSizeItem
64 Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
65 Q_PROPERTY(QDeclarative1Transition *move READ move WRITE setMove NOTIFY moveChanged)
66 Q_PROPERTY(QDeclarative1Transition *add READ add WRITE setAdd NOTIFY addChanged)
68 enum PositionerType { None = 0x0, Horizontal = 0x1, Vertical = 0x2, Both = 0x3 };
69 QDeclarative1BasePositioner(PositionerType, QDeclarativeItem *parent);
70 ~QDeclarative1BasePositioner();
75 QDeclarative1Transition *move() const;
76 void setMove(QDeclarative1Transition *);
78 QDeclarative1Transition *add() const;
79 void setAdd(QDeclarative1Transition *);
82 QDeclarative1BasePositioner(QDeclarative1BasePositionerPrivate &dd, PositionerType at, QDeclarativeItem *parent);
83 virtual void componentComplete();
84 virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
85 void finishApplyTransitions();
88 void spacingChanged();
93 void prePositioning();
94 void graphicsWidgetGeometryChanged();
97 virtual void doPositioning(QSizeF *contentSize)=0;
98 virtual void reportConflictingAnchors()=0;
99 class PositionedItem {
101 PositionedItem(QGraphicsObject *i) : item(i), isNew(false), isVisible(true) {}
102 bool operator==(const PositionedItem &other) const { return other.item == item; }
103 QGraphicsObject *item;
108 QPODVector<PositionedItem,8> positionedItems;
109 void positionX(int,const PositionedItem &target);
110 void positionY(int,const PositionedItem &target);
113 Q_DISABLE_COPY(QDeclarative1BasePositioner)
114 Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1BasePositioner)
117 class Q_AUTOTEST_EXPORT QDeclarative1Column : public QDeclarative1BasePositioner
121 QDeclarative1Column(QDeclarativeItem *parent=0);
123 virtual void doPositioning(QSizeF *contentSize);
124 virtual void reportConflictingAnchors();
126 Q_DISABLE_COPY(QDeclarative1Column)
129 class Q_AUTOTEST_EXPORT QDeclarative1Row: public QDeclarative1BasePositioner
132 Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged REVISION 1)
133 Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged REVISION 1)
135 QDeclarative1Row(QDeclarativeItem *parent=0);
137 Qt::LayoutDirection layoutDirection() const;
138 void setLayoutDirection (Qt::LayoutDirection);
139 Qt::LayoutDirection effectiveLayoutDirection() const;
142 Q_REVISION(1) void layoutDirectionChanged();
143 Q_REVISION(1) void effectiveLayoutDirectionChanged();
146 virtual void doPositioning(QSizeF *contentSize);
147 virtual void reportConflictingAnchors();
149 Q_DISABLE_COPY(QDeclarative1Row)
152 class Q_AUTOTEST_EXPORT QDeclarative1Grid : public QDeclarative1BasePositioner
155 Q_PROPERTY(int rows READ rows WRITE setRows NOTIFY rowsChanged)
156 Q_PROPERTY(int columns READ columns WRITE setColumns NOTIFY columnsChanged)
157 Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
158 Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged REVISION 1)
159 Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged REVISION 1)
161 QDeclarative1Grid(QDeclarativeItem *parent=0);
163 int rows() const {return m_rows;}
164 void setRows(const int rows);
166 int columns() const {return m_columns;}
167 void setColumns(const int columns);
170 enum Flow { LeftToRight, TopToBottom };
174 Qt::LayoutDirection layoutDirection() const;
175 void setLayoutDirection (Qt::LayoutDirection);
176 Qt::LayoutDirection effectiveLayoutDirection() const;
180 void columnsChanged();
182 Q_REVISION(1) void layoutDirectionChanged();
183 Q_REVISION(1) void effectiveLayoutDirectionChanged();
186 virtual void doPositioning(QSizeF *contentSize);
187 virtual void reportConflictingAnchors();
193 Q_DISABLE_COPY(QDeclarative1Grid)
196 class QDeclarative1FlowPrivate;
197 class Q_AUTOTEST_EXPORT QDeclarative1Flow: public QDeclarative1BasePositioner
200 Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
201 Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged REVISION 1)
202 Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged REVISION 1)
204 QDeclarative1Flow(QDeclarativeItem *parent=0);
207 enum Flow { LeftToRight, TopToBottom };
211 Qt::LayoutDirection layoutDirection() const;
212 void setLayoutDirection (Qt::LayoutDirection);
213 Qt::LayoutDirection effectiveLayoutDirection() const;
216 Q_REVISION(1) void layoutDirectionChanged();
217 Q_REVISION(1) void effectiveLayoutDirectionChanged();
220 virtual void doPositioning(QSizeF *contentSize);
221 virtual void reportConflictingAnchors();
223 QDeclarative1Flow(QDeclarative1FlowPrivate &dd, QDeclarativeItem *parent);
225 Q_DISABLE_COPY(QDeclarative1Flow)
226 Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Flow)
232 QML_DECLARE_TYPE(QDeclarative1Column)
233 QML_DECLARE_TYPE(QDeclarative1Row)
234 QML_DECLARE_TYPE(QDeclarative1Grid)
235 QML_DECLARE_TYPE(QDeclarative1Flow)