fep/aknfep/src/AknFepUiInputStatePredictiveInputQwertyPhrase.cpp
changeset 40 2cb9bae34d17
parent 31 f1bdd6b078d1
child 49 37f5d84451bd
equal deleted inserted replaced
31:f1bdd6b078d1 40:2cb9bae34d17
     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 TAknFepInputStatePredictiveInputQwertyPhrase methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 #include "AknFepUiInputStatePredictiveInputQwertyPhrase.h"
       
    31 #include "AknFepUICtrlCandidatePane.h"
       
    32 #include "AknFepUiCtrlContainerChinese.h"
       
    33 #include "AknFepUIManagerStateInterface.h"  //MAknFepUIManagerStateInterface
       
    34 #include "AknFepManagerUIInterface.h"       //MAknFepManagerUIInterface
       
    35 #include "AknFepManager.h"                  //FepMan flag
       
    36 
       
    37 #include <PtiEngine.h>                      //CPtiEngine
       
    38 
       
    39 TAknFepInputStatePredictiveInputQwertyPhrase::TAknFepInputStatePredictiveInputQwertyPhrase(
       
    40                                 MAknFepUIManagerStateInterface* aOwner,
       
    41                                 MAknFepUICtrlContainerChinese* aUIContainer)
       
    42     :TAknFepInputStateCandidateQwertyBasePhrase(aOwner, aUIContainer)
       
    43     {
       
    44     iState = EPredictiveInput;
       
    45     
       
    46     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
    47     // set container window position to follow cursor
       
    48     TPoint baseLine = TPoint(0,0);
       
    49     TInt height = 0;
       
    50     TInt ascent = 0;
       
    51     TRAPD(ret,iOwner->FepMan()->GetScreenCoordinatesL(baseLine,height,ascent));
       
    52     if (ret == KErrNone)
       
    53         {
       
    54         uiContainer->SetContainerPosition(baseLine, height);    
       
    55         }
       
    56 
       
    57     uiContainer->FocusCandidatePane(ETrue);
       
    58     uiContainer->SetLayout(MAknFepUICtrlContainerChinese::ELayoutCandidate);
       
    59 
       
    60     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    61     MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane();
       
    62     // for some reason needs to feed back to ptiengine current Chinese phrase just before get the prediction
       
    63     TPtrC text = candidatePane->CurrentPhraseCandidate();
       
    64     candidatePane->SelectFirstPhrase(); 
       
    65     ptiengine->SetPredictiveChineseChar(text);
       
    66     
       
    67     TRAPD(ignore,ptiengine->GetChinesePhraseCandidatesL(*(candidatePane->CandidateArray())));
       
    68     if (ignore == KErrNone)
       
    69         {
       
    70         candidatePane->SplitPhraseCandidatesIntoPages(); 
       
    71         uiContainer->SetLayout(MAknFepUICtrlContainerChinese::ELayoutCandidate);
       
    72         candidatePane->SetCandidateBuffer();
       
    73 
       
    74         TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() &&
       
    75                                 uiContainer->CandidatePane()->IsFirstPage());
       
    76         TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length();
       
    77         TBool showHorizontalScrollArrows = multiplePages || bufLength>1;
       
    78 
       
    79         uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows); 
       
    80         uiContainer->ShowVerticalScrollArrows(multiplePages);
       
    81         uiContainer->CandidatePane()->ShowCandidateOrdinals(ETrue);
       
    82         }
       
    83     }
       
    84 
       
    85 TBool TAknFepInputStatePredictiveInputQwertyPhrase::HandleKeyL(TInt aKey, TKeyPressLength aLength)
       
    86     {
       
    87     TBool ret = ETrue;
       
    88     
       
    89     if(aKey == EStdKeyBackspace)
       
    90         {
       
    91         iOwner->FepMan()->TryCloseUiL();
       
    92         }
       
    93     else if(aKey == EStdKeyLeftFunc && aLength == EShortKeyPress) // launch sct table
       
    94         {
       
    95         MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
    96         if (fepMan->IsAbleToLaunchSCT())
       
    97             {
       
    98             fepMan->LaunchSpecialCharacterTableL();
       
    99             }
       
   100         }
       
   101     else if(iOwner->IsValidChineseInputKeyQwerty(aKey))
       
   102         {
       
   103         CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   104         // it is needed when we use phrase input engine, otherwise it seems not cleared
       
   105         ptiengine->ClearCurrentWord(); 
       
   106         ptiengine->ResetToneMark();
       
   107 
       
   108         iOwner->ChangeState(EEntry);
       
   109         ret = EFalse; //passes to entry state to handle the key
       
   110         }
       
   111     else 
       
   112         {
       
   113         ret = TAknFepInputStateCandidateQwertyBasePhrase::HandleKeyL(aKey, aLength);
       
   114         }
       
   115     return ret;
       
   116     }
       
   117 
       
   118 // End of file