fep/aknfep/src/AknFepUiInputStatePredictiveCandidateHalfQwertyChinesePhrase.cpp
changeset 40 2cb9bae34d17
parent 31 f1bdd6b078d1
child 49 37f5d84451bd
equal deleted inserted replaced
31:f1bdd6b078d1 40:2cb9bae34d17
     1 /*
       
     2 * Copyright (c) 2007 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 phrase predictive candidate MiniQwerty 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 "AknFepUiInputStatePredictiveCandidateHalfQwertyChinesePhrase.h"
       
    34 #include "AknFepUiCtrlContainerChinese.h"
       
    35 #include "AknFepUIManagerStateInterface.h"  
       
    36 #include "AknFepManagerUIInterface.h" 
       
    37 #include "AknFepManager.h"      
       
    38 #include "AknFepUICtrlCandidatePane.h"
       
    39 #include "aknfepuictrleditpane.h"
       
    40 #include "AknFepUICtrlPinyinPopup.h"
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // TAknFepInputStatePredictiveCandidateMiniQwertyChinesePhrase::
       
    44 // TAknFepInputStatePredictiveCandidateMiniQwertyChinesePhrase
       
    45 // (other items were commented in a header).
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 TAknFepInputStatePredictiveCandidateHalfQwertyChinesePhrase::
       
    49 TAknFepInputStatePredictiveCandidateHalfQwertyChinesePhrase(
       
    50     MAknFepUIManagerStateInterface* aOwner,
       
    51     MAknFepUICtrlContainerChinese* aUIContainer)
       
    52     :TAknFepInputStatePredictiveInputQwertyChinesePhrase(aOwner, aUIContainer)
       
    53     {
       
    54     iState = EPredictiveCandidate;
       
    55     UIContainer()->CandidatePane()->ShowCandidateOrdinals(EFalse);
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // TAknFepInputStatePredictiveCandidateMiniQwertyChinesePhrase::HandleKeyL
       
    60 // (other items were commented in a header).
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 TBool TAknFepInputStatePredictiveCandidateHalfQwertyChinesePhrase::HandleKeyL(
       
    64     TInt aKey, TKeyPressLength aLength )
       
    65     {
       
    66     MAknFepUICtrlPinyinPopup* popup = UIContainer()->PinyinPopupWindow();
       
    67     TBool ret = ETrue;
       
    68 
       
    69     if ( aKey == EPtiKeyQwertyComma || aKey == EStdKeyForwardSlash|| aKey
       
    70         == EStdKeySquareBracketRight )
       
    71         {
       
    72         iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
       
    73         ret = ETrue;
       
    74         }
       
    75     else if ( aKey == EStdKeyFullStop )
       
    76         {
       
    77         iOwner->FepMan()->TryCloseUiL();
       
    78         ret = EFalse;
       
    79         }
       
    80     else if ( aKey == EStdKeyLeftFunc )
       
    81         {
       
    82         iOwner->FepMan()->TryCloseUiL();
       
    83         iOwner->FepMan()->LaunchSelectModeMenuL();
       
    84         }
       
    85     else if ( iOwner->FepMan()->IsFlagSet( CAknFepManager::EFlagQwertyShiftMode )
       
    86         || iOwner->FepMan()->IsFlagSet( CAknFepManager::EFlagQwertyChrKeyDepressed )
       
    87         || iOwner->FepMan()->IsFlagSet( CAknFepManager::EFlagShiftKeyDepressed ) )
       
    88         {
       
    89         iOwner->FepMan()->TryCloseUiL();
       
    90         ret = EFalse;
       
    91         }
       
    92     else if ( CAknFepFnKeyManager::EFnKeyNext == iOwner->FepMan()->FnKeyState() || CAknFepFnKeyManager::EFnKeyLock
       
    93         == iOwner->FepMan()->FnKeyState() || CAknFepFnKeyManager::EFnKeyDown
       
    94         == iOwner->FepMan()->FnKeyState() ) // for fn + a character
       
    95         {
       
    96         iOwner->FepMan()->TryCloseUiL();
       
    97         ret = EFalse;
       
    98         }
       
    99     else if ( aKey ==EKeyLeftCtrl || aKey == EKeyRightCtrl )
       
   100         {
       
   101         iOwner->FepMan()->TryCloseUiL();
       
   102         ret = EFalse;
       
   103         }
       
   104     else if ( aKey == EStdKeyBackspace )
       
   105         {
       
   106         iOwner->FepMan()->TryCloseUiL();
       
   107         }
       
   108     else if ( aKey ==EKeyRightFunc )//fn key
       
   109         {
       
   110         iOwner->FepMan()->TryCloseUiL();
       
   111         ret = EFalse;
       
   112         }
       
   113     else if ( aKey ==EStdKeySpace )
       
   114         {
       
   115         if ( ECangJie ==iOwner->FepMan()->InputMode() )
       
   116             {
       
   117             TPtrC text = UIContainer()->CandidatePane()->CurrentPhraseCandidate();
       
   118             if ( text.Length() )
       
   119                 {
       
   120                 MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   121                 fepMan->NewTextL( text );
       
   122                 fepMan->CommitInlineEditL();
       
   123                 iOwner->PtiEngine()->SetPredictiveChineseChar( text );
       
   124                 if ( fepMan->IsFlagSet( CAknFepManager::EFlagEditorFull ) )
       
   125                     {
       
   126                     fepMan->ClearFlag( CAknFepManager::EFlagEditorFull );
       
   127                     iOwner->FepMan()->TryCloseUiL();
       
   128                     }
       
   129                 else
       
   130                     {
       
   131                     iOwner->ChangeState( EPredictiveCandidate );
       
   132                     }
       
   133                 }
       
   134             return ETrue;
       
   135             }
       
   136         else if ( EZhuyin ==iOwner->FepMan()->InputMode()&&
       
   137         EPtiKeyboardHalfQwerty == iOwner->FepMan()->KeyboardLayout() )
       
   138             {
       
   139             popup->SetPreStateIsPredictive( ETrue );
       
   140             iOwner->ChangeState( EEntry );
       
   141             ret = EFalse;
       
   142             }
       
   143         else
       
   144             {
       
   145             iOwner->FepMan()->TryCloseUiL();
       
   146             ret = EFalse;
       
   147             }
       
   148         }
       
   149     else if ( aKey == EStdKeyDevice0 || aKey == EStdKeyDevice3 || aKey
       
   150         == EStdKeyEnter ) // Add for SK1, selection,enter
       
   151         {
       
   152         TBool state = ETrue;
       
   153         if ( UIContainer()->EditPaneWindow()->IsChangeState() && aLength == ELongKeyPress )
       
   154             {
       
   155             state = EFalse;
       
   156             }
       
   157         else
       
   158             {
       
   159             UIContainer()->EditPaneWindow()->SetChangeState( EFalse );
       
   160             }
       
   161         if ( state )
       
   162             {
       
   163             TPtrC text = UIContainer()->CandidatePane()->CurrentPhraseCandidate();
       
   164             if ( text.Length() )
       
   165                 {
       
   166                 MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   167                 fepMan->NewTextL( text );
       
   168                 fepMan->CommitInlineEditL();
       
   169                 iOwner->PtiEngine()->SetPredictiveChineseChar( text );
       
   170                 if ( fepMan->IsFlagSet( CAknFepManager::EFlagEditorFull ) )
       
   171                     {
       
   172                     fepMan->ClearFlag( CAknFepManager::EFlagEditorFull );
       
   173                     iOwner->FepMan()->TryCloseUiL();
       
   174                     }
       
   175                 else
       
   176                     {
       
   177                     iOwner->ChangeState( EPredictiveCandidate );
       
   178                     }
       
   179                 }
       
   180             }
       
   181         }
       
   182     else if ( aKey == EStdKeyRightArrow )
       
   183         {
       
   184         iOwner->ChangeState( EPredictiveInput );
       
   185         UIContainer()->CandidatePane()->SelectNext();
       
   186         }
       
   187     else if ( aKey == EStdKeyLeftArrow )
       
   188         {
       
   189         iOwner->ChangeState( EPredictiveInput );
       
   190         UIContainer()->CandidatePane()->SelectLastPhrase();
       
   191         }
       
   192     else if ( iOwner->IsValidChineseInputKeyQwerty( aKey ) )
       
   193         {
       
   194         if ( aLength == ELongKeyPress )
       
   195             {
       
   196             TBool state = ETrue;
       
   197             if ( popup->IsChangeStatet() )
       
   198                 {
       
   199                 state = EFalse;
       
   200                 }
       
   201             else
       
   202                 {
       
   203                 popup->SetChangeState( EFalse );
       
   204                 }
       
   205             if ( state )
       
   206                 {
       
   207                 iOwner->FepMan()->TryCloseUiL();
       
   208                 return EFalse;
       
   209                 }
       
   210             else
       
   211                 {
       
   212                 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
       
   213                 return ETrue;
       
   214                 }
       
   215             }
       
   216 
       
   217         if ( EPinyin ==iOwner->FepMan()->InputMode() )
       
   218             {
       
   219             CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   220             // it is needed when we use phrase input engine, otherwise it seems not cleared
       
   221             ptiengine->ClearCurrentWord();
       
   222             ptiengine->ResetToneMark();
       
   223 
       
   224             popup->SetPreStateIsPredictive( ETrue );
       
   225             iOwner->ChangeState( EEntry );
       
   226             ret = EFalse; //passes to entry state to handle the key
       
   227             }
       
   228         else if ( EZhuyin ==iOwner->FepMan()->InputMode() ||
       
   229         ECangJie ==iOwner->FepMan()->InputMode() ||
       
   230         EStroke ==iOwner->FepMan()->InputMode() )
       
   231             {
       
   232             if ( EZhuyin ==iOwner->FepMan()->InputMode() &&
       
   233             ( aKey == EPtiKeyQwertyQ ||
       
   234                 aKey == EPtiKeyQwertyA ||
       
   235                 aKey == EPtiKeyQwertyO ||
       
   236                 aKey == EPtiKeyQwertyL ||
       
   237                 aKey == EPtiKeyQwertyZ ) )
       
   238                 {
       
   239                 iOwner->FepMan()->TryCloseUiL();
       
   240                 return EFalse;
       
   241                 }
       
   242             CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   243             // it is needed when we use phrase input engine, otherwise it seems not cleared
       
   244             ptiengine->ClearCurrentWord();
       
   245             ptiengine->ResetToneMark();
       
   246 
       
   247             popup->SetPreStateIsPredictive( ETrue );
       
   248             iOwner->ChangeState( EEntry );
       
   249             ret = EFalse; //passes to entry state to handle the key
       
   250             }
       
   251         }
       
   252     else if ( aKey == EStdKeyDevice2 )//sk2
       
   253         {
       
   254         iOwner->FepMan()->TryCloseUiL();
       
   255         }
       
   256     else if ( aKey == EPtiKeyQwertyQ ||
       
   257             aKey == EPtiKeyQwertyW ||
       
   258             aKey == EPtiKeyQwertyO ||
       
   259             aKey == EPtiKeyQwertyP ||
       
   260             aKey == EPtiKeyQwertyA ||
       
   261             aKey == EPtiKeyQwertyS ||
       
   262             aKey == EPtiKeyQwertyL ||
       
   263             aKey == EPtiKeyQwertyZ ||
       
   264             aKey == EPtiKeyQwertyX ||
       
   265             aKey == EPtiKeyQwertyC ||
       
   266             aKey == EPtiKeyQwertyV ||
       
   267             aKey == EPtiKeyQwertyB ||
       
   268             aKey == EPtiKeyQwertyN ||
       
   269             aKey == EPtiKeyQwertyM )
       
   270         {
       
   271         if ( EStroke ==iOwner->FepMan()->InputMode() )
       
   272             {
       
   273             iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
       
   274             iOwner->FepMan()->TryCloseUiL();
       
   275             return EFalse;
       
   276             }
       
   277         }
       
   278     else if ( (aKey == EPtiKeyQwerty7 ||
       
   279     		aKey == EPtiKeyQwerty8 ||
       
   280     		aKey == EPtiKeyQwerty9) &&
       
   281     		iOwner->FepMan()->InputMode() == EStroke )
       
   282     	{
       
   283     	if ( aLength == EShortKeyPress )
       
   284     		{
       
   285             iOwner->FepMan()->TryCloseUiL();
       
   286             ret = EFalse;
       
   287             }
       
   288     	}
       
   289     else
       
   290         {
       
   291         ret = TAknFepInputStateCandidateQwertyBaseChinesePhrase::HandleKeyL(
       
   292             aKey, aLength );
       
   293         }
       
   294     return ret;
       
   295     }
       
   296 
       
   297 // End of file