|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CMIDToolkit.h" |
|
20 #include "MIDUtils.h" |
|
21 #include "javax_microedition_lcdui_Gauge.h" |
|
22 |
|
23 LOCAL_C void CreateL(CMIDToolkit* aToolkit,TInt* aHandle,jobject aGauge,const TDesC* aLabel,TBool aInteractive,TInt aMaxValue,TInt aInitialValue) |
|
24 { |
|
25 MMIDGauge* gauge = aToolkit->ComponentFactory()->CreateGaugeL(*aLabel,aInteractive,aMaxValue,aInitialValue); |
|
26 CleanupDisposePushL(gauge); |
|
27 *aHandle = aToolkit->RegisterComponentL(gauge, aGauge); |
|
28 CleanupPopComponent(gauge); |
|
29 } |
|
30 |
|
31 JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_Gauge__1create |
|
32 (JNIEnv* aJni,jobject,jint aToolkit,jobject aGauge,jstring aLabel,jboolean aInteractive, |
|
33 jint aMaxValue,jint aIntialValue) |
|
34 { |
|
35 jobject gauge = aJni->NewWeakGlobalRef(aGauge); |
|
36 if (gauge == 0) |
|
37 return KErrNoMemory; |
|
38 // |
|
39 CMIDToolkit* toolkit =JavaUnhand<CMIDToolkit>(aToolkit); |
|
40 RJString label(*aJni,aLabel); |
|
41 TInt h=0; |
|
42 TInt err = toolkit->ExecuteTrap(&CreateL,toolkit,&h,gauge,(const TDesC*)&label,(TBool)aInteractive,(TInt)aMaxValue,(TInt)aIntialValue); |
|
43 if (err!=KErrNone) |
|
44 { |
|
45 aJni->DeleteWeakGlobalRef((jweak)gauge); |
|
46 return err; |
|
47 } |
|
48 return h; |
|
49 } |
|
50 |
|
51 LOCAL_C jint GetValue(MMIDGauge* aGauge) |
|
52 { |
|
53 return aGauge->GetValue(); |
|
54 } |
|
55 JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_Gauge__1getValue(JNIEnv*,jobject,jint aToolkit,jint aItem) |
|
56 { |
|
57 MMIDGauge* gauge = MIDUnhandObject<MMIDGauge>(aItem); |
|
58 return JavaUnhand<CMIDToolkit>(aToolkit)->Execute(GetValue,gauge); |
|
59 } |
|
60 |
|
61 LOCAL_C void SetValueL(MMIDGauge* aGauge,TInt aValue) |
|
62 { |
|
63 aGauge->SetValueL(aValue); |
|
64 } |
|
65 JNIEXPORT int JNICALL Java_javax_microedition_lcdui_Gauge__1setValue |
|
66 (JNIEnv*,jobject,jint aToolkit,jint aItem,jint aValue) |
|
67 { |
|
68 MMIDGauge* gauge = MIDUnhandObject<MMIDGauge>(aItem); |
|
69 return JavaUnhand<CMIDToolkit>(aToolkit)->ExecuteTrap(&SetValueL,gauge,(TInt)aValue); |
|
70 } |
|
71 |
|
72 LOCAL_C void InvokeSetMaxValueL(jint aHandle, jint aMaxValue, jint aValue) |
|
73 { |
|
74 MMIDGauge* gauge = MIDUnhandObject<MMIDGauge>(aHandle); |
|
75 |
|
76 gauge->SetMaxValueL(aMaxValue); |
|
77 gauge->SetValueL(aValue); |
|
78 } |
|
79 |
|
80 JNIEXPORT int JNICALL Java_javax_microedition_lcdui_Gauge__1setMaxValue |
|
81 (JNIEnv*,jobject,jint aToolkit,jint aGauge,jint aMaxValue, jint aValue) |
|
82 { |
|
83 return JavaUnhand<CMIDToolkit>(aToolkit)->ExecuteTrap(&InvokeSetMaxValueL,aGauge, aMaxValue, aValue); |
|
84 } |