Qt 4.8
qgesture.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QGESTURE_H
43 #define QGESTURE_H
44 
45 #include <QtCore/qobject.h>
46 #include <QtCore/qlist.h>
47 #include <QtCore/qdatetime.h>
48 #include <QtCore/qpoint.h>
49 #include <QtCore/qrect.h>
50 #include <QtCore/qmetatype.h>
51 
52 #ifndef QT_NO_GESTURES
53 
55 
58 
60 
61 QT_MODULE(Gui)
62 
63 class QGesturePrivate;
65 {
66  Q_OBJECT
68 
69  Qt::GestureState state;
70  Qt::GestureType gestureType;
71  QGesture::GestureCancelPolicy gestureCancelPolicy;
72  QPointF hotSpot;
73  bool hasHotSpot;
74 
75 public:
76  explicit QGesture(QObject *parent = 0);
77  ~QGesture();
78 
79  Qt::GestureType gestureType() const;
80 
81  Qt::GestureState state() const;
82 
83  QPointF hotSpot() const;
84  void setHotSpot(const QPointF &value);
85  bool hasHotSpot() const;
86  void unsetHotSpot();
87 
89  CancelNone = 0,
90  CancelAllInContext
91  };
92 
93  void setGestureCancelPolicy(GestureCancelPolicy policy);
94  GestureCancelPolicy gestureCancelPolicy() const;
95 
96 protected:
97  QGesture(QGesturePrivate &dd, QObject *parent);
98 
99 private:
100  friend class QGestureEvent;
101  friend class QGestureRecognizer;
102  friend class QGestureManager;
103  friend class QGraphicsScenePrivate;
104 };
105 
106 class QPanGesturePrivate;
108 {
109  Q_OBJECT
111 
112  QPointF lastOffset;
113  QPointF offset;
114  QPointF delta;
115  qreal acceleration;
116  Q_PRIVATE_PROPERTY(QPanGesture::d_func(), qreal horizontalVelocity READ horizontalVelocity WRITE setHorizontalVelocity)
117  Q_PRIVATE_PROPERTY(QPanGesture::d_func(), qreal verticalVelocity READ verticalVelocity WRITE setVerticalVelocity)
118 
119 public:
120  QPanGesture(QObject *parent = 0);
121 
122  QPointF lastOffset() const;
123  QPointF offset() const;
124  QPointF delta() const;
125  qreal acceleration() const;
126 
127  void setLastOffset(const QPointF &value);
128  void setOffset(const QPointF &value);
129  void setAcceleration(qreal value);
130 
133 };
134 
137 {
138  Q_OBJECT
140  Q_FLAGS(ChangeFlags ChangeFlag)
141 
142 public:
143  enum ChangeFlag {
144  ScaleFactorChanged = 0x1,
145  RotationAngleChanged = 0x2,
146  CenterPointChanged = 0x4
147  };
148  Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)
149 
150  ChangeFlags totalChangeFlags;
151  ChangeFlags changeFlags;
152 
153  qreal totalScaleFactor;
154  qreal lastScaleFactor;
155  qreal scaleFactor;
156 
157  qreal totalRotationAngle;
158  qreal lastRotationAngle;
159  qreal rotationAngle;
160 
161  QPointF startCenterPoint;
162  QPointF lastCenterPoint;
163  QPointF centerPoint;
164 
165 public:
166  QPinchGesture(QObject *parent = 0);
167 
168  ChangeFlags totalChangeFlags() const;
169  void setTotalChangeFlags(ChangeFlags value);
170 
171  ChangeFlags changeFlags() const;
172  void setChangeFlags(ChangeFlags value);
173 
174  QPointF startCenterPoint() const;
175  QPointF lastCenterPoint() const;
176  QPointF centerPoint() const;
177  void setStartCenterPoint(const QPointF &value);
178  void setLastCenterPoint(const QPointF &value);
179  void setCenterPoint(const QPointF &value);
180 
181  qreal totalScaleFactor() const;
182  qreal lastScaleFactor() const;
183  qreal scaleFactor() const;
184  void setTotalScaleFactor(qreal value);
185  void setLastScaleFactor(qreal value);
186  void setScaleFactor(qreal value);
187 
188  qreal totalRotationAngle() const;
189  qreal lastRotationAngle() const;
190  qreal rotationAngle() const;
191  void setTotalRotationAngle(qreal value);
192  void setLastRotationAngle(qreal value);
193  void setRotationAngle(qreal value);
194 
196 };
197 
199 
201 
202 Q_DECLARE_METATYPE(QPinchGesture::ChangeFlags)
203 
205 
208 {
209  Q_OBJECT
212 
213  SwipeDirection horizontalDirection;
214  SwipeDirection verticalDirection;
215  qreal swipeAngle;
216  Q_PRIVATE_PROPERTY(QSwipeGesture::d_func(), qreal velocity READ velocity WRITE setVelocity)
217 
218 public:
219  enum SwipeDirection { NoDirection, Left, Right, Up, Down };
220  QSwipeGesture(QObject *parent = 0);
221 
222  SwipeDirection horizontalDirection() const;
223  SwipeDirection verticalDirection() const;
224 
225  qreal swipeAngle() const;
226  void setSwipeAngle(qreal value);
227 
229 };
230 
231 class QTapGesturePrivate;
233 {
234  Q_OBJECT
236 
238 
239 public:
240  QTapGesture(QObject *parent = 0);
241 
242  QPointF position() const;
243  void setPosition(const QPointF &pos);
244 
246 };
247 
250 {
251  Q_OBJECT
253 
254  QPointF position;
255 
256 public:
257  QTapAndHoldGesture(QObject *parent = 0);
258 
259  QPointF position() const;
260  void setPosition(const QPointF &pos);
261 
262  static void setTimeout(int msecs);
263  static int timeout();
264 
266 };
267 
269 
272 
273 #endif // QT_NO_GESTURES
274 
275 #endif // QGESTURE_H
The QPanGesture class describes a panning gesture made by the user.
Definition: qgesture.h:107
double qreal
Definition: qglobal.h:1193
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define Q_PRIVATE_PROPERTY(d, define Q_REVISION(v)
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
Definition: qglobal.h:2348
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QTapAndHoldGesture class describes a tap-and-hold (aka LongTap) gesture made by the user...
Definition: qgesture.h:249
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
GestureCancelPolicy
This enum describes how accepting a gesture can cancel other gestures automatically.
Definition: qgesture.h:88
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QGestureEvent class provides the description of triggered gestures.
Definition: qevent.h:841
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags...
Definition: qglobal.h:2355
The QPinchGesture class describes a pinch gesture made by the user.
Definition: qgesture.h:136
GestureType
Definition: qnamespace.h:1759
#define Q_OBJECT
Definition: qobjectdefs.h:157
#define Q_DECLARE_METATYPE(TYPE)
This macro makes the type Type known to QMetaType as long as it provides a public default constructor...
Definition: qmetatype.h:265
ChangeFlag
This enum describes the changes that can occur to the properties of the gesture object.
Definition: qgesture.h:143
The QGesture class represents a gesture, containing properties that describe the corresponding user i...
Definition: qgesture.h:64
The QGestureRecognizer class provides the infrastructure for gesture recognition. ...
Definition: qnamespace.h:54
The QTapGesture class describes a tap gesture made by the user.
Definition: qgesture.h:232
#define Q_FLAGS(x)
Definition: qobjectdefs.h:85
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
#define class
The QSwipeGesture class describes a swipe gesture made by the user.
Definition: qgesture.h:207
SwipeDirection
This enum describes the possible directions for the gesture&#39;s motion along the horizontal and vertica...
Definition: qgesture.h:219
#define QT_END_HEADER
Definition: qglobal.h:137
GestureState
Definition: qnamespace.h:1750