fep/aknfep/src/AknFepUiInputStatePredictiveCandidateQwertyZhuyin.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 TAknFepInputStatePredictiveCandidateQwertyZhuyin methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 #include "AknFepUiInputStatePredictiveCandidateQwertyZhuyin.h"
       
    31 #include "AknFepUIManagerStateInterface.h"  //MAknFepUIManagerStateInterface
       
    32 #include "AknFepManagerUIInterface.h"       //MAknFepManagerUIInterface
       
    33 #include "AknFepUICtrlCandidatePane.h"
       
    34 #include "AknFepManager.h"                  //FepMan flag
       
    35 
       
    36 #include <PtiEngine.h>                      //CPtiEngine
       
    37 
       
    38 TAknFepInputStatePredictiveCandidateQwertyZhuyin::TAknFepInputStatePredictiveCandidateQwertyZhuyin(
       
    39                                 MAknFepUIManagerStateInterface* aOwner,
       
    40                                 MAknFepUICtrlContainerChinese* aUIContainer)
       
    41     :TAknFepInputStateCandidateQwertyChinese(aOwner, aUIContainer)
       
    42     {
       
    43     iState = EPredictiveCandidate;
       
    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 
       
    56     uiContainer->FocusCandidatePane(ETrue);
       
    57     uiContainer->SetLayout(MAknFepUICtrlContainerChinese::ELayoutCandidate);
       
    58 
       
    59     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    60     uiContainer->CandidatePane()->SelectFirst(); 
       
    61     uiContainer->CandidatePane()->SetCandidateBuffer(ptiengine->CandidatePage());
       
    62 
       
    63     TBool multiplePages = ptiengine->MoreCandidatePages();
       
    64     TInt bufLength = ptiengine->CandidatePage().Length();
       
    65     TBool showHorizontalScrollArrows = multiplePages || bufLength>1;
       
    66     
       
    67     uiContainer->ShowVerticalScrollArrows(multiplePages);
       
    68     uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows);
       
    69     uiContainer->CandidatePane()->ShowCandidateOrdinals(EFalse);
       
    70     UpdateIndicator();
       
    71     }
       
    72 
       
    73 TBool TAknFepInputStatePredictiveCandidateQwertyZhuyin::HandleKeyL(TInt aKey, 
       
    74                                                                    TKeyPressLength aLength)
       
    75     {
       
    76     TBool ret = ETrue;
       
    77     
       
    78     if(aKey == EStdKeyBackspace)
       
    79         {
       
    80         iOwner->FepMan()->TryCloseUiL();
       
    81         }
       
    82     else if(aKey == EStdKeyLeftFunc && aLength == EShortKeyPress)
       
    83         {
       
    84         MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
    85         if (fepMan->IsAbleToLaunchSCT())
       
    86             {
       
    87             fepMan->LaunchSpecialCharacterTableL();
       
    88             }
       
    89         }
       
    90     else if(iOwner->IsQwertyZhuyinToneMarkKey(aKey))
       
    91         {
       
    92         iOwner->FepMan()->TryCloseUiL();
       
    93         return EFalse;
       
    94         }
       
    95     else if(iOwner->IsValidChineseInputKeyQwerty(aKey))
       
    96         {
       
    97         CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    98         // it is needed when we use phrase input engine, otherwise it seems not cleared
       
    99         ptiengine->ClearCurrentWord(); 
       
   100         ptiengine->ResetToneMark();
       
   101 
       
   102         iOwner->ChangeState(EEntry);
       
   103         ret = EFalse; //passes to entry state to handle the key
       
   104         }
       
   105     else if(!HandleVerticalNavigation(aKey))
       
   106         {
       
   107         if (aKey == EStdKeyLeftArrow || aKey == EStdKeyRightArrow)
       
   108             {
       
   109             iOwner->ChangeState(EPredictiveInput);
       
   110             ret = EFalse; //passes to predictive input state to handle the key
       
   111             }
       
   112         else
       
   113             {
       
   114             ret = TAknFepInputStateCandidateQwertyChinese::HandleKeyL(aKey, aLength);
       
   115             }
       
   116         }
       
   117     return ret;
       
   118     }
       
   119 
       
   120 // End of file