diff -r ae942d28ec0e -r 2455ef1f5bbc javauis/lcdui_akn/javalcdui/src/ChoiceGroup.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/lcdui_akn/javalcdui/src/ChoiceGroup.cpp Wed Sep 01 12:33:18 2010 +0100 @@ -0,0 +1,174 @@ +/* +* Copyright (c) 2001-2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "CMIDToolkit.h" +#include "MIDUtils.h" +#include "lcdgr.h" + +#include "javax_microedition_lcdui_ChoiceGroup.h" + +LOCAL_C void CreateChoiceGroupL +( + CMIDToolkit* aToolkit, + jweak aRef, + const TDesC* aLabel, + TInt aType, + jint* aHandle +) +{ + ASSERT(aLabel); + MMIDComponentFactory& factory = *aToolkit->ComponentFactory(); + RArray dummyTextArray; + RArray dummyImageArray; + MMIDChoiceGroup* choice = factory.CreateChoiceGroupL(*aLabel, aType, dummyTextArray, dummyImageArray); + CleanupDisposePushL(choice); + *aHandle = aToolkit->RegisterComponentL(choice, aRef); + CleanupPopComponent(choice); +} + +JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_ChoiceGroup__1create +( + JNIEnv* aJni, + jobject aChoiceGroup, + jint aToolkit, + jstring aLabel, + jint aType +) +{ + jweak ref = aJni->NewWeakGlobalRef(aChoiceGroup); + if (ref == 0) + { + return KErrNoMemory; + } + + RJString label(*aJni, aLabel); + + CMIDToolkit* toolkit = JavaUnhand(aToolkit); + + jint handle = 0; + jint error = toolkit->ExecuteTrap( + &CreateChoiceGroupL, + toolkit, + ref, + (const TDesC*)&label, + (TInt)aType, + &handle + ); + + if (error != KErrNone) + { + ASSERT(ref); + aJni->DeleteWeakGlobalRef(ref); + return error; + } + + return handle; +} + +LOCAL_C void InsertElementL(MMIDChoiceGroup* aChoice,TInt aIndex,const TDesC* aText,MMIDImage* aImage) +{ + aChoice->InsertElementL(aIndex,*aText, aImage); +} +JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_ChoiceGroup__1insert +(JNIEnv* aEnv,jobject,jint aItem,jint aToolkit,jint aIndex,jstring aStringItem,jint aImage) +{ + RJString string(*aEnv,aStringItem); + MMIDImage* image = MIDUnhand(aImage); + MMIDChoiceGroup* choice = MIDUnhandObject(aItem); + return JavaUnhand(aToolkit)->ExecuteTrap(&InsertElementL,choice,(TInt)aIndex,(const TDesC*)&string,image); +} + +LOCAL_C void DeleteElementL(MMIDChoiceGroup* aChoice,TInt aIndex) +{ + aChoice->DeleteElementL(aIndex); +} +JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_ChoiceGroup__1delete +(JNIEnv *, jobject, jint aItem, jint aToolkit, jint aIndex) +{ + MMIDChoiceGroup* choice = MIDUnhandObject(aItem); + return JavaUnhand(aToolkit)->ExecuteTrap(&DeleteElementL,choice,(TInt)aIndex); +} + +LOCAL_C void DeleteAllL(MMIDChoiceGroup* aChoice) +{ + aChoice->DeleteAllL(); +} +JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_ChoiceGroup__1deleteAll +(JNIEnv *, jobject, jint aItem, jint aToolkit) +{ + MMIDChoiceGroup* choice = MIDUnhandObject(aItem); + return JavaUnhand(aToolkit)->ExecuteTrap(&DeleteAllL,choice); +} + +LOCAL_C void SetElementL(MMIDChoiceGroup* aChoice,TInt aIndex,const TDesC* aText,MMIDImage* aImage) +{ + aChoice->SetElementL(aIndex,*aText, aImage); +} +JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_ChoiceGroup__1set +(JNIEnv* aEnv,jobject,jint aItem,jint aToolkit,jint aIndex,jstring aStringItem,jint aImage) +{ + RJString string(*aEnv,aStringItem); + MMIDImage* image = MIDUnhand(aImage); + MMIDChoiceGroup* choice = MIDUnhandObject(aItem); + return JavaUnhand(aToolkit)->ExecuteTrap(&SetElementL,choice,(TInt)aIndex,(const TDesC*)&string,image); +} + +LOCAL_C TBool IsSelected(MMIDChoiceGroup* aChoice,TInt aIndex) +{ + return aChoice->IsSelected(aIndex); +} +JNIEXPORT jboolean JNICALL Java_javax_microedition_lcdui_ChoiceGroup__1isSelected +(JNIEnv*,jobject,jint aItem,jint aToolkit,jint aIndex) +{ + MMIDChoiceGroup* choice = MIDUnhandObject(aItem); + return (jboolean)JavaUnhand(aToolkit)->Execute(&IsSelected,choice,(TInt)aIndex); +} + +LOCAL_C void SelectElementL(MMIDChoiceGroup* aChoice,TInt aIndex,TBool aSelected) +{ + aChoice->SelectElementL(aIndex,aSelected); +} +JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_ChoiceGroup__1select +(JNIEnv*,jobject,jint aItem,jint aToolkit,jint aIndex,jboolean aSelected) +{ + MMIDChoiceGroup* choice = MIDUnhandObject(aItem); + return JavaUnhand(aToolkit)->ExecuteTrap(&SelectElementL,choice,(TInt)aIndex,(TBool)aSelected); +} + +LOCAL_C void SetFontL(MMIDChoiceGroup* aChoice,TInt aIndex, MMIDFont* aFont) +{ + aChoice->SetFontL(aIndex,aFont); +} +JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_ChoiceGroup__1setFont +(JNIEnv*,jobject,jint aItem,jint aToolkit,jint aIndex,jint aFont) +{ + MMIDChoiceGroup* choice = MIDUnhandObject(aItem); + MMIDFont* font = MIDUnhandObject(aFont); + CMIDToolkit* toolkit = JavaUnhand(aToolkit); + return toolkit->ExecuteTrap(&SetFontL,choice,(TInt)aIndex,font); +} + +LOCAL_C void SetFitPolicyL(MMIDChoiceGroup* aChoice,TInt aFitPolicy) +{ + aChoice->SetFitPolicyL(aFitPolicy); +} +JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_ChoiceGroup__1setFitPolicy +(JNIEnv*,jobject,jint aItem,jint aToolkit,jint aFitPolicy) +{ + MMIDChoiceGroup* choice = MIDUnhandObject(aItem); + return JavaUnhand(aToolkit)->ExecuteTrap(&SetFitPolicyL,choice,(TInt)aFitPolicy); +}