Update licenseheader text in source files for qtdeclarative Qt module
[profile/ivi/qtdeclarative.git] / src / declarative / items / qsgflickable_p.h
1 // Commit: 1bcddaaf318fc37c71c5191913f3487c49444ec6
2 /****************************************************************************
3 **
4 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
5 ** All rights reserved.
6 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 **
8 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 **
10 ** $QT_BEGIN_LICENSE:LGPL$
11 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this
15 ** file. Please review the following information to ensure the GNU Lesser
16 ** General Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** GNU General Public License Usage
24 ** Alternatively, this file may be used under the terms of the GNU General
25 ** Public License version 3.0 as published by the Free Software Foundation
26 ** and appearing in the file LICENSE.GPL included in the packaging of this
27 ** file. Please review the following information to ensure the GNU General
28 ** Public License version 3.0 requirements will be met:
29 ** http://www.gnu.org/copyleft/gpl.html.
30 **
31 ** Other Usage
32 ** Alternatively, this file may be used in accordance with the terms and
33 ** conditions contained in a signed written agreement between you and Nokia.
34 **
35 **
36 **
37 **
38 **
39 ** $QT_END_LICENSE$
40 **
41 ****************************************************************************/
42
43 #ifndef QSGFLICKABLE_P_H
44 #define QSGFLICKABLE_P_H
45
46 #include "qsgitem.h"
47
48 QT_BEGIN_HEADER
49
50 QT_BEGIN_NAMESPACE
51
52 QT_MODULE(Declarative)
53
54 class QSGFlickablePrivate;
55 class QSGFlickableVisibleArea;
56 class Q_AUTOTEST_EXPORT QSGFlickable : public QSGItem
57 {
58     Q_OBJECT
59
60     Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged)
61     Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged)
62     Q_PROPERTY(qreal contentX READ contentX WRITE setContentX NOTIFY contentXChanged)
63     Q_PROPERTY(qreal contentY READ contentY WRITE setContentY NOTIFY contentYChanged)
64     Q_PROPERTY(QSGItem *contentItem READ contentItem CONSTANT)
65
66     Q_PROPERTY(qreal horizontalVelocity READ horizontalVelocity NOTIFY horizontalVelocityChanged)
67     Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged)
68
69     Q_PROPERTY(BoundsBehavior boundsBehavior READ boundsBehavior WRITE setBoundsBehavior NOTIFY boundsBehaviorChanged)
70     Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity NOTIFY maximumFlickVelocityChanged)
71     Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
72     Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged)
73     Q_PROPERTY(bool movingHorizontally READ isMovingHorizontally NOTIFY movingHorizontallyChanged)
74     Q_PROPERTY(bool movingVertically READ isMovingVertically NOTIFY movingVerticallyChanged)
75     Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged)
76     Q_PROPERTY(bool flickingHorizontally READ isFlickingHorizontally NOTIFY flickingHorizontallyChanged)
77     Q_PROPERTY(bool flickingVertically READ isFlickingVertically NOTIFY flickingVerticallyChanged)
78     Q_PROPERTY(FlickableDirection flickableDirection READ flickableDirection WRITE setFlickableDirection NOTIFY flickableDirectionChanged)
79
80     Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged)
81     Q_PROPERTY(int pressDelay READ pressDelay WRITE setPressDelay NOTIFY pressDelayChanged)
82
83     Q_PROPERTY(bool atXEnd READ isAtXEnd NOTIFY isAtBoundaryChanged)
84     Q_PROPERTY(bool atYEnd READ isAtYEnd NOTIFY isAtBoundaryChanged)
85     Q_PROPERTY(bool atXBeginning READ isAtXBeginning NOTIFY isAtBoundaryChanged)
86     Q_PROPERTY(bool atYBeginning READ isAtYBeginning NOTIFY isAtBoundaryChanged)
87
88     Q_PROPERTY(QSGFlickableVisibleArea *visibleArea READ visibleArea CONSTANT)
89
90     Q_PROPERTY(QDeclarativeListProperty<QObject> flickableData READ flickableData)
91     Q_PROPERTY(QDeclarativeListProperty<QSGItem> flickableChildren READ flickableChildren)
92     Q_CLASSINFO("DefaultProperty", "flickableData")
93
94     Q_ENUMS(FlickableDirection)
95     Q_ENUMS(BoundsBehavior)
96
97 public:
98     QSGFlickable(QSGItem *parent=0);
99     ~QSGFlickable();
100
101     QDeclarativeListProperty<QObject> flickableData();
102     QDeclarativeListProperty<QSGItem> flickableChildren();
103
104     enum BoundsBehavior { StopAtBounds, DragOverBounds, DragAndOvershootBounds };
105     BoundsBehavior boundsBehavior() const;
106     void setBoundsBehavior(BoundsBehavior);
107
108     qreal contentWidth() const;
109     void setContentWidth(qreal);
110
111     qreal contentHeight() const;
112     void setContentHeight(qreal);
113
114     qreal contentX() const;
115     virtual void setContentX(qreal pos);
116
117     qreal contentY() const;
118     virtual void setContentY(qreal pos);
119
120     bool isMoving() const;
121     bool isMovingHorizontally() const;
122     bool isMovingVertically() const;
123     bool isFlicking() const;
124     bool isFlickingHorizontally() const;
125     bool isFlickingVertically() const;
126
127     int pressDelay() const;
128     void setPressDelay(int delay);
129
130     qreal maximumFlickVelocity() const;
131     void setMaximumFlickVelocity(qreal);
132
133     qreal flickDeceleration() const;
134     void setFlickDeceleration(qreal);
135
136     bool isInteractive() const;
137     void setInteractive(bool);
138
139     qreal horizontalVelocity() const;
140     qreal verticalVelocity() const;
141
142     bool isAtXEnd() const;
143     bool isAtXBeginning() const;
144     bool isAtYEnd() const;
145     bool isAtYBeginning() const;
146
147     QSGItem *contentItem();
148
149     enum FlickableDirection { AutoFlickDirection=0x00, HorizontalFlick=0x01, VerticalFlick=0x02, HorizontalAndVerticalFlick=0x03 };
150     FlickableDirection flickableDirection() const;
151     void setFlickableDirection(FlickableDirection);
152
153     Q_INVOKABLE void resizeContent(qreal w, qreal h, QPointF center);
154     Q_INVOKABLE void returnToBounds();
155
156 Q_SIGNALS:
157     void contentWidthChanged();
158     void contentHeightChanged();
159     void contentXChanged();
160     void contentYChanged();
161     void movingChanged();
162     void movingHorizontallyChanged();
163     void movingVerticallyChanged();
164     void flickingChanged();
165     void flickingHorizontallyChanged();
166     void flickingVerticallyChanged();
167     void horizontalVelocityChanged();
168     void verticalVelocityChanged();
169     void isAtBoundaryChanged();
170     void flickableDirectionChanged();
171     void interactiveChanged();
172     void boundsBehaviorChanged();
173     void maximumFlickVelocityChanged();
174     void flickDecelerationChanged();
175     void pressDelayChanged();
176     void movementStarted();
177     void movementEnded();
178     void flickStarted();
179     void flickEnded();
180
181 protected:
182     virtual bool childMouseEventFilter(QSGItem *, QEvent *);
183     virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
184     virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
185     virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
186     virtual void wheelEvent(QWheelEvent *event);
187     virtual void timerEvent(QTimerEvent *event);
188
189     QSGFlickableVisibleArea *visibleArea();
190
191 protected Q_SLOTS:
192     virtual void ticked();
193     void movementStarting();
194     void movementEnding();
195
196 protected:
197     void movementXEnding();
198     void movementYEnding();
199     virtual qreal minXExtent() const;
200     virtual qreal minYExtent() const;
201     virtual qreal maxXExtent() const;
202     virtual qreal maxYExtent() const;
203     qreal vWidth() const;
204     qreal vHeight() const;
205     virtual void viewportMoved();
206     virtual void geometryChanged(const QRectF &newGeometry,
207                                  const QRectF &oldGeometry);
208     void mouseUngrabEvent();
209     bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
210
211     bool xflick() const;
212     bool yflick() const;
213     void cancelFlick();
214
215 protected:
216     QSGFlickable(QSGFlickablePrivate &dd, QSGItem *parent);
217
218 private:
219     Q_DISABLE_COPY(QSGFlickable)
220     Q_DECLARE_PRIVATE(QSGFlickable)
221     friend class QSGFlickableVisibleArea;
222 };
223
224 QT_END_NAMESPACE
225
226 QML_DECLARE_TYPE(QSGFlickable)
227
228 QT_END_HEADER
229
230 #endif // QSGFLICKABLE_P_H