fep/aknfep/src/aknfepuiinputstateqwertykorean.cpp
branchRCL_3
changeset 19 ac7e4d1d9209
parent 0 eb1f2e154e89
equal deleted inserted replaced
18:b1ea1642412e 19:ac7e4d1d9209
    22 //#include "AknFepDbgKorean.h"
    22 //#include "AknFepDbgKorean.h"
    23 
    23 
    24 #include <PtiEngine.h>
    24 #include <PtiEngine.h>
    25 #include <PtiDefs.h>
    25 #include <PtiDefs.h>
    26 #include <PtiKeyMappings.h>
    26 #include <PtiKeyMappings.h>
    27 #include <PtiDefs.h>        
    27 #include <PtiDefs.h>   
       
    28 
       
    29 const TInt KMaxPtiTextBufSize = 255;
    28 
    30 
    29 TAknFepInputStateQwertyKorean::TAknFepInputStateQwertyKorean(
    31 TAknFepInputStateQwertyKorean::TAknFepInputStateQwertyKorean(
    30         MAknFepUIManagerStateInterface* aOwner)
    32         MAknFepUIManagerStateInterface* aOwner)
    31     : TAknFepInputStateQwerty(aOwner)
    33     : TAknFepInputStateQwerty(aOwner)
    32     {
    34     {
    37 
    39 
    38 TAknFepInputStateQwertyKorean::~TAknFepInputStateQwertyKorean()
    40 TAknFepInputStateQwertyKorean::~TAknFepInputStateQwertyKorean()
    39     {
    41     {
    40     }
    42     }
    41 
    43 
    42 TBool TAknFepInputStateQwertyKorean::HandleKeyL(TInt aKey, TKeyPressLength /*aLength*/)
    44 TBool TAknFepInputStateQwertyKorean::HandleKeyL(TInt aKey, TKeyPressLength aLength)
    43     {
    45     {	
    44 //    LOG2("KO.IS.QWERTY.HandleKeyL %d,%d",aKey,aLength);
    46     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
    45     CPtiEngine& ptiEngine(*(iOwner->PtiEngine()));
    47     CPtiEngine* ptiengine = iOwner->PtiEngine();
    46     MAknFepManagerUIInterface& fepMan(*(iOwner->FepMan()));
    48     TBool ret = ETrue;
    47     
    49        
    48     TPtrC text(ptiEngine.AppendKeyPress((TPtiKey)aKey));
    50 	switch( aKey )
    49     TBuf<1> chr;            
    51 		{
    50     for (TInt jj = 0; jj < text.Length(); jj++)
    52 		case EKeyDelete:
    51         {
    53 		case EStdKeyDelete:
    52         chr.Zero();
    54 		case EKeyBackspace:
    53         chr.Append(text[jj]);
    55 		case EStdKeyBackspace:
    54         fepMan.NewCharacterL(chr);
    56 			{
    55         }
    57 			if (fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))
    56     return ETrue;
    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;
    57     }
   153     }
    58 
       
    59 void TAknFepInputStateQwertyKorean::KeyTimerExpired()
       
    60     {
       
    61 //    LOG1("KO.IS.QWERTY.KeyTimerExpired %d",iData);
       
    62     CPtiEngine& ptiEngine(*(iOwner->PtiEngine()));
       
    63     MAknFepManagerUIInterface& fepMan(*(iOwner->FepMan()));
       
    64     
       
    65     TPtrC text(ptiEngine.CurrentWord());
       
    66     TBuf<1> chr;            
       
    67     for (TInt jj = 0; jj < text.Length(); jj++)
       
    68         {
       
    69         chr.Zero();
       
    70         chr.Append(text[jj]);
       
    71         TRAP_IGNORE( fepMan.NewCharacterL(chr) );
       
    72         }
       
    73     
       
    74     //TRAPD(err, fepMan.CommitInlineEditL())
       
    75     TRAP_IGNORE( fepMan.CommitInlineEditL() )
       
    76     }
       
    77 
       
    78 //fepMan.StartInlineEditL(text);
       
    79 //iFepMan.StartInlineEditL()
       
    80 //virtual void SetCursorSelectionL(const TCursorSelection& aCurSel, TBool aSyncCursor) = 0;