diff -r 000000000000 -r eb1f2e154e89 textinput/peninputcommonlayout/src/peninputuistatebase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/textinput/peninputcommonlayout/src/peninputuistatebase.cpp Tue Feb 02 01:02:04 2010 +0200 @@ -0,0 +1,149 @@ +/* +* Copyright (c) 2002-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: Implementation of the ui state base +* +*/ + + +// User includes +#include +#include // Define EPluginInputModeHwr +#include +#include "peninputuistatebase.h" +#include "peninputlayoutcontext.h" +#include "peninputcmd.h" +#include "peninputcommonlayoutglobalenum.h" + +const TInt KMaxKeyLength = 10; + +// ======== MEMBER FUNCTIONS ======== + +// -------------------------------------------------------------------------- +// CPeninputUiStateBase::CPeninputUiStateBase +// (other items were commented in a header) +// -------------------------------------------------------------------------- +// +EXPORT_C CPeninputUiStateBase::CPeninputUiStateBase( + MPeninputUiStateMgr* aUiStateMgr, MPeninputLayoutContext* aContext ) + : iUiStateMgr( aUiStateMgr ), iContext( aContext ) + { + } + +// -------------------------------------------------------------------------- +// CPeninputUiStateBase::NewL +// (other items were commented in a header) +// -------------------------------------------------------------------------- +// +EXPORT_C CPeninputUiStateBase* CPeninputUiStateBase::NewL( + MPeninputUiStateMgr* aUiStateMgr, MPeninputLayoutContext* aContext ) + { + CPeninputUiStateBase* self = new ( ELeave ) + CPeninputUiStateBase( aUiStateMgr, aContext ); + CleanupStack::PushL( self ); + self->Construct(); + CleanupStack::Pop( self ); + + return self; + } + +// -------------------------------------------------------------------------- +// CPeninputUiStateBase::ConstructL +// (other items were commented in a header) +// -------------------------------------------------------------------------- +// +EXPORT_C void CPeninputUiStateBase::Construct() + { + } + +// -------------------------------------------------------------------------- +// CPeninputUiStateBase::~CPeninputUiStateBase +// (other items were commented in a header) +// -------------------------------------------------------------------------- +// +EXPORT_C CPeninputUiStateBase::~CPeninputUiStateBase() + { + } + +// -------------------------------------------------------------------------- +// CPeninputUiStateBase::HandleKeyEventL +// (other items were commented in a header) +// -------------------------------------------------------------------------- +// +EXPORT_C TBool CPeninputUiStateBase::HandleKeyEventL( + const TRawEvent& /*aData*/ ) + { + return EFalse; + } + +// -------------------------------------------------------------------------- +// CPeninputUiStateBase::HandleControlEvent +// (other items were commented in a header). +// -------------------------------------------------------------------------- +// +EXPORT_C TBool CPeninputUiStateBase::HandleControlEvent( TInt /*aEventType*/, + const TDesC& /*aEventData*/ ) + { + return EFalse; + } + +// -------------------------------------------------------------------------- +// CPeninputUiStateBase::SendKey +// (other items were commented in a header). +// -------------------------------------------------------------------------- +// +EXPORT_C TBool CPeninputUiStateBase::SendKey( const TDesC& aEventData ) + { + TInt len = aEventData.Length(); + + if ( iContext->LayoutType() == EPluginInputModeHwr ) + { + iContext->Sendkey(ESignalKeyEvent,aEventData); + } + else + { + if ( len == 1) + { + // If it is enter, tab, space, back key etc. + TPtrC ptr = aEventData.Left(1); + iContext->Sendkey(ESignalKeyEvent,ptr); + } + else if ( len > 1) + { + // If it is virtual key + TVirtualKeyEventData* data = (TVirtualKeyEventData* ) aEventData.Ptr(); + + TInt lang = CPeninputDataConverter::AnyToInt + ( iContext->RequestData( EPeninputDataTypeInputLanguage ) ); + + TBuf trueKeySeries; + + if ( lang == ELangArabic ) + { + TInt len = data->iKeyData.Length(); + for ( TInt i=0;i < len; i++ ) + { + trueKeySeries.Append(data->iKeyData[len-i-1]); + } + } + else + { + trueKeySeries.Append( data->iKeyData ); + } + + iContext->Sendkey( ESignalKeyEvent, trueKeySeries ); + } + } + + return ETrue; + }