|
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: JNI implementation of TextEditorImpl class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INTERNAL INCLUDES |
|
20 #include "com_nokia_mid_ui_TextEditorImpl.h" |
|
21 |
|
22 // EXTERNAL INCLUDES |
|
23 #include <MMIDTextEditor.h> |
|
24 #include <CMIDToolkit.h> |
|
25 #include <jutils.h> |
|
26 #include <jdebug.h> |
|
27 |
|
28 /** |
|
29 * Local helper function for setting a text editor visible. |
|
30 * |
|
31 * @param aEditor The editor to set visible. |
|
32 */ |
|
33 LOCAL_C void SetIndicatorVisibilityL( |
|
34 MMIDTextEditor* aEditor, |
|
35 TBool aVisible) |
|
36 { |
|
37 aEditor->SetIndicatorVisibilityL(aVisible); |
|
38 } |
|
39 |
|
40 /* |
|
41 * Class: com_nokia_mid_ui_TextEditorImpl |
|
42 * Method: _setIndicatorVisibility |
|
43 * Signature: (IIZ)I |
|
44 */ |
|
45 JNIEXPORT jint JNICALL |
|
46 Java_com_nokia_mid_ui_TextEditorImpl__1setIndicatorVisibility( |
|
47 JNIEnv* /*aJniEnv*/, |
|
48 jobject /*aPeer*/, |
|
49 jint aToolkitHandle, |
|
50 jint aNativePeerHandle, |
|
51 jboolean aVisible) |
|
52 { |
|
53 DEBUG_INT("TextEditorImpl.cpp - setIndicatorVisibility +, aVisible=%d", |
|
54 aVisible); |
|
55 |
|
56 CMIDToolkit* toolkit = JavaUnhand< CMIDToolkit >(aToolkitHandle); |
|
57 |
|
58 MMIDTextEditor* editor = |
|
59 MIDUnhandObject< MMIDTextEditor >(aNativePeerHandle); |
|
60 |
|
61 TInt error = toolkit->ExecuteTrap( |
|
62 &SetIndicatorVisibilityL, |
|
63 editor, |
|
64 (TBool)aVisible); |
|
65 |
|
66 DEBUG_INT("TextEditorImpl.cpp - setIndicatorVisibility -, error=%d", |
|
67 error); |
|
68 |
|
69 return error; |
|
70 } |
|
71 |
|
72 /** |
|
73 * Local helper function for setting a position of an indicator. |
|
74 * |
|
75 * @param aEditor The editor. |
|
76 * @param aX The x coordinate of the anchor point. |
|
77 * @param aY The y coordinate of the anchor point. |
|
78 */ |
|
79 LOCAL_C void SetIndicatorLocation(MMIDTextEditor* aEditor, TInt aX, TInt aY) |
|
80 { |
|
81 aEditor->SetIndicatorPosition(aX, aY); |
|
82 } |
|
83 |
|
84 /* |
|
85 * Class: com_nokia_mid_ui_TextEditorImpl |
|
86 * Method: _setIndicatorLocation |
|
87 * Signature: (IIII)I |
|
88 */ |
|
89 JNIEXPORT jint JNICALL |
|
90 Java_com_nokia_mid_ui_TextEditorImpl__1setIndicatorLocation( |
|
91 JNIEnv* /*aJniEnv*/, |
|
92 jobject /*aPeer*/, |
|
93 jint aToolkitHandle, |
|
94 jint aNativePeerHandle, |
|
95 jint aX, |
|
96 jint aY) |
|
97 { |
|
98 DEBUG("TextEditorImpl.cpp - setIndicatorLocation +"); |
|
99 |
|
100 CMIDToolkit* toolkit = JavaUnhand< CMIDToolkit >(aToolkitHandle); |
|
101 |
|
102 MMIDTextEditor* editor = |
|
103 MIDUnhandObject< MMIDTextEditor >(aNativePeerHandle); |
|
104 |
|
105 toolkit->ExecuteV(&SetIndicatorLocation, editor, aX, aY); |
|
106 |
|
107 DEBUG("TextEditorImpl.cpp - setIndicatorLocation -"); |
|
108 |
|
109 return KErrNone; |
|
110 } |
|
111 |
|
112 /** |
|
113 * Local helper function for getting the size of an indicator. |
|
114 * |
|
115 * @param aEditor The editor. |
|
116 * @param aSize On return contains the size of the indicator. |
|
117 */ |
|
118 LOCAL_C void IndicatorSize(MMIDTextEditor* aEditor, TSize* aSize) |
|
119 { |
|
120 *aSize = aEditor->IndicatorSize(); |
|
121 } |
|
122 |
|
123 /* |
|
124 * Class: com_nokia_mid_ui_TextEditorImpl |
|
125 * Method: _getIndicatorSize |
|
126 * Signature: (II[I)I |
|
127 */ |
|
128 JNIEXPORT jint JNICALL Java_com_nokia_mid_ui_TextEditorImpl__1getIndicatorSize( |
|
129 JNIEnv* aJniEnv, |
|
130 jobject /*aPeer*/, |
|
131 jint aToolkitHandle, |
|
132 jint aNativePeerHandle, |
|
133 jintArray aSize) |
|
134 { |
|
135 DEBUG("TextEditorImpl.cpp - getIndicatorSize +"); |
|
136 |
|
137 CMIDToolkit* toolkit = JavaUnhand< CMIDToolkit >(aToolkitHandle); |
|
138 |
|
139 MMIDTextEditor* editor = |
|
140 MIDUnhandObject< MMIDTextEditor >(aNativePeerHandle); |
|
141 |
|
142 TSize size; |
|
143 |
|
144 toolkit->ExecuteV(&IndicatorSize, editor, &size); |
|
145 |
|
146 // Store returned size. |
|
147 jint sizeArray[ 2 ] = { size.iWidth, size.iHeight }; |
|
148 aJniEnv->SetIntArrayRegion(aSize, 0, 2, sizeArray); |
|
149 |
|
150 DEBUG_INT2("TextEditorImpl.cpp - getIndicatorSize -, width=%d height=%d", |
|
151 size.iWidth, size.iHeight); |
|
152 |
|
153 return KErrNone; |
|
154 } |
|
155 |
|
156 /** |
|
157 * Local helper function for setting the disabled touch UI input mode. |
|
158 * |
|
159 * @param aEditor The editor. |
|
160 * @param aTouchInputMode The disabled touch input mode. |
|
161 */ |
|
162 LOCAL_C void SetDisabledTouchInputModes( |
|
163 MMIDTextEditor* aEditor, |
|
164 TInt aTouchInputModes) |
|
165 { |
|
166 aEditor->SetDisabledTouchInputModes(aTouchInputModes); |
|
167 } |
|
168 |
|
169 /* |
|
170 * Class: com_nokia_mid_ui_TextEditorImpl |
|
171 * Method: _setDisabledTouchInputModes |
|
172 * Signature: (III)I |
|
173 */ |
|
174 JNIEXPORT jint JNICALL |
|
175 Java_com_nokia_mid_ui_TextEditorImpl__1setDisabledTouchInputModes( |
|
176 JNIEnv* /*aJniEnv*/, |
|
177 jobject /*aPeer*/, |
|
178 jint aToolkitHandle, |
|
179 jint aNativePeerHandle, |
|
180 jint aTouchInputModes) |
|
181 { |
|
182 DEBUG("TextEditorImpl.cpp - setDisabledTouchInputModes +"); |
|
183 |
|
184 CMIDToolkit* toolkit = JavaUnhand< CMIDToolkit >(aToolkitHandle); |
|
185 |
|
186 MMIDTextEditor* editor = |
|
187 MIDUnhandObject< MMIDTextEditor >(aNativePeerHandle); |
|
188 |
|
189 toolkit->ExecuteV( |
|
190 &SetDisabledTouchInputModes, editor, aTouchInputModes); |
|
191 |
|
192 DEBUG("TextEditorImpl.cpp - setDisabledTouchInputModes -"); |
|
193 |
|
194 return KErrNone; |
|
195 } |
|
196 |
|
197 /** |
|
198 * Local helper function for getting the disabled touch UI input mode. |
|
199 * |
|
200 * @param aEditor The editor. |
|
201 * @return The disabled touch input mode. |
|
202 */ |
|
203 LOCAL_C TInt DisabledTouchInputModes(MMIDTextEditor* aEditor) |
|
204 { |
|
205 return aEditor->DisabledTouchInputModes(); |
|
206 } |
|
207 |
|
208 /* |
|
209 * Class: com_nokia_mid_ui_TextEditorImpl |
|
210 * Method: _getDisabledTouchInputModes |
|
211 * Signature: (II)I |
|
212 */ |
|
213 JNIEXPORT jint JNICALL |
|
214 Java_com_nokia_mid_ui_TextEditorImpl__1getDisabledTouchInputModes( |
|
215 JNIEnv* /*aJniEnv*/, |
|
216 jobject /*aPeer*/, |
|
217 jint aToolkitHandle, |
|
218 jint aNativePeerHandle) |
|
219 { |
|
220 DEBUG("TextEditorImpl.cpp - getDisabledTouchInputModes +"); |
|
221 |
|
222 CMIDToolkit* toolkit = |
|
223 JavaUnhand< CMIDToolkit >(aToolkitHandle); |
|
224 MMIDTextEditor* editor = |
|
225 MIDUnhandObject< MMIDTextEditor >(aNativePeerHandle); |
|
226 |
|
227 TInt modes = toolkit->Execute(&DisabledTouchInputModes, editor); |
|
228 |
|
229 DEBUG("TextEditorImpl.cpp - getDisabledTouchInputModes -"); |
|
230 |
|
231 return modes; |
|
232 } |
|
233 |
|
234 /** |
|
235 * Local helper function for setting the preferred touch UI input mode. |
|
236 * |
|
237 * @param aEditor The editor. |
|
238 * @param aTouchInputMode The preferred touch input mode. |
|
239 */ |
|
240 LOCAL_C void SetPreferredTouchInputMode( |
|
241 MMIDTextEditor* aEditor, |
|
242 TInt aTouchInputMode) |
|
243 { |
|
244 aEditor->SetPreferredTouchInputMode(aTouchInputMode); |
|
245 } |
|
246 |
|
247 /* |
|
248 * Class: com_nokia_mid_ui_TextEditorImpl |
|
249 * Method: _setPreferredTouchMode |
|
250 * Signature: (III)I |
|
251 */ |
|
252 JNIEXPORT jint JNICALL |
|
253 Java_com_nokia_mid_ui_TextEditorImpl__1setPreferredTouchMode( |
|
254 JNIEnv* /*aJniEnv*/, |
|
255 jobject /*aPeer*/, |
|
256 jint aToolkitHandle, |
|
257 jint aNativePeerHandle, |
|
258 jint aTouchInputMode) |
|
259 { |
|
260 DEBUG("TextEditorImpl.cpp - setPreferredTouchMode +"); |
|
261 |
|
262 CMIDToolkit* toolkit = |
|
263 JavaUnhand< CMIDToolkit >(aToolkitHandle); |
|
264 MMIDTextEditor* editor = |
|
265 MIDUnhandObject< MMIDTextEditor >(aNativePeerHandle); |
|
266 |
|
267 toolkit->ExecuteV(&SetPreferredTouchInputMode, editor, aTouchInputMode); |
|
268 |
|
269 DEBUG("TextEditorImpl.cpp - setPreferredTouchMode -"); |
|
270 |
|
271 return KErrNone; |
|
272 } |
|
273 |
|
274 /** |
|
275 * Local helper function for getting the preferred touch UI input mode. |
|
276 * |
|
277 * @param aEditor The editor. |
|
278 * @return The preferred touch input mode. |
|
279 */ |
|
280 LOCAL_C TInt PreferredTouchInputMode(MMIDTextEditor* aEditor) |
|
281 { |
|
282 return aEditor->PreferredTouchInputMode(); |
|
283 } |
|
284 |
|
285 /* |
|
286 * Class: com_nokia_mid_ui_TextEditorImpl |
|
287 * Method: _getPreferredTouchMode |
|
288 * Signature: (II)I |
|
289 */ |
|
290 JNIEXPORT jint JNICALL |
|
291 Java_com_nokia_mid_ui_TextEditorImpl__1getPreferredTouchMode( |
|
292 JNIEnv* /*aJniEnv*/, |
|
293 jobject /*aPeer*/, |
|
294 jint aToolkitHandle, |
|
295 jint aNativePeerHandle) |
|
296 { |
|
297 DEBUG("TextEditorImpl.cpp - getPreferredTouchMode +"); |
|
298 |
|
299 CMIDToolkit* toolkit = |
|
300 JavaUnhand< CMIDToolkit >(aToolkitHandle); |
|
301 MMIDTextEditor* editor = |
|
302 MIDUnhandObject< MMIDTextEditor >(aNativePeerHandle); |
|
303 |
|
304 TInt mode = toolkit->Execute(&PreferredTouchInputMode, editor); |
|
305 |
|
306 DEBUG("TextEditorImpl.cpp - getPreferredTouchMode -"); |
|
307 |
|
308 return mode; |
|
309 } |
|
310 |
|
311 |
|
312 /** |
|
313 * Local helper function for reseting indicator state. |
|
314 * |
|
315 * @param aEditor The editor. |
|
316 */ |
|
317 LOCAL_C void ResetIndicatorStateL(MMIDTextEditor* aEditor) |
|
318 { |
|
319 aEditor->SetDefaultIndicatorsL(); |
|
320 } |
|
321 |
|
322 /* |
|
323 * Class: com_nokia_mid_ui_TextEditorImpl |
|
324 * Method: _setDefaultIndicators |
|
325 * Signature: (II)I |
|
326 */ |
|
327 JNIEXPORT jint JNICALL |
|
328 Java_com_nokia_mid_ui_TextEditorImpl__1setDefaultIndicators( |
|
329 JNIEnv* /*aJniEnv*/, |
|
330 jobject /*aPeer*/, |
|
331 jint aToolkitHandle, |
|
332 jint aNativePeerHandle, |
|
333 jboolean /*aIsFullScreen*/) |
|
334 { |
|
335 DEBUG("TextEditorImpl.cpp - setDefaultIndicators +"); |
|
336 |
|
337 CMIDToolkit* toolkit = |
|
338 JavaUnhand< CMIDToolkit >(aToolkitHandle); |
|
339 MMIDTextEditor* editor = |
|
340 MIDUnhandObject< MMIDTextEditor >(aNativePeerHandle); |
|
341 |
|
342 TInt error = toolkit->ExecuteTrap(&ResetIndicatorStateL, editor); |
|
343 |
|
344 DEBUG("TextEditorImpl.cpp - setDefaultIndicators -"); |
|
345 |
|
346 return error; |
|
347 } |
|
348 |
|
349 /** |
|
350 * Local helper function for setting position of a caret. |
|
351 * |
|
352 * @param aEditor The editor. |
|
353 * @param aX The x coordinate of the wanted caret position. |
|
354 * @param aY The y coordinate of the wanted caret position. |
|
355 */ |
|
356 LOCAL_C void SetCaretXYL(MMIDTextEditor* aEditor, TInt aX, TInt aY) |
|
357 { |
|
358 aEditor->SetCaretXYL(aX, aY); |
|
359 } |
|
360 |
|
361 /* |
|
362 * Class: com_nokia_mid_ui_TextEditorImpl |
|
363 * Method: _setCaretXY |
|
364 * Signature: (IIII)I |
|
365 */ |
|
366 JNIEXPORT jint JNICALL |
|
367 Java_com_nokia_mid_ui_TextEditorImpl__1setCaretXY( |
|
368 JNIEnv* /*aJniEnv*/, |
|
369 jobject /*aPeer*/, |
|
370 jint aToolkitHandle, |
|
371 jint aNativePeerHandle, |
|
372 jint aX, |
|
373 jint aY) |
|
374 { |
|
375 DEBUG("TextEditorImpl.cpp - setCaretXY +"); |
|
376 |
|
377 CMIDToolkit* toolkit = JavaUnhand< CMIDToolkit >(aToolkitHandle); |
|
378 |
|
379 MMIDTextEditor* editor = |
|
380 MIDUnhandObject< MMIDTextEditor >(aNativePeerHandle); |
|
381 |
|
382 TInt error = toolkit->ExecuteTrap(&SetCaretXYL, editor, aX, aY); |
|
383 |
|
384 DEBUG("TextEditorImpl.cpp - setCaretXY -"); |
|
385 |
|
386 return error; |
|
387 } |
|
388 |
|
389 // End of file |