|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "stateengineconfiguration.h" |
|
19 #include "uieventsender.h" |
|
20 #include "utils.h" |
|
21 |
|
22 using namespace stmUiEventEngine ; |
|
23 |
|
24 CStateEngineConfiguration::CStateEngineConfiguration() : |
|
25 m_touchAreaShape(ERectangle), |
|
26 m_holdAreaShape(ERectangle) |
|
27 { |
|
28 } |
|
29 |
|
30 void CStateEngineConfiguration::ConstructL() |
|
31 { |
|
32 m_uiEventSender = CUiEventSender::NewL() ; |
|
33 } |
|
34 |
|
35 CStateEngineConfiguration::~CStateEngineConfiguration() |
|
36 { |
|
37 delete m_uiEventSender ; |
|
38 } |
|
39 |
|
40 void CStateEngineConfiguration::setTolerance(long fingersize_mm, |
|
41 TPoint& tolerance, |
|
42 TAreaShape shape) |
|
43 { |
|
44 long s = Mm2Pixels(fingersize_mm) / 2; |
|
45 switch(shape) |
|
46 { |
|
47 case EEllipse: |
|
48 tolerance.iX = (s * 2) / 3; |
|
49 tolerance.iY = s; |
|
50 break ; |
|
51 case ERectangle: |
|
52 case ECircle: |
|
53 default: |
|
54 tolerance.iX = s; |
|
55 tolerance.iY = s; |
|
56 break ; |
|
57 } |
|
58 } |
|
59 |
|
60 /*! |
|
61 * Set the new touch limits for calculating the touch area. |
|
62 * The size is given in millimetres. The shape of the touch area |
|
63 * defines how the parameter is used. |
|
64 * Rectangle: each side of the rectangle has length of fingersize_mm. |
|
65 * Circle: the parameter defines the diameter of the cicle. |
|
66 * Ellipse: the parameter defines the vertical diameter of the ellipse, |
|
67 * horizontal diameter is half of it. |
|
68 */ |
|
69 void CStateEngineConfiguration::setTouchTimeArea(long fingersize_mm) |
|
70 { |
|
71 setTolerance(fingersize_mm, m_touchTimeTolerance, m_touchAreaShape); |
|
72 |
|
73 // make sure that both touch areas are defined, so if the touch area is not yet set, |
|
74 // use the same as for touch time area. |
|
75 if (m_touchTolerance.iX == 0) |
|
76 { |
|
77 setTouchArea(fingersize_mm) ; |
|
78 } |
|
79 } |
|
80 /*! |
|
81 * Set the new touch limits for calculating the touch area. |
|
82 * The size is given in millimetres. The shape of the touch area |
|
83 * defines how the parameter is used. |
|
84 * Rectangle: each side of the rectangle has length of fingersize_mm. |
|
85 * Circle: the parameter defines the diameter of the cicle. |
|
86 * Ellipse: the parameter defines the vertical diameter of the ellipse, |
|
87 * horizontal diameter is half of it. |
|
88 */ |
|
89 void CStateEngineConfiguration::setTouchArea(long fingersize_mm) |
|
90 { |
|
91 setTolerance(fingersize_mm, m_touchTolerance, m_touchAreaShape); |
|
92 } |
|
93 /*! |
|
94 * \return the touch are shape |
|
95 */ |
|
96 TAreaShape CStateEngineConfiguration::getTouchAreaShape() |
|
97 { |
|
98 return m_touchAreaShape ; |
|
99 } |
|
100 /*! |
|
101 * \parameter the touch are shape |
|
102 */ |
|
103 void CStateEngineConfiguration::setTouchAreaShape(TAreaShape aShape) |
|
104 { |
|
105 this->m_touchAreaShape = aShape ; |
|
106 } |
|
107 /*! |
|
108 * \return the touch timeout in microseconds. |
|
109 */ |
|
110 unsigned int CStateEngineConfiguration::getTouchTimeout() |
|
111 { |
|
112 return m_touchTimerLimit ; |
|
113 } |
|
114 /*! |
|
115 * set the touch timeout in microseconds. |
|
116 */ |
|
117 void CStateEngineConfiguration::setTouchTimeout(unsigned int a) |
|
118 { |
|
119 m_touchTimerLimit = a ; |
|
120 } |
|
121 /*! |
|
122 * Set the hold area. Hold are shape determines how exactly the area is handled. |
|
123 * \sa setTouchArea |
|
124 */ |
|
125 void CStateEngineConfiguration::setHoldArea(long fingersize_mm) |
|
126 { |
|
127 setTolerance(fingersize_mm, m_holdTolerance, m_holdAreaShape); |
|
128 } |
|
129 /*! |
|
130 * Get the shape of the hold area: Rectangle, Circle or Ellipse, |
|
131 */ |
|
132 TAreaShape CStateEngineConfiguration::getHoldAreaShape() |
|
133 { |
|
134 return m_holdAreaShape ; |
|
135 } |
|
136 /*! |
|
137 * Set the shape of the hold area: Rectangle, Circle or Ellipse, |
|
138 */ |
|
139 void CStateEngineConfiguration::setHoldAreaShape(TAreaShape aShape) |
|
140 { |
|
141 m_holdAreaShape = aShape ; |
|
142 } |
|
143 /*! |
|
144 * \return the hold timeout in microseconds. |
|
145 */ |
|
146 unsigned int CStateEngineConfiguration::getHoldTimeout() |
|
147 { |
|
148 return m_holdTimerLimit ; |
|
149 } |
|
150 /*! |
|
151 * set the hold timeout value in microseconds. |
|
152 */ |
|
153 void CStateEngineConfiguration::setHoldTimeout(unsigned int a) |
|
154 { |
|
155 m_holdTimerLimit = a ; |
|
156 } |
|
157 /*! |
|
158 * get the touch suppress timeout value in microseconds. |
|
159 */ |
|
160 unsigned int CStateEngineConfiguration::getTouchSuppressTimeout() |
|
161 { |
|
162 return m_suppressTimerLimit ; |
|
163 } |
|
164 /*! |
|
165 * set the touch suppress timeout. |
|
166 * \param the timeout value in microseconds. |
|
167 */ |
|
168 void CStateEngineConfiguration::setTouchSuppressTimeout(unsigned int a) |
|
169 { |
|
170 m_suppressTimerLimit = a ; |
|
171 } |
|
172 /*! |
|
173 * MStateMachine method. |
|
174 */ |
|
175 unsigned int CStateEngineConfiguration::getMoveSuppressTimeout() |
|
176 { |
|
177 return m_moveSuppressTimerLimit ; |
|
178 } |
|
179 /*! |
|
180 * MStateMachine method. |
|
181 */ |
|
182 void CStateEngineConfiguration::setMoveSuppressTimeout(unsigned int a) |
|
183 { |
|
184 m_moveSuppressTimerLimit = a ; |
|
185 } |
|
186 /*! |
|
187 * MStateMachine method. |
|
188 * Sets logging on or off. |
|
189 */ |
|
190 void CStateEngineConfiguration::enableLogging(bool a) |
|
191 { |
|
192 m_enableLogging = a ; |
|
193 m_uiEventSender->setLogging(a) ; |
|
194 } |
|
195 |
|
196 /*! |
|
197 * \param a new UI event observer |
|
198 */ |
|
199 bool CStateEngineConfiguration::addUiEventObserver(MUiEventObserver* observer) |
|
200 { |
|
201 // The event sender handles the observers |
|
202 return m_uiEventSender->addObserver(observer) ; |
|
203 } |
|
204 /*! |
|
205 * MStateMachine method. |
|
206 */ |
|
207 bool CStateEngineConfiguration::removeUiEventObserver(MUiEventObserver* observer) |
|
208 { |
|
209 // The event sender handles the observers |
|
210 return m_uiEventSender->removeObserver(observer) ; |
|
211 } |
|
212 |