|
1 /* |
|
2 * Copyright (c) 2008 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 the License "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: Gesture Definitions |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef GENERICSIMPLEGESTURE_H_ |
|
19 #define GENERICSIMPLEGESTURE_H_ |
|
20 #include <rt_gestureif.h> |
|
21 #include <rt_uievent.h> |
|
22 |
|
23 |
|
24 namespace stmGesture |
|
25 { |
|
26 |
|
27 /*! |
|
28 * Class for creating a simple gesture for notifying the listener. |
|
29 * If the basic features are enough for the gesture, then this class |
|
30 * is enough to be instantiated; there is the location and speed |
|
31 * determined from the UI event; also type can be specified as well |
|
32 * as integer detail data. |
|
33 */ |
|
34 NONSHARABLE_CLASS( TGenericSimpleGesture ): public MGestureIf |
|
35 { |
|
36 public: |
|
37 TGenericSimpleGesture( |
|
38 TGestureUid uid, const TPoint& loc, int type = 0, |
|
39 const stmUiEventEngine::MUiEventSpeed* speedIf = NULL); |
|
40 |
|
41 public: // implementation of MGestureIf |
|
42 |
|
43 TGestureUid gestureUid() const { return m_uid; } |
|
44 void setDetails(int aDetails) { m_details = aDetails;} // additional info can be passed here. |
|
45 /*! |
|
46 * MGestureIf methods |
|
47 */ |
|
48 virtual TPoint getLocation() const ; // Location where the gesture happened (if applicable) |
|
49 virtual int getType() const ; // If the gesture can have different types |
|
50 virtual float getSpeedX() const __SOFTFP |
|
51 { |
|
52 return m_speed ? m_speed->speedX() : 0.f; |
|
53 } |
|
54 virtual float getSpeedY() const __SOFTFP |
|
55 { |
|
56 return m_speed ? m_speed->speedY() : 0.f; |
|
57 } |
|
58 virtual int getDetails() const ; // Other possible details.... |
|
59 |
|
60 virtual void setName(const TDesC8& aName) ; |
|
61 virtual TPtrC8 getGestureName() ; // String name for gesture |
|
62 |
|
63 public: |
|
64 void setType(int aType) |
|
65 { |
|
66 m_type = aType; |
|
67 } |
|
68 |
|
69 protected: |
|
70 TPoint m_location ; |
|
71 TGestureUid m_uid; |
|
72 int m_type ; |
|
73 // What would be the other details? |
|
74 int m_details ; |
|
75 const stmUiEventEngine::MUiEventSpeed* m_speed ; |
|
76 TPtrC8 m_name ; |
|
77 }; |
|
78 |
|
79 NONSHARABLE_CLASS( TDirectionalGesture ): public TGenericSimpleGesture |
|
80 { |
|
81 public: |
|
82 TDirectionalGesture( |
|
83 TGestureUid uid, const TPoint& loc, const TPoint& prevLoc, |
|
84 const stmUiEventEngine::MUiEventSpeed* speedIf = NULL, bool logging = false); |
|
85 |
|
86 void setVector(const TPoint& last, const TPoint& previous) ; |
|
87 void setLogging(bool enabled) { m_loggingEnabled = enabled; } |
|
88 |
|
89 TPoint getLengthAndDirection() const {return m_vector;} |
|
90 TGestureDirection getDirection() const ; |
|
91 TInt getLength() const |
|
92 { |
|
93 return ((m_vector.iX*m_vector.iX)+(m_vector.iY*m_vector.iY)) ; |
|
94 } |
|
95 |
|
96 protected: |
|
97 TPoint m_vector ; |
|
98 bool m_loggingEnabled ; |
|
99 }; |
|
100 |
|
101 NONSHARABLE_CLASS( TTwoPointGesture ): public TDirectionalGesture |
|
102 { |
|
103 public: |
|
104 TTwoPointGesture(TGestureUid uid, const TPoint& pos1, const TPoint& pos2); |
|
105 TPoint getPinchEndPos() const { return m_location2; } |
|
106 |
|
107 private: |
|
108 TPoint m_location2 ; |
|
109 }; |
|
110 |
|
111 } // namespace |
|
112 |
|
113 #endif /* GENERICSIMPLEGESTURE_H_ */ |