fep/aknfep/src/AknFepUIInputStateEntryMiniQwertyPinyinPhrase.cpp
changeset 40 2cb9bae34d17
parent 31 f1bdd6b078d1
child 49 37f5d84451bd
equal deleted inserted replaced
31:f1bdd6b078d1 40:2cb9bae34d17
     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  TAknFepInputStateEntryMiniQwertyPinyinPhrase 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 "AknFepUIInputStateEntryMiniQwertyPinyinPhrase.h"
       
    35 #include "aknfepuictrleditpane.h"           //pinyin phrase creation
       
    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 KManualChangeState = 0; 
       
    46 //const TUint16 KSegment = 0x0020;
       
    47 // ---------------------------------------------------------------------------
       
    48 // TAknFepInputStateEntryMiniQwertyPinyinPhrase::TAknFepInputStateEntryMiniQwertyPinyinPhrase
       
    49 // C++ default constructor
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 TAknFepInputStateEntryMiniQwertyPinyinPhrase::TAknFepInputStateEntryMiniQwertyPinyinPhrase(
       
    53      MAknFepUIManagerStateInterface* aOwner,MAknFepUICtrlContainerChinese* aUIContainer ):
       
    54      TAknFepInputMiniQwertyPinyinPhraseBase( aOwner, aUIContainer)
       
    55     {
       
    56     iState = EEntry;
       
    57     iOwner->PtiEngine()->SetInputMode( EPtiEnginePinyinPhraseQwerty );
       
    58     iOwner->PtiEngine()->SetCase( EPtiCaseLower );
       
    59     UIContainer()->SetLayout( MAknFepUICtrlContainerChinese::ELayoutKeystroke );
       
    60     UIContainer()->FocusCandidatePane( ETrue );
       
    61     UIContainer()->CandidatePane()->SelectFirstPhrase();
       
    62     UIContainer()->CandidatePane()->ShowCandidateOrdinals( EFalse );
       
    63     UIContainer()->EditPaneWindow()->DeactiveCursor();
       
    64     UIContainer()->SetFepMan( iOwner->FepMan() );
       
    65     // so that it could handle EKeyCBA1
       
    66     iOwner->FepMan()->EntryPhrase( ETrue );
       
    67     RefreshUI( ETrue );
       
    68     }
       
    69 // ---------------------------------------------------------------------------
       
    70 // TAknFepInputStateEntryMiniQwertyPinyinPhrase::HandleKeyL
       
    71 // Handle system key press event.
       
    72 // ---------------------------------------------------------------------------
       
    73 //     
       
    74 TBool TAknFepInputStateEntryMiniQwertyPinyinPhrase::HandleKeyL( TInt aKey,
       
    75     TKeyPressLength aLength )
       
    76     {
       
    77     TBool ret = ETrue;
       
    78     MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane();
       
    79     switch ( aKey )
       
    80         {
       
    81         case EStdKeyLeftFunc: //chr key
       
    82         case EStdKeySpace:
       
    83         case EStdKeyBackspace:
       
    84         case EStdKeyEnter:
       
    85             {
       
    86             ret = TAknFepInputMiniQwertyPinyinPhraseBase::HandleKeyL( aKey,
       
    87                 aLength );
       
    88             break;
       
    89             }
       
    90         case EKeyLeftShift:
       
    91         case EKeyRightShift:
       
    92         case EKeyLeftCtrl:
       
    93         case EKeyRightCtrl:
       
    94         case EKeyRightFunc://fn 
       
    95         case EKeyLeftFunc: // fn 
       
    96             {
       
    97             iOwner->FepMan()->TryCloseUiL();
       
    98             ret =EFalse;
       
    99             break;
       
   100             }
       
   101         case EStdKeyUpArrow:
       
   102             {
       
   103             if ( candidatePane->IsFirstPage() )
       
   104                 {
       
   105                 UIContainer()->EditPaneWindow()->SetAutoChangeStateFlag( KManualChangeState );
       
   106                 iOwner->ChangeState( EMiniQwertyEdit );
       
   107                 ret = ETrue;
       
   108                 }
       
   109             else 
       
   110                 {
       
   111                 candidatePane->PreviousCandidatePage();
       
   112                 candidatePane->SetCandidateBuffer();
       
   113                 candidatePane->SelectFirst();
       
   114                 UpdateIndicator();
       
   115                 }
       
   116             break;
       
   117             }
       
   118         case EStdKeyDownArrow:
       
   119             {
       
   120             ret = TAknFepInputStateCandidateQwertyBaseChinesePhrase::HandleKeyL( aKey, aLength );
       
   121             break;
       
   122             }
       
   123         case EStdKeyRightArrow:
       
   124             {
       
   125             if ( candidatePane->VisibleCandidateCount()!= 1 )
       
   126                 {
       
   127                 iOwner->ChangeState( ECandidate );
       
   128                 candidatePane->SelectNext();
       
   129                 UpdateIndicator();
       
   130                 }
       
   131             break;
       
   132             }
       
   133         case EStdKeyLeftArrow:
       
   134             {
       
   135             if ( candidatePane->VisibleCandidateCount()!= 1 )
       
   136                 {
       
   137                 iOwner->ChangeState( ECandidate );
       
   138                 TInt numbertotal = UIContainer()->CandidatePane()->VisibleCandidateCount();
       
   139                 UIContainer()->CandidatePane()->SelectIndex( numbertotal - 1 );
       
   140                 UpdateIndicator();
       
   141                 }
       
   142             break;
       
   143             }
       
   144         case EStdKeyDevice0: //select key 
       
   145         case EStdKeyDevice3: // msk 
       
   146             {
       
   147             ret = TAknFepInputMiniQwertyPinyinPhraseBase::HandleKeyL(
       
   148                aKey, aLength );
       
   149             break;
       
   150             }
       
   151         case EStdKeyDevice1:
       
   152             {
       
   153             iOwner->FepMan()->TryCloseUiL();
       
   154             break;
       
   155             }
       
   156         case EStdKeySingleQuote:
       
   157             {
       
   158             iOwner->FepMan()->PlaySound( EAvkonSIDStandardKeyClick );
       
   159             break;
       
   160             }
       
   161         default:
       
   162                // chr + character 
       
   163             if ( iOwner->FepMan()->IsFlagSet( CAknFepManager::EFlagShiftKeyDepressed )
       
   164                     || iOwner->FepMan()->IsFlagSet( CAknFepManager::EFlagQwertyChrKeyDepressed ) )
       
   165                 {
       
   166                 iOwner->FepMan()->TryCloseUiL();
       
   167                 ret = EFalse;
       
   168                 }
       
   169             else if ( CAknFepFnKeyManager::EFnKeyNext == iOwner->FepMan()->FnKeyState() 
       
   170                     || CAknFepFnKeyManager::EFnKeyLock == iOwner->FepMan()->FnKeyState()
       
   171                     || CAknFepFnKeyManager::EFnKeyDown == iOwner->FepMan()->FnKeyState()
       
   172                     ||!iOwner->IsValidChineseInputKeyQwerty( aKey ) ) //fn play error tone
       
   173                     {
       
   174                     iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
       
   175                     }
       
   176             else
       
   177                  {
       
   178                   ret = TAknFepInputMiniQwertyPinyinPhraseBase::HandleKeyL(
       
   179                      aKey, aLength );
       
   180                  }
       
   181             break;
       
   182         }
       
   183     return ret;
       
   184     };
       
   185 // ---------------------------------------------------------------------------
       
   186 // TAknFepInputStateEditinigMiniQwertyPinyinPhrase::TAknFepInputStateEditinigMiniQwertyPinyinPhrase
       
   187 // C++ default constructor
       
   188 // ---------------------------------------------------------------------------
       
   189 //
       
   190 TAknFepInputStateEditinigMiniQwertyPinyinPhrase::TAknFepInputStateEditinigMiniQwertyPinyinPhrase( 
       
   191     MAknFepUIManagerStateInterface* aOwner,MAknFepUICtrlContainerChinese* aUIContainer ):
       
   192     TAknFepInputMiniQwertyPinyinPhraseBase( aOwner,aUIContainer )                           
       
   193     {
       
   194     iState = EMiniQwertyEdit;
       
   195     iOwner->PtiEngine()->SetInputMode( EPtiEnginePinyinPhraseQwerty );
       
   196     iOwner->PtiEngine()->SetCase( EPtiCaseLower );
       
   197     RefreshUI( ETrue );
       
   198     UIContainer()->FocusCandidatePane( EFalse );
       
   199     UIContainer()->CandidatePane()->ShowCandidateOrdinals( EFalse );
       
   200     UIContainer()->EditPaneWindow()->ActiveCursor();
       
   201     }
       
   202 // ---------------------------------------------------------------------------
       
   203 // TAknFepInputStateEditinigMiniQwertyPinyinPhrase::HandleKeyL
       
   204 // Handle system key press event.
       
   205 // ---------------------------------------------------------------------------
       
   206 // 
       
   207 TBool TAknFepInputStateEditinigMiniQwertyPinyinPhrase::HandleKeyL( TInt aKey ,TKeyPressLength aLength )
       
   208     {
       
   209     TBool ret = ETrue;
       
   210     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
   211     MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane();
       
   212     if ( iOwner->FepMan()->GetComposChrFlag() && aKey == EStdKeyLeftFunc )
       
   213         {
       
   214         iOwner->FepMan()->SetComposChrFlag(EFalse);
       
   215         return ETrue;
       
   216         }
       
   217     switch ( aKey )
       
   218         {
       
   219         //the following key is handled by the base class 
       
   220         case EStdKeyLeftFunc: //chr key
       
   221         case EStdKeySpace:
       
   222         case EStdKeyBackspace:
       
   223         case EStdKeyEnter:
       
   224         case EStdKeyRightArrow:
       
   225         case EStdKeyLeftArrow:
       
   226             {
       
   227             ret = TAknFepInputMiniQwertyPinyinPhraseBase::HandleKeyL(
       
   228                 aKey, aLength);
       
   229             break;
       
   230             }
       
   231         case EKeyLeftShift:
       
   232         case EKeyRightShift:
       
   233         case EKeyLeftCtrl:
       
   234         case EKeyRightCtrl:
       
   235         case EKeyRightFunc://fn 
       
   236         case EKeyLeftFunc: // fn 
       
   237             {
       
   238             if ( !uiContainer->EditPaneWindow()->GetAutoChangeStateFlag()
       
   239                  || uiContainer->EditPaneWindow()->PhraseArray()->Count() != 0)
       
   240                 {
       
   241                 iOwner->FepMan()->PlaySound( EAvkonSIDStandardKeyClick );
       
   242                 ret = ETrue;
       
   243                 }
       
   244             else
       
   245                 {
       
   246                 iOwner->FepMan()->TryCloseUiL();
       
   247                 ret = EFalse;
       
   248                 }
       
   249             break;
       
   250             }
       
   251     // inactive 
       
   252         case EStdKeyUpArrow:
       
   253             {
       
   254             break;
       
   255             }
       
   256             //if the canidate is empty ,inactive;else candiniate selecting state
       
   257         case EStdKeyDownArrow:
       
   258             {
       
   259             if ( 0 != candidatePane->VisibleCandidateCount() )
       
   260                 {
       
   261                 uiContainer->EditPaneWindow()->SetChangeState( ETrue );
       
   262                 iOwner->ChangeState( ECandidate );
       
   263                 }
       
   264             break;
       
   265             }
       
   266         case EStdKeyDevice0:
       
   267         case EStdKeyDevice3:
       
   268             {
       
   269             ret = TAknFepInputMiniQwertyPinyinPhraseBase::HandleKeyL(
       
   270                 aKey, aLength);
       
   271             break;
       
   272             }
       
   273           
       
   274         case EStdKeyDevice1:
       
   275             {
       
   276             iOwner->FepMan()->TryCloseUiL();
       
   277             break;
       
   278             }
       
   279         case EStdKeySingleQuote:
       
   280             {
       
   281             iOwner->FepMan()->PlaySound( EAvkonSIDStandardKeyClick );
       
   282             break;
       
   283             }
       
   284         default:
       
   285             // chr + character 
       
   286             if ( iOwner->FepMan()->IsFlagSet( CAknFepManager::EFlagShiftKeyDepressed )
       
   287                 || iOwner->FepMan()->IsFlagSet( CAknFepManager::EFlagQwertyChrKeyDepressed ) )
       
   288                 {
       
   289                 iOwner->FepMan()->SetComposChrFlag( ETrue );
       
   290                 if ( !uiContainer->EditPaneWindow()->GetAutoChangeStateFlag()
       
   291                       || uiContainer->EditPaneWindow()->PhraseArray()->Count() != 0)
       
   292                     {
       
   293                     iOwner->FepMan()->PlaySound(EAvkonSIDStandardKeyClick);
       
   294                     return  ETrue;
       
   295                     }
       
   296                 else
       
   297                     {
       
   298                     iOwner->FepMan()->TryCloseUiL();
       
   299                     return EFalse;
       
   300                     }
       
   301                 }
       
   302             else
       
   303                 {
       
   304                 ret = TAknFepInputMiniQwertyPinyinPhraseBase::HandleKeyL(
       
   305                     aKey, aLength);
       
   306                 break;
       
   307                 }
       
   308         }
       
   309     return ret;
       
   310     }
       
   311 // ---------------------------------------------------------------------------
       
   312 // TAknFepInputStateEntryMiniQwertyPinyinPhrase::HandleCommandL
       
   313 // Handling Command
       
   314 // ---------------------------------------------------------------------------
       
   315 //
       
   316 void TAknFepInputStateEntryMiniQwertyPinyinPhrase::HandleCommandL(
       
   317     TInt aCommandId )
       
   318     {
       
   319     TPtrC text = UIContainer()->CandidatePane()->CurrentPhraseCandidate( );
       
   320     MAknFepManagerUIInterface* fepMan = iOwner->FepMan( );
       
   321     switch ( aCommandId )
       
   322         {
       
   323         // Handle the event frome command.
       
   324         case EAknSoftkeySelect:
       
   325     //    case (TUint16)EAknSoftkeySelect: //the Selected in soft CBA
       
   326             if ( text.Length( ) )
       
   327                 {
       
   328                 fepMan->NewTextL( text );
       
   329                 fepMan->CommitInlineEditL( );
       
   330                 iOwner->PtiEngine()->SetPredictiveChineseChar( text );
       
   331                 if ( fepMan->IsFlagSet( CAknFepManager::EFlagEditorFull ) )
       
   332                     {
       
   333                     fepMan->ClearFlag( CAknFepManager::EFlagEditorFull );
       
   334                     iOwner->FepMan()->TryCloseUiL( );
       
   335                     }
       
   336                 else
       
   337                     {
       
   338                     iOwner->ChangeState( EPredictiveCandidate );
       
   339                     }
       
   340                 }
       
   341             break;
       
   342         default:
       
   343             TAknFepInputStateChineseBase::HandleCommandL( aCommandId );
       
   344             break;
       
   345         }
       
   346     }
       
   347 // ---------------------------------------------------------------------------
       
   348 // TAknFepInputStateEditinigMiniQwertyPinyinPhrase::HandleCommandL
       
   349 // Handling Command
       
   350 // ---------------------------------------------------------------------------
       
   351 //
       
   352 void TAknFepInputStateEditinigMiniQwertyPinyinPhrase::HandleCommandL(
       
   353     TInt aCommandId )
       
   354     {
       
   355     TAknFepInputMiniQwertyPinyinPhraseBase::HandleCommandL( aCommandId );
       
   356     }
       
   357 // End Of File
       
   358