fep/aknfep/src/AknFepUiInputStateCandidateQwertyBasePhrase.cpp
changeset 36 a7632c26d895
parent 35 0f326f2e628e
child 42 b3eaa440ab06
equal deleted inserted replaced
35:0f326f2e628e 36:a7632c26d895
     1 /*
       
     2 * Copyright (c) 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:           
       
    15 *       Provides the TAknFepInputStateCandidateQwertyBasePhrase methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 #include "AknFepUiInputStateCandidateQwertyBasePhrase.h"
       
    31 
       
    32 #include "AknFepUiCtrlContainerChinese.h"
       
    33 #include "AknFepUICtrlCandidatePane.h"
       
    34 #include "AknFepUIManagerStateInterface.h"  //MAknFepUIManagerStateInterface
       
    35 #include "AknFepManagerUIInterface.h"
       
    36 #include "AknFepManager.h"                  //FepMan flag
       
    37 
       
    38 #include <PtiEngine.h>                      //CPtiEngine
       
    39 
       
    40 TAknFepInputStateCandidateQwertyBasePhrase::TAknFepInputStateCandidateQwertyBasePhrase(
       
    41                                 MAknFepUIManagerStateInterface* aOwner,
       
    42                                 MAknFepUICtrlContainerChinese* aUIContainer)
       
    43     :TAknFepInputStateChineseBase(aOwner, aUIContainer)
       
    44     {
       
    45     }
       
    46 
       
    47 TBool TAknFepInputStateCandidateQwertyBasePhrase::HandleKeyL(TInt aKey, TKeyPressLength /*aLength*/)
       
    48     {
       
    49     if(aKey == EStdKeyDevice1)
       
    50         {
       
    51         iOwner->FepMan()->TryCloseUiL();
       
    52         }
       
    53 
       
    54     else if(!( HandleVerticalNavigation(aKey) || HandleHorizontalNavigation(aKey) ))
       
    55         {
       
    56         // it may be one of the 'valid' numbers..
       
    57         TInt index = MapKeyToIndex(aKey);
       
    58         MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane();
       
    59 
       
    60         if(candidatePane->SelectIndex(index) || aKey == EStdKeyDevice3 || aKey == EStdKeyEnter)
       
    61             {
       
    62             TPtrC text = candidatePane->CurrentPhraseCandidate();
       
    63             if(text.Length())
       
    64                 {            
       
    65                 MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
    66                 fepMan->NewTextL(text);
       
    67                 fepMan->CommitInlineEditL();
       
    68                 iOwner->PtiEngine()->SetPredictiveChineseChar(text);
       
    69                 if (fepMan->IsFlagSet(CAknFepManager::EFlagEditorFull))
       
    70                     {
       
    71                     fepMan->ClearFlag(CAknFepManager::EFlagEditorFull);
       
    72                     iOwner->FepMan()->TryCloseUiL();
       
    73                     }
       
    74                 else
       
    75                     {
       
    76                     iOwner->ChangeState(EPredictiveInput);
       
    77                     }
       
    78                 }
       
    79             else
       
    80                 {
       
    81                 // No candidates available. Back to Entry state.
       
    82                 iOwner->ChangeState(EEntry);
       
    83                 }
       
    84             }
       
    85         }
       
    86 
       
    87     return ETrue;
       
    88     }
       
    89 
       
    90 TBool TAknFepInputStateCandidateQwertyBasePhrase::HandleHorizontalNavigation(TInt aKey)
       
    91     {
       
    92     MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane();
       
    93     TBool response = EFalse;
       
    94 
       
    95     // Do navigation...
       
    96     if (aKey == EStdKeyLeftArrow)
       
    97         {
       
    98         if(!candidatePane->SelectPrev())
       
    99             {
       
   100             candidatePane->PreviousCandidatePage();
       
   101             candidatePane->SetCandidateBuffer();
       
   102             candidatePane->SelectLastPhrase();
       
   103             }
       
   104         response = ETrue;
       
   105         }
       
   106     else if (aKey == EStdKeyRightArrow)
       
   107         {
       
   108         if(!candidatePane->SelectNext())
       
   109             {
       
   110             candidatePane->NextCandidatePage();
       
   111             candidatePane->SetCandidateBuffer();
       
   112             candidatePane->SelectFirstPhrase();
       
   113             }
       
   114         response = ETrue;
       
   115         }
       
   116 
       
   117     return response;
       
   118     }
       
   119 
       
   120 TBool TAknFepInputStateCandidateQwertyBasePhrase::HandleVerticalNavigation(TInt aKey)
       
   121     {
       
   122     MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane();
       
   123     
       
   124     if (aKey == EStdKeyDownArrow || aKey == EStdKeySpace)
       
   125         {
       
   126         candidatePane->NextCandidatePage();
       
   127         }
       
   128     else if (aKey == EStdKeyUpArrow)
       
   129         {
       
   130         candidatePane->PreviousCandidatePage();
       
   131         }
       
   132     else
       
   133         {
       
   134         return EFalse;
       
   135         }
       
   136     candidatePane->SetCandidateBuffer();
       
   137     candidatePane->SelectFirstPhrase();
       
   138 
       
   139     return ETrue;
       
   140     }
       
   141 
       
   142 // ---------------------------------------------------------------------------
       
   143 // TAknFepInputStateCandidateQwertyBasePhrase::HandleCommandL
       
   144 // Handling Command
       
   145 // ---------------------------------------------------------------------------
       
   146 //
       
   147 void TAknFepInputStateCandidateQwertyBasePhrase::HandleCommandL(
       
   148     TInt aCommandId )
       
   149     {
       
   150     TAknFepInputStateChineseBase::HandleCommandL( aCommandId );
       
   151     }
       
   152 // End of file