fep/aknfep/src/AknFepUiInputStateEntryQwertyWesternPredictive.cpp
branchRCL_3
changeset 44 ecbabf52600f
child 46 bd83ceabce89
equal deleted inserted replaced
43:ebd48d2de13c 44:ecbabf52600f
       
     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:           
       
    15 *       Provides the TAknFepInputStateEntryQwertyWesternPredictive methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 #include "AknFepUiInputStateEntryQwertyWesternPredictive.h"
       
    31 #include "AknFepUIManagerStateInterface.h"      //MAknFepUIManagerStateInterface
       
    32 #include "AknFepManagerUIInterface.h"           //MAknFepManagerUIInterface
       
    33 #include "AknFepUiManagerWestern.h"
       
    34 #include "AknFepManager.h"
       
    35 #include "AknFepPanic.h"
       
    36 #include "AknFepCaseManager.h"
       
    37 #include "AknFepPluginManager.h"
       
    38 
       
    39 #include <PtiEngine.h>              //CPtiEngine
       
    40 #include <PtiDefs.h>                //keys
       
    41 #include <PtiCompositionDataIF.h>   //MPtiEngineCompositionDataInterface
       
    42 #include <featmgr.h>                //FeatureManager
       
    43 #include <e32keys.h>
       
    44 #include <aknfep.rsg>
       
    45 
       
    46 
       
    47 static const TInt KKeyMappingsLength = 63;
       
    48 
       
    49 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
       
    50 //
       
    51 TAknFepInputStateEntryQwertyWesternPredictive::
       
    52 TAknFepInputStateEntryQwertyWesternPredictive(MAknFepUIManagerStateInterface* aOwner)
       
    53     :TAknFepInputStateBase(aOwner)
       
    54     {
       
    55     //this class insists on the existence of a case manager
       
    56     __ASSERT_DEBUG(iOwner->CaseMan(), AknFepPanic(EAknFepPanicNoCaseManager));
       
    57 
       
    58     iState = EEntry;
       
    59     iMatchState = EWordMatchNone;
       
    60     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    61     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
    62 
       
    63     TPtiTextCase caseMode = ptiengine->Case();
       
    64 
       
    65     ptiengine->SetInputMode(EPtiEngineQwertyPredictive );    
       
    66     ptiengine->SetCase(caseMode);
       
    67     TBool isUnlimitedEditor = EFalse;
       
    68     ptiengine->SetMaxLengthForAutoCompletedCandidates(
       
    69               fepMan->EditorFreeSpaceForAutoWordCompletion(isUnlimitedEditor ));
       
    70     
       
    71 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
    72     if(fepMan->IsAutoCompleteOn())
       
    73     {
       
    74 	    TRAP_IGNORE(ptiengine->HandleCommandL( EPtiCommandEnableAutoCompletion ));
       
    75     }
       
    76     else
       
    77     {
       
    78 	    TRAP_IGNORE(ptiengine->HandleCommandL( EPtiCommandDisableAutoCompletion ));
       
    79     }
       
    80     TPtiErrorCorrectionLevel correctionLevel = 
       
    81                     (TPtiErrorCorrectionLevel)fepMan->AdvancedPredictiveTypingCorrectionLevel();
       
    82     TRAP_IGNORE(ptiengine->HandleCommandL( EPtiCommandSetCorrectionLevel, 
       
    83                                           &correctionLevel ));	
       
    84 	
       
    85     TPtiKeyboardType keyboard = fepMan->KeyboardLayout();
       
    86     ptiengine->SetKeyboardType(keyboard);
       
    87 	
       
    88     TBool isNumberCandidateShown = fepMan->IsAdvancedPredictiveNumberCandidateShown();
       
    89     TRAP_IGNORE(ptiengine->HandleCommandL( EPtiCommandSetNumberCandidateStatus, 
       
    90                                           &isNumberCandidateShown ));
       
    91 	
       
    92     TBool primaryCandidateState = fepMan->AdvancedPredictivePrimaryCandidate();
       
    93     TRAP_IGNORE(ptiengine->HandleCommandL( EPtiCommandSetProactiveCorrection, 
       
    94                                           &primaryCandidateState ));
       
    95 #endif //RD_INTELLIGENT_TEXT_INPUT
       
    96     }
       
    97 
       
    98 
       
    99 ///////////////////////////////////////////////////////////////////////////////////////////////////
       
   100 //
       
   101 TBool TAknFepInputStateEntryQwertyWesternPredictive::HandleKeyL(TInt aKey, TKeyPressLength aLength)
       
   102     {
       
   103     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   104     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   105     CAknFepFnKeyManager::TFnKeyState fnKeyState  = fepMan->FnKeyState();
       
   106 	if(fnKeyState  != CAknFepFnKeyManager::EFnKeyNone)
       
   107 		{
       
   108 		ptiengine->SetCase(EPtiCaseFnLower);
       
   109 		}
       
   110 
       
   111     // Handle the Chr cycling
       
   112     if ( fepMan->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed) )
       
   113         {
       
   114         if ( iData && (iData != aKey) )
       
   115             {
       
   116             // Chr key is still pressed down but character key was changed from previous one
       
   117             // to new one. The previous character is committed and PtiEngine starts 
       
   118             // prosessing new key.
       
   119             ptiengine->CancelTimerActivity();
       
   120             
       
   121             if ( !fepMan->EditorHasFreeSpace() )
       
   122                 {
       
   123                 return EFalse;
       
   124                 }
       
   125             }
       
   126         fepMan->SetFlag( CAknFepManager::EFlagInsideMultitapInlineEditingTransaction );
       
   127         }
       
   128 
       
   129     TBool response = EFalse;
       
   130 
       
   131 
       
   132     // Handle dead keys with space or backspace. These keys are not mapped in PtiEngine, so they cannot
       
   133     // be handled there.
       
   134     if ( ptiengine->HandleCommandL(EPtiCommandDeadKeyWaiting) == 1 )
       
   135         {
       
   136         if ( aKey == EStdKeyBackspace )
       
   137             {
       
   138             // Pending dead key is removed with backspace. No other characters are removed.
       
   139             ptiengine->HandleCommandL(EPtiCommandGetAndClearDeadKeyRootChar);
       
   140             response = ETrue;
       
   141             }
       
   142         else if ( aKey == EStdKeySpace )
       
   143             {
       
   144             // Dead key followed by space enters the dead key root character
       
   145             TText deadRoot = ptiengine->HandleCommandL(EPtiCommandGetAndClearDeadKeyRootChar);
       
   146             ptiengine->HandleCommandL( EPtiCommandAppendCharacter, &deadRoot );
       
   147             
       
   148             TPtrC newText = ptiengine->CurrentWord();
       
   149             fepMan->UpdateInlineEditL( newText, newText.Length() );
       
   150             iOwner->CaseMan()->UpdateCase(ENullNaviEvent);
       
   151             
       
   152             response = ETrue;
       
   153             }
       
   154         }		    
       
   155 
       
   156     if (!response) // key not yet handled
       
   157         {
       
   158         switch (aKey)
       
   159             {
       
   160             case EStdKeySpace: //fall through
       
   161             case EStdKeyEnter:
       
   162             case EStdKeyTab:
       
   163             case EStdKeyLeftArrow:
       
   164             case EStdKeyRightArrow:
       
   165             case EStdKeyUpArrow:
       
   166             case EStdKeyDownArrow:
       
   167                 response = HandleWordBreakingKeysL(aKey);
       
   168                 break;
       
   169                 
       
   170             // Long press of shift key start copy event.     
       
   171             // Its should handle by framework.    
       
   172             case EStdKeyF21:
       
   173             case EKeyF21:
       
   174             // Soft key handle by framework
       
   175             // Selection key handle by AknFepManeger.
       
   176             case EStdKeyDevice0: // iCode:EKeyCBA1
       
   177             case EStdKeyDevice1: //	iCode:EKeyCBA2
       
   178             case EStdKeyDevice3: // iCode:EKeyOK
       
   179             case EKeyCBA1:
       
   180             case EKeyCBA2:
       
   181             case EKeyOK:
       
   182             	response = EFalse;
       
   183             	break;
       
   184 
       
   185             case EKeyUpArrow: 
       
   186                 if ( fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction) )
       
   187                     {
       
   188 #ifdef RD_INTELLIGENT_TEXT_INPUT                    
       
   189                     //fepMan->HideExactWordPopUp();
       
   190                     // Select the exact match with the up arrow and lock it.
       
   191                     // Another alternative could be to call function DoPreviousMatchL() from here
       
   192                     TBool primaryCandidateState = fepMan->AdvancedPredictivePrimaryCandidate(); 
       
   193                     TInt wordIndexToSelect = 0;
       
   194             		if (EFalse == primaryCandidateState)
       
   195             			{
       
   196             			ptiengine->HandleCommandL( EPtiCommandUserActionGetIndexOfSecondaryCandidate, 
       
   197         							&wordIndexToSelect );
       
   198             			}
       
   199             			
       
   200             			if (fepMan->IsExactWordPopUpShown())
       
   201             			{
       
   202             			    fepMan->HideExactWordPopUp();			
       
   203 				        	ptiengine->HandleCommandL( 
       
   204 	                               EPtiCommandUserActionSetCurrentIndexOfCandidates, 
       
   205 	                			   &wordIndexToSelect );
       
   206 	                    	ptiengine->HandleCommandL( EPtiCommandLockCurrentCandidate );
       
   207 	                    	TPtrC selectedWord = ptiengine->CurrentWord();
       
   208 	                    	fepMan->UpdateInlineEditL( selectedWord, selectedWord.Length() ); 
       
   209 	                    	response = ETrue;        							
       
   210 	            			break;	
       
   211             			}
       
   212 						else
       
   213 						{
       
   214 							fepMan->LaunchCandidatePopupListL( wordIndexToSelect );
       
   215 						    response = ETrue;        							
       
   216 	            			break;                 
       
   217 						}
       
   218 
       
   219 #endif // RD_INTELLIGENT_TEXT_INPUT            			
       
   220                     }
       
   221                     // fall through
       
   222             case EKeyDownArrow:
       
   223             case EKeyLeftArrow:
       
   224             case EKeyRightArrow:
       
   225             case EKeyBackspace:
       
   226                 response = HandleNaviKeysL(aKey, aLength);
       
   227                 break;
       
   228             
       
   229             
       
   230             default:
       
   231                 HandleShiftState(aKey);
       
   232                 response = HandleQwertyKeysL(aKey);
       
   233 #ifdef __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__
       
   234 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   235                 if ( aLength == ELongKeyPress )
       
   236                     {
       
   237                     // Expire multitap timer after long press. 
       
   238                     ptiengine->CancelTimerActivity();
       
   239                     }
       
   240 #endif // RD_INTELLIGENT_TEXT_INPUT
       
   241 #endif // __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__
       
   242                 break;
       
   243             }
       
   244         }
       
   245     
       
   246     iData = aKey; // store the pressed key for future reference
       
   247     return response;
       
   248     }
       
   249 
       
   250 
       
   251 //////////////////////////////////////////////////////////////////////////////////
       
   252 //
       
   253 void TAknFepInputStateEntryQwertyWesternPredictive::HandleShiftState( TInt aKey )
       
   254     {
       
   255     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   256     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   257     CAknFepCaseManager* caseMan = iOwner->CaseMan();
       
   258     CAknFepFnKeyManager::TFnKeyState fnKeyState  = fepMan->FnKeyState();
       
   259     TPtiTextCase shiftedCase;
       
   260     if(fnKeyState  != CAknFepFnKeyManager::EFnKeyNone)
       
   261 		{
       
   262 		shiftedCase = EPtiCaseFnLower;
       
   263 		}
       
   264 	else
       
   265  		{
       
   266  		shiftedCase= EPtiCaseLower;	
       
   267  		}
       
   268 
       
   269     TBool portraitFSQ = FeatureManager::FeatureSupported( 
       
   270         KFeatureIdFfVirtualFullscrPortraitQwertyInput )
       
   271         && fepMan->PluginUIManager() 
       
   272         && fepMan->PluginUIManager()->PluginInputMode() == EPluginInputModePortraitFSQ;
       
   273 
       
   274     // For addition of ITI features. 
       
   275     // When FSQ is opened wiht ITI features enabled,
       
   276     // after pressing keys, don't need to re-set current text case by editor's text or FN key state.
       
   277     // Because FSQ's case doesn't obey editor's case and there is no fn key on FSQ.
       
   278     if ( fepMan->PluginUIManager() 
       
   279         && ( fepMan->PluginUIManager()->PluginInputMode() == EPluginInputModeFSQ 
       
   280                 || portraitFSQ )
       
   281         && fepMan->WesternPredictive() )
       
   282         {
       
   283         return;
       
   284         }
       
   285         
       
   286     // Find out if the key is alphabetic
       
   287     TBuf<KKeyMappingsLength> keyMappings; 
       
   288     ptiengine->MappingDataForKey( (TPtiKey)aKey, keyMappings, EPtiCaseUpper );   
       
   289     TBool isAlpha = ( keyMappings.Length() && TChar(keyMappings[0]).IsAlpha() );
       
   290     
       
   291     if (isAlpha && (fnKeyState  == CAknFepFnKeyManager::EFnKeyNone))
       
   292         {
       
   293         switch ( caseMan->CurrentCase() )
       
   294             {
       
   295             case EAknEditorTextCase:
       
   296                 {
       
   297                 // Alphabetic characters are always capitalized in "Abc" mode 
       
   298                 // unless the shift is pressed 
       
   299                 // Thai language should not go to automatic capitalization in text case
       
   300                 // mode and predictive input. This is because it would lead to the character 
       
   301                 // mapped to upper case being displayed instead of the intended character.
       
   302                 // So below is what is essentially a XNOR condition - 
       
   303                 // 1) no-shiftkey and language with case    => upper case
       
   304                 // 2) no-shiftkey and language without case => lower case
       
   305                 // 3) shiftkey and language with case       => lower case
       
   306                 // 4) shiftkey and language without case    => upper case
       
   307                 TInt inputLang = ptiengine->CurrentLanguage()->LanguageCode();
       
   308                 if ( ( fepMan->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode) ||
       
   309                        fepMan->IsFlagSet(CAknFepManager::EFlagLongShiftKeyPress) )  
       
   310                       == ( inputLang == ELangThai ||
       
   311 					  	   inputLang == ELangArabic ||
       
   312                            inputLang == ELangFarsi ||
       
   313                            inputLang == ELangHebrew ||
       
   314                            inputLang == ELangUrdu ||
       
   315                            inputLang == ELangHindi ) )
       
   316                     {
       
   317                     shiftedCase = EPtiCaseUpper;
       
   318                     }          
       
   319                 }
       
   320             break;
       
   321             
       
   322             case EAknEditorLowerCase:
       
   323                 {
       
   324                 // Pressing shift enters uppercae letters in the "abc" mode
       
   325                 if ( fepMan->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode) ||
       
   326                      fepMan->IsFlagSet(CAknFepManager::EFlagLongShiftKeyPress) )
       
   327                     {
       
   328                     shiftedCase = EPtiCaseUpper;
       
   329                     }                
       
   330                 }
       
   331             break;
       
   332             
       
   333             case EAknEditorUpperCase:
       
   334                 {
       
   335                 // In the "ABC" mode (capslock mode) the letters are uppercased
       
   336                 // unless the shift is pressed
       
   337                 if ( !(fepMan->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode)||
       
   338                       fepMan->IsFlagSet(CAknFepManager::EFlagLongShiftKeyPress)) )
       
   339                     {
       
   340                     shiftedCase = EPtiCaseUpper;
       
   341                     }                
       
   342                 }
       
   343             break;
       
   344                 
       
   345             default:
       
   346             break;
       
   347             }
       
   348 
       
   349         
       
   350         }
       
   351     else
       
   352         {
       
   353         // non-alphabetic keys are shifted if and only if shift is pressed, no matter what is the input state
       
   354         if ( (fnKeyState  == CAknFepFnKeyManager::EFnKeyNone) &&
       
   355              ( fepMan->IsFlagSet(CAknFepManager::EFlagLongShiftKeyPress) ||
       
   356                fepMan->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode) ) )
       
   357             {
       
   358             shiftedCase = EPtiCaseUpper;
       
   359             }
       
   360         else if( (fnKeyState  == CAknFepFnKeyManager::EFnKeyNext) &&
       
   361                  (caseMan->CurrentCase() == EAknEditorTextCase ||
       
   362                   caseMan->CurrentCase() == EAknEditorUpperCase ||
       
   363                   fepMan->IsFlagSet(CAknFepManager::EFlagLongShiftKeyPress) || 
       
   364                   fepMan->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode)))
       
   365             {
       
   366             shiftedCase = EPtiCaseFnUpper;  
       
   367             }
       
   368         else if (( fepMan->IsFlagSet(CAknFepManager::EFlagLongShiftKeyPress) || 
       
   369         		  fepMan->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode)) && 
       
   370         		  (fnKeyState  != CAknFepFnKeyManager::EFnKeyNone))
       
   371 	        {
       
   372 			shiftedCase = EPtiCaseFnUpper;
       
   373 	        }    
       
   374         }
       
   375 
       
   376     
       
   377     // Handle the Chr key state
       
   378     if ( fepMan->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed) )
       
   379         {
       
   380         // Chr key is pressed down. Chr mode is used.
       
   381         if (shiftedCase == EPtiCaseLower)
       
   382             {
       
   383             shiftedCase = EPtiCaseChrLower;
       
   384             }
       
   385         else if (shiftedCase == EPtiCaseUpper)
       
   386             {
       
   387             shiftedCase = EPtiCaseChrUpper;
       
   388             }
       
   389         }
       
   390     
       
   391     ptiengine->SetCase(shiftedCase);
       
   392     
       
   393     fepMan->ClearFlag(CAknFepManager::EFlagNoActionDuringShiftKeyPress);
       
   394     }
       
   395 
       
   396 
       
   397 //////////////////////////////////////////////////////////////////////////////////
       
   398 //
       
   399 
       
   400 TBool TAknFepInputStateEntryQwertyWesternPredictive::HandleWordBreakingKeysL(TInt aKey)
       
   401     {
       
   402     TBool retVal = EFalse; // in most cases we let also the upper levels handle these key events
       
   403     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   404     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   405     CAknFepFnKeyManager::TFnKeyState fnKeyState  = fepMan->FnKeyState();
       
   406     
       
   407 
       
   408     // Up and down arrows break the inline word input only when shift or chr is held down
       
   409     if ( !fepMan->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed) &&
       
   410          !fepMan->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode) &&
       
   411          ( aKey==EStdKeyUpArrow || aKey==EStdKeyDownArrow ) )
       
   412         {
       
   413         return retVal;    
       
   414         }
       
   415 
       
   416 
       
   417     if ( fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction) )
       
   418         {
       
   419         TBool rightToLeftLang = fepMan->IsRightToLeftLanguage();
       
   420         TInt tailLength = 0;
       
   421 	    ptiengine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, &tailLength );
       
   422         switch (aKey)
       
   423             {
       
   424             case EStdKeyLeftArrow:
       
   425             case EStdKeyRightArrow:    
       
   426             	// In case the inline editing is ongoing and there is a word completion
       
   427                 // currently shown, the first backwards tap will remove the suggested 
       
   428                 // completion. 
       
   429                 if(tailLength > 0)
       
   430 	                {
       
   431 	                if ((rightToLeftLang && aKey == EStdKeyLeftArrow) 
       
   432 	                	|| (! rightToLeftLang && aKey == EStdKeyRightArrow ))
       
   433 	                    {
       
   434 					    ptiengine->HandleCommandL( EPtiCommandLockCurrentCandidate);
       
   435 					    TPtrC selectedWord = ptiengine->CurrentWord();
       
   436                         fepMan->UpdateInlineEditL( selectedWord, selectedWord.Length() );  //selection.iAnchorPosition
       
   437                         // To fix the Suggested word is not committed when Arrow right key is pressed.
       
   438                         ptiengine->CommitCurrentWord();
       
   439                         fepMan->TryCloseUiL();
       
   440                         // Asyncronous case update after the editor has handled the key
       
   441                 		fepMan->SimulateKeyEventL(EKeyF19); 
       
   442 	                    retVal = ETrue;
       
   443 	                    }
       
   444 	                else if((rightToLeftLang && aKey == EStdKeyRightArrow) 
       
   445 	                	|| (! rightToLeftLang && aKey == EStdKeyLeftArrow )) 
       
   446 		                {
       
   447 	                    fepMan->RemoveSuggestedAdvanceCompletionL();
       
   448 	                    retVal = ETrue;
       
   449 		                }    	
       
   450 	                }
       
   451                 else
       
   452 	                {
       
   453 	                ptiengine->CommitCurrentWord();
       
   454 	                retVal = EFalse;
       
   455 	                }
       
   456             break;  
       
   457             case EStdKeyUpArrow:
       
   458             case EStdKeyDownArrow:
       
   459             case EStdKeyEnter:
       
   460             case EStdKeySpace:
       
   461             case EStdKeyTab:
       
   462             {  
       
   463             	//retVal = ETrue;
       
   464             	TBool wasInlineEditing = EFalse;	
       
   465             	wasInlineEditing = 
       
   466                           fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction);
       
   467 
       
   468                 if(aKey == EStdKeySpace && tailLength > 0)
       
   469                     {
       
   470                     fepMan->RemoveSuggestedAdvanceCompletionL();
       
   471                     }
       
   472                 	
       
   473             	ptiengine->CommitCurrentWord();
       
   474                 fepMan->CommitInlineEditL();
       
   475                 /* Temporary Fix */
       
   476                 //EFlagInsideInlineEditingTransaction flag check is not required
       
   477                 //but just to make sure.
       
   478                 if (aKey == EStdKeySpace && fnKeyState == CAknFepFnKeyManager::EFnKeyDown)
       
   479                     fepMan->LaunchSelectModeMenuL();
       
   480                 else if(aKey == EStdKeySpace && wasInlineEditing)
       
   481                 	{
       
   482                 	_LIT(KSpace," ");                
       
   483 	                fepMan->StartInlineEditL();
       
   484 	                fepMan->UpdateInlineEditL(KSpace,0);
       
   485 	                fepMan->CommitInlineEditL();
       
   486                 	retVal = ETrue;
       
   487                 	}                
       
   488                 /* Temporary Fix */
       
   489                 fepMan->TryCloseUiL();                
       
   490                 // Asyncronous case update after the editor has handled the key
       
   491                 fepMan->SimulateKeyEventL(EKeyF19); 
       
   492             	}                
       
   493             break;
       
   494             default:
       
   495                 __ASSERT_DEBUG( EFalse, AknFepPanic(EAknFepPanicNotSupportKey) );
       
   496             }
       
   497 
       
   498         }
       
   499     else
       
   500         {
       
   501         iOwner->ChangeState( EInitial );
       
   502         }
       
   503 
       
   504     return retVal;
       
   505     }
       
   506 
       
   507 
       
   508 /////////////////////////////////////////////////////////////////////////////////
       
   509 //
       
   510 TBool TAknFepInputStateEntryQwertyWesternPredictive::HandleQwertyKeysL(TInt aKey)
       
   511     {
       
   512     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   513     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   514     
       
   515     CAknFepCaseManager* caseMan = iOwner->CaseMan(); 
       
   516     CAknFepFnKeyManager::TFnKeyState fnKeyState  = fepMan->FnKeyState();
       
   517     
       
   518     // Key is consumed if the PtiEngine maps it to some character
       
   519     TBuf<KKeyMappingsLength> keyMappings; 
       
   520     
       
   521     if(fnKeyState  != CAknFepFnKeyManager::EFnKeyNone)
       
   522 		{
       
   523 		
       
   524 		// Try to know is there any mapping for function upper
       
   525 		// char. For user point of view this changes has been made.
       
   526 		if( ptiengine->Case() == EPtiCaseFnUpper )
       
   527 			{
       
   528 	    	ptiengine->MappingDataForKey( (TPtiKey)aKey, keyMappings, EPtiCaseFnUpper);
       
   529 			}
       
   530 		else
       
   531 			{
       
   532 		   	ptiengine->MappingDataForKey( (TPtiKey)aKey, keyMappings, EPtiCaseFnLower);			
       
   533 			}
       
   534 		}
       
   535 	else
       
   536  		{
       
   537 	    ptiengine->MappingDataForKey( (TPtiKey)aKey, keyMappings, EPtiCaseLower);   
       
   538  		}
       
   539     //ITI : Pti Engine can be asked to give the proper data for the keys under Fn Key.
       
   540     TBool keyIsMapped = ( keyMappings.Length() > 0 );
       
   541     
       
   542     // The dead key handling inside the PtiDefaultCore assumes that no other key mapping queries
       
   543     // have been made between handling the dead key and the next one (these queries change the
       
   544     // internal state of the key mapping object). For this reason, we must return the key mappings
       
   545     // to their previous state. This is quite dirty hack, but so is the dead key handling code which
       
   546     // forces us to do this.
       
   547     if(fnKeyState  != CAknFepFnKeyManager::EFnKeyNone)
       
   548 		{
       
   549 	    ptiengine->MappingDataForKey( (TPtiKey)iData, keyMappings, EPtiCaseFnLower);
       
   550 		}
       
   551 	else
       
   552  		{
       
   553  		ptiengine->MappingDataForKey( (TPtiKey)iData, keyMappings, EPtiCaseLower);
       
   554  		}
       
   555  		
       
   556  	// For user point of view this changes has been made.
       
   557  	// If key does not map to function upper char, then try to insert
       
   558  	// functionized char.
       
   559 	if( (EPtiCaseFnUpper == ptiengine->Case()) && !keyIsMapped )
       
   560   		{
       
   561         ptiengine->SetCase((TPtiTextCase)EPtiCaseFnLower);
       
   562        	ptiengine->MappingDataForKey( (TPtiKey)aKey, keyMappings, EPtiCaseFnLower);
       
   563         keyIsMapped = ( keyMappings.Length() > 0 );
       
   564  		}
       
   565 
       
   566     if ( keyIsMapped )
       
   567         {
       
   568         if ( !(fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction)) )
       
   569             { // 'new' inline edit                        
       
   570             ptiengine->ClearCurrentWord();
       
   571             if (caseMan->CurrentCase() == EAknEditorTextCase)
       
   572                 {
       
   573                 ptiengine->MarkAutoCapitalized();    
       
   574                 }            
       
   575             
       
   576             fepMan->StartInlineEditL();
       
   577             }
       
   578                        
       
   579         TPtrC newText = ptiengine->AppendKeyPress((TPtiKey)aKey);
       
   580         fepMan->UpdateInlineEditL(newText, newText.Length());
       
   581         
       
   582         // Normally we update the case after key press. However, if Chr key is held down, the case update
       
   583         // must not happen until when the Chr is released or the timer expires (in both of these cases
       
   584         // the function KeyTimerExpired() will get callled).         
       
   585         if ( !fepMan->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed) )
       
   586             {
       
   587        	    iOwner->CaseMan()->UpdateCase(ENullNaviEvent);
       
   588        	    }
       
   589     	else
       
   590             {
       
   591             fepMan->ClearFlag(CAknFepManager::EFlagNoActionDuringChrKeyPress);
       
   592             }
       
   593            
       
   594         return ETrue;
       
   595         }
       
   596         // MT error fixing : If any key does not map any functionized char, 
       
   597         // its should not display any char fn mode, other behaviour as usual.
       
   598         // If the Fn key stae indicate that fn key pres & we are looking for functionnized
       
   599         // char, if its not availble it will do nothing. So we have to block the event
       
   600         // go to framework.
       
   601         if( aKey!=EStdKeyBackspace && fnKeyState  != CAknFepFnKeyManager::EFnKeyNone)
       
   602         	return ETrue;
       
   603         
       
   604         // Framework will handle the key event.
       
   605        	return EFalse;
       
   606     }
       
   607     
       
   608 
       
   609 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
       
   610 //
       
   611 TBool TAknFepInputStateEntryQwertyWesternPredictive::HandleNaviKeysL(TInt aKey, TKeyPressLength /*aLength*/)
       
   612     {
       
   613     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   614     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   615 
       
   616     if (!(fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction)))
       
   617         {
       
   618         TBuf<CAknFepManager::EMaximumFepWordLength> textToUncommit;
       
   619         TBool comsumeKey;
       
   620         if (!(fepMan->TryGetTextToUncommitL(textToUncommit, aKey, comsumeKey)))
       
   621             {
       
   622             // If T9 word length > 32, the navi key is consumed without action.
       
   623             // Maybe should navigate inside word.
       
   624             return comsumeKey;
       
   625             }
       
   626         ptiengine->ClearCurrentWord();
       
   627         ptiengine->SetCurrentWord(textToUncommit); // this set the input sequence of PtiEngine
       
   628         fepMan->StartInlineEditL(fepMan->UncommittedText(), textToUncommit, 
       
   629         						 textToUncommit.Length(), EFalse);
       
   630         }
       
   631 
       
   632     if (aKey == EKeyBackspace)
       
   633         {
       
   634         TPtrC newText = ptiengine->DeleteKeyPress();
       
   635         TPtrC selectedWord = ptiengine->CurrentWord();
       
   636         fepMan->UpdateInlineEditL(selectedWord, selectedWord.Length());
       
   637 
       
   638 		fepMan->ClearFlag(CAknFepManager::EFlagRemoveMatchesMenuItem);           
       
   639         if (ptiengine->NumberOfCandidates() <= 1)
       
   640         	{
       
   641 			fepMan->SetFlag(CAknFepManager::EFlagRemoveMatchesMenuItem);           	
       
   642         	}
       
   643 
       
   644         iOwner->CaseMan()->UpdateCase(EBackspaceEvent);
       
   645         fepMan->CloseUiIfWordDeletedL();
       
   646         }
       
   647     
       
   648     return ETrue;
       
   649     }
       
   650 
       
   651 
       
   652 /////////////////////////////////////////////////////////////////////////////
       
   653 //
       
   654 void TAknFepInputStateEntryQwertyWesternPredictive::LastWordInSelectionList()
       
   655     {
       
   656 
       
   657     }
       
   658 
       
   659 
       
   660 //////////////////////////////////////////////////////////////////////////////
       
   661 //
       
   662 void TAknFepInputStateEntryQwertyWesternPredictive::FirstWordInSelectionList()
       
   663     {   
       
   664     }
       
   665 
       
   666 
       
   667 /////////////////////////////////////////////////////////////////
       
   668 //
       
   669 void TAknFepInputStateEntryQwertyWesternPredictive::KeyTimerExpired()
       
   670     {
       
   671     if (iData)
       
   672         {
       
   673         MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   674         CAknFepCaseManager* caseMan = iOwner->CaseMan(); 
       
   675         caseMan->UpdateCase(ENullNaviEvent); 
       
   676         fepMan->ClearFlag( CAknFepManager::EFlagInsideMultitapInlineEditingTransaction );
       
   677         iData = 0;
       
   678         }
       
   679     }
       
   680    
       
   681 
       
   682 // End of file