1 // Commit: 1bcddaaf318fc37c71c5191913f3487c49444ec6
2 /****************************************************************************
4 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
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.
41 ****************************************************************************/
43 #ifndef QQUICKFLICKABLE_P_H
44 #define QQUICKFLICKABLE_P_H
46 #include "qquickitem.h"
52 class QQuickFlickablePrivate;
53 class QQuickFlickableVisibleArea;
54 class Q_QUICK_EXPORT QQuickFlickable : public QQuickItem
58 Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged)
59 Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged)
60 Q_PROPERTY(qreal contentX READ contentX WRITE setContentX NOTIFY contentXChanged)
61 Q_PROPERTY(qreal contentY READ contentY WRITE setContentY NOTIFY contentYChanged)
62 Q_PROPERTY(QQuickItem *contentItem READ contentItem CONSTANT)
64 Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged)
65 Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged)
66 Q_PROPERTY(qreal yOrigin READ yOrigin NOTIFY yOriginChanged)
68 Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged)
69 Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged)
70 Q_PROPERTY(qreal xOrigin READ xOrigin NOTIFY xOriginChanged)
72 Q_PROPERTY(qreal horizontalVelocity READ horizontalVelocity NOTIFY horizontalVelocityChanged)
73 Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged)
75 Q_PROPERTY(BoundsBehavior boundsBehavior READ boundsBehavior WRITE setBoundsBehavior NOTIFY boundsBehaviorChanged)
76 Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity NOTIFY maximumFlickVelocityChanged)
77 Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
78 Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged)
79 Q_PROPERTY(bool movingHorizontally READ isMovingHorizontally NOTIFY movingHorizontallyChanged)
80 Q_PROPERTY(bool movingVertically READ isMovingVertically NOTIFY movingVerticallyChanged)
81 Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged)
82 Q_PROPERTY(bool flickingHorizontally READ isFlickingHorizontally NOTIFY flickingHorizontallyChanged)
83 Q_PROPERTY(bool flickingVertically READ isFlickingVertically NOTIFY flickingVerticallyChanged)
84 Q_PROPERTY(bool dragging READ isDragging NOTIFY draggingChanged)
85 Q_PROPERTY(bool draggingHorizontally READ isDraggingHorizontally NOTIFY draggingHorizontallyChanged)
86 Q_PROPERTY(bool draggingVertically READ isDraggingVertically NOTIFY draggingVerticallyChanged)
87 Q_PROPERTY(FlickableDirection flickableDirection READ flickableDirection WRITE setFlickableDirection NOTIFY flickableDirectionChanged)
89 Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged)
90 Q_PROPERTY(int pressDelay READ pressDelay WRITE setPressDelay NOTIFY pressDelayChanged)
92 Q_PROPERTY(bool atXEnd READ isAtXEnd NOTIFY isAtBoundaryChanged)
93 Q_PROPERTY(bool atYEnd READ isAtYEnd NOTIFY isAtBoundaryChanged)
94 Q_PROPERTY(bool atXBeginning READ isAtXBeginning NOTIFY isAtBoundaryChanged)
95 Q_PROPERTY(bool atYBeginning READ isAtYBeginning NOTIFY isAtBoundaryChanged)
97 Q_PROPERTY(QQuickFlickableVisibleArea *visibleArea READ visibleArea CONSTANT)
99 Q_PROPERTY(bool pixelAligned READ pixelAligned WRITE setPixelAligned NOTIFY pixelAlignedChanged)
101 Q_PROPERTY(QDeclarativeListProperty<QObject> flickableData READ flickableData)
102 Q_PROPERTY(QDeclarativeListProperty<QQuickItem> flickableChildren READ flickableChildren)
103 Q_CLASSINFO("DefaultProperty", "flickableData")
105 Q_ENUMS(FlickableDirection)
106 Q_ENUMS(BoundsBehavior)
109 QQuickFlickable(QQuickItem *parent=0);
112 QDeclarativeListProperty<QObject> flickableData();
113 QDeclarativeListProperty<QQuickItem> flickableChildren();
115 enum BoundsBehavior { StopAtBounds, DragOverBounds, DragAndOvershootBounds };
116 BoundsBehavior boundsBehavior() const;
117 void setBoundsBehavior(BoundsBehavior);
119 qreal contentWidth() const;
120 void setContentWidth(qreal);
122 qreal contentHeight() const;
123 void setContentHeight(qreal);
125 qreal contentX() const;
126 virtual void setContentX(qreal pos);
128 qreal contentY() const;
129 virtual void setContentY(qreal pos);
131 qreal topMargin() const;
132 void setTopMargin(qreal m);
134 qreal bottomMargin() const;
135 void setBottomMargin(qreal m);
137 qreal leftMargin() const;
138 void setLeftMargin(qreal m);
140 qreal rightMargin() const;
141 void setRightMargin(qreal m);
143 virtual qreal yOrigin() const;
144 virtual qreal xOrigin() const;
146 bool isMoving() const;
147 bool isMovingHorizontally() const;
148 bool isMovingVertically() const;
149 bool isFlicking() const;
150 bool isFlickingHorizontally() const;
151 bool isFlickingVertically() const;
152 bool isDragging() const;
153 bool isDraggingHorizontally() const;
154 bool isDraggingVertically() const;
156 int pressDelay() const;
157 void setPressDelay(int delay);
159 qreal maximumFlickVelocity() const;
160 void setMaximumFlickVelocity(qreal);
162 qreal flickDeceleration() const;
163 void setFlickDeceleration(qreal);
165 bool isInteractive() const;
166 void setInteractive(bool);
168 qreal horizontalVelocity() const;
169 qreal verticalVelocity() const;
171 bool isAtXEnd() const;
172 bool isAtXBeginning() const;
173 bool isAtYEnd() const;
174 bool isAtYBeginning() const;
176 QQuickItem *contentItem();
178 enum FlickableDirection { AutoFlickDirection=0x00, HorizontalFlick=0x01, VerticalFlick=0x02, HorizontalAndVerticalFlick=0x03 };
179 FlickableDirection flickableDirection() const;
180 void setFlickableDirection(FlickableDirection);
182 bool pixelAligned() const;
183 void setPixelAligned(bool align);
185 Q_INVOKABLE void resizeContent(qreal w, qreal h, QPointF center);
186 Q_INVOKABLE void returnToBounds();
189 void contentWidthChanged();
190 void contentHeightChanged();
191 void contentXChanged();
192 void contentYChanged();
193 void topMarginChanged();
194 void bottomMarginChanged();
195 void leftMarginChanged();
196 void rightMarginChanged();
197 void yOriginChanged();
198 void xOriginChanged();
199 void movingChanged();
200 void movingHorizontallyChanged();
201 void movingVerticallyChanged();
202 void flickingChanged();
203 void flickingHorizontallyChanged();
204 void flickingVerticallyChanged();
205 void draggingChanged();
206 void draggingHorizontallyChanged();
207 void draggingVerticallyChanged();
208 void horizontalVelocityChanged();
209 void verticalVelocityChanged();
210 void isAtBoundaryChanged();
211 void flickableDirectionChanged();
212 void interactiveChanged();
213 void boundsBehaviorChanged();
214 void maximumFlickVelocityChanged();
215 void flickDecelerationChanged();
216 void pressDelayChanged();
217 void movementStarted();
218 void movementEnded();
223 void pixelAlignedChanged();
226 virtual bool childMouseEventFilter(QQuickItem *, QEvent *);
227 virtual void mousePressEvent(QMouseEvent *event);
228 virtual void mouseMoveEvent(QMouseEvent *event);
229 virtual void mouseReleaseEvent(QMouseEvent *event);
230 virtual void wheelEvent(QWheelEvent *event);
231 virtual void timerEvent(QTimerEvent *event);
233 QQuickFlickableVisibleArea *visibleArea();
236 void movementStarting();
237 void movementEnding();
240 void movementXEnding();
241 void movementYEnding();
242 virtual qreal minXExtent() const;
243 virtual qreal minYExtent() const;
244 virtual qreal maxXExtent() const;
245 virtual qreal maxYExtent() const;
246 qreal vWidth() const;
247 qreal vHeight() const;
248 virtual void componentComplete();
249 virtual void viewportMoved();
250 virtual void geometryChanged(const QRectF &newGeometry,
251 const QRectF &oldGeometry);
252 void mouseUngrabEvent();
253 bool sendMouseEvent(QMouseEvent *event);
260 QQuickFlickable(QQuickFlickablePrivate &dd, QQuickItem *parent);
263 Q_DISABLE_COPY(QQuickFlickable)
264 Q_DECLARE_PRIVATE(QQuickFlickable)
265 friend class QQuickFlickableVisibleArea;
270 QML_DECLARE_TYPE(QQuickFlickable)
274 #endif // QQUICKFLICKABLE_P_H