fep/aknfep/src/AknFepUiInputStatePredictiveCandidateStroke.cpp
changeset 0 eb1f2e154e89
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     1 /*
       
     2 * Copyright (c) 2002 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 TAknFepInputStatePredictiveCandidateStroke methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 #include "AknFepUiInputStatePredictiveCandidateStroke.h"
       
    31 #include "AknFepUIManagerStateInterface.h"  //MAknFepUIManagerStateInterface
       
    32 #include "AknFepManagerUIInterface.h"       //MAknFepManagerUIInterface
       
    33 #include "AknFepUICtrlCandidatePane.h"      //MAknFepUICtrlCandidatePane
       
    34 #include <PtiEngine.h>                      //CPtiEngine
       
    35 
       
    36 TAknFepInputStatePredictiveCandidateStroke::TAknFepInputStatePredictiveCandidateStroke(
       
    37                                 MAknFepUIManagerStateInterface* aOwner,
       
    38                                 MAknFepUICtrlContainerChinese* aUIContainer)
       
    39     :TAknFepInputStateCandidateChinese(aOwner, aUIContainer)
       
    40     {
       
    41     iState = EPredictiveCandidate;
       
    42     
       
    43     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
    44     
       
    45     // set container window position to follow cursor
       
    46     TPoint baseLine = TPoint(0,0);
       
    47     TInt height = 0;
       
    48     TInt ascent = 0;
       
    49     TRAPD(ret,iOwner->FepMan()->GetScreenCoordinatesL(baseLine,height,ascent));
       
    50     if (ret == KErrNone)
       
    51         {
       
    52         uiContainer->SetContainerPosition(baseLine, height);    
       
    53         }
       
    54 
       
    55     uiContainer->FocusCandidatePane(ETrue);
       
    56     uiContainer->SetLayout(MAknFepUICtrlContainerChinese::ELayoutCandidate);
       
    57 
       
    58     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    59     ptiengine->SetCandidatePageLength(MAknFepUICtrlContainerChinese::ELayoutInput);
       
    60 
       
    61     // for some reason needs to feed back to ptiengine current Chinese char just before get the prediction
       
    62     TPtrC text = uiContainer->CandidatePane()->CurrentCandidate();
       
    63     uiContainer->CandidatePane()->SelectFirst(); 
       
    64     ptiengine->SetPredictiveChineseChar(text);
       
    65     
       
    66     uiContainer->CandidatePane()->SetCandidateBuffer(ptiengine->CandidatePage());
       
    67 
       
    68     TBool multiplePages = ptiengine->MoreCandidatePages();
       
    69     TInt bufLength = ptiengine->CandidatePage().Length();
       
    70     TBool showHorizontalScrollArrows = multiplePages || bufLength>1;
       
    71     
       
    72     uiContainer->ShowVerticalScrollArrows(multiplePages);
       
    73     uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows);
       
    74     uiContainer->CandidatePane()->ShowCandidateOrdinals(EFalse);    
       
    75     }
       
    76 
       
    77 TBool TAknFepInputStatePredictiveCandidateStroke::HandleKeyL(TInt aKey, TKeyPressLength aLength)
       
    78     {
       
    79     if (aKey == EPtiKey0 || aKey == EPtiKey7 ||
       
    80         aKey == EPtiKey8 || aKey == EPtiKey9)
       
    81         {
       
    82         iOwner->FepMan()->TryCloseUiL();
       
    83         return EFalse;
       
    84         }
       
    85         
       
    86     TBool ret = ETrue;
       
    87     if(aLength == ELongKeyPress) 
       
    88         {
       
    89         return ret;
       
    90         }
       
    91     if(iOwner->IsValidChineseInputKey(aKey))
       
    92         {
       
    93         CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    94         // it is needed when we use phrase input engine, otherwise it seems not cleared
       
    95         ptiengine->ClearCurrentWord(); 
       
    96         ptiengine->ResetToneMark();
       
    97 
       
    98         iOwner->ChangeState(EEntry);
       
    99         ret = EFalse; //passes to entry state to handle the key
       
   100         }
       
   101         
       
   102     if(!HandleVerticalNavigation(aKey))
       
   103         {
       
   104         if (aKey == EKeyLeftArrow || aKey == EKeyRightArrow || aKey == EKeyOK)
       
   105             {
       
   106             iOwner->ChangeState(EPredictiveInput);
       
   107             ret = EFalse; //passes to predictive input state to handle the key
       
   108             }
       
   109         else if(aKey == EKeyBackspace)
       
   110             {
       
   111             iOwner->FepMan()->TryCloseUiL();
       
   112             }
       
   113         else if (aKey == EPtiKeyStar)
       
   114             {
       
   115             ret = TAknFepInputStateCandidateChinese::HandleKeyL(aKey, aLength);
       
   116             }   
       
   117         }
       
   118     return ret;
       
   119     }