|
1 /* |
|
2 * Copyright (c) 2006-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 "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: Implementation of MTactileFeedbackInterface of eSWT midlets. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifdef RD_TACTILE_FEEDBACK |
|
20 |
|
21 #include "CMIDToolkit.h" |
|
22 #include <touchfeedback.h> |
|
23 #include <eswtwidgetscore.h> |
|
24 #include "CTactileFeedbackInterfaceESWT.h" |
|
25 #include "TactileFeedbackImpl.h" |
|
26 |
|
27 |
|
28 class TactileFeedback_creator : public MSwtFunctor |
|
29 { |
|
30 public: |
|
31 void (*create)(MTouchFeedback**); |
|
32 |
|
33 |
|
34 mutable MTouchFeedback* retval; |
|
35 |
|
36 TactileFeedback_creator() |
|
37 { |
|
38 create = &_CreateMTouchFeedback; |
|
39 } |
|
40 |
|
41 void operator()() const |
|
42 { |
|
43 create(&retval); |
|
44 } |
|
45 }; |
|
46 |
|
47 class TactileFeedback_directFeedback : public MSwtFunctor |
|
48 { |
|
49 public: |
|
50 void (*directFeedback)(MTouchFeedback*, TTouchLogicalFeedback); |
|
51 MTouchFeedback* iTactileFeeback; |
|
52 TTouchLogicalFeedback iStyle; |
|
53 |
|
54 TactileFeedback_directFeedback() |
|
55 { |
|
56 directFeedback = &_DoDirectFeedback; |
|
57 } |
|
58 |
|
59 void operator()() const |
|
60 { |
|
61 directFeedback(iTactileFeeback, iStyle); |
|
62 } |
|
63 }; |
|
64 |
|
65 |
|
66 class TactileFeedback_isSupported : public MSwtFunctor |
|
67 { |
|
68 public: |
|
69 mutable TBool retval; |
|
70 TBool(*isSupported)(MTouchFeedback*); |
|
71 MTouchFeedback* iTactileFeeback; |
|
72 |
|
73 TactileFeedback_isSupported() |
|
74 { |
|
75 isSupported = &_IsTouchFeedbackSupported; |
|
76 } |
|
77 void operator()() const |
|
78 { |
|
79 retval = isSupported(iTactileFeeback); |
|
80 } |
|
81 }; |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 class TactileFeedback_registerArea : public MSwtFunctor |
|
87 { |
|
88 public: |
|
89 void (*registerArea)(MTouchFeedback*, CCoeControl*, TInt, TRect, TTouchLogicalFeedback); |
|
90 MTouchFeedback* iTactileFeeback; |
|
91 CCoeControl* iControl; |
|
92 TInt iAreaIndex; |
|
93 TRect iArea; |
|
94 TTouchLogicalFeedback iStyle; |
|
95 |
|
96 TactileFeedback_registerArea() |
|
97 { |
|
98 registerArea = &_RegisterFeedbackArea; |
|
99 } |
|
100 |
|
101 void operator()() const |
|
102 { |
|
103 registerArea(iTactileFeeback, iControl, iAreaIndex, iArea, iStyle); |
|
104 } |
|
105 }; |
|
106 |
|
107 |
|
108 class TactileFeedback_removeArea : public MSwtFunctor |
|
109 { |
|
110 public: |
|
111 void (*removeArea)(MTouchFeedback*, CCoeControl*, TInt); |
|
112 MTouchFeedback* iTactileFeeback; |
|
113 CCoeControl* iControl; |
|
114 TInt iAreaIndex; |
|
115 |
|
116 TactileFeedback_removeArea() |
|
117 { |
|
118 removeArea = &_UnregisterFeedbackArea; |
|
119 } |
|
120 |
|
121 void operator()() const |
|
122 { |
|
123 removeArea(iTactileFeeback, iControl, iAreaIndex); |
|
124 } |
|
125 }; |
|
126 |
|
127 class TactileFeedback_removeFeedbackForControl : public MSwtFunctor |
|
128 { |
|
129 public: |
|
130 void (*removeFeedback)(MTouchFeedback*, CCoeControl*); |
|
131 MTouchFeedback* iTactileFeeback; |
|
132 CCoeControl* iControl; |
|
133 |
|
134 TactileFeedback_removeFeedbackForControl() |
|
135 { |
|
136 removeFeedback = &_UnregisterFeedbackForControl; |
|
137 } |
|
138 |
|
139 void operator()() const |
|
140 { |
|
141 removeFeedback(iTactileFeeback, iControl); |
|
142 } |
|
143 }; |
|
144 |
|
145 |
|
146 class TactileFeedback_moveAreaToFirstPriority : public MSwtFunctor |
|
147 { |
|
148 public: |
|
149 void (*moveArea)(MTouchFeedback*, CCoeControl*, TInt); |
|
150 MTouchFeedback* iTactileFeeback; |
|
151 CCoeControl* iControl; |
|
152 TInt iAreaIndex; |
|
153 |
|
154 TactileFeedback_moveAreaToFirstPriority() |
|
155 { |
|
156 moveArea = &_MoveAreaToFirstPriority; |
|
157 } |
|
158 |
|
159 void operator()() const |
|
160 { |
|
161 moveArea(iTactileFeeback, iControl, iAreaIndex); |
|
162 } |
|
163 }; |
|
164 |
|
165 |
|
166 CTactileFeedbackInterfaceESWT::CTactileFeedbackInterfaceESWT(MSwtClient* aESWT_client) |
|
167 { |
|
168 iESWT_client = aESWT_client; |
|
169 TactileFeedback_creator creator; |
|
170 iESWT_client->Execute(creator); |
|
171 iFeedback = creator.retval; |
|
172 |
|
173 }; |
|
174 |
|
175 |
|
176 void CTactileFeedbackInterfaceESWT::DirectFeedback(TTouchLogicalFeedback aStyle) |
|
177 { |
|
178 |
|
179 TactileFeedback_directFeedback directFeedback; |
|
180 directFeedback.iTactileFeeback = iFeedback; |
|
181 directFeedback.iStyle = aStyle; |
|
182 iESWT_client->Execute(directFeedback); |
|
183 }; |
|
184 |
|
185 void CTactileFeedbackInterfaceESWT::RegisterFeedbackArea(void* aControl, TInt /*aControlType*/, TInt aAreaIndex, TInt aX, TInt aY, TInt aWidth, TInt aHeight, TTouchLogicalFeedback aStyle) |
|
186 { |
|
187 MSwtControl* ctrl = (MSwtControl*)aControl; |
|
188 CCoeControl& cc = ctrl->CoeControl(); |
|
189 |
|
190 |
|
191 TRect area(aX, aY, aX + aWidth, aY + aHeight); |
|
192 area.Move(cc.Position()); |
|
193 TactileFeedback_registerArea registerArea; |
|
194 registerArea.iTactileFeeback = iFeedback; |
|
195 registerArea.iControl = &cc; |
|
196 registerArea.iAreaIndex = aAreaIndex; |
|
197 registerArea.iArea = area; |
|
198 registerArea.iStyle = aStyle; |
|
199 iESWT_client->Execute(registerArea); |
|
200 }; |
|
201 |
|
202 void CTactileFeedbackInterfaceESWT::UnregisterFeedbackArea(void* aControl, TInt /*aControlType*/, TInt aAreaIndex) |
|
203 { |
|
204 MSwtControl* ctrl = (MSwtControl*)aControl; |
|
205 CCoeControl& cc = ctrl->CoeControl(); |
|
206 |
|
207 TactileFeedback_removeArea removeArea; |
|
208 removeArea.iTactileFeeback = iFeedback; |
|
209 removeArea.iControl = &cc; |
|
210 removeArea.iAreaIndex = aAreaIndex; |
|
211 iESWT_client->Execute(removeArea); |
|
212 } |
|
213 |
|
214 void CTactileFeedbackInterfaceESWT::UnregisterFeedbackForControl(void* aControl, TInt /*aControlType*/) |
|
215 { |
|
216 MSwtControl* ctrl = (MSwtControl*)aControl; |
|
217 CCoeControl& cc = ctrl->CoeControl(); |
|
218 |
|
219 TactileFeedback_removeFeedbackForControl removeFeedback; |
|
220 removeFeedback.iTactileFeeback = iFeedback; |
|
221 removeFeedback.iControl = &cc; |
|
222 iESWT_client->Execute(removeFeedback); |
|
223 } |
|
224 |
|
225 void CTactileFeedbackInterfaceESWT::MoveAreaToFirstPriority(void* aControl, TInt /*aControlType*/, TInt aAreaIndex) |
|
226 { |
|
227 MSwtControl* ctrl = (MSwtControl*)aControl; |
|
228 CCoeControl& cc = ctrl->CoeControl(); |
|
229 |
|
230 TactileFeedback_moveAreaToFirstPriority moveArea; |
|
231 moveArea.iTactileFeeback = iFeedback; |
|
232 moveArea.iControl = &cc; |
|
233 moveArea.iAreaIndex = aAreaIndex; |
|
234 iESWT_client->Execute(moveArea); |
|
235 |
|
236 } |
|
237 |
|
238 TBool CTactileFeedbackInterfaceESWT::IsTouchFeedbackSupported() |
|
239 { |
|
240 TactileFeedback_isSupported isFeedbackSupported; |
|
241 isFeedbackSupported.iTactileFeeback = iFeedback; |
|
242 iESWT_client->Execute(isFeedbackSupported); |
|
243 |
|
244 return isFeedbackSupported.retval; |
|
245 } |
|
246 |
|
247 #endif |