fep/aknfep/src/AknFepUiInputStateEntryZhuyin.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 CAknFepUIInputStateZhuyin methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 #include "AknFepUiInputStateEntryZhuyin.h"
       
    31 #include "AknFepUIManagerStateInterface.h"
       
    32 
       
    33 #include <PtiEngine.h>
       
    34 
       
    35 #include <e32keys.h>
       
    36 #include <PtiDefs.h>                //keys
       
    37 
       
    38 #include "AknFepUICtrlInputPane.h"
       
    39 #include "AknFepUICtrlCandidatePane.h"
       
    40 #include "AknFepManager.h"
       
    41 
       
    42 const TInt KMaxCandidateCountFromCore = 6;
       
    43 
       
    44 TAknFepInputStateEntryZhuyin::TAknFepInputStateEntryZhuyin(
       
    45                                 MAknFepUIManagerStateInterface* aOwner,
       
    46                                 MAknFepUICtrlContainerChinese* aUIContainer)
       
    47     :TAknFepInputStateEntryZhuyinStrokeBase(aOwner, aUIContainer)
       
    48     {
       
    49     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
    50     uiContainer->SetLayout(MAknFepUICtrlContainerChinese::ELayoutInput);
       
    51     uiContainer->CandidatePane()->SelectFirst(); 
       
    52     uiContainer->InputPane()->SetOverrideFontId(0);
       
    53 
       
    54     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    55     if (EPtiEngineZhuyin != ptiengine->InputMode())
       
    56         {
       
    57         ptiengine->SetInputMode(EPtiEngineZhuyin);
       
    58         }
       
    59     ptiengine->SetCandidatePageLength(MAknFepUICtrlContainerChinese::ELayoutInput);
       
    60     
       
    61     if (ptiengine->NumberOfCandidates() == 0)
       
    62         {
       
    63         uiContainer->CandidatePane()->ShowUpScrollArrows(EFalse);    
       
    64         }
       
    65     else
       
    66         {
       
    67         uiContainer->CandidatePane()->ShowUpScrollArrows(ETrue);    
       
    68         }
       
    69  
       
    70     TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length();
       
    71     uiContainer->CandidatePane()->ShowDownScrollArrows
       
    72         (bufLength == KMaxCandidateCountFromCore ? ETrue : EFalse);
       
    73     uiContainer->CandidatePane()->ShowLeftScrollArrows(EFalse);
       
    74     uiContainer->CandidatePane()->ShowRightScrollArrows(bufLength ? ETrue : EFalse);
       
    75     
       
    76     iUseforResourcechange = EFalse;
       
    77     }
       
    78 void TAknFepInputStateEntryZhuyin::HandleCommandL(TInt /*aCommandId*/)
       
    79 	{	
       
    80     RefreshUI(iUseforResourcechange);	
       
    81  	}
       
    82 TBool TAknFepInputStateEntryZhuyin::HandleKeyL(TInt aKey, TKeyPressLength aLength)
       
    83     {
       
    84    	iOwner->FepMan()->SetCcpuFlag(CAknFepManager::ECcpuStateIgnoreStarUp);        
       
    85     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    86     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
    87             
       
    88     if((aKey == EPtiKeyStar) && (aLength == EShortKeyPress))
       
    89         {
       
    90         ptiengine->CancelTimerActivity();
       
    91 
       
    92         if(ptiengine->IncrementToneMark(ETrue))
       
    93             {
       
    94             uiContainer->ShowVerticalScrollArrows(ptiengine->MoreCandidatePages());
       
    95             SetInputPaneToneMark();
       
    96             iUseforResourcechange = EFalse;
       
    97             RefreshUI(EFalse);
       
    98             }
       
    99         return ETrue;
       
   100         }
       
   101     else if(aKey == EKeyBackspace)
       
   102         {
       
   103 		if (iOwner->PtiEngine()->DeleteKeyPress().Length())
       
   104             {
       
   105             TBool multiplePages = ptiengine->MoreCandidatePages();
       
   106             TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length();
       
   107             TBool showHorizontalScrollArrows = multiplePages || bufLength>1;
       
   108 
       
   109             uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows); 
       
   110             uiContainer->ShowVerticalScrollArrows(multiplePages);
       
   111             iUseforResourcechange = EFalse;
       
   112             RefreshUI(EFalse);
       
   113             SetInputPaneToneMark();
       
   114             }
       
   115         else
       
   116             {
       
   117             iOwner->FepMan()->TryCloseUiL();
       
   118             if (aLength == ELongKeyPress)
       
   119                 {
       
   120                 iOwner->FepMan()->SetLongClearAfterCloseUI(ETrue);
       
   121                 }
       
   122             }
       
   123         return ETrue;    
       
   124         }
       
   125     else if((aLength == EShortKeyPress) && iOwner->IsValidChineseInputKey(aKey))
       
   126         {
       
   127      	iOwner->FepMan()->SetCcpuFlag(CAknFepManager::ECcpuStateIgnoreStarUp);        
       
   128 
       
   129         ptiengine->AppendKeyPress((TPtiKey)aKey);
       
   130         
       
   131         TBool multiplePages = ptiengine->MoreCandidatePages();
       
   132         TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length();
       
   133         TBool showHorizontalScrollArrows = multiplePages || bufLength>1;
       
   134 
       
   135         uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows); 
       
   136         uiContainer->ShowVerticalScrollArrows(multiplePages);
       
   137         SetInputPaneToneMark();
       
   138         iUseforResourcechange = EFalse;
       
   139         RefreshUI(EFalse);
       
   140         return ETrue;
       
   141         }
       
   142     else if(aKey == EKeyDownArrow)
       
   143         {
       
   144         if (iOwner->PtiEngine()->CandidatePage().Length() == 
       
   145             KMaxCandidateCountFromCore)
       
   146             {
       
   147             ptiengine->CancelTimerActivity();
       
   148             ptiengine->NextCandidatePage();
       
   149             iUseforResourcechange = ETrue;
       
   150             RefreshUI(ETrue);
       
   151             }
       
   152         return ETrue;
       
   153         }
       
   154     else if(aKey == EKeyUpArrow)
       
   155         {
       
   156         if (ptiengine->NumberOfCandidates() != 0)
       
   157             {
       
   158             ptiengine->CancelTimerActivity();
       
   159             ptiengine->PreviousCandidatePage();
       
   160             iUseforResourcechange = ETrue;
       
   161             RefreshUI(ETrue);
       
   162             }
       
   163         return ETrue;
       
   164         }   
       
   165     else if(aKey == EKeyOK || aKey == EKeyRightArrow || aKey == EKeyLeftArrow)
       
   166         {
       
   167         ptiengine->CancelTimerActivity();        
       
   168         iOwner->ChangeState(ECandidate);
       
   169         return EFalse;
       
   170         }
       
   171 
       
   172     return TAknFepInputStateEntryZhuyinStrokeBase::HandleKeyL(aKey, aLength);
       
   173     }
       
   174 
       
   175 void TAknFepInputStateEntryZhuyin::KeyTimerExpired()
       
   176     {
       
   177     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   178     TPtrC candidates = ptiengine->CandidatePage();
       
   179     TText toneMark;
       
   180     TBool toneMarkEntered = ptiengine->ToneMark(toneMark);
       
   181     TBool toneMarkValid = ptiengine->IsToneMarkValidForSpelling();
       
   182     if(!candidates.Length() || (toneMarkEntered && !toneMarkValid))
       
   183         {
       
   184         MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
   185         if(toneMarkEntered)
       
   186             {
       
   187             ptiengine->ResetToneMark();
       
   188             if( !candidates.Length() )  
       
   189             	{
       
   190             	ptiengine->DeleteKeyPress();
       
   191             	}
       
   192             }
       
   193         else
       
   194             {
       
   195             ptiengine->DeleteKeyPress();
       
   196             }
       
   197         SetInputPaneToneMark();
       
   198  
       
   199         TBool multiplePages = ptiengine->MoreCandidatePages();
       
   200         TInt bufLength = ptiengine->CandidatePage().Length();
       
   201         TBool showHorizontalScrollArrows = multiplePages || bufLength>1;
       
   202         
       
   203         uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows);
       
   204         uiContainer->ShowVerticalScrollArrows(ptiengine->MoreCandidatePages());
       
   205         RefreshUI(EFalse);
       
   206         }
       
   207     }
       
   208 
       
   209 void TAknFepInputStateEntryZhuyin::RefreshUI(TBool aOrdinals)
       
   210     {
       
   211     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   212     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
   213     MAknFepUICtrlInputPane* inputPane = uiContainer->InputPane();
       
   214 
       
   215     // Universal layout 
       
   216     TPoint baseLine = TPoint(0,0);
       
   217     TInt height = 0;
       
   218     TInt ascent = 0;
       
   219     
       
   220     TRAPD(ret,iOwner->FepMan()->GetScreenCoordinatesL(baseLine,height,ascent));
       
   221     if (ret == KErrNone)
       
   222         {
       
   223         uiContainer->SetContainerPosition(baseLine, height);    
       
   224         }
       
   225 
       
   226     TPtrC candidates = ptiengine->CandidatePage();
       
   227     uiContainer->CandidatePane()->SetCandidateBuffer(candidates);
       
   228     uiContainer->Enable(ETrue);
       
   229     if (aOrdinals)
       
   230         {
       
   231         uiContainer->CandidatePane()->ShowCandidateOrdinals(ETrue);
       
   232         }
       
   233     else
       
   234         {
       
   235         uiContainer->CandidatePane()->ShowCandidateOrdinals(EFalse);
       
   236         }
       
   237 
       
   238     TPtrC ptr = ptiengine->GetPhoneticSpelling(1);
       
   239     inputPane->SetText(ptr);
       
   240 
       
   241     if (ptiengine->NumberOfCandidates() == 0)
       
   242         {
       
   243         uiContainer->CandidatePane()->ShowUpScrollArrows(EFalse);    
       
   244         }
       
   245     else
       
   246         {
       
   247         uiContainer->CandidatePane()->ShowUpScrollArrows(ETrue);    
       
   248         }
       
   249  
       
   250     TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length();
       
   251     uiContainer->CandidatePane()->ShowDownScrollArrows
       
   252         (bufLength == KMaxCandidateCountFromCore ? ETrue : EFalse);
       
   253     uiContainer->CandidatePane()->ShowLeftScrollArrows(EFalse);
       
   254     uiContainer->CandidatePane()->ShowRightScrollArrows(bufLength ? ETrue : EFalse);
       
   255     }
       
   256 
       
   257 // End of file