|
1 /******************************************************************************* |
|
2 * Copyright (c) 2005, 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. This program and the accompanying materials |
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
|
5 * which accompanies this distribution, and is available at |
|
6 * http://www.eclipse.org/legal/epl-v10.html |
|
7 * |
|
8 * Contributors: |
|
9 * Nokia Corporation - S60 implementation |
|
10 *******************************************************************************/ |
|
11 |
|
12 |
|
13 #include <coecntrl.h> |
|
14 #include <AknUtils.h> |
|
15 #include "swtevents.h" |
|
16 #include "eswtwidgetscore.h" |
|
17 #include "eswtwidgetsexpanded.h" |
|
18 #include "javalocalref.h" |
|
19 #include "methodcall.h" |
|
20 #include "utils.h" |
|
21 #include "swtdialogbroker.h" |
|
22 |
|
23 |
|
24 // ======== MEMBER FUNCTIONS ======== |
|
25 |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CSwtEvent::CSwtEvent |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 inline CSwtEvent::CSwtEvent(TSwtPeer aPeer) |
|
32 : iPeer(aPeer) |
|
33 { |
|
34 ASSERT(iPeer); |
|
35 } |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CSwtEvent::Dispatch |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 void CSwtEvent::Dispatch(JNIEnv* aJniEnv) |
|
42 { |
|
43 ASSERT(!IsDisplayDisposed()); |
|
44 ASSERT(!IsPeerDisposed()); |
|
45 DoDispatch(aJniEnv); |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CSwtCallbackEvent::CSwtCallbackEvent |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 inline CSwtCallbackEvent::CSwtCallbackEvent(TSwtPeer aPeer) |
|
53 : CSwtEvent(aPeer) |
|
54 { |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CSwtCallbackEvent::DoDispatch |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 void CSwtCallbackEvent::DoDispatch(JNIEnv* aJniEnv) |
|
62 { |
|
63 // Dispatch the message |
|
64 jboolean doIt; |
|
65 TBool ok = SendEvent(aJniEnv, doIt); |
|
66 |
|
67 // Check if further execution should stop |
|
68 if (IsDisplayDisposed() || IsPeerDisposed() || !ok) |
|
69 { |
|
70 return; |
|
71 } |
|
72 |
|
73 // Call back the originator |
|
74 TRAPD(error, CallMethodL(this, &CSwtCallbackEvent::CallbackL, doIt)); |
|
75 ThrowIfError(error, aJniEnv); |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CSwtPlainEvent::CSwtPlainEvent |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 CSwtPlainEvent::CSwtPlainEvent(TSwtPeer aPeer, TSwtEventType aType) |
|
83 : CSwtEvent(aPeer) |
|
84 , iType(aType) |
|
85 , iDetail(KSwtNone) |
|
86 , iItemPeer(NULL) |
|
87 { |
|
88 } |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // CSwtPlainEvent::CSwtPlainEvent |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 CSwtPlainEvent::CSwtPlainEvent(TSwtPeer aPeer, TSwtEventType aType, |
|
95 TInt aDetail, TSwtPeer aItemPeer) |
|
96 : CSwtEvent(aPeer) |
|
97 , iType(aType) |
|
98 , iDetail(aDetail) |
|
99 , iItemPeer(aItemPeer) |
|
100 { |
|
101 } |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // CSwtPlainEvent::Type |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 TSwtEventType CSwtPlainEvent::Type() const |
|
108 { |
|
109 return iType; |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CSwtPlainEvent::DoDispatch |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 void CSwtPlainEvent::DoDispatch(JNIEnv* aJniEnv) |
|
117 { |
|
118 TBool failed; |
|
119 CallVoidJavaMethod(failed, aJniEnv, Peer(), "internal_sendEvent", |
|
120 "(IILorg/eclipse/swt/widgets/Widget;)V", static_cast<jint>(iType), |
|
121 iDetail, iItemPeer); |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CSwtKeyEvent::CSwtKeyEvent |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 CSwtKeyEvent::CSwtKeyEvent(MSwtControl& aControl, const TSwtKeyEventData& aData, |
|
129 const TKeyEvent& aKeyEvent, TEventCode aType) |
|
130 : CSwtCallbackEvent(aControl.JavaPeer()) |
|
131 , iControl(aControl) |
|
132 , iSwtType(aData.iType) |
|
133 , iCharacter(static_cast<jchar>(aData.iCharacter)) |
|
134 , iKeyCode(aData.iKeyCode) |
|
135 , iStateMask(aData.iStateMask) |
|
136 , iKeyEvent(aKeyEvent) |
|
137 , iType(aType) |
|
138 { |
|
139 ASSERT(aType == EEventKeyDown || aType == EEventKey || aType == EEventKeyUp); |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CSwtKeyEvent::Type |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 TSwtEventType CSwtKeyEvent::Type() const |
|
147 { |
|
148 return iSwtType; |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // CSwtKeyEvent::SendEvent |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 TBool CSwtKeyEvent::SendEvent(JNIEnv* aJniEnv, jboolean& aDoIt) |
|
156 { |
|
157 TBool failed; |
|
158 aDoIt = CallBooleanJavaMethod(failed, aJniEnv, Peer(), "sendKeyEvent", |
|
159 "(ICII)Z", static_cast<jint>(iSwtType), iCharacter, iKeyCode, |
|
160 iStateMask); |
|
161 return (failed || aJniEnv->ExceptionCheck()) ? EFalse : ETrue; |
|
162 } |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // CSwtKeyEvent::CSwtKeyEvent |
|
166 // ----------------------------------------------------------------------------- |
|
167 // |
|
168 void CSwtKeyEvent::CallbackL(TBool aDoIt) |
|
169 { |
|
170 if (aDoIt) |
|
171 { |
|
172 // There is no difference between key-down and key event in SWT. Therefore, |
|
173 // those events are merged. If this is such an event, let's un-merge. |
|
174 // EEventKeyDown can be posted only if the key does not generate EEventKey! |
|
175 if (iType == EEventKey && iKeyEvent.iRepeats == 0) |
|
176 { |
|
177 TKeyEvent keyDownEvent(iKeyEvent); |
|
178 keyDownEvent.iCode = 0; |
|
179 iControl.ProcessKeyEventL(keyDownEvent, EEventKeyDown); |
|
180 } |
|
181 iControl.ProcessKeyEventL(iKeyEvent, iType); |
|
182 |
|
183 #ifndef RD_JAVA_S60_RELEASE_9_2 |
|
184 if (AknLayoutUtils::MSKEnabled()) |
|
185 { |
|
186 // Cba consumes the MSK event key, we have to create a simulated |
|
187 // EEventKey for EStdKeyDevice3 key down event. |
|
188 if (iType == EEventKeyDown && iKeyEvent.iScanCode == EStdKeyDevice3 && |
|
189 iKeyEvent.iRepeats == 0) |
|
190 { |
|
191 TKeyEvent keyEvent(iKeyEvent); |
|
192 keyEvent.iCode = EKeyOK; |
|
193 iControl.ProcessKeyEventL(keyEvent, EEventKey); |
|
194 } |
|
195 } |
|
196 #endif // RD_JAVA_S60_RELEASE_9_2 |
|
197 } |
|
198 } |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // CSwtTraverseEvent::CSwtTraverseEvent |
|
202 // ----------------------------------------------------------------------------- |
|
203 // |
|
204 CSwtTraverseEvent::CSwtTraverseEvent(MSwtControl& aControl, TSwtTraversal aDetail, |
|
205 TBool aDoIt, const TSwtKeyEventData& aData, const TKeyEvent& aKeyEvent, |
|
206 TEventCode aType) |
|
207 : CSwtKeyEvent(aControl, aData, aKeyEvent, aType) |
|
208 , iDetail(aDetail) |
|
209 , iDoItDefault(ConvertBoolean(aDoIt)) |
|
210 { |
|
211 } |
|
212 |
|
213 |
|
214 // ----------------------------------------------------------------------------- |
|
215 // CSwtTraverseEvent::Type |
|
216 // ----------------------------------------------------------------------------- |
|
217 // |
|
218 TSwtEventType CSwtTraverseEvent::Type() const |
|
219 { |
|
220 return ESwtEventTraverse; |
|
221 } |
|
222 |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // CSwtTraverseEvent::DoDispatch |
|
226 // Dispatches the traverse event, and depending on the event's "doit" field may |
|
227 // also dispatch the original key event. |
|
228 // ----------------------------------------------------------------------------- |
|
229 // |
|
230 void CSwtTraverseEvent::DoDispatch(JNIEnv* aJniEnv) |
|
231 { |
|
232 // Dispatch the message |
|
233 jboolean doIt; |
|
234 TBool ok = SendTraverseEvent(aJniEnv, doIt); |
|
235 |
|
236 // Check if further execution should stop |
|
237 if (IsDisplayDisposed() || IsPeerDisposed() || !ok) |
|
238 { |
|
239 return; |
|
240 } |
|
241 |
|
242 // Perform traversal or key event |
|
243 if (doIt) |
|
244 { |
|
245 if (iDetail != ESwtTraverseNone) |
|
246 { |
|
247 TRAPD(error, CallMethodL(this, &CSwtTraverseEvent::TraverseCallbackL)); |
|
248 ThrowIfError(error, aJniEnv); |
|
249 } |
|
250 } |
|
251 else |
|
252 { |
|
253 CSwtKeyEvent::DoDispatch(aJniEnv); |
|
254 } |
|
255 } |
|
256 |
|
257 // ----------------------------------------------------------------------------- |
|
258 // CSwtTraverseEvent::SendTraverseEvent |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 TBool CSwtTraverseEvent::SendTraverseEvent(JNIEnv* aJniEnv, jboolean& aDoIt) |
|
262 { |
|
263 TBool failed; |
|
264 const char* signature = "(IZCII)Lorg/eclipse/swt/widgets/Event;"; |
|
265 jobject event = CallObjectJavaMethod(failed, aJniEnv, Peer(), |
|
266 "sendTraverseEvent", signature, iDetail, iDoItDefault, |
|
267 iCharacter, iKeyCode, iStateMask); |
|
268 |
|
269 // Check if further execution should stop |
|
270 if (IsDisplayDisposed() || aJniEnv->ExceptionCheck() || failed) |
|
271 { |
|
272 return EFalse; |
|
273 } |
|
274 |
|
275 ASSERT(event); |
|
276 jclass clazz = aJniEnv->FindClass("org/eclipse/swt/widgets/Event"); |
|
277 if (!clazz) |
|
278 { |
|
279 failed = ETrue; |
|
280 } |
|
281 else |
|
282 { |
|
283 aDoIt = GetBooleanField(aJniEnv, event, clazz, "doit", failed); |
|
284 iDetail = GetIntField(aJniEnv, event, clazz, "detail", failed); |
|
285 aJniEnv->DeleteLocalRef(clazz); |
|
286 } |
|
287 aJniEnv->DeleteLocalRef(event); |
|
288 |
|
289 return !failed; |
|
290 } |
|
291 |
|
292 // ----------------------------------------------------------------------------- |
|
293 // CSwtTraverseEvent::TraverseCallbackL |
|
294 // ----------------------------------------------------------------------------- |
|
295 // |
|
296 void CSwtTraverseEvent::TraverseCallbackL() |
|
297 { |
|
298 // Ensure the control still has the focus, it may not always be so if |
|
299 // too many events have been generated before being processed |
|
300 // Must call here IsFocusControl() instead of CoeControl().IsFocused() |
|
301 // because Shells can never get Coe focus. Shell focus is defined to be |
|
302 // the state when the Shell is active and has no focused children. |
|
303 if (iControl.IsFocusControl()) |
|
304 { |
|
305 // Find the Control's Shell |
|
306 MSwtShell* shell; |
|
307 MSwtControl* ctrl = &iControl; |
|
308 while ((shell = ctrl->ShellInterface()) == NULL) |
|
309 { |
|
310 ctrl = ctrl->GetParent()->Control(); |
|
311 } |
|
312 |
|
313 // Find next focusable control |
|
314 MSwtControl* newFocus = shell->FindTraversalTargetL(iDetail, iControl); |
|
315 if (newFocus) |
|
316 { |
|
317 newFocus->CoeControl().SetFocus(ETrue, ENoDrawNow); |
|
318 } |
|
319 } |
|
320 } |
|
321 |
|
322 // ----------------------------------------------------------------------------- |
|
323 // CSwtMouseEvent::CSwtMouseEvent |
|
324 // ----------------------------------------------------------------------------- |
|
325 // |
|
326 CSwtMouseEvent::CSwtMouseEvent(TSwtPeer aPeer, TSwtEventType aType, |
|
327 TInt aButton, const TPoint& aPos, TInt aStateMask) |
|
328 : CSwtEvent(aPeer) |
|
329 , iType(aType) |
|
330 , iButton(aButton) |
|
331 , iX(aPos.iX) |
|
332 , iY(aPos.iY) |
|
333 , iStateMask(aStateMask) |
|
334 { |
|
335 } |
|
336 |
|
337 // ----------------------------------------------------------------------------- |
|
338 // CSwtMouseEvent::Type |
|
339 // ----------------------------------------------------------------------------- |
|
340 // |
|
341 TSwtEventType CSwtMouseEvent::Type() const |
|
342 { |
|
343 return iType; |
|
344 } |
|
345 |
|
346 // ----------------------------------------------------------------------------- |
|
347 // CSwtMouseEvent::DoDispatch |
|
348 // ----------------------------------------------------------------------------- |
|
349 // |
|
350 void CSwtMouseEvent::DoDispatch(JNIEnv* aJniEnv) |
|
351 { |
|
352 TBool failed; |
|
353 CallVoidJavaMethod(failed, aJniEnv, Peer(), "sendMouseEvent", "(IIIII)V", |
|
354 static_cast<jint>(iType), iButton, iX, iY, iStateMask); |
|
355 } |
|
356 |
|
357 // ----------------------------------------------------------------------------- |
|
358 // CSwtScrollEvent::CSwtScrollEvent |
|
359 // ----------------------------------------------------------------------------- |
|
360 // |
|
361 CSwtScrollEvent::CSwtScrollEvent(TSwtPeer aPeer, TInt aDetail) |
|
362 : CSwtEvent(aPeer) |
|
363 , iDetail(aDetail) |
|
364 { |
|
365 ASSERT((aDetail >= ESwtKeyArrowUp && aDetail <= ESwtKeyEnd) |
|
366 || aDetail == KSwtDrag || aDetail == 0); |
|
367 } |
|
368 |
|
369 // ----------------------------------------------------------------------------- |
|
370 // CSwtScrollEvent::Type |
|
371 // ----------------------------------------------------------------------------- |
|
372 // |
|
373 TSwtEventType CSwtScrollEvent::Type() const |
|
374 { |
|
375 return ESwtEventSelection; |
|
376 } |
|
377 |
|
378 // ----------------------------------------------------------------------------- |
|
379 // CSwtScrollEvent::DoDispatch |
|
380 // ----------------------------------------------------------------------------- |
|
381 // |
|
382 void CSwtScrollEvent::DoDispatch(JNIEnv* aJniEnv) |
|
383 { |
|
384 TBool failed; |
|
385 CallVoidJavaMethod(failed, aJniEnv, Peer(), "sendScrollEvent", "(I)V", iDetail); |
|
386 } |
|
387 |
|
388 // ----------------------------------------------------------------------------- |
|
389 // CSwtPaintEvent::CSwtPaintEvent |
|
390 // ----------------------------------------------------------------------------- |
|
391 // |
|
392 CSwtPaintEvent::CSwtPaintEvent(TSwtPeer aSenderPeer, TSwtPeer aShellPeer, |
|
393 const TRect& aRect, TBool aMergeable) |
|
394 : CSwtEvent(aShellPeer) |
|
395 , iMergeable(aMergeable) |
|
396 , iRect(aRect) |
|
397 , iSenderPeer(aSenderPeer) |
|
398 { |
|
399 } |
|
400 |
|
401 // ----------------------------------------------------------------------------- |
|
402 // CSwtPaintEvent::Type |
|
403 // ----------------------------------------------------------------------------- |
|
404 // |
|
405 TSwtEventType CSwtPaintEvent::Type() const |
|
406 { |
|
407 return ESwtEventPaint; |
|
408 } |
|
409 |
|
410 // ----------------------------------------------------------------------------- |
|
411 // CSwtPaintEvent::DoDispatch |
|
412 // ----------------------------------------------------------------------------- |
|
413 // |
|
414 void CSwtPaintEvent::DoDispatch(JNIEnv* aJniEnv) |
|
415 { |
|
416 TBool failed; |
|
417 CallObjectJavaMethod(failed, aJniEnv, Peer(), "paint", |
|
418 "(Lorg/eclipse/swt/graphics/Rectangle;ZZ)Lorg/eclipse/swt/graphics/Rectangle;", |
|
419 NewJavaRectangle(aJniEnv, iRect), ConvertBoolean(ETrue), |
|
420 ConvertBoolean(ETrue)); |
|
421 } |
|
422 |
|
423 // ----------------------------------------------------------------------------- |
|
424 // CSwtResizeEvent::CSwtResizeEvent |
|
425 // ----------------------------------------------------------------------------- |
|
426 // |
|
427 CSwtResizeEvent::CSwtResizeEvent(TSwtPeer aPeer) |
|
428 : CSwtEvent(aPeer) |
|
429 { |
|
430 } |
|
431 |
|
432 // ----------------------------------------------------------------------------- |
|
433 // CSwtResizeEvent::Type |
|
434 // ----------------------------------------------------------------------------- |
|
435 // |
|
436 TSwtEventType CSwtResizeEvent::Type() const |
|
437 { |
|
438 return ESwtEventResize; |
|
439 } |
|
440 |
|
441 // ----------------------------------------------------------------------------- |
|
442 // CSwtResizeEvent::DoDispatch |
|
443 // ----------------------------------------------------------------------------- |
|
444 // |
|
445 void CSwtResizeEvent::DoDispatch(JNIEnv* aJniEnv) |
|
446 { |
|
447 TBool failed; |
|
448 CallVoidJavaMethod(failed, aJniEnv, Peer(), "sendResizeEvent", "()V"); |
|
449 } |
|
450 |
|
451 // ----------------------------------------------------------------------------- |
|
452 // CSwtTimerCallback::CSwtTimerCallback |
|
453 // ----------------------------------------------------------------------------- |
|
454 // |
|
455 CSwtTimerCallback::CSwtTimerCallback(TSwtPeer aPeer, TInt aTimerHandle) |
|
456 : CSwtEvent(aPeer) |
|
457 , iTimerHandle(aTimerHandle) |
|
458 { |
|
459 } |
|
460 |
|
461 // ----------------------------------------------------------------------------- |
|
462 // CSwtTimerCallback::Type |
|
463 // ----------------------------------------------------------------------------- |
|
464 // |
|
465 TSwtEventType CSwtTimerCallback::Type() const |
|
466 { |
|
467 return ESwtEventNone; |
|
468 } |
|
469 |
|
470 // ----------------------------------------------------------------------------- |
|
471 // CSwtTimerCallback::DoDispatch |
|
472 // ----------------------------------------------------------------------------- |
|
473 // |
|
474 void CSwtTimerCallback::DoDispatch(JNIEnv* aJniEnv) |
|
475 { |
|
476 TBool failed; |
|
477 CallVoidJavaMethod(failed, aJniEnv, Peer(), "timerCallback", "(I)V", |
|
478 iTimerHandle); |
|
479 } |
|
480 |
|
481 // ----------------------------------------------------------------------------- |
|
482 // CSwtVerifyEvent::CSwtVerifyEvent |
|
483 // ----------------------------------------------------------------------------- |
|
484 // |
|
485 CSwtVerifyEvent::CSwtVerifyEvent(MSwtVerifyEventObserver& aWidget, |
|
486 TSwtPeer aPeer, TInt aStart, TInt aEnd) |
|
487 : CSwtEvent(aPeer) |
|
488 , iWidget(aWidget) |
|
489 , iStart(aStart) |
|
490 , iEnd(aEnd) |
|
491 { |
|
492 } |
|
493 |
|
494 // ----------------------------------------------------------------------------- |
|
495 // CSwtVerifyEvent::~CSwtVerifyEvent |
|
496 // ----------------------------------------------------------------------------- |
|
497 // |
|
498 CSwtVerifyEvent::~CSwtVerifyEvent() |
|
499 { |
|
500 delete iOriginalText; |
|
501 } |
|
502 |
|
503 // ----------------------------------------------------------------------------- |
|
504 // CSwtVerifyEvent::ConstructL |
|
505 // ----------------------------------------------------------------------------- |
|
506 // |
|
507 void CSwtVerifyEvent::ConstructL(const TDesC& aText) |
|
508 { |
|
509 iOriginalText = aText.AllocL(); |
|
510 } |
|
511 |
|
512 // ----------------------------------------------------------------------------- |
|
513 // CSwtVerifyEvent::NewL |
|
514 // ----------------------------------------------------------------------------- |
|
515 // |
|
516 CSwtVerifyEvent* CSwtVerifyEvent::NewL(MSwtVerifyEventObserver& aWidget, |
|
517 TSwtPeer aPeer, TInt aStart, TInt aEnd, const TDesC& aText) |
|
518 { |
|
519 CSwtVerifyEvent* self = new(ELeave) CSwtVerifyEvent(aWidget, aPeer, |
|
520 aStart, aEnd); |
|
521 CleanupStack::PushL(self); |
|
522 self->ConstructL(aText); |
|
523 CleanupStack::Pop(self); |
|
524 return self; |
|
525 } |
|
526 |
|
527 // ----------------------------------------------------------------------------- |
|
528 // CSwtVerifyEvent::Type |
|
529 // ----------------------------------------------------------------------------- |
|
530 // |
|
531 TSwtEventType CSwtVerifyEvent::Type() const |
|
532 { |
|
533 return ESwtEventVerify; |
|
534 } |
|
535 |
|
536 // ----------------------------------------------------------------------------- |
|
537 // CSwtVerifyEvent::DoDispatch |
|
538 // ----------------------------------------------------------------------------- |
|
539 // |
|
540 void CSwtVerifyEvent::DoDispatch(JNIEnv* aJniEnv) |
|
541 { |
|
542 TRAPD(error, DoDispatchL(aJniEnv)); |
|
543 ThrowIfError(error, aJniEnv); |
|
544 } |
|
545 |
|
546 // ----------------------------------------------------------------------------- |
|
547 // CSwtVerifyEvent::DoDispatchL |
|
548 // ----------------------------------------------------------------------------- |
|
549 // |
|
550 void CSwtVerifyEvent::DoDispatchL(JNIEnv* aJniEnv) |
|
551 { |
|
552 // Convert the original string to a Java string |
|
553 jstring text = NewJavaString(aJniEnv, *iOriginalText); |
|
554 DeleteInUiHeap(iOriginalText); |
|
555 iOriginalText = NULL; |
|
556 if (!text) |
|
557 { |
|
558 return; |
|
559 } |
|
560 |
|
561 // Dispatch the message |
|
562 TBool failed; |
|
563 const char* signature = "(IILjava/lang/String;)Lorg/eclipse/swt/widgets/Event;"; |
|
564 RJavaLocalRef<jobject> event(aJniEnv, CallObjectJavaMethod(failed, aJniEnv, |
|
565 Peer(), "sendVerifyEvent", signature, iStart, iEnd, text)); |
|
566 aJniEnv->DeleteLocalRef(text); |
|
567 |
|
568 // Check if further execution should stop |
|
569 if (IsDisplayDisposed() || failed || aJniEnv->ExceptionCheck()) |
|
570 { |
|
571 return; |
|
572 } |
|
573 |
|
574 ASSERT(event); |
|
575 |
|
576 // Retrieve "doit" and "text" |
|
577 jboolean doIt = JNI_FALSE; |
|
578 HBufC* verifiedText = NULL; |
|
579 CleanupClosePushL(event); |
|
580 RJavaLocalRef<jclass> clazz(aJniEnv, aJniEnv->FindClass( |
|
581 "org/eclipse/swt/widgets/Event")); |
|
582 if (!clazz) |
|
583 { |
|
584 failed = ETrue; |
|
585 } |
|
586 else |
|
587 { |
|
588 CleanupClosePushL(clazz); |
|
589 doIt = GetBooleanField(aJniEnv, event, clazz, "doit", failed); |
|
590 if (doIt) |
|
591 { |
|
592 verifiedText = GetStringFieldL(aJniEnv, event, clazz, "text", failed); |
|
593 } |
|
594 CleanupStack::PopAndDestroy(&clazz); |
|
595 } |
|
596 CleanupStack::PopAndDestroy(&event); |
|
597 |
|
598 // Callback the originator |
|
599 if (doIt && !failed && !IsPeerDisposed()) |
|
600 { |
|
601 TPtr ptr(NULL, 0, 0); |
|
602 if (verifiedText) |
|
603 { |
|
604 CleanupStack::PushL(verifiedText); |
|
605 ptr.Set(verifiedText->Des()); |
|
606 } |
|
607 CallMethodL(&iWidget, &MSwtVerifyEventObserver::ProcessVerifiedTextL, |
|
608 iStart, iEnd, ptr); |
|
609 if (verifiedText) |
|
610 { |
|
611 CleanupStack::Pop(verifiedText); |
|
612 } |
|
613 } |
|
614 delete verifiedText; |
|
615 } |
|
616 |
|
617 // ----------------------------------------------------------------------------- |
|
618 // CSwtScreenEvent::CSwtScreenEvent |
|
619 // ----------------------------------------------------------------------------- |
|
620 // |
|
621 CSwtScreenEvent::CSwtScreenEvent(TSwtPeer aPeer, TInt aType) |
|
622 : CSwtEvent(aPeer) |
|
623 , iType(aType) |
|
624 { |
|
625 } |
|
626 |
|
627 // ----------------------------------------------------------------------------- |
|
628 // CSwtScreenEvent::Type |
|
629 // ----------------------------------------------------------------------------- |
|
630 // |
|
631 TSwtEventType CSwtScreenEvent::Type() const |
|
632 { |
|
633 return ESwtEventNone; |
|
634 } |
|
635 |
|
636 // ----------------------------------------------------------------------------- |
|
637 // CSwtScreenEvent::DoDispatch |
|
638 // ----------------------------------------------------------------------------- |
|
639 // |
|
640 void CSwtScreenEvent::DoDispatch(JNIEnv* aJniEnv) |
|
641 { |
|
642 TBool failed; |
|
643 |
|
644 const char* methodName; |
|
645 switch (iType) |
|
646 { |
|
647 case MSwtScreen::KEventScreenActivated: |
|
648 methodName = "internal_sendScreenEventActivated"; |
|
649 break; |
|
650 case MSwtScreen::KEventScreenDeactivated: |
|
651 methodName = "internal_sendScreenEventDeactivated"; |
|
652 break; |
|
653 case MSwtScreen::KEventScreenOrientationChanged: |
|
654 methodName = "internal_sendOrientationScreenChanged"; |
|
655 break; |
|
656 default: |
|
657 return; |
|
658 } |
|
659 |
|
660 CallVoidJavaMethod(failed, aJniEnv, Peer(), methodName, "()V"); |
|
661 } |
|
662 |
|
663 // ----------------------------------------------------------------------------- |
|
664 // CSwtMobileDeviceEvent::CSwtMobileDeviceEvent |
|
665 // ----------------------------------------------------------------------------- |
|
666 // |
|
667 CSwtMobileDeviceEvent::CSwtMobileDeviceEvent(TSwtPeer aPeer, TInt aEventType) |
|
668 : CSwtEvent(aPeer) |
|
669 , iEventType(aEventType) |
|
670 { |
|
671 } |
|
672 |
|
673 // ----------------------------------------------------------------------------- |
|
674 // CSwtMobileDeviceEvent::Type |
|
675 // ----------------------------------------------------------------------------- |
|
676 // |
|
677 TSwtEventType CSwtMobileDeviceEvent::Type() const |
|
678 { |
|
679 return ESwtEventNone; |
|
680 } |
|
681 |
|
682 // ----------------------------------------------------------------------------- |
|
683 // CSwtMobileDeviceEvent::DoDispatch |
|
684 // ----------------------------------------------------------------------------- |
|
685 // |
|
686 void CSwtMobileDeviceEvent::DoDispatch(JNIEnv* aJniEnv) |
|
687 { |
|
688 TBool failed; |
|
689 CallVoidJavaMethod(failed, aJniEnv, Peer(), |
|
690 "internal_sendMobileDeviceEvent", "(I)V", iEventType); |
|
691 } |
|
692 |
|
693 // ----------------------------------------------------------------------------- |
|
694 // CSwtTreeEvent::CSwtTreeEvent |
|
695 // ----------------------------------------------------------------------------- |
|
696 // |
|
697 CSwtTreeEvent::CSwtTreeEvent(TSwtPeer aPeer, TSwtEventType aType, TInt aItemHandle) |
|
698 : CSwtEvent(aPeer) |
|
699 , iType(aType) |
|
700 , iItemHandle(aItemHandle) |
|
701 { |
|
702 } |
|
703 |
|
704 // ----------------------------------------------------------------------------- |
|
705 // CSwtTreeEvent::Type |
|
706 // ----------------------------------------------------------------------------- |
|
707 // |
|
708 TSwtEventType CSwtTreeEvent::Type() const |
|
709 { |
|
710 return iType; |
|
711 } |
|
712 |
|
713 // ----------------------------------------------------------------------------- |
|
714 // CSwtTreeEvent::DoDispatch |
|
715 // ----------------------------------------------------------------------------- |
|
716 // |
|
717 void CSwtTreeEvent::DoDispatch(JNIEnv* aJniEnv) |
|
718 { |
|
719 TBool failed; |
|
720 CallVoidJavaMethod(failed, aJniEnv, Peer(), "internal_sendEvent", |
|
721 "(II)V", static_cast< jint >(iType), static_cast< jint >(iItemHandle)); |
|
722 } |
|
723 |
|
724 // ----------------------------------------------------------------------------- |
|
725 // CSwtForegroundEvent::CSwtForegroundEvent |
|
726 // ----------------------------------------------------------------------------- |
|
727 // |
|
728 CSwtForegroundEvent::CSwtForegroundEvent(TSwtPeer aPeer, |
|
729 const TBool& aForeground) |
|
730 : CSwtEvent(aPeer) |
|
731 , iForeground(aForeground) |
|
732 { |
|
733 } |
|
734 |
|
735 // ----------------------------------------------------------------------------- |
|
736 // CSwtForegroundEvent::Type |
|
737 // ----------------------------------------------------------------------------- |
|
738 // |
|
739 TSwtEventType CSwtForegroundEvent::Type() const |
|
740 { |
|
741 return ESwtEventForeground; |
|
742 } |
|
743 |
|
744 // ----------------------------------------------------------------------------- |
|
745 // CSwtForegroundEvent::DoDispatch |
|
746 // ----------------------------------------------------------------------------- |
|
747 // |
|
748 void CSwtForegroundEvent::DoDispatch(JNIEnv* aJniEnv) |
|
749 { |
|
750 TBool failed; |
|
751 jboolean jForeground = JNI_TRUE; |
|
752 if (!iForeground) |
|
753 { |
|
754 jForeground = JNI_FALSE; |
|
755 } |
|
756 CallStaticVoidJavaMethod(failed, aJniEnv, |
|
757 "org/eclipse/swt/internal/symbian/ForegroundNotifyWrapper", |
|
758 "setForeground", "(Z)V", jForeground); |
|
759 } |
|
760 |
|
761 // ----------------------------------------------------------------------------- |
|
762 // CSwtLocationChangingEvent::CSwtLocationChangingEvent |
|
763 // ----------------------------------------------------------------------------- |
|
764 // |
|
765 CSwtLocationChangingEvent::CSwtLocationChangingEvent(TSwtPeer aPeer, |
|
766 MSwtBrowser& aBrowser, TBool aDoIt, TBool aTop, |
|
767 TSwtBrCallBackOperationType aCallBackOperationType) |
|
768 : CSwtCallbackEvent(aPeer) |
|
769 , iBrowser(&aBrowser) |
|
770 , iDoIt(aDoIt) |
|
771 , iTop(aTop) |
|
772 , iCallBackOperationType(aCallBackOperationType) |
|
773 { |
|
774 } |
|
775 |
|
776 // ----------------------------------------------------------------------------- |
|
777 // CSwtLocationChangingEvent::ConstructL |
|
778 // ----------------------------------------------------------------------------- |
|
779 // |
|
780 void CSwtLocationChangingEvent::ConstructL(const TDesC& aLocation) |
|
781 { |
|
782 iLocation = aLocation.AllocL(); |
|
783 } |
|
784 |
|
785 // ----------------------------------------------------------------------------- |
|
786 // CSwtLocationChangingEvent::NewL |
|
787 // ----------------------------------------------------------------------------- |
|
788 // |
|
789 CSwtLocationChangingEvent* CSwtLocationChangingEvent::NewL(TSwtPeer aPeer, |
|
790 MSwtBrowser& aBrowser, TBool aDoIt, TBool aTop, |
|
791 const TDesC& aLocation, TSwtBrCallBackOperationType aCallBackOperationType) |
|
792 { |
|
793 CSwtLocationChangingEvent* self = new(ELeave) CSwtLocationChangingEvent( |
|
794 aPeer, aBrowser, aDoIt, aTop, aCallBackOperationType); |
|
795 CleanupStack::PushL(self); |
|
796 self->ConstructL(aLocation); |
|
797 CleanupStack::Pop(self); |
|
798 return self; |
|
799 } |
|
800 |
|
801 // ----------------------------------------------------------------------------- |
|
802 // CSwtLocationChangingEvent::~CSwtLocationChangingEvent |
|
803 // ----------------------------------------------------------------------------- |
|
804 // |
|
805 CSwtLocationChangingEvent::~CSwtLocationChangingEvent() |
|
806 { |
|
807 delete iLocation; |
|
808 } |
|
809 |
|
810 // ----------------------------------------------------------------------------- |
|
811 // CSwtLocationChangingEvent::SendEvent |
|
812 // ----------------------------------------------------------------------------- |
|
813 // |
|
814 TBool CSwtLocationChangingEvent::SendEvent(JNIEnv* aJniEnv, jboolean& aDoIt) |
|
815 { |
|
816 TBool failed; |
|
817 jstring location = NewJavaString(aJniEnv, *iLocation); |
|
818 aDoIt = CallBooleanJavaMethod(failed, aJniEnv, Peer(), |
|
819 "internal_sendLocationChangingEvent", "(ZZLjava/lang/String;)Z", |
|
820 static_cast<jboolean>(iDoIt), static_cast<jboolean>(iTop), |
|
821 location); |
|
822 // Don't delete iLocation here, CallBack function still needs it. |
|
823 return (failed || aJniEnv->ExceptionCheck()) ? EFalse : ETrue; |
|
824 } |
|
825 |
|
826 // ----------------------------------------------------------------------------- |
|
827 // CSwtLocationChangingEvent::CallbackL |
|
828 // This function is always called in UI thread |
|
829 // ----------------------------------------------------------------------------- |
|
830 // |
|
831 void CSwtLocationChangingEvent::CallbackL(TBool aDoIt) |
|
832 { |
|
833 if (aDoIt) |
|
834 { |
|
835 // Load URL based on iCallBackOperationType |
|
836 TRAP_IGNORE(iBrowser->DoSetUrlL(*iLocation, iCallBackOperationType)); |
|
837 } |
|
838 delete iLocation; |
|
839 iLocation = NULL; |
|
840 } |
|
841 |
|
842 // ----------------------------------------------------------------------------- |
|
843 // CSwtLocationChangedEvent::CSwtLocationChangedEvent |
|
844 // ----------------------------------------------------------------------------- |
|
845 // |
|
846 CSwtLocationChangedEvent::CSwtLocationChangedEvent(TSwtPeer aPeer, TBool aDoIt, |
|
847 TBool aTop) |
|
848 : CSwtEvent(aPeer) |
|
849 , iDoIt(aDoIt) |
|
850 , iTop(aTop) |
|
851 { |
|
852 } |
|
853 |
|
854 // ----------------------------------------------------------------------------- |
|
855 // CSwtLocationChangedEvent::ConstructL |
|
856 // ----------------------------------------------------------------------------- |
|
857 // |
|
858 void CSwtLocationChangedEvent::ConstructL(const TDesC& aLocation) |
|
859 { |
|
860 iLocation = aLocation.AllocL(); |
|
861 } |
|
862 |
|
863 // ----------------------------------------------------------------------------- |
|
864 // CSwtLocationChangedEvent::NewL |
|
865 // ----------------------------------------------------------------------------- |
|
866 // |
|
867 CSwtLocationChangedEvent* CSwtLocationChangedEvent::NewL(TSwtPeer aPeer, |
|
868 TBool aDoIt, TBool aTop, const TDesC& aLocation) |
|
869 { |
|
870 CSwtLocationChangedEvent* self = new(ELeave) CSwtLocationChangedEvent( |
|
871 aPeer, aDoIt, aTop); |
|
872 CleanupStack::PushL(self); |
|
873 self->ConstructL(aLocation); |
|
874 CleanupStack::Pop(self); |
|
875 return self; |
|
876 } |
|
877 |
|
878 // ----------------------------------------------------------------------------- |
|
879 // CSwtLocationChangedEvent::~CSwtLocationChangedEvent |
|
880 // ----------------------------------------------------------------------------- |
|
881 // |
|
882 CSwtLocationChangedEvent::~CSwtLocationChangedEvent() |
|
883 { |
|
884 delete iLocation; |
|
885 } |
|
886 |
|
887 // ----------------------------------------------------------------------------- |
|
888 // CSwtLocationChangedEvent::DoDispatch |
|
889 // ----------------------------------------------------------------------------- |
|
890 // |
|
891 void CSwtLocationChangedEvent::DoDispatch(JNIEnv* aJniEnv) |
|
892 { |
|
893 TBool failed; |
|
894 jstring location = NewJavaString(aJniEnv, *iLocation); |
|
895 |
|
896 DeleteInUiHeap(iLocation); |
|
897 iLocation = NULL; |
|
898 |
|
899 CallVoidJavaMethod(failed, aJniEnv, Peer(), |
|
900 "internal_sendLocationChangedEvent", "(ZZLjava/lang/String;)V", |
|
901 static_cast< jboolean >(iDoIt), static_cast< jboolean >(iTop), |
|
902 location); |
|
903 } |
|
904 |
|
905 // ----------------------------------------------------------------------------- |
|
906 // CSwtProgressEvent::CSwtProgressEvent |
|
907 // ----------------------------------------------------------------------------- |
|
908 // |
|
909 CSwtProgressEvent::CSwtProgressEvent(TSwtPeer aPeer, TInt aCurrent,TInt aTotal) |
|
910 : CSwtEvent(aPeer) |
|
911 , iCurrent(aCurrent) |
|
912 , iTotal(aTotal) |
|
913 { |
|
914 } |
|
915 |
|
916 // ----------------------------------------------------------------------------- |
|
917 // CSwtProgressEvent::~CSwtProgressEvent |
|
918 // ----------------------------------------------------------------------------- |
|
919 // |
|
920 CSwtProgressEvent::~CSwtProgressEvent() |
|
921 { |
|
922 } |
|
923 |
|
924 // ----------------------------------------------------------------------------- |
|
925 // CSwtProgressEvent::DoDispatch |
|
926 // ----------------------------------------------------------------------------- |
|
927 // |
|
928 void CSwtProgressEvent::DoDispatch(JNIEnv* aJniEnv) |
|
929 { |
|
930 TBool failed; |
|
931 CallVoidJavaMethod(failed, aJniEnv, Peer(), "internal_sendProgressEvent", |
|
932 "(II)V", static_cast< jint >(iCurrent),static_cast< jint >(iTotal)); |
|
933 } |
|
934 |
|
935 // ----------------------------------------------------------------------------- |
|
936 // CSwtProgressCompletedEvent::DoDispatch |
|
937 // ----------------------------------------------------------------------------- |
|
938 // |
|
939 CSwtProgressCompletedEvent::CSwtProgressCompletedEvent(TSwtPeer aPeer, |
|
940 TInt aCurrent, TInt aTotal) |
|
941 : CSwtEvent(aPeer) |
|
942 , iCurrent(aCurrent) |
|
943 , iTotal(aTotal) |
|
944 { |
|
945 } |
|
946 |
|
947 // ----------------------------------------------------------------------------- |
|
948 // CSwtProgressCompletedEvent::~CSwtProgressCompletedEvent |
|
949 // ----------------------------------------------------------------------------- |
|
950 // |
|
951 CSwtProgressCompletedEvent::~CSwtProgressCompletedEvent() |
|
952 { |
|
953 } |
|
954 |
|
955 // ----------------------------------------------------------------------------- |
|
956 // CSwtProgressCompletedEvent::DoDispatch |
|
957 // ----------------------------------------------------------------------------- |
|
958 // |
|
959 void CSwtProgressCompletedEvent::DoDispatch(JNIEnv* aJniEnv) |
|
960 { |
|
961 TBool failed; |
|
962 CallVoidJavaMethod(failed, aJniEnv, Peer(), |
|
963 "internal_sendProgressCompletedEvent", "(II)V", |
|
964 static_cast< jint >(iCurrent),static_cast< jint >(iTotal)); |
|
965 } |
|
966 |
|
967 // ----------------------------------------------------------------------------- |
|
968 // CSwtStatusTextEvent::CSwtStatusTextEvent |
|
969 // ----------------------------------------------------------------------------- |
|
970 // |
|
971 CSwtStatusTextEvent::CSwtStatusTextEvent(TSwtPeer aPeer) |
|
972 : CSwtEvent(aPeer) |
|
973 { |
|
974 } |
|
975 |
|
976 // ----------------------------------------------------------------------------- |
|
977 // CSwtStatusTextEvent::ConstructL |
|
978 // ----------------------------------------------------------------------------- |
|
979 // |
|
980 void CSwtStatusTextEvent::ConstructL(const TDesC& aStatusText) |
|
981 { |
|
982 iStatusText = aStatusText.AllocL(); |
|
983 } |
|
984 |
|
985 // ----------------------------------------------------------------------------- |
|
986 // CSwtStatusTextEvent::NewL |
|
987 // ----------------------------------------------------------------------------- |
|
988 // |
|
989 CSwtStatusTextEvent* CSwtStatusTextEvent::NewL(TSwtPeer aPeer, |
|
990 const TDesC& aStatusText) |
|
991 { |
|
992 CSwtStatusTextEvent* self = new(ELeave) CSwtStatusTextEvent(aPeer); |
|
993 CleanupStack::PushL(self); |
|
994 self->ConstructL(aStatusText); |
|
995 CleanupStack::Pop(self); |
|
996 return self; |
|
997 } |
|
998 |
|
999 // ----------------------------------------------------------------------------- |
|
1000 // CSwtStatusTextEvent::~CSwtStatusTextEvent |
|
1001 // ----------------------------------------------------------------------------- |
|
1002 // |
|
1003 CSwtStatusTextEvent::~CSwtStatusTextEvent() |
|
1004 { |
|
1005 delete iStatusText; |
|
1006 } |
|
1007 |
|
1008 // ----------------------------------------------------------------------------- |
|
1009 // CSwtStatusTextEvent::DoDispatch |
|
1010 // ----------------------------------------------------------------------------- |
|
1011 // |
|
1012 void CSwtStatusTextEvent::DoDispatch(JNIEnv* aJniEnv) |
|
1013 { |
|
1014 TBool failed; |
|
1015 jstring statusText = NewJavaString(aJniEnv, *iStatusText); |
|
1016 DeleteInUiHeap(iStatusText); |
|
1017 iStatusText = NULL; |
|
1018 CallVoidJavaMethod(failed, aJniEnv, Peer(), "internal_sendStatusTextEvent", |
|
1019 "(Ljava/lang/String;)V", statusText); |
|
1020 } |
|
1021 |
|
1022 // ----------------------------------------------------------------------------- |
|
1023 // CSwtTitleEvent::CSwtTitleEvent |
|
1024 // ----------------------------------------------------------------------------- |
|
1025 // |
|
1026 CSwtTitleEvent::CSwtTitleEvent(TSwtPeer aPeer) |
|
1027 : CSwtEvent(aPeer) |
|
1028 { |
|
1029 } |
|
1030 |
|
1031 // ----------------------------------------------------------------------------- |
|
1032 // CSwtTitleEvent::ConstructL |
|
1033 // ----------------------------------------------------------------------------- |
|
1034 // |
|
1035 void CSwtTitleEvent::ConstructL(const TDesC& aTitle) |
|
1036 { |
|
1037 iTitle = aTitle.AllocL(); |
|
1038 } |
|
1039 |
|
1040 // ----------------------------------------------------------------------------- |
|
1041 // CSwtTitleEvent::NewL |
|
1042 // ----------------------------------------------------------------------------- |
|
1043 // |
|
1044 CSwtTitleEvent* CSwtTitleEvent::NewL(TSwtPeer aPeer, const TDesC& aTitle) |
|
1045 { |
|
1046 |
|
1047 CSwtTitleEvent* self = new(ELeave) CSwtTitleEvent(aPeer); |
|
1048 CleanupStack::PushL(self); |
|
1049 self->ConstructL(aTitle); |
|
1050 CleanupStack::Pop(self); |
|
1051 return self; |
|
1052 } |
|
1053 |
|
1054 // ----------------------------------------------------------------------------- |
|
1055 // CSwtTitleEvent::~CSwtTitleEvent |
|
1056 // ----------------------------------------------------------------------------- |
|
1057 // |
|
1058 CSwtTitleEvent::~CSwtTitleEvent() |
|
1059 { |
|
1060 delete iTitle; |
|
1061 } |
|
1062 |
|
1063 // ----------------------------------------------------------------------------- |
|
1064 // CSwtTitleEvent::DoDispatch |
|
1065 // ----------------------------------------------------------------------------- |
|
1066 // |
|
1067 void CSwtTitleEvent::DoDispatch(JNIEnv* aJniEnv) |
|
1068 { |
|
1069 |
|
1070 TBool failed; |
|
1071 jstring title = NewJavaString(aJniEnv, *iTitle); |
|
1072 DeleteInUiHeap(iTitle); |
|
1073 iTitle = NULL; |
|
1074 CallVoidJavaMethod(failed, aJniEnv, Peer(), "internal_sendTitleEvent", |
|
1075 "(Ljava/lang/String;)V", title); |
|
1076 } |
|
1077 |
|
1078 // ----------------------------------------------------------------------------- |
|
1079 // CSwtDialogStringResultEvent::CSwtDialogStringResultEvent |
|
1080 // ----------------------------------------------------------------------------- |
|
1081 // |
|
1082 CSwtDialogStringResultEvent::CSwtDialogStringResultEvent(CSwtDialogBroker* aBroker, TSwtPeer aPeer) |
|
1083 : CSwtEvent(aPeer), iDialogBroker(aBroker) |
|
1084 { |
|
1085 } |
|
1086 |
|
1087 // ----------------------------------------------------------------------------- |
|
1088 // CSwtDialogStringResultEvent::ConstructL |
|
1089 // ----------------------------------------------------------------------------- |
|
1090 // |
|
1091 void CSwtDialogStringResultEvent::ConstructL(const TDesC& aDialogResult) |
|
1092 { |
|
1093 iDialogResult = aDialogResult.AllocL(); |
|
1094 } |
|
1095 |
|
1096 // ----------------------------------------------------------------------------- |
|
1097 // CSwtDialogStringResultEvent::NewL |
|
1098 // ----------------------------------------------------------------------------- |
|
1099 // |
|
1100 CSwtDialogStringResultEvent* CSwtDialogStringResultEvent |
|
1101 ::NewL(CSwtDialogBroker* aBroker, TSwtPeer aPeer, const TDesC& aDialogResult) |
|
1102 { |
|
1103 |
|
1104 CSwtDialogStringResultEvent* self = new(ELeave) CSwtDialogStringResultEvent(aBroker, aPeer); |
|
1105 CleanupStack::PushL(self); |
|
1106 self->ConstructL(aDialogResult); |
|
1107 CleanupStack::Pop(self); |
|
1108 return self; |
|
1109 } |
|
1110 |
|
1111 // ----------------------------------------------------------------------------- |
|
1112 // CSwtDialogStringResultEvent::~CSwtDialogStringResultEvent |
|
1113 // ----------------------------------------------------------------------------- |
|
1114 // |
|
1115 CSwtDialogStringResultEvent::~CSwtDialogStringResultEvent() |
|
1116 { |
|
1117 delete iDialogBroker; |
|
1118 delete iDialogResult; |
|
1119 } |
|
1120 |
|
1121 // ----------------------------------------------------------------------------- |
|
1122 // CSwtDialogStringResultEvent::Type |
|
1123 // ----------------------------------------------------------------------------- |
|
1124 // |
|
1125 TSwtEventType CSwtDialogStringResultEvent::Type() const |
|
1126 { |
|
1127 return ESwtEventDialogStringResult; |
|
1128 } |
|
1129 |
|
1130 |
|
1131 // ----------------------------------------------------------------------------- |
|
1132 // CSwtDialogStringResultEvent::DoDispatch |
|
1133 // ----------------------------------------------------------------------------- |
|
1134 // |
|
1135 void CSwtDialogStringResultEvent::DoDispatch(JNIEnv* aJniEnv) |
|
1136 { |
|
1137 |
|
1138 CSwtDisplay* display = CSwtDisplay::CurrentOrNull(); |
|
1139 ASSERT(display); |
|
1140 // active object have to be deleted in UI thread |
|
1141 CallMethod(display, &CSwtDisplay::RemoveDialogBroker, iDialogBroker); |
|
1142 iDialogBroker = NULL; |
|
1143 |
|
1144 TBool failed; |
|
1145 jstring string = NewJavaString(aJniEnv, *iDialogResult); |
|
1146 DeleteInUiHeap(iDialogResult); |
|
1147 iDialogResult = NULL; |
|
1148 |
|
1149 CallVoidJavaMethod(failed, aJniEnv, Peer(), "internal_sendResult", |
|
1150 "(Ljava/lang/String;)V", string); |
|
1151 } |
|
1152 |
|
1153 |
|
1154 // ----------------------------------------------------------------------------- |
|
1155 // CSwtDialogIntegerResultEvent::CSwtDialogIntegerResultEvent |
|
1156 // ----------------------------------------------------------------------------- |
|
1157 // |
|
1158 CSwtDialogIntegerResultEvent::CSwtDialogIntegerResultEvent(CSwtDialogBroker* aBroker, |
|
1159 TSwtPeer aPeer, TInt aDialogResult) |
|
1160 : CSwtEvent(aPeer), iDialogBroker(aBroker) |
|
1161 , iDialogResult(aDialogResult) |
|
1162 { |
|
1163 } |
|
1164 |
|
1165 // ----------------------------------------------------------------------------- |
|
1166 // CSwtDialogIntegerResultEvent::~CSwtDialogIntegerResultEvent |
|
1167 // ----------------------------------------------------------------------------- |
|
1168 // |
|
1169 CSwtDialogIntegerResultEvent::~CSwtDialogIntegerResultEvent() |
|
1170 { |
|
1171 delete iDialogBroker; |
|
1172 } |
|
1173 |
|
1174 // ----------------------------------------------------------------------------- |
|
1175 // CSwtDialogIntegerResultEvent::Type |
|
1176 // ----------------------------------------------------------------------------- |
|
1177 // |
|
1178 TSwtEventType CSwtDialogIntegerResultEvent::Type() const |
|
1179 { |
|
1180 return ESwtEventDialogIntegerResult; |
|
1181 } |
|
1182 |
|
1183 |
|
1184 // ----------------------------------------------------------------------------- |
|
1185 // CSwtDialogIntegerResultEvent::DoDispatch |
|
1186 // ----------------------------------------------------------------------------- |
|
1187 // |
|
1188 void CSwtDialogIntegerResultEvent::DoDispatch(JNIEnv* aJniEnv) |
|
1189 { |
|
1190 |
|
1191 CSwtDisplay* display = CSwtDisplay::CurrentOrNull(); |
|
1192 ASSERT(display); |
|
1193 // active object have to be deleted in UI thread |
|
1194 CallMethod(display, &CSwtDisplay::RemoveDialogBroker, iDialogBroker); |
|
1195 iDialogBroker = NULL; |
|
1196 |
|
1197 TBool failed; |
|
1198 CallVoidJavaMethod(failed, aJniEnv, Peer(), "internal_sendResult", |
|
1199 "(I)V", static_cast< jint >(iDialogResult)); |
|
1200 } |
|
1201 // ----------------------------------------------------------------------------- |
|
1202 // CSwtDialogRgbResultEvent::CSwtDialogRgbResultEvent |
|
1203 // ----------------------------------------------------------------------------- |
|
1204 // |
|
1205 CSwtDialogRgbResultEvent::CSwtDialogRgbResultEvent(CSwtDialogBroker* aBroker, TSwtPeer aPeer, TInt aRed, TInt aGreen, TInt aBlue) |
|
1206 : CSwtEvent(aPeer) |
|
1207 , iDialogBroker(aBroker) |
|
1208 , iRed(aRed) |
|
1209 , iGreen(aGreen) |
|
1210 , iBlue(aBlue) |
|
1211 { |
|
1212 } |
|
1213 |
|
1214 // ----------------------------------------------------------------------------- |
|
1215 // CSwtDialogRgbResultEvent::~CSwtDialogRgbResultEvent |
|
1216 // ----------------------------------------------------------------------------- |
|
1217 // |
|
1218 CSwtDialogRgbResultEvent::~CSwtDialogRgbResultEvent() |
|
1219 { |
|
1220 delete iDialogBroker; |
|
1221 } |
|
1222 |
|
1223 // ----------------------------------------------------------------------------- |
|
1224 // CSwtDialogRgbResultEvent::Type |
|
1225 // ----------------------------------------------------------------------------- |
|
1226 // |
|
1227 TSwtEventType CSwtDialogRgbResultEvent::Type() const |
|
1228 { |
|
1229 return ESwtEventDialogRgbResult; |
|
1230 } |
|
1231 |
|
1232 |
|
1233 // ----------------------------------------------------------------------------- |
|
1234 // CSwtDialogRgbResultEvent::DoDispatch |
|
1235 // ----------------------------------------------------------------------------- |
|
1236 // |
|
1237 void CSwtDialogRgbResultEvent::DoDispatch(JNIEnv* aJniEnv) |
|
1238 { |
|
1239 CSwtDisplay* display = CSwtDisplay::CurrentOrNull(); |
|
1240 ASSERT(display); |
|
1241 // active object have to be deleted in UI thread |
|
1242 CallMethod(display, &CSwtDisplay::RemoveDialogBroker, iDialogBroker); |
|
1243 iDialogBroker = NULL; |
|
1244 |
|
1245 TBool failed; |
|
1246 CallVoidJavaMethod(failed, aJniEnv, Peer(), "internal_sendResult", |
|
1247 "(III)V", static_cast< jint >(iRed), |
|
1248 static_cast< jint >(iGreen), |
|
1249 static_cast< jint >(iBlue)); |
|
1250 } |
|
1251 |
|
1252 |
|
1253 |
|
1254 // ----------------------------------------------------------------------------- |
|
1255 // CSwtSettingsEvent::CSwtSettingsEvent |
|
1256 // ----------------------------------------------------------------------------- |
|
1257 // |
|
1258 CSwtSettingsEvent::CSwtSettingsEvent(TSwtPeer aPeer, TBool aThemeChanged) |
|
1259 :CSwtEvent(aPeer) |
|
1260 ,iThemeChanged(aThemeChanged) |
|
1261 { |
|
1262 } |
|
1263 |
|
1264 TSwtEventType CSwtSettingsEvent::Type() const |
|
1265 { |
|
1266 return ESwtEventSettings; |
|
1267 } |
|
1268 |
|
1269 void CSwtSettingsEvent::DoDispatch(JNIEnv* aJniEnv) |
|
1270 { |
|
1271 TBool failed; |
|
1272 CallVoidJavaMethod(failed, aJniEnv, Peer(), "runSettings", |
|
1273 "(Z)V", static_cast< jboolean >(iThemeChanged)); |
|
1274 } |
|
1275 |
|
1276 |
|
1277 // ----------------------------------------------------------------------------- |
|
1278 // CSwtCloseEvent::CSwtCloseEvent |
|
1279 // ----------------------------------------------------------------------------- |
|
1280 // |
|
1281 CSwtCloseEvent::CSwtCloseEvent(TSwtPeer aPeer, TBool& aDispatched) |
|
1282 : CSwtCallbackEvent(aPeer), iDispatched(aDispatched) |
|
1283 { |
|
1284 } |
|
1285 |
|
1286 |
|
1287 // ----------------------------------------------------------------------------- |
|
1288 // CSwtCloseEvent::Type |
|
1289 // ----------------------------------------------------------------------------- |
|
1290 // |
|
1291 TSwtEventType CSwtCloseEvent::Type() const |
|
1292 { |
|
1293 return ESwtEventClose; |
|
1294 } |
|
1295 |
|
1296 // ----------------------------------------------------------------------------- |
|
1297 // CSwtCloseEvent::SendEvent |
|
1298 // ----------------------------------------------------------------------------- |
|
1299 // |
|
1300 TBool CSwtCloseEvent::SendEvent(JNIEnv* aJniEnv, jboolean &aDoIt) |
|
1301 { |
|
1302 TBool failed; |
|
1303 aDoIt = CallBooleanJavaMethod(failed, aJniEnv, Peer(), |
|
1304 "sendCloseEvent", "()Z"); |
|
1305 |
|
1306 TBool fine = !failed && !aJniEnv->ExceptionCheck(); |
|
1307 if (fine && aDoIt) |
|
1308 { |
|
1309 // CallbackL needs the display. Get it here as we are in the Java ui thread. |
|
1310 iDisplay = CSwtDisplay::CurrentOrNull(); |
|
1311 } |
|
1312 |
|
1313 return fine; |
|
1314 } |
|
1315 |
|
1316 // ----------------------------------------------------------------------------- |
|
1317 // CSwtCloseEvent::SendEvent |
|
1318 // ----------------------------------------------------------------------------- |
|
1319 // |
|
1320 void CSwtCloseEvent::CallbackL(TBool aDoIt) |
|
1321 { |
|
1322 iDispatched = ETrue; |
|
1323 if (aDoIt) |
|
1324 { |
|
1325 if (iDisplay) |
|
1326 { |
|
1327 iDisplay->OfferWsEventL(SwtWsEventShutdown); |
|
1328 } |
|
1329 } |
|
1330 } |
|
1331 |
|
1332 // ----------------------------------------------------------------------------- |
|
1333 // CSwtTextSelectionEvent::CSwtTextSelectionEvent |
|
1334 // ----------------------------------------------------------------------------- |
|
1335 // |
|
1336 CSwtTextSelectionEvent::CSwtTextSelectionEvent(TSwtPeer aPeer) |
|
1337 : CSwtEvent(aPeer) |
|
1338 { |
|
1339 } |
|
1340 |
|
1341 // ----------------------------------------------------------------------------- |
|
1342 // CSwtTextSelectionEvent::ConstructL |
|
1343 // ----------------------------------------------------------------------------- |
|
1344 // |
|
1345 void CSwtTextSelectionEvent::ConstructL(const TDesC& aSelectedText) |
|
1346 { |
|
1347 iSelectedText = aSelectedText.AllocL(); |
|
1348 } |
|
1349 |
|
1350 // ----------------------------------------------------------------------------- |
|
1351 // CSwtTextSelectionEvent::NewL |
|
1352 // ----------------------------------------------------------------------------- |
|
1353 // |
|
1354 CSwtTextSelectionEvent* CSwtTextSelectionEvent::NewL(TSwtPeer aPeer, |
|
1355 const TDesC& aSelectedText) |
|
1356 { |
|
1357 CSwtTextSelectionEvent* self = new(ELeave) CSwtTextSelectionEvent(aPeer); |
|
1358 CleanupStack::PushL(self); |
|
1359 self->ConstructL(aSelectedText); |
|
1360 CleanupStack::Pop(self); |
|
1361 return self; |
|
1362 } |
|
1363 |
|
1364 // ----------------------------------------------------------------------------- |
|
1365 // CSwtTextSelectionEvent::~CSwtTextSelectionEvent |
|
1366 // ----------------------------------------------------------------------------- |
|
1367 // |
|
1368 CSwtTextSelectionEvent::~CSwtTextSelectionEvent() |
|
1369 { |
|
1370 delete iSelectedText; |
|
1371 } |
|
1372 |
|
1373 // ----------------------------------------------------------------------------- |
|
1374 // CSwtTextSelectionEvent::DoDispatch |
|
1375 // ----------------------------------------------------------------------------- |
|
1376 // |
|
1377 void CSwtTextSelectionEvent::DoDispatch(JNIEnv* aJniEnv) |
|
1378 { |
|
1379 TBool failed; |
|
1380 jstring selectedText = NewJavaString(aJniEnv, *iSelectedText); |
|
1381 DeleteInUiHeap(iSelectedText); |
|
1382 iSelectedText = NULL; |
|
1383 CallVoidJavaMethod(failed, aJniEnv, Peer(), "internal_sendEvent", |
|
1384 "(ILjava/lang/String;)V", static_cast<jint>(Type()), selectedText); |
|
1385 } |
|
1386 |