diff -r f5050f1da672 -r 04becd199f91 javauis/lcdui_akn/javalcdui/src/DateField.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/lcdui_akn/javalcdui/src/DateField.cpp Tue Apr 27 16:30:29 2010 +0300 @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2002 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 "javax_microedition_lcdui_DateField.h" + +LOCAL_C void CreateL(CMIDToolkit* aToolkit,TInt* aHandle,jobject aDateField,const TDesC* aLabel,TInt aFieldType) +{ + MMIDDateField* dateField = aToolkit->ComponentFactory()->CreateDateFieldL(*aLabel,(MMIDDateField::TFieldType)aFieldType); + CleanupDisposePushL(dateField); + *aHandle = aToolkit->RegisterComponentL(dateField, aDateField); + CleanupPopComponent(dateField); +} +JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_DateField__1create +(JNIEnv* aJni,jobject,jint aToolkit,jobject aDateField,jstring aLabel,jint aFieldType) +{ + jobject dateField = aJni->NewWeakGlobalRef(aDateField); + if (dateField == 0) + return KErrNoMemory; + // + CMIDToolkit* toolkit = JavaUnhand(aToolkit); + RJString label(*aJni,aLabel); + TInt h = 0; + TInt err = toolkit->ExecuteTrap(&CreateL,toolkit,&h,dateField,(const TDesC*)&label,(TInt)aFieldType); + if (err!=KErrNone) + { + aJni->DeleteWeakGlobalRef((jweak)dateField); + return err; + } + return h; +} + +LOCAL_C void Date(MMIDDateField* aItem,TTime* aTime) +{ + *aTime = aItem->Date(); +} +JNIEXPORT jlong JNICALL Java_javax_microedition_lcdui_DateField__1getDate +(JNIEnv *,jobject,jint aToolkit,jint aItem) +{ + MMIDDateField* item = MIDUnhandObject(aItem); + CMIDToolkit* toolkit = JavaUnhand(aToolkit); + TTime time; + toolkit->ExecuteV(&Date,item,&time); + return JavaEpocTime::CreateJavaTime(time); +} + +LOCAL_C void SetDate(MMIDDateField* aItem,TTime* aTime) +{ + aItem->SetDate(*aTime); +} +JNIEXPORT void JNICALL Java_javax_microedition_lcdui_DateField__1setDate +(JNIEnv *,jobject,jint aToolkit,jint aItem,jlong aTime) +{ + MMIDDateField* item = MIDUnhandObject(aItem); + CMIDToolkit* toolkit = JavaUnhand(aToolkit); + TTime epocTime = JavaEpocTime::CreateEpocTTime(aTime); + toolkit->ExecuteV(&SetDate,item,&epocTime); +} + +void InvokeSetInputModeL(jint aDateField, jint aInputMode) +{ + MMIDDateField* dateField = MIDUnhandObject(aDateField); + dateField->SetInputModeL((MMIDDateField::TInputMode)aInputMode); +} + +JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_DateField__1setInputMode +(JNIEnv*,jobject,jint aToolkit, jint aItem, jint aInputMode) +{ + // + CMIDToolkit* toolkit = JavaUnhand(aToolkit); + return toolkit->ExecuteTrap(InvokeSetInputModeL, aItem, aInputMode); +} + +LOCAL_C void SetUninitialized(MMIDDateField* aItem) +{ + aItem->SetUninitialized(); +} +JNIEXPORT void JNICALL Java_javax_microedition_lcdui_DateField__1setUninitialized +(JNIEnv*,jobject,jint aToolkit,jint aDateField) +{ + MMIDDateField* item = MIDUnhandObject(aDateField); + CMIDToolkit* toolkit = JavaUnhand(aToolkit); + toolkit->ExecuteV(&SetUninitialized,item); +}