qstmgesturelib/qstmgestureevent.h
changeset 0 1450b09d0cfd
child 3 0954f5dd2cd0
equal deleted inserted replaced
-1:000000000000 0:1450b09d0cfd
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef QSTMGESTUREEVENT_H_
       
    19 #define QSTMGESTUREEVENT_H_
       
    20 
       
    21 #include <QEvent>
       
    22 #include <QPoint>
       
    23 #include <QString>
       
    24 #include <QVarLengthArray>
       
    25 #include <QMouseEvent>
       
    26 #include <QGesture>
       
    27 #include <QWidget>
       
    28 
       
    29 #include "qstmgesturedefs.h"
       
    30 #include "qstmgesture_if.h"
       
    31 
       
    32 #define QStmGestureEventType QEvent::User + 1 
       
    33 #define QStmGestureType Qt::CustomGesture
       
    34 
       
    35 
       
    36 enum QStm_GestureType
       
    37 	{
       
    38 	    QStmUknownGestureType = 0,
       
    39 	    QStmTouchGestureType,
       
    40 	    QStmTapGestureType,
       
    41 	    QStmDoubleTapGestureType,
       
    42 	    QStmLongPressGestureType,
       
    43 	    QStmHoverGestureType,
       
    44 	    QStmPanGestureType,
       
    45 	    QStmReleaseGestureType,
       
    46 	    
       
    47 	    QStmLeftRightGestureType,
       
    48 	    QStmUpDownGestureType,
       
    49 	    QStmFlickGestureType,     
       
    50 	    QStmEdgeScrollGestureType,
       
    51 	    
       
    52 	    QStmPinchGestureType, 
       
    53 	    QStmCornerZoomGestureType
       
    54 	};
       
    55 
       
    56 
       
    57 
       
    58 class QSTMGESTURELIB_EXPORT QStm_Gesture : public QGesture
       
    59 {
       
    60 	Q_OBJECT
       
    61 	
       
    62 public:	
       
    63 
       
    64 	QStm_Gesture(QObject* parent = 0);
       
    65     
       
    66     virtual ~QStm_Gesture() {}
       
    67     
       
    68     QStm_Gesture& operator=(QStm_Gesture& other);
       
    69     QPoint  position() const { return m_pos; }
       
    70     void setPosition(const QPoint &pos) { m_pos = pos; /*setHotSpot(QPointF(pos)); */}
       
    71     
       
    72     void setGestureStmType(QStm_GestureType type) { m_gstType = type; }    
       
    73     QStm_GestureType  getGestureStmType() const { return m_gstType; }
       
    74     
       
    75     void setGestureState(Qt::GestureState state) { m_state = state; }
       
    76     Qt::GestureState gestureState() { return m_state; }
       
    77     
       
    78     void setGestureSubType(int type) { m_gstSubType = type; }
       
    79     int  getGestureSubType() { return m_gstSubType; }    
       
    80     
       
    81     qreal getSpeed() { return m_speed; }
       
    82     void setSpeed(qreal speed) { m_speed = speed; }
       
    83     
       
    84     QPointF getSpeedVec() { return m_speedVec; }
       
    85     void setSpeedVec(QPointF speedVec) { m_speedVec = speedVec; }
       
    86     
       
    87     QPoint getLengthAndDirection() { return m_vector; }
       
    88     void setLengthAndDirection(QPoint vec) { m_vector = vec; }
       
    89     
       
    90     int getDirection() { return m_direction; }
       
    91     void setDirection(int dir) { m_direction = dir; }
       
    92     QString  gestureName();
       
    93     
       
    94     void* getDetails() { return m_details; }
       
    95     void  setDetails(void* details ) { m_details = details; }
       
    96     
       
    97     bool sendEvent(QEvent* event);
       
    98     QList<QMouseEvent*>   getMouseEvents();
       
    99     bool sendMouseEvents(QObject* receiver, Qt::KeyboardModifier modifier = Qt::NoModifier);
       
   100     bool sendMouseEvents(Qt::KeyboardModifier modifier = Qt::NoModifier);
       
   101     bool postMouseEvents(QObject* receiver, Qt::KeyboardModifier modifier = Qt::NoModifier);
       
   102 
       
   103     void setTarget(QWidget* target) { m_target = target; }
       
   104     QWidget* target() { return m_target; }
       
   105     
       
   106     static void setAssignedGestureType(Qt::GestureType type) { s_assignedType = type; }
       
   107     static Qt::GestureType assignedType() { return s_assignedType; } 
       
   108     
       
   109     
       
   110 
       
   111 private:
       
   112     bool sendOrPostMouseEvents(QObject* receiver, Qt::KeyboardModifier modifier, bool send);
       
   113     void gestureTypeToMouseTypes(QVarLengthArray<int, 4>& types);     
       
   114     
       
   115     
       
   116     qreal             m_speed;    
       
   117     int               m_direction;
       
   118     QPoint            m_vector;
       
   119     QStm_GestureType  m_gstType;
       
   120     Qt::GestureState  m_state;
       
   121     int               m_gstSubType;
       
   122     QPoint            m_pos;
       
   123     void*             m_details;
       
   124     QPointF           m_speedVec;
       
   125     static Qt::GestureType   s_assignedType;
       
   126     QWidget*          m_target;
       
   127 };
       
   128 
       
   129 
       
   130 QSTMGESTURELIB_EXPORT QStm_Gesture* getQStmGesture(QEvent* event);
       
   131 
       
   132 
       
   133 
       
   134 class QSTMGESTURELIB_EXPORT QStm_GestureEvent : public QEvent
       
   135 {
       
   136 public:	
       
   137 	QStm_GestureEvent();
       
   138 	virtual ~QStm_GestureEvent();
       
   139 	static QEvent::Type stmGestureEventType() { return static_cast<QEvent::Type>(QStmGestureEventType); }
       
   140 };
       
   141 
       
   142 
       
   143 #endif /* QSTMGESTUREEVENT_H_ */