Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / quick / items / qquickflickable_p.h
1 // Commit: 1bcddaaf318fc37c71c5191913f3487c49444ec6
2 /****************************************************************************
3 **
4 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
5 ** Contact: http://www.qt-project.org/
6 **
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 **
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.
17 **
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.
21 **
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.
29 **
30 ** Other Usage
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.
33 **
34 **
35 **
36 **
37 **
38 **
39 ** $QT_END_LICENSE$
40 **
41 ****************************************************************************/
42
43 #ifndef QQUICKFLICKABLE_P_H
44 #define QQUICKFLICKABLE_P_H
45
46 #include "qquickitem.h"
47
48 QT_BEGIN_HEADER
49
50 QT_BEGIN_NAMESPACE
51
52 class QQuickFlickablePrivate;
53 class QQuickFlickableVisibleArea;
54 class Q_QUICK_EXPORT QQuickFlickable : public QQuickItem
55 {
56     Q_OBJECT
57
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)
63
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)
67
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)
71
72     Q_PROPERTY(qreal horizontalVelocity READ horizontalVelocity NOTIFY horizontalVelocityChanged)
73     Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged)
74
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)
88
89     Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged)
90     Q_PROPERTY(int pressDelay READ pressDelay WRITE setPressDelay NOTIFY pressDelayChanged)
91
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)
96
97     Q_PROPERTY(QQuickFlickableVisibleArea *visibleArea READ visibleArea CONSTANT)
98
99     Q_PROPERTY(bool pixelAligned READ pixelAligned WRITE setPixelAligned NOTIFY pixelAlignedChanged)
100
101     Q_PROPERTY(QDeclarativeListProperty<QObject> flickableData READ flickableData)
102     Q_PROPERTY(QDeclarativeListProperty<QQuickItem> flickableChildren READ flickableChildren)
103     Q_CLASSINFO("DefaultProperty", "flickableData")
104
105     Q_ENUMS(FlickableDirection)
106     Q_ENUMS(BoundsBehavior)
107
108 public:
109     QQuickFlickable(QQuickItem *parent=0);
110     ~QQuickFlickable();
111
112     QDeclarativeListProperty<QObject> flickableData();
113     QDeclarativeListProperty<QQuickItem> flickableChildren();
114
115     enum BoundsBehavior { StopAtBounds, DragOverBounds, DragAndOvershootBounds };
116     BoundsBehavior boundsBehavior() const;
117     void setBoundsBehavior(BoundsBehavior);
118
119     qreal contentWidth() const;
120     void setContentWidth(qreal);
121
122     qreal contentHeight() const;
123     void setContentHeight(qreal);
124
125     qreal contentX() const;
126     virtual void setContentX(qreal pos);
127
128     qreal contentY() const;
129     virtual void setContentY(qreal pos);
130
131     qreal topMargin() const;
132     void setTopMargin(qreal m);
133
134     qreal bottomMargin() const;
135     void setBottomMargin(qreal m);
136
137     qreal leftMargin() const;
138     void setLeftMargin(qreal m);
139
140     qreal rightMargin() const;
141     void setRightMargin(qreal m);
142
143     virtual qreal yOrigin() const;
144     virtual qreal xOrigin() const;
145
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;
155
156     int pressDelay() const;
157     void setPressDelay(int delay);
158
159     qreal maximumFlickVelocity() const;
160     void setMaximumFlickVelocity(qreal);
161
162     qreal flickDeceleration() const;
163     void setFlickDeceleration(qreal);
164
165     bool isInteractive() const;
166     void setInteractive(bool);
167
168     qreal horizontalVelocity() const;
169     qreal verticalVelocity() const;
170
171     bool isAtXEnd() const;
172     bool isAtXBeginning() const;
173     bool isAtYEnd() const;
174     bool isAtYBeginning() const;
175
176     QQuickItem *contentItem();
177
178     enum FlickableDirection { AutoFlickDirection=0x00, HorizontalFlick=0x01, VerticalFlick=0x02, HorizontalAndVerticalFlick=0x03 };
179     FlickableDirection flickableDirection() const;
180     void setFlickableDirection(FlickableDirection);
181
182     bool pixelAligned() const;
183     void setPixelAligned(bool align);
184
185     Q_INVOKABLE void resizeContent(qreal w, qreal h, QPointF center);
186     Q_INVOKABLE void returnToBounds();
187
188 Q_SIGNALS:
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();
219     void flickStarted();
220     void flickEnded();
221     void dragStarted();
222     void dragEnded();
223     void pixelAlignedChanged();
224
225 protected:
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);
232
233     QQuickFlickableVisibleArea *visibleArea();
234
235 protected Q_SLOTS:
236     void movementStarting();
237     void movementEnding();
238
239 protected:
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);
254
255     bool xflick() const;
256     bool yflick() const;
257     void cancelFlick();
258
259 protected:
260     QQuickFlickable(QQuickFlickablePrivate &dd, QQuickItem *parent);
261
262 private:
263     Q_DISABLE_COPY(QQuickFlickable)
264     Q_DECLARE_PRIVATE(QQuickFlickable)
265     friend class QQuickFlickableVisibleArea;
266 };
267
268 QT_END_NAMESPACE
269
270 QML_DECLARE_TYPE(QQuickFlickable)
271
272 QT_END_HEADER
273
274 #endif // QQUICKFLICKABLE_P_H