fep/aknfep/src/AknFepUiInputStateEntryThaiPredictive.cpp
changeset 40 2cb9bae34d17
parent 31 f1bdd6b078d1
child 49 37f5d84451bd
equal deleted inserted replaced
31:f1bdd6b078d1 40:2cb9bae34d17
     1 /*
       
     2 * Copyright (c) 2002 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 TAknFepInputStateEntryThaiPredictive methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 #include "AknFepUiInputStateEntryThaiPredictive.h"
       
    31 #include "AknFepUIManagerStateInterface.h"      //MAknFepUIManagerStateInterface
       
    32 #include "AknFepManagerUIInterface.h"           //MAknFepManagerUIInterface
       
    33 #include "AknFepManager.h"
       
    34 #include "AknFepPanic.h"
       
    35 #include "AknFepCaseManager.h"
       
    36 
       
    37 #include <PtiEngine.h>                             //CPtiEngine
       
    38 #include <PtiDefs.h>                            //keys
       
    39 #include <e32keys.h>
       
    40 #include <aknfep.rsg>
       
    41 
       
    42 TAknFepInputStateEntryThaiPredictive::
       
    43 TAknFepInputStateEntryThaiPredictive(MAknFepUIManagerStateInterface* aOwner)
       
    44     :TAknFepInputStateEntryWesternPredictive(aOwner)
       
    45     {
       
    46     //this class insists on the existence of a case manager
       
    47     __ASSERT_DEBUG(iOwner->CaseMan(), AknFepPanic(EAknFepPanicNoCaseManager));
       
    48 
       
    49     iState = EEntry;
       
    50     iMatchState = EWordMatchNone;
       
    51     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    52 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
    53     ptiengine->SetInputMode(EPtiEnginePredictive);
       
    54     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
    55     TBool isUnlimitedEditor = EFalse;
       
    56     ptiengine->SetMaxLengthForAutoCompletedCandidates(fepMan->EditorFreeSpaceForAutoWordCompletion(isUnlimitedEditor ));
       
    57     // To set the input mode
       
    58     if(fepMan->IsAutoCompleteOn())
       
    59         {
       
    60 		TRAP_IGNORE(ptiengine->HandleCommandL(EPtiCommandEnableAutoCompletion));
       
    61         }
       
    62     else
       
    63         {
       
    64 		TRAP_IGNORE(ptiengine->HandleCommandL(EPtiCommandDisableAutoCompletion));
       
    65         }
       
    66     
       
    67     TPtiKeyboardType keyboard = fepMan->KeyboardLayout();
       
    68     ptiengine->SetKeyboardType(keyboard);
       
    69     TBool isNumberCandidateShown = fepMan->IsAdvancedPredictiveNumberCandidateShown();
       
    70 	TRAP_IGNORE(ptiengine->HandleCommandL( EPtiCommandSetNumberCandidateStatus, &isNumberCandidateShown ));
       
    71 #else
       
    72     ptiengine->ClearCurrentWord();
       
    73 #ifdef RD_PRED_AW_COMPLETION
       
    74     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
    75     // To set the input mode
       
    76     if(fepMan->IsAutoCompleteOn())
       
    77         {
       
    78         ptiengine->SetInputMode(EPtiEngineWordCompletion);
       
    79         }
       
    80     else
       
    81 #endif // RD_PRED_AW_COMPLETION
       
    82         {
       
    83         ptiengine->SetInputMode(EPtiEnginePredictive);
       
    84         }
       
    85 #endif // RD_INTELLIGENT_TEXT_INPUT
       
    86     ptiengine->SetCase(EPtiCaseLower);
       
    87     }
       
    88 
       
    89 TBool TAknFepInputStateEntryThaiPredictive::HandleKeyL(TInt aKey, TKeyPressLength aLength)
       
    90     {
       
    91     TBool response = ETrue;
       
    92 
       
    93     switch (aKey)
       
    94         {
       
    95     case EPtiKey1: //fall through
       
    96     case EPtiKey2:
       
    97     case EPtiKey3:
       
    98     case EPtiKey4:
       
    99     case EPtiKey5:
       
   100     case EPtiKey6:
       
   101     case EPtiKey7:
       
   102     case EPtiKey8:
       
   103     case EPtiKey9:
       
   104     case EPtiKey0:
       
   105     case EPtiKeyStar:
       
   106         response = HandleStandardNumericKeysL(aKey, aLength);
       
   107         break;
       
   108     case EKeyDownArrow:
       
   109         response = HandleDownKeyL();
       
   110         break;
       
   111     case EKeyUpArrow:
       
   112         response = HandleUpKeyL();
       
   113         break;
       
   114     case EKeyRightArrow: // fall through
       
   115     case EKeyLeftArrow: 
       
   116     case EKeyBackspace:
       
   117         response = HandleNaviKeysL(aKey, aLength);
       
   118         break;
       
   119     default:
       
   120         response = EFalse;
       
   121         break;
       
   122         }
       
   123     return response;
       
   124     }
       
   125 
       
   126 TBool TAknFepInputStateEntryThaiPredictive::HandleDownKeyL()
       
   127     {
       
   128     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   129     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   130     
       
   131     if (!(fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction)))
       
   132         {
       
   133         return EFalse;
       
   134         }
       
   135     else
       
   136         {
       
   137         if (fepMan->IsFlagSet(CAknFepManager::EFlagNoMatches))
       
   138             {
       
   139             //no more matches
       
   140             fepMan->PlaySound(EAvkonSIDWarningTone);
       
   141             }
       
   142         else if (ptiengine->NumberOfCandidates()<=1)
       
   143             { 
       
   144             // only one match
       
   145             if (iMatchState == EWordMatchFirst || iMatchState == EWordMatchNone)
       
   146                 {
       
   147                 fepMan->UpdateCbaL(R_AKNFEP_SOFTKEYS_SPELL_EMPTY);
       
   148                 iMatchState = EWordMatchLast;
       
   149                 }
       
   150             }
       
   151         else
       
   152             { 
       
   153             // > 1 match
       
   154             if (iMatchState == EWordMatchLast && !(ptiengine->LastEnteredKey() == EPtiKey1))
       
   155                 {
       
   156                 fepMan->UpdateCbaL(R_AKNFEP_SOFTKEYS_SPELL_PREVIOUS);
       
   157                 }
       
   158             else if (iMatchState == EWordMatchFirst || iMatchState == EWordMatchNone)
       
   159                 {
       
   160                 fepMan->UpdateCbaL(R_AKNFEP_SOFTKEYS_EMPTY_PREVIOUS);
       
   161                 iMatchState = EWordMatchStd;
       
   162                 }
       
   163             TPtrC newText = ptiengine->NextCandidate();
       
   164             fepMan->UpdateInlineEditL(newText, 0);
       
   165             }
       
   166         }
       
   167     return ETrue;
       
   168     }
       
   169 
       
   170 TBool TAknFepInputStateEntryThaiPredictive::HandleUpKeyL()
       
   171     {
       
   172     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   173     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   174     if (!(fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction)))
       
   175         {
       
   176         return EFalse;
       
   177         }    
       
   178     
       
   179 #ifdef RD_INTELLIGENT_TEXT_INPUT    
       
   180     TInt lastCandidateIndex = ptiengine->NumberOfCandidates() -1;
       
   181     if(lastCandidateIndex >= 0)
       
   182         {
       
   183         // Get last word on list
       
   184         fepMan->LaunchCandidatePopupListL( lastCandidateIndex );        
       
   185         }
       
   186     else
       
   187         {
       
   188         TInt wordIndexToSelect = 0;
       
   189         // Get next word on list (wrap around if at end)
       
   190         ptiengine->HandleCommandL( EPtiCommandUserActionGetCurrentIndexOfCandidates, 
       
   191 			&wordIndexToSelect );
       
   192         wordIndexToSelect < lastCandidateIndex ? wordIndexToSelect++ : wordIndexToSelect = 0;
       
   193         fepMan->LaunchCandidatePopupListL( wordIndexToSelect );        
       
   194         }                        	                        	    
       
   195 	   
       
   196 #else      
       
   197     if (!( (iMatchState == EWordMatchFirst) || !(fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))))
       
   198         {
       
   199         if (iMatchState == EWordMatchLast || iMatchState == EWordMatchAfterLast)
       
   200             {
       
   201             fepMan->UpdateCbaL(R_AKNFEP_SOFTKEYS_EMPTY_PREVIOUS);
       
   202             }
       
   203         iMatchState = EWordMatchStd; 
       
   204         TPtrC prevText = ptiengine->PreviousCandidate();
       
   205         fepMan->UpdateInlineEditL(prevText, 0);
       
   206         }
       
   207         
       
   208 #endif //RD_INTELLIGENT_TEXT_INPUT
       
   209     return ETrue;
       
   210     }
       
   211 
       
   212 // End of file