fep/aknfep/src/AknFepUiInputStateCandidateHalfQwertyChinesePhrase.cpp
changeset 0 eb1f2e154e89
child 12 5e18d8c489d6
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     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 Pinyin and Stroke phrase candidate state
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 // System includes
       
    30 #include <PtiEngine.h>   
       
    31 
       
    32 // User includes
       
    33 #include "AknFepUiInputStateCandidateHalfQwertyChinesePhrase.h"
       
    34 #include "AknFepUiInputStateCandidateQwertyBaseChinesePhrase.h"
       
    35 #include "AknFepUiCtrlContainerChinese.h"
       
    36 #include "AknFepManagerUIInterface.h"       //MAknFepManagerUIInterface
       
    37 #include "AknFepUICtrlCandidatePane.h"
       
    38 #include "AknFepUICtrlInputPane.h"
       
    39 #include "AknFepUICtrlPinyinPopup.h"
       
    40 #include "AknFepUIManagerStateInterface.h"  
       
    41 #include "AknFepManager.h" 
       
    42 #include <AknFep.rsg>                 
       
    43 
       
    44 // Constant definition
       
    45 const TInt KMinCandidateCount = 1;
       
    46 //const TInt KInputPaneLength = 32;
       
    47 //_LIT(KSep, "'");
       
    48 //_LIT(KReplace, "");
       
    49 // ---------------------------------------------------------------------------
       
    50 // AknFepUiInputStateCandidateHalfQwertyChinesePhrase::
       
    51 // TAknFepUiInputStateCandidateHalfQwertyChinesePhrase
       
    52 // (other items were commented in a header).
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 TAknFepUiInputStateCandidateHalfQwertyChinesePhrase::
       
    56 TAknFepUiInputStateCandidateHalfQwertyChinesePhrase(MAknFepUIManagerStateInterface* aOwner,
       
    57                                                       MAknFepUICtrlContainerChinese* aUIContainer)
       
    58     :TAknFepInputStateCandidateQwertyBaseChinesePhrase(aOwner, aUIContainer)
       
    59     {
       
    60     iState = ECandidate;
       
    61     MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
       
    62     
       
    63     TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() &&
       
    64                             uiContainer->CandidatePane()->IsFirstPage());
       
    65     TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length();
       
    66     TBool showHorizontalScrollArrows = multiplePages || bufLength > KMinCandidateCount;
       
    67 
       
    68     uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows); 
       
    69     uiContainer->ShowVerticalScrollArrows(multiplePages);
       
    70     uiContainer->FocusCandidatePane(ETrue);
       
    71     uiContainer->CandidatePane()->ShowCandidateOrdinals(ETrue);
       
    72     uiContainer->CandidatePane()->SelectFirstPhrase();
       
    73     UpdateIndicator();
       
    74     }
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // AknFepUiInputStateCandidateMiniQwertyPinyinAndStrokePhrase::HandleKeyL
       
    78 // (other items were commented in a header).
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 TBool TAknFepUiInputStateCandidateHalfQwertyChinesePhrase::HandleKeyL(TInt aKey,
       
    82                                                                     TKeyPressLength aLength)
       
    83     {
       
    84     TInt selected = UIContainer()->CandidatePane()->SelectedIndex();
       
    85     TInt numbertotal = UIContainer()->CandidatePane()->VisibleCandidateCount();
       
    86     MAknFepUICtrlPinyinPopup* popup = UIContainer()->PinyinPopupWindow();
       
    87 
       
    88 
       
    89     if ( aKey != EStdKeyLeftFunc && 
       
    90         (iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed) ||
       
    91         iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagShiftKeyDepressed)))
       
    92         {
       
    93         iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
       
    94         return ETrue;
       
    95         }
       
    96     else if ( aKey == EStdKeyLeftFunc )
       
    97         {
       
    98         iOwner->FepMan()->TryCloseUiL();
       
    99         iOwner->FepMan()->LaunchSelectModeMenuL();
       
   100         }
       
   101     else if ( aKey ==EStdKeySpace)
       
   102         {
       
   103         iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
       
   104         return ETrue;
       
   105         }
       
   106     else if(aKey == EStdKeyBackspace) //clear key
       
   107         {
       
   108         UIContainer()->CandidatePane()->SplitPhraseCandidatesIntoPages();
       
   109         UIContainer()->CandidatePane()->SetCandidateBuffer();
       
   110         iOwner->ChangeState(EEntry);
       
   111         popup->SetChangeState( ETrue );
       
   112         iOwner->FepMan()->UpdateCbaL(R_AKNFEP_SOFTKEYS_OK_SELECT_CANCEL);
       
   113 
       
   114         return ETrue;
       
   115         }   
       
   116     else if(aKey == EStdKeyUpArrow)   //up key
       
   117         {
       
   118         if(UIContainer()->CandidatePane()->IsFirstPage())
       
   119             {
       
   120             if ( EPinyin ==iOwner->FepMan()->InputMode() )
       
   121                 {
       
   122                 iOwner->ChangeState(EEntry);
       
   123                 iOwner->FepMan()->UpdateCbaL(R_AKNFEP_SOFTKEYS_OK_SELECT_CANCEL);
       
   124                 }
       
   125             return ETrue;
       
   126             }
       
   127         else
       
   128             {
       
   129             return TAknFepInputStateCandidateQwertyBaseChinesePhrase::HandleKeyL(aKey, aLength);
       
   130             }   
       
   131         }
       
   132     else if ( aKey == EStdKeyDownArrow )
       
   133         {
       
   134         TBool state = ETrue;
       
   135         if ( popup->IsChangeStatet( ) && aLength == ELongKeyPress )
       
   136             {
       
   137             state = EFalse;
       
   138             }
       
   139         else
       
   140             {
       
   141             popup->SetChangeState( EFalse );
       
   142             }
       
   143         if ( state )
       
   144             {
       
   145             return TAknFepInputStateCandidateQwertyBaseChinesePhrase::HandleKeyL(
       
   146                             aKey, aLength );
       
   147             }
       
   148         }
       
   149     else if (aKey == EStdKeyLeftArrow)//in the same row
       
   150         {
       
   151         if (selected == 0)
       
   152            {
       
   153             UIContainer()->CandidatePane()->SelectIndex(numbertotal-1);
       
   154            }
       
   155         else
       
   156            {
       
   157             UIContainer()->CandidatePane()->SelectIndex(selected - 1);
       
   158            }      
       
   159         return ETrue;   
       
   160         }
       
   161     else if (aKey == EStdKeyRightArrow)//in the same row
       
   162         {
       
   163         if (selected == numbertotal-1)
       
   164             {
       
   165             UIContainer()->CandidatePane()->SelectIndex(0);
       
   166             }
       
   167         else
       
   168             {
       
   169             UIContainer()->CandidatePane()->SelectIndex(selected + 1);
       
   170             }     
       
   171         return ETrue;       
       
   172         } 
       
   173     else if ( aKey == EStdKeyDevice0 || 
       
   174               aKey == EStdKeyDevice3 ||
       
   175               aKey == EStdKeyEnter )//SK1,Select,Enter
       
   176         {
       
   177         TPtrC text = UIContainer()->CandidatePane()->CurrentPhraseCandidate();
       
   178         if(text.Length())
       
   179             {            
       
   180             MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   181             fepMan->NewTextL(text);
       
   182             fepMan->CommitInlineEditL();
       
   183             iOwner->PtiEngine()->SetPredictiveChineseChar(text);
       
   184             if (fepMan->IsFlagSet(CAknFepManager::EFlagEditorFull))
       
   185                 {
       
   186                 fepMan->ClearFlag(CAknFepManager::EFlagEditorFull);
       
   187                 iOwner->FepMan()->TryCloseUiL();
       
   188                 }
       
   189             else
       
   190                 {
       
   191                 iOwner->ChangeState(EPredictiveCandidate);
       
   192                 }
       
   193             }
       
   194         return ETrue;
       
   195         }   
       
   196     else
       
   197         {
       
   198         return TAknFepInputStateCandidateQwertyBaseChinesePhrase::HandleKeyL(aKey, aLength);
       
   199         }  
       
   200         
       
   201     return EFalse;     
       
   202     }
       
   203 
       
   204 // End of file