fep/aknfep/src/AknFepUIInputStateEntryMiniQwertyCangJie.cpp
changeset 36 a7632c26d895
parent 35 0f326f2e628e
child 42 b3eaa440ab06
equal deleted inserted replaced
35:0f326f2e628e 36:a7632c26d895
     1 /*
       
     2 * Copyright (c) 2007 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 *       Provides the  TAknFepInputStateEntryMiniQwertyCangJie methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 #include "AknFepUIManagerStateInterface.h"  //MAknFepUIManagerStateInterface
       
    30 #include "AknFepUiCtrlContainerChinese.h"
       
    31 #include "AknFepManagerUIInterface.h"       //MAknFepManagerUIInterface
       
    32 #include "AknFepUICtrlCandidatePane.h"
       
    33 #include "AknFepUICtrlPinyinPopup.h"
       
    34 #include "AknFepUIInputStateEntryMiniQwertyCangJie.h"
       
    35 
       
    36 
       
    37 #include "AknFepManager.h"                  //FepMan flag
       
    38 #include "AknFepUICtrlInputPane.h"
       
    39 #include "AknFepUiCtrlContainerChinese.h"
       
    40 #include <aknfep.rsg>
       
    41 #include <PtiEngine.h>      //CPtiEngine
       
    42 #include <e32keys.h>        //keys  
       
    43 #include <avkon.rsg>
       
    44 
       
    45 //const TInt KInputPaneLength = 32;
       
    46 //_LIT(KSep, "'");
       
    47 //_LIT(KReplace, "");
       
    48 
       
    49 TAknFepInputStateEntryMiniQwertyCangJie::TAknFepInputStateEntryMiniQwertyCangJie(
       
    50                                MAknFepUIManagerStateInterface* aOwner,
       
    51                                MAknFepUICtrlContainerChinese* aUIContainer)
       
    52     :TAknFepInputStateEntryQwertyBaseChinesePhrase(aOwner,aUIContainer)                           
       
    53     {
       
    54     CPtiEngine* ptiengine = iOwner->PtiEngine();    
       
    55     if(iOwner->FepMan()->CangJieMode() == EPtiEngineNormalCangjieQwerty)
       
    56         {
       
    57         ptiengine->SetInputMode(EPtiEngineNormalCangjieQwerty);            
       
    58         }
       
    59     else if(iOwner->FepMan()->CangJieMode() == EPtiEngineEasyCangjieQwerty)
       
    60         {
       
    61         ptiengine->SetInputMode(EPtiEngineEasyCangjieQwerty);            
       
    62         }
       
    63     else
       
    64         {
       
    65         ptiengine->SetInputMode(EPtiEngineAdvCangjieQwerty);            
       
    66         }
       
    67     ptiengine->SetCase(EPtiCaseLower);
       
    68     UIContainer()->CandidatePane()->ShowCandidateOrdinals(EFalse);
       
    69     }
       
    70 
       
    71 TBool TAknFepInputStateEntryMiniQwertyCangJie::HandleKeyL(TInt aKey, TKeyPressLength aLength)
       
    72     {
       
    73     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    74     TBool ret = ETrue;
       
    75     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
    76     MAknFepUICtrlInputPane* inputPane = uiContainer->InputPane();
       
    77     MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane();
       
    78 
       
    79     if(aKey == EStdKeyLeftFunc && aLength == EShortKeyPress)//chr key to close UI
       
    80         {
       
    81         iOwner->FepMan()->TryCloseUiL();
       
    82         ret = EFalse;
       
    83         }
       
    84     else if( CAknFepFnKeyManager::EFnKeyNext == iOwner->FepMan()->FnKeyState() ||
       
    85              CAknFepFnKeyManager::EFnKeyLock == iOwner->FepMan()->FnKeyState() ||
       
    86              CAknFepFnKeyManager::EFnKeyDown == iOwner->FepMan()->FnKeyState())
       
    87         {
       
    88     	iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
       
    89     	ret = ETrue;
       
    90         }
       
    91     else if (iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagShiftKeyDepressed) ||
       
    92              iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed))
       
    93         {
       
    94         iOwner->FepMan()->TryCloseUiL();
       
    95         ret = EFalse;
       
    96         }   
       
    97     else if (aKey == EKeyLeftShift || aKey ==EKeyLeftCtrl || aKey == EKeyRightCtrl)      
       
    98         {
       
    99     	iOwner->FepMan()->TryCloseUiL();
       
   100         ret = EFalse;
       
   101         }
       
   102     else if (aKey ==EKeyRightFunc)//fn
       
   103     	{
       
   104     	iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
       
   105     	ret = ETrue;
       
   106     	}    
       
   107     else if(aKey == EStdKeyBackspace)//should have long and short 
       
   108         {
       
   109         if (iOwner->PtiEngine()->DeleteKeyPress().Length())
       
   110             {
       
   111             uiContainer->ShowVerticalScrollArrows(!(uiContainer->CandidatePane()->IsLastPage() &&
       
   112                                                     uiContainer->CandidatePane()->IsFirstPage()));
       
   113             SetInputPaneToneMark();
       
   114             inputPane->SetFlag(MAknFepUICtrlInputPane::EPhoneticChanged);
       
   115             RefreshUI();
       
   116             }
       
   117         else
       
   118             {
       
   119             iOwner->FepMan()->TryCloseUiL();
       
   120             if (aLength == ELongKeyPress)
       
   121                 {
       
   122                 iOwner->FepMan()->SetLongClearAfterCloseUI(ETrue);
       
   123                 }
       
   124             }
       
   125         }
       
   126     else if ( aKey == EStdKeyDevice0 || aKey == EStdKeyDevice3 || aKey == EStdKeySpace ) // Add for SK1
       
   127         {
       
   128         TPtrC text = UIContainer()->CandidatePane()->CurrentPhraseCandidate();
       
   129         if(text.Length())
       
   130             {            
       
   131             MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   132             fepMan->NewTextL(text);
       
   133             fepMan->CommitInlineEditL();
       
   134             iOwner->PtiEngine()->SetPredictiveChineseChar(text);
       
   135             if (fepMan->IsFlagSet(CAknFepManager::EFlagEditorFull))
       
   136                 {
       
   137                 fepMan->ClearFlag(CAknFepManager::EFlagEditorFull);
       
   138                 iOwner->FepMan()->TryCloseUiL();
       
   139                 }
       
   140             else
       
   141                 {
       
   142                 iOwner->ChangeState(EPredictiveCandidate);
       
   143                 }
       
   144             }
       
   145         } 
       
   146     else if(aKey == EStdKeyUpArrow)
       
   147         {
       
   148     	if (candidatePane->IsFirstPage())
       
   149             {
       
   150             return ETrue;   
       
   151             }
       
   152         candidatePane->PreviousCandidatePage(); 
       
   153         candidatePane->SetCandidateBuffer();
       
   154         candidatePane->SelectFirstPhrase();
       
   155         UpdateIndicator();
       
   156         }
       
   157     else if(aKey == EStdKeyDownArrow)
       
   158         {
       
   159         return TAknFepInputStateCandidateQwertyBaseChinesePhrase::HandleKeyL(aKey, aLength);
       
   160         }
       
   161     else if( aKey == EStdKeyRightArrow )
       
   162         {
       
   163         if ( candidatePane->VisibleCandidateCount() != 1 )
       
   164 	        {
       
   165 	        iOwner->ChangeState( ECandidate );  
       
   166 	    	candidatePane->SelectNext(); 	
       
   167 	    	UpdateIndicator();
       
   168 	        }    	
       
   169         }
       
   170     else if ( aKey == EStdKeyLeftArrow )  
       
   171     	{
       
   172     	if ( candidatePane->VisibleCandidateCount()!= 1 )
       
   173 	    	{
       
   174 	    	iOwner->ChangeState( ECandidate );  
       
   175 	        candidatePane->SelectLastPhrase();	
       
   176 	        UpdateIndicator();
       
   177 	    	}
       
   178     	}     
       
   179     else if(aLength == EShortKeyPress && iOwner->IsValidChineseInputKeyQwerty(aKey))
       
   180         {
       
   181        
       
   182         TInt stringBeforeLength(0);
       
   183         TInt stringAfterLength(0);
       
   184         
       
   185         stringBeforeLength = ptiengine->GetPhoneticSpelling(1).Length();
       
   186         stringAfterLength = ptiengine->AppendKeyPress((TPtiKey)aKey).Length();
       
   187         
       
   188         if (stringBeforeLength != stringAfterLength)
       
   189             {
       
   190             if (ptiengine->GetPhoneticSpelling(1).Length() == 1)
       
   191                 {
       
   192                // iOwner->FepMan()->UpdateCbaL(R_AVKON_SOFTKEYS_EMPTY);
       
   193                 iOwner->FepMan()->UpdateCbaL(R_AKNFEP_SOFTKEYS_OK_SELECT_CANCEL);
       
   194                 }
       
   195             
       
   196             TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() &&
       
   197                                     uiContainer->CandidatePane()->IsFirstPage());
       
   198             TInt bufLength = ptiengine->CandidatePage().Length();
       
   199             TBool showHorizontalScrollArrows = multiplePages || bufLength>1;
       
   200         
       
   201             uiContainer->ShowVerticalScrollArrows(!(uiContainer->CandidatePane()->IsLastPage() &&
       
   202                                                     uiContainer->CandidatePane()->IsFirstPage()));
       
   203             uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows);         
       
   204             SetInputPaneToneMark();
       
   205             uiContainer->InputPane()->SetFlag(MAknFepUICtrlInputPane::EPhoneticChanged);
       
   206 
       
   207             RefreshUI();
       
   208             }
       
   209         else
       
   210             {
       
   211             iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
       
   212             }
       
   213             
       
   214         if (ptiengine->GetPhoneticSpelling(1).Length() == 0)
       
   215             {
       
   216             iOwner->FepMan()->UpdateCbaL(NULL);
       
   217             }
       
   218         }
       
   219     else    
       
   220         {
       
   221         ret = TAknFepInputStateEntryQwertyBaseChinesePhrase::HandleKeyL(aKey, aLength);
       
   222         }
       
   223         
       
   224     return ret;
       
   225     }
       
   226 
       
   227 
       
   228 // ---------------------------------------------------------------------------
       
   229 // TAknFepInputStateEntryMiniQwertyCangJie::HandleCommandL
       
   230 // Handling Command
       
   231 // ---------------------------------------------------------------------------
       
   232 //
       
   233 void TAknFepInputStateEntryMiniQwertyCangJie::HandleCommandL( TInt aCommandId )
       
   234     {
       
   235     TPtrC text = UIContainer()->CandidatePane()->CurrentPhraseCandidate( );
       
   236     MAknFepManagerUIInterface* fepMan = iOwner->FepMan( );
       
   237     switch ( aCommandId )
       
   238         {
       
   239         // Handle the event frome command.
       
   240         case EAknSoftkeySelect:
       
   241      //   case (TUint16)EAknSoftkeySelect: //the Selected in soft CBA
       
   242             if ( text.Length( ) )
       
   243                 {
       
   244                 fepMan->NewTextL( text );
       
   245                 fepMan->CommitInlineEditL( );
       
   246                 iOwner->PtiEngine()->SetPredictiveChineseChar( text );
       
   247                 if ( fepMan->IsFlagSet( CAknFepManager::EFlagEditorFull ) )
       
   248                     {
       
   249                     fepMan->ClearFlag( CAknFepManager::EFlagEditorFull );
       
   250                     iOwner->FepMan()->TryCloseUiL( );
       
   251                     }
       
   252                 else
       
   253                     {
       
   254                     iOwner->ChangeState( EPredictiveCandidate );
       
   255                     }
       
   256                 }
       
   257             break;
       
   258         default:
       
   259             TAknFepInputStateChineseBase::HandleCommandL( aCommandId );
       
   260             break;
       
   261         }
       
   262     }
       
   263 // End of file