fep/aknfep/src/AknFepUiInputStateEntryStrokePhrase.cpp
changeset 36 a7632c26d895
parent 35 0f326f2e628e
child 42 b3eaa440ab06
equal deleted inserted replaced
35:0f326f2e628e 36:a7632c26d895
     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 Stroke phrase entry state
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 // System includes
       
    30 #include <PtiEngine.h>
       
    31 #include <aknnotewrappers.h> //CAknWarningNote 
       
    32 
       
    33 // User includes
       
    34 #include "AknFepUiInputStateEntryStrokePhrase.h"
       
    35 #include "AknFepUIManagerStateInterface.h"
       
    36 #include "AknFepUICtrlCandidatePane.h"
       
    37 #include "AknFepUICtrlPinyinPopup.h"
       
    38 #include "AknFepUICtrlInputPane.h"
       
    39 #include "aknfepuictrleditpane.h" 
       
    40 #include "AknFepManager.h"
       
    41 
       
    42 // const param
       
    43 const TInt KMinCnadidateCount = 1;
       
    44 const TInt KMaxKeystrokeCount = 31;
       
    45 const TInt KMaxPhraseCreationCount = 7;
       
    46 const TInt KManualChangeState = 0; 
       
    47 const TInt KChangeStatebyBackSpce = 0x1000;//set popup flag for change state.
       
    48 //const TUint16 KSegment = 0x0020;
       
    49 _LIT( KMaxPhraseNote,"\x8BCD\x7EC4\x6700\x957F\x4E3A\x4E03\x5B57" );
       
    50 _LIT( KDelimiter, "\x2022");
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // TAknFepInputStateEntryStrokePhrase::
       
    54 // TAknFepInputStateEntryStrokePhrase
       
    55 // (other items were commented in a header).
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 TAknFepInputStateEntryStrokePhrase::TAknFepInputStateEntryStrokePhrase(
       
    59     MAknFepUIManagerStateInterface* aOwner,
       
    60     MAknFepUICtrlContainerChinese* aUIContainer) :
       
    61     TAknFepInputStateStrokePhraseBase( aOwner, aUIContainer)
       
    62     {  
       
    63     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
    64     MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane();
       
    65     
       
    66     iState = EEntry;
       
    67     uiContainer->SetLayout( MAknFepUICtrlContainerChinese::ELayoutKeystroke );
       
    68     TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() &&
       
    69                             uiContainer->CandidatePane()->IsFirstPage());
       
    70     TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length();
       
    71     TBool showHorizontalScrollArrows = multiplePages || bufLength>1;
       
    72 
       
    73     uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows); 
       
    74     uiContainer->ShowVerticalScrollArrows(multiplePages);
       
    75     uiContainer->FocusCandidatePane(ETrue);
       
    76     candidatePane->SetHighlighted(ETrue);
       
    77     candidatePane->ShowCandidateOrdinals(EFalse);
       
    78     candidatePane->SelectFirstPhrase();
       
    79     uiContainer->InputPane()->SetOverrideFontId( 0 );
       
    80     iOwner->FepMan()->EntryPhrase( ETrue );
       
    81 
       
    82     RefreshUI( ETrue );
       
    83  	}
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // TAknFepInputStateEntryStrokePhrase::HandleKeyL
       
    87 // (other items were commented in a header).
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 TBool TAknFepInputStateEntryStrokePhrase::HandleKeyL( 
       
    91                                                     TInt aKey,
       
    92                                                     TKeyPressLength aLength )
       
    93     {
       
    94     TBool ret = ETrue;
       
    95     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
    96     MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane();
       
    97     MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow();
       
    98     switch ( aKey )
       
    99         {
       
   100         case EPtiKeyStar:
       
   101             {
       
   102             break;
       
   103             }
       
   104         case EKeyUpArrow:
       
   105             {
       
   106             if ( !candidatePane->IsFirstPage() )
       
   107                 {
       
   108                 candidatePane->PreviousCandidatePage();  
       
   109                 RefreshCandidate();
       
   110                 }
       
   111             else
       
   112                 {
       
   113                 popup->SetState( EFalse );
       
   114                 popup->SetState( KManualChangeState );
       
   115                 popup->SetChangeState( ETrue );
       
   116                 //change state to sequence edit
       
   117                 iOwner->ChangeState( EStrokeSequenceEdit );
       
   118                 }
       
   119             break;
       
   120             }
       
   121         case EKeyDownArrow:
       
   122             {
       
   123             if ( CheckKeyNeedRepeat( aLength ) )
       
   124                 {
       
   125                 if ( candidatePane->IsLastPage( ) )
       
   126                     {
       
   127                     return ETrue;
       
   128                     }
       
   129                 if ( candidatePane->NeedGetNewCandidatePage( ) )
       
   130                     {
       
   131                     if ( !iOwner->PtiEngine()->NextCandidatePage( ) )
       
   132                         {
       
   133                         if ( candidatePane->IsLastPage( ) )
       
   134                             {
       
   135                             iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
       
   136                             return ETrue;
       
   137                             }
       
   138                         }
       
   139                     else
       
   140                         {
       
   141                         CDesCArrayFlat* phraseCandidates =
       
   142                             candidatePane->CandidateArray( );
       
   143                         RPointerArray<HBufC> list;
       
   144                         GetNewCandidatesL( iOwner->PtiEngine()->CandidatePage( ), list );
       
   145                         for (TInt i = 0; i < list.Count( ); ++i )
       
   146                             {
       
   147                             phraseCandidates->AppendL( *(list[i]) );
       
   148                             }
       
   149                         list.ResetAndDestroy();
       
   150                         }
       
   151                     }
       
   152                 candidatePane->NextCandidatePage();
       
   153                 candidatePane->SetCandidateBuffer();
       
   154                 candidatePane->SelectFirstPhrase();
       
   155                 RefreshCandidate();
       
   156                 }
       
   157             else
       
   158                 {
       
   159                 iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
       
   160                 }
       
   161             break;
       
   162             }
       
   163         case EKeyLeftArrow:
       
   164         case EKeyRightArrow:
       
   165             {
       
   166             popup->SetChangeState( ETrue );
       
   167             iOwner->ChangeState( ECandidate );
       
   168             ret = EFalse;
       
   169             break;
       
   170             }
       
   171         case EKeyCBA1:
       
   172         case EKeyOK:
       
   173             {
       
   174             if ( CheckKeyNeedRepeat( aLength ) )
       
   175                 {
       
   176                 popup->SetChangeState( ETrue );
       
   177                 iOwner->ChangeState( ECandidate );
       
   178                 ret = EFalse;
       
   179                 }
       
   180             else
       
   181                 {
       
   182                 iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
       
   183                 }
       
   184             break;
       
   185             }
       
   186         default:
       
   187             return TAknFepInputStateStrokePhraseBase::HandleKeyL( aKey, aLength );
       
   188         }
       
   189     
       
   190     return ret;
       
   191     }
       
   192 
       
   193 
       
   194 // ---------------------------------------------------------------------------
       
   195 // TAknFepInputStateEntryStrokePhrase::HandleCommandL
       
   196 // Handling Command
       
   197 // ---------------------------------------------------------------------------
       
   198 //
       
   199 void TAknFepInputStateEntryStrokePhrase::HandleCommandL( TInt aCommandId )
       
   200     {
       
   201     switch ( aCommandId )
       
   202         {
       
   203         // Handle the event frome command.
       
   204         case EAknSoftkeySelect:
       
   205             HandleCommitL();
       
   206             break;
       
   207         default:
       
   208             TAknFepInputStateChineseBase::HandleCommandL( aCommandId );
       
   209             break;
       
   210         }
       
   211     }
       
   212 
       
   213 // ---------------------------------------------------------------------------
       
   214 // TAknFepInputStateEntryStrokePhrase::HandleCommit 
       
   215 // Handle CBA1,ok and select candidate phrase key press.
       
   216 // ---------------------------------------------------------------------------
       
   217 //
       
   218 void TAknFepInputStateEntryStrokePhrase::HandleCommitL()
       
   219     {
       
   220     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
   221     MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane();
       
   222     MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow();
       
   223     MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
       
   224     CDesCArrayFlat* keystrokeArray = popup->KeystrokeArrayForStroke();
       
   225     CDesCArrayFlat* phrase = popup->ChooseChineseCharacterArrayForStroke();
       
   226     TPtrC text = candidatePane->CurrentPhraseCandidate();
       
   227     if( text.Length() ) 
       
   228         {
       
   229         if ( CommitInlineEEPL( text ) )
       
   230             {
       
   231             if ( phrase->Count() >= KMaxPhraseCreationCount )
       
   232                 {
       
   233                 if ( keystrokeArray->Count() != 0 )
       
   234                     {
       
   235                     CAknWarningNote* errnote = new( ELeave ) CAknWarningNote();
       
   236                     errnote->SetTone( CAknNoteDialog::EWarningTone );
       
   237                     errnote->ExecuteLD( KMaxPhraseNote );
       
   238                     }
       
   239                 else
       
   240                     {
       
   241                     iOwner->FepMan()->PhraseCreation( EFalse );
       
   242                     iOwner->FepMan()->EntryPhrase( EFalse );
       
   243                     iOwner->FepMan()->PinyinPhraseCreation( EFalse );
       
   244                     iOwner->FepMan()->EnableKeyStar( ETrue );
       
   245                     iOwner->FepMan()->TryCloseUiL(); //no more keys, close the UI.
       
   246                     }
       
   247                 }
       
   248             else
       
   249                 {
       
   250                 if ( !iOwner->FepMan()->IsPhraseCreation() )
       
   251                     {
       
   252                     if (iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagEditorFull))
       
   253                         {
       
   254                         iOwner->FepMan()->ClearFlag(CAknFepManager::EFlagEditorFull);
       
   255                         iOwner->FepMan()->TryCloseUiL();
       
   256                         }
       
   257                     else
       
   258                         {
       
   259                         iOwner->ChangeState( EPredictiveCandidate );
       
   260                         }
       
   261                     }
       
   262                 else
       
   263                     {
       
   264                     iOwner->FepMan()->PhraseCreation( EFalse );
       
   265                     iOwner->FepMan()->EntryPhrase( EFalse );
       
   266                     iOwner->FepMan()->PinyinPhraseCreation( EFalse );
       
   267                     iOwner->FepMan()->EnableKeyStar( ETrue );
       
   268                     iOwner->FepMan()->TryCloseUiL(); //no more keys, close the UI.
       
   269                     }
       
   270                 }
       
   271             popup->ResetStrokeArray();
       
   272             }
       
   273         else
       
   274             {
       
   275             editPane->SetCursorIndexOfKeystroke( 0 );
       
   276             if ( CheckFirstGroupStroke() )
       
   277                 {
       
   278                 popup->SetState( ETrue );
       
   279                 iOwner->ChangeState( EEntry );
       
   280                 }
       
   281             else
       
   282                 {
       
   283                 popup->SetState( ETrue );
       
   284                 //change state to sequence edit
       
   285                 iOwner->ChangeState( EStrokeSequenceEdit );
       
   286                 }
       
   287             }
       
   288         }
       
   289     }
       
   290 
       
   291 // ---------------------------------------------------------------------------
       
   292 // TAknFepInputStateEntryStrokePhrase::CommitInlineEEPL 
       
   293 // Commit phrase to the EEP ctrl.
       
   294 // ---------------------------------------------------------------------------
       
   295 //
       
   296 TBool TAknFepInputStateEntryStrokePhrase::CommitInlineEEPL( 
       
   297                                                         const TDesC& aText )
       
   298     {
       
   299     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
   300     MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow();
       
   301     CDesCArrayFlat* keystrokeArray = popup->KeystrokeArrayForStroke();
       
   302     CDesCArrayFlat* phrase = popup->ChooseChineseCharacterArrayForStroke();
       
   303     CDesCArrayFlat* phraseKeystroke = 
       
   304         popup->ChooseChineseCharacterArrayKeystrokeForStroke();
       
   305     
       
   306     TBuf<KMaxPhraseCreationCount> phraseCreated;
       
   307     
       
   308     TInt textCount = aText.Length();
       
   309     TInt allTextCount = 0;
       
   310     TInt i = 0;
       
   311     TInt j = 0;
       
   312     // append character to chinese array
       
   313     for ( i = 0; i < textCount; i++ )
       
   314         {
       
   315         phrase->AppendL( aText.Mid( i, 1 ) );
       
   316         }
       
   317     
       
   318     TInt characterCount = phrase->Count();
       
   319     
       
   320     // if chinese character is more than 7 or not
       
   321     // if more than 7 show a warning not
       
   322     if ( characterCount >= KMaxPhraseCreationCount )
       
   323         {
       
   324         for ( i = 0; i < KMaxPhraseCreationCount; ++i )
       
   325             {
       
   326             phraseCreated.Append( phrase->MdcaPoint(i) );
       
   327             }
       
   328         AddPhraseToDB( phraseCreated );
       
   329         iOwner->FepMan()->NewTextL( phraseCreated );
       
   330         iOwner->FepMan()->CommitInlineEditL();
       
   331         }
       
   332     
       
   333     // calculate the total number of character according to stroke
       
   334     for ( i = 0; i < keystrokeArray->Count(); i++ )
       
   335         {
       
   336         if ( keystrokeArray->MdcaPoint( i ) == KDelimiter )
       
   337             {
       
   338             allTextCount = allTextCount + 1;
       
   339             }
       
   340         }
       
   341     
       
   342     allTextCount = allTextCount + 1;
       
   343     if ( keystrokeArray->MdcaPoint( keystrokeArray->Count() - 1 ) ==  
       
   344         KDelimiter )
       
   345         {
       
   346         allTextCount--;
       
   347         }
       
   348     
       
   349     // if total number is less than the character's count which user has selected
       
   350     // commit the character to editor and user db   
       
   351     if ( allTextCount <= textCount && characterCount < KMaxPhraseCreationCount )
       
   352         {
       
   353         for ( i = 0; i < characterCount; ++i )
       
   354             {
       
   355             phraseCreated.Append( phrase->MdcaPoint(i) );
       
   356             } 
       
   357         iOwner->FepMan()->NewTextL( phraseCreated );
       
   358         iOwner->FepMan()->CommitInlineEditL();
       
   359         AddPhraseToDB( phraseCreated );
       
   360         return ETrue;
       
   361         }
       
   362     
       
   363     // add the stroke to chosen character array
       
   364     // delete key stroke which charactor is corresponding
       
   365     for ( j = 0; j < textCount; j++ )
       
   366         {
       
   367         TInt keyCount = 0;
       
   368         TInt ret = keystrokeArray->Find( KDelimiter , 
       
   369                                          keyCount, 
       
   370                                          ECmpFolded );
       
   371         
       
   372         if ( ret != 0)
       
   373             {
       
   374             keyCount = keystrokeArray->Count();
       
   375             j = textCount;
       
   376             }
       
   377         else
       
   378             {
       
   379             keyCount++;
       
   380             }
       
   381 
       
   382         TBuf<KMaxKeystrokeCount> keystroke;
       
   383         for ( i = 0; i < keyCount; i++ )
       
   384             {
       
   385             keystroke.Append( keystrokeArray->MdcaPoint( 0 ) );
       
   386             keystrokeArray->Delete( 0 );
       
   387             }
       
   388         phraseKeystroke->AppendL( keystroke );
       
   389         }    
       
   390     if ( keystrokeArray->Count() > 0 )
       
   391         {
       
   392         iOwner->FepMan()->PhraseCreation( ETrue );
       
   393         }
       
   394     if ( characterCount >= KMaxPhraseCreationCount )
       
   395         {
       
   396         return ETrue;
       
   397         }
       
   398 
       
   399     return EFalse;
       
   400     }
       
   401 
       
   402 // End of file
       
   403 
       
   404 // ---------------------------------------------------------
       
   405 // C++ constructor
       
   406 // ---------------------------------------------------------
       
   407 //
       
   408 TAknFepInputStateEditStrokePhrase::TAknFepInputStateEditStrokePhrase(
       
   409     MAknFepUIManagerStateInterface* aOwner,
       
   410     MAknFepUICtrlContainerChinese* aUIContainer ) :
       
   411     TAknFepInputStateStrokePhraseBase( aOwner, aUIContainer)
       
   412     {
       
   413     iState = EStrokeSequenceEdit;
       
   414 
       
   415     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
   416     uiContainer->FocusCandidatePane( EFalse );
       
   417     uiContainer->CandidatePane()->ShowCandidateOrdinals( EFalse );
       
   418     uiContainer->SetLayout( MAknFepUICtrlContainerChinese::ELayoutKeystroke );
       
   419     uiContainer->CandidatePane()->SelectFirstPhrase();
       
   420     uiContainer->ShowVerticalScrollArrows( ETrue );
       
   421     uiContainer->ShowHorizontalScrollArrows( EFalse );
       
   422     uiContainer->InputPane()->SetOverrideFontId( 0 );
       
   423 
       
   424     RefreshUI();
       
   425     }
       
   426 
       
   427 // ---------------------------------------------------------------------------
       
   428 // TAknFepInputStateEditStrokePhrase::HandleKeyL
       
   429 // ---------------------------------------------------------------------------
       
   430 //
       
   431 TBool TAknFepInputStateEditStrokePhrase::HandleKeyL( 
       
   432                                                     TInt aKey,
       
   433                                                     TKeyPressLength aLength )
       
   434     {
       
   435     return TAknFepInputStateStrokePhraseBase::HandleKeyL( 
       
   436                                                    aKey, 
       
   437                                                    aLength );
       
   438     }
       
   439 
       
   440 // ---------------------------------------------------------------------------
       
   441 // TAknFepInputStateEntryStrokePhraseCreation::
       
   442 // TAknFepInputStateEntryStrokePhraseCreation
       
   443 // (other items were commented in a header).
       
   444 // ---------------------------------------------------------------------------
       
   445 //
       
   446 TAknFepInputStateCandidateStrokePhrase::TAknFepInputStateCandidateStrokePhrase(
       
   447     MAknFepUIManagerStateInterface* aOwner,
       
   448     MAknFepUICtrlContainerChinese* aUIContainer)
       
   449     :TAknFepInputStateStrokePhraseBase(aOwner, aUIContainer)
       
   450     {
       
   451     iState = ECandidate;
       
   452     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
   453     
       
   454     TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() &&
       
   455                             uiContainer->CandidatePane()->IsFirstPage());
       
   456     TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length();
       
   457     TBool showHorizontalScrollArrows = multiplePages || bufLength > KMinCnadidateCount;
       
   458 
       
   459     uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows); 
       
   460     uiContainer->ShowVerticalScrollArrows(multiplePages);
       
   461     uiContainer->FocusCandidatePane(ETrue);
       
   462     uiContainer->CandidatePane()->ShowCandidateOrdinals(ETrue);
       
   463     uiContainer->CandidatePane()->SelectFirstPhrase();
       
   464     uiContainer->EditPaneWindow()->DisableCursor();
       
   465     }
       
   466 
       
   467 // ---------------------------------------------------------------------------
       
   468 // TAknFepInputStateCandidateStrokePhrase::HandleKeyL
       
   469 // (other items were commented in a header).
       
   470 // ---------------------------------------------------------------------------
       
   471 //
       
   472 TBool TAknFepInputStateCandidateStrokePhrase::HandleKeyL( 
       
   473                                         TInt aKey, 
       
   474                                         TKeyPressLength /*aLength*/ )
       
   475     {
       
   476     TBool ret = ETrue;
       
   477     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
   478     MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane();
       
   479     MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow();
       
   480     MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
       
   481     // it may be one of the 'valid' numbers..
       
   482     TInt index = MapKeyToIndex(aKey);
       
   483 
       
   484     switch( aKey )
       
   485         {
       
   486         case EKeyBackspace:
       
   487             {
       
   488             editPane->EnableCursor();
       
   489             popup->SetChangeState( ETrue );
       
   490             iOwner->ChangeState( EEntry );
       
   491             popup->SetFlag( KChangeStatebyBackSpce );
       
   492             break;
       
   493             }
       
   494         case EKeyDownArrow:
       
   495             {
       
   496             if ( candidatePane->IsLastPage() )
       
   497                 {
       
   498                 return ETrue;
       
   499                 }
       
   500             if ( candidatePane->NeedGetNewCandidatePage( ) )
       
   501                 {
       
   502                 if ( !iOwner->PtiEngine()->NextCandidatePage( ) )
       
   503                     {
       
   504                     if ( candidatePane->IsLastPage() )
       
   505                         {
       
   506                         iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
       
   507                         return ETrue;
       
   508                         }
       
   509                     }
       
   510                 else
       
   511                     {
       
   512                     CDesCArrayFlat* phraseCandidates =
       
   513                         candidatePane->CandidateArray( );
       
   514                     RPointerArray<HBufC> list;
       
   515                     GetNewCandidatesL( iOwner->PtiEngine()->CandidatePage( ), list );
       
   516                     for (TInt i = 0; i < list.Count( ); ++i )
       
   517                         {
       
   518                         phraseCandidates->AppendL( *(list[i]) );
       
   519                         }
       
   520                     list.ResetAndDestroy();
       
   521                     }
       
   522                 }
       
   523             candidatePane->NextCandidatePage( );
       
   524             RefreshCandidate( );
       
   525             break;
       
   526             }
       
   527         case EKeyUpArrow:
       
   528             {
       
   529             if( !candidatePane->IsFirstPage() )
       
   530                 {
       
   531                 candidatePane->PreviousCandidatePage();
       
   532                 RefreshCandidate();
       
   533                 }
       
   534             else
       
   535                 {
       
   536                 popup->SetChangeState( ETrue );
       
   537                 popup->SetState( EFalse );
       
   538                 iOwner->ChangeState( EStrokeSequenceEdit );
       
   539                 }
       
   540             break;
       
   541             }
       
   542         case EKeyLeftArrow:
       
   543         case EKeyRightArrow:
       
   544             {
       
   545             HandleHorizontalNavigation( aKey );
       
   546             break;
       
   547             }
       
   548         case EPtiKeyStar:
       
   549             {
       
   550             break;
       
   551             }
       
   552         case EKeyCBA2:
       
   553             {
       
   554             popup->ResetStrokeArray();
       
   555             iOwner->FepMan()->EntryPhrase( EFalse );
       
   556             iOwner->FepMan()->PhraseCreation( EFalse );
       
   557             iOwner->FepMan()->TryCloseUiL();
       
   558             break;
       
   559             }
       
   560         default:
       
   561             {
       
   562             if ( ( aKey == EKeyOK ) || aKey == EKeyCBA1 ||
       
   563                         candidatePane->SelectIndex( index,EFalse ) )
       
   564                 {
       
   565                 HandleCommitL();
       
   566                 }
       
   567             else
       
   568                 {
       
   569                 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
       
   570                 }
       
   571             break;
       
   572             }
       
   573         }
       
   574     return ret;
       
   575     }
       
   576 
       
   577 // ---------------------------------------------------------------------------
       
   578 // TAknFepInputStateCandidateStrokePhrase::HandleHorizontalNavigation 
       
   579 // Handle Horizontal Navigation.
       
   580 // ---------------------------------------------------------------------------
       
   581 //
       
   582 void TAknFepInputStateCandidateStrokePhrase::HandleHorizontalNavigation(
       
   583                                                                    TInt aKey )
       
   584     {
       
   585     MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane();
       
   586     // Do navigation...
       
   587     if (aKey == EKeyLeftArrow)
       
   588         {        
       
   589         if(!candidatePane->SelectPrev())
       
   590             {
       
   591             candidatePane->SetCandidateBuffer();
       
   592             candidatePane->SelectLastPhrase();
       
   593             }
       
   594         }
       
   595     else if (aKey == EKeyRightArrow)
       
   596         {              
       
   597         if(!candidatePane->SelectNext())
       
   598             {
       
   599             candidatePane->SetCandidateBuffer();
       
   600             candidatePane->SelectFirstPhrase();
       
   601             }        
       
   602         }
       
   603     }
       
   604 
       
   605 // ---------------------------------------------------------------------------
       
   606 // TAknFepInputStateCandidateStrokePhrase::HandleCommit 
       
   607 // Handle CBA1,ok and select candidate phrase key press.
       
   608 // ---------------------------------------------------------------------------
       
   609 //
       
   610 void TAknFepInputStateCandidateStrokePhrase::HandleCommitL()
       
   611     {
       
   612     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
   613     MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane();
       
   614     MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow();
       
   615     MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
       
   616     CDesCArrayFlat* keystrokeArray = popup->KeystrokeArrayForStroke();
       
   617     CDesCArrayFlat* phrase = popup->ChooseChineseCharacterArrayForStroke();
       
   618     TPtrC text = candidatePane->CurrentPhraseCandidate();
       
   619     if( text.Length() ) 
       
   620         {
       
   621         if ( CommitInlineEEPL( text ) )
       
   622             {
       
   623             if ( phrase->Count() <= KMaxPhraseCreationCount && !iOwner->FepMan()->IsPhraseCreation() )
       
   624                 {
       
   625                 if ( !iOwner->FepMan()->IsPhraseCreation( ) )
       
   626                     {
       
   627                     if ( iOwner->FepMan()->IsFlagSet( CAknFepManager::EFlagEditorFull ) )
       
   628                         {
       
   629                         iOwner->FepMan()->ClearFlag( CAknFepManager::EFlagEditorFull );
       
   630                         iOwner->FepMan()->TryCloseUiL( );
       
   631                         }
       
   632                     else
       
   633                         {
       
   634                         iOwner->ChangeState( EPredictiveCandidate );
       
   635                         }
       
   636                     }
       
   637                 else
       
   638                     {
       
   639                     iOwner->FepMan()->PhraseCreation( EFalse );
       
   640                     iOwner->FepMan()->EntryPhrase( EFalse );
       
   641                     iOwner->FepMan()->PinyinPhraseCreation( EFalse );
       
   642                     iOwner->FepMan()->EnableKeyStar( ETrue );
       
   643                     iOwner->FepMan()->TryCloseUiL(); //no more keys, close the UI.
       
   644                     }
       
   645                 }
       
   646             else
       
   647                 {
       
   648                 if ( keystrokeArray->Count() != 0 && phrase->Count() >= KMaxPhraseCreationCount )
       
   649                     {
       
   650                     CAknWarningNote* errnote = new( ELeave ) CAknWarningNote();
       
   651                     errnote->SetTone( CAknNoteDialog::EWarningTone );
       
   652                     errnote->ExecuteLD( KMaxPhraseNote );
       
   653                     }
       
   654                 else
       
   655                     {
       
   656                     iOwner->FepMan()->PhraseCreation( EFalse );
       
   657                     iOwner->FepMan()->EntryPhrase( EFalse );
       
   658                     iOwner->FepMan()->PinyinPhraseCreation( EFalse );
       
   659                     iOwner->FepMan()->EnableKeyStar( ETrue );
       
   660                     iOwner->FepMan()->TryCloseUiL(); //no more keys, close the UI.
       
   661                     }
       
   662                 }
       
   663             popup->ResetStrokeArray();
       
   664             }
       
   665         else
       
   666             {
       
   667             editPane->SetCursorIndexOfKeystroke( 0 );
       
   668             if ( CheckFirstGroupStroke() )
       
   669                 {
       
   670                 popup->SetState( ETrue );
       
   671                 iOwner->ChangeState( EEntry );
       
   672                 }
       
   673             else
       
   674                 {
       
   675                 popup->SetState( ETrue );
       
   676                 //change state to sequence edit
       
   677                 iOwner->ChangeState( EStrokeSequenceEdit );
       
   678                 }
       
   679             }
       
   680         }
       
   681     }
       
   682 
       
   683 // ---------------------------------------------------------------------------
       
   684 // TAknFepInputStateCandidateStrokePhrase::CommitInlineEEPL 
       
   685 // Commit phrase to the EEP ctrl.
       
   686 // ---------------------------------------------------------------------------
       
   687 //
       
   688 TBool TAknFepInputStateCandidateStrokePhrase::CommitInlineEEPL( 
       
   689                                                         const TDesC& aText )
       
   690     {
       
   691     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
   692     MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow();
       
   693     CDesCArrayFlat* keystrokeArray = popup->KeystrokeArrayForStroke();
       
   694     CDesCArrayFlat* phrase = popup->ChooseChineseCharacterArrayForStroke();
       
   695     CDesCArrayFlat* phraseKeystroke = 
       
   696         popup->ChooseChineseCharacterArrayKeystrokeForStroke();
       
   697     
       
   698     TBuf<KMaxPhraseCreationCount> phraseCreated;
       
   699     
       
   700     TInt textCount = aText.Length();
       
   701     TInt allTextCount = 0;
       
   702     TInt i = 0;
       
   703     TInt j = 0;
       
   704     // append character to chinese array
       
   705     for ( i = 0; i < textCount; i++ )
       
   706         {
       
   707         phrase->AppendL( aText.Mid( i, 1 ) );
       
   708         }
       
   709     
       
   710     TInt characterCount = phrase->Count();
       
   711     
       
   712     // if chinese character is more than 7 or not
       
   713     // if more than 7 show a warning not
       
   714     if ( characterCount >= KMaxPhraseCreationCount )
       
   715         {
       
   716         for ( i = 0; i < KMaxPhraseCreationCount; ++i )
       
   717             {
       
   718             phraseCreated.Append( phrase->MdcaPoint(i) );
       
   719             }
       
   720         AddPhraseToDB( phraseCreated );
       
   721         iOwner->FepMan()->NewTextL( phraseCreated );
       
   722         iOwner->FepMan()->CommitInlineEditL();
       
   723         }
       
   724     
       
   725     // calculate the total number of character according to stroke
       
   726     for ( i = 0; i < keystrokeArray->Count(); i++ )
       
   727         {
       
   728         if ( keystrokeArray->MdcaPoint( i ) == KDelimiter )
       
   729             {
       
   730             allTextCount = allTextCount + 1;
       
   731             }
       
   732         }
       
   733     
       
   734     allTextCount = allTextCount + 1;
       
   735     if ( keystrokeArray->MdcaPoint( keystrokeArray->Count() - 1 ) ==  
       
   736         KDelimiter )
       
   737         {
       
   738         allTextCount--;
       
   739         }
       
   740     
       
   741     // if total number is less than the character's count which user has selected
       
   742     // commit the character to editor and user db   
       
   743     if ( allTextCount <= textCount && characterCount < KMaxPhraseCreationCount )
       
   744         {
       
   745         for ( i = 0; i < characterCount; ++i )
       
   746             {
       
   747             phraseCreated.Append( phrase->MdcaPoint(i) );
       
   748             } 
       
   749         iOwner->FepMan()->NewTextL( phraseCreated );
       
   750         iOwner->FepMan()->CommitInlineEditL();
       
   751         AddPhraseToDB( phraseCreated );
       
   752         return ETrue;
       
   753         }
       
   754     
       
   755     // add the stroke to chosen character array
       
   756     // delete key stroke which charactor is corresponding
       
   757     for ( j = 0; j < textCount; j++ )
       
   758         {
       
   759         TInt keyCount = 0;
       
   760         TInt ret = keystrokeArray->Find( KDelimiter , 
       
   761                                          keyCount, 
       
   762                                          ECmpFolded );
       
   763         
       
   764         if ( ret != 0)
       
   765             {
       
   766             keyCount = keystrokeArray->Count();
       
   767             j = textCount;
       
   768             }
       
   769         else
       
   770             {
       
   771             keyCount++;
       
   772             }
       
   773 
       
   774         TBuf<KMaxKeystrokeCount> keystroke;
       
   775         for ( i = 0; i < keyCount; i++ )
       
   776             {
       
   777             keystroke.Append( keystrokeArray->MdcaPoint( 0 ) );
       
   778             keystrokeArray->Delete( 0 );
       
   779             }
       
   780         phraseKeystroke->AppendL( keystroke );
       
   781         }    
       
   782     if ( keystrokeArray->Count() > 0 )
       
   783         {
       
   784         iOwner->FepMan()->PhraseCreation( ETrue );
       
   785         }    
       
   786     
       
   787     if ( characterCount >= KMaxPhraseCreationCount )
       
   788         {
       
   789         return ETrue;
       
   790         }
       
   791 
       
   792     return EFalse;
       
   793     }
       
   794 
       
   795 // ---------------------------------------------------------------------------
       
   796 // TAknFepInputStateCandidateStrokePhrase::HandleCommandL
       
   797 // Handling Command
       
   798 // ---------------------------------------------------------------------------
       
   799 //
       
   800 void TAknFepInputStateCandidateStrokePhrase::HandleCommandL( TInt aCommandId )
       
   801     {
       
   802     switch ( aCommandId )
       
   803         {
       
   804         // Handle the event frome command.
       
   805         case EAknSoftkeySelect:
       
   806             //    case (TUint16)EAknSoftkeySelect: //the Selected in soft CBA
       
   807             HandleCommitL();
       
   808             break;
       
   809         default:
       
   810             TAknFepInputStateChineseBase::HandleCommandL( aCommandId );
       
   811             break;
       
   812         }
       
   813     }
       
   814 
       
   815 // End of file