fep/aknfep/src/AknFepUiInputStateEntryQwertyBase.cpp
changeset 36 a7632c26d895
parent 35 0f326f2e628e
child 42 b3eaa440ab06
equal deleted inserted replaced
35:0f326f2e628e 36:a7632c26d895
     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 TAknFepUIInputStateEntryQwertyBase methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 #include "AknFepUIManagerStateInterface.h"  //MAknFepUIManagerStateInterface
       
    31 #include "AknFepUiCtrlContainerChinese.h"
       
    32 #include "AknFepManagerUIInterface.h"       //MAknFepManagerUIInterface
       
    33 #include "AknFepUICtrlCandidatePane.h"
       
    34 #include "AknFepUICtrlInputPane.h"
       
    35 #include "AknFepUiInputStateEntryQwertyBase.h"
       
    36 
       
    37 #include <PtiEngine.h>      //CPtiEngine
       
    38 #include <e32keys.h>        //keys  
       
    39 #include <avkon.rsg>
       
    40 
       
    41 const TText KPinyinTone4Valid = 0x02D9;
       
    42 const TText KPinyinTone4Invalid = 0x0020;
       
    43 
       
    44 TAknFepInputStateEntryQwertyBase::TAknFepInputStateEntryQwertyBase(
       
    45                                MAknFepUIManagerStateInterface* aOwner,
       
    46                                MAknFepUICtrlContainerChinese* aUIContainer)
       
    47     :TAknFepInputStateCandidateQwerty(aOwner,aUIContainer)                           
       
    48     {
       
    49     iState = EEntry;
       
    50 
       
    51     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
    52     uiContainer->ShowHorizontalScrollArrows(EFalse);
       
    53     uiContainer->FocusCandidatePane(ETrue);
       
    54 
       
    55     MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane();
       
    56     candidatePane->SetHighlighted(ETrue);
       
    57     candidatePane->SelectFirst();
       
    58     uiContainer->SetLayout(MAknFepUICtrlContainerChinese::ELayoutInput);
       
    59     }
       
    60 
       
    61 TBool TAknFepInputStateEntryQwertyBase::HandleKeyL(TInt aKey, TKeyPressLength aLength)
       
    62     {
       
    63     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    64     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
    65     TBool ret = ETrue;
       
    66     
       
    67     if(aKey == EStdKeyBackspace)
       
    68         {
       
    69 		if (iOwner->PtiEngine()->DeleteKeyPress().Length())
       
    70             {
       
    71             TBool multiplePages = ptiengine->MoreCandidatePages();
       
    72             TInt bufLength = ptiengine->CandidatePage().Length();
       
    73             TBool showHorizontalScrollArrows = multiplePages || bufLength>1;
       
    74         
       
    75             UIContainer()->ShowHorizontalScrollArrows(showHorizontalScrollArrows);
       
    76             uiContainer->ShowVerticalScrollArrows(ptiengine->MoreCandidatePages());
       
    77             SetInputPaneToneMark();
       
    78             RefreshUI();
       
    79             }
       
    80         else
       
    81             {
       
    82             iOwner->FepMan()->TryCloseUiL();
       
    83             }
       
    84         }
       
    85     else if((aLength == EShortKeyPress) && iOwner->IsValidChineseInputKeyQwerty(aKey))
       
    86         {
       
    87         ptiengine->AppendKeyPress((TPtiKey)aKey);
       
    88 
       
    89         TBool multiplePages = ptiengine->MoreCandidatePages();
       
    90         TInt bufLength = ptiengine->CandidatePage().Length();
       
    91         TBool showHorizontalScrollArrows = multiplePages || bufLength>1;
       
    92         
       
    93         UIContainer()->ShowHorizontalScrollArrows(showHorizontalScrollArrows);
       
    94         uiContainer->ShowVerticalScrollArrows(ptiengine->MoreCandidatePages());
       
    95         SetInputPaneToneMark();
       
    96         RefreshUI();
       
    97         }
       
    98     else 
       
    99         {
       
   100         ret = TAknFepInputStateCandidateQwertyBase::HandleKeyL(aKey, aLength);
       
   101         }
       
   102     return ret;
       
   103     }
       
   104 
       
   105 void TAknFepInputStateEntryQwertyBase::RefreshUI()
       
   106     {
       
   107     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   108     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
   109     MAknFepUICtrlInputPane* inputPane = uiContainer->InputPane();
       
   110     
       
   111     // set container's position
       
   112     TPoint baseLine = TPoint(0,0);
       
   113     TInt height = 0;
       
   114     TInt ascent = 0;
       
   115     TRAPD(ret,iOwner->FepMan()->GetScreenCoordinatesL(baseLine,height,ascent));
       
   116     if (ret == KErrNone)
       
   117         {
       
   118         uiContainer->SetContainerPosition(baseLine, height);    
       
   119         }
       
   120     
       
   121     TText toneMark;
       
   122     TBool toneMarkEntered = ptiengine->ToneMark(toneMark);
       
   123     TBuf<1> validToneMarkBuf;
       
   124     if(toneMarkEntered)
       
   125         {
       
   126         // override specific invalid tonemark character only, the others are the same character 
       
   127         // when both valid and invalid
       
   128         if(toneMark == KPinyinTone4Invalid)
       
   129             toneMark = KPinyinTone4Valid;
       
   130         validToneMarkBuf.Append(toneMark);
       
   131         }
       
   132     
       
   133     ptiengine->EnableToneMarks(ETrue);
       
   134     TPtrC candidates = ptiengine->CandidatePage();
       
   135     uiContainer->CandidatePane()->SetCandidateBuffer(candidates);
       
   136     uiContainer->Enable(ETrue);
       
   137     uiContainer->CandidatePane()->SelectFirst();
       
   138     TPtrC ptr = ptiengine->GetPhoneticSpelling(1);
       
   139     inputPane->SetText(ptr);
       
   140     inputPane->SetToneMark(validToneMarkBuf);  
       
   141     }
       
   142 
       
   143 void TAknFepInputStateEntryQwertyBase::SetInputPaneToneMark()
       
   144     {
       
   145     }
       
   146 
       
   147 void TAknFepInputStateEntryQwertyBase::InitializeStateL(void)
       
   148     {
       
   149     iOwner->FepMan()->UpdateCbaL(R_AVKON_SOFTKEYS_EMPTY);
       
   150     }
       
   151 
       
   152 // End of file