fep/aknfep/src/AknFepUiInputStateEntryStroke.cpp
changeset 40 2cb9bae34d17
parent 31 f1bdd6b078d1
child 49 37f5d84451bd
equal deleted inserted replaced
31:f1bdd6b078d1 40:2cb9bae34d17
     1 /*
       
     2 * Copyright (c) 2002-2004 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 TAknFepInputStateEntryStroke methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 #include <fontids.hrh>
       
    31 #include <PtiEngine.h>
       
    32 
       
    33 #include "AknFepUiInputStateEntryStroke.h"
       
    34 
       
    35 #include "AknFepUIManagerStateInterface.h"
       
    36 
       
    37 #include "AknFepUiCtrlContainerChinese.h"
       
    38 #include "AknFepUICtrlInputPane.h"
       
    39 #include "AknFepUICtrlCandidatePane.h"
       
    40 #include "AknFepManagerUIInterface.h"       //MAknFepManagerUIInterface
       
    41 #include "AknFepManager.h"
       
    42 
       
    43 const TInt KMaxCandidateCountFromCore = 6;
       
    44 
       
    45 TAknFepInputStateEntryStroke::TAknFepInputStateEntryStroke(
       
    46                                 MAknFepUIManagerStateInterface* aOwner,
       
    47                                 MAknFepUICtrlContainerChinese* aUIContainer)
       
    48     :TAknFepInputStateEntryZhuyinStrokeBase(aOwner, aUIContainer)
       
    49     {
       
    50     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
    51     uiContainer->SetLayout(MAknFepUICtrlContainerChinese::ELayoutInput);
       
    52     uiContainer->CandidatePane()->SelectFirst(); 
       
    53     uiContainer->InputPane()->SetOverrideFontId(KScreenFontUidStrokes);
       
    54     uiContainer->CandidatePane()->ShowCandidateOrdinals(EFalse);
       
    55 
       
    56     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    57     if ( EPtiEngineStroke != ptiengine->InputMode() )
       
    58     {
       
    59     ptiengine->SetInputMode(EPtiEngineStroke);
       
    60     }
       
    61     ptiengine->SetCandidatePageLength(MAknFepUICtrlContainerChinese::ELayoutInput);
       
    62     }
       
    63 
       
    64 void TAknFepInputStateEntryStroke::HandleCommandL(TInt /*aCommandId*/)
       
    65 	{	
       
    66     RefreshUI();	
       
    67  	}
       
    68 
       
    69 TBool TAknFepInputStateEntryStroke::HandleKeyL(TInt aKey, TKeyPressLength aLength)
       
    70     {
       
    71     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    72     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
    73     MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane();
       
    74 
       
    75     if(aKey == EKeyBackspace)
       
    76         {
       
    77         if (iOwner->PtiEngine()->DeleteKeyPress().Length())
       
    78             {
       
    79             RefreshUI();
       
    80             SetInputPaneToneMark();
       
    81             }
       
    82         else
       
    83             {
       
    84             iOwner->FepMan()->TryCloseUiL();
       
    85             if (aLength == ELongKeyPress)
       
    86                 {
       
    87                 iOwner->FepMan()->SetLongClearAfterCloseUI(ETrue);
       
    88                 }
       
    89             }
       
    90         }
       
    91     else if((aLength == EShortKeyPress) && iOwner->IsValidChineseInputKey(aKey))
       
    92         {
       
    93     	iOwner->FepMan()->SetCcpuFlag(CAknFepManager::ECcpuStateIgnoreStarUp);        
       
    94        
       
    95         TInt stringBeforeLength(0);
       
    96         TInt stringAfterLength(0);
       
    97         
       
    98         stringBeforeLength = ptiengine->GetPhoneticSpelling(1).Length();
       
    99         stringAfterLength = ptiengine->AppendKeyPress((TPtiKey)aKey).Length();
       
   100         
       
   101         if (stringBeforeLength != stringAfterLength)
       
   102             {
       
   103             TBool multiplePages = ptiengine->MoreCandidatePages();
       
   104             TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length();
       
   105             TBool showHorizontalScrollArrows = multiplePages || bufLength>1;
       
   106 
       
   107             uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows); 
       
   108             uiContainer->ShowVerticalScrollArrows(multiplePages);
       
   109             SetInputPaneToneMark();
       
   110             RefreshUI();
       
   111             }
       
   112         else
       
   113             {            
       
   114             iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
       
   115             }
       
   116         }
       
   117     else if(aKey == EKeyDownArrow)
       
   118         {
       
   119         if (iOwner->PtiEngine()->CandidatePage().Length() == 
       
   120             KMaxCandidateCountFromCore)
       
   121             {
       
   122             ptiengine->NextCandidatePage();
       
   123             RefreshUI();
       
   124             }
       
   125         }
       
   126     else if(aKey == EKeyUpArrow)
       
   127         {
       
   128         if (ptiengine->NumberOfCandidates() != 0)
       
   129             {
       
   130             ptiengine->PreviousCandidatePage();
       
   131             RefreshUI();
       
   132             }
       
   133         }   
       
   134     else if(aKey == EKeyOK || aKey == EKeyRightArrow || aKey == EKeyLeftArrow)
       
   135         {
       
   136         iOwner->ChangeState(ECandidate);
       
   137         return EFalse;
       
   138         }
       
   139         
       
   140     else if(aKey == EPtiKeyStar)
       
   141     	{
       
   142     	return ETrue;
       
   143     	}
       
   144     	
       
   145     else if (!iOwner->IsValidChineseInputKey(aKey))
       
   146         {
       
   147         iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
       
   148         }
       
   149         
       
   150     return ETrue;
       
   151     }
       
   152 
       
   153 void TAknFepInputStateEntryStroke::RefreshUI()
       
   154     {
       
   155     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   156     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
   157     MAknFepUICtrlInputPane* inputPane = uiContainer->InputPane();
       
   158  
       
   159     TBool multiplePages = ptiengine->MoreCandidatePages();
       
   160     TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length();
       
   161     TBool showHorizontalScrollArrows = multiplePages || bufLength>1;
       
   162 
       
   163     uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows); 
       
   164     uiContainer->ShowVerticalScrollArrows(multiplePages);
       
   165 
       
   166     // Universal layout 
       
   167     TPoint baseLine = TPoint(0,0);
       
   168     TInt height = 0;
       
   169     TInt ascent = 0;
       
   170     
       
   171     TRAPD(ret,iOwner->FepMan()->GetScreenCoordinatesL(baseLine,height,ascent));
       
   172     if (ret == KErrNone)
       
   173         {
       
   174         uiContainer->SetContainerPosition(baseLine, height);    
       
   175         }
       
   176     TPtrC candidates = ptiengine->CandidatePage();
       
   177     uiContainer->CandidatePane()->SetCandidateBuffer(candidates);
       
   178     uiContainer->Enable(ETrue);
       
   179 
       
   180     TPtrC ptr = ptiengine->GetPhoneticSpelling(1);
       
   181     inputPane->SetText(ptr);
       
   182     if (ptiengine->NumberOfCandidates() == 0)
       
   183         {
       
   184         uiContainer->CandidatePane()->ShowUpScrollArrows(EFalse);    
       
   185         }
       
   186     else
       
   187         {
       
   188         uiContainer->CandidatePane()->ShowUpScrollArrows(ETrue);    
       
   189         }
       
   190     
       
   191     uiContainer->CandidatePane()->ShowDownScrollArrows
       
   192         (bufLength == KMaxCandidateCountFromCore ? ETrue : EFalse);
       
   193     uiContainer->CandidatePane()->ShowLeftScrollArrows(EFalse);
       
   194     uiContainer->CandidatePane()->ShowRightScrollArrows(bufLength ? ETrue : EFalse);
       
   195     }
       
   196 
       
   197 // End of file