1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
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 class QDeclarative1BasePositionerPrivate;
59 class Q_QTQUICK1_EXPORT QDeclarative1BasePositioner : public QDeclarative1ImplicitSizeItem
63 Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
64 Q_PROPERTY(QDeclarative1Transition *move READ move WRITE setMove NOTIFY moveChanged)
65 Q_PROPERTY(QDeclarative1Transition *add READ add WRITE setAdd NOTIFY addChanged)
67 enum PositionerType { None = 0x0, Horizontal = 0x1, Vertical = 0x2, Both = 0x3 };
68 QDeclarative1BasePositioner(PositionerType, QDeclarativeItem *parent);
69 ~QDeclarative1BasePositioner();
74 QDeclarative1Transition *move() const;
75 void setMove(QDeclarative1Transition *);
77 QDeclarative1Transition *add() const;
78 void setAdd(QDeclarative1Transition *);
81 QDeclarative1BasePositioner(QDeclarative1BasePositionerPrivate &dd, PositionerType at, QDeclarativeItem *parent);
82 virtual void componentComplete();
83 virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
84 void finishApplyTransitions();
87 void spacingChanged();
92 void prePositioning();
93 void graphicsWidgetGeometryChanged();
96 virtual void doPositioning(QSizeF *contentSize)=0;
97 virtual void reportConflictingAnchors()=0;
98 class PositionedItem {
100 PositionedItem(QGraphicsObject *i) : item(i), isNew(false), isVisible(true) {}
101 bool operator==(const PositionedItem &other) const { return other.item == item; }
102 QGraphicsObject *item;
107 QPODVector<PositionedItem,8> positionedItems;
108 void positionX(int,const PositionedItem &target);
109 void positionY(int,const PositionedItem &target);
112 Q_DISABLE_COPY(QDeclarative1BasePositioner)
113 Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1BasePositioner)
116 class Q_AUTOTEST_EXPORT QDeclarative1Column : public QDeclarative1BasePositioner
120 QDeclarative1Column(QDeclarativeItem *parent=0);
122 virtual void doPositioning(QSizeF *contentSize);
123 virtual void reportConflictingAnchors();
125 Q_DISABLE_COPY(QDeclarative1Column)
128 class Q_AUTOTEST_EXPORT QDeclarative1Row: public QDeclarative1BasePositioner
131 Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged REVISION 1)
132 Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged REVISION 1)
134 QDeclarative1Row(QDeclarativeItem *parent=0);
136 Qt::LayoutDirection layoutDirection() const;
137 void setLayoutDirection (Qt::LayoutDirection);
138 Qt::LayoutDirection effectiveLayoutDirection() const;
141 Q_REVISION(1) void layoutDirectionChanged();
142 Q_REVISION(1) void effectiveLayoutDirectionChanged();
145 virtual void doPositioning(QSizeF *contentSize);
146 virtual void reportConflictingAnchors();
148 Q_DISABLE_COPY(QDeclarative1Row)
151 class Q_AUTOTEST_EXPORT QDeclarative1Grid : public QDeclarative1BasePositioner
154 Q_PROPERTY(int rows READ rows WRITE setRows NOTIFY rowsChanged)
155 Q_PROPERTY(int columns READ columns WRITE setColumns NOTIFY columnsChanged)
156 Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
157 Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged REVISION 1)
158 Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged REVISION 1)
160 QDeclarative1Grid(QDeclarativeItem *parent=0);
162 int rows() const {return m_rows;}
163 void setRows(const int rows);
165 int columns() const {return m_columns;}
166 void setColumns(const int columns);
169 enum Flow { LeftToRight, TopToBottom };
173 Qt::LayoutDirection layoutDirection() const;
174 void setLayoutDirection (Qt::LayoutDirection);
175 Qt::LayoutDirection effectiveLayoutDirection() const;
179 void columnsChanged();
181 Q_REVISION(1) void layoutDirectionChanged();
182 Q_REVISION(1) void effectiveLayoutDirectionChanged();
185 virtual void doPositioning(QSizeF *contentSize);
186 virtual void reportConflictingAnchors();
192 Q_DISABLE_COPY(QDeclarative1Grid)
195 class QDeclarative1FlowPrivate;
196 class Q_AUTOTEST_EXPORT QDeclarative1Flow: public QDeclarative1BasePositioner
199 Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
200 Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged REVISION 1)
201 Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged REVISION 1)
203 QDeclarative1Flow(QDeclarativeItem *parent=0);
206 enum Flow { LeftToRight, TopToBottom };
210 Qt::LayoutDirection layoutDirection() const;
211 void setLayoutDirection (Qt::LayoutDirection);
212 Qt::LayoutDirection effectiveLayoutDirection() const;
215 Q_REVISION(1) void layoutDirectionChanged();
216 Q_REVISION(1) void effectiveLayoutDirectionChanged();
219 virtual void doPositioning(QSizeF *contentSize);
220 virtual void reportConflictingAnchors();
222 QDeclarative1Flow(QDeclarative1FlowPrivate &dd, QDeclarativeItem *parent);
224 Q_DISABLE_COPY(QDeclarative1Flow)
225 Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Flow)
231 QML_DECLARE_TYPE(QDeclarative1Column)
232 QML_DECLARE_TYPE(QDeclarative1Row)
233 QML_DECLARE_TYPE(QDeclarative1Grid)
234 QML_DECLARE_TYPE(QDeclarative1Flow)