fep/aknfep/src/AknFepUiInputStateInitialChineseGenericQwerty.cpp
changeset 36 a7632c26d895
parent 35 0f326f2e628e
child 42 b3eaa440ab06
equal deleted inserted replaced
35:0f326f2e628e 36:a7632c26d895
     1 /*
       
     2 * Copyright (c) 2005 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 TAknFepInputStateInitialChineseGenericQwerty methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 #include "AknFepUiInputStateInitialChineseGenericQwerty.h"
       
    31 #include "AknFepUIManagerStateInterface.h"
       
    32 #include "AknFepManagerUIInterface.h"
       
    33 
       
    34 #include "AknFepManager.h"         //FepMan flag
       
    35 
       
    36 #include <PtiEngine.h>
       
    37 
       
    38 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
    39 #include <AknFepFnKeyManager.h>
       
    40 #endif
       
    41 const TText KZhuyinTone2 = 0x02CA; // qwerty key6
       
    42 const TText KZhuyinTone3 = 0x02C7; // qwerty key3
       
    43 const TText KZhuyinTone4 = 0x02CB; // qwerty key4
       
    44 const TText KZhuyinTone5 = 0x02D9; // qwerty key7
       
    45 
       
    46 TAknFepInputStateInitialChineseGenericQwerty::
       
    47 TAknFepInputStateInitialChineseGenericQwerty(MAknFepUIManagerStateInterface* aOwner, TInt aMode)
       
    48     :TAknFepInputStateQwerty(aOwner)
       
    49     {
       
    50     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    51 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
    52     MPtiLanguage* ptilang = ptiengine->CurrentLanguage(); 
       
    53 #endif
       
    54     
       
    55     switch( aMode )
       
    56         {
       
    57         case EPinyin:
       
    58 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
    59             if (ptilang->HasInputMode(EPtiEnginePinyinPhraseQwerty))
       
    60                 {         
       
    61                 ptiengine->SetInputMode(EPtiEnginePinyinPhraseQwerty);
       
    62                 }
       
    63             else
       
    64 #endif
       
    65             ptiengine->SetInputMode(EPtiEnginePinyinQwerty);
       
    66             break;
       
    67         case EStroke:
       
    68 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
    69             if (ptilang->HasInputMode(EPtiEngineStrokePhraseQwerty))         
       
    70                 ptiengine->SetInputMode(EPtiEngineStrokePhraseQwerty);
       
    71             else
       
    72 #endif
       
    73             ptiengine->SetInputMode(EPtiEngineStrokeQwerty);
       
    74             break;
       
    75         case EZhuyin:
       
    76 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
    77             if (ptilang->HasInputMode(EPtiEngineZhuyinPhraseQwerty))         
       
    78                 ptiengine->SetInputMode(EPtiEngineZhuyinPhraseQwerty);
       
    79             else
       
    80 #endif
       
    81             ptiengine->SetInputMode(EPtiEngineZhuyinQwerty);
       
    82             break;
       
    83         case ECangJie:
       
    84             ptiengine->SetInputMode(EPtiEngineNormalCangjieQwerty);
       
    85             break;
       
    86         default:
       
    87             break;
       
    88         }
       
    89 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
    90     ptiengine->SetKeyboardType(iOwner->FepMan()->KeyboardLayout());        
       
    91 #endif
       
    92     }
       
    93 
       
    94 TBool TAknFepInputStateInitialChineseGenericQwerty::HandleKeyL(TInt aKey, TKeyPressLength aLength)
       
    95     {
       
    96     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    97 
       
    98     TBool ret = EFalse;
       
    99     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   100 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   101 	CAknFepFnKeyManager::TFnKeyState fnKeyState  = fepMan->FnKeyState();
       
   102 	const TPtiKeyboardType keyboardType = ptiengine->KeyboardType();
       
   103 #endif
       
   104 
       
   105     if(iData)
       
   106         {
       
   107         iData = 0;
       
   108         }
       
   109     
       
   110     if(aKey == EStdKeyLeftFunc && aLength == EShortKeyPress) 
       
   111         {
       
   112         if (fepMan->IsAbleToLaunchSCT())
       
   113             {
       
   114             fepMan->LaunchSpecialCharacterTableL();
       
   115             }
       
   116         }
       
   117     else if(iOwner->IsQwertyZhuyinToneMarkKey(aKey) &&
       
   118         aLength == EShortKeyPress
       
   119 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   120         && !fnKeyState   
       
   121 #endif
       
   122         && !fepMan->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode)
       
   123         && !fepMan->IsFlagSet(CAknFepManager::EFlagShiftKeyDepressed)
       
   124         && !fepMan->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed))
       
   125         {
       
   126         TBuf<1> ToneMarkBuf;
       
   127 #ifdef RD_INTELLIGENT_TEXT_INPUT 
       
   128         if( keyboardType == EPtiKeyboardQwerty4x12)
       
   129             {
       
   130 #endif
       
   131         switch(aKey)
       
   132             {
       
   133             case EPtiKeyQwerty3:
       
   134                 ToneMarkBuf.Append(KZhuyinTone3);
       
   135                 break;
       
   136 
       
   137             case EPtiKeyQwerty4:
       
   138                 ToneMarkBuf.Append(KZhuyinTone4);
       
   139                 break;
       
   140 
       
   141             case EPtiKeyQwerty6:
       
   142                 ToneMarkBuf.Append(KZhuyinTone2);
       
   143                 break;
       
   144 
       
   145             case EPtiKeyQwerty7:
       
   146                 ToneMarkBuf.Append(KZhuyinTone5);
       
   147                 break;
       
   148             default:
       
   149                 break;
       
   150             }
       
   151 #ifdef RD_INTELLIGENT_TEXT_INPUT 
       
   152                 }
       
   153             else
       
   154                 if (keyboardType == EPtiKeyboardQwerty4x10 || keyboardType
       
   155                         == EPtiKeyboardQwerty3x11)
       
   156                     {
       
   157                     switch (aKey)
       
   158                         {
       
   159                         case EPtiKeyQwertyE:
       
   160                             ToneMarkBuf.Append(KZhuyinTone3);
       
   161                             break;
       
   162 
       
   163                         case EPtiKeyQwertyR:
       
   164                             ToneMarkBuf.Append(KZhuyinTone4);
       
   165                             break;
       
   166 
       
   167                         case EPtiKeyQwertyY:
       
   168                             ToneMarkBuf.Append(KZhuyinTone2);
       
   169                             break;
       
   170 
       
   171                         case EPtiKeyQwertyU:
       
   172                             ToneMarkBuf.Append(KZhuyinTone5);
       
   173                             break;
       
   174                         default:
       
   175                             break;
       
   176                         }
       
   177                     }
       
   178 #endif
       
   179         
       
   180         MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   181         fepMan->NewCharacterL(ToneMarkBuf);
       
   182         fepMan->CommitInlineEditL();
       
   183         if (fepMan->IsFlagSet(CAknFepManager::EFlagEditorFull))
       
   184             {
       
   185             fepMan->ClearFlag(CAknFepManager::EFlagEditorFull);
       
   186             iOwner->FepMan()->TryCloseUiL();
       
   187             }
       
   188         ret = ETrue;
       
   189         }
       
   190     else if(iOwner->IsValidChineseInputKeyQwerty(aKey) && 
       
   191             !fepMan->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed) && 
       
   192 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   193             !fepMan->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode) &&
       
   194             !fepMan->IsFlagSet(CAknFepManager::EFlagShiftKeyDepressed) &&
       
   195             !fnKeyState)
       
   196 #else
       
   197             !fepMan->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode))
       
   198 #endif
       
   199         {
       
   200         if ( aLength == EShortKeyPress )
       
   201         	{
       
   202             ptiengine->ClearCurrentWord();
       
   203             ptiengine->ResetToneMark();
       
   204             
       
   205             if(iOwner->ChangeState(EEntry) == EEntry)
       
   206                 {
       
   207                 iOwner->FepMan()->SendUIActivatedNotification();
       
   208                 }
       
   209         	}
       
   210         else
       
   211         	{
       
   212         	return ETrue;
       
   213         	}
       
   214         }
       
   215     else if (fepMan->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode) && 
       
   216              fepMan->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed))
       
   217         {
       
   218         ret = ETrue;
       
   219         }
       
   220     else if (IsCharacter(aKey) || IsSCTKey(aKey))
       
   221         {
       
   222         HandleKeyByShiftOrCharPressed(aKey,aLength);
       
   223         if (fepMan->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed))
       
   224             {
       
   225             fepMan->ClearFlag(CAknFepManager::EFlagNoActionDuringChrKeyPress);        
       
   226             }
       
   227         ret = ETrue;
       
   228         }
       
   229     else if ((IsCharacter(aKey) || aKey == EPtiKeyQwertySpace) 
       
   230            && fepMan->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed))
       
   231         {
       
   232         fepMan->ClearFlag(CAknFepManager::EFlagQwertyChrKeyDepressed);
       
   233         fepMan->ClearFlag(CAknFepManager::EFlagNoActionDuringChrKeyPress);
       
   234 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   235         if((aKey == EPtiKeyQwertySpace) &&EPtiKeyboardQwerty4x12 != ptiengine->KeyboardType())
       
   236             {
       
   237             TPtrC text;
       
   238             _LIT(KSpaceCharacter, " ");
       
   239             text.Set(KSpaceCharacter);        
       
   240                 
       
   241             if (text.Length())
       
   242                 {
       
   243                 TBuf<1> chr;            
       
   244                 for (TInt jj = 0; jj < text.Length(); jj++)
       
   245                    	{
       
   246                    	chr.Zero();
       
   247                    	chr.Append(text[jj]);
       
   248                     fepMan->NewCharacterL(chr);               	         	                        
       
   249                	    fepMan->CommitInlineEditL();
       
   250                    	}
       
   251                 ret = ETrue;
       
   252                 }                
       
   253             }
       
   254 #endif
       
   255         }
       
   256 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   257     else if(aKey == EPtiKeyQwertySpace)
       
   258         {
       
   259         if (fnKeyState == CAknFepFnKeyManager::EFnKeyDown)
       
   260             {
       
   261             fepMan->LaunchSelectModeMenuL();
       
   262             ret = ETrue;
       
   263             }
       
   264         else
       
   265             {
       
   266 	        TPtrC text;
       
   267 	        _LIT(KSpaceCharacter, " ");
       
   268 	        text.Set(KSpaceCharacter);        
       
   269 	            
       
   270 	        if (text.Length())
       
   271 	            {
       
   272 	            TBuf<1> chr;            
       
   273 	            for (TInt jj = 0; jj < text.Length(); jj++)
       
   274 	               	{
       
   275 	               	chr.Zero();
       
   276 	               	chr.Append(text[jj]);
       
   277 	                fepMan->NewCharacterL(chr);               	         	                        
       
   278 	           	    fepMan->CommitInlineEditL();
       
   279 	           	    //ptiengine->ClearCurrentWord();
       
   280 	               	}
       
   281 	            ret = ETrue;
       
   282 	            } 
       
   283             }
       
   284         }
       
   285 #endif
       
   286     return ret;
       
   287     }
       
   288 
       
   289 TBool TAknFepInputStateInitialChineseGenericQwerty::IsSCTKey(TInt aKey)
       
   290     {
       
   291     TBool response = EFalse;
       
   292 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   293     CPtiEngine* ptiengine = iOwner->PtiEngine();   
       
   294     if(EPtiKeyboardQwerty4x12 == ptiengine->KeyboardType()) 
       
   295         {
       
   296 #endif
       
   297     if (IsNumberKey( aKey ) ||
       
   298         aKey == EPtiKeyQwertyPlus ||
       
   299         aKey == EPtiKeyQwertyMinus ||
       
   300         aKey == EPtiKeyQwertyComma ||
       
   301         aKey == EPtiKeyQwertySemicolon ||
       
   302         aKey == EPtiKeyQwertyFullstop ||
       
   303         aKey == EPtiKeyQwertyHash ||
       
   304         aKey == EPtiKeyQwertySlash ||
       
   305         aKey == EPtiKeyQwertyApostrophe)
       
   306         {
       
   307         response = ETrue;
       
   308         }
       
   309 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   310         }
       
   311     else if(EPtiKeyboardQwerty4x10 == ptiengine->KeyboardType())
       
   312         {
       
   313         if(aKey == EPtiKeyQwertyComma ||
       
   314            aKey == EPtiKeyQwertyFullstop ||
       
   315            aKey == EPtiKeyQwertySlash ||
       
   316            aKey == EStdKeySingleQuote ||
       
   317            aKey == EStdKeySquareBracketRight ||
       
   318            aKey == EStdKeySquareBracketLeft)
       
   319             {
       
   320             response = ETrue;
       
   321             }
       
   322         }
       
   323     else if(EPtiKeyboardQwerty3x11 == ptiengine->KeyboardType())
       
   324     	{
       
   325     	 if(aKey == EPtiKeyQwertyComma ||
       
   326     		aKey == EPtiKeyQwertyFullstop ||
       
   327     	    aKey == EPtiKeyQwertySlash ||
       
   328     	    aKey == EStdKeySingleQuote ||
       
   329     	    aKey == EStdKeySquareBracketRight ||
       
   330     	    aKey == EPtiKeyQwertyAtCharacter )
       
   331     		 {
       
   332     		 response = ETrue;
       
   333     		 }
       
   334     	}
       
   335 #endif
       
   336     return response;
       
   337     }
       
   338 
       
   339 TBool TAknFepInputStateInitialChineseGenericQwerty::IsCharacter(TInt aKey)
       
   340     {
       
   341     TBool response = EFalse;
       
   342     if (aKey >= EPtiKeyQwertyA && aKey <= EPtiKeyQwertyZ)
       
   343         {
       
   344         response = ETrue;
       
   345         }
       
   346     return response;
       
   347     }
       
   348     
       
   349 TBool TAknFepInputStateInitialChineseGenericQwerty::HandleKeyByShiftOrCharPressed(TInt aKey, 
       
   350                                                                                   TKeyPressLength /*aLength*/)
       
   351     {
       
   352     TBool ret = EFalse;
       
   353     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   354 
       
   355     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   356     CAknFepCaseManager* caseMan = iOwner->CaseMan(); 
       
   357 
       
   358     fepMan->ClearFlag(CAknFepManager::EFlagNoActionDuringShiftKeyPress);
       
   359     
       
   360     TPtiTextCase caseMode = EPtiCaseLower;
       
   361     if (fepMan->IsOnlyNumericPermitted())
       
   362         {
       
   363         return ret;
       
   364         }
       
   365     TPtiTextCase shiftedCase = caseMode;
       
   366     if (fepMan->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode | CAknFepManager::EFlagShiftKeyDepressed)) 
       
   367         {
       
   368         shiftedCase = EPtiCaseUpper;
       
   369         } 
       
   370     
       
   371     if (fepMan->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed) )
       
   372         {
       
   373         shiftedCase = EPtiCaseChrLower;
       
   374         }
       
   375 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   376     if (fepMan->FnKeyState())
       
   377         {
       
   378         shiftedCase = EPtiCaseFnLower;
       
   379         }
       
   380 #endif
       
   381     
       
   382     ptiengine->SetCase(shiftedCase);
       
   383     
       
   384 
       
   385     TPtrC text;
       
   386     text.Set(ptiengine->AppendKeyPress((TPtiKey)aKey));
       
   387         
       
   388     if (text.Length())
       
   389         {
       
   390         TBuf<1> chr;            
       
   391         for (TInt jj = 0; jj < text.Length(); jj++)
       
   392            	{
       
   393            	chr.Zero();
       
   394            	chr.Append(text[jj]);
       
   395            	TRAP_IGNORE(fepMan->NewCharacterL(chr));
       
   396            	TRAP_IGNORE(fepMan->CommitInlineEditL());
       
   397        	    ptiengine->ClearCurrentWord();
       
   398            	}
       
   399         ret = ETrue;
       
   400         }
       
   401 
       
   402     return ret;
       
   403     }
       
   404 
       
   405 void TAknFepInputStateInitialChineseGenericQwerty::KeyTimerExpired()
       
   406     {
       
   407     
       
   408     }    
       
   409     
       
   410 // End of file