fep/aknfep/src/AknFepUiInputStatePredictiveInputQwertyStroke.cpp
changeset 40 2cb9bae34d17
parent 31 f1bdd6b078d1
child 49 37f5d84451bd
equal deleted inserted replaced
31:f1bdd6b078d1 40:2cb9bae34d17
     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 qwertystroke state
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 #include "AknFepUiInputStatePredictiveInputQwertyStroke.h"
       
    30 #include "AknFepUICtrlCandidatePane.h"
       
    31 #include "AknFepUiCtrlContainerChinese.h"
       
    32 #include "AknFepUIManagerStateInterface.h"  //MAknFepUIManagerStateInterface
       
    33 #include "AknFepManagerUIInterface.h"       //MAknFepManagerUIInterface
       
    34 #include "AknFepManager.h"                  //FepMan flag
       
    35 
       
    36 #include <PtiEngine.h>                      //CPtiEngine
       
    37 
       
    38 TAknFepInputStatePredictiveInputQwertyStroke::TAknFepInputStatePredictiveInputQwertyStroke(
       
    39                                 MAknFepUIManagerStateInterface* aOwner,
       
    40                                 MAknFepUICtrlContainerChinese* aUIContainer)
       
    41     :TAknFepInputStateCandidateQwertyChineseBase(aOwner, aUIContainer)
       
    42     {
       
    43     iState = EPredictiveInput;
       
    44     
       
    45     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
    46     // set container window position to follow cursor
       
    47     TPoint baseLine = TPoint(0,0);
       
    48     TInt height = 0;
       
    49     TInt ascent = 0;
       
    50     TRAPD(ret,iOwner->FepMan()->GetScreenCoordinatesL(baseLine,height,ascent));
       
    51     if (ret == KErrNone)
       
    52         {
       
    53         uiContainer->SetContainerPosition(baseLine, height);    
       
    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     uiContainer->CandidatePane()->SetCandidateBuffer(ptiengine->CandidatePage());
       
    66 
       
    67     TBool multiplePages = ptiengine->MoreCandidatePages();
       
    68     TInt bufLength = ptiengine->CandidatePage().Length();
       
    69     TBool showHorizontalScrollArrows = multiplePages || bufLength>1;
       
    70     
       
    71     uiContainer->ShowVerticalScrollArrows(multiplePages);
       
    72     uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows);
       
    73     uiContainer->CandidatePane()->ShowCandidateOrdinals(ETrue);
       
    74     UpdateIndicator();
       
    75     }
       
    76 
       
    77 TBool TAknFepInputStatePredictiveInputQwertyStroke::HandleKeyL(TInt aKey, TKeyPressLength aLength)
       
    78     {
       
    79     TBool ret = ETrue;
       
    80 
       
    81     if (iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode) ||
       
    82         iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed))
       
    83         {
       
    84         iOwner->FepMan()->TryCloseUiL();
       
    85         ret = EFalse;
       
    86         }
       
    87     else if (IsValidEntryKey(aKey))
       
    88         {
       
    89         iOwner->FepMan()->TryCloseUiL();
       
    90         ret = EFalse;
       
    91         }
       
    92     else if(aKey == EStdKeyBackspace)
       
    93         {
       
    94         iOwner->FepMan()->TryCloseUiL();
       
    95         }
       
    96     else if(aKey == EStdKeyLeftFunc && aLength == EShortKeyPress)
       
    97         {
       
    98         MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
    99         if (fepMan->IsAbleToLaunchSCT())
       
   100             {
       
   101             fepMan->LaunchSpecialCharacterTableL();
       
   102             }
       
   103         }
       
   104     else if(iOwner->IsValidChineseInputKeyQwerty(aKey))
       
   105         {
       
   106         CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   107         // it is needed when we use phrase input engine, otherwise it seems not cleared
       
   108         ptiengine->ClearCurrentWord(); 
       
   109         ptiengine->ResetToneMark();
       
   110 
       
   111         iOwner->ChangeState(EEntry);
       
   112         ret = EFalse; //passes to entry state to handle the key
       
   113         }
       
   114     else if(aKey == EStdKeyDevice1)
       
   115         {
       
   116         iOwner->FepMan()->TryCloseUiL();
       
   117         }
       
   118     else
       
   119         {
       
   120         ret = TAknFepInputStateCandidateQwertyChineseBase::HandleKeyL(aKey, aLength);
       
   121         }
       
   122     return ret;
       
   123     }
       
   124 
       
   125 TBool  TAknFepInputStatePredictiveInputQwertyStroke::IsValidEntryKey(TInt aKey)
       
   126     {
       
   127     TBool response = ETrue;
       
   128 
       
   129     if ((aKey >= EPtiKeyQwertyA && aKey <= EPtiKeyQwertyZ) ||
       
   130         (aKey >= EStdKeyLeftArrow && aKey <= EStdKeyDownArrow) ||
       
   131         (aKey >= EPtiKeyQwerty0 && aKey <= EPtiKeyQwerty9) ||
       
   132          aKey == EStdKeyBackspace || aKey == EStdKeyLeftFunc ||
       
   133          aKey == EStdKeyDevice1)
       
   134         {
       
   135         response = EFalse;
       
   136         }
       
   137 
       
   138     return response;
       
   139     }    
       
   140 
       
   141 // ---------------------------------------------------------------------------
       
   142 // TAknFepInputStatePredictiveInputQwertyStroke::HandleCommandL
       
   143 // Handling Command
       
   144 // ---------------------------------------------------------------------------
       
   145 //
       
   146 void TAknFepInputStatePredictiveInputQwertyStroke::HandleCommandL(
       
   147     TInt aCommandId )
       
   148     {
       
   149     TAknFepInputStateChineseBase::HandleCommandL( aCommandId );
       
   150     }
       
   151 // End of file