fep/aknfep/src/AknFepUiManagerBase.cpp
changeset 0 eb1f2e154e89
child 12 5e18d8c489d6
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     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 CAknFepUIManagerBase methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 // INCLUDE FILES
       
    31 #include <e32keys.h>
       
    32 #include <e32svr.h> // RDebug stuff...
       
    33 
       
    34 #include "AknFepGlobalEnums.h"
       
    35 #include "AknFepUiManagerBase.h"
       
    36 
       
    37 // Western input
       
    38 #include "AknFepUiInputStateInitialLatinMultitap.h"
       
    39 #include "AknFepUiInputStateInitialNumber.h"
       
    40 #include "AknFepUiInputStateInitialWesternPredictive.h"
       
    41 #include "AknFepUiInputStateEntryWesternPredictive.h"
       
    42 
       
    43 #include "AknFepCaseManager.h"
       
    44 #include "AknFepPanic.h"
       
    45 
       
    46 #include <AknFep.rsg>
       
    47 #include <AknIndicatorContainer.h>  // CAknIndicatorContainer::TIndicatorContext
       
    48 #include <PtiEngine.h> 
       
    49 #include <PtiDefs.h>
       
    50 
       
    51 // CONSTANTS
       
    52 const TInt KNumberOfKeymapResources = 8;
       
    53 const TInt KNumericKeymapResourceIds[KNumberOfKeymapResources] = 
       
    54     {
       
    55     R_AKNFEP_NUMBER_MODE_KEYMAP_STANDARD,
       
    56     R_AKNFEP_NUMBER_MODE_KEYMAP_PLAIN,
       
    57     R_AKNFEP_NUMBER_MODE_KEYMAP_CALCULATOR,
       
    58     R_AKNFEP_NUMBER_MODE_KEYMAP_CONVERTER,
       
    59     R_AKNFEP_NUMBER_MODE_KEYMAP_TO_FIELD,
       
    60     R_AKNFEP_NUMBER_MODE_KEYMAP_FIXED_DIALLING,
       
    61     R_AKNFEP_NUMBER_MODE_KEYMAP_SAT,
       
    62     R_AKNFEP_NUMBER_MODE_KEYMAP_SAT_HIDDEN
       
    63     };
       
    64 
       
    65 #define EAknEditorNativeKeysNumberModeKeymap EAknEditorReservedInternalUseKeymap
       
    66 
       
    67 /**
       
    68 *  CAknFepUIManagerBase class.
       
    69 * 
       
    70 */
       
    71 
       
    72 //============================ MEMBER FUNCTIONS ==============================
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // CAknFepUIManagerBase::NewL
       
    76 // 
       
    77 // 
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 CAknFepUIManagerBase* CAknFepUIManagerBase::NewL(MAknFepManagerUIInterface* aFepMan, 
       
    81                                                  CAknFepCaseManager* aCaseMan, TLanguage aLanguage)
       
    82     {   
       
    83     CAknFepUIManagerBase* self = new(ELeave)CAknFepUIManagerBase(aFepMan, aCaseMan);
       
    84     CleanupStack::PushL(self);
       
    85     self->ConstructL(aLanguage);
       
    86     CleanupStack::Pop();
       
    87     return self;
       
    88     }
       
    89 
       
    90 // ---------------------------------------------------------------------------
       
    91 // CAknFepUIManagerBase::~CAknFepUIManagerBase
       
    92 // 
       
    93 // 
       
    94 // ---------------------------------------------------------------------------
       
    95 //
       
    96 CAknFepUIManagerBase::~CAknFepUIManagerBase()
       
    97     {
       
    98     CloseUI();
       
    99     delete iNumericKeymapBuffer;
       
   100     }
       
   101 
       
   102 /**
       
   103  *  MAknFepManagerInterface class.
       
   104  * 
       
   105  */
       
   106 //============================ MEMBER FUNCTIONS ==============================
       
   107 
       
   108 // ---------------------------------------------------------------------------
       
   109 // CAknFepUIManagerBase::SetMode
       
   110 // 
       
   111 // 
       
   112 // ---------------------------------------------------------------------------
       
   113 //
       
   114 #ifdef RD_INTELLIGENT_TEXT_INPUT        
       
   115 void CAknFepUIManagerBase::SetMode(TInt aMode, 
       
   116 									TBool aPredictive, 
       
   117 									TBool aQwertyInputMode, 
       
   118 									TInt aKeyboardType)
       
   119 #else
       
   120 void CAknFepUIManagerBase::SetMode(TInt aMode, TBool aPredictive, TBool aQwertyInputMode)
       
   121 #endif
       
   122     {
       
   123     iMode=aMode;
       
   124     iPredictive = aPredictive;
       
   125 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   126     iQwertyInputMode = aQwertyInputMode; // predictive QWERTY changes (e.g. XT9)
       
   127 #endif //RD_INTELLIGENT_TEXT_INPUT
       
   128     if (aQwertyInputMode 
       
   129 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   130     && !aPredictive // predictive QWERTY changes (e.g. XT9): added second condition
       
   131 #endif //RD_INTELLIGENT_TEXT_INPUT
       
   132 	) 
       
   133         {
       
   134 #ifdef RD_INTELLIGENT_TEXT_INPUT        
       
   135         if (aKeyboardType == EPtiKeyboardHalfQwerty)
       
   136             {
       
   137             ChangeState(EHalfQwerty);                        
       
   138             }
       
   139         else
       
   140             {
       
   141 #endif            
       
   142         ChangeState(EQwerty);
       
   143 #ifdef RD_INTELLIGENT_TEXT_INPUT                                
       
   144             }                       
       
   145 #endif            
       
   146         }
       
   147     else
       
   148         {
       
   149         ChangeState(EInitial);
       
   150         }
       
   151     }
       
   152 
       
   153 // ---------------------------------------------------------------------------
       
   154 // CAknFepUIManagerBase::SetCase
       
   155 // 
       
   156 // 
       
   157 // ---------------------------------------------------------------------------
       
   158 //
       
   159 void CAknFepUIManagerBase::SetCase(TCase aCase)
       
   160     {
       
   161 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   162     TPtiTextCase newCase = EPtiCaseLower;
       
   163     
       
   164     TBool noResetCase = EFalse;
       
   165     
       
   166     switch( aCase )
       
   167         {
       
   168         case EUpperCase:
       
   169             {
       
   170             newCase = EPtiCaseUpper;
       
   171             }
       
   172             break;
       
   173         case ELowerCase:
       
   174             {
       
   175             newCase = EPtiCaseLower;
       
   176             }
       
   177             break;    
       
   178         case EFnKeyLowerCase:
       
   179             {
       
   180             newCase = EPtiCaseFnLower;
       
   181             }
       
   182             break;
       
   183             
       
   184         case EFnKeyUpperCase:
       
   185             {
       
   186             newCase = EPtiCaseFnUpper;
       
   187             noResetCase = ETrue;
       
   188             }
       
   189             break;
       
   190             
       
   191         default:
       
   192         break;
       
   193         }
       
   194 
       
   195     CAknFepFnKeyManager::TFnKeyState fnKeyState = iFepMan->FnKeyState();
       
   196 #ifdef __REVERSE_FN_KEY_SUPPORTED
       
   197     // For Reverse Fn key mapping
       
   198     if(!iFepMan->IsReverseFnkeyInput())
       
   199     	{
       
   200 #endif //__REVERSE_FN_KEY_SUPPORTED
       
   201     switch (fnKeyState)
       
   202         {
       
   203         case CAknFepFnKeyManager::EFnKeyLock:
       
   204         case CAknFepFnKeyManager::EFnKeyForced:
       
   205         case CAknFepFnKeyManager::EFnKeyDown:
       
   206             if( !noResetCase )
       
   207             newCase = EPtiCaseFnLower;
       
   208             break;
       
   209         case CAknFepFnKeyManager::EFnKeyNone:
       
   210         case CAknFepFnKeyManager::EFnKeyPressed:
       
   211         case CAknFepFnKeyManager::EFnKeyNext:
       
   212         case CAknFepFnKeyManager::EFnKeyPressedAgain:
       
   213         default:
       
   214             break;
       
   215         }
       
   216 #ifdef __REVERSE_FN_KEY_SUPPORTED
       
   217         }
       
   218 #endif //__REVERSE_FN_KEY_SUPPORTED
       
   219     PtiEngine()->SetCase( newCase );
       
   220 #else 
       
   221     PtiEngine()->SetCase((aCase == EUpperCase)? EPtiCaseUpper : EPtiCaseLower);
       
   222 #endif
       
   223     }
       
   224 
       
   225 // ---------------------------------------------------------------------------
       
   226 // CAknFepUIManagerBase::SetNumberModeKeyMappingL
       
   227 // 
       
   228 // 
       
   229 // ---------------------------------------------------------------------------
       
   230 //
       
   231 void CAknFepUIManagerBase::SetNumberModeKeyMappingL(
       
   232      TAknEditorNumericKeymap aAknEditorNumericKeymap)
       
   233     {
       
   234     __ASSERT_DEBUG(
       
   235         (aAknEditorNumericKeymap >= 0 && aAknEditorNumericKeymap < KNumberOfKeymapResources) ||
       
   236         (aAknEditorNumericKeymap == EAknEditorAlphanumericNumberModeKeymap) ||
       
   237         (aAknEditorNumericKeymap == EAknEditorNativeKeysNumberModeKeymap), 
       
   238         AknFepPanic(EAknFepPanicIllegalNumberModeKeymapping));
       
   239 
       
   240 #ifdef RD_INTELLIGENT_TEXT_INPUT        
       
   241     if (aAknEditorNumericKeymap == EAknEditorAlphanumericNumberModeKeymap && iNumericKeymapBuffer)
       
   242         {
       
   243         delete iNumericKeymapBuffer;
       
   244         iNumericKeymapBuffer = NULL;
       
   245         return;
       
   246         }
       
   247 #endif
       
   248     
       
   249     // Fep does not handle keys when EAknEditorNativeKeysNumberModeKeymap is used.
       
   250     if (aAknEditorNumericKeymap != EAknEditorNativeKeysNumberModeKeymap && 
       
   251         aAknEditorNumericKeymap != EAknEditorAlphanumericNumberModeKeymap)
       
   252         {
       
   253         TInt keymapResourceId = KNumericKeymapResourceIds[aAknEditorNumericKeymap];
       
   254         if (iNumericKeymapResourceId != keymapResourceId || !iNumericKeymapBuffer)
       
   255             {
       
   256             delete iNumericKeymapBuffer;
       
   257             iNumericKeymapBuffer = NULL;
       
   258             iNumericKeymapBuffer = CCoeEnv::Static()->AllocReadResourceL( keymapResourceId );
       
   259             iNumericKeymapResourceId = keymapResourceId;
       
   260             }
       
   261         }
       
   262     }
       
   263 
       
   264 const TDesC& CAknFepUIManagerBase::NumberModeKeyMapping() const
       
   265     {
       
   266     if (iNumericKeymapBuffer)
       
   267         {
       
   268         return *iNumericKeymapBuffer;
       
   269         }
       
   270     return KNullDesC;
       
   271     }
       
   272 
       
   273 // ---------------------------------------------------------------------------
       
   274 // CAknFepUIManagerBase::HandleKeyL
       
   275 // 
       
   276 // 
       
   277 // ---------------------------------------------------------------------------
       
   278 //
       
   279 TBool CAknFepUIManagerBase::HandleKeyL(TInt aKey, TKeyPressLength aLength, TEventCode /*aEventCode*/)
       
   280     {
       
   281     if (!iStatePtr)
       
   282         {
       
   283         return EFalse;
       
   284         }
       
   285     
       
   286     TUIState currentState = iStatePtr->State();
       
   287     if (aLength == EShortKeyPress)
       
   288         {
       
   289         iInitialFepUIState = currentState;
       
   290         }
       
   291 #ifdef __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__        
       
   292 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   293     // Calculate and store the number of characters now and the delta with 
       
   294     // the last key press to be used when long press substitutes the initial
       
   295     // character.
       
   296     
       
   297     // This change is done for fixing the error :- Long keypress 
       
   298     // inputs the alphabet as well along with number/special character 
       
   299     // when candidate list is open.
       
   300     
       
   301     TInt curInputSeqLen = 0;
       
   302     TInt curEditorTextLen = 0;
       
   303     TInt curWordLen = 0;
       
   304     if (aLength == EShortKeyPress)
       
   305     	{
       
   306         curInputSeqLen = PtiEngine()->CurrentInputSequence().Length();
       
   307         curWordLen =  PtiEngine()->CurrentWord().Length();
       
   308         curEditorTextLen = FepMan()->DocumentLength();
       
   309     	iCaseBeforeLongKey = CaseMan()->CurrentCase();
       
   310     	}
       
   311 
       
   312     if ( aLength == ELongKeyPress )
       
   313         {
       
   314         if ( HandleLongKeyL( aKey ) )
       
   315             {
       
   316             return ETrue;
       
   317             }
       
   318         }
       
   319         
       
   320     TInt retVal = ETrue;
       
   321     TBool handledKey = iStatePtr->HandleKeyL(aKey, aLength);
       
   322     if(!handledKey)
       
   323         {
       
   324         if(currentState != iStatePtr->State()) //Check to see if we've changed state.
       
   325             {
       
   326             retVal = iStatePtr->HandleKeyL(aKey, aLength);
       
   327             }
       
   328         else
       
   329             {
       
   330             retVal = EFalse; // we've failed to handle it..
       
   331             }
       
   332         }
       
   333 	
       
   334 	// The delta is calculated after the short key press character is entered.
       
   335 	// The check with EStdKeyF21 is done to fix the bug :
       
   336 	// When prediction is off, keep shift key pressed down. 
       
   337 	// Just before the editor enters the selection mode, 
       
   338 	// do a long press of a number key. Along with the number 
       
   339 	// even the alphabet is entered.
       
   340     if (aLength == EShortKeyPress && (handledKey || retVal) && (aKey!=EStdKeyF21))
       
   341    	    {
       
   342 		// for the punctuation key, the autocompletion part is accepted, 
       
   343 		// because of which the delta has to be calculated 
       
   344 		// based on the current word length
       
   345     	if( aKey == EStdKeyFullStop && EPtiKeyboardHalfQwerty == FepMan()->KeyboardLayout())	
       
   346     	    {
       
   347     	    iInputSeqLenDeltaWithLastKey = PtiEngine()->CurrentWord().Length() - curWordLen;
       
   348     	    }
       
   349     	else
       
   350     	    {
       
   351     	    iInputSeqLenDeltaWithLastKey = PtiEngine()->CurrentInputSequence().Length() - curInputSeqLen;
       
   352     	    }
       
   353     	iEditorTextLenDeltaWithLastKey = FepMan()->DocumentLength() - curEditorTextLen;
       
   354     	// This change is done to fix the bug : Select the text
       
   355     	// using shift key. Do a long press of a key. Along 
       
   356     	// with the number even the alphabet is entered.
       
   357     	if(iEditorTextLenDeltaWithLastKey <= 0)
       
   358     		{
       
   359     		iEditorTextLenDeltaWithLastKey = iStatePtr->GetShortKeyPressTxtLength();
       
   360     		}
       
   361         }
       
   362     
       
   363     else if ( aLength == EShortKeyPress && 
       
   364             EPtiKeyboardHalfQwerty == FepMan()->KeyboardLayout() && 
       
   365             EFalse == retVal && PtiEngine()->IsValidKey((TPtiKey)aKey))
       
   366         {
       
   367         // reset the two deltas
       
   368         iInputSeqLenDeltaWithLastKey = 0;
       
   369         iEditorTextLenDeltaWithLastKey = 0;
       
   370         }
       
   371 
       
   372     return retVal;
       
   373 #endif // RD_INTELLIGENT_TEXT_INPUT  
       
   374 #else 
       
   375 
       
   376     if(!iStatePtr->HandleKeyL(aKey, aLength))
       
   377         {
       
   378         if(currentState != iStatePtr->State()) //Check to see if we've changed state.
       
   379             {
       
   380             return iStatePtr->HandleKeyL(aKey, aLength);
       
   381             }
       
   382         return EFalse; // we've failed to handle it..
       
   383         }
       
   384     return ETrue; //we're ok.
       
   385 #endif // __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__
       
   386     
       
   387     }
       
   388 
       
   389 // ---------------------------------------------------------------------------
       
   390 // CAknFepUIManagerBase::HandleCommandL
       
   391 // 
       
   392 // 
       
   393 // ---------------------------------------------------------------------------
       
   394 //
       
   395 void CAknFepUIManagerBase::HandleCommandL(TInt aCommandId)
       
   396     {
       
   397     iStatePtr->HandleCommandL(aCommandId);
       
   398     }
       
   399 
       
   400 void CAknFepUIManagerBase::HandleCommandL(TInt aCommandId, TInt /*aParam*/)
       
   401     {
       
   402     iStatePtr->HandleCommandL(aCommandId);
       
   403     }
       
   404 // ---------------------------------------------------------------------------
       
   405 // CAknFepUIManagerBase::CloseUI
       
   406 // 
       
   407 // 
       
   408 // ---------------------------------------------------------------------------
       
   409 //
       
   410 void CAknFepUIManagerBase::CloseUI()
       
   411     {
       
   412     ChangeState(EInitial);
       
   413     }
       
   414 
       
   415 
       
   416 // ---------------------------------------------------------------------------
       
   417 // CAknFepUIManagerBase::ExpireMultitapTimer
       
   418 // 
       
   419 // 
       
   420 // ---------------------------------------------------------------------------
       
   421 //
       
   422 void CAknFepUIManagerBase::ExpireMultitapTimer()
       
   423     {
       
   424     PtiEngine()->CancelTimerActivity();
       
   425     }
       
   426 
       
   427 // ---------------------------------------------------------------------------
       
   428 // CAknFepUIManagerBase::IsValidNumericLongKeyPress
       
   429 // 
       
   430 // 
       
   431 // ---------------------------------------------------------------------------
       
   432 //
       
   433 TBool CAknFepUIManagerBase::IsValidNumericLongKeyPress(TInt aKey) const
       
   434     {
       
   435     TBool response = EFalse;
       
   436 
       
   437     switch(aKey)
       
   438         {
       
   439         case EPtiKey0:
       
   440         case EPtiKey1:
       
   441         case EPtiKey2:
       
   442         case EPtiKey3:
       
   443         case EPtiKey4:
       
   444         case EPtiKey5:
       
   445         case EPtiKey6:
       
   446         case EPtiKey7:
       
   447         case EPtiKey8:
       
   448         case EPtiKey9:            
       
   449             if (iInitialFepUIState == EInitial || 
       
   450                 iInitialFepUIState == EPredictiveCandidate)
       
   451                 {
       
   452                 response = ETrue;
       
   453                 }
       
   454             break;
       
   455         default:
       
   456             break;
       
   457         }
       
   458     return response;
       
   459     }
       
   460 
       
   461 // ---------------------------------------------------------------------------
       
   462 // CAknFepUIManagerBase::AddTextToUserDictionaryL
       
   463 // 
       
   464 // 
       
   465 // ---------------------------------------------------------------------------
       
   466 //
       
   467 void CAknFepUIManagerBase::AddTextToUserDictionaryL(const TDesC& /*aText*/)
       
   468     {
       
   469     }
       
   470 
       
   471 // ---------------------------------------------------------------------------
       
   472 // CAknFepUIManagerBase::GetFormatOfFepInlineText
       
   473 // 
       
   474 // 
       
   475 // ---------------------------------------------------------------------------
       
   476 //
       
   477 void CAknFepUIManagerBase::GetFormatOfFepInlineText(TCharFormat& /*aFormat*/, TInt& /*aNumberOfCharactersWithSameFormat*/, TInt /*aPositionOfCharacter*/) const
       
   478     {
       
   479     }
       
   480 
       
   481 // ---------------------------------------------------------------------------
       
   482 // CAknFepUIManagerBase::SupportLanguage
       
   483 // 
       
   484 // 
       
   485 // ---------------------------------------------------------------------------
       
   486 //
       
   487 TInt CAknFepUIManagerBase::SupportLanguage(TInt /*aMode*/) const
       
   488     {
       
   489     return iLanguage;
       
   490     }
       
   491 
       
   492 // ---------------------------------------------------------------------------
       
   493 // CAknFepUIManagerBase::SetInputLanguageL
       
   494 // 
       
   495 // 
       
   496 // ---------------------------------------------------------------------------
       
   497 //
       
   498 void CAknFepUIManagerBase::SetInputLanguageL(TLanguage aLanguage)
       
   499     {
       
   500     iLanguage = aLanguage;
       
   501     }
       
   502 
       
   503 // ---------------------------------------------------------------------------
       
   504 // CAknFepUIManagerBase::IsValidShiftKeyPress
       
   505 // 
       
   506 // 
       
   507 // ---------------------------------------------------------------------------
       
   508 //
       
   509 TBool CAknFepUIManagerBase::IsValidShiftKeyPress() const
       
   510     {
       
   511     return ETrue;
       
   512     }
       
   513 
       
   514 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   515 TBool CAknFepUIManagerBase::IsValidFnKeyPress() const
       
   516     {
       
   517     return ETrue;
       
   518     }
       
   519 
       
   520 
       
   521 TBool CAknFepUIManagerBase::IsValidLongChrKeyPress() const
       
   522     {
       
   523     return ETrue;
       
   524     }
       
   525 
       
   526 #endif
       
   527 // ---------------------------------------------------------------------------
       
   528 // CAknFepUIManagerBase::SetEditorContext
       
   529 // 
       
   530 // 
       
   531 // ---------------------------------------------------------------------------
       
   532 //
       
   533 void CAknFepUIManagerBase::SetEditorContext(TInt /*aContext*/)
       
   534     {
       
   535     }
       
   536 
       
   537 // ---------------------------------------------------------------------------
       
   538 // CAknFepUIManagerBase::ActivateUI
       
   539 // 
       
   540 // 
       
   541 // ---------------------------------------------------------------------------
       
   542 //
       
   543 void CAknFepUIManagerBase::ActivateUI()
       
   544     {
       
   545     }
       
   546 
       
   547 /**
       
   548  *  MAknFepUIManagerStateInterface class.
       
   549  * 
       
   550  */
       
   551 //============================ MEMBER FUNCTIONS ==============================
       
   552 
       
   553 // ---------------------------------------------------------------------------
       
   554 // CAknFepUIManagerBase::State
       
   555 // 
       
   556 // 
       
   557 // ---------------------------------------------------------------------------
       
   558 //
       
   559 TUIState CAknFepUIManagerBase::State() const
       
   560     {
       
   561     return iStatePtr->State();
       
   562     }
       
   563 
       
   564 // ---------------------------------------------------------------------------
       
   565 // CAknFepUIManagerBase::ChangeState
       
   566 // 
       
   567 // 
       
   568 // ---------------------------------------------------------------------------
       
   569 //
       
   570 TUIState CAknFepUIManagerBase::ChangeState(TUIState aState)
       
   571     {
       
   572 //    iFepUiState = TAknFepInputStateBase(this);
       
   573 #ifdef _DEBUG
       
   574     RDebug::Print(_L("UI Manager: New State: %d"), iStatePtr->State());
       
   575 #endif
       
   576     return aState;
       
   577     }
       
   578 
       
   579 // ---------------------------------------------------------------------------
       
   580 // CAknFepUIManagerBase::FepMan
       
   581 // 
       
   582 // 
       
   583 // ---------------------------------------------------------------------------
       
   584 //
       
   585 MAknFepManagerUIInterface* CAknFepUIManagerBase::FepMan() const
       
   586     {
       
   587     return iFepMan;
       
   588     }
       
   589 
       
   590 // ---------------------------------------------------------------------------
       
   591 // CAknFepUIManagerBase::PtiEngine
       
   592 // 
       
   593 // 
       
   594 // ---------------------------------------------------------------------------
       
   595 //
       
   596 CPtiEngine* CAknFepUIManagerBase::PtiEngine() const
       
   597     {
       
   598     return iPtiEngine;
       
   599     }
       
   600 
       
   601 // ---------------------------------------------------------------------------
       
   602 // CAknFepUIManagerBase::IsValidChineseInputKey
       
   603 // 
       
   604 // 
       
   605 // ---------------------------------------------------------------------------
       
   606 //
       
   607 TBool CAknFepUIManagerBase::IsValidChineseInputKey(TInt /*aKey*/) const
       
   608     {
       
   609     return ETrue;
       
   610     }
       
   611 
       
   612 // ---------------------------------------------------------------------------
       
   613 // CAknFepUIManagerBase::IsValidChineseInputKeyQwerty
       
   614 // 
       
   615 // 
       
   616 // ---------------------------------------------------------------------------
       
   617 //
       
   618 TBool CAknFepUIManagerBase::IsValidChineseInputKeyQwerty(TInt /*aKey*/) const
       
   619     {
       
   620     return ETrue;
       
   621     }
       
   622     
       
   623 // ---------------------------------------------------------------------------
       
   624 // CAknFepUIManagerBase::UpdateCangJieState
       
   625 // 
       
   626 // 
       
   627 // ---------------------------------------------------------------------------
       
   628 //
       
   629 void CAknFepUIManagerBase::UpdateCangJieState()
       
   630     {
       
   631     }
       
   632 
       
   633 // ---------------------------------------------------------------------------
       
   634 // CAknFepUIManagerBase::IsValidChineseSymbol
       
   635 // 
       
   636 // 
       
   637 // ---------------------------------------------------------------------------
       
   638 //
       
   639 TBool CAknFepUIManagerBase::IsValidChineseSymbol(TInt /*akey*/) const
       
   640 	{
       
   641 	return ETrue;
       
   642 	}
       
   643 
       
   644 // ---------------------------------------------------------------------------
       
   645 // CAknFepUIManagerBase::IsQwertyZhuyinToneMarkKey
       
   646 // 
       
   647 // 
       
   648 // ---------------------------------------------------------------------------
       
   649 //
       
   650 TBool CAknFepUIManagerBase::IsQwertyZhuyinToneMarkKey(TInt /*aKey*/) const
       
   651     {
       
   652     return ETrue;
       
   653     }
       
   654 
       
   655 // ---------------------------------------------------------------------------
       
   656 // CAknFepUIManagerBase::GetLanguage
       
   657 // 
       
   658 // 
       
   659 // ---------------------------------------------------------------------------
       
   660 //
       
   661 TLanguage CAknFepUIManagerBase::GetLanguage() const
       
   662     {
       
   663     return iLanguage;
       
   664     }
       
   665 
       
   666 // ---------------------------------------------------------------------------
       
   667 // CAknFepUIManagerBase::CaseMan
       
   668 // 
       
   669 // 
       
   670 // ---------------------------------------------------------------------------
       
   671 //
       
   672 CAknFepCaseManager* CAknFepUIManagerBase::CaseMan() const
       
   673     {
       
   674     return iCaseMan;
       
   675     }
       
   676 
       
   677 // ---------------------------------------------------------------------------
       
   678 // CAknFepUIManagerBase::GetLatestDeliberateSelection
       
   679 // 
       
   680 // 
       
   681 // ---------------------------------------------------------------------------
       
   682 //
       
   683 TPtr CAknFepUIManagerBase::GetLatestDeliberateSelection() const
       
   684     {
       
   685     return TPtr(NULL, 0, 0);
       
   686     }
       
   687 
       
   688 // ---------------------------------------------------------------------------
       
   689 // CAknFepUIManagerBase::ThaiSCTResourceId
       
   690 // 
       
   691 // 
       
   692 // ---------------------------------------------------------------------------
       
   693 //
       
   694 TInt CAknFepUIManagerBase::ThaiSCTResourceId(TUint /*aPrewChar*/,TInt /*aKey*/)
       
   695     {
       
   696     return 0;
       
   697     }
       
   698 
       
   699 // ---------------------------------------------------------------------------
       
   700 // CAknFepUIManagerBase::CandidateArray
       
   701 // 
       
   702 // 
       
   703 // ---------------------------------------------------------------------------
       
   704 //
       
   705 CDesCArrayFlat* CAknFepUIManagerBase::CandidateArray()
       
   706     {
       
   707     return NULL;
       
   708     }
       
   709 
       
   710 // ---------------------------------------------------------------------------
       
   711 // CAknFepUIManagerBase::IsPredictive
       
   712 // 
       
   713 // 
       
   714 // ---------------------------------------------------------------------------
       
   715 //
       
   716 TBool CAknFepUIManagerBase::IsPredictive() const
       
   717     {
       
   718     return EFalse;
       
   719     }
       
   720 
       
   721 // ---------------------------------------------------------------------------
       
   722 // CAknFepUIManagerBase::SetInlineEditUnderlineVisibility
       
   723 // 
       
   724 // 
       
   725 // ---------------------------------------------------------------------------
       
   726 //
       
   727 void CAknFepUIManagerBase::SetInlineEditUnderlineVisibility(TBool /*aFlag*/)
       
   728     {
       
   729     }
       
   730 
       
   731 /**
       
   732  *  CAknFepUIManagerBase class.
       
   733  * 
       
   734  */
       
   735 //============================ MEMBER FUNCTIONS ==============================
       
   736 
       
   737 // ---------------------------------------------------------------------------
       
   738 // CAknFepUIManagerBase::CAknFepUIManagerBase
       
   739 // 
       
   740 // 
       
   741 // ---------------------------------------------------------------------------
       
   742 //
       
   743 CAknFepUIManagerBase::CAknFepUIManagerBase(MAknFepManagerUIInterface* aFepMan, 
       
   744                                            CAknFepCaseManager* aCaseMan)
       
   745     :iMode(ENumber), 
       
   746     iFepMan(aFepMan),
       
   747     iCaseMan(aCaseMan)
       
   748     {
       
   749     }
       
   750 
       
   751 // ---------------------------------------------------------------------------
       
   752 // CAknFepUIManagerBase::ConstructL
       
   753 // 
       
   754 // 
       
   755 // ---------------------------------------------------------------------------
       
   756 //
       
   757 void CAknFepUIManagerBase::ConstructL(TLanguage aLanguage)
       
   758     {   
       
   759     iPtiEngine = iFepMan->PtiEngine(); // Get PtiEngine
       
   760     iLanguage = aLanguage;
       
   761     iStatePtr = FepUIState();
       
   762     SetNumberModeKeyMappingL(EAknEditorStandardNumberModeKeymap);
       
   763     }
       
   764 
       
   765 // ---------------------------------------------------------------------------
       
   766 // CAknFepUIManagerBase::FepUIState
       
   767 // 
       
   768 // 
       
   769 // ---------------------------------------------------------------------------
       
   770 //
       
   771 TAknFepInputStateBase* CAknFepUIManagerBase::FepUIState()
       
   772     {
       
   773     return NULL;
       
   774     }
       
   775 
       
   776 // ---------------------------------------------------------------------------
       
   777 // CAknFepUIManagerBase::IsQwerty
       
   778 // 
       
   779 // 
       
   780 // ---------------------------------------------------------------------------
       
   781 //
       
   782 TBool CAknFepUIManagerBase::IsQwerty() const
       
   783     {
       
   784     return EFalse;
       
   785     }
       
   786 
       
   787 // ---------------------------------------------------------------------------
       
   788 // CAknFepUIManagerBase::SetFepAwareEditorText
       
   789 // 
       
   790 // 
       
   791 // ---------------------------------------------------------------------------
       
   792 //
       
   793 void CAknFepUIManagerBase::SetFepAwareEditorText(const TFepInputContextFieldData& /*aIcfData*/)
       
   794     {
       
   795     }
       
   796 
       
   797 // ---------------------------------------------------------------------------
       
   798 // CAknFepUIManagerBase::EditorMaxLength
       
   799 // 
       
   800 // 
       
   801 // ---------------------------------------------------------------------------
       
   802 //
       
   803 TInt CAknFepUIManagerBase::EditorMaxLength()
       
   804     {
       
   805     return 0;
       
   806     }
       
   807 
       
   808 // ---------------------------------------------------------------------------
       
   809 // CAknFepUIManagerBase::SizeChanged
       
   810 // 
       
   811 // 
       
   812 // ---------------------------------------------------------------------------
       
   813 //
       
   814 const TInt KResourceChanged =  1;
       
   815 void CAknFepUIManagerBase::ResourceChanged(TInt /*aType*/)
       
   816     {
       
   817     if ( !iStatePtr )
       
   818         {
       
   819         return;
       
   820         }
       
   821 
       
   822     TRAP_IGNORE(iStatePtr->HandleCommandL(KResourceChanged));	
       
   823     }
       
   824 
       
   825 // ---------------------------------------------------------------------------
       
   826 // CAknFepUIManagerBase::SetNextFepUI
       
   827 // 
       
   828 // 
       
   829 // ---------------------------------------------------------------------------
       
   830 //
       
   831 void CAknFepUIManagerBase::SetNextFepUI(MAknFepManagerInterface* /*aNextUi*/)
       
   832     {
       
   833     }
       
   834 
       
   835 // ---------------------------------------------------------------------------
       
   836 // CAknFepUIManagerBase::SetStarKeyFlag
       
   837 // 
       
   838 // 
       
   839 // ---------------------------------------------------------------------------
       
   840 //
       
   841 void CAknFepUIManagerBase::SetStarKeyFlag( TBool aSet )
       
   842 	{
       
   843 	if ( iStatePtr )
       
   844         {
       
   845         iStatePtr->SetStarKeyFlag( aSet );
       
   846         }
       
   847 	}
       
   848 #ifdef __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__
       
   849 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   850 // ---------------------------------------------------------------------------
       
   851 // CAknFepUIManagerBase::HandleLongKeyL
       
   852 // 
       
   853 // 
       
   854 // ---------------------------------------------------------------------------
       
   855 //
       
   856 TBool CAknFepUIManagerBase::HandleLongKeyL( TInt aKey )
       
   857     {
       
   858 #ifdef _DEBUG
       
   859     RDebug::Print( _L("HandleLongKeyL(%c)"), aKey );
       
   860 #endif
       
   861     
       
   862     TBool consume = EFalse;
       
   863     
       
   864     if ( iQwertyInputMode &&                                         // Long press implementation for non-QWERTY modes is elsewhere
       
   865          iFepMan->LongPressNumberEntryOnQwerty() &&                  // Is long press number entry supported
       
   866          iFepMan->FnKeyState() == CAknFepFnKeyManager::EFnKeyNone && // Long press is handled differently only in non-Fn modes
       
   867          iFepMan->KeyMapsDifferentCharacterWithFn( (TPtiKey)aKey ) ) // Does the given key have a different character in Fn mode 
       
   868         {
       
   869         TBool charRemoved = RollbackPreviousCharL();
       
   870         
       
   871         // Continue only if there's space left in the editor field after the rollback.
       
   872         // In case of secret editor, the removal of the initial character is asynchronous.
       
   873         // In that case the editor may still seem to be filled up although we have already
       
   874         // queued the rollback event.
       
   875         if ( iFepMan->EditorHasFreeSpace() || charRemoved )
       
   876             {
       
   877             // Long key press load, if editor in textcase mode reload the 
       
   878             // text case mode, because shrot key press reset textcase mode.
       
   879             CaseMan()->SetCurrentCase(iCaseBeforeLongKey);
       
   880             
       
   881             iFepMan->SetFnKeyState( CAknFepFnKeyManager::EFnKeyNext );
       
   882 
       
   883             // Figure out the used case (upper/lower)
       
   884             TPtiTextCase ptiCase = EPtiCaseFnLower;
       
   885             
       
   886             if ( CaseMan()->CurrentCase() == EAknEditorTextCase ||
       
   887                  CaseMan()->CurrentCase() == EAknEditorUpperCase )
       
   888                 {
       
   889                 ptiCase = EPtiCaseFnUpper;
       
   890                 }
       
   891 
       
   892             if ( iFepMan->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode) &&
       
   893                  CaseMan()->IsAbleChangeCase() )
       
   894                 {
       
   895                 // QWERTY shift mode => swap the case
       
   896                 if ( ptiCase == EPtiCaseFnLower ) 
       
   897                     ptiCase = EPtiCaseFnUpper;
       
   898                 else 
       
   899                     ptiCase = EPtiCaseFnLower;
       
   900                 }
       
   901 
       
   902             // In case we are in uppercase mode but there's no characters mapped to that mode,
       
   903             // use the lower case instead.
       
   904             if ( ptiCase == EPtiCaseFnUpper )
       
   905                 {
       
   906                 TBuf<1> upperFnMapping;
       
   907                 iPtiEngine->MappingDataForKey( (TPtiKey)aKey, upperFnMapping, EPtiCaseFnUpper );
       
   908                 if ( !upperFnMapping.Length() )
       
   909                     {
       
   910                     ptiCase = EPtiCaseFnLower;
       
   911                     }
       
   912                 }
       
   913 
       
   914             iPtiEngine->SetCase( ptiCase );
       
   915             }
       
   916         else
       
   917             {
       
   918             consume = ETrue;
       
   919             }
       
   920         }
       
   921     return consume;    
       
   922     }
       
   923 
       
   924 // ---------------------------------------------------------------------------
       
   925 // CAknFepUIManagerBase::RollbackPreviousCharL
       
   926 // 
       
   927 // 
       
   928 // ---------------------------------------------------------------------------
       
   929 //
       
   930 TBool CAknFepUIManagerBase::RollbackPreviousCharL()
       
   931     {
       
   932     TBool characterRemoved = ETrue;
       
   933     
       
   934     if( iFepMan->KeyboardLayout() == EPtiKeyboardHalfQwerty )
       
   935     	{
       
   936         if (iFepMan->IsFlagSet(CAknFepManager::EFlagNoMatches))
       
   937             {
       
   938             iFepMan->TryRemoveNoMatchesIndicatorL();
       
   939             iFepMan->UpdateCbaL(NULL);
       
   940             // make sure that the candidates 
       
   941             // will be updated the next time
       
   942             iPtiEngine->HandleCommandL(EPtiCommandSetFlagToUpdateCandidates);
       
   943             // Need to return as DeleteKeyPress should not be passed to ptiengine.
       
   944             // This is because ptiengine does not maintain the input sequence
       
   945             // if the key press does not increase the word length. So when no matches
       
   946             // character is (?) is deleted, no need to pass to ptiengine. This is to done
       
   947             // to solve the bug :enter characters till the no matches character is shown. Now press
       
   948             // backspace, last character is not deleted.
       
   949             return ETrue;
       
   950             }
       
   951     	}
       
   952     
       
   953     // It depends on the editor type and input mode, how the previous character
       
   954     // can be rolled back.
       
   955     if ( iPtiEngine->HandleCommandL(EPtiCommandDeadKeyWaiting) > 0 )
       
   956         {
       
   957         // The previous key entered a dead character
       
   958         iPtiEngine->HandleCommandL(EPtiCommandGetAndClearDeadKeyRootChar);
       
   959         }
       
   960     else if ( iInputSeqLenDeltaWithLastKey > 0 )
       
   961         {
       
   962         // The previous key entered chracter(s) to input sequence of PtiEngine
       
   963         for ( TInt i=0 ; i<iInputSeqLenDeltaWithLastKey ; ++i )
       
   964             {
       
   965             iPtiEngine->DeleteKeyPress();
       
   966             }
       
   967         if ( iFepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction) )
       
   968             {
       
   969             TPtrC curWord = iPtiEngine->CurrentWord();
       
   970             iFepMan->UpdateInlineEditL( curWord, curWord.Length() );
       
   971             }
       
   972 		if ( iFepMan->IsSupportsSecretText() )
       
   973         	{
       
   974             // Fep communicates with secret text editors using simulated events.
       
   975             iFepMan->SimulateKeyEventL(EKeyF20);
       
   976             iFepMan->ClearFlag( CAknFepManager::EFlagInsideMultitapInlineEditingTransaction);
       
   977             }    
       
   978     
       
   979         }
       
   980     else if ( iEditorTextLenDeltaWithLastKey > 0 )
       
   981         {
       
   982         // The previous key entered character(s) directly to the editor
       
   983         for ( TInt i=0 ; i<iEditorTextLenDeltaWithLastKey ; ++i )
       
   984             {
       
   985             if ( iFepMan->IsSupportsSecretText() )
       
   986                 {
       
   987                 // Fep communicates with secret text editors using simulated events.
       
   988                 iFepMan->SimulateKeyEventL(EKeyF20);
       
   989                 iFepMan->ClearFlag(CAknFepManager::EFlagInsideMultitapInlineEditingTransaction);
       
   990                 }
       
   991             else
       
   992                 {
       
   993                 // In normal editors, the character can be removed directly
       
   994                 iFepMan->RemovePreviousCharacterL();
       
   995                 }
       
   996             }
       
   997         }
       
   998     else
       
   999         {
       
  1000         // The previous key press produced no characters => do nothing
       
  1001         characterRemoved = EFalse;
       
  1002         }
       
  1003         
       
  1004     return characterRemoved;   
       
  1005     }
       
  1006 #endif // RD_INTELLIGENT_TEXT_INPUT
       
  1007 #endif // __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__	
       
  1008 
       
  1009 // add for phrase creation
       
  1010 MZhuyinKeyHandler* CAknFepUIManagerBase::ZhuyinKeyHandler()
       
  1011     {
       
  1012     return iFepMan->ZhuyinKeyHandler();
       
  1013     }
       
  1014 //add for phrase creation
       
  1015 CAknFepZhuyinAnalyser* CAknFepUIManagerBase::ZhuyinAnalyser()
       
  1016     {
       
  1017     return iFepMan->ZhuyinAnalyser();
       
  1018     }
       
  1019 
       
  1020 // End of file