textinput/peninputcommonlayout/src/peninputuistatebase.cpp
changeset 27 694fa80c203c
parent 24 fc42a86c98e3
child 35 0f326f2e628e
equal deleted inserted replaced
24:fc42a86c98e3 27:694fa80c203c
     1 /*
       
     2 * Copyright (c) 2002-2005 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:  Implementation of the ui state base
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // User includes
       
    20 #include <peninputlayoutvkb.h>
       
    21 #include <AknFepGlobalEnums.h>      // Define EPluginInputModeHwr
       
    22 #include <peninputdataconverter.h>
       
    23 #include "peninputuistatebase.h"
       
    24 #include "peninputlayoutcontext.h"
       
    25 #include "peninputcmd.h"
       
    26 #include "peninputcommonlayoutglobalenum.h"
       
    27 
       
    28 const TInt KMaxKeyLength = 10;
       
    29 
       
    30 // ======== MEMBER FUNCTIONS ========
       
    31 
       
    32 // --------------------------------------------------------------------------
       
    33 // CPeninputUiStateBase::CPeninputUiStateBase
       
    34 // (other items were commented in a header)
       
    35 // --------------------------------------------------------------------------
       
    36 //
       
    37 EXPORT_C CPeninputUiStateBase::CPeninputUiStateBase( 
       
    38     MPeninputUiStateMgr* aUiStateMgr, MPeninputLayoutContext* aContext )
       
    39     : iUiStateMgr( aUiStateMgr ), iContext( aContext )
       
    40     {
       
    41     }
       
    42     
       
    43 // --------------------------------------------------------------------------
       
    44 // CPeninputUiStateBase::NewL
       
    45 // (other items were commented in a header)
       
    46 // --------------------------------------------------------------------------
       
    47 //
       
    48 EXPORT_C CPeninputUiStateBase* CPeninputUiStateBase::NewL( 
       
    49     MPeninputUiStateMgr* aUiStateMgr, MPeninputLayoutContext* aContext )
       
    50     {
       
    51     CPeninputUiStateBase* self = new ( ELeave ) 
       
    52         CPeninputUiStateBase( aUiStateMgr, aContext );
       
    53     CleanupStack::PushL( self );
       
    54     self->Construct(); 
       
    55     CleanupStack::Pop( self );
       
    56     
       
    57     return self;
       
    58     }  
       
    59     
       
    60 // --------------------------------------------------------------------------
       
    61 // CPeninputUiStateBase::ConstructL
       
    62 // (other items were commented in a header)
       
    63 // --------------------------------------------------------------------------
       
    64 //
       
    65 EXPORT_C void CPeninputUiStateBase::Construct()
       
    66     {
       
    67     } 
       
    68           
       
    69 // --------------------------------------------------------------------------
       
    70 // CPeninputUiStateBase::~CPeninputUiStateBase
       
    71 // (other items were commented in a header)
       
    72 // --------------------------------------------------------------------------
       
    73 //
       
    74 EXPORT_C CPeninputUiStateBase::~CPeninputUiStateBase()
       
    75     {    
       
    76     }        
       
    77 
       
    78 // --------------------------------------------------------------------------
       
    79 // CPeninputUiStateBase::HandleKeyEventL
       
    80 // (other items were commented in a header)
       
    81 // --------------------------------------------------------------------------
       
    82 //
       
    83 EXPORT_C TBool CPeninputUiStateBase::HandleKeyEventL( 
       
    84     const TRawEvent& /*aData*/ )   
       
    85     {
       
    86     return EFalse;
       
    87     }    
       
    88 
       
    89 // --------------------------------------------------------------------------
       
    90 // CPeninputUiStateBase::HandleControlEvent
       
    91 // (other items were commented in a header).
       
    92 // --------------------------------------------------------------------------
       
    93 //
       
    94 EXPORT_C TBool CPeninputUiStateBase::HandleControlEvent( TInt /*aEventType*/, 
       
    95     const TDesC& /*aEventData*/ )
       
    96     {
       
    97     return EFalse;   
       
    98     }
       
    99 
       
   100 // --------------------------------------------------------------------------
       
   101 // CPeninputUiStateBase::SendKey
       
   102 // (other items were commented in a header).
       
   103 // --------------------------------------------------------------------------
       
   104 //
       
   105 EXPORT_C TBool CPeninputUiStateBase::SendKey( const TDesC& aEventData )
       
   106     {
       
   107     TInt len = aEventData.Length();
       
   108     
       
   109     if ( iContext->LayoutType() == EPluginInputModeHwr )
       
   110         {
       
   111         iContext->Sendkey(ESignalKeyEvent,aEventData);
       
   112         }
       
   113     else
       
   114         {
       
   115         if ( len == 1)
       
   116             {
       
   117             // If it is enter, tab, space, back key etc.
       
   118             TPtrC ptr = aEventData.Left(1);
       
   119             iContext->Sendkey(ESignalKeyEvent,ptr);            
       
   120             }
       
   121         else if ( len > 1)
       
   122             {
       
   123             // If it is virtual key
       
   124             TVirtualKeyEventData* data = (TVirtualKeyEventData* ) aEventData.Ptr();
       
   125             
       
   126             TInt lang = CPeninputDataConverter::AnyToInt
       
   127                 ( iContext->RequestData( EPeninputDataTypeInputLanguage ) );    
       
   128             
       
   129             TBuf<KMaxKeyLength> trueKeySeries;
       
   130                 
       
   131             if ( lang == ELangArabic )
       
   132                 {
       
   133                 TInt len = data->iKeyData.Length();
       
   134                 for ( TInt i=0;i < len; i++ ) 
       
   135                     {
       
   136                     trueKeySeries.Append(data->iKeyData[len-i-1]);
       
   137                     }        
       
   138                 } 
       
   139             else
       
   140                 {
       
   141                 trueKeySeries.Append( data->iKeyData );
       
   142                 }
       
   143                     
       
   144             iContext->Sendkey( ESignalKeyEvent, trueKeySeries );             
       
   145             }            
       
   146         }
       
   147         
       
   148     return ETrue; 
       
   149     }