|
1 /* |
|
2 * Copyright (c) 2005-2006 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: JNI methods |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "CM2GEventSource.h" |
|
20 #include "com_nokia_microedition_m2g_M2GSVGImage.h" |
|
21 #include "MM2GSVGProxy.h" |
|
22 #include <methodwrappers.h> |
|
23 |
|
24 M2G_NS_START |
|
25 |
|
26 // EXTERNAL DATA STRUCTURES |
|
27 |
|
28 // EXTERNAL FUNCTION PROTOTYPES |
|
29 |
|
30 // CONSTANTS |
|
31 |
|
32 // MACROS |
|
33 |
|
34 // LOCAL CONSTANTS AND MACROS |
|
35 |
|
36 // MODULE DATA STRUCTURES |
|
37 |
|
38 // LOCAL FUNCTION PROTOTYPES |
|
39 |
|
40 // FORWARD DECLARATIONS |
|
41 |
|
42 // CLASS DECLARATION |
|
43 |
|
44 // ================================ FUNCTIONS ================================== |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // Java_com_nokia_microedition_m2g_M2GSVGImage::_dispatchMouseEvent |
|
48 // ----------------------------------------------------------------------------- |
|
49 /** |
|
50 * Calls MM2GSVGProxy::DispatchMouseEventL method. |
|
51 * @since Series S60 3.0 |
|
52 * @param aProxy Proxy instance. |
|
53 * @param aDocumentHandle Document handle. |
|
54 * @param aX X coordinate. |
|
55 * @param aY Y coordinate |
|
56 * @param aElementHandle Target element handle |
|
57 */ |
|
58 LOCAL_C void DoDispatchMouseEventL( |
|
59 MM2GSVGProxy* aProxy, |
|
60 TInt aDocumentHandle, |
|
61 TInt aX, |
|
62 TInt aY, |
|
63 TInt* aElementHandle) |
|
64 { |
|
65 aProxy->DispatchMouseEventL( |
|
66 STATIC_CAST(TM2GSvgDocumentHandle, aDocumentHandle), |
|
67 aX, aY, *aElementHandle); |
|
68 } |
|
69 |
|
70 /** |
|
71 * JNI method |
|
72 */ |
|
73 JNIEXPORT jint JNICALL |
|
74 Java_com_nokia_microedition_m2g_M2GSVGImage__1dispatchMouseEvent( |
|
75 JNIEnv* aJni, |
|
76 jclass, |
|
77 jint aEventSourceHandle, |
|
78 jint aSvgProxyHandle, |
|
79 jint aDocumentHandle, jint aX, jint aY, jboolean aUiToolkit) |
|
80 { |
|
81 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GSVGImage ) _dispatchMouseEvent - begin"); |
|
82 |
|
83 TInt elementHandle = M2G_INVALID_HANDLE; |
|
84 TInt err = KM2GNotOk; |
|
85 if (aUiToolkit) |
|
86 { |
|
87 MSwtClient* client = reinterpret_cast< MSwtClient *>(aEventSourceHandle); |
|
88 if (client && aSvgProxyHandle) |
|
89 { |
|
90 typedef void (MM2GSVGProxy::*pDispatchMouseEventL)(const TM2GSvgDocumentHandle&, |
|
91 TInt, |
|
92 TInt, |
|
93 TM2GSvgElementHandle&); |
|
94 pDispatchMouseEventL DispatchMouseEventL = &MM2GSVGProxy::DispatchMouseEventL; |
|
95 MM2GSVGProxy * aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
96 TM2GSvgDocumentHandle lDocumentHandle = STATIC_CAST(TM2GSvgDocumentHandle, aDocumentHandle); |
|
97 TMethodWrapper4<MM2GSVGProxy,const TM2GSvgDocumentHandle&,TInt,TInt,TM2GSvgElementHandle& > |
|
98 DispatchMouseEvent( |
|
99 *aProxy, |
|
100 DispatchMouseEventL, |
|
101 lDocumentHandle, |
|
102 aX, |
|
103 aY, |
|
104 elementHandle |
|
105 ); |
|
106 err = client->Execute(DispatchMouseEvent); |
|
107 } |
|
108 } |
|
109 else |
|
110 { |
|
111 CM2GEventSource* eventSource = JavaUnhand< CM2GEventSource >(aEventSourceHandle); |
|
112 if (eventSource && aSvgProxyHandle) |
|
113 { |
|
114 err = eventSource->ExecuteTrap( |
|
115 &DoDispatchMouseEventL, |
|
116 JavaUnhand< MM2GSVGProxy >(aSvgProxyHandle), |
|
117 aDocumentHandle, aX, aY, &elementHandle); |
|
118 } |
|
119 } |
|
120 M2GGeneral::CheckErrorCode(aJni, err); |
|
121 |
|
122 M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GSVGImage ) _dispatchMouseEvent: %d - end", elementHandle); |
|
123 return elementHandle; |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // Java_com_nokia_microedition_m2g_M2GSVGImage::_focusOn |
|
128 // ----------------------------------------------------------------------------- |
|
129 /** |
|
130 * Calls MM2GSVGProxy::FocusOnL method. |
|
131 * @since Series S60 3.1 |
|
132 * @param aProxy Proxy instance. |
|
133 * @param aDocumentHandle Document handle. |
|
134 * @param aElementHandle Target element handle |
|
135 */ |
|
136 LOCAL_C void DoFocusOnL( |
|
137 MM2GSVGProxy* aProxy, |
|
138 TInt aDocumentHandle, |
|
139 TInt aElementHandle) |
|
140 { |
|
141 aProxy->FocusOnL( |
|
142 STATIC_CAST(TM2GSvgDocumentHandle, aDocumentHandle), |
|
143 STATIC_CAST(TM2GSvgElementHandle, aElementHandle)); |
|
144 } |
|
145 |
|
146 /** |
|
147 * JNI method |
|
148 */ |
|
149 JNIEXPORT void JNICALL |
|
150 Java_com_nokia_microedition_m2g_M2GSVGImage__1focusOn( |
|
151 JNIEnv* /* aJni */, |
|
152 jclass, |
|
153 jint aEventSourceHandle, |
|
154 jint aSvgProxyHandle, |
|
155 jint aDocumentHandle, jint aElementHandle, jboolean aUiToolkit) |
|
156 { |
|
157 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GSVGImage ) _focusOn - begin"); |
|
158 |
|
159 // TInt elementHandle = M2G_INVALID_HANDLE; |
|
160 // TInt err = KM2GNotOk; |
|
161 if (aUiToolkit) |
|
162 { |
|
163 MSwtClient* client = reinterpret_cast< MSwtClient *>(aEventSourceHandle); |
|
164 if (client && aSvgProxyHandle) |
|
165 { |
|
166 typedef void (MM2GSVGProxy::*pFocusOnL)( |
|
167 const TM2GSvgDocumentHandle&, |
|
168 const TM2GSvgElementHandle&); |
|
169 pFocusOnL FocusOnL = &MM2GSVGProxy::FocusOnL; |
|
170 MM2GSVGProxy * aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
171 TM2GSvgDocumentHandle lDocumentHandle = STATIC_CAST(TM2GSvgDocumentHandle, aDocumentHandle); |
|
172 TM2GSvgElementHandle lElementHandle = STATIC_CAST(TM2GSvgElementHandle, aElementHandle); |
|
173 TMethodWrapper2<MM2GSVGProxy, |
|
174 const TM2GSvgDocumentHandle&, |
|
175 const TM2GSvgElementHandle& > FocusOn( |
|
176 *aProxy, |
|
177 FocusOnL, |
|
178 lDocumentHandle, |
|
179 lElementHandle |
|
180 ); |
|
181 /*err = */ |
|
182 client->Execute(FocusOn); |
|
183 } |
|
184 } |
|
185 else |
|
186 { |
|
187 CM2GEventSource* eventSource = JavaUnhand< CM2GEventSource >(aEventSourceHandle); |
|
188 |
|
189 if (eventSource && aSvgProxyHandle) |
|
190 { |
|
191 /*err =*/ |
|
192 eventSource->ExecuteTrap( |
|
193 &DoFocusOnL, |
|
194 JavaUnhand< MM2GSVGProxy >(aSvgProxyHandle), |
|
195 aDocumentHandle, aElementHandle); |
|
196 |
|
197 } |
|
198 } |
|
199 M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GSVGImage ) _focusOn: %d - end", err); |
|
200 |
|
201 } |
|
202 |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // Java_com_nokia_microedition_m2g_M2GSVGImage::_focusOut |
|
206 // ----------------------------------------------------------------------------- |
|
207 /** |
|
208 * Calls MM2GSVGProxy::FocusOutL method. |
|
209 * @since Series S60 3.1 |
|
210 * @param aProxy Proxy instance. |
|
211 * @param aDocumentHandle Document handle. |
|
212 * @param aElementHandle Target element handle |
|
213 */ |
|
214 LOCAL_C void DoFocusOutL( |
|
215 MM2GSVGProxy* aProxy, |
|
216 TInt aDocumentHandle, |
|
217 TInt aElementHandle) |
|
218 { |
|
219 aProxy->FocusOutL( |
|
220 STATIC_CAST(TM2GSvgDocumentHandle, aDocumentHandle), |
|
221 STATIC_CAST(TM2GSvgElementHandle, aElementHandle)); |
|
222 } |
|
223 |
|
224 /** |
|
225 * JNI method |
|
226 */ |
|
227 JNIEXPORT void JNICALL |
|
228 Java_com_nokia_microedition_m2g_M2GSVGImage__1focusOut( |
|
229 JNIEnv* /* aJni */, |
|
230 jclass, |
|
231 jint aEventSourceHandle, |
|
232 jint aSvgProxyHandle, |
|
233 jint aDocumentHandle, jint aElementHandle, jboolean aUiToolkit) |
|
234 { |
|
235 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GSVGImage ) _focusOut - begin"); |
|
236 |
|
237 // TInt elementHandle = M2G_INVALID_HANDLE; |
|
238 // TInt err = KM2GNotOk; |
|
239 if (aUiToolkit) |
|
240 { |
|
241 MSwtClient* client = reinterpret_cast< MSwtClient *>(aEventSourceHandle); |
|
242 if (client && aSvgProxyHandle) |
|
243 { |
|
244 typedef void (MM2GSVGProxy::*pFocusOutL)( |
|
245 const TM2GSvgDocumentHandle&, |
|
246 const TM2GSvgElementHandle&); |
|
247 pFocusOutL FocusOutL = &MM2GSVGProxy::FocusOutL; |
|
248 MM2GSVGProxy * aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
249 TM2GSvgDocumentHandle lDocumentHandle = STATIC_CAST(TM2GSvgDocumentHandle, aDocumentHandle); |
|
250 TM2GSvgElementHandle lElementHandle = STATIC_CAST(TM2GSvgElementHandle, aElementHandle); |
|
251 TMethodWrapper2<MM2GSVGProxy, |
|
252 const TM2GSvgDocumentHandle&, |
|
253 const TM2GSvgElementHandle& > FocusOut( |
|
254 *aProxy, |
|
255 FocusOutL, |
|
256 lDocumentHandle, |
|
257 lElementHandle |
|
258 ); |
|
259 /*err = */ |
|
260 client->Execute(FocusOut); |
|
261 } |
|
262 } |
|
263 else |
|
264 { |
|
265 CM2GEventSource* eventSource = JavaUnhand< CM2GEventSource >(aEventSourceHandle); |
|
266 |
|
267 if (eventSource && aSvgProxyHandle) |
|
268 { |
|
269 /*err = */ |
|
270 eventSource->ExecuteTrap( |
|
271 &DoFocusOutL, |
|
272 JavaUnhand< MM2GSVGProxy >(aSvgProxyHandle), |
|
273 aDocumentHandle, aElementHandle); |
|
274 } |
|
275 } |
|
276 |
|
277 M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GSVGImage ) _focusOut: %d - end", err); |
|
278 |
|
279 } |
|
280 |
|
281 // ----------------------------------------------------------------------------- |
|
282 // Java_com_nokia_microedition_m2g_M2GSVGImage::_getExternalListItem |
|
283 // EXTENSION |
|
284 // ----------------------------------------------------------------------------- |
|
285 /** |
|
286 * Calls MM2GSVGProxy::GetExternalListItemL method. |
|
287 * @since Series S60 3.0 |
|
288 * @param aProxy Proxy instance. |
|
289 * @param aDocumentHandle Document pointer. |
|
290 * @param aIndex External item index. |
|
291 * @param aItem External item |
|
292 * @throws Exception if not ok |
|
293 */ |
|
294 LOCAL_C void DoGetExternalListItemL( |
|
295 MM2GSVGProxy* aProxy, |
|
296 TInt aDocumentHandle, |
|
297 TInt aIndex, |
|
298 TPtrC16* aItem) |
|
299 { |
|
300 TInt result = aProxy->GetExternalListItemL( |
|
301 STATIC_CAST(TM2GSvgDocumentHandle, aDocumentHandle), |
|
302 aIndex, |
|
303 *aItem); |
|
304 } |
|
305 |
|
306 /** |
|
307 * JNI method |
|
308 */ |
|
309 JNIEXPORT jstring JNICALL |
|
310 Java_com_nokia_microedition_m2g_M2GSVGImage__1getExternalListItem( |
|
311 JNIEnv* aJni, |
|
312 jclass, |
|
313 jint aEventSourceHandle, |
|
314 jint aSvgProxyHandle, |
|
315 jint aDocumentHandle, |
|
316 jint aIndex, |
|
317 jboolean aUiToolkit) |
|
318 { |
|
319 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GSVGImage ) _getExternalListItem - begin"); |
|
320 TPtrC16 lItem; |
|
321 TInt err = KM2GNotOk; |
|
322 TInt result = KM2GNotOk; |
|
323 if (aUiToolkit) |
|
324 { |
|
325 MSwtClient* client = reinterpret_cast< MSwtClient *>(aEventSourceHandle); |
|
326 if (client && aSvgProxyHandle) |
|
327 { |
|
328 typedef TInt(MM2GSVGProxy::*pGetExternalListItemL)( |
|
329 const TM2GSvgDocumentHandle&, |
|
330 TInt, |
|
331 TPtrC16&); |
|
332 pGetExternalListItemL GetExternalListItemL = &MM2GSVGProxy::GetExternalListItemL; |
|
333 MM2GSVGProxy * aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
334 // TM2GSvgDocumentHandle lDocumentHandle = STATIC_CAST( TM2GSvgDocumentHandle, aDocumentHandle ); |
|
335 TMethodWrapperR3<TInt, |
|
336 TInt, |
|
337 MM2GSVGProxy, |
|
338 const TM2GSvgDocumentHandle&, |
|
339 TInt, |
|
340 TPtrC16&> GetExternalListItem( |
|
341 result, |
|
342 *aProxy, |
|
343 GetExternalListItemL, |
|
344 aDocumentHandle, |
|
345 aIndex, |
|
346 lItem |
|
347 ); |
|
348 err = client->Execute(GetExternalListItem); |
|
349 } |
|
350 } |
|
351 else |
|
352 { |
|
353 CM2GEventSource* eventSource = JavaUnhand< CM2GEventSource >(aEventSourceHandle); |
|
354 |
|
355 if (eventSource && aSvgProxyHandle) |
|
356 { |
|
357 err = eventSource->ExecuteTrap( |
|
358 &DoGetExternalListItemL, |
|
359 JavaUnhand< MM2GSVGProxy >(aSvgProxyHandle), |
|
360 aDocumentHandle, |
|
361 aIndex, |
|
362 &lItem); |
|
363 M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GSVGImage ) _getExternalListItem: %d - end", err); |
|
364 } |
|
365 } |
|
366 if ((M2GGeneral::CheckErrorCode(aJni, err) == KM2GOk) && (lItem.Length() > 0)) |
|
367 { |
|
368 return CreateJavaString(*aJni, lItem); |
|
369 } |
|
370 |
|
371 return NULL; |
|
372 } |
|
373 |
|
374 // ----------------------------------------------------------------------------- |
|
375 // Java_com_nokia_microedition_m2g_M2GSVGImage::_getExternalListSize |
|
376 // ----------------------------------------------------------------------------- |
|
377 /** |
|
378 * Calls MM2GSVGProxy::GetExternalListItemL method. |
|
379 * @since Series S60 3.0 |
|
380 * @param aProxy Proxy instance. |
|
381 * @param aDocumentHandle Document handle. |
|
382 * @param aListSz List size to be returned. |
|
383 */ |
|
384 LOCAL_C void DoGetExternalListSizeL( |
|
385 MM2GSVGProxy* aProxy, |
|
386 TInt aDocumentHandle, TInt* aListSz) |
|
387 { |
|
388 aProxy->GetExternalListSizeL( |
|
389 STATIC_CAST(TM2GSvgDocumentHandle, aDocumentHandle), *aListSz); |
|
390 } |
|
391 |
|
392 /** |
|
393 * JNI method |
|
394 */ |
|
395 JNIEXPORT TInt JNICALL |
|
396 Java_com_nokia_microedition_m2g_M2GSVGImage__1getExternalListSize( |
|
397 JNIEnv* aJni, |
|
398 jclass, |
|
399 jint aEventSourceHandle, |
|
400 jint aSvgProxyHandle, |
|
401 jint aDocumentHandle, |
|
402 jboolean aUiToolkit) |
|
403 { |
|
404 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GSVGImage ) _getExternalListSize - begin"); |
|
405 |
|
406 // TInt elementHandle = M2G_INVALID_HANDLE; |
|
407 TInt err = KM2GNotOk; |
|
408 TInt listSz = 0; |
|
409 if (aUiToolkit) |
|
410 { |
|
411 MSwtClient* client = reinterpret_cast< MSwtClient *>(aEventSourceHandle); |
|
412 if (client && aSvgProxyHandle) |
|
413 { |
|
414 typedef void (MM2GSVGProxy::*pGetExternalListSizeL)( |
|
415 const TM2GSvgDocumentHandle&, |
|
416 TInt&); |
|
417 pGetExternalListSizeL GetExternalListSizeL = &MM2GSVGProxy::GetExternalListSizeL; |
|
418 MM2GSVGProxy * aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
419 TM2GSvgDocumentHandle lDocumentHandle = STATIC_CAST(TM2GSvgDocumentHandle, aDocumentHandle); |
|
420 TMethodWrapper2<MM2GSVGProxy, |
|
421 const TM2GSvgDocumentHandle&, |
|
422 TInt& > GetExternalListSize( |
|
423 *aProxy, |
|
424 GetExternalListSizeL, |
|
425 lDocumentHandle, |
|
426 listSz |
|
427 ); |
|
428 err = client->Execute(GetExternalListSize); |
|
429 } |
|
430 } |
|
431 else |
|
432 { |
|
433 CM2GEventSource* eventSource = JavaUnhand< CM2GEventSource >(aEventSourceHandle); |
|
434 if (eventSource && aSvgProxyHandle) |
|
435 { |
|
436 err = eventSource->ExecuteTrap( |
|
437 &DoGetExternalListSizeL, |
|
438 JavaUnhand< MM2GSVGProxy >(aSvgProxyHandle), |
|
439 aDocumentHandle, &listSz); |
|
440 } |
|
441 } |
|
442 M2GGeneral::CheckErrorCode(aJni, err); |
|
443 |
|
444 M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GSVGImage ) _getExternalListSize: %d - end", listSz); |
|
445 return listSz; |
|
446 } |
|
447 |
|
448 // ----------------------------------------------------------------------------- |
|
449 // Java_com_nokia_microedition_m2g_M2GSVGImage::_getExternalListItem |
|
450 // ----------------------------------------------------------------------------- |
|
451 /** |
|
452 * Calls MM2GSVGProxy::GetExternalListItemL method. |
|
453 * @since Series S60 3.0 |
|
454 * @param aProxy Proxy instance. |
|
455 * @param aDocumentHandle Document pointer. |
|
456 * @param aIndex Index. |
|
457 * @param aStrBuf Returns a string |
|
458 * @throws Exception if not ok |
|
459 */ |
|
460 LOCAL_C void DoInitViewportL( |
|
461 MM2GSVGProxy* aProxy, |
|
462 TInt aDocumentHandle) |
|
463 { |
|
464 aProxy->InitViewportL( |
|
465 STATIC_CAST(TM2GSvgDocumentHandle, aDocumentHandle)); |
|
466 } |
|
467 |
|
468 /** |
|
469 * JNI method |
|
470 */ |
|
471 JNIEXPORT void JNICALL |
|
472 Java_com_nokia_microedition_m2g_M2GSVGImage__1initViewport( |
|
473 JNIEnv*, |
|
474 jclass, |
|
475 jint aEventSourceHandle, |
|
476 jint aSvgProxyHandle, |
|
477 jint aDocumentHandle, |
|
478 jboolean aUiToolkit) |
|
479 { |
|
480 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GSVGImage ) _initViewport - begin"); |
|
481 // TInt elementHandle = M2G_INVALID_HANDLE; |
|
482 // TInt err = KM2GNotOk; |
|
483 if (aUiToolkit) |
|
484 { |
|
485 MSwtClient* client = reinterpret_cast< MSwtClient *>(aEventSourceHandle); |
|
486 if (client && aSvgProxyHandle) |
|
487 { |
|
488 typedef void (MM2GSVGProxy::*pInitViewportL)( |
|
489 const TM2GSvgDocumentHandle&); |
|
490 pInitViewportL InitViewportL = &MM2GSVGProxy::InitViewportL; |
|
491 MM2GSVGProxy * aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
492 TM2GSvgDocumentHandle lDocumentHandle = STATIC_CAST(TM2GSvgDocumentHandle, aDocumentHandle); |
|
493 TMethodWrapper1<MM2GSVGProxy, |
|
494 const TM2GSvgDocumentHandle& |
|
495 > InitViewport( |
|
496 *aProxy, |
|
497 InitViewportL, |
|
498 lDocumentHandle |
|
499 ); |
|
500 /*err = */ |
|
501 client->Execute(InitViewport); |
|
502 } |
|
503 } |
|
504 else |
|
505 { |
|
506 CM2GEventSource* eventSource = JavaUnhand< CM2GEventSource >(aEventSourceHandle); |
|
507 if (eventSource && aSvgProxyHandle) |
|
508 { |
|
509 /*err =*/ |
|
510 eventSource->ExecuteTrap( |
|
511 &DoInitViewportL, |
|
512 JavaUnhand< MM2GSVGProxy >(aSvgProxyHandle), |
|
513 aDocumentHandle); |
|
514 } |
|
515 } |
|
516 M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GSVGImage ) _initViewport: %d - end", err); |
|
517 |
|
518 } |
|
519 |
|
520 M2G_NS_END |