fep/aknfep/src/AknFepUiInputStatePredictiveInputQwertyChinesePhrase.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 predictive input qwerty chinese phrase state
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 #include "AknFepUiInputStatePredictiveInputQwertyChinesePhrase.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 TAknFepInputStatePredictiveInputQwertyChinesePhrase::
       
    40 TAknFepInputStatePredictiveInputQwertyChinesePhrase(
       
    41     MAknFepUIManagerStateInterface* aOwner,
       
    42     MAknFepUICtrlContainerChinese* aUIContainer)
       
    43     :TAknFepInputStateCandidateQwertyBaseChinesePhrase(aOwner, aUIContainer)
       
    44     {
       
    45     iState = EPredictiveInput;
       
    46     
       
    47     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
    48     // set container window position to follow cursor
       
    49     TPoint baseLine = TPoint(0,0);
       
    50     TInt height = 0;
       
    51     TInt ascent = 0;
       
    52     TRAPD(ret,iOwner->FepMan()->GetScreenCoordinatesL(baseLine,height,ascent));
       
    53     if (ret == KErrNone)
       
    54         {
       
    55         uiContainer->SetContainerPosition(baseLine, height);    
       
    56         }
       
    57 
       
    58     uiContainer->FocusCandidatePane(ETrue);
       
    59     uiContainer->SetLayout(MAknFepUICtrlContainerChinese::ELayoutCandidate);
       
    60 
       
    61     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    62     MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane();
       
    63     
       
    64     // for some reason needs to feed back to ptiengine current Chinese phrase just before get the prediction
       
    65     candidatePane->SelectFirstPhrase();
       
    66     if(iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction) ||
       
    67        iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagInsideMultitapInlineEditingTransaction))
       
    68     	{// SetPredictiveChineseChar() should be called just after call fepMan->CommitInlineEditL() usually at some where
       
    69     	TPtrC text = candidatePane->CurrentPhraseCandidate();
       
    70     	ptiengine->SetPredictiveChineseChar(text);
       
    71     	}
       
    72     
       
    73     
       
    74     TRAPD(ignore,ptiengine->GetChinesePhraseCandidatesL(*(candidatePane->CandidateArray())));
       
    75     if (ignore == KErrNone)
       
    76         {
       
    77         candidatePane->SplitPhraseCandidatesIntoPages(); 
       
    78         uiContainer->SetLayout(MAknFepUICtrlContainerChinese::ELayoutCandidate);
       
    79         candidatePane->SetCandidateBuffer();
       
    80 
       
    81         TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() &&
       
    82                                 uiContainer->CandidatePane()->IsFirstPage());
       
    83         TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length();
       
    84         TBool showHorizontalScrollArrows = multiplePages || bufLength>1;
       
    85 
       
    86         uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows); 
       
    87         uiContainer->ShowVerticalScrollArrows(multiplePages);
       
    88         uiContainer->CandidatePane()->ShowCandidateOrdinals(ETrue);
       
    89         UpdateIndicator();
       
    90         }
       
    91     }
       
    92 
       
    93 TBool TAknFepInputStatePredictiveInputQwertyChinesePhrase::HandleKeyL(TInt aKey, 
       
    94                                                                       TKeyPressLength aLength)
       
    95     {
       
    96     TBool ret = ETrue;
       
    97     
       
    98     if(aKey == EStdKeyBackspace)
       
    99         {
       
   100         iOwner->FepMan()->TryCloseUiL();
       
   101         }
       
   102     else if(aKey == EStdKeyLeftFunc && aLength == EShortKeyPress) // launch sct table
       
   103         {
       
   104         MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   105         if (fepMan->IsAbleToLaunchSCT())
       
   106             {
       
   107             fepMan->LaunchSpecialCharacterTableL();
       
   108             }
       
   109         }
       
   110     else if(iOwner->IsValidChineseInputKeyQwerty(aKey))
       
   111         {
       
   112         CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   113         // it is needed when we use phrase input engine, otherwise it seems not cleared
       
   114         ptiengine->ClearCurrentWord(); 
       
   115         ptiengine->ResetToneMark();
       
   116 
       
   117         iOwner->ChangeState(EEntry);
       
   118         ret = EFalse; //passes to entry state to handle the key
       
   119         }
       
   120     else 
       
   121         {
       
   122         ret = TAknFepInputStateCandidateQwertyBaseChinesePhrase::HandleKeyL(aKey, aLength);
       
   123         }
       
   124     return ret;
       
   125     }
       
   126 
       
   127 // End of file