fep/aknfep/src/AknFepUiInputStatePredictiveInputQwerty.cpp
changeset 0 eb1f2e154e89
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     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 TAknFepInputStatePredictiveInputQwerty methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 #include "AknFepUiInputStatePredictiveInputQwerty.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 TAknFepInputStatePredictiveInputQwerty::TAknFepInputStatePredictiveInputQwerty(
       
    40                                 MAknFepUIManagerStateInterface* aOwner,
       
    41                                 MAknFepUICtrlContainerChinese* aUIContainer)
       
    42     :TAknFepInputStateCandidateQwertyChineseBase(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     uiContainer->FocusCandidatePane(ETrue);
       
    57     uiContainer->SetLayout(MAknFepUICtrlContainerChinese::ELayoutCandidate);
       
    58 
       
    59     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    60     ptiengine->SetCandidatePageLength(MAknFepUICtrlContainerChinese::ELayoutInput);
       
    61 
       
    62     // for some reason needs to feed back to ptiengine current Chinese char just before get the prediction
       
    63     TPtrC text = uiContainer->CandidatePane()->CurrentCandidate();
       
    64     uiContainer->CandidatePane()->SelectFirst(); 
       
    65     ptiengine->SetPredictiveChineseChar(text);
       
    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(ETrue);
       
    75     UpdateIndicator();
       
    76     }
       
    77 
       
    78 TBool TAknFepInputStatePredictiveInputQwerty::HandleKeyL(TInt aKey, TKeyPressLength aLength)
       
    79     {
       
    80     TBool ret = ETrue;
       
    81     
       
    82     if(aKey == EStdKeyBackspace)
       
    83         {
       
    84         iOwner->FepMan()->TryCloseUiL();
       
    85         }
       
    86     else if(aKey == EStdKeyLeftFunc && aLength == EShortKeyPress)
       
    87         {
       
    88         MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
    89         if (fepMan->IsAbleToLaunchSCT())
       
    90             {
       
    91             fepMan->LaunchSpecialCharacterTableL();
       
    92             }
       
    93         }
       
    94     else if(iOwner->IsValidChineseInputKeyQwerty(aKey))
       
    95         {
       
    96         CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    97         // it is needed when we use phrase input engine, otherwise it seems not cleared
       
    98         ptiengine->ClearCurrentWord(); 
       
    99         ptiengine->ResetToneMark();
       
   100 
       
   101         iOwner->ChangeState(EEntry);
       
   102         ret = EFalse; //passes to entry state to handle the key
       
   103         }
       
   104     else if(aKey == EStdKeyDevice1)
       
   105         {
       
   106         iOwner->FepMan()->TryCloseUiL();
       
   107         }
       
   108     else 
       
   109         {
       
   110         ret = TAknFepInputStateCandidateQwertyChineseBase::HandleKeyL(aKey, aLength);
       
   111         }
       
   112     return ret;
       
   113     }
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 // TAknFepInputStatePredictiveInputQwerty::HandleCommandL
       
   117 // Handling Command
       
   118 // ---------------------------------------------------------------------------
       
   119 //
       
   120 void TAknFepInputStatePredictiveInputQwerty::HandleCommandL( TInt aCommandId )
       
   121     {
       
   122     TAknFepInputStateChineseBase::HandleCommandL( aCommandId );
       
   123     }
       
   124 // End of file