- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qgesture.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtGui module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QGESTURE_H
    00043 #define QGESTURE_H
    00044
    00045 #include <QtCore/qobject.h>
    00046 #include <QtCore/qlist.h>
    00047 #include <QtCore/qdatetime.h>
    00048 #include <QtCore/qpoint.h>
    00049 #include <QtCore/qrect.h>
    00050 #include <QtCore/qmetatype.h>
    00051
    00052 #ifndef QT_NO_GESTURES
    00053
    00054 QT_BEGIN_HEADER
    00055
    00056 Q_DECLARE_METATYPE(Qt::GestureState)
    00057 Q_DECLARE_METATYPE(Qt::GestureType)
    00058
    00059 QT_BEGIN_NAMESPACE
    00060
    00061 QT_MODULE(Gui)
    00062
    00063 class QGesturePrivate;
    00064 class Q_GUI_EXPORT QGesture : public QObject
    00065 {
    00066     Q_OBJECT
    00067     Q_DECLARE_PRIVATE(QGesture)
    00068
    00069     Q_PROPERTY(Qt::GestureState state READ state)
    00070     Q_PROPERTY(Qt::GestureType gestureType READ gestureType)
    00071     Q_PROPERTY(QGesture::GestureCancelPolicy gestureCancelPolicy READ gestureCancelPolicy WRITE setGestureCancelPolicy)
    00072     Q_PROPERTY(QPointF hotSpot READ hotSpot WRITE setHotSpot RESET unsetHotSpot)
    00073     Q_PROPERTY(bool hasHotSpot READ hasHotSpot)
    00074
    00075 public:
    00076     explicit QGesture(QObject *parent = 0);
    00077     ~QGesture();
    00078
    00079     Qt::GestureType gestureType() const;
    00080
    00081     Qt::GestureState state() const;
    00082
    00083     QPointF hotSpot() const;
    00084     void setHotSpot(const QPointF &value);
    00085     bool hasHotSpot() const;
    00086     void unsetHotSpot();
    00087
    00088     enum GestureCancelPolicy {
    00089         CancelNone = 0,
    00090         CancelAllInContext
    00091     };
    00092
    00093     void setGestureCancelPolicy(GestureCancelPolicy policy);
    00094     GestureCancelPolicy gestureCancelPolicy() const;
    00095
    00096 protected:
    00097     QGesture(QGesturePrivate &dd, QObject *parent);
    00098
    00099 private:
    00100     friend class QGestureEvent;
    00101     friend class QGestureRecognizer;
    00102     friend class QGestureManager;
    00103     friend class QGraphicsScenePrivate;
    00104 };
    00105
    00106 class QPanGesturePrivate;
    00107 class Q_GUI_EXPORT QPanGesture : public QGesture
    00108 {
    00109     Q_OBJECT
    00110     Q_DECLARE_PRIVATE(QPanGesture)
    00111
    00112     Q_PROPERTY(QPointF lastOffset READ lastOffset WRITE setLastOffset)
    00113     Q_PROPERTY(QPointF offset READ offset WRITE setOffset)
    00114     Q_PROPERTY(QPointF delta READ delta STORED false)
    00115     Q_PROPERTY(qreal acceleration READ acceleration WRITE setAcceleration)
    00116     Q_PRIVATE_PROPERTY(QPanGesture::d_func(), qreal horizontalVelocity READ horizontalVelocity WRITE setHorizontalVelocity)
    00117     Q_PRIVATE_PROPERTY(QPanGesture::d_func(), qreal verticalVelocity READ verticalVelocity WRITE setVerticalVelocity)
    00118
    00119 public:
    00120     QPanGesture(QObject *parent = 0);
    00121
    00122     QPointF lastOffset() const;
    00123     QPointF offset() const;
    00124     QPointF delta() const;
    00125     qreal acceleration() const;
    00126
    00127     void setLastOffset(const QPointF &value);
    00128     void setOffset(const QPointF &value);
    00129     void setAcceleration(qreal value);
    00130
    00131     friend class QPanGestureRecognizer;
    00132     friend class QWinNativePanGestureRecognizer;
    00133 };
    00134
    00135 class QPinchGesturePrivate;
    00136 class Q_GUI_EXPORT QPinchGesture : public QGesture
    00137 {
    00138     Q_OBJECT
    00139     Q_DECLARE_PRIVATE(QPinchGesture)
    00140     Q_FLAGS(ChangeFlags ChangeFlag)
    00141
    00142 public:
    00143     enum ChangeFlag {
    00144         ScaleFactorChanged = 0x1,
    00145         RotationAngleChanged = 0x2,
    00146         CenterPointChanged = 0x4
    00147     };
    00148     Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)
    00149
    00150     Q_PROPERTY(ChangeFlags totalChangeFlags READ totalChangeFlags WRITE setTotalChangeFlags)
    00151     Q_PROPERTY(ChangeFlags changeFlags READ changeFlags WRITE setChangeFlags)
    00152
    00153     Q_PROPERTY(qreal totalScaleFactor READ totalScaleFactor WRITE setTotalScaleFactor)
    00154     Q_PROPERTY(qreal lastScaleFactor READ lastScaleFactor WRITE setLastScaleFactor)
    00155     Q_PROPERTY(qreal scaleFactor READ scaleFactor WRITE setScaleFactor)
    00156
    00157     Q_PROPERTY(qreal totalRotationAngle READ totalRotationAngle WRITE setTotalRotationAngle)
    00158     Q_PROPERTY(qreal lastRotationAngle READ lastRotationAngle WRITE setLastRotationAngle)
    00159     Q_PROPERTY(qreal rotationAngle READ rotationAngle WRITE setRotationAngle)
    00160
    00161     Q_PROPERTY(QPointF startCenterPoint READ startCenterPoint WRITE setStartCenterPoint)
    00162     Q_PROPERTY(QPointF lastCenterPoint READ lastCenterPoint WRITE setLastCenterPoint)
    00163     Q_PROPERTY(QPointF centerPoint READ centerPoint WRITE setCenterPoint)
    00164
    00165 public:
    00166     QPinchGesture(QObject *parent = 0);
    00167
    00168     ChangeFlags totalChangeFlags() const;
    00169     void setTotalChangeFlags(ChangeFlags value);
    00170
    00171     ChangeFlags changeFlags() const;
    00172     void setChangeFlags(ChangeFlags value);
    00173
    00174     QPointF startCenterPoint() const;
    00175     QPointF lastCenterPoint() const;
    00176     QPointF centerPoint() const;
    00177     void setStartCenterPoint(const QPointF &value);
    00178     void setLastCenterPoint(const QPointF &value);
    00179     void setCenterPoint(const QPointF &value);
    00180
    00181     qreal totalScaleFactor() const;
    00182     qreal lastScaleFactor() const;
    00183     qreal scaleFactor() const;
    00184     void setTotalScaleFactor(qreal value);
    00185     void setLastScaleFactor(qreal value);
    00186     void setScaleFactor(qreal value);
    00187
    00188     qreal totalRotationAngle() const;
    00189     qreal lastRotationAngle() const;
    00190     qreal rotationAngle() const;
    00191     void setTotalRotationAngle(qreal value);
    00192     void setLastRotationAngle(qreal value);
    00193     void setRotationAngle(qreal value);
    00194
    00195     friend class QPinchGestureRecognizer;
    00196 };
    00197
    00198 Q_DECLARE_OPERATORS_FOR_FLAGS(QPinchGesture::ChangeFlags)
    00199
    00200 QT_END_NAMESPACE
    00201
    00202 Q_DECLARE_METATYPE(QPinchGesture::ChangeFlags)
    00203
    00204 QT_BEGIN_NAMESPACE
    00205
    00206 class QSwipeGesturePrivate;
    00207 class Q_GUI_EXPORT QSwipeGesture : public QGesture
    00208 {
    00209     Q_OBJECT
    00210     Q_DECLARE_PRIVATE(QSwipeGesture)
    00211     Q_ENUMS(SwipeDirection)
    00212
    00213     Q_PROPERTY(SwipeDirection horizontalDirection READ horizontalDirection STORED false)
    00214     Q_PROPERTY(SwipeDirection verticalDirection READ verticalDirection STORED false)
    00215     Q_PROPERTY(qreal swipeAngle READ swipeAngle WRITE setSwipeAngle)
    00216     Q_PRIVATE_PROPERTY(QSwipeGesture::d_func(), qreal velocity READ velocity WRITE setVelocity)
    00217
    00218 public:
    00219     enum SwipeDirection { NoDirection, Left, Right, Up, Down };
    00220     QSwipeGesture(QObject *parent = 0);
    00221
    00222     SwipeDirection horizontalDirection() const;
    00223     SwipeDirection verticalDirection() const;
    00224
    00225     qreal swipeAngle() const;
    00226     void setSwipeAngle(qreal value);
    00227
    00228     friend class QSwipeGestureRecognizer;
    00229 };
    00230
    00231 class QTapGesturePrivate;
    00232 class Q_GUI_EXPORT QTapGesture : public QGesture
    00233 {
    00234     Q_OBJECT
    00235     Q_DECLARE_PRIVATE(QTapGesture)
    00236
    00237     Q_PROPERTY(QPointF position READ position WRITE setPosition)
    00238
    00239 public:
    00240     QTapGesture(QObject *parent = 0);
    00241
    00242     QPointF position() const;
    00243     void setPosition(const QPointF &pos);
    00244
    00245     friend class QTapGestureRecognizer;
    00246 };
    00247
    00248 class QTapAndHoldGesturePrivate;
    00249 class Q_GUI_EXPORT QTapAndHoldGesture : public QGesture
    00250 {
    00251     Q_OBJECT
    00252     Q_DECLARE_PRIVATE(QTapAndHoldGesture)
    00253
    00254     Q_PROPERTY(QPointF position READ position WRITE setPosition)
    00255
    00256 public:
    00257     QTapAndHoldGesture(QObject *parent = 0);
    00258
    00259     QPointF position() const;
    00260     void setPosition(const QPointF &pos);
    00261
    00262     static void setTimeout(int msecs);
    00263     static int timeout();
    00264
    00265     friend class QTapAndHoldGestureRecognizer;
    00266 };
    00267
    00268 QT_END_NAMESPACE
    00269
    00270 Q_DECLARE_METATYPE(QGesture::GestureCancelPolicy)
    00271 QT_END_HEADER
    00272
    00273 #endif // QT_NO_GESTURES
    00274
    00275 #endif // QGESTURE_H