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 QDECLARATIVEFLICKABLE_H
43 #define QDECLARATIVEFLICKABLE_H
45 #include "qdeclarativeitem.h"
51 QT_MODULE(Declarative)
53 class QDeclarative1FlickablePrivate;
54 class QDeclarative1FlickableVisibleArea;
55 class Q_AUTOTEST_EXPORT QDeclarative1Flickable : public QDeclarativeItem
59 Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged)
60 Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged)
61 Q_PROPERTY(qreal contentX READ contentX WRITE setContentX NOTIFY contentXChanged)
62 Q_PROPERTY(qreal contentY READ contentY WRITE setContentY NOTIFY contentYChanged)
63 Q_PROPERTY(QDeclarativeItem *contentItem READ contentItem CONSTANT)
65 Q_PROPERTY(qreal horizontalVelocity READ horizontalVelocity NOTIFY horizontalVelocityChanged)
66 Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged)
68 Q_PROPERTY(BoundsBehavior boundsBehavior READ boundsBehavior WRITE setBoundsBehavior NOTIFY boundsBehaviorChanged)
69 Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity NOTIFY maximumFlickVelocityChanged)
70 Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
71 Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged)
72 Q_PROPERTY(bool movingHorizontally READ isMovingHorizontally NOTIFY movingHorizontallyChanged)
73 Q_PROPERTY(bool movingVertically READ isMovingVertically NOTIFY movingVerticallyChanged)
74 Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged)
75 Q_PROPERTY(bool flickingHorizontally READ isFlickingHorizontally NOTIFY flickingHorizontallyChanged)
76 Q_PROPERTY(bool flickingVertically READ isFlickingVertically NOTIFY flickingVerticallyChanged)
77 Q_PROPERTY(FlickableDirection flickableDirection READ flickableDirection WRITE setFlickableDirection NOTIFY flickableDirectionChanged)
79 Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged)
80 Q_PROPERTY(int pressDelay READ pressDelay WRITE setPressDelay NOTIFY pressDelayChanged)
82 Q_PROPERTY(bool atXEnd READ isAtXEnd NOTIFY isAtBoundaryChanged)
83 Q_PROPERTY(bool atYEnd READ isAtYEnd NOTIFY isAtBoundaryChanged)
84 Q_PROPERTY(bool atXBeginning READ isAtXBeginning NOTIFY isAtBoundaryChanged)
85 Q_PROPERTY(bool atYBeginning READ isAtYBeginning NOTIFY isAtBoundaryChanged)
87 Q_PROPERTY(QDeclarative1FlickableVisibleArea *visibleArea READ visibleArea CONSTANT)
89 Q_PROPERTY(QDeclarativeListProperty<QObject> flickableData READ flickableData)
90 Q_PROPERTY(QDeclarativeListProperty<QGraphicsObject> flickableChildren READ flickableChildren)
91 Q_CLASSINFO("DefaultProperty", "flickableData")
93 Q_ENUMS(FlickableDirection)
94 Q_ENUMS(BoundsBehavior)
97 QDeclarative1Flickable(QDeclarativeItem *parent=0);
98 ~QDeclarative1Flickable();
100 QDeclarativeListProperty<QObject> flickableData();
101 QDeclarativeListProperty<QGraphicsObject> flickableChildren();
103 enum BoundsBehavior { StopAtBounds, DragOverBounds, DragAndOvershootBounds };
104 BoundsBehavior boundsBehavior() const;
105 void setBoundsBehavior(BoundsBehavior);
107 qreal contentWidth() const;
108 void setContentWidth(qreal);
110 qreal contentHeight() const;
111 void setContentHeight(qreal);
113 qreal contentX() const;
114 virtual void setContentX(qreal pos);
116 qreal contentY() const;
117 virtual void setContentY(qreal pos);
119 bool isMoving() const;
120 bool isMovingHorizontally() const;
121 bool isMovingVertically() const;
122 bool isFlicking() const;
123 bool isFlickingHorizontally() const;
124 bool isFlickingVertically() const;
126 int pressDelay() const;
127 void setPressDelay(int delay);
129 qreal maximumFlickVelocity() const;
130 void setMaximumFlickVelocity(qreal);
132 qreal flickDeceleration() const;
133 void setFlickDeceleration(qreal);
135 bool isInteractive() const;
136 void setInteractive(bool);
138 qreal horizontalVelocity() const;
139 qreal verticalVelocity() const;
141 bool isAtXEnd() const;
142 bool isAtXBeginning() const;
143 bool isAtYEnd() const;
144 bool isAtYBeginning() const;
146 QDeclarativeItem *contentItem();
148 enum FlickableDirection { AutoFlickDirection=0x00, HorizontalFlick=0x01, VerticalFlick=0x02, HorizontalAndVerticalFlick=0x03 };
149 FlickableDirection flickableDirection() const;
150 void setFlickableDirection(FlickableDirection);
152 Q_INVOKABLE Q_REVISION(1) void resizeContent(qreal w, qreal h, QPointF center);
153 Q_INVOKABLE Q_REVISION(1) void returnToBounds();
156 void contentWidthChanged();
157 void contentHeightChanged();
158 void contentXChanged();
159 void contentYChanged();
160 void movingChanged();
161 void movingHorizontallyChanged();
162 void movingVerticallyChanged();
163 void flickingChanged();
164 void flickingHorizontallyChanged();
165 void flickingVerticallyChanged();
166 void horizontalVelocityChanged();
167 void verticalVelocityChanged();
168 void isAtBoundaryChanged();
169 void flickableDirectionChanged();
170 void interactiveChanged();
171 void boundsBehaviorChanged();
172 void maximumFlickVelocityChanged();
173 void flickDecelerationChanged();
174 void pressDelayChanged();
175 void movementStarted();
176 void movementEnded();
181 virtual bool sceneEventFilter(QGraphicsItem *, QEvent *);
182 void mousePressEvent(QGraphicsSceneMouseEvent *event);
183 void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
184 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
185 void wheelEvent(QGraphicsSceneWheelEvent *event);
186 void timerEvent(QTimerEvent *event);
188 QDeclarative1FlickableVisibleArea *visibleArea();
191 virtual void ticked();
192 void movementStarting();
193 void movementEnding();
196 void movementXEnding();
197 void movementYEnding();
198 virtual qreal minXExtent() const;
199 virtual qreal minYExtent() const;
200 virtual qreal maxXExtent() const;
201 virtual qreal maxYExtent() const;
202 qreal vWidth() const;
203 qreal vHeight() const;
204 virtual void viewportMoved();
205 virtual void geometryChanged(const QRectF &newGeometry,
206 const QRectF &oldGeometry);
207 bool sceneEvent(QEvent *event);
208 bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
215 QDeclarative1Flickable(QDeclarative1FlickablePrivate &dd, QDeclarativeItem *parent);
218 Q_DISABLE_COPY(QDeclarative1Flickable)
219 Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Flickable)
220 friend class QDeclarative1FlickableVisibleArea;
225 QML_DECLARE_TYPE(QDeclarative1Flickable)