author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:23:59 +0300 | |
branch | RCL_3 |
changeset 83 | 26b2b12093af |
parent 66 | 2455ef1f5bbc |
permissions | -rw-r--r-- |
66 | 1 |
/******************************************************************************* |
2 |
* Copyright (c) 2006, 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 "org_eclipse_ercp_swt_mobile_internal_OS.h" |
|
14 |
#include "eswtmobileextensions.h" |
|
15 |
#include "mmf/common/mmfcontrollerpluginresolver.h" |
|
16 |
#include "templatehelpers.h" |
|
17 |
#include "utils.h" |
|
18 |
#include "swtdialogbroker.h" |
|
19 |
||
20 |
||
21 |
// ======== LOCAL FUNCTIONS ======== |
|
22 |
||
23 |
||
24 |
template<class C> |
|
25 |
static jint NewMobileWidget(JNIEnv* aJniEnv, |
|
26 |
C*(MSwtFactory::*aMethodL)(MSwtDisplay&, TSwtPeer, MSwtComposite&, TInt) const, |
|
27 |
jobject aPeer, |
|
28 |
jint aParent, |
|
29 |
jint aStyle) |
|
30 |
{ |
|
31 |
CSwtDisplay& display = CSwtDisplay::Current(); |
|
32 |
const MSwtFactory* factory = &display.Factory(); |
|
33 |
return NewWidget(aJniEnv, factory, aMethodL, display, aPeer, aParent, aStyle); |
|
34 |
} |
|
35 |
||
36 |
||
37 |
extern "C" |
|
38 |
{ |
|
39 |
||
40 |
/* |
|
41 |
* Class CaptionedControl |
|
42 |
*/ |
|
43 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_CaptionedControl_1New( |
|
44 |
JNIEnv* aJniEnv, |
|
45 |
jclass, |
|
46 |
jobject aPeer, |
|
47 |
jint aParent, |
|
48 |
jint aStyle) |
|
49 |
{ |
|
50 |
CSwtDisplay& display = CSwtDisplay::Current(); |
|
51 |
const MSwtFactory& factory = display.Factory(); |
|
52 |
jweak peerRef = aJniEnv->NewWeakGlobalRef(aPeer); |
|
53 |
if (peerRef == NULL) |
|
54 |
return 0; |
|
55 |
||
56 |
MSwtComposite* parent = reinterpret_cast<MSwtComposite*>(aParent); |
|
57 |
MSwtCaptionedControl* result = NULL; |
|
58 |
TRAPD(error, CallMethodL(result, &factory, &MSwtFactory::NewCaptionedControlL, |
|
59 |
display, peerRef, *parent, aStyle)); |
|
60 |
if (error) |
|
61 |
{ |
|
62 |
aJniEnv->DeleteWeakGlobalRef(peerRef); |
|
63 |
Throw(error, aJniEnv); |
|
64 |
} |
|
65 |
||
66 |
INCREASE_INSTANCE_COUNT(result, CaptionedControl); |
|
67 |
||
68 |
return reinterpret_cast<jint>(result); |
|
69 |
} |
|
70 |
||
71 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_CaptionedControl_1CompositeHandle( |
|
72 |
JNIEnv*, |
|
73 |
jclass, |
|
74 |
jint aHandle) |
|
75 |
{ |
|
76 |
MSwtCaptionedControl* theControl = reinterpret_cast<MSwtCaptionedControl*>(aHandle); |
|
77 |
MSwtComposite* result; |
|
78 |
CallMethod(result, theControl, &MSwtCaptionedControl::Composite); |
|
79 |
return reinterpret_cast<jint>(result); |
|
80 |
} |
|
81 |
||
82 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_CaptionedControl_1SetText( |
|
83 |
JNIEnv* aJniEnv, |
|
84 |
jclass, |
|
85 |
jint aHandle, |
|
86 |
jstring aString) |
|
87 |
{ |
|
88 |
CallTextMethodThrow(aJniEnv, aHandle, &MSwtCaptionedControl::SetTextL, aString); |
|
89 |
} |
|
90 |
||
91 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_CaptionedControl_1SetTrailingText( |
|
92 |
JNIEnv* aJniEnv, |
|
93 |
jclass, |
|
94 |
jint aHandle, |
|
95 |
jstring aString) |
|
96 |
{ |
|
97 |
CallTextMethodThrow(aJniEnv, aHandle, &MSwtCaptionedControl::SetTrailingTextL, aString); |
|
98 |
} |
|
99 |
||
100 |
JNIEXPORT jstring JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_CaptionedControl_1GetText( |
|
101 |
JNIEnv* aJniEnv, |
|
102 |
jclass, |
|
103 |
jint aHandle) |
|
104 |
{ |
|
105 |
const MSwtCaptionedControl* theControl = reinterpret_cast<MSwtCaptionedControl*>(aHandle); |
|
106 |
const TDesC* text; |
|
107 |
CallMethod(text, theControl, &MSwtCaptionedControl::GetText); |
|
108 |
return NewJavaString(aJniEnv, (text != NULL) ? *text : KNullDesC()); |
|
109 |
} |
|
110 |
||
111 |
JNIEXPORT jstring JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_CaptionedControl_1GetTrailingText( |
|
112 |
JNIEnv* aJniEnv, |
|
113 |
jclass, |
|
114 |
jint aHandle) |
|
115 |
{ |
|
116 |
const MSwtCaptionedControl* theControl = reinterpret_cast<MSwtCaptionedControl*>(aHandle); |
|
117 |
const TDesC* text; |
|
118 |
CallMethod(text, theControl, &MSwtCaptionedControl::GetTrailingText); |
|
119 |
return NewJavaString(aJniEnv, (text != NULL) ? *text : KNullDesC()); |
|
120 |
} |
|
121 |
||
122 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_CaptionedControl_1SetImage( |
|
123 |
JNIEnv* aJniEnv, |
|
124 |
jclass, |
|
125 |
jint aHandle, |
|
126 |
jint aImageHandle) |
|
127 |
{ |
|
128 |
MSwtCaptionedControl* theControl = reinterpret_cast<MSwtCaptionedControl*>(aHandle); |
|
129 |
MSwtImage* image = reinterpret_cast<MSwtImage*>(aImageHandle); |
|
130 |
TRAPD(error, CallMethodL(theControl, &MSwtCaptionedControl::SetImageL, image)); |
|
131 |
ThrowIfError(error, aJniEnv); |
|
132 |
} |
|
133 |
||
134 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_CaptionedControl_1SetChildPreferredSize(JNIEnv*, jclass, jint aHandle, jint aWidth, jint aHeight) |
|
135 |
{ |
|
136 |
MSwtCaptionedControl* theControl = reinterpret_cast<MSwtCaptionedControl*>(aHandle); |
|
137 |
TSize size(aWidth, aHeight); |
|
138 |
CallMethod(theControl, &MSwtCaptionedControl::SetChildPreferredSize, size); |
|
139 |
} |
|
140 |
||
141 |
||
142 |
/* |
|
143 |
* Class Command |
|
144 |
*/ |
|
145 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_Command_1New(JNIEnv* aJniEnv, |
|
146 |
jclass, jobject aJavaPeer, jint aParentControl, jint aParentCommand, jint aType, jint aPriority) |
|
147 |
{ |
|
148 |
CSwtDisplay& display = CSwtDisplay::Current(); |
|
149 |
MSwtControl* parentControl = reinterpret_cast<MSwtControl*>(aParentControl); |
|
150 |
MSwtCommand* parentCommand = reinterpret_cast<MSwtCommand*>(aParentCommand); |
|
151 |
const MSwtFactory* factory = &display.Factory(); |
|
152 |
||
153 |
jweak peerRef = aJniEnv->NewWeakGlobalRef(aJavaPeer); |
|
154 |
if (peerRef == NULL) |
|
155 |
return 0; |
|
156 |
||
157 |
MSwtCommand* result = NULL; |
|
158 |
TRAPD(error, CallMethodL(result, factory, &MSwtFactory::NewCommandL, |
|
159 |
display, peerRef, *parentControl, parentCommand, aType, aPriority)); |
|
160 |
if (error) |
|
161 |
{ |
|
162 |
aJniEnv->DeleteWeakGlobalRef(peerRef); |
|
163 |
Throw(error, aJniEnv); |
|
164 |
} |
|
165 |
||
166 |
INCREASE_INSTANCE_COUNT(result, Command); |
|
167 |
||
168 |
return reinterpret_cast<jint>(result); |
|
169 |
} |
|
170 |
||
171 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_Command_1Dispose( |
|
172 |
JNIEnv* aJniEnv, |
|
173 |
jclass, |
|
174 |
jint aHandle) |
|
175 |
{ |
|
176 |
MSwtCommand* command = reinterpret_cast<MSwtCommand*>(aHandle); |
|
177 |
TSwtPeer peerRef; |
|
178 |
CallMethod(peerRef, command, &MSwtCommand::Dispose); |
|
179 |
||
180 |
ReleasePeer(aJniEnv, peerRef); |
|
181 |
||
182 |
DECREASE_INSTANCE_COUNT(Command); |
|
183 |
} |
|
184 |
||
185 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_Command_1SetAccelerator( |
|
186 |
JNIEnv* aJniEnv, |
|
187 |
jclass, |
|
188 |
jint aHandle, |
|
189 |
jint aAccelerator) |
|
190 |
{ |
|
191 |
MSwtCommand* command = reinterpret_cast<MSwtCommand*>(aHandle); |
|
192 |
TRAPD(error, CallMethodL(command, &MSwtCommand::SetAcceleratorL, aAccelerator)); |
|
193 |
ThrowIfError(error, aJniEnv); |
|
194 |
} |
|
195 |
||
196 |
JNIEXPORT jboolean JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_Command_1IsDefaultCommand( |
|
197 |
JNIEnv*, |
|
198 |
jclass, |
|
199 |
jint aHandle) |
|
200 |
{ |
|
201 |
const MSwtCommand* command = reinterpret_cast<MSwtCommand*>(aHandle); |
|
202 |
TBool result; |
|
203 |
CallMethod(result, command, &MSwtCommand::IsDefaultCommand); |
|
204 |
return ConvertBoolean(result); |
|
205 |
} |
|
206 |
||
207 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_Command_1SetDefaultCommand( |
|
208 |
JNIEnv* aJniEnv, |
|
209 |
jclass, |
|
210 |
jint aHandle) |
|
211 |
{ |
|
212 |
MSwtCommand* command = reinterpret_cast<MSwtCommand*>(aHandle); |
|
213 |
TBool thisIsTrue = ETrue; |
|
214 |
TRAPD(error, CallMethodL(command, &MSwtCommand::SetDefaultCommand, thisIsTrue)); |
|
215 |
ThrowIfError(error, aJniEnv); |
|
216 |
} |
|
217 |
||
218 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_Command_1SetText( |
|
219 |
JNIEnv* aJniEnv, |
|
220 |
jclass, |
|
221 |
jint aHandle, |
|
222 |
jstring aText) |
|
223 |
{ |
|
224 |
CallTextMethodThrow(aJniEnv, aHandle, &MSwtCommand::SetTextL, aText); |
|
225 |
} |
|
226 |
||
227 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_Command_1SetImage( |
|
228 |
JNIEnv* aJniEnv, |
|
229 |
jclass, |
|
230 |
jint aHandle, |
|
231 |
jint aImageHandle) |
|
232 |
{ |
|
233 |
MSwtCommand* command = reinterpret_cast<MSwtCommand*>(aHandle); |
|
234 |
MSwtImage* image = reinterpret_cast<MSwtImage*>(aImageHandle); |
|
235 |
TRAPD(error, CallMethodL(command, &MSwtCommand::SetImageL, image)); |
|
236 |
ThrowIfError(error, aJniEnv); |
|
237 |
} |
|
238 |
||
239 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_Command_1SetLongLabel( |
|
240 |
JNIEnv* aJniEnv, |
|
241 |
jclass, |
|
242 |
jint aHandle, |
|
243 |
jstring aText) |
|
244 |
{ |
|
245 |
CallTextMethodThrow(aJniEnv, aHandle, &MSwtCommand::SetLongLabelL, aText); |
|
246 |
} |
|
247 |
||
248 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_Command_1SetEnabled( |
|
249 |
JNIEnv*, jclass, |
|
250 |
jint aHandle, |
|
251 |
jboolean aEnabled) |
|
252 |
{ |
|
253 |
MSwtCommand* command = reinterpret_cast<MSwtCommand*>(aHandle); |
|
254 |
CallMethod(command, &MSwtCommand::SetEnabled, aEnabled); |
|
255 |
} |
|
256 |
||
257 |
||
258 |
/* |
|
259 |
* Class ConstrainedText |
|
260 |
*/ |
|
261 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ConstrainedText_1New( |
|
262 |
JNIEnv* aJniEnv, |
|
263 |
jclass, |
|
264 |
jobject aPeer, |
|
265 |
jint aParent, |
|
266 |
jint aStyle) |
|
267 |
{ |
|
268 |
jint handle = NewMobileWidget(aJniEnv, &MSwtFactory::NewConstrainedTextL, |
|
269 |
aPeer, aParent, aStyle); |
|
270 |
INCREASE_INSTANCE_COUNT(handle, ConstrainedText); |
|
271 |
return handle; |
|
272 |
} |
|
273 |
||
274 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ConstrainedText_1SetConstraint( |
|
275 |
JNIEnv* aJniEnv, |
|
276 |
jclass, |
|
277 |
jint aHandle, |
|
278 |
jint aConstraint) |
|
279 |
{ |
|
280 |
MSwtConstrainedText* constrText = reinterpret_cast<MSwtConstrainedText*>(aHandle); |
|
281 |
MSwtConstrainedText::TConstraint constraint = static_cast<MSwtConstrainedText::TConstraint>( |
|
282 |
aConstraint); |
|
283 |
TRAPD(error, CallMethodL(constrText, &MSwtConstrainedText::SetConstraintL, constraint)); |
|
284 |
ThrowIfError(error, aJniEnv); |
|
285 |
} |
|
286 |
||
287 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ConstrainedText_1ControlHandle( |
|
288 |
JNIEnv*, |
|
289 |
jclass, |
|
290 |
jint aHandle) |
|
291 |
{ |
|
292 |
MSwtConstrainedText* constrText = reinterpret_cast<MSwtConstrainedText*>(aHandle); |
|
293 |
MSwtControl* result; |
|
294 |
CallMethod(result, constrText, &MSwtConstrainedText::Control); |
|
295 |
return reinterpret_cast<jint>(result); |
|
296 |
} |
|
297 |
||
298 |
JNIEXPORT jstring JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ConstrainedText_1GetText( |
|
299 |
JNIEnv* aJniEnv, |
|
300 |
jclass, |
|
301 |
jint aHandle) |
|
302 |
{ |
|
303 |
return CallTextGetterThrow(aJniEnv, aHandle, &MSwtConstrainedText::GetTextL); |
|
304 |
} |
|
305 |
||
306 |
JNIEXPORT jboolean JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ConstrainedText_1SetText( |
|
307 |
JNIEnv* aJniEnv, |
|
308 |
jclass, |
|
309 |
jint aHandle, |
|
310 |
jstring aText) |
|
311 |
{ |
|
312 |
return ConvertBoolean(CallBoolTextMethodThrow(aJniEnv, aHandle, &MSwtConstrainedText::SetTextL, |
|
313 |
aText, EFalse)); |
|
314 |
} |
|
315 |
||
316 |
JNIEXPORT jboolean JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ConstrainedText_1Append( |
|
317 |
JNIEnv* aJniEnv, |
|
318 |
jclass, |
|
319 |
jint aHandle, |
|
320 |
jstring aText) |
|
321 |
{ |
|
322 |
return ConvertBoolean(CallBoolTextMethodThrow(aJniEnv, aHandle, &MSwtConstrainedText::AppendL, |
|
323 |
aText, EFalse)); |
|
324 |
} |
|
325 |
||
326 |
JNIEXPORT jboolean JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ConstrainedText_1Insert( |
|
327 |
JNIEnv* aJniEnv, |
|
328 |
jclass, |
|
329 |
jint aHandle, |
|
330 |
jstring aText) |
|
331 |
{ |
|
332 |
return ConvertBoolean(CallBoolTextMethodThrow(aJniEnv, aHandle, &MSwtConstrainedText::InsertL, |
|
333 |
aText, EFalse)); |
|
334 |
} |
|
335 |
||
336 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ConstrainedText_1GetCharCount( |
|
337 |
JNIEnv*, |
|
338 |
jclass, |
|
339 |
jint aHandle) |
|
340 |
{ |
|
341 |
const MSwtConstrainedText* constrText = reinterpret_cast<MSwtConstrainedText*>(aHandle); |
|
342 |
TInt result; |
|
343 |
CallMethod(result, constrText, &MSwtConstrainedText::GetCharCount); |
|
344 |
return result; |
|
345 |
} |
|
346 |
||
347 |
JNIEXPORT jboolean JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ConstrainedText_1SetTextLimit( |
|
348 |
JNIEnv* aJniEnv, |
|
349 |
jclass, |
|
350 |
jint aHandle, |
|
351 |
jint aLimit) |
|
352 |
{ |
|
353 |
MSwtConstrainedText* constrText = reinterpret_cast<MSwtConstrainedText*>(aHandle); |
|
354 |
TBool result; |
|
355 |
TRAPD(error, CallMethodL(result, constrText, &MSwtConstrainedText::SetTextLimitL, aLimit)); |
|
356 |
ThrowIfError(error, aJniEnv); |
|
357 |
return ConvertBoolean(result); |
|
358 |
} |
|
359 |
||
360 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ConstrainedText_1GetCaretPosition( |
|
361 |
JNIEnv*, |
|
362 |
jclass, |
|
363 |
jint aHandle) |
|
364 |
{ |
|
365 |
const MSwtConstrainedText* constrText = reinterpret_cast<MSwtConstrainedText*>(aHandle); |
|
366 |
TInt result; |
|
367 |
CallMethod(result, constrText, &MSwtConstrainedText::GetCaretPosition); |
|
368 |
return result; |
|
369 |
} |
|
370 |
||
371 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ConstrainedText_1SetSelection( |
|
372 |
JNIEnv* aJniEnv, |
|
373 |
jclass, |
|
374 |
jint aHandle, |
|
375 |
jint aStart, |
|
376 |
jint aEnd) |
|
377 |
{ |
|
378 |
MSwtConstrainedText* constrText = reinterpret_cast<MSwtConstrainedText*>(aHandle); |
|
379 |
TRAPD(error, CallMethodL(constrText, &MSwtConstrainedText::SetSelectionL, aStart, aEnd)); |
|
380 |
ThrowIfError(error, aJniEnv); |
|
381 |
} |
|
382 |
||
383 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ConstrainedText_1ClearSelection( |
|
384 |
JNIEnv* aJniEnv, |
|
385 |
jclass, |
|
386 |
jint aHandle) |
|
387 |
{ |
|
388 |
MSwtConstrainedText* constrText = reinterpret_cast<MSwtConstrainedText*>(aHandle); |
|
389 |
TRAPD(error, CallMethodL(constrText, &MSwtConstrainedText::ClearSelectionL)); |
|
390 |
ThrowIfError(error, aJniEnv); |
|
391 |
} |
|
392 |
||
393 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ConstrainedText_1SelectAll( |
|
394 |
JNIEnv* aJniEnv, |
|
395 |
jclass, |
|
396 |
jint aHandle) |
|
397 |
{ |
|
398 |
MSwtConstrainedText* constrText = reinterpret_cast<MSwtConstrainedText*>(aHandle); |
|
399 |
TRAPD(error, CallMethodL(constrText, &MSwtConstrainedText::SelectAllL)); |
|
400 |
ThrowIfError(error, aJniEnv); |
|
401 |
} |
|
402 |
||
403 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ConstrainedText_1ShowSelection( |
|
404 |
JNIEnv* aJniEnv, |
|
405 |
jclass, |
|
406 |
jint aHandle) |
|
407 |
{ |
|
408 |
MSwtConstrainedText* constrText = reinterpret_cast<MSwtConstrainedText*>(aHandle); |
|
409 |
TRAPD(error, CallMethodL(constrText, &MSwtConstrainedText::ShowSelectionL)); |
|
410 |
ThrowIfError(error, aJniEnv); |
|
411 |
} |
|
412 |
||
413 |
JNIEXPORT jboolean JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ConstrainedText_1Cut( |
|
414 |
JNIEnv* aJniEnv, |
|
415 |
jclass, |
|
416 |
jint aHandle) |
|
417 |
{ |
|
418 |
MSwtConstrainedText* constrText = reinterpret_cast<MSwtConstrainedText*>(aHandle); |
|
419 |
TBool result = EFalse; |
|
420 |
TRAPD(error, CallMethodL(result, constrText, &MSwtConstrainedText::CutL)); |
|
421 |
ThrowIfError(error, aJniEnv); |
|
422 |
return ConvertBoolean(result); |
|
423 |
} |
|
424 |
||
425 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ConstrainedText_1Copy( |
|
426 |
JNIEnv* aJniEnv, |
|
427 |
jclass, |
|
428 |
jint aHandle) |
|
429 |
{ |
|
430 |
MSwtConstrainedText* constrText = reinterpret_cast<MSwtConstrainedText*>(aHandle); |
|
431 |
TRAPD(error, CallMethodL(constrText, &MSwtConstrainedText::CopyL)); |
|
432 |
ThrowIfError(error, aJniEnv); |
|
433 |
} |
|
434 |
||
435 |
JNIEXPORT jboolean JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ConstrainedText_1Paste( |
|
436 |
JNIEnv* aJniEnv, |
|
437 |
jclass, |
|
438 |
jint aHandle) |
|
439 |
{ |
|
440 |
MSwtConstrainedText* constrText = reinterpret_cast<MSwtConstrainedText*>(aHandle); |
|
441 |
TBool result = EFalse; |
|
442 |
TRAPD(error, CallMethodL(result, constrText, &MSwtConstrainedText::PasteL)); |
|
443 |
ThrowIfError(error, aJniEnv); |
|
444 |
return ConvertBoolean(result); |
|
445 |
} |
|
446 |
||
447 |
JNIEXPORT jboolean JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ConstrainedText_1GetEditable( |
|
448 |
JNIEnv*, |
|
449 |
jclass, |
|
450 |
jint aHandle) |
|
451 |
{ |
|
452 |
const MSwtConstrainedText* constrText = reinterpret_cast<MSwtConstrainedText*>(aHandle); |
|
453 |
TBool result; |
|
454 |
CallMethod(result, constrText, &MSwtConstrainedText::GetEditable); |
|
455 |
return ConvertBoolean(result); |
|
456 |
} |
|
457 |
||
458 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ConstrainedText_1SetEditable( |
|
459 |
JNIEnv* /*aJniEnv*/, |
|
460 |
jclass, |
|
461 |
jint aHandle, |
|
462 |
jboolean aEditable) |
|
463 |
{ |
|
464 |
MSwtConstrainedText* constrText = reinterpret_cast<MSwtConstrainedText*>(aHandle); |
|
465 |
CallMethod(constrText, &MSwtConstrainedText::SetEditable, aEditable); |
|
466 |
} |
|
467 |
||
468 |
||
469 |
/* |
|
470 |
* Class DateEditor |
|
471 |
*/ |
|
472 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_DateEditor_1New( |
|
473 |
JNIEnv* aJniEnv, |
|
474 |
jclass, |
|
475 |
jobject aPeer, |
|
476 |
jint aParent, |
|
477 |
jint aStyle) |
|
478 |
{ |
|
479 |
jint handle = NewMobileWidget(aJniEnv, &MSwtFactory::NewDateEditorL, aPeer, |
|
480 |
aParent, aStyle); |
|
481 |
INCREASE_INSTANCE_COUNT(handle, DateEditor); |
|
482 |
return handle; |
|
483 |
} |
|
484 |
||
485 |
JNIEXPORT jintArray JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_DateEditor_1GetDate( |
|
486 |
JNIEnv* aJniEnv, |
|
487 |
jclass, |
|
488 |
jint aHandle) |
|
489 |
{ |
|
490 |
MSwtDateEditor* dateEditor = reinterpret_cast<MSwtDateEditor*>(aHandle); |
|
491 |
TInt64 time; |
|
492 |
CallMethod(time, dateEditor, &MSwtDateEditor::GetDate); |
|
493 |
||
494 |
time /= 1000; |
|
495 |
TInt splitDate[2]; |
|
496 |
splitDate[0] = I64HIGH(time); |
|
497 |
splitDate[1] = I64LOW(time); |
|
498 |
return NewJavaIntArray(aJniEnv, splitDate, 2); |
|
499 |
} |
|
500 |
||
501 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_DateEditor_1GetOffset( |
|
502 |
JNIEnv*, |
|
503 |
jclass, |
|
504 |
jint aHandle) |
|
505 |
{ |
|
506 |
const MSwtDateEditor* dateEditor = reinterpret_cast<MSwtDateEditor*>(aHandle); |
|
507 |
TInt result(0); |
|
508 |
CallMethod(result, dateEditor, &MSwtDateEditor::GetOffset); |
|
509 |
return result; |
|
510 |
} |
|
511 |
||
512 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_DateEditor_1Handle( |
|
513 |
JNIEnv*, |
|
514 |
jclass, |
|
515 |
jint aHandle) |
|
516 |
{ |
|
517 |
MSwtDateEditor* dateEditor = reinterpret_cast<MSwtDateEditor*>(aHandle); |
|
518 |
MSwtControl* result; |
|
519 |
CallMethod(result, dateEditor, &MSwtDateEditor::Control); |
|
520 |
return reinterpret_cast<jint>(result); |
|
521 |
} |
|
522 |
||
523 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_DateEditor_1SetDate( |
|
524 |
JNIEnv*, |
|
525 |
jclass, |
|
526 |
jint aHandle, |
|
527 |
jint aDateHigh, |
|
528 |
jint aDateLow) |
|
529 |
{ |
|
530 |
MSwtDateEditor* dateEditor = reinterpret_cast<MSwtDateEditor*>(aHandle); |
|
531 |
TInt64 dateInMicroSec(MAKE_TINT64(static_cast<TUint>(aDateHigh), |
|
532 |
static_cast<TUint>(aDateLow))); |
|
533 |
dateInMicroSec *= 1000; |
|
534 |
CallMethod(dateEditor, &MSwtDateEditor::SetDate, dateInMicroSec); |
|
535 |
} |
|
536 |
||
537 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_DateEditor_1SetOffset( |
|
538 |
JNIEnv*, |
|
539 |
jclass, |
|
540 |
jint aHandle, |
|
541 |
jint aSeconds) |
|
542 |
{ |
|
543 |
MSwtDateEditor* dateEditor = reinterpret_cast<MSwtDateEditor*>(aHandle); |
|
544 |
CallMethod(dateEditor, &MSwtDateEditor::SetOffset, aSeconds); |
|
545 |
} |
|
546 |
||
547 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_DateEditor_1SetDateEditorStyle( |
|
548 |
JNIEnv* aJniEnv, |
|
549 |
jclass, |
|
550 |
jint aHandle, |
|
551 |
jint aDateEditorStyle) |
|
552 |
{ |
|
553 |
MSwtDateEditor* dateEditor = reinterpret_cast<MSwtDateEditor*>(aHandle); |
|
554 |
TRAPD(error, CallMethodL(dateEditor, &MSwtDateEditor::SetDateEditorStyleL, aDateEditorStyle)); |
|
555 |
ThrowIfError(error, aJniEnv); |
|
556 |
} |
|
557 |
||
558 |
||
559 |
/* |
|
560 |
* Class HyperLink |
|
561 |
*/ |
|
562 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_HyperLink_1ControlHandle( |
|
563 |
JNIEnv*, |
|
564 |
jclass, |
|
565 |
jint aHandle) |
|
566 |
{ |
|
567 |
MSwtHyperLink* hyperLink = reinterpret_cast<MSwtHyperLink*>(aHandle); |
|
568 |
MSwtControl* result; |
|
569 |
CallMethod(result, hyperLink, &MSwtHyperLink::Control); |
|
570 |
return reinterpret_cast<jint>(result); |
|
571 |
} |
|
572 |
||
573 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_HyperLink_1New( |
|
574 |
JNIEnv* aJniEnv, |
|
575 |
jclass, |
|
576 |
jobject aPeer, |
|
577 |
jint aParent, |
|
578 |
jint aStyle) |
|
579 |
{ |
|
580 |
jint handle = NewMobileWidget(aJniEnv, &MSwtFactory::NewHyperLinkL, |
|
581 |
aPeer, aParent, aStyle); |
|
582 |
INCREASE_INSTANCE_COUNT(handle, HyperLink); |
|
583 |
return handle; |
|
584 |
} |
|
585 |
||
586 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_HyperLink_1SetText( |
|
587 |
JNIEnv* aJniEnv, |
|
588 |
jclass, |
|
589 |
jint aHandle, |
|
590 |
jstring aString) |
|
591 |
{ |
|
592 |
CallTextMethodThrow(aJniEnv, aHandle, &MSwtHyperLink::SetTextL, aString); |
|
593 |
} |
|
594 |
||
595 |
JNIEXPORT jstring JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_HyperLink_1GetText( |
|
596 |
JNIEnv* aJniEnv, |
|
597 |
jclass, |
|
598 |
jint aHandle) |
|
599 |
{ |
|
600 |
MSwtHyperLink* hyperLink = reinterpret_cast<MSwtHyperLink*>(aHandle); |
|
601 |
const TDesC* text = NULL; |
|
602 |
CallMethod(text, hyperLink, &MSwtHyperLink::GetText); |
|
603 |
return NewJavaString(aJniEnv, (text != NULL) ? *text : KNullDesC()); |
|
604 |
} |
|
605 |
||
606 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_HyperLink_1SetFormat( |
|
607 |
JNIEnv* /*aJniEnv*/, |
|
608 |
jclass, |
|
609 |
jint aHandle, |
|
610 |
jint aFormat) |
|
611 |
{ |
|
612 |
MSwtHyperLink* hyperLink = reinterpret_cast<MSwtHyperLink*>(aHandle); |
|
613 |
CallMethod(hyperLink, &MSwtHyperLink::SetFormat, aFormat); |
|
614 |
} |
|
615 |
||
616 |
||
617 |
/* |
|
618 |
* Class Input |
|
619 |
*/ |
|
620 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_Input_1New( |
|
621 |
JNIEnv* aJniEnv, |
|
622 |
jclass, |
|
623 |
jobject aPeer, |
|
624 |
jint aId) |
|
625 |
{ |
|
626 |
CSwtDisplay& display = CSwtDisplay::Current(); |
|
627 |
const MSwtFactory* mobileFactory = &display.Factory(); |
|
628 |
jweak peerRef = aJniEnv->NewWeakGlobalRef(aPeer); |
|
629 |
if (peerRef == NULL) |
|
630 |
return 0; |
|
631 |
||
632 |
MSwtInput* input = NULL; |
|
633 |
TRAPD(error, CallMethodL(input, mobileFactory, &MSwtFactory::NewInputL, |
|
634 |
peerRef, aId)); |
|
635 |
if (error) |
|
636 |
{ |
|
637 |
aJniEnv->DeleteWeakGlobalRef(peerRef); |
|
638 |
Throw(error, aJniEnv); |
|
639 |
} |
|
640 |
||
641 |
INCREASE_INSTANCE_COUNT(input, Input); |
|
642 |
||
643 |
return reinterpret_cast<jint>(input); |
|
644 |
} |
|
645 |
||
646 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_Input_1Dispose( |
|
647 |
JNIEnv* aJniEnv, |
|
648 |
jclass, |
|
649 |
jint aHandle) |
|
650 |
{ |
|
651 |
MSwtInput* input = reinterpret_cast<MSwtInput*>(aHandle); |
|
652 |
TSwtPeer peerRef; |
|
653 |
CallMethod(peerRef, input, &MSwtInput::Dispose); |
|
654 |
||
655 |
ReleasePeer(aJniEnv, peerRef); |
|
656 |
||
657 |
DECREASE_INSTANCE_COUNT(Input); |
|
658 |
} |
|
659 |
||
660 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_Input_1GetLocation( |
|
661 |
JNIEnv* /*aJniEnv*/, |
|
662 |
jclass, |
|
663 |
jint aHandle) |
|
664 |
{ |
|
665 |
MSwtInput* input = reinterpret_cast<MSwtInput*>(aHandle); |
|
666 |
TInt location = 0; |
|
667 |
CallMethod(location, input, &MSwtInput::GetLocation); |
|
668 |
return location; |
|
669 |
} |
|
670 |
||
671 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_Input_1GetType( |
|
672 |
JNIEnv* /*aJniEnv*/, |
|
673 |
jclass, |
|
674 |
jint aHandle) |
|
675 |
{ |
|
676 |
MSwtInput* input = reinterpret_cast<MSwtInput*>(aHandle); |
|
677 |
TInt type = 0; |
|
678 |
CallMethod(type, input, &MSwtInput::GetType); |
|
679 |
return type; |
|
680 |
} |
|
681 |
||
682 |
||
683 |
/* |
|
684 |
* Class ListBox |
|
685 |
*/ |
|
686 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListBox_1New( |
|
687 |
JNIEnv* aJniEnv, |
|
688 |
jclass, |
|
689 |
jobject aPeer, |
|
690 |
jint aParent, |
|
691 |
jint aStyle) |
|
692 |
{ |
|
693 |
jint handle = NewMobileWidget( |
|
694 |
aJniEnv, |
|
695 |
&MSwtFactory::NewListBoxL, |
|
696 |
aPeer, |
|
697 |
aParent, |
|
698 |
aStyle); |
|
699 |
INCREASE_INSTANCE_COUNT(handle, ListBox); |
|
700 |
return handle; |
|
701 |
} |
|
702 |
||
703 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListBox_1SetLayoutStyle( |
|
704 |
JNIEnv* aJniEnv, |
|
705 |
jclass, |
|
706 |
jint aHandle, |
|
707 |
jint aLayoutStyle) |
|
708 |
{ |
|
709 |
MSwtListBox* theListBox = reinterpret_cast<MSwtListBox*>(aHandle); |
|
710 |
TRAPD( |
|
711 |
error, |
|
712 |
CallMethodL( |
|
713 |
theListBox, |
|
714 |
&MSwtListBox::SetLayoutStyleL, |
|
715 |
aLayoutStyle)); |
|
716 |
ThrowIfError(error, aJniEnv); |
|
717 |
} |
|
718 |
||
719 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListBox_1ScrollableHandle( |
|
720 |
JNIEnv*, |
|
721 |
jclass, |
|
722 |
jint aHandle) |
|
723 |
{ |
|
724 |
MSwtListBox* theListBox = reinterpret_cast<MSwtListBox*>(aHandle); |
|
725 |
MSwtScrollable* result; |
|
726 |
CallMethod( |
|
727 |
result, |
|
728 |
theListBox, |
|
729 |
&MSwtListBox::Scrollable); |
|
730 |
return reinterpret_cast<jint>(result); |
|
731 |
} |
|
732 |
||
733 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListBox_1Deselect__II( |
|
734 |
JNIEnv* aJniEnv, |
|
735 |
jclass, |
|
736 |
jint aHandle, |
|
737 |
jint aIndex) |
|
738 |
{ |
|
739 |
MSwtListBox* theListBox = reinterpret_cast<MSwtListBox*>(aHandle); |
|
740 |
TRAPD( |
|
741 |
error, |
|
742 |
CallMethodL( |
|
743 |
theListBox, |
|
744 |
&MSwtListBox::DeselectItemL, |
|
745 |
aIndex)); |
|
746 |
ThrowIfError(error, aJniEnv); |
|
747 |
} |
|
748 |
||
749 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListBox_1Deselect__III( |
|
750 |
JNIEnv* aJniEnv, |
|
751 |
jclass, |
|
752 |
jint aHandle, |
|
753 |
jint aStart, |
|
754 |
jint aEnd) |
|
755 |
{ |
|
756 |
MSwtListBox* theListBox = reinterpret_cast<MSwtListBox*>(aHandle); |
|
757 |
TRAPD( |
|
758 |
error, |
|
759 |
CallMethodL( |
|
760 |
theListBox, |
|
761 |
&MSwtListBox::DeselectRangeL, |
|
762 |
aStart, |
|
763 |
aEnd)); |
|
764 |
ThrowIfError(error, aJniEnv); |
|
765 |
} |
|
766 |
||
767 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListBox_1Deselect__I_3I( |
|
768 |
JNIEnv* aJniEnv, |
|
769 |
jclass, |
|
770 |
jint aHandle, |
|
771 |
jintArray aIndices) |
|
772 |
{ |
|
773 |
TInt* ints = NULL; |
|
774 |
TInt count = JavaIntsToInts(aJniEnv, aIndices, ints); |
|
775 |
if (count == 0) |
|
776 |
{ |
|
777 |
return; |
|
778 |
} |
|
779 |
||
780 |
MSwtListBox* theListBox = reinterpret_cast<MSwtListBox*>(aHandle); |
|
781 |
TRAPD( |
|
782 |
error, |
|
783 |
CallMethodL( |
|
784 |
theListBox, |
|
785 |
&MSwtListBox::DeselectItemsL, |
|
786 |
ints, |
|
787 |
count)); |
|
788 |
delete[] ints; |
|
789 |
ThrowIfError(error, aJniEnv); |
|
790 |
} |
|
791 |
||
792 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListBox_1DeselectAll( |
|
793 |
JNIEnv* aJniEnv, |
|
794 |
jclass, |
|
795 |
jint aHandle) |
|
796 |
{ |
|
797 |
MSwtListBox* theListBox = reinterpret_cast<MSwtListBox*>(aHandle); |
|
798 |
TRAPD( |
|
799 |
error, |
|
800 |
CallMethodL( |
|
801 |
theListBox, |
|
802 |
&MSwtListBox::DeselectAllL)); |
|
803 |
ThrowIfError(error, aJniEnv); |
|
804 |
} |
|
805 |
||
806 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListBox_1GetSelectionCount( |
|
807 |
JNIEnv*, |
|
808 |
jclass, |
|
809 |
jint aHandle) |
|
810 |
{ |
|
811 |
const MSwtListBox* theListBox = reinterpret_cast<MSwtListBox*>(aHandle); |
|
812 |
TInt result; |
|
813 |
CallMethod( |
|
814 |
result, |
|
815 |
theListBox, |
|
816 |
&MSwtListBox::GetSelectionCount); |
|
817 |
return result; |
|
818 |
} |
|
819 |
||
820 |
JNIEXPORT jintArray JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListBox_1GetSelectionIndices( |
|
821 |
JNIEnv* aJniEnv, |
|
822 |
jclass, |
|
823 |
jint aHandle) |
|
824 |
{ |
|
825 |
const MSwtListBox* theListBox = reinterpret_cast<MSwtListBox*>(aHandle); |
|
826 |
const CArrayFix<TInt>* selectionArray; |
|
827 |
CallMethod( |
|
828 |
selectionArray, |
|
829 |
theListBox, |
|
830 |
&MSwtListBox::GetSelectionIndices); |
|
831 |
TInt count = selectionArray ? selectionArray->Count() : 0; |
|
832 |
jintArray result = aJniEnv->NewIntArray(count); |
|
833 |
if (!result) |
|
834 |
{ |
|
835 |
return NULL; |
|
836 |
} |
|
837 |
||
838 |
for (TInt i = 0; i < count; ++i) |
|
839 |
{ |
|
840 |
TInt value = (*selectionArray)[i]; //lint !e613 |
|
841 |
aJniEnv->SetIntArrayRegion(result, i, 1, &value); |
|
842 |
} |
|
843 |
return result; |
|
844 |
} |
|
845 |
||
846 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListBox_1GetFocusIndex( |
|
847 |
JNIEnv *, |
|
848 |
jclass, |
|
849 |
jint aHandle) |
|
850 |
{ |
|
851 |
const MSwtListBox* theListBox = reinterpret_cast<MSwtListBox*>(aHandle); |
|
852 |
TInt result = 0; |
|
853 |
CallMethod( |
|
854 |
result, |
|
855 |
theListBox, |
|
856 |
&MSwtListBox::GetFocusIndex); |
|
857 |
return result; |
|
858 |
} |
|
859 |
||
860 |
static void ListBox_RefreshItemL(JNIEnv* aJniEnv, |
|
861 |
MSwtListBox* aListBox, |
|
862 |
TInt aIndex, |
|
863 |
jobject aJavaItem) |
|
864 |
{ |
|
865 |
CSwtListBoxItem* item = ConvertListBoxItemL(aJniEnv, aJavaItem); |
|
866 |
if (item) |
|
867 |
{ |
|
868 |
CleanupStack::PushL(item); |
|
869 |
} |
|
870 |
// item can be also null |
|
871 |
CallMethodL(aListBox, &MSwtListBox::RefreshItemL, aIndex, item); |
|
872 |
if (item) |
|
873 |
{ |
|
874 |
CleanupStack::PopAndDestroy(item); |
|
875 |
} |
|
876 |
} |
|
877 |
||
878 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListBox_1RefreshItem( |
|
879 |
JNIEnv* aJniEnv, |
|
880 |
jclass, |
|
881 |
jint aHandle, |
|
882 |
jint aIndex, |
|
883 |
jobject aJavaItem) |
|
884 |
{ |
|
885 |
MSwtListBox* theListBox = reinterpret_cast< MSwtListBox* >(aHandle); |
|
886 |
TRAPD( |
|
887 |
error, |
|
888 |
ListBox_RefreshItemL( |
|
889 |
aJniEnv, |
|
890 |
theListBox, |
|
891 |
aIndex, |
|
892 |
aJavaItem)); |
|
893 |
ThrowIfError(error, aJniEnv); |
|
894 |
} |
|
895 |
||
896 |
// LeaveScan does not like method pointers in argument lists, this typedef |
|
897 |
// helps preventing it from misreporting |
|
898 |
typedef void (MSwtListBox::*TListBoxSetModelMethod)(const RSwtListBoxItemsArray&); |
|
899 |
||
900 |
static void ListBox_ConvertModelAndCallMethodL( |
|
901 |
JNIEnv* aJniEnv, |
|
902 |
const jobjectArray aDataModelArray, |
|
903 |
MSwtListBox* aListBox, |
|
904 |
TListBoxSetModelMethod aMethodL) |
|
905 |
{ |
|
906 |
TBool failed = EFalse; |
|
907 |
RSwtListBoxItemsArray array = ConvertListBoxItemArrayL( |
|
908 |
aJniEnv, |
|
909 |
aDataModelArray, |
|
910 |
failed); |
|
911 |
if (!failed) |
|
912 |
{ |
|
913 |
CleanupResetAndDestroyPushL(array); |
|
914 |
CallMethodL(aListBox, aMethodL, array); |
|
915 |
CleanupStack::PopAndDestroy(); // array |
|
916 |
} |
|
917 |
else |
|
918 |
{ |
|
919 |
array.ResetAndDestroy(); |
|
920 |
} |
|
921 |
} |
|
922 |
||
923 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListBox_1RefreshList( |
|
924 |
JNIEnv* aJniEnv, |
|
925 |
jclass, |
|
926 |
jint aHandle, |
|
927 |
jobjectArray aDataModelArray) |
|
928 |
{ |
|
929 |
ASSERT(aDataModelArray); |
|
930 |
MSwtListBox* theListBox = reinterpret_cast<MSwtListBox*>(aHandle); |
|
931 |
TRAPD( |
|
932 |
error, |
|
933 |
ListBox_ConvertModelAndCallMethodL( |
|
934 |
aJniEnv, |
|
935 |
aDataModelArray, |
|
936 |
theListBox, |
|
937 |
&MSwtListBox::RefreshListL)); |
|
938 |
ThrowIfError(error, aJniEnv); |
|
939 |
} |
|
940 |
||
941 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListBox_1Select__IIZ( |
|
942 |
JNIEnv* aJniEnv, |
|
943 |
jclass, |
|
944 |
jint aHandle, |
|
945 |
jint aIndex, |
|
946 |
jboolean aScroll) |
|
947 |
{ |
|
948 |
MSwtListBox* theListBox = reinterpret_cast<MSwtListBox*>(aHandle); |
|
949 |
TRAPD( |
|
950 |
error, |
|
951 |
CallMethodL( |
|
952 |
theListBox, |
|
953 |
&MSwtListBox::SelectItemL, |
|
954 |
aIndex, aScroll)); |
|
955 |
ThrowIfError(error, aJniEnv); |
|
956 |
} |
|
957 |
||
958 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListBox_1Select__III( |
|
959 |
JNIEnv* aJniEnv, |
|
960 |
jclass, |
|
961 |
jint aHandle, |
|
962 |
jint aStart, |
|
963 |
jint aEnd) |
|
964 |
{ |
|
965 |
MSwtListBox* theListBox = reinterpret_cast<MSwtListBox*>(aHandle); |
|
966 |
TRAPD( |
|
967 |
error, |
|
968 |
CallMethodL( |
|
969 |
theListBox, |
|
970 |
&MSwtListBox::SelectRangeL, |
|
971 |
aStart, |
|
972 |
aEnd)); |
|
973 |
ThrowIfError(error, aJniEnv); |
|
974 |
} |
|
975 |
||
976 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListBox_1SelectAll( |
|
977 |
JNIEnv* aJniEnv, |
|
978 |
jclass, |
|
979 |
jint aHandle) |
|
980 |
{ |
|
981 |
MSwtListBox* theListBox = reinterpret_cast<MSwtListBox*>(aHandle); |
|
982 |
TRAPD( |
|
983 |
error, |
|
984 |
CallMethodL( |
|
985 |
theListBox, |
|
986 |
&MSwtListBox::SelectAllL)); |
|
987 |
ThrowIfError(error, aJniEnv); |
|
988 |
} |
|
989 |
||
990 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListBox_1SetFocusIndex(JNIEnv*, jclass, jint aHandle, jint aIndex) |
|
991 |
{ |
|
992 |
MSwtListBox* theListBox = reinterpret_cast<MSwtListBox*>(aHandle); |
|
993 |
CallMethod(theListBox, &MSwtListBox::SetFocusIndex, aIndex); |
|
994 |
} |
|
995 |
||
996 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListBox_1SetDataModel( |
|
997 |
JNIEnv* aJniEnv, |
|
998 |
jclass, |
|
999 |
jint aHandle, |
|
1000 |
jobjectArray aDataModelArray) |
|
1001 |
{ |
|
1002 |
MSwtListBox* theListBox = reinterpret_cast<MSwtListBox*>(aHandle); |
|
1003 |
TRAPD( |
|
1004 |
error, |
|
1005 |
ListBox_ConvertModelAndCallMethodL( |
|
1006 |
aJniEnv, |
|
1007 |
aDataModelArray, |
|
1008 |
theListBox, |
|
1009 |
&MSwtListBox::SetDataModelL)); |
|
1010 |
ThrowIfError(error, aJniEnv); |
|
1011 |
} |
|
1012 |
||
1013 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListBox_1SetHeadingFont( |
|
1014 |
JNIEnv* aJniEnv, |
|
1015 |
jclass, |
|
1016 |
jint aHandle, |
|
1017 |
jint aFontHandle) |
|
1018 |
{ |
|
1019 |
MSwtListBox* theListBox = reinterpret_cast<MSwtListBox*>(aHandle); |
|
1020 |
MSwtFont* font = reinterpret_cast<MSwtFont*>(aFontHandle); |
|
1021 |
TRAPD( |
|
1022 |
error, |
|
1023 |
CallMethodL( |
|
1024 |
theListBox, |
|
1025 |
&MSwtListBox::SetHeadingFontL, |
|
1026 |
font)); |
|
1027 |
ThrowIfError(error, aJniEnv); |
|
1028 |
} |
|
1029 |
||
1030 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListBox_1ShowSelection( |
|
1031 |
JNIEnv*, |
|
1032 |
jclass, |
|
1033 |
jint aHandle) |
|
1034 |
{ |
|
1035 |
MSwtListBox* theListBox = reinterpret_cast<MSwtListBox*>(aHandle); |
|
1036 |
CallMethod(theListBox, &MSwtListBox::ShowSelection); |
|
1037 |
} |
|
1038 |
||
1039 |
||
1040 |
/* |
|
1041 |
* Class ListView |
|
1042 |
*/ |
|
1043 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1New( |
|
1044 |
JNIEnv* aJniEnv, |
|
1045 |
jclass, |
|
1046 |
jobject aPeer, |
|
1047 |
jint aParent, |
|
1048 |
jint aStyle) |
|
1049 |
{ |
|
1050 |
jint handle = NewMobileWidget(aJniEnv, &MSwtFactory::NewListViewL, aPeer, |
|
1051 |
aParent, aStyle); |
|
1052 |
INCREASE_INSTANCE_COUNT(handle, ListView); |
|
1053 |
return handle; |
|
1054 |
} |
|
1055 |
||
1056 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1ScrollableHandle( |
|
1057 |
JNIEnv*, |
|
1058 |
jclass, |
|
1059 |
jint aHandle) |
|
1060 |
{ |
|
1061 |
MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1062 |
MSwtScrollable* result; |
|
1063 |
CallMethod(result, theListView, &MSwtListView::Scrollable); |
|
1064 |
return reinterpret_cast<jint>(result); |
|
1065 |
} |
|
1066 |
||
1067 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1Add__ILjava_lang_String_2I( |
|
1068 |
JNIEnv* aJniEnv, |
|
1069 |
jclass, |
|
1070 |
jint aHandle, |
|
1071 |
jstring aString, |
|
1072 |
jint aIconHandle) |
|
1073 |
{ |
|
1074 |
MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1075 |
MSwtImage* icon = reinterpret_cast<MSwtImage*>(aIconHandle); |
|
1076 |
TRAPD(error, |
|
1077 |
HBufC* convertedText = ConvertStringL(aJniEnv, aString); |
|
1078 |
CleanupStack::PushL(convertedText); |
|
1079 |
TPtr des(convertedText->Des()); |
|
1080 |
CallMethodL(theListView, &MSwtListView::AppendL, des, icon); |
|
1081 |
CleanupStack::PopAndDestroy(convertedText); |
|
1082 |
); |
|
1083 |
ThrowIfError(error, aJniEnv); |
|
1084 |
} |
|
1085 |
||
1086 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1Add__ILjava_lang_String_2II( |
|
1087 |
JNIEnv* aJniEnv, |
|
1088 |
jclass, |
|
1089 |
jint aHandle, |
|
1090 |
jstring aString, |
|
1091 |
jint aIconHandle, |
|
1092 |
jint aIndex) |
|
1093 |
{ |
|
1094 |
MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1095 |
MSwtImage* icon = reinterpret_cast<MSwtImage*>(aIconHandle); |
|
1096 |
TRAPD(error, |
|
1097 |
HBufC* convertedText = ConvertStringL(aJniEnv, aString); |
|
1098 |
CleanupStack::PushL(convertedText); |
|
1099 |
TPtr des(convertedText->Des()); |
|
1100 |
CallMethodL(theListView, &MSwtListView::InsertL, aIndex, des, icon); |
|
1101 |
CleanupStack::PopAndDestroy(convertedText); |
|
1102 |
); |
|
1103 |
ThrowIfError(error, aJniEnv); |
|
1104 |
} |
|
1105 |
||
1106 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1Deselect__II( |
|
1107 |
JNIEnv*, |
|
1108 |
jclass, |
|
1109 |
jint aHandle, |
|
1110 |
jint aIndex) |
|
1111 |
{ |
|
1112 |
MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1113 |
CallMethod(theListView, &MSwtListView::DeselectItem, aIndex); |
|
1114 |
} |
|
1115 |
||
1116 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1Deselect__III( |
|
1117 |
JNIEnv*, |
|
1118 |
jclass, |
|
1119 |
jint aHandle, |
|
1120 |
jint aStart, |
|
1121 |
jint aEnd) |
|
1122 |
{ |
|
1123 |
MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1124 |
CallMethod(theListView, &MSwtListView::DeselectRange, aStart, aEnd); |
|
1125 |
} |
|
1126 |
||
1127 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1Deselect__I_3I( |
|
1128 |
JNIEnv* aJniEnv, |
|
1129 |
jclass, |
|
1130 |
jint aHandle, |
|
1131 |
jintArray aIndices) |
|
1132 |
{ |
|
1133 |
TInt* ints = NULL; |
|
1134 |
TInt count = JavaIntsToInts(aJniEnv, aIndices, ints); |
|
1135 |
if (count == 0) |
|
1136 |
return; |
|
1137 |
||
1138 |
MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1139 |
CallMethod(theListView, &MSwtListView::DeselectItems, ints, count); |
|
1140 |
delete[] ints; |
|
1141 |
} |
|
1142 |
||
1143 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1DeselectAll( |
|
1144 |
JNIEnv*, |
|
1145 |
jclass, |
|
1146 |
jint aHandle) |
|
1147 |
{ |
|
1148 |
MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1149 |
CallMethod(theListView, &MSwtListView::DeselectAll); |
|
1150 |
} |
|
1151 |
||
1152 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1GetFocusIndex( |
|
1153 |
JNIEnv*, |
|
1154 |
jclass, |
|
1155 |
jint aHandle) |
|
1156 |
{ |
|
1157 |
const MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1158 |
TInt result = 0; |
|
1159 |
CallMethod(result, theListView, &MSwtListView::GetFocusIndex); |
|
1160 |
return result; |
|
1161 |
} |
|
1162 |
||
1163 |
JNIEXPORT jstring JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1GetItem( |
|
1164 |
JNIEnv* aJniEnv, |
|
1165 |
jclass, |
|
1166 |
jint aHandle, |
|
1167 |
jint aIndex) |
|
1168 |
{ |
|
1169 |
const MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1170 |
TPtrC result; |
|
1171 |
TRAPD(error, CallMethodL(theListView, &MSwtListView::GetItemL, aIndex, result)); |
|
1172 |
if (error == KErrNone) |
|
1173 |
{ |
|
1174 |
return NewJavaString(aJniEnv, result); |
|
1175 |
} |
|
1176 |
else |
|
1177 |
{ |
|
1178 |
Throw(error, aJniEnv); |
|
1179 |
return 0; |
|
1180 |
} |
|
1181 |
} |
|
1182 |
||
1183 |
JNIEXPORT jobject JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1GetIconSize( |
|
1184 |
JNIEnv* aJniEnv, |
|
1185 |
jclass, |
|
1186 |
jint aHandle, |
|
1187 |
jint aStyle) |
|
1188 |
{ |
|
1189 |
const MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1190 |
TPoint result(TPoint::EUninitialized); |
|
1191 |
CallMethod(result, theListView, &MSwtListView::GetIconSize, aStyle); |
|
1192 |
return NewJavaPoint(aJniEnv, result); |
|
1193 |
} |
|
1194 |
||
1195 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1GetItemCount( |
|
1196 |
JNIEnv*, |
|
1197 |
jclass, |
|
1198 |
jint aHandle) |
|
1199 |
{ |
|
1200 |
const MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1201 |
TInt result = 0; |
|
1202 |
CallMethod(result, theListView, &MSwtListView::GetItemCount); |
|
1203 |
return result; |
|
1204 |
} |
|
1205 |
||
1206 |
JNIEXPORT jobjectArray JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1GetItems( |
|
1207 |
JNIEnv* aJniEnv, |
|
1208 |
jclass, |
|
1209 |
jint aHandle) |
|
1210 |
{ |
|
1211 |
const MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1212 |
CPtrCArray* array = NULL; |
|
1213 |
TRAPD(error, CallMethodL(array, theListView, &MSwtListView::GetItemsL)); |
|
1214 |
if (error != KErrNone) |
|
1215 |
{ |
|
1216 |
Throw(error, aJniEnv); |
|
1217 |
DeleteInUiHeap(array); |
|
1218 |
return NULL; |
|
1219 |
} |
|
1220 |
if (array == NULL) |
|
1221 |
{ |
|
1222 |
return NULL; |
|
1223 |
} |
|
1224 |
||
1225 |
// Construct the array of strings. |
|
1226 |
jobjectArray javaStringArray = NULL; |
|
1227 |
jclass stringClass = aJniEnv->FindClass("java/lang/String"); |
|
1228 |
if (stringClass != NULL) |
|
1229 |
{ |
|
1230 |
const TInt count = array->Count(); |
|
1231 |
javaStringArray = aJniEnv->NewObjectArray(count, stringClass, NULL); |
|
1232 |
if (javaStringArray != NULL) |
|
1233 |
{ |
|
1234 |
jstring javaString; |
|
1235 |
for (TInt i=0; i<count; ++i) |
|
1236 |
{ |
|
1237 |
javaString = NewJavaString(aJniEnv, array->At(i)); |
|
1238 |
aJniEnv->SetObjectArrayElement(javaStringArray, i, javaString); //lint !e613 |
|
1239 |
aJniEnv->DeleteLocalRef(javaString); |
|
1240 |
} |
|
1241 |
} |
|
1242 |
aJniEnv->DeleteLocalRef(stringClass); |
|
1243 |
} |
|
1244 |
||
1245 |
DeleteInUiHeap(array); |
|
1246 |
return javaStringArray; |
|
1247 |
} |
|
1248 |
||
1249 |
JNIEXPORT jobjectArray JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1GetSelection( |
|
1250 |
JNIEnv* aJniEnv, |
|
1251 |
jclass, |
|
1252 |
jint aHandle) |
|
1253 |
{ |
|
1254 |
const MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1255 |
CPtrCArray* selectedItemArray = NULL; |
|
1256 |
TRAPD(error, CallMethodL(selectedItemArray, theListView, &MSwtListView::GetSelectionL)); |
|
1257 |
if (error!=KErrNone) |
|
1258 |
{ |
|
1259 |
Throw(error, aJniEnv); |
|
1260 |
DeleteInUiHeap(selectedItemArray); |
|
1261 |
return NULL; |
|
1262 |
} |
|
1263 |
||
1264 |
if (selectedItemArray==NULL) |
|
1265 |
{ |
|
1266 |
return NULL; |
|
1267 |
} |
|
1268 |
||
1269 |
jobjectArray javaItemArray = NULL; |
|
1270 |
jclass stringClass = aJniEnv->FindClass("java/lang/String"); |
|
1271 |
if (stringClass != NULL) |
|
1272 |
{ |
|
1273 |
const TInt count = selectedItemArray->Count(); |
|
1274 |
javaItemArray = aJniEnv->NewObjectArray(count, stringClass, NULL); |
|
1275 |
if (javaItemArray != NULL) |
|
1276 |
{ |
|
1277 |
jstring javaString; |
|
1278 |
for (TInt i=0; i<count; ++i) |
|
1279 |
{ |
|
1280 |
javaString = NewJavaString(aJniEnv, selectedItemArray->At(i)); |
|
1281 |
aJniEnv->SetObjectArrayElement(javaItemArray, i, javaString); //lint !e613 |
|
1282 |
aJniEnv->DeleteLocalRef(javaString); |
|
1283 |
} |
|
1284 |
} |
|
1285 |
aJniEnv->DeleteLocalRef(stringClass); |
|
1286 |
} |
|
1287 |
||
1288 |
DeleteInUiHeap(selectedItemArray); |
|
1289 |
return javaItemArray; |
|
1290 |
} |
|
1291 |
||
1292 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1GetSelectionCount( |
|
1293 |
JNIEnv*, |
|
1294 |
jclass, |
|
1295 |
jint aHandle) |
|
1296 |
{ |
|
1297 |
const MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1298 |
TInt count; |
|
1299 |
CallMethod(count, theListView, &MSwtListView::GetSelectionCount); |
|
1300 |
return count; |
|
1301 |
} |
|
1302 |
||
1303 |
JNIEXPORT jintArray JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1GetSelectionIndices( |
|
1304 |
JNIEnv* aJniEnv, |
|
1305 |
jclass, |
|
1306 |
jint aHandle) |
|
1307 |
{ |
|
1308 |
const MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1309 |
const CArrayFix<TInt>* selectionArray; |
|
1310 |
CallMethod(selectionArray, theListView, &MSwtListView::GetSelectionIndices); |
|
1311 |
TInt count = (selectionArray!=NULL) ? selectionArray->Count() : 0; |
|
1312 |
jintArray result = aJniEnv->NewIntArray(count); |
|
1313 |
if (!result) |
|
1314 |
{ |
|
1315 |
return NULL; |
|
1316 |
} |
|
1317 |
||
1318 |
for (TInt i=0; i<count; ++i) |
|
1319 |
{ |
|
1320 |
TInt value = (*selectionArray)[i]; //lint !e613 |
|
1321 |
aJniEnv->SetIntArrayRegion(result, i, 1, &value); |
|
1322 |
} |
|
1323 |
return result; |
|
1324 |
} |
|
1325 |
||
1326 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1GetTopIndex( |
|
1327 |
JNIEnv*, |
|
1328 |
jclass, |
|
1329 |
jint aHandle) |
|
1330 |
{ |
|
1331 |
const MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1332 |
TInt result; |
|
1333 |
CallMethod(result, theListView, &MSwtListView::GetTopIndex); |
|
1334 |
return result; |
|
1335 |
} |
|
1336 |
||
1337 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1IndexOf( |
|
1338 |
JNIEnv* aJniEnv, |
|
1339 |
jclass, |
|
1340 |
jint aHandle, |
|
1341 |
jstring aString, |
|
1342 |
jint aStart) |
|
1343 |
{ |
|
1344 |
HBufC* string = NULL; |
|
1345 |
TRAPD(error, (string=ConvertStringL(aJniEnv, aString))); |
|
1346 |
if (string == NULL) |
|
1347 |
{ |
|
1348 |
Throw(error, aJniEnv); |
|
1349 |
return 0; |
|
1350 |
} |
|
1351 |
||
1352 |
const MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1353 |
TInt result; |
|
1354 |
CallMethod(result, theListView, &MSwtListView::IndexOf, *string, aStart); |
|
1355 |
delete string; |
|
1356 |
return result; |
|
1357 |
} |
|
1358 |
||
1359 |
JNIEXPORT jboolean JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1IsSelected( |
|
1360 |
JNIEnv*, |
|
1361 |
jclass, |
|
1362 |
jint aHandle, |
|
1363 |
jint aIndex) |
|
1364 |
{ |
|
1365 |
const MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1366 |
TBool result = EFalse; |
|
1367 |
CallMethod(result, theListView, &MSwtListView::IsSelected, aIndex); |
|
1368 |
return ConvertBoolean(result); |
|
1369 |
} |
|
1370 |
||
1371 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1Remove__II( |
|
1372 |
JNIEnv* aJniEnv, |
|
1373 |
jclass, |
|
1374 |
jint aHandle, |
|
1375 |
jint aIndex) |
|
1376 |
{ |
|
1377 |
MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1378 |
TRAPD(error, CallMethodL(theListView, &MSwtListView::RemoveItemL, aIndex)); |
|
1379 |
ThrowIfError(error, aJniEnv); |
|
1380 |
} |
|
1381 |
||
1382 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1Remove__III( |
|
1383 |
JNIEnv* aJniEnv, |
|
1384 |
jclass, |
|
1385 |
jint aHandle, |
|
1386 |
jint aStart, |
|
1387 |
jint aEnd) |
|
1388 |
{ |
|
1389 |
MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1390 |
TRAPD(error, CallMethodL(theListView, &MSwtListView::RemoveRangeL, aStart, aEnd)); |
|
1391 |
ThrowIfError(error, aJniEnv); |
|
1392 |
} |
|
1393 |
||
1394 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1Remove__I_3I( |
|
1395 |
JNIEnv* aJniEnv, |
|
1396 |
jclass, |
|
1397 |
jint aHandle, |
|
1398 |
jintArray aIndices) |
|
1399 |
{ |
|
1400 |
TInt* ints = NULL; |
|
1401 |
TInt count = JavaIntsToInts(aJniEnv, aIndices, ints); |
|
1402 |
if (count == 0) |
|
1403 |
return; |
|
1404 |
||
1405 |
MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1406 |
TRAPD(error, CallMethodL(theListView, &MSwtListView::RemoveItemsL, ints, count)); |
|
1407 |
ThrowIfError(error, aJniEnv); |
|
1408 |
delete[] ints; |
|
1409 |
} |
|
1410 |
||
1411 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1RemoveAll( |
|
1412 |
JNIEnv* aJniEnv, |
|
1413 |
jclass, |
|
1414 |
jint aHandle) |
|
1415 |
{ |
|
1416 |
MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1417 |
TRAPD(error, CallMethodL(theListView, &MSwtListView::RemoveAllL)); |
|
1418 |
ThrowIfError(error, aJniEnv); |
|
1419 |
} |
|
1420 |
||
1421 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1Select__IIZ( |
|
1422 |
JNIEnv* aJniEnv, |
|
1423 |
jclass, |
|
1424 |
jint aHandle, |
|
1425 |
jint aIndex, |
|
1426 |
jboolean aScroll) |
|
1427 |
{ |
|
1428 |
MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1429 |
TRAPD(error, CallMethodL(theListView, &MSwtListView::SelectItemL, aIndex, aScroll)); |
|
1430 |
ThrowIfError(error, aJniEnv); |
|
1431 |
} |
|
1432 |
||
1433 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1Select__III( |
|
1434 |
JNIEnv* aJniEnv, |
|
1435 |
jclass, |
|
1436 |
jint aHandle, |
|
1437 |
jint aStart, |
|
1438 |
jint aEnd) |
|
1439 |
{ |
|
1440 |
MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1441 |
TRAPD(error, CallMethodL(theListView, &MSwtListView::SelectRangeL, aStart, aEnd)); |
|
1442 |
ThrowIfError(error, aJniEnv); |
|
1443 |
} |
|
1444 |
||
1445 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1SelectAll( |
|
1446 |
JNIEnv* aJniEnv, |
|
1447 |
jclass, |
|
1448 |
jint aHandle) |
|
1449 |
{ |
|
1450 |
MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1451 |
TRAPD(error, CallMethodL(theListView, &MSwtListView::SelectAllL)); |
|
1452 |
ThrowIfError(error, aJniEnv); |
|
1453 |
} |
|
1454 |
||
1455 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1SetFocusIndex(JNIEnv*, jclass, jint aHandle, jint aIndex) |
|
1456 |
{ |
|
1457 |
MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1458 |
CallMethod(theListView, &MSwtListView::SetFocusIndex, aIndex); |
|
1459 |
} |
|
1460 |
||
1461 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1SetItems( |
|
1462 |
JNIEnv* aJniEnv, |
|
1463 |
jclass, |
|
1464 |
jint aHandle, |
|
1465 |
jobjectArray aStringArray, |
|
1466 |
jintArray aIconsHandles) |
|
1467 |
{ |
|
1468 |
CDesCArray* resultArray = NULL; |
|
1469 |
TRAPD(error, (resultArray=ConvertStringArrayL(aJniEnv, aStringArray))); |
|
1470 |
if (error != KErrNone || resultArray == NULL) |
|
1471 |
{ |
|
1472 |
delete resultArray; |
|
1473 |
ThrowIfError(error, aJniEnv); |
|
1474 |
return; |
|
1475 |
} |
|
1476 |
||
1477 |
RPointerArray<MSwtImage> iconsHandles; |
|
1478 |
if (aIconsHandles != NULL) |
|
1479 |
{ |
|
1480 |
TInt count = (aJniEnv->GetArrayLength(aIconsHandles)); |
|
1481 |
||
1482 |
jboolean isCopy; |
|
1483 |
jint* elements = aJniEnv->GetIntArrayElements(aIconsHandles, &isCopy); |
|
1484 |
if (elements != NULL) |
|
1485 |
{ |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1486 |
for (TInt i=0; i<count; ++i) |
66 | 1487 |
{ |
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1488 |
iconsHandles.Append(reinterpret_cast<MSwtImage*>(elements[i])); |
66 | 1489 |
} |
1490 |
// Cleanup |
|
1491 |
aJniEnv->ReleaseIntArrayElements(aIconsHandles, elements, JNI_ABORT); |
|
1492 |
} |
|
1493 |
} |
|
1494 |
||
1495 |
MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1496 |
TRAP(error, CallMethodL(theListView, &MSwtListView::SetItemsL, resultArray, iconsHandles)); |
|
1497 |
ThrowIfError(error, aJniEnv); |
|
1498 |
delete resultArray; |
|
1499 |
} |
|
1500 |
||
1501 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1SetLayout( |
|
1502 |
JNIEnv* aJniEnv, |
|
1503 |
jclass, |
|
1504 |
jint aHandle, |
|
1505 |
jint aLayout) |
|
1506 |
{ |
|
1507 |
MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1508 |
TRAPD(error, CallMethodL(theListView, &MSwtListView::SetLayoutL, aLayout)); |
|
1509 |
ThrowIfError(error, aJniEnv); |
|
1510 |
} |
|
1511 |
||
1512 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1SetLayoutDensity( |
|
1513 |
JNIEnv* aJniEnv, |
|
1514 |
jclass, |
|
1515 |
jint aHandle, |
|
1516 |
jint aDensity) |
|
1517 |
{ |
|
1518 |
MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1519 |
TRAPD(error, CallMethodL(theListView, &MSwtListView::SetLayoutDensityL, aDensity)); |
|
1520 |
ThrowIfError(error, aJniEnv); |
|
1521 |
} |
|
1522 |
||
1523 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_ListView_1ShowSelection( |
|
1524 |
JNIEnv*, |
|
1525 |
jclass, |
|
1526 |
jint aHandle) |
|
1527 |
{ |
|
1528 |
MSwtListView* theListView = reinterpret_cast<MSwtListView*>(aHandle); |
|
1529 |
CallMethod(theListView, &MSwtListView::ShowSelection); |
|
1530 |
} |
|
1531 |
||
1532 |
||
1533 |
/* |
|
1534 |
* Class MobileDevice |
|
1535 |
*/ |
|
1536 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MobileDevice_1New( |
|
1537 |
JNIEnv* aJniEnv, |
|
1538 |
jclass, |
|
1539 |
jobject aPeer) |
|
1540 |
{ |
|
1541 |
CSwtDisplay& display = CSwtDisplay::Current(); |
|
1542 |
const MSwtFactory* factory = &display.Factory(); |
|
1543 |
jweak peerRef = aJniEnv->NewWeakGlobalRef(aPeer); |
|
1544 |
if (peerRef == NULL) |
|
1545 |
return 0; |
|
1546 |
||
1547 |
MSwtMobileDevice* result = NULL; |
|
1548 |
TRAPD(error, CallMethodL(result, factory, &MSwtFactory::NewMobileDeviceL, |
|
1549 |
display, peerRef)); |
|
1550 |
if (error) |
|
1551 |
{ |
|
1552 |
aJniEnv->DeleteWeakGlobalRef(peerRef); |
|
1553 |
Throw(error, aJniEnv); |
|
1554 |
} |
|
1555 |
||
1556 |
return reinterpret_cast<jint>(result); |
|
1557 |
} |
|
1558 |
||
1559 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MobileDevice_1Dispose( |
|
1560 |
JNIEnv* aJniEnv, |
|
1561 |
jclass, |
|
1562 |
jint aHandle) |
|
1563 |
{ |
|
1564 |
CSwtDisplay& display = CSwtDisplay::Current(); |
|
1565 |
MSwtMobileDevice* mobileDevice = reinterpret_cast<MSwtMobileDevice*>(aHandle); |
|
1566 |
TSwtPeer peerRef; |
|
1567 |
CallMethod(peerRef, mobileDevice, &MSwtMobileDevice::Dispose); |
|
1568 |
||
1569 |
ReleasePeer(aJniEnv, peerRef); |
|
1570 |
} |
|
1571 |
||
1572 |
JNIEXPORT jboolean JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MobileDevice_1IsOpen( |
|
1573 |
JNIEnv* /*aJniEnv*/, |
|
1574 |
jclass, |
|
1575 |
jint aHandle) |
|
1576 |
{ |
|
1577 |
const MSwtMobileDevice* mobileDevice = reinterpret_cast<MSwtMobileDevice*>(aHandle); |
|
1578 |
||
1579 |
TBool isOpen(EFalse); |
|
1580 |
CallMethod(isOpen, mobileDevice, &MSwtMobileDevice::IsOpen); |
|
1581 |
||
1582 |
return ConvertBoolean(isOpen); |
|
1583 |
} |
|
1584 |
||
1585 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MobileDevice_1Alert( |
|
1586 |
JNIEnv* /*aJniEnv*/, |
|
1587 |
jclass, |
|
1588 |
jint aHandle, |
|
1589 |
jint aLevel) |
|
1590 |
{ |
|
1591 |
MSwtMobileDevice* mobileDevice = reinterpret_cast<MSwtMobileDevice*>(aHandle); |
|
1592 |
MSwtMobileDevice::TAlertLevel level = static_cast<MSwtMobileDevice::TAlertLevel>(aLevel); |
|
1593 |
CallMethod(mobileDevice, &MSwtMobileDevice::Alert, level); |
|
1594 |
} |
|
1595 |
||
1596 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MobileDevice_1GetInputNumber( |
|
1597 |
JNIEnv* /*aJniEnv*/, |
|
1598 |
jclass, |
|
1599 |
jint aHandle) |
|
1600 |
{ |
|
1601 |
const MSwtMobileDevice* mobileDevice = reinterpret_cast<MSwtMobileDevice*>(aHandle); |
|
1602 |
||
1603 |
TInt nbInputs; |
|
1604 |
CallMethod(nbInputs, mobileDevice, &MSwtMobileDevice::GetInputNumber); |
|
1605 |
||
1606 |
return nbInputs; |
|
1607 |
} |
|
1608 |
||
1609 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MobileDevice_1GetScreenNumber( |
|
1610 |
JNIEnv* /*aJniEnv*/, |
|
1611 |
jclass, |
|
1612 |
jint aHandle) |
|
1613 |
{ |
|
1614 |
const MSwtMobileDevice* mobileDevice = reinterpret_cast<MSwtMobileDevice*>(aHandle); |
|
1615 |
||
1616 |
TInt nbScreens; |
|
1617 |
CallMethod(nbScreens, mobileDevice, &MSwtMobileDevice::GetScreenNumber); |
|
1618 |
return nbScreens; |
|
1619 |
} |
|
1620 |
||
1621 |
||
1622 |
/* |
|
1623 |
* Class MobileShell |
|
1624 |
*/ |
|
1625 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MobileShell_1New( |
|
1626 |
JNIEnv* aJniEnv, jclass, jobject aPeer, jint aParent, jint aStyle) |
|
1627 |
{ |
|
1628 |
CSwtDisplay& display = CSwtDisplay::Current(); |
|
1629 |
const MSwtFactory* factory = &display.Factory(); |
|
1630 |
jweak peerRef = aJniEnv->NewWeakGlobalRef(aPeer); |
|
1631 |
if (!peerRef) |
|
1632 |
{ |
|
1633 |
return 0; |
|
1634 |
} |
|
1635 |
||
1636 |
MSwtShell* parent = reinterpret_cast<MSwtShell*>(aParent); |
|
1637 |
MSwtMobileShell* result = NULL; |
|
1638 |
TRAPD(error, CallMethodL(result, factory, |
|
1639 |
&MSwtFactory::NewMobileShellL, |
|
1640 |
display, peerRef, parent, aStyle)); |
|
1641 |
if (error) |
|
1642 |
{ |
|
1643 |
aJniEnv->DeleteWeakGlobalRef(peerRef); |
|
1644 |
Throw(error, aJniEnv); |
|
1645 |
} |
|
1646 |
||
1647 |
INCREASE_INSTANCE_COUNT(result, MobileShell); |
|
1648 |
||
1649 |
return reinterpret_cast<jint>(result); |
|
1650 |
} |
|
1651 |
||
1652 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MobileShell_1ChangeTrim( |
|
1653 |
JNIEnv* aJniEnv, jclass, jint aHandle, jint aStyle, jint aStatusStyle) |
|
1654 |
{ |
|
1655 |
MSwtMobileShell* mobileShell = reinterpret_cast<MSwtMobileShell*>(aHandle); |
|
1656 |
TRAPD(error, CallMethodL(mobileShell, &MSwtMobileShell::ChangeTrimL, |
|
1657 |
aStyle, aStatusStyle)); |
|
1658 |
ThrowIfError(error, aJniEnv); |
|
1659 |
} |
|
1660 |
||
1661 |
JNIEXPORT jboolean JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MobileShell_1GetFullScreenMode( |
|
1662 |
JNIEnv*, jclass, jint aHandle) |
|
1663 |
{ |
|
1664 |
const MSwtMobileShell* mobileShell = reinterpret_cast<MSwtMobileShell*>(aHandle); |
|
1665 |
const MSwtShell* shell = mobileShell->Shell(); |
|
1666 |
TBool isFullScreen(EFalse); |
|
1667 |
CallMethod(isFullScreen, shell, &MSwtShell::FullScreenMode); |
|
1668 |
return ConvertBoolean(isFullScreen); |
|
1669 |
} |
|
1670 |
||
1671 |
JNIEXPORT jboolean JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MobileShell_1GetKeyState( |
|
1672 |
JNIEnv*, jclass, jint aHandle, jint aSwtKeyCode) |
|
1673 |
{ |
|
1674 |
MSwtMobileShell* mobileShell = reinterpret_cast<MSwtMobileShell*>(aHandle); |
|
1675 |
TBool result = EFalse; |
|
1676 |
CallMethod(result, mobileShell, &MSwtMobileShell::GetKeyState, aSwtKeyCode); |
|
1677 |
return ConvertBoolean(result); |
|
1678 |
} |
|
1679 |
||
1680 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MobileShell_1GetShellHandle( |
|
1681 |
JNIEnv*, jclass, jint aHandle) |
|
1682 |
{ |
|
1683 |
const MSwtMobileShell* mobileShell = reinterpret_cast<MSwtMobileShell*>(aHandle); |
|
1684 |
const MSwtShell* shell = NULL; |
|
1685 |
CallMethod(shell, mobileShell, &MSwtMobileShell::Shell); |
|
1686 |
return reinterpret_cast<jint>(shell); |
|
1687 |
} |
|
1688 |
||
1689 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MobileShell_1SetFullScreenMode( |
|
1690 |
JNIEnv*, jclass, jint aHandle, jboolean aIsFullScreen) |
|
1691 |
{ |
|
1692 |
MSwtMobileShell* mobileShell = reinterpret_cast<MSwtMobileShell*>(aHandle); |
|
1693 |
MSwtShell* shell = const_cast<MSwtShell*>(mobileShell->Shell()); |
|
1694 |
CallMethod(shell, &MSwtShell::SetFullScreen, aIsFullScreen); |
|
1695 |
} |
|
1696 |
||
1697 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MobileShell_1SetStatusText( |
|
1698 |
JNIEnv* aJniEnv, jclass, jint aHandle, jstring aText) |
|
1699 |
{ |
|
1700 |
CallTextMethodThrow(aJniEnv, aHandle, &MSwtMobileShell::SetStatusTextL, aText); |
|
1701 |
} |
|
1702 |
||
1703 |
||
1704 |
/* |
|
1705 |
* Class MultiPageDialog |
|
1706 |
*/ |
|
1707 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MultipageDialog_1TabGroup_1ControlHandle( |
|
1708 |
JNIEnv*, |
|
1709 |
jclass, |
|
1710 |
jint aTabGroupHandle) |
|
1711 |
{ |
|
1712 |
MSwtMultiPageTabGroup* tabGroup = reinterpret_cast<MSwtMultiPageTabGroup*>(aTabGroupHandle); |
|
1713 |
MSwtControl* result; |
|
1714 |
CallMethod(result, tabGroup, &MSwtMultiPageTabGroup::Control); |
|
1715 |
return reinterpret_cast<jint>(result); |
|
1716 |
} |
|
1717 |
||
1718 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MultipageDialog_1Pager_1New( |
|
1719 |
JNIEnv* aJniEnv, |
|
1720 |
jclass, |
|
1721 |
jobject aPeer, |
|
1722 |
jint aParentHandle) |
|
1723 |
{ |
|
1724 |
CSwtDisplay& display = CSwtDisplay::Current(); |
|
1725 |
const MSwtFactory* factory = &display.Factory(); |
|
1726 |
jweak peerRef = aJniEnv->NewWeakGlobalRef(aPeer); |
|
1727 |
if (peerRef == NULL) |
|
1728 |
return 0; |
|
1729 |
||
1730 |
MSwtShell* parent = reinterpret_cast<MSwtShell*>(aParentHandle); |
|
1731 |
MSwtMultiPagePager* result = NULL; |
|
1732 |
TRAPD(error, CallMethodL(result, factory, &MSwtFactory::NewMultiPagePagerL, |
|
1733 |
display, peerRef, *parent)); |
|
1734 |
if (error) |
|
1735 |
{ |
|
1736 |
aJniEnv->DeleteWeakGlobalRef(peerRef); |
|
1737 |
Throw(error, aJniEnv); |
|
1738 |
} |
|
1739 |
||
1740 |
INCREASE_INSTANCE_COUNT(result, MultiPagePager); |
|
1741 |
||
1742 |
return reinterpret_cast<jint>(result); |
|
1743 |
} |
|
1744 |
||
1745 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MultiPageDialog_1Pager_1CompositeHandle( |
|
1746 |
JNIEnv*, |
|
1747 |
jclass, |
|
1748 |
jint aHandle) |
|
1749 |
{ |
|
1750 |
MSwtMultiPagePager* pager = reinterpret_cast<MSwtMultiPagePager*>(aHandle); |
|
1751 |
MSwtComposite* result; |
|
1752 |
CallMethod(result, pager, &MSwtMultiPagePager::Composite); |
|
1753 |
return reinterpret_cast<jint>(result); |
|
1754 |
} |
|
1755 |
||
1756 |
JNIEXPORT jintArray JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MultiPageDialog_1Pager_1GetDialogMargins( |
|
1757 |
JNIEnv* aJniEnv, |
|
1758 |
jclass, |
|
1759 |
jint aHandle) |
|
1760 |
{ |
|
1761 |
const MSwtMultiPagePager* pager = reinterpret_cast<MSwtMultiPagePager*>(aHandle); |
|
1762 |
TMargins margins; |
|
1763 |
CallMethod(margins, pager, &MSwtMultiPagePager::GetDialogMargins); |
|
1764 |
||
1765 |
TInt marginsArray[4]; |
|
1766 |
marginsArray[0] = margins.iLeft; |
|
1767 |
marginsArray[1] = margins.iTop; |
|
1768 |
marginsArray[2] = margins.iRight; |
|
1769 |
marginsArray[3] = margins.iBottom; |
|
1770 |
return NewJavaIntArray(aJniEnv, marginsArray, 4); |
|
1771 |
} |
|
1772 |
||
1773 |
JNIEXPORT jintArray JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MultiPageDialog_1Pager_1GetPagerMargins( |
|
1774 |
JNIEnv* aJniEnv, |
|
1775 |
jclass, |
|
1776 |
jint aHandle) |
|
1777 |
{ |
|
1778 |
const MSwtMultiPagePager* pager = reinterpret_cast<MSwtMultiPagePager*>(aHandle); |
|
1779 |
TMargins margins; |
|
1780 |
CallMethod(margins, pager, &MSwtMultiPagePager::GetPagerMargins); |
|
1781 |
||
1782 |
TInt marginsArray[4]; |
|
1783 |
marginsArray[0] = margins.iLeft; |
|
1784 |
marginsArray[1] = margins.iTop; |
|
1785 |
marginsArray[2] = margins.iRight; |
|
1786 |
marginsArray[3] = margins.iBottom; |
|
1787 |
return NewJavaIntArray(aJniEnv, marginsArray, 4); |
|
1788 |
} |
|
1789 |
||
1790 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MultipageDialog_1TabGroup_1New( |
|
1791 |
JNIEnv* aJniEnv, |
|
1792 |
jclass, |
|
1793 |
jobject aPeer, |
|
1794 |
jint aParentHandle) |
|
1795 |
{ |
|
1796 |
CSwtDisplay& display = CSwtDisplay::Current(); |
|
1797 |
const MSwtFactory* factory = &display.Factory(); |
|
1798 |
jweak peerRef = aJniEnv->NewWeakGlobalRef(aPeer); |
|
1799 |
if (peerRef == NULL) |
|
1800 |
return 0; |
|
1801 |
||
1802 |
MSwtShell* parent = reinterpret_cast<MSwtShell*>(aParentHandle); |
|
1803 |
MSwtMultiPageTabGroup* result = NULL; |
|
1804 |
TRAPD(error, CallMethodL(result, factory, &MSwtFactory::NewMultiPageTabGroupL, display, peerRef, *parent)); |
|
1805 |
if (error) |
|
1806 |
{ |
|
1807 |
aJniEnv->DeleteWeakGlobalRef(peerRef); |
|
1808 |
Throw(error, aJniEnv); |
|
1809 |
} |
|
1810 |
||
1811 |
INCREASE_INSTANCE_COUNT(result, MultiPageTabGroup); |
|
1812 |
||
1813 |
return reinterpret_cast<jint>(result); |
|
1814 |
} |
|
1815 |
||
1816 |
static TInt MultiPageDialog_TabGroup_AddPageL(JNIEnv* aJniEnv, |
|
1817 |
jint aTabGroupHandle, |
|
1818 |
jstring aTitle, |
|
1819 |
jint aImageHandle) |
|
1820 |
{ |
|
1821 |
MSwtMultiPageTabGroup* tabGroup = reinterpret_cast<MSwtMultiPageTabGroup*>(aTabGroupHandle); |
|
1822 |
MSwtImage* image = reinterpret_cast<MSwtImage*>(aImageHandle); |
|
1823 |
TInt selectedIndex = 0; |
|
1824 |
||
1825 |
HBufC* title = ConvertStringLC(aJniEnv, aTitle); |
|
1826 |
||
1827 |
CallMethodL(selectedIndex, tabGroup, &MSwtMultiPageTabGroup::AddPageL, *title, image); |
|
1828 |
CleanupStack::PopAndDestroy(title); |
|
1829 |
||
1830 |
return selectedIndex; |
|
1831 |
} |
|
1832 |
||
1833 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MultiPageDialog_1TabGroup_1AddPage( |
|
1834 |
JNIEnv* aJniEnv, |
|
1835 |
jclass, |
|
1836 |
jint aTabGroupHandle, |
|
1837 |
jstring aTitle, |
|
1838 |
jint aImageHandle) |
|
1839 |
{ |
|
1840 |
TInt selectedIndex = 0; |
|
1841 |
TRAPD(error, (selectedIndex = MultiPageDialog_TabGroup_AddPageL(aJniEnv, aTabGroupHandle, aTitle, aImageHandle))); |
|
1842 |
ThrowIfError(error, aJniEnv); |
|
1843 |
return selectedIndex; |
|
1844 |
} |
|
1845 |
||
1846 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MultipageDialog_1TabGroup_1SetPager( |
|
1847 |
JNIEnv*, |
|
1848 |
jclass, |
|
1849 |
jint aHandle, |
|
1850 |
jint aPagerHandle) |
|
1851 |
{ |
|
1852 |
MSwtMultiPageTabGroup* tabGroup = reinterpret_cast<MSwtMultiPageTabGroup*>(aHandle); |
|
1853 |
MSwtMultiPagePager* pager = reinterpret_cast<MSwtMultiPagePager*>(aPagerHandle); |
|
1854 |
CallMethod(tabGroup, &MSwtMultiPageTabGroup::SetPager, pager); |
|
1855 |
} |
|
1856 |
||
1857 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MultiPageDialog_1TabGroup_1SelectPage( |
|
1858 |
JNIEnv*, |
|
1859 |
jclass, |
|
1860 |
jint aTabGroupHandle, |
|
1861 |
jint aIndex) |
|
1862 |
{ |
|
1863 |
MSwtMultiPageTabGroup* tabGroup = reinterpret_cast<MSwtMultiPageTabGroup*>(aTabGroupHandle); |
|
1864 |
TInt selectedIndex = 0; |
|
1865 |
CallMethod(selectedIndex, tabGroup, &MSwtMultiPageTabGroup::SelectPage, aIndex); |
|
1866 |
return selectedIndex; |
|
1867 |
} |
|
1868 |
||
1869 |
static void MultiPageDialog_TabGroup_SetTabTitleL(JNIEnv* aJniEnv, |
|
1870 |
jint aHandle, |
|
1871 |
jint aIndex, |
|
1872 |
jstring aString) |
|
1873 |
{ |
|
1874 |
MSwtMultiPageTabGroup* tabGroup = reinterpret_cast<MSwtMultiPageTabGroup*>(aHandle); |
|
1875 |
HBufC* convertedText = ConvertStringLC(aJniEnv, aString); |
|
1876 |
TPtr des(convertedText->Des()); |
|
1877 |
CallMethodL(tabGroup, &MSwtMultiPageTabGroup::SetTabTitleL, aIndex, des); |
|
1878 |
CleanupStack::PopAndDestroy(convertedText); |
|
1879 |
} |
|
1880 |
||
1881 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MultipageDialog_1TabGroup_1SetTabTitle( |
|
1882 |
JNIEnv* aJniEnv, |
|
1883 |
jclass, |
|
1884 |
jint aHandle, |
|
1885 |
jint aIndex, |
|
1886 |
jstring aString) |
|
1887 |
{ |
|
1888 |
TRAPD(error, MultiPageDialog_TabGroup_SetTabTitleL(aJniEnv, aHandle, aIndex, aString)); |
|
1889 |
ThrowIfError(error, aJniEnv); |
|
1890 |
} |
|
1891 |
||
1892 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MultiPageDialog_1TabGroup_1RemovePage( |
|
1893 |
JNIEnv*, |
|
1894 |
jclass, |
|
1895 |
jint aTabGroupHandle, |
|
1896 |
jint aIndex) |
|
1897 |
{ |
|
1898 |
MSwtMultiPageTabGroup* tabGroup = reinterpret_cast<MSwtMultiPageTabGroup*>(aTabGroupHandle); |
|
1899 |
TInt selectedIndex = 0; |
|
1900 |
CallMethod(selectedIndex, tabGroup, &MSwtMultiPageTabGroup::RemovePage, aIndex); |
|
1901 |
return selectedIndex; |
|
1902 |
} |
|
1903 |
||
1904 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MultiPageDialog_1New( |
|
1905 |
JNIEnv* aJniEnv, |
|
1906 |
jclass, |
|
1907 |
jobject aPeer, |
|
1908 |
jint aParentHandle) |
|
1909 |
{ |
|
1910 |
CSwtDisplay& display = CSwtDisplay::Current(); |
|
1911 |
const MSwtFactory* factory = &display.Factory(); |
|
1912 |
jweak peerRef = aJniEnv->NewWeakGlobalRef(aPeer); |
|
1913 |
if (peerRef == NULL) |
|
1914 |
return 0; |
|
1915 |
||
1916 |
MSwtShell* parent = reinterpret_cast<MSwtShell*>(aParentHandle); |
|
1917 |
MSwtMultiPageDialog* result = NULL; |
|
1918 |
TRAPD(error, CallMethodL(result, factory, &MSwtFactory::NewMultiPageDialogL, |
|
1919 |
display, peerRef, *parent)); |
|
1920 |
if (error) |
|
1921 |
{ |
|
1922 |
aJniEnv->DeleteWeakGlobalRef(peerRef); |
|
1923 |
Throw(error, aJniEnv); |
|
1924 |
} |
|
1925 |
||
1926 |
INCREASE_INSTANCE_COUNT(result, MultiPageDialog); |
|
1927 |
||
1928 |
return reinterpret_cast<jint>(result); |
|
1929 |
} |
|
1930 |
||
1931 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MultiPageDialog_1ControlHandle( |
|
1932 |
JNIEnv*, |
|
1933 |
jclass, |
|
1934 |
jint aHandle) |
|
1935 |
{ |
|
1936 |
MSwtMultiPageDialog* theControl = reinterpret_cast<MSwtMultiPageDialog*>(aHandle); |
|
1937 |
MSwtControl* result; |
|
1938 |
CallMethod(result, theControl, &MSwtMultiPageDialog::Control); |
|
1939 |
return reinterpret_cast<jint>(result); |
|
1940 |
} |
|
1941 |
||
1942 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MultiPageDialog_1Close( |
|
1943 |
JNIEnv *, |
|
1944 |
jclass, |
|
1945 |
jint aHandle) |
|
1946 |
{ |
|
1947 |
MSwtMultiPageDialog* dialog = reinterpret_cast<MSwtMultiPageDialog*>(aHandle); |
|
1948 |
CallMethod(dialog, &MSwtMultiPageDialog::Close); |
|
1949 |
} |
|
1950 |
||
1951 |
static void MultiPageDialog_CreatePageL( |
|
1952 |
JNIEnv* aJniEnv, |
|
1953 |
jint aHandle, |
|
1954 |
jint aCompositeHandle, |
|
1955 |
jstring aTitle, |
|
1956 |
jint aImageHandle) |
|
1957 |
{ |
|
1958 |
MSwtMultiPageDialog* dialog = reinterpret_cast<MSwtMultiPageDialog*>(aHandle); |
|
1959 |
MSwtImage* image = reinterpret_cast<MSwtImage*>(aImageHandle); |
|
1960 |
MSwtComposite* composite = reinterpret_cast<MSwtComposite*>(aCompositeHandle); |
|
1961 |
HBufC* title = ConvertStringLC(aJniEnv, aTitle); |
|
1962 |
CallMethodL(dialog, &MSwtMultiPageDialog::CreatePageL, composite, *title, image); |
|
1963 |
CleanupStack::PopAndDestroy(title); |
|
1964 |
} |
|
1965 |
||
1966 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MultiPageDialog_1CreatePage( |
|
1967 |
JNIEnv* aJniEnv, |
|
1968 |
jclass, |
|
1969 |
jint aHandle, |
|
1970 |
jint aCompositeHandle, |
|
1971 |
jstring aTitle, |
|
1972 |
jint aImageHandle) |
|
1973 |
{ |
|
1974 |
TRAPD(error, MultiPageDialog_CreatePageL(aJniEnv, aHandle, aCompositeHandle, aTitle, |
|
1975 |
aImageHandle)); |
|
1976 |
ThrowIfError(error, aJniEnv); |
|
1977 |
} |
|
1978 |
||
1979 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MultiPageDialog_1DeletePage( |
|
1980 |
JNIEnv* aJniEnv, |
|
1981 |
jclass, |
|
1982 |
jint aHandle, |
|
1983 |
jint aIndex) |
|
1984 |
{ |
|
1985 |
MSwtMultiPageDialog* dialog = reinterpret_cast<MSwtMultiPageDialog*>(aHandle); |
|
1986 |
TRAPD(error, CallMethodL(dialog, &MSwtMultiPageDialog::DeletePageL, aIndex)); |
|
1987 |
ThrowIfError(error, aJniEnv); |
|
1988 |
} |
|
1989 |
||
1990 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MultiPageDialog_1GetSelectedIndex( |
|
1991 |
JNIEnv*, |
|
1992 |
jclass, |
|
1993 |
jint aHandle) |
|
1994 |
{ |
|
1995 |
MSwtMultiPageDialog* dialog = reinterpret_cast<MSwtMultiPageDialog*>(aHandle); |
|
1996 |
TInt index = 0; |
|
1997 |
CallMethod(index, dialog, &MSwtMultiPageDialog::GetSelectedIndex); |
|
1998 |
return index; |
|
1999 |
} |
|
2000 |
||
2001 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MultiPageDialog_1Open( |
|
2002 |
JNIEnv* aJniEnv, |
|
2003 |
jclass, |
|
2004 |
jint aHandle) |
|
2005 |
{ |
|
2006 |
MSwtMultiPageDialog* dialog = reinterpret_cast<MSwtMultiPageDialog*>(aHandle); |
|
2007 |
TRAPD(error, CallMethodL(dialog, &MSwtMultiPageDialog::OpenL)); |
|
2008 |
ThrowIfError(error, aJniEnv); |
|
2009 |
} |
|
2010 |
||
2011 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MultiPageDialog_1SetSelection( |
|
2012 |
JNIEnv*, |
|
2013 |
jclass, |
|
2014 |
jint aHandle, |
|
2015 |
jint aIndex) |
|
2016 |
{ |
|
2017 |
MSwtMultiPageDialog* dialog = reinterpret_cast<MSwtMultiPageDialog*>(aHandle); |
|
2018 |
CallMethod(dialog, &MSwtMultiPageDialog::SetSelection, aIndex); |
|
2019 |
} |
|
2020 |
||
2021 |
static void MultiPageDialog_SetTitleAndImageL( |
|
2022 |
JNIEnv* aJniEnv, |
|
2023 |
jint aHandle, |
|
2024 |
jint aIndex, |
|
2025 |
jstring aTitle, |
|
2026 |
jint aImageHandle) |
|
2027 |
{ |
|
2028 |
MSwtMultiPageDialog* dialog = reinterpret_cast<MSwtMultiPageDialog*>(aHandle); |
|
2029 |
MSwtImage* image = reinterpret_cast<MSwtImage*>(aImageHandle); |
|
2030 |
HBufC* title = ConvertStringLC(aJniEnv, aTitle); |
|
2031 |
CallMethodL(dialog, &MSwtMultiPageDialog::SetTitleAndImageL, aIndex, *title, image); |
|
2032 |
CleanupStack::PopAndDestroy(title); |
|
2033 |
} |
|
2034 |
||
2035 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MultiPageDialog_1SetTitleAndImage( |
|
2036 |
JNIEnv* aJniEnv, |
|
2037 |
jclass, |
|
2038 |
jint aHandle, |
|
2039 |
jint aIndex, |
|
2040 |
jstring aTitle, |
|
2041 |
jint aImageHandle) |
|
2042 |
{ |
|
2043 |
TRAPD(error, MultiPageDialog_SetTitleAndImageL(aJniEnv, aHandle, aIndex, aTitle, aImageHandle)); |
|
2044 |
ThrowIfError(error, aJniEnv); |
|
2045 |
} |
|
2046 |
||
2047 |
static void MultiPageDialog_SetTitleL(JNIEnv* aJniEnv, jint aHandle, jint aIndex, jstring aTitle) |
|
2048 |
{ |
|
2049 |
MSwtMultiPageDialog* dialog = reinterpret_cast<MSwtMultiPageDialog*>(aHandle); |
|
2050 |
HBufC* title = ConvertStringLC(aJniEnv, aTitle); |
|
2051 |
CallMethodL(dialog, &MSwtMultiPageDialog::SetTitleL, aIndex, *title); |
|
2052 |
CleanupStack::PopAndDestroy(title); |
|
2053 |
} |
|
2054 |
||
2055 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_MultiPageDialog_1SetTitle( |
|
2056 |
JNIEnv* aJniEnv, |
|
2057 |
jclass, |
|
2058 |
jint aHandle, |
|
2059 |
jint aIndex, |
|
2060 |
jstring aTitle) |
|
2061 |
{ |
|
2062 |
TRAPD(error, MultiPageDialog_SetTitleL(aJniEnv, aHandle, aIndex, aTitle)); |
|
2063 |
ThrowIfError(error, aJniEnv); |
|
2064 |
} |
|
2065 |
||
2066 |
||
2067 |
/* |
|
2068 |
* Class QueryDialog |
|
2069 |
*/ |
|
2070 |
static void QueryDialog_OpenL(JNIEnv* aJniEnv, |
|
2071 |
TSwtPeer aPeer, |
|
2072 |
const jstring aTitle, |
|
2073 |
TInt aStyle, |
|
2074 |
TInt aQueryType, |
|
2075 |
const jstring aPromptText, |
|
2076 |
const jstring aDefaultValue, |
|
2077 |
TInt aMinimum, |
|
2078 |
TInt aMaximum) |
|
2079 |
{ |
|
2080 |
CSwtDisplay& display = CSwtDisplay::Current(); |
|
2081 |
||
2082 |
HBufC* title = (aTitle !=NULL) ? ConvertStringLC(aJniEnv, |
|
2083 |
aTitle) : HBufC::NewLC(0); |
|
2084 |
HBufC* promptText = (aPromptText !=NULL) ? ConvertStringLC(aJniEnv, |
|
2085 |
aPromptText) : HBufC::NewLC(0); |
|
2086 |
HBufC* defaultValue = (aDefaultValue!=NULL) ? ConvertStringLC(aJniEnv, |
|
2087 |
aDefaultValue) : HBufC::NewLC(0); |
|
2088 |
||
2089 |
||
2090 |
display.RequestRunDialogL(aPeer , CSwtDialogBroker::EQueryDialog, aStyle, *title, |
|
2091 |
*promptText, *defaultValue, aQueryType, aMinimum, aMaximum); |
|
2092 |
||
2093 |
CleanupStack::PopAndDestroy(3, title); // defaultValue, promptText, title |
|
2094 |
} |
|
2095 |
||
2096 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_QueryDialog_1Open( |
|
2097 |
JNIEnv* aJniEnv, |
|
2098 |
jclass, |
|
2099 |
jobject aPeer, |
|
2100 |
jstring aTitle, |
|
2101 |
jint aStyle, |
|
2102 |
jint aQueryType, |
|
2103 |
jstring aPromptText, |
|
2104 |
jstring aDefaultValue, |
|
2105 |
jint aMinimum, |
|
2106 |
jint aMaximum) |
|
2107 |
{ |
|
2108 |
TRAPD(error, QueryDialog_OpenL(aJniEnv, reinterpret_cast< TSwtPeer >(aPeer), aTitle, aStyle, aQueryType, aPromptText, |
|
2109 |
aDefaultValue, aMinimum, aMaximum)); |
|
2110 |
ThrowIfError(error, aJniEnv); |
|
2111 |
||
2112 |
} |
|
2113 |
||
2114 |
static jstring QueryDialog_ConvertDefaultValueL(JNIEnv* aJniEnv, const jstring aString, |
|
2115 |
TInt aQueryType) |
|
2116 |
{ |
|
2117 |
CSwtDisplay& display = CSwtDisplay::Current(); |
|
2118 |
const MSwtFactory* mobileFactory = &display.Factory(); |
|
2119 |
HBufC* string = (aString!=NULL) ? ConvertStringLC(aJniEnv, aString) : HBufC::NewLC(0); |
|
2120 |
||
2121 |
HBufC* result = NULL; |
|
2122 |
CallMethodL(result, mobileFactory, |
|
2123 |
&MSwtFactory::RunQueryDialogConvertDefaultValueL, *string, aQueryType); |
|
2124 |
||
2125 |
jstring javaResult = NULL; |
|
2126 |
if (result != NULL) |
|
2127 |
{ |
|
2128 |
javaResult = NewJavaString(aJniEnv,*result); |
|
2129 |
DeleteInUiHeap(result); |
|
2130 |
} |
|
2131 |
||
2132 |
CleanupStack::PopAndDestroy(string); |
|
2133 |
return javaResult; |
|
2134 |
} |
|
2135 |
||
2136 |
JNIEXPORT jstring JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_QueryDialog_1ConvertDefaultValue( |
|
2137 |
JNIEnv* aJniEnv, |
|
2138 |
jclass, |
|
2139 |
jstring aString, |
|
2140 |
jint aQueryType) |
|
2141 |
{ |
|
2142 |
jstring result = NULL; |
|
2143 |
TRAPD(error, (result = QueryDialog_ConvertDefaultValueL(aJniEnv, aString, aQueryType))); |
|
2144 |
ThrowIfError(error, aJniEnv); |
|
2145 |
return result; |
|
2146 |
} |
|
2147 |
||
2148 |
||
2149 |
/* |
|
2150 |
* Class Screen |
|
2151 |
*/ |
|
2152 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_Screen_1New( |
|
2153 |
JNIEnv* aJniEnv, jclass, jobject aPeer, jint aId) |
|
2154 |
{ |
|
2155 |
CSwtDisplay& display = CSwtDisplay::Current(); |
|
2156 |
const MSwtFactory* mobileFactory = &display.Factory(); |
|
2157 |
jweak peerRef = aJniEnv->NewWeakGlobalRef(aPeer); |
|
2158 |
if (peerRef == NULL) |
|
2159 |
{ |
|
2160 |
return 0; |
|
2161 |
} |
|
2162 |
||
2163 |
MSwtScreen* screen = NULL; |
|
2164 |
TRAPD(error, CallMethodL(screen, mobileFactory, |
|
2165 |
&MSwtFactory::NewScreenL, display, peerRef, aId)); |
|
2166 |
if (error) |
|
2167 |
{ |
|
2168 |
aJniEnv->DeleteWeakGlobalRef(peerRef); |
|
2169 |
Throw(error, aJniEnv); |
|
2170 |
} |
|
2171 |
||
2172 |
INCREASE_INSTANCE_COUNT(screen, Screen); |
|
2173 |
||
2174 |
return reinterpret_cast<jint>(screen); |
|
2175 |
} |
|
2176 |
||
2177 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_Screen_1Dispose( |
|
2178 |
JNIEnv* aJniEnv, |
|
2179 |
jclass, |
|
2180 |
jint aHandle) |
|
2181 |
{ |
|
2182 |
CSwtDisplay& display = CSwtDisplay::Current(); |
|
2183 |
MSwtScreen* screen = reinterpret_cast<MSwtScreen*>(aHandle); |
|
2184 |
TSwtPeer peerRef; |
|
2185 |
CallMethod(peerRef, screen, &MSwtScreen::Dispose); |
|
2186 |
||
2187 |
ReleasePeer(aJniEnv, peerRef); |
|
2188 |
||
2189 |
DECREASE_INSTANCE_COUNT(Screen); |
|
2190 |
} |
|
2191 |
||
2192 |
JNIEXPORT jobject JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_Screen_1GetBounds( |
|
2193 |
JNIEnv* aJniEnv, |
|
2194 |
jclass, |
|
2195 |
jint aHandle) |
|
2196 |
{ |
|
2197 |
MSwtScreen* screen = reinterpret_cast<MSwtScreen*>(aHandle); |
|
2198 |
TRect bounds(TRect::EUninitialized); |
|
2199 |
CallMethod(bounds, screen, &MSwtScreen::GetBounds); |
|
2200 |
return NewJavaRectangle(aJniEnv, bounds); |
|
2201 |
} |
|
2202 |
||
2203 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_Screen_1GetColorDepth( |
|
2204 |
JNIEnv*, |
|
2205 |
jclass, |
|
2206 |
jint aHandle) |
|
2207 |
{ |
|
2208 |
MSwtScreen* screen = reinterpret_cast<MSwtScreen*>(aHandle); |
|
2209 |
TInt colorDepth; |
|
2210 |
CallMethod(colorDepth, screen, &MSwtScreen::GetColorDepth); |
|
2211 |
return colorDepth; |
|
2212 |
} |
|
2213 |
||
2214 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_Screen_1GetLocation( |
|
2215 |
JNIEnv*, |
|
2216 |
jclass, |
|
2217 |
jint aHandle) |
|
2218 |
{ |
|
2219 |
MSwtScreen* screen = reinterpret_cast<MSwtScreen*>(aHandle); |
|
2220 |
||
2221 |
TInt location; |
|
2222 |
CallMethod(location, screen, &MSwtScreen::GetLocation); |
|
2223 |
||
2224 |
return location; |
|
2225 |
} |
|
2226 |
||
2227 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_Screen_1GetOrientation( |
|
2228 |
JNIEnv*, |
|
2229 |
jclass, |
|
2230 |
jint aHandle) |
|
2231 |
{ |
|
2232 |
MSwtScreen* screen = reinterpret_cast<MSwtScreen*>(aHandle); |
|
2233 |
TInt orientation; |
|
2234 |
CallMethod(orientation, screen, &MSwtScreen::GetOrientation); |
|
2235 |
return orientation; |
|
2236 |
} |
|
2237 |
||
2238 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_Screen_1SetOrientation( |
|
2239 |
JNIEnv* aJniEnv, |
|
2240 |
jclass, |
|
2241 |
jint aHandle, |
|
2242 |
jint aOrientation) |
|
2243 |
{ |
|
2244 |
MSwtScreen* screen = reinterpret_cast<MSwtScreen*>(aHandle); |
|
2245 |
TRAPD(error, CallMethodL(screen, &MSwtScreen::SetOrientationL, aOrientation)); |
|
2246 |
ThrowIfError(error, aJniEnv); |
|
2247 |
} |
|
2248 |
||
2249 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_Screen_1GetUsage( |
|
2250 |
JNIEnv*, |
|
2251 |
jclass, |
|
2252 |
jint aHandle) |
|
2253 |
{ |
|
2254 |
MSwtScreen* screen = reinterpret_cast<MSwtScreen*>(aHandle); |
|
2255 |
||
2256 |
TInt usage; |
|
2257 |
CallMethod(usage, screen, &MSwtScreen::GetUsage); |
|
2258 |
||
2259 |
return usage; |
|
2260 |
} |
|
2261 |
||
2262 |
JNIEXPORT jboolean JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_Screen_1IsActive( |
|
2263 |
JNIEnv*, |
|
2264 |
jclass, |
|
2265 |
jint aHandle) |
|
2266 |
{ |
|
2267 |
MSwtScreen* screen = reinterpret_cast<MSwtScreen*>(aHandle); |
|
2268 |
||
2269 |
TBool isActive(EFalse); |
|
2270 |
CallMethod(isActive, screen, &MSwtScreen::IsActive); |
|
2271 |
||
2272 |
return ConvertBoolean(isActive); |
|
2273 |
} |
|
2274 |
||
2275 |
JNIEXPORT jboolean JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_Screen_1IsTouchScreen( |
|
2276 |
JNIEnv*, |
|
2277 |
jclass, |
|
2278 |
jint aHandle) |
|
2279 |
{ |
|
2280 |
MSwtScreen* screen = reinterpret_cast<MSwtScreen*>(aHandle); |
|
2281 |
TBool isTouchScreen; |
|
2282 |
CallMethod(isTouchScreen, screen, &MSwtScreen::IsTouchScreen); |
|
2283 |
return ConvertBoolean(isTouchScreen); |
|
2284 |
} |
|
2285 |
||
2286 |
||
2287 |
/* |
|
2288 |
* Class SortedList |
|
2289 |
*/ |
|
2290 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_SortedList_1New( |
|
2291 |
JNIEnv* aJniEnv, |
|
2292 |
jclass, |
|
2293 |
jobject aPeer, |
|
2294 |
jint aParent, |
|
2295 |
jint aStyle) |
|
2296 |
{ |
|
2297 |
jint handle = NewMobileWidget(aJniEnv, &MSwtFactory::NewSortedListL, aPeer, |
|
2298 |
aParent, aStyle); |
|
2299 |
INCREASE_INSTANCE_COUNT(handle, SortedList); |
|
2300 |
return handle; |
|
2301 |
} |
|
2302 |
||
2303 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_SortedList_1ScrollableHandle( |
|
2304 |
JNIEnv*, |
|
2305 |
jclass, |
|
2306 |
jint aHandle) |
|
2307 |
{ |
|
2308 |
MSwtSortedList* sortedList = reinterpret_cast<MSwtSortedList*>(aHandle); |
|
2309 |
MSwtScrollable* result; |
|
2310 |
CallMethod(result, sortedList, &MSwtSortedList::Scrollable); |
|
2311 |
return reinterpret_cast<jint>(result); |
|
2312 |
} |
|
2313 |
||
2314 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_SortedList_1Add( |
|
2315 |
JNIEnv* aJniEnv, |
|
2316 |
jclass, |
|
2317 |
jint aHandle, |
|
2318 |
jstring aString) |
|
2319 |
{ |
|
2320 |
/*MSwtSortedList* sortedList = reinterpret_cast<MSwtSortedList*>( aHandle ); |
|
2321 |
CallTextMethodThrow( aJniEnv, sortedList, &MSwtSortedList::AppendL, aString ); |
|
2322 |
*/ |
|
2323 |
CallTextMethodThrow(aJniEnv, aHandle, &MSwtSortedList::AppendL, aString); |
|
2324 |
} |
|
2325 |
||
2326 |
JNIEXPORT jstring JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_SortedList_1GetFocusedItem( |
|
2327 |
JNIEnv* aJniEnv, |
|
2328 |
jclass, |
|
2329 |
jint aHandle) |
|
2330 |
{ |
|
2331 |
const MSwtSortedList* sortedList = reinterpret_cast<MSwtSortedList*>(aHandle); |
|
2332 |
TPtrC item; |
|
2333 |
CallMethod(sortedList, &MSwtSortedList::GetFocusedItem, item); |
|
2334 |
return (item.Length()==0) ? NULL : NewJavaString(aJniEnv, item); |
|
2335 |
} |
|
2336 |
||
2337 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_SortedList_1GetItemHeight( |
|
2338 |
JNIEnv*, |
|
2339 |
jclass, |
|
2340 |
jint aHandle) |
|
2341 |
{ |
|
2342 |
const MSwtSortedList* sortedList = reinterpret_cast<MSwtSortedList*>(aHandle); |
|
2343 |
TInt height; |
|
2344 |
CallMethod(height, sortedList, &MSwtSortedList::GetItemHeight); |
|
2345 |
return height; |
|
2346 |
} |
|
2347 |
||
2348 |
JNIEXPORT jobjectArray JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_SortedList_1GetSelection( |
|
2349 |
JNIEnv* aJniEnv, |
|
2350 |
jclass, |
|
2351 |
jint aHandle) |
|
2352 |
{ |
|
2353 |
const MSwtSortedList* sortedList = reinterpret_cast<MSwtSortedList*>(aHandle); |
|
2354 |
CPtrCArray* selectedItemArray = NULL; |
|
2355 |
TRAPD(error, CallMethodL(selectedItemArray, sortedList, &MSwtSortedList::GetSelectionL)); |
|
2356 |
if (error!=KErrNone) |
|
2357 |
{ |
|
2358 |
Throw(error, aJniEnv); |
|
2359 |
DeleteInUiHeap(selectedItemArray); |
|
2360 |
return NULL; |
|
2361 |
} |
|
2362 |
||
2363 |
if (selectedItemArray==NULL) |
|
2364 |
{ |
|
2365 |
return NULL; |
|
2366 |
} |
|
2367 |
||
2368 |
jobjectArray javaItemArray = NULL; |
|
2369 |
jclass stringClass = aJniEnv->FindClass("java/lang/String"); |
|
2370 |
if (stringClass != NULL) |
|
2371 |
{ |
|
2372 |
const TInt count = (selectedItemArray!=NULL) ? selectedItemArray->Count() : 0; |
|
2373 |
javaItemArray = aJniEnv->NewObjectArray(count, stringClass, NULL); |
|
2374 |
if (javaItemArray != NULL) |
|
2375 |
{ |
|
2376 |
jstring javaString; |
|
2377 |
for (TInt i=0; i<count; ++i) |
|
2378 |
{ |
|
2379 |
javaString = NewJavaString(aJniEnv, selectedItemArray->At(i)); |
|
2380 |
aJniEnv->SetObjectArrayElement(javaItemArray, i, javaString); //lint !e613 |
|
2381 |
aJniEnv->DeleteLocalRef(javaString); |
|
2382 |
} |
|
2383 |
} |
|
2384 |
aJniEnv->DeleteLocalRef(stringClass); |
|
2385 |
} |
|
2386 |
||
2387 |
DeleteInUiHeap(selectedItemArray); |
|
2388 |
return javaItemArray; |
|
2389 |
} |
|
2390 |
||
2391 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_SortedList_1GetSelectionCount( |
|
2392 |
JNIEnv*, |
|
2393 |
jclass, |
|
2394 |
jint aHandle) |
|
2395 |
{ |
|
2396 |
const MSwtSortedList* sortedList = reinterpret_cast<MSwtSortedList*>(aHandle); |
|
2397 |
TInt count; |
|
2398 |
CallMethod(count, sortedList, &MSwtSortedList::GetSelectionCount); |
|
2399 |
return count; |
|
2400 |
} |
|
2401 |
||
2402 |
static TBool SortedList_RemoveL(JNIEnv* aJniEnv, jint aHandle, jstring aString) |
|
2403 |
{ |
|
2404 |
MSwtSortedList* sortedList = reinterpret_cast<MSwtSortedList*>(aHandle); |
|
2405 |
HBufC* convertedText = ConvertStringLC(aJniEnv, aString); |
|
2406 |
TBool removeError(ETrue); |
|
2407 |
CallMethodL(removeError, sortedList, &MSwtSortedList::RemoveL, *convertedText); |
|
2408 |
CleanupStack::PopAndDestroy(convertedText); |
|
2409 |
return removeError; |
|
2410 |
} |
|
2411 |
||
2412 |
JNIEXPORT jboolean JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_SortedList_1Remove( |
|
2413 |
JNIEnv* aJniEnv, |
|
2414 |
jclass, |
|
2415 |
jint aHandle, |
|
2416 |
jstring aString) |
|
2417 |
{ |
|
2418 |
TBool removeError(ETrue); |
|
2419 |
TRAPD(error, (removeError=SortedList_RemoveL(aJniEnv, aHandle, aString))); |
|
2420 |
ThrowIfError(error, aJniEnv); |
|
2421 |
return ConvertBoolean(removeError); |
|
2422 |
} |
|
2423 |
||
2424 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_SortedList_1RemoveAll( |
|
2425 |
JNIEnv* aJniEnv, |
|
2426 |
jclass, |
|
2427 |
jint aHandle) |
|
2428 |
{ |
|
2429 |
MSwtSortedList* sortedList = reinterpret_cast<MSwtSortedList*>(aHandle); |
|
2430 |
TRAPD(error, CallMethodL(sortedList, &MSwtSortedList::RemoveAllL)); |
|
2431 |
ThrowIfError(error, aJniEnv); |
|
2432 |
} |
|
2433 |
||
2434 |
static TBool SortedList_SelectL(JNIEnv* aJniEnv, jint aHandle, jstring aString) |
|
2435 |
{ |
|
2436 |
MSwtSortedList* sortedList = reinterpret_cast<MSwtSortedList*>(aHandle); |
|
2437 |
HBufC* convertedText = NULL; |
|
2438 |
if (aString != NULL) |
|
2439 |
{ |
|
2440 |
convertedText = ConvertStringLC(aJniEnv, aString); |
|
2441 |
} |
|
2442 |
||
2443 |
TBool selectError(ETrue); |
|
2444 |
CallMethodL(selectError, sortedList, &MSwtSortedList::SelectItemL, convertedText); |
|
2445 |
||
2446 |
if (convertedText != NULL) |
|
2447 |
{ |
|
2448 |
CleanupStack::PopAndDestroy(convertedText); |
|
2449 |
} |
|
2450 |
||
2451 |
return selectError; |
|
2452 |
} |
|
2453 |
||
2454 |
JNIEXPORT jboolean JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_SortedList_1Select( |
|
2455 |
JNIEnv* aJniEnv, |
|
2456 |
jclass, |
|
2457 |
jint aHandle, |
|
2458 |
jstring aString) |
|
2459 |
{ |
|
2460 |
TBool selectError(ETrue); |
|
2461 |
TRAPD(error, (selectError=SortedList_SelectL(aJniEnv, aHandle, aString))); |
|
2462 |
ThrowIfError(error, aJniEnv); |
|
2463 |
return ConvertBoolean(selectError); |
|
2464 |
} |
|
2465 |
||
2466 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_SortedList_1SetItems( |
|
2467 |
JNIEnv* aJniEnv, |
|
2468 |
jclass, |
|
2469 |
jint aHandle, |
|
2470 |
jobjectArray aStringArray) |
|
2471 |
{ |
|
2472 |
CDesCArray* resultArray = NULL; |
|
2473 |
TRAPD(error, (resultArray=ConvertStringArrayL(aJniEnv, aStringArray))); |
|
2474 |
if (error != KErrNone || resultArray == NULL) |
|
2475 |
{ |
|
2476 |
delete resultArray; |
|
2477 |
ThrowIfError(error, aJniEnv); |
|
2478 |
return; |
|
2479 |
} |
|
2480 |
||
2481 |
MSwtSortedList* sortedList = reinterpret_cast<MSwtSortedList*>(aHandle); |
|
2482 |
TRAP(error, CallMethodL(sortedList, &MSwtSortedList::SetItemsL, resultArray)); |
|
2483 |
ThrowIfError(error, aJniEnv); |
|
2484 |
delete resultArray; |
|
2485 |
} |
|
2486 |
||
2487 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_SortedList_1SetModeStyle( |
|
2488 |
JNIEnv* aJniEnv, |
|
2489 |
jclass, |
|
2490 |
jint aHandle, |
|
2491 |
jint aModeStyle) |
|
2492 |
{ |
|
2493 |
MSwtSortedList* sortedList = reinterpret_cast<MSwtSortedList*>(aHandle); |
|
2494 |
TRAPD(error, CallMethodL(sortedList, &MSwtSortedList::SetModeStyleL, aModeStyle)); |
|
2495 |
ThrowIfError(error, aJniEnv); |
|
2496 |
} |
|
2497 |
||
2498 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_SortedList_1SetSelection( |
|
2499 |
JNIEnv* aJniEnv, |
|
2500 |
jclass, |
|
2501 |
jint aHandle, |
|
2502 |
jobjectArray aStringArray) |
|
2503 |
{ |
|
2504 |
CDesCArray* resultArray = NULL; |
|
2505 |
TRAPD(error, (resultArray=ConvertStringArrayL(aJniEnv, aStringArray))); |
|
2506 |
if (error != KErrNone || resultArray == NULL) |
|
2507 |
{ |
|
2508 |
delete resultArray; |
|
2509 |
ThrowIfError(error, aJniEnv); |
|
2510 |
return; |
|
2511 |
} |
|
2512 |
||
2513 |
MSwtSortedList* sortedList = reinterpret_cast<MSwtSortedList*>(aHandle); |
|
2514 |
TRAP(error, CallMethodL(sortedList, &MSwtSortedList::SetSelectionL, resultArray)); |
|
2515 |
ThrowIfError(error, aJniEnv); |
|
2516 |
delete resultArray; |
|
2517 |
} |
|
2518 |
||
2519 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_SortedList_1ShowSelection( |
|
2520 |
JNIEnv*, |
|
2521 |
jclass, |
|
2522 |
jint aHandle) |
|
2523 |
{ |
|
2524 |
MSwtSortedList* sortedList = reinterpret_cast<MSwtSortedList*>(aHandle); |
|
2525 |
CallMethod(sortedList, &MSwtSortedList::ShowSelection); |
|
2526 |
} |
|
2527 |
||
2528 |
||
2529 |
/** |
|
2530 |
* Class TaskTip |
|
2531 |
*/ |
|
2532 |
JNIEXPORT jobject JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_TaskTip_1DefaultBounds( |
|
2533 |
JNIEnv* aJniEnv, jclass) |
|
2534 |
{ |
|
2535 |
MSwtDisplay& display = CSwtDisplay::Current(); |
|
2536 |
TRect res(TRect::EUninitialized); |
|
2537 |
CallMethod(res, &display.UiUtils(), &MSwtUiUtils::TaskTipRect); |
|
2538 |
return NewJavaRectangle(aJniEnv, res); |
|
2539 |
} |
|
2540 |
||
2541 |
||
2542 |
/* |
|
2543 |
* Class TextExtension |
|
2544 |
*/ |
|
2545 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_TextExtension_1New( |
|
2546 |
JNIEnv* aJniEnv, |
|
2547 |
jclass, |
|
2548 |
jobject aPeer, |
|
2549 |
jint aParent, |
|
2550 |
jint aStyle) |
|
2551 |
{ |
|
2552 |
jint handle = NewMobileWidget(aJniEnv, &MSwtFactory::NewTextExtensionL, |
|
2553 |
aPeer, aParent, aStyle); |
|
2554 |
INCREASE_INSTANCE_COUNT(handle, TextExtension); |
|
2555 |
return handle; |
|
2556 |
} |
|
2557 |
||
2558 |
JNIEXPORT jint JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_TextExtension_1TextHandle( |
|
2559 |
JNIEnv*, |
|
2560 |
jclass, |
|
2561 |
jint aHandle) |
|
2562 |
{ |
|
2563 |
MSwtTextExtension* textExtension = reinterpret_cast<MSwtTextExtension*>(aHandle); |
|
2564 |
MSwtText* result; |
|
2565 |
CallMethod(result, textExtension, &MSwtTextExtension::Text); |
|
2566 |
return reinterpret_cast<jint>(result); |
|
2567 |
} |
|
2568 |
||
2569 |
static void TextExtension_SetTypeStyleL(TInt aHandle, TInt aStyle) |
|
2570 |
{ |
|
2571 |
MSwtTextExtension* textExtension = reinterpret_cast<MSwtTextExtension*>(aHandle); |
|
2572 |
CallMethodL(textExtension, &MSwtTextExtension::SetTypeStyleL, aStyle); |
|
2573 |
} |
|
2574 |
||
2575 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_TextExtension_1SetTypeStyle( |
|
2576 |
JNIEnv* aJniEnv, |
|
2577 |
jclass, |
|
2578 |
jint aHandle, |
|
2579 |
jint aStyle) |
|
2580 |
{ |
|
2581 |
TRAPD(error, TextExtension_SetTypeStyleL(aHandle, aStyle)); |
|
2582 |
ThrowIfError(error, aJniEnv); |
|
2583 |
} |
|
2584 |
||
2585 |
static void TextExtension_SetInitialInputModeL( |
|
2586 |
JNIEnv* aJniEnv, |
|
2587 |
TInt aHandle, |
|
2588 |
TInt aCasingModifier, |
|
2589 |
const jstring aMode) |
|
2590 |
{ |
|
2591 |
HBufC* mode = ConvertStringLC(aJniEnv, aMode); |
|
2592 |
||
2593 |
MSwtTextExtension* textExtension = reinterpret_cast<MSwtTextExtension*>(aHandle); |
|
2594 |
MSwtTextExtension::TCasingModifier modifier = static_cast<MSwtTextExtension::TCasingModifier>( |
|
2595 |
aCasingModifier); |
|
2596 |
CallMethodL(textExtension, &MSwtTextExtension::SetInitialInputModeL, modifier, mode); |
|
2597 |
||
2598 |
if (mode != NULL) |
|
2599 |
CleanupStack::PopAndDestroy(mode); |
|
2600 |
} |
|
2601 |
||
2602 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_TextExtension_1SetInitialInputMode( |
|
2603 |
JNIEnv* aJniEnv, |
|
2604 |
jclass, |
|
2605 |
jint aHandle, |
|
2606 |
jint aCasingModifier, |
|
2607 |
jstring aMode) |
|
2608 |
{ |
|
2609 |
TRAPD(error, TextExtension_SetInitialInputModeL(aJniEnv, aHandle, aCasingModifier, aMode)); |
|
2610 |
ThrowIfError(error, aJniEnv); |
|
2611 |
} |
|
2612 |
||
2613 |
||
2614 |
/* |
|
2615 |
* Class TimedMessageBox |
|
2616 |
*/ |
|
2617 |
static void TimedMessageBox_OpenL(JNIEnv* aJniEnv, |
|
2618 |
TSwtPeer aPeer, |
|
2619 |
const jstring aTitle, |
|
2620 |
const jstring aMessage, |
|
2621 |
TInt aStyle, |
|
2622 |
TInt aImageHandle) |
|
2623 |
{ |
|
2624 |
CSwtDisplay& display = CSwtDisplay::Current(); |
|
2625 |
||
2626 |
HBufC* message = (aMessage!=NULL) ? ConvertStringLC(aJniEnv, aMessage) : HBufC::NewLC(0); |
|
2627 |
HBufC* title = (aTitle != NULL) ? ConvertStringLC(aJniEnv, aTitle) : HBufC::NewLC(0); |
|
2628 |
||
2629 |
display.RequestRunDialogL(aPeer, CSwtDialogBroker::ETimedMessageBox, aStyle, *title, *message, KNullDesC(), aImageHandle); |
|
2630 |
||
2631 |
CleanupStack::PopAndDestroy(2, message); // title, message |
|
2632 |
} |
|
2633 |
||
2634 |
JNIEXPORT void JNICALL Java_org_eclipse_ercp_swt_mobile_internal_OS_TimedMessageBox_1Open( |
|
2635 |
JNIEnv* aJniEnv, |
|
2636 |
jclass, |
|
2637 |
jobject aPeer, |
|
2638 |
jstring aTitle, |
|
2639 |
jstring aMessage, |
|
2640 |
jint aStyle, |
|
2641 |
jint aImageHandle) |
|
2642 |
{ |
|
2643 |
TRAPD(error, TimedMessageBox_OpenL(aJniEnv, reinterpret_cast< TSwtPeer >(aPeer), aTitle, aMessage, aStyle, aImageHandle)); |
|
2644 |
ThrowIfError(error, aJniEnv); |
|
2645 |
} |
|
2646 |
||
2647 |
} // extern "C" |