|
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 |
|
19 #ifndef QSTMGENERICSIMPLEGESTURE_H_ |
|
20 #define QSTMGENERICSIMPLEGESTURE_H_ |
|
21 #include "qstmgesture_if.h" |
|
22 #include "qstmuievent_if.h" |
|
23 |
|
24 |
|
25 namespace qstmGesture |
|
26 { |
|
27 |
|
28 /*! |
|
29 * Class for creating a simple gesture for notifying the listener. |
|
30 * If the basic features are enough for the gesture, then this class |
|
31 * is enough to be instantiated; there is the location and speed |
|
32 * determined from the UI event; also type can be specified as well |
|
33 * as integer detail data. |
|
34 */ |
|
35 class QStm_GenericSimpleGesture : public QStm_GestureIf |
|
36 { |
|
37 public: |
|
38 QStm_GenericSimpleGesture( |
|
39 QStm_GestureUid uid, const QPoint& loc, int type = 0, |
|
40 const qstmUiEventEngine::QStm_UiEventSpeedIf* speedIf = NULL); |
|
41 |
|
42 public: // implementation of QStm_GestureIf |
|
43 |
|
44 QStm_GestureUid gestureUid() const { return m_uid; } |
|
45 void setDetails(void* details) { m_details = details;} // additional info can be passed here. |
|
46 virtual QPoint getLocation() const ; // Location where the gesture happened (if applicable) |
|
47 virtual int getType() const ; // If the gesture can have different types |
|
48 |
|
49 virtual float getSpeed() const /*__SOFTFP*/ |
|
50 { |
|
51 return m_speed ? m_speed->speed() : 0.f; |
|
52 } |
|
53 |
|
54 virtual QPointF getSpeedVec() const |
|
55 { |
|
56 return m_speed ? m_speed->speedVec() : QPointF(0.0, 0.0); |
|
57 } |
|
58 |
|
59 virtual void* getDetails() const ; // Other possible details.... |
|
60 |
|
61 virtual void setName(const QString& name) ; |
|
62 virtual QString getGestureName() ; // String name for gesture |
|
63 |
|
64 virtual void setTarget(void* target) { m_target = target; } |
|
65 virtual void* target() { return m_target; } |
|
66 |
|
67 public: |
|
68 void setType(int type) { m_type = type; } |
|
69 |
|
70 protected: |
|
71 QPoint m_location ; |
|
72 QStm_GestureUid m_uid; |
|
73 int m_type ; |
|
74 void* m_details ; |
|
75 const qstmUiEventEngine::QStm_UiEventSpeedIf* m_speed ; |
|
76 QString m_name ; |
|
77 void* m_target; |
|
78 }; |
|
79 |
|
80 class QStm_DirectionalGesture : public QStm_GenericSimpleGesture |
|
81 { |
|
82 public: |
|
83 QStm_DirectionalGesture( |
|
84 QStm_GestureUid uid, const QPoint& loc, const QPoint& prevLoc, |
|
85 const qstmUiEventEngine::QStm_UiEventSpeedIf* speedIf = NULL, bool logging = false); |
|
86 |
|
87 void setVector(const QPoint& last, const QPoint& previous) ; |
|
88 void setLogging(bool enabled) { m_loggingEnabled = enabled; } |
|
89 |
|
90 QPoint getLengthAndDirection() const {return m_vector;} |
|
91 QStm_GestureDirection getDirection() const ; |
|
92 int getLength() const |
|
93 { |
|
94 return ((m_vector.x() * m_vector.x()) + (m_vector.y() * m_vector.y())) ; |
|
95 } |
|
96 |
|
97 protected: |
|
98 QPoint m_vector ; |
|
99 bool m_loggingEnabled ; |
|
100 }; |
|
101 |
|
102 class QStm_TwoPointGesture : public QStm_DirectionalGesture |
|
103 { |
|
104 public: |
|
105 QStm_TwoPointGesture(QStm_GestureUid uid, const QPoint& pos1, const QPoint& pos2); |
|
106 |
|
107 private: |
|
108 QPoint m_location2 ; |
|
109 }; |
|
110 |
|
111 } // namespace |
|
112 |
|
113 |
|
114 |
|
115 #endif /* QSTMGENERICSIMPLEGESTURE_H_ */ |