|
1 /* |
|
2 * Copyright (c) 2009 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: Delivers editor input actions to the Java side. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INTERNAL INCLUDES |
|
20 #include "CMIDTextEditorObserver.h" |
|
21 |
|
22 // EXTERNAL INCLUDES |
|
23 #include <j2me/jdebug.h> |
|
24 |
|
25 // --------------------------------------------------------------------------- |
|
26 // CMIDTextEditorEvent::CMIDTextEditorEvent |
|
27 // --------------------------------------------------------------------------- |
|
28 // |
|
29 CMIDTextEditorObserver::CMIDTextEditorEvent::CMIDTextEditorEvent( |
|
30 jobject aPeer, |
|
31 jmethodID aMethod, |
|
32 TUint aParam) : |
|
33 CJavaEvent(CJavaEventBase::EDisposableEvent), |
|
34 iPeer(aPeer), iMethod(aMethod), iParam(aParam) |
|
35 { |
|
36 } |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // CMIDTextEditorObserver::~CMIDTextEditorEvent |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 CMIDTextEditorObserver::CMIDTextEditorEvent::~CMIDTextEditorEvent() |
|
43 { |
|
44 // Nothing to do. |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CMIDTextEditorObserver::~CMIDTextEditorEvent |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 void CMIDTextEditorObserver::CMIDTextEditorEvent::Dispatch(JNIEnv& aJniEnv) |
|
52 { |
|
53 DEBUG("CMIDTextEditorObserver::Dispatch +"); |
|
54 |
|
55 // Make a direct call to the Java side. |
|
56 aJniEnv.CallVoidMethod(iPeer, iMethod, iParam); |
|
57 |
|
58 // Exception is cleared after this call returns to base class. |
|
59 |
|
60 DEBUG("CMIDTextEditorObserver::Dispatch -"); |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // CMIDTextEditorObserver::NewL |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 CMIDTextEditorObserver* CMIDTextEditorObserver::NewL( |
|
68 CMIDToolkit& aToolkit, |
|
69 JNIEnv& aJniEnv, |
|
70 jobject aPeer, |
|
71 jmethodID aMethod) |
|
72 { |
|
73 CMIDTextEditorObserver* self = new(ELeave) CMIDTextEditorObserver( |
|
74 aToolkit, aJniEnv, aPeer, aMethod); |
|
75 |
|
76 return self; |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // CMIDTextEditorObserver::~CMIDTextEditorObserver |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 CMIDTextEditorObserver::~CMIDTextEditorObserver() |
|
84 { |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // CMIDTextEditorObserver::Dispose |
|
89 // (other items are commented in the header file) |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 void CMIDTextEditorObserver::Dispose() |
|
93 { |
|
94 DEBUG("CMIDTextEditorObserver::Dispose +"); |
|
95 |
|
96 delete this; |
|
97 |
|
98 DEBUG("CMIDTextEditorObserver::Dispose -"); |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // CMIDTextEditorObserver::InputAction |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 void CMIDTextEditorObserver::NotifyInputAction(TUint aActions) |
|
106 { |
|
107 DEBUG("CMIDTextEditorObserver::NotifyInputAction +"); |
|
108 |
|
109 TRAP_IGNORE( |
|
110 { |
|
111 // Cannot currently use reusable since events may occur |
|
112 // really fast causing some events to be missed or overwritten. |
|
113 CMIDTextEditorEvent* event = |
|
114 new CMIDTextEditorEvent(iPeer, iMethod, aActions); |
|
115 // Post event |
|
116 iToolkit.PostEvent(event, CJavaEventBase::EEventPriority); |
|
117 }); |
|
118 |
|
119 DEBUG("CMIDTextEditorObserver::NotifyInputAction -"); |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // CMIDTextEditorObserver::CMIDTextEditorObserver |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 CMIDTextEditorObserver::CMIDTextEditorObserver( |
|
127 CMIDToolkit& aToolkit, |
|
128 JNIEnv& aJniEnv, |
|
129 jobject aPeer, |
|
130 jmethodID aMethod) : |
|
131 iToolkit(aToolkit), |
|
132 iJniEnv(aJniEnv), |
|
133 iPeer(aPeer), |
|
134 iMethod(aMethod) |
|
135 { |
|
136 } |
|
137 |
|
138 // End of file |