|
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_M2GSVGAnimationElement.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_M2GSVGAnimationElement::_beginElementAt |
|
48 // ----------------------------------------------------------------------------- |
|
49 /** |
|
50 * Calls MM2GSVGProxy::BeginElementAtL method. |
|
51 * @since Series S60 3.0 |
|
52 * @param aProxy Proxy instance. |
|
53 * @param aDocumentHandle Document handle |
|
54 * @param aElementHandle Element handle |
|
55 * @param aOffset Offset time |
|
56 * @throws Exception if not ok. |
|
57 */ |
|
58 LOCAL_C void DoBeginElementAtL( |
|
59 MM2GSVGProxy* aProxy, |
|
60 TInt aDocumentHandle, |
|
61 TInt aElementHandle, |
|
62 TReal32* aOffset, TReal32* aCurrentTime) |
|
63 { |
|
64 TInt16 restartAttribute; |
|
65 aProxy->GetEnumTraitL( |
|
66 STATIC_CAST(TM2GSvgElementHandle, aElementHandle), |
|
67 STATIC_CAST(TM2GSvgAttrType, KM2GRestartAttribute), |
|
68 restartAttribute); |
|
69 TInt isActive; |
|
70 aProxy->IsActiveL(STATIC_CAST(TM2GSvgElementHandle, aElementHandle), isActive); |
|
71 |
|
72 if (isActive && (restartAttribute == KM2GRestartWhenNotActive)) |
|
73 { |
|
74 M2G_DEBUG_1("M2G_DEBUG: M2GSVGAnimationElement::DoBeginElementAtL() - active & restart att:%d", restartAttribute); |
|
75 } |
|
76 else if ((*aCurrentTime != 0) && (restartAttribute == KM2GRestartNever)) |
|
77 { |
|
78 // Cannot restart even if animation hasn't ended? |
|
79 M2G_DEBUG_1("M2G_DEBUG: M2GSVGAnimationElement::DoBeginElementAtL() - not active & restart att:%d", restartAttribute); |
|
80 } |
|
81 else |
|
82 { |
|
83 M2G_DEBUG_2("M2G_DEBUG: M2GSVGAnimationElement::DoBeginElementAtL() - offset:%f & current:%f", *aOffset, *aCurrentTime); |
|
84 aProxy->BeginElementAtL( |
|
85 STATIC_CAST(TM2GSvgDocumentHandle, aDocumentHandle), |
|
86 STATIC_CAST(TM2GSvgElementHandle, aElementHandle), |
|
87 *aOffset + *aCurrentTime); |
|
88 } |
|
89 } |
|
90 |
|
91 /** |
|
92 * JNI method |
|
93 */ |
|
94 JNIEXPORT void JNICALL |
|
95 Java_com_nokia_microedition_m2g_M2GSVGAnimationElement__1beginElementAt( |
|
96 JNIEnv* aJni, |
|
97 jobject, |
|
98 jint aEventSourceHandle, |
|
99 jint aSvgProxyHandle, |
|
100 jint aDocumentHandle, |
|
101 jint aElementHandle, |
|
102 jfloat aOffset, |
|
103 jfloat aCurrentTime, |
|
104 jboolean aUIToolkit) |
|
105 { |
|
106 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GSVGAnimationElement ) _beginElementAt - begin"); |
|
107 TInt err = KM2GNotOk; |
|
108 if (aUIToolkit) |
|
109 { |
|
110 MSwtClient* client = reinterpret_cast< MSwtClient* >(aEventSourceHandle); |
|
111 TInt16 restartAttribute; |
|
112 TInt isActive; |
|
113 if (client && aSvgProxyHandle) |
|
114 { |
|
115 typedef void (MM2GSVGProxy::*pBeginElementAtL)(const TInt&, const TInt&,const TReal32&); |
|
116 typedef void (MM2GSVGProxy::*pGetEnumTraitL)(const TInt&, const TInt16&, TInt16&); |
|
117 typedef void (MM2GSVGProxy::*pIsActiveL)(const TInt&, TInt&); |
|
118 pBeginElementAtL BeginElementAtL = &MM2GSVGProxy::BeginElementAtL; |
|
119 pGetEnumTraitL GetEnumTraitL = &MM2GSVGProxy::GetEnumTraitL; |
|
120 pIsActiveL IsActiveL = &MM2GSVGProxy::IsActiveL; |
|
121 MM2GSVGProxy* aProxy = JavaUnhand< MM2GSVGProxy >(aSvgProxyHandle); |
|
122 TMethodWrapper3<MM2GSVGProxy,const TInt&,const TInt&, const TReal32& > |
|
123 BeginElementAt( |
|
124 *aProxy, |
|
125 BeginElementAtL, |
|
126 aDocumentHandle, |
|
127 aElementHandle, |
|
128 aOffset + aCurrentTime |
|
129 ); |
|
130 TMethodWrapper3<MM2GSVGProxy,const TInt&,const TInt16&, TInt16& > |
|
131 GetEnumTrait( |
|
132 *aProxy, |
|
133 GetEnumTraitL, |
|
134 aElementHandle, |
|
135 KM2GRestartAttribute, |
|
136 restartAttribute |
|
137 ); |
|
138 TMethodWrapper2<MM2GSVGProxy,const TInt&, TInt& > |
|
139 lIsActive( |
|
140 *aProxy, |
|
141 IsActiveL, |
|
142 aElementHandle, |
|
143 isActive |
|
144 ); |
|
145 client->Execute(GetEnumTrait); |
|
146 client->Execute(lIsActive); |
|
147 if (isActive && (restartAttribute == KM2GRestartWhenNotActive)) |
|
148 { |
|
149 M2G_DEBUG_1("M2G_DEBUG: M2GSVGAnimationElement::DoBeginElementAtL() - active & restart att:%d", restartAttribute); |
|
150 } |
|
151 else if ((aCurrentTime != 0) && (restartAttribute == KM2GRestartNever)) |
|
152 { |
|
153 M2G_DEBUG_1("M2G_DEBUG: M2GSVGAnimationElement::DoBeginElementAtL() - not active & restart att:%d", restartAttribute); |
|
154 } |
|
155 else |
|
156 { |
|
157 err = client->Execute(BeginElementAt); |
|
158 } |
|
159 } |
|
160 } |
|
161 else |
|
162 { |
|
163 CM2GEventSource* eventSource = JavaUnhand< CM2GEventSource >(aEventSourceHandle); |
|
164 if (eventSource && aSvgProxyHandle && aDocumentHandle) |
|
165 { |
|
166 err = eventSource->ExecuteTrap( |
|
167 &DoBeginElementAtL, |
|
168 JavaUnhand< MM2GSVGProxy >(aSvgProxyHandle), |
|
169 aDocumentHandle, aElementHandle, |
|
170 REINTERPRET_CAST(TReal32*, &aOffset), |
|
171 REINTERPRET_CAST(TReal32*, &aCurrentTime)); |
|
172 } |
|
173 } |
|
174 M2GGeneral::CheckErrorCode(aJni, err); |
|
175 |
|
176 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GSVGAnimationElement ) _beginElementAt - end"); |
|
177 } |
|
178 |
|
179 // ----------------------------------------------------------------------------- |
|
180 // Java_com_nokia_microedition_m2g_M2GSVGAnimationElement::_endElementAt |
|
181 // ----------------------------------------------------------------------------- |
|
182 /** |
|
183 * Calls MM2GSVGProxy::EndElementAt method. |
|
184 * @since Series S60 3.0 |
|
185 * @param aProxy Proxy instance. |
|
186 * @param aDocumentHandle Document handle |
|
187 * @param aElementHandle Element handle |
|
188 * @param aOffset Offset time |
|
189 */ |
|
190 LOCAL_C void DoEndElementAtL( |
|
191 MM2GSVGProxy* aProxy, |
|
192 TInt aDocumentHandle, |
|
193 TInt aElementHandle, |
|
194 TReal32* aOffset) |
|
195 { |
|
196 aProxy->EndElementAtL( |
|
197 STATIC_CAST(TM2GSvgDocumentHandle, aDocumentHandle), |
|
198 STATIC_CAST(TM2GSvgElementHandle, aElementHandle), |
|
199 *aOffset); |
|
200 } |
|
201 |
|
202 /** |
|
203 * JNI method |
|
204 */ |
|
205 JNIEXPORT void JNICALL |
|
206 Java_com_nokia_microedition_m2g_M2GSVGAnimationElement__1endElementAt( |
|
207 JNIEnv* aJni, |
|
208 jobject, |
|
209 jint aEventSourceHandle, |
|
210 jint aSvgProxyHandle, |
|
211 jint aDocumentHandle, |
|
212 jint aElementHandle, |
|
213 jfloat aOffset, |
|
214 jboolean aUIToolkit) |
|
215 { |
|
216 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GSVGAnimationElement ) _endElementAt - begin"); |
|
217 TInt err = KM2GNotOk; |
|
218 if (aUIToolkit) |
|
219 { |
|
220 MSwtClient* client = reinterpret_cast< MSwtClient* >(aEventSourceHandle); |
|
221 if (client && aSvgProxyHandle) |
|
222 { |
|
223 typedef void (MM2GSVGProxy::*pEndElementAtL)(const TInt&, const TInt&,const TReal32&); |
|
224 pEndElementAtL EndElementAtL = &MM2GSVGProxy::EndElementAtL; |
|
225 MM2GSVGProxy* aProxy = JavaUnhand< MM2GSVGProxy >(aSvgProxyHandle); |
|
226 TMethodWrapper3<MM2GSVGProxy,const TInt&,const TInt&, const TReal32& > |
|
227 EndElementAt( |
|
228 *aProxy, |
|
229 EndElementAtL, |
|
230 aDocumentHandle, |
|
231 aElementHandle, |
|
232 aOffset |
|
233 ); |
|
234 err = client->Execute(EndElementAt); |
|
235 } |
|
236 } |
|
237 else |
|
238 { |
|
239 CM2GEventSource* eventSource = JavaUnhand< CM2GEventSource >(aEventSourceHandle); |
|
240 if (eventSource && aSvgProxyHandle && aDocumentHandle) |
|
241 { |
|
242 err = eventSource->ExecuteTrap( |
|
243 &DoEndElementAtL, |
|
244 JavaUnhand< MM2GSVGProxy >(aSvgProxyHandle), |
|
245 aDocumentHandle, aElementHandle, |
|
246 REINTERPRET_CAST(TReal32*, &aOffset)); |
|
247 } |
|
248 } |
|
249 M2GGeneral::CheckErrorCode(aJni, err); |
|
250 |
|
251 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GSVGAnimationElement ) _endElementAt - end"); |
|
252 } |
|
253 |
|
254 // ----------------------------------------------------------------------------- |
|
255 // Java_com_nokia_microedition_m2g_M2GSVGAnimationElement::_isActive |
|
256 // ----------------------------------------------------------------------------- |
|
257 /** |
|
258 * Calls MM2GSVGProxy::EndElementAt method. |
|
259 * @since Series S60 3.0 |
|
260 * @param aProxy Proxy instance. |
|
261 * @param aElementHandle Element handle |
|
262 */ |
|
263 LOCAL_C void DoIsActiveL( |
|
264 MM2GSVGProxy* aProxy, |
|
265 TInt aElementHandle, |
|
266 TInt* aActive) |
|
267 { |
|
268 aProxy->IsActiveL( |
|
269 STATIC_CAST(TM2GSvgElementHandle, aElementHandle), |
|
270 *aActive); |
|
271 } |
|
272 |
|
273 /** |
|
274 * JNI method |
|
275 */ |
|
276 JNIEXPORT jboolean JNICALL |
|
277 Java_com_nokia_microedition_m2g_M2GSVGAnimationElement__1isActive( |
|
278 JNIEnv* aJni, |
|
279 jobject, |
|
280 jint aEventSourceHandle, |
|
281 jint aSvgProxyHandle, |
|
282 jint aElementHandle, |
|
283 jboolean aUiToolkit) |
|
284 { |
|
285 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GSVGAnimationElement ) _isActive - begin"); |
|
286 TInt err = KM2GNotOk; |
|
287 TInt active = 0; |
|
288 if (aUiToolkit) |
|
289 { |
|
290 MSwtClient* client = reinterpret_cast< MSwtClient* >(aEventSourceHandle); |
|
291 if (client && aSvgProxyHandle) |
|
292 { |
|
293 typedef void (MM2GSVGProxy::*pIsActiveL)(const TInt&,TInt&); |
|
294 pIsActiveL IsActiveL = &MM2GSVGProxy::IsActiveL; |
|
295 MM2GSVGProxy* aProxy = JavaUnhand< MM2GSVGProxy >(aSvgProxyHandle); |
|
296 TMethodWrapper2<MM2GSVGProxy,const TInt&,TInt& > |
|
297 lIsActive( |
|
298 *aProxy, |
|
299 IsActiveL, |
|
300 aElementHandle, |
|
301 active |
|
302 ); |
|
303 err = client->Execute(lIsActive); |
|
304 } |
|
305 } |
|
306 else |
|
307 { |
|
308 CM2GEventSource* eventSource = JavaUnhand< CM2GEventSource >(aEventSourceHandle); |
|
309 |
|
310 if (eventSource && aSvgProxyHandle) |
|
311 { |
|
312 err = eventSource->ExecuteTrap( |
|
313 &DoIsActiveL, |
|
314 JavaUnhand< MM2GSVGProxy >(aSvgProxyHandle), |
|
315 aElementHandle, &active); |
|
316 } |
|
317 } |
|
318 |
|
319 M2GGeneral::CheckErrorCode(aJni, err); |
|
320 M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GSVGAnimationElement ) _isActive: %d - end", active); |
|
321 return STATIC_CAST(jboolean, (active == 1 ? ETrue : EFalse)); |
|
322 } |
|
323 |
|
324 |
|
325 M2G_NS_END |
|
326 |
|
327 |