fep/aknfep/src/AknFepUiInputStateZhuyinFindQwerty.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 TAknFepInputStateZhuyinFindQwerty methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 #include "AknFepUiInputStateZhuyinFindQwerty.h"
       
    31 #include "AknFepUIManagerStateInterface.h"
       
    32 #include "AknFepCaseManager.h"
       
    33 
       
    34 #include <e32keys.h>
       
    35 #include <PtiEngine.h>
       
    36 #include <PtiDefs.h>                //keys
       
    37 
       
    38 TAknFepInputStateZhuyinFindQwerty::TAknFepInputStateZhuyinFindQwerty(
       
    39         MAknFepUIManagerStateInterface* aOwner,
       
    40         MAknFepUICtrlContainerChinese* aUIContainer) :
       
    41     TAknFepInputStateChineseFindQwerty(aOwner, aUIContainer)
       
    42     {
       
    43     iOwner->PtiEngine()->SetInputMode(EPtiEngineZhuyinQwerty);
       
    44     }
       
    45 
       
    46 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
    47 TAknFepInputStateZhuyinFindMiniQwerty::TAknFepInputStateZhuyinFindMiniQwerty(
       
    48         MAknFepUIManagerStateInterface* aOwner, TInt aMode) :
       
    49     TAknFepInputStateInitialChineseGenericQwerty(aOwner, aMode)
       
    50     {
       
    51     iState = EInitial;
       
    52     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    53 
       
    54     ptiengine->SetInputMode(EPtiEngineInputModeZhuyinMiniQwertyFind);
       
    55     ptiengine->SetKeyboardType(iOwner->FepMan()->KeyboardLayout());
       
    56 
       
    57     }
       
    58 
       
    59 TBool TAknFepInputStateZhuyinFindMiniQwerty::HandleKeyL(TInt aKey,
       
    60         TKeyPressLength aLength)
       
    61     {
       
    62     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
    63     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    64     TBool ret = EFalse;
       
    65 
       
    66     if (iData != aKey)
       
    67         {
       
    68         fepMan->CommitInlineEditL();
       
    69         ptiengine->ClearCurrentWord();
       
    70         CAknFepCaseManager* caseMan = iOwner->CaseMan();
       
    71         caseMan->UpdateCase(ENullNaviEvent);
       
    72         }
       
    73 
       
    74     iData = aKey;
       
    75     if ( aLength == EShortKeyPress && CAknFepFnKeyManager::EFnKeyNone
       
    76         == iOwner->FepMan()->FnKeyState() && (!fepMan->IsFlagSet(
       
    77         CAknFepManager::EFlagQwertyShiftMode
       
    78             | CAknFepManager::EFlagShiftKeyDepressed )) )
       
    79         {
       
    80         if (ptiengine->InputMode()!= EPtiEngineInputModeZhuyinMiniQwertyFind)
       
    81             {
       
    82             ptiengine->SetInputMode(EPtiEngineInputModeZhuyinMiniQwertyFind);
       
    83             }
       
    84         switch (aKey)
       
    85             {
       
    86             case EPtiKeyQwerty1:
       
    87                 aKey = EPtiKeyQwertyQ;
       
    88                 break;
       
    89             case EPtiKeyQwerty2:
       
    90                 aKey = EPtiKeyQwertyW;
       
    91                 break;
       
    92             case EPtiKeyQwerty3:
       
    93                 aKey = EPtiKeyQwertyE;
       
    94                 break;
       
    95             case EPtiKeyQwerty4:
       
    96                 aKey = EPtiKeyQwertyR;
       
    97                 break;
       
    98             case EPtiKeyQwerty5:
       
    99                 aKey = EPtiKeyQwertyT;
       
   100                 break;
       
   101             case EPtiKeyQwerty6:
       
   102                 aKey = EPtiKeyQwertyY;
       
   103                 break;
       
   104             case EPtiKeyQwerty7:
       
   105                 aKey = EPtiKeyQwertyU;
       
   106                 break;
       
   107             case EPtiKeyQwerty8:
       
   108                 aKey = EPtiKeyQwertyI;
       
   109                 break;
       
   110             case EPtiKeyQwerty9:
       
   111                 aKey = EPtiKeyQwertyO;
       
   112                 break;
       
   113             case EPtiKeyQwerty0:
       
   114                 aKey = EPtiKeyQwertyP;
       
   115                 break;
       
   116             default:
       
   117                 break;
       
   118             }
       
   119 
       
   120         if (aKey == EPtiKeyQwertyE || aKey == EPtiKeyQwertyR || aKey
       
   121                 == EPtiKeyQwertyY || aKey == EPtiKeyQwertyU)
       
   122             {
       
   123             ret= ETrue;
       
   124             }
       
   125         else if (iOwner->IsValidChineseInputKeyQwerty(aKey) )
       
   126             {
       
   127         	HandleCaseChange(aKey, ETrue);
       
   128             TPtrC text = ptiengine->AppendKeyPress((TPtiKey)aKey);
       
   129             if (text.Length())
       
   130                 {
       
   131                 fepMan->NewCharacterL(text);
       
   132                 ret = ETrue;
       
   133                 }
       
   134             }
       
   135         else if (aKey == EStdKeyBackspace)
       
   136             {
       
   137             iOwner->PtiEngine()->DeleteKeyPress();
       
   138             }
       
   139         else if ( EPtiKeyQwertyComma == aKey )
       
   140         	{
       
   141         		//show the width comma 
       
   142             TPtrC text = ptiengine->AppendKeyPress((TPtiKey)aKey);
       
   143             if (text.Length())
       
   144                 {
       
   145                 fepMan->NewCharacterL(text);
       
   146                 ret = ETrue;
       
   147                 }
       
   148         	}
       
   149         }
       
   150     else
       
   151         {
       
   152         ptiengine->SetInputMode( EPtiEngineZhuyinPhraseQwerty );
       
   153         ptiengine->ClearCurrentWord();        
       
   154         if ( !fepMan->IsFlagSet( CAknFepManager::EFlagQwertyShiftMode
       
   155             | CAknFepManager::EFlagShiftKeyDepressed ) )
       
   156             {
       
   157             // the case for Fn mode
       
   158             fepMan->SetFnKeyState( CAknFepFnKeyManager::EFnKeyNext );
       
   159             }
       
   160         ret = TAknFepInputStateInitialChineseGenericQwerty::HandleKeyL( aKey,
       
   161             aLength );
       
   162         }
       
   163     return ret;
       
   164     }
       
   165 
       
   166 void TAknFepInputStateZhuyinFindMiniQwerty::KeyTimerExpired()
       
   167     {
       
   168 
       
   169     if (iData)
       
   170         {
       
   171         MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   172         TRAP_IGNORE(fepMan->CommitInlineEditL())
       
   173 
       
   174         CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   175         ptiengine->ClearCurrentWord();
       
   176 
       
   177         fepMan->ClearFlag(CAknFepManager::EFlagInsideMultitapInlineEditingTransaction);
       
   178         }
       
   179 
       
   180     }
       
   181 
       
   182 #ifdef __HALF_QWERTY_KEYPAD
       
   183 
       
   184 TAknFepInputStateZhuyinFindHalfQwerty::TAknFepInputStateZhuyinFindHalfQwerty(
       
   185         MAknFepUIManagerStateInterface* aOwner, TInt aMode) :
       
   186     TAknFepInputStateInitialChineseGenericHalfQwerty(aOwner, aMode)
       
   187     {
       
   188     iState = EInitial;
       
   189     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   190 
       
   191     ptiengine->SetInputMode(EPtiEngineZhuyinPhraseHalfQwerty);
       
   192     ptiengine->SetKeyboardType(iOwner->FepMan()->KeyboardLayout());
       
   193 
       
   194     }
       
   195 
       
   196 TBool TAknFepInputStateZhuyinFindHalfQwerty::HandleKeyL(TInt aKey,
       
   197         TKeyPressLength aLength)
       
   198     {
       
   199     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   200     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   201     TBool ret = EFalse;
       
   202 
       
   203     if (iData && (iData != aKey))
       
   204         {
       
   205         fepMan->CommitInlineEditL();
       
   206         ptiengine->ClearCurrentWord();
       
   207         fepMan->ClearFlag(
       
   208                 CAknFepManager::EFlagInsideMultitapInlineEditingTransaction);
       
   209         iOwner->CaseMan()->UpdateCase(ENullNaviEvent);
       
   210         }
       
   211 
       
   212     iData = aKey;
       
   213     
       
   214     if (IsValidZhuyinKey(aKey) && CAknFepFnKeyManager::EFnKeyNone
       
   215 			== iOwner->FepMan()->FnKeyState() && aLength == EShortKeyPress )
       
   216 		{
       
   217 		TPtrC text;
       
   218 		switch (aKey)
       
   219 			{
       
   220 			case EPtiKeyQwertyE:
       
   221 				aKey = EPtiKey1;
       
   222 				break;
       
   223 			case EPtiKeyQwertyT:
       
   224                 aKey = EPtiKey2;
       
   225                 break;
       
   226             case EPtiKeyQwertyU:
       
   227                 aKey = EPtiKey3;
       
   228                 break;
       
   229             case EPtiKeyQwertyD:
       
   230                 aKey = EPtiKey4;
       
   231                 break;
       
   232             case EPtiKeyQwertyG:
       
   233                 aKey = EPtiKey5;
       
   234                 break;
       
   235             case EPtiKeyQwertyJ:
       
   236                 aKey = EPtiKey6;
       
   237                 break;
       
   238             case EPtiKeyQwertyC:
       
   239                 aKey = EPtiKey7;
       
   240                 break;
       
   241             case EPtiKeyQwertyB:
       
   242                 aKey = EPtiKey8;
       
   243                 break;
       
   244             case EPtiKeyQwertyM:
       
   245                 aKey = EPtiKey9;
       
   246                 break;
       
   247             case EPtiKeyQwertySpace:
       
   248                 aKey = EPtiKey0;
       
   249                 break;
       
   250 			default:
       
   251 				break;
       
   252 			}
       
   253 			ptiengine->SetCase(EPtiCaseLower);
       
   254 			ptiengine->SetInputMode(EPtiEngineZhuyinPhraseHalfQwerty);
       
   255 			text.Set(ptiengine->AppendKeyPress((TPtiKey)aKey));
       
   256 			if (text.Length())
       
   257 				{
       
   258 				fepMan->StartInlineEditL();
       
   259 				fepMan->UpdateInlineEditL(text,0);
       
   260 				fepMan->CommitInlineEditL();
       
   261 				ret = ETrue;
       
   262 				}
       
   263 			}
       
   264     else if ( IsValidZhuyinKey(aKey) && aLength == ELongKeyPress)
       
   265     	{
       
   266     	TPtrC text;
       
   267         TBuf<5> allFnMappedCharacters;
       
   268         ptiengine->MappingDataForKey((TPtiKey)aKey, allFnMappedCharacters, EPtiCaseFnLower);
       
   269         text.Set(allFnMappedCharacters);
       
   270         if (text.Length())
       
   271         	{
       
   272         	TBuf<1> chr;   
       
   273             chr.Append( text[0] );
       
   274             fepMan->RemovePreviousCharacterL();
       
   275             fepMan->NewCharacterL(chr);
       
   276             fepMan->CommitInlineEditL();      
       
   277             ptiengine->ClearCurrentWord();                
       
   278             iData = 0;
       
   279         	}                                 
       
   280         ret = ETrue;
       
   281     	}
       
   282     else if (IsValidZhuyinKey(aKey) && aLength == ELongKeyPress
       
   283             && CAknFepFnKeyManager::EFnKeyLock
       
   284                     != iOwner->FepMan()->FnKeyState())
       
   285         {
       
   286         ret = EFalse;
       
   287         }
       
   288     else if (fepMan->EditorHasFreeSpace())
       
   289         {
       
   290         TPtiTextCase caseMode = ptiengine->Case();
       
   291         if (ptiengine->InputMode() != EPtiEngineHalfQwerty)
       
   292             {
       
   293             ptiengine->ClearCurrentWord();
       
   294             ptiengine->SetInputMode(EPtiEngineHalfQwerty);
       
   295             }
       
   296         ptiengine->SetCase(caseMode);
       
   297 
       
   298         ret = TAknFepInputStateInitialChineseGenericHalfQwerty::HandleKeyL(
       
   299                 aKey, aLength);          
       
   300         }
       
   301     return ret;
       
   302     }
       
   303 
       
   304 // ---------------------------------------------------------------------------
       
   305 // TAknFepInputStateZhuyinFindHalfQwerty::KeyTimerExpired
       
   306 // 
       
   307 // Functions from MPtiObserver interface
       
   308 // ---------------------------------------------------------------------------
       
   309 //
       
   310 void TAknFepInputStateZhuyinFindHalfQwerty::KeyTimerExpired()
       
   311     {
       
   312     if (iData)
       
   313         {
       
   314         MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   315         if (fepMan->EditorHasFreeSpace())
       
   316             {
       
   317                 TRAP_IGNORE(fepMan->CommitInlineEditL())
       
   318             }
       
   319         CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   320         ptiengine->ClearCurrentWord();
       
   321 
       
   322         fepMan->ClearFlag(
       
   323                 CAknFepManager::EFlagInsideMultitapInlineEditingTransaction);
       
   324         CAknFepFnKeyManager::TFnKeyState fnKeyState = fepMan->FnKeyState();
       
   325         if ( !fepMan->IsFlagSet(CAknFepManager::EFlagLongShiftKeyPress) )
       
   326             {
       
   327             if (fnKeyState == CAknFepFnKeyManager::EFnKeyNext)
       
   328                 fepMan->SetFnKeyState(CAknFepFnKeyManager::EFnKeyNone);
       
   329             }
       
   330         }
       
   331     }
       
   332 
       
   333 TBool TAknFepInputStateZhuyinFindHalfQwerty::IsValidZhuyinKey(TInt aKey)
       
   334     {
       
   335     if (aKey == EPtiKeyQwertyE|| aKey == EPtiKeyQwertyT|| aKey
       
   336             == EPtiKeyQwertyU|| aKey == EPtiKeyQwertyD|| aKey
       
   337             == EPtiKeyQwertyG|| aKey == EPtiKeyQwertyJ|| aKey
       
   338             == EPtiKeyQwertyC|| aKey == EPtiKeyQwertyB|| aKey
       
   339             == EPtiKeyQwertyM|| aKey == EPtiKeyQwertySpace)
       
   340         {
       
   341         return ETrue;
       
   342         }
       
   343     else
       
   344         {
       
   345         return EFalse;
       
   346         }
       
   347 
       
   348     }
       
   349 #endif //__HALF_QWERTY_KEYPAD
       
   350 
       
   351 #endif //RD_INTELLIGENT_TEXT_INPUT
       
   352 // End of file