fep/aknfep/src/aknfepuiinputstateqwertykorean.cpp
branchRCL_3
changeset 44 ecbabf52600f
child 56 8152b1f1763a
equal deleted inserted replaced
43:ebd48d2de13c 44:ecbabf52600f
       
     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 *       CAknFepInputStateQwertyKorean implementation
       
    16 *
       
    17 */
       
    18 
       
    19 #include "AknFepUiInputStateQwertyKorean.h"
       
    20 #include "AknFepUIManagerStateInterface.h"      //MAknFepUIManagerStateInterface
       
    21 #include "AknFepManagerUIInterface.h"           //MAknFepManagerUIInterface
       
    22 //#include "AknFepDbgKorean.h"
       
    23 
       
    24 #include <PtiEngine.h>
       
    25 #include <PtiDefs.h>
       
    26 #include <PtiKeyMappings.h>
       
    27 #include <PtiDefs.h>   
       
    28 
       
    29 const TInt KMaxPtiTextBufSize = 255;
       
    30 
       
    31 TAknFepInputStateQwertyKorean::TAknFepInputStateQwertyKorean(
       
    32         MAknFepUIManagerStateInterface* aOwner)
       
    33     : TAknFepInputStateQwerty(aOwner)
       
    34     {
       
    35     CPtiEngine& ptiEngine(*(aOwner->PtiEngine()));
       
    36     ptiEngine.SetInputMode(EPtiEngineQwertyKorean);
       
    37     ptiEngine.ClearCurrentWord();
       
    38     }
       
    39 
       
    40 TAknFepInputStateQwertyKorean::~TAknFepInputStateQwertyKorean()
       
    41     {
       
    42     }
       
    43 
       
    44 TBool TAknFepInputStateQwertyKorean::HandleKeyL(TInt aKey, TKeyPressLength aLength)
       
    45     {	
       
    46     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
    47     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    48     TBool ret = ETrue;
       
    49        
       
    50 	switch( aKey )
       
    51 		{
       
    52 		case EKeyDelete:
       
    53 		case EStdKeyDelete:
       
    54 		case EKeyBackspace:
       
    55 		case EStdKeyBackspace:
       
    56 			{
       
    57 			if (fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))
       
    58 				{
       
    59 				TPtrC newText = ptiengine->DeleteKeyPress();
       
    60 				if( newText.Length() > 0 )
       
    61 					{
       
    62 					  fepMan->UpdateInlineEditL(newText, newText.Length());
       
    63 					}
       
    64 				else
       
    65 					{
       
    66 					fepMan->CancelInlineEdit();
       
    67 					ptiengine->ClearCurrentWord();
       
    68 					}	      	
       
    69 				}
       
    70 			else
       
    71 				{
       
    72 				ret = EFalse;	
       
    73 				}
       
    74 			}
       
    75 			break;
       
    76 		case EStdKeyEnter:
       
    77 		case EStdKeySpace:
       
    78 		case EStdKeyTab:
       
    79 		case EStdKeyLeftArrow:
       
    80 		case EStdKeyRightArrow:
       
    81 		case EStdKeyDownArrow:
       
    82 		case EStdKeyUpArrow:
       
    83 			{
       
    84 			fepMan->CommitInlineEditL();	
       
    85 			ptiengine->CommitCurrentWord();
       
    86 			ret = EFalse; 
       
    87 			}
       
    88 			break;
       
    89 		default:
       
    90 			{
       
    91 			//normal character handled here
       
    92 			if ( EShortKeyPress == aLength )
       
    93 				{
       
    94 				if (!(fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction)))
       
    95 					{ 
       
    96 					// start inline edit
       
    97 					ptiengine->ClearCurrentWord();
       
    98 					fepMan->StartInlineEditL();
       
    99 					fepMan->SetInlineEditingCursorVisibilityL(ETrue);
       
   100 					}
       
   101 										 
       
   102 				TPtrC aText = ptiengine->AppendKeyPress((TPtiKey)aKey);
       
   103 				if( aText.Length() > 0 )
       
   104 					{
       
   105 					 fepMan->UpdateInlineEditL(aText, aText.Length());	
       
   106 					 if( aText.Length()  >= KMaxPtiTextBufSize )
       
   107 						{
       
   108 						// force commit 
       
   109 						fepMan->CommitInlineEditL();	
       
   110 						ptiengine->CommitCurrentWord();
       
   111 						}	
       
   112 					}	
       
   113 				}
       
   114 			else // long press
       
   115 				{
       
   116 				if (!fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))
       
   117 					{
       
   118 					return ETrue; 			
       
   119 					}
       
   120 				
       
   121 				//delete last input text
       
   122 				TPtrC text = ptiengine->DeleteKeyPress();
       
   123 				if( text.Length() >0 )
       
   124 					{
       
   125 				    fepMan->UpdateInlineEditL(text, text.Length());
       
   126 					}
       
   127 	            
       
   128 	            // add new text
       
   129 				TPtiTextCase previousCase = ptiengine->Case();
       
   130 				switch ( previousCase )
       
   131 					{
       
   132 					case EPtiCaseLower:
       
   133 					case EPtiCaseUpper:
       
   134 						ptiengine->SetCase( EPtiCaseFnLower );
       
   135 						break;
       
   136 					default:
       
   137 						break;
       
   138 					}
       
   139 					   
       
   140 				TPtrC newText = ptiengine->AppendKeyPress((TPtiKey)aKey);
       
   141 				if( newText.Length() >0 )
       
   142 					{
       
   143 					 fepMan->UpdateInlineEditL(newText, newText.Length());
       
   144 					}
       
   145 				ptiengine->SetCase( previousCase );
       
   146 				fepMan->CommitInlineEditL();
       
   147 				ptiengine->ClearCurrentWord();
       
   148 				}
       
   149 			}  
       
   150 			break;
       
   151 		}                                                             	  	                    				   
       
   152     return ret;
       
   153     }