fep/aknfep/src/AknFepUiInputStateInitialKoreanMultitap.cpp
changeset 0 eb1f2e154e89
child 3 f5a1e66df979
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     1 /*
       
     2 * Copyright (c) 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 TAknFepInputStateInitialKoreanMultitap methods.
       
    16 *
       
    17 */
       
    18 
       
    19 #include "AknFepUiInputStateInitialKoreanMultitap.h"
       
    20 #include "AknFepUIManagerStateInterface.h"      //MAknFepUIManagerStateInterface
       
    21 #include "AknFepManagerUIInterface.h"           //MAknFepManagerUIInterface
       
    22 #include "AknFepCaseManager.h"
       
    23 #include "AknFepUiIndicInputManager.h"
       
    24 #include "AknFepManager.h"
       
    25 
       
    26 #include <PtiEngine.h>
       
    27 #include <PtiDefs.h>
       
    28 
       
    29 TAknFepInputStateInitialKoreanMultitap::TAknFepInputStateInitialKoreanMultitap(MAknFepUIManagerStateInterface* aOwner)
       
    30     :TAknFepInputStateInitialMultitapBase(aOwner)
       
    31     {
       
    32     iState = EInitial; 
       
    33     
       
    34     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
    35     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    36 
       
    37     TPtiTextCase caseMode = ptiengine->Case();
       
    38 
       
    39 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
    40      TRAP_IGNORE(ptiengine->ActivateLanguageL(ELangKorean, EPtiEngineMultitappingKorean))
       
    41     ptiengine->SetInputMode(EPtiEngineMultitappingKorean);
       
    42 #else
       
    43      TRAP_IGNORE(ptiengine->ActivateLanguageL(ELangKorean, EPtiEngineMultitapping))
       
    44     ptiengine->SetInputMode(EPtiEngineMultitapping);
       
    45 #endif //RD_INTELLIGENT_TEXT_INPUT
       
    46 
       
    47     ptiengine->SetCase(caseMode);
       
    48     }
       
    49 
       
    50 TBool TAknFepInputStateInitialKoreanMultitap::HandleKeyL(TInt aKey, TKeyPressLength aLength)
       
    51     {
       
    52     
       
    53     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
    54     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    55     TBool ret = ETrue;
       
    56        
       
    57     if(aLength == EShortKeyPress)
       
    58         {
       
    59                      
       
    60        	if(aKey == EKeyBackspace)
       
    61         	{
       
    62         	// Narat Geul engine tries first to disassemble hangul to jamos. if disassembly is not possible,
       
    63         	// then clear character. 
       
    64         	if (fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))
       
    65         		{
       
    66         		TPtrC newText = ptiengine->DeleteKeyPress();
       
    67        			fepMan->UpdateInlineEditL(newText, newText.Length());
       
    68        			
       
    69         		if (newText.Length() == 0)
       
    70         			{
       
    71 	        		fepMan->CancelInlineEdit();
       
    72    		     		ptiengine->ClearCurrentWord();
       
    73         			}	      	
       
    74         		}
       
    75         	else
       
    76         		{
       
    77         		ret = EFalse;	
       
    78         		}
       
    79         	}
       
    80         else
       
    81             {
       
    82 	
       
    83             if(aKey == EKeyLeftArrow ||
       
    84             	aKey == EKeyRightArrow ||
       
    85             	aKey == EKeyDownArrow ||
       
    86             	aKey == EKeyUpArrow)
       
    87             	{
       
    88                	ret = EFalse;            
       
    89             	}
       
    90             else
       
    91             	{
       
    92             	if (!(fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction)))
       
    93                 	{ // 'new' inline edit
       
    94              	  	ptiengine->ClearCurrentWord();
       
    95                 	fepMan->StartInlineEditL();
       
    96                 	fepMan->SetInlineEditingCursorVisibilityL(ETrue);
       
    97                 	}
       
    98                       	   	             
       
    99             	TPtrC aText = ptiengine->AppendKeyPress((TPtiKey)aKey);
       
   100             	fepMan->UpdateInlineEditL(aText, aText.Length());	
       
   101    						
       
   102             	// Force commit	when buffer length is 511. Needs to be commited in order to 
       
   103             	// prevent ptiengines iTextBuffer overflow. Even though it is very unlikely
       
   104             	// case
       
   105             	if(aText.Length() >= 254)
       
   106             		{
       
   107             		if (CommitOrNot(aText.Right(CAknFepManager::ESingleCharacter), aKey))
       
   108             			{
       
   109             			TPtrC text = ptiengine->DeleteKeyPress();
       
   110             			fepMan->UpdateInlineEditL(text, text.Length());
       
   111             			fepMan->CommitInlineEditL();
       
   112             			
       
   113             			ptiengine->ClearCurrentWord();
       
   114             			
       
   115             			TPtrC newText = ptiengine->AppendKeyPress((TPtiKey)aKey);			
       
   116             			fepMan->StartInlineEditL();
       
   117             			fepMan->UpdateInlineEditL(newText, newText.Length());	
       
   118             			}
       
   119             		else if(aText.Length() >= 255)
       
   120             			{// force commit 
       
   121             			fepMan->CommitInlineEditL();	
       
   122             			}
       
   123             		}
       
   124 				else
       
   125 					{
       
   126 					fepMan->UpdateInlineEditL(aText, aText.Length());	
       
   127 					}           		
       
   128             	}                                                              	  	                    				
       
   129           	}    
       
   130         }
       
   131     else // long keypress
       
   132         {  
       
   133           
       
   134  	    if (aKey == EPtiKeyStar)
       
   135             {
       
   136 
       
   137            	ptiengine->DeleteKeyPress();
       
   138             TPtrC text = ptiengine->PreviousCandidate();
       
   139             fepMan->UpdateInlineEditL(text, text.Length());
       
   140             fepMan->CommitInlineEditL();
       
   141             ptiengine->ClearCurrentWord();
       
   142 
       
   143             fepMan->LaunchSelectModeMenuL();               
       
   144             }
       
   145 		else
       
   146 			{
       
   147 			// Insert number through long key press.			                  
       
   148         	if (aKey != EKeyBackspace)
       
   149         		{
       
   150         		if (!fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))
       
   151         			{
       
   152         			// No edit transaction going on, we have ended here because of long
       
   153         			// key press created editor on UI or some other similar non-standard situation.
       
   154         			// We can't handle key press, so just consume it.
       
   155         			return ETrue; 			
       
   156         			}
       
   157 				
       
   158 			 	TPtrC text = ptiengine->PreviousCandidate();
       
   159            	 	fepMan->UpdateInlineEditL(text, text.Length());
       
   160                	fepMan->CommitInlineEditL();
       
   161                	ptiengine->ClearCurrentWord();
       
   162        			ret = EFalse;
       
   163         		}
       
   164         	else if (aKey == EKeyBackspace)
       
   165         		{
       
   166         		if (fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))
       
   167         			{
       
   168 					fepMan->CommitInlineEditL();
       
   169 					ptiengine->ClearCurrentWord();
       
   170 					fepMan->TryCloseUiL();
       
   171         			}
       
   172         		ret = EFalse;	
       
   173         		}
       
   174         	else
       
   175         		{
       
   176         		ret = EFalse;
       
   177         		}       		
       
   178 			}
       
   179 		
       
   180         } 
       
   181     return ret;
       
   182     } 
       
   183      
       
   184 // Decides wheather text should be commited or not. Makes comparison between latest key input
       
   185 // and "seed" jamos. if latest input match with one of "seed" jamos and star or hash key cannot make
       
   186 // any changes to input, then commit.
       
   187 // NOTE; the "seed" jamos are characters that are printed on keymat. Narat geul engine compiles all
       
   188 // the hanguls from 12 jamos.  
       
   189 TBool TAknFepInputStateInitialKoreanMultitap::CommitOrNot(TPtrC aData, TInt aKey)
       
   190 	{
       
   191 	TBool commit = EFalse;
       
   192 	TBuf<CAknFepManager::EMaximumFepWordLength> mappings;
       
   193 	TInt len;
       
   194 	
       
   195 	CPtiEngine* ptiengine = iOwner->PtiEngine();	
       
   196 	MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   197 	
       
   198 	ptiengine->MappingDataForKey((TPtiKey)aKey, mappings, ptiengine->Case());
       
   199 	len = mappings.Length();
       
   200 	
       
   201 	for (TInt i = 0; i < len; i++ )
       
   202 		{
       
   203 		if(aData.Compare(mappings.Left(i + 1)) == 0)
       
   204 			{
       
   205 			commit = ETrue;
       
   206 			break;
       
   207 			}
       
   208 		}
       
   209 		
       
   210 	return commit;
       
   211 	}
       
   212 
       
   213 // End of file