textinput/peninputfingerhwrar/src/peninputfingerhwrarlayout.cpp
branchRCL_3
changeset 12 5e18d8c489d6
parent 7 6defe5d1bd39
child 19 ac7e4d1d9209
equal deleted inserted replaced
11:c8fb4cf7b3ae 12:5e18d8c489d6
    16 */
    16 */
    17 
    17 
    18 //SYSTEM INCLUDES
    18 //SYSTEM INCLUDES
    19 #include <bautils.h>
    19 #include <bautils.h>
    20 #include <coemain.h>
    20 #include <coemain.h>
    21 
    21 #include <CommonEngineDomainCRKeys.h>
    22 //FEP Includes
    22 //FEP Includes
    23 #include <aknfepglobalenums.h>
    23 #include <AknFepGlobalEnums.h>
    24 #include <aknfeppeninputenums.h>
    24 #include <aknfeppeninputenums.h>
    25 #include <peninputlayoutchoicelist.h>
    25 #include <peninputlayoutchoicelist.h>
    26 #include <settingsinternalcrkeys.h>
    26 #include <settingsinternalcrkeys.h>
    27 #include <centralrepository.h>
    27 #include <centralrepository.h>
    28 #include <peninputlayoutvkb.h>
    28 #include <peninputlayoutvkb.h>
    47 const TUint8 KIntLen = sizeof(TInt)/2;
    47 const TUint8 KIntLen = sizeof(TInt)/2;
    48 const TUint8 KIntSize = sizeof(TInt);
    48 const TUint8 KIntSize = sizeof(TInt);
    49 
    49 
    50 const TInt16 KEmotionKeyMark = 0xFFFE;
    50 const TInt16 KEmotionKeyMark = 0xFFFE;
    51 
    51 
       
    52 class CPeninputFingerHwrArCallBack : public CActive
       
    53     {
       
    54     friend class CPeninputFingerHwrArLayout;
       
    55 public:
       
    56     void IssueRequestL();
       
    57 private:
       
    58     CPeninputFingerHwrArCallBack(CPeninputFingerHwrArLayout* aHwrArLayout);
       
    59 	void RunL();
       
    60 	void DoCancel();
       
    61 private:
       
    62     CPeninputFingerHwrArLayout* iHwrArLayout;
       
    63 	};
       
    64 
       
    65 CPeninputFingerHwrArCallBack::CPeninputFingerHwrArCallBack(CPeninputFingerHwrArLayout* aHwrArLayout)
       
    66     :CActive(EPriorityHigh)
       
    67     {
       
    68 	CActiveScheduler::Add(this);
       
    69 	iHwrArLayout = aHwrArLayout;
       
    70 	}
       
    71 void CPeninputFingerHwrArCallBack::IssueRequestL()
       
    72     {
       
    73     if(!IsActive())
       
    74         {
       
    75         iStatus=KRequestPending;
       
    76         SetActive();        
       
    77         TRequestStatus *pS=(&iStatus);
       
    78         
       
    79         User::RequestComplete(pS,0);
       
    80         }
       
    81     }
       
    82 void CPeninputFingerHwrArCallBack::RunL()
       
    83     {
       
    84     iHwrArLayout->CallBackL();
       
    85     }
       
    86 
       
    87 void CPeninputFingerHwrArCallBack::DoCancel()
       
    88     {
       
    89     
       
    90     }
       
    91 
    52 // ============================ MEMBER FUNCTIONS =============================
    92 // ============================ MEMBER FUNCTIONS =============================
    53 
    93 
    54 // ---------------------------------------------------------------------------
    94 // ---------------------------------------------------------------------------
    55 // Symbian Constructor
    95 // Symbian Constructor
    56 // ---------------------------------------------------------------------------
    96 // ---------------------------------------------------------------------------
    85 
   125 
    86     iDataStore = CPeninputFingerHwrArDataStore::NewL( (*layoutData).iPtiEngine, this );
   126     iDataStore = CPeninputFingerHwrArDataStore::NewL( (*layoutData).iPtiEngine, this );
    87 
   127 
    88     //create the repository for gereral settings
   128     //create the repository for gereral settings
    89     iRepositorySetting = CRepository::NewL( KCRUidPersonalizationSettings );
   129     iRepositorySetting = CRepository::NewL( KCRUidPersonalizationSettings );
    90 
       
    91     //create the repository watcher for general settings
   130     //create the repository watcher for general settings
    92     iGSRepositoryWatcher = CAknFepRepositoryWatcher::NewL( 
   131     iGSRepositoryWatcher = CAknFepRepositoryWatcher::NewL( 
    93             KCRUidPersonalizationSettings, 
   132             KCRUidPersonalizationSettings, 
    94             TCallBack( HandleGSRepositoryCallBack, this ), 
   133             TCallBack( HandleGSRepositoryCallBack, this ), 
    95             iRepositorySetting );
   134             iRepositorySetting );
   101     CreateHwrWindowL();
   140     CreateHwrWindowL();
   102 	
   141 	
   103 	//retrieve the settings
   142 	//retrieve the settings
   104     LoadAndPublishDefaultL();
   143     LoadAndPublishDefaultL();
   105 	
   144 	
       
   145     //iCallBack = new (ELeave) CPeninputFingerHwrArCallBack(this);
       
   146     
   106     //set screen layout extent
   147     //set screen layout extent
   107     SetRect( TRect( TPoint( 0, 0 ), ScreenSize() ) );
   148     SetRect( TRect( TPoint( 0, 0 ), ScreenSize() ) );
   108     }
   149     }
   109 	
   150 	
   110 // ---------------------------------------------------------------------------
   151 // ---------------------------------------------------------------------------
   140     switch ( aCmd )
   181     switch ( aCmd )
   141         {
   182         {
   142         case ECmdPenInputEditorNumericKeyMap:
   183         case ECmdPenInputEditorNumericKeyMap:
   143             {
   184             {
   144             iDataStore->SetNumberMode( *(TAknEditorNumericKeymap*)aData );
   185             iDataStore->SetNumberMode( *(TAknEditorNumericKeymap*)aData );
       
   186             OnNumMappingChangedL();
   145             }
   187             }
   146             break;
   188             break;
   147         case ECmdPenInputEditorCustomNumericKeyMap:
   189         case ECmdPenInputEditorCustomNumericKeyMap:
   148             {
   190             {
   149             TInt len = *( TInt* )( aData - KIntSize );
   191             TInt len = *( TInt* )( aData - KIntSize );
   159             break;
   201             break;
   160         case ECmdPenInputLanguage:
   202         case ECmdPenInputLanguage:
   161             {
   203             {
   162             TInt language = *( TInt* )aData;
   204             TInt language = *( TInt* )aData;
   163             iDataStore->SetLanguageL( language );
   205             iDataStore->SetLanguageL( language );
       
   206             if(iHwrWnd)
       
   207                 {
       
   208                 iHwrWnd->SetIcfLanguage(language);
       
   209                 }
   164             }
   210             }
   165             break;
   211             break;
   166         case ECmdPenInputPermittedCase:
   212         case ECmdPenInputPermittedCase:
   167             {
   213             {
   168             TInt cs = *( TInt* )aData;
   214             TInt cs = *( TInt* )aData;
   221             break;
   267             break;
   222         case ECmdPenInputEnableSettingBtn:    
   268         case ECmdPenInputEnableSettingBtn:    
   223             {
   269             {
   224             TBool isEnableSetting = *aData;
   270             TBool isEnableSetting = *aData;
   225             iHwrWnd->SetEnableSettingBtn(isEnableSetting);
   271             iHwrWnd->SetEnableSettingBtn(isEnableSetting);
       
   272             }
       
   273             break;
       
   274         case ECmdPeninputArabicNumModeChanged:
       
   275             {
       
   276             TBool isArabicNativeNum = *aData;
       
   277             iHwrWnd->SetNativeNumMode(isArabicNativeNum);
   226             }
   278             }
   227             break;
   279             break;
   228         default:
   280         default:
   229 		    ret = KErrUnknown;
   281 		    ret = KErrUnknown;
   230             break;
   282             break;
   274 		// this is just a temporary solution to avoid this panic happened.
   326 		// this is just a temporary solution to avoid this panic happened.
   275 		// The best solution is to get the cusor postion which should be provide by ICF control 
   327 		// The best solution is to get the cusor postion which should be provide by ICF control 
   276 		// but ICF does not offer such API
   328 		// but ICF does not offer such API
   277 		if(aData.iFlag & EFepICFDataDirectionMFNE )
   329 		if(aData.iFlag & EFepICFDataDirectionMFNE )
   278 			{
   330 			{
       
   331 			iIsEditorMFNE = ETrue;
   279 			return KErrNone;
   332 			return KErrNone;
   280 			}
   333 			}
   281 			
   334 		
       
   335         iIsEditorMFNE = EFalse;		
   282 		iDataStore->SetFirstCandidateType(ECandDefaultFirst);
   336 		iDataStore->SetFirstCandidateType(ECandDefaultFirst);
   283 		if(iDataStore->PrimaryRange() == ERangeEnglish)
   337 //		if(iDataStore->PrimaryRange() == ERangeEnglish)
   284 		    {
   338 //		    {
   285 		    return KErrNone;
   339 //		    return KErrNone;
   286 		    }
   340 //		    }
   287 		TUint16 charBeforeCursor = 0;
   341 		TUint16 charBeforeCursor = 0;
   288 		
   342 		
   289         if(iHwrWnd->GetCharBeforeCursor(aData.iCurSel.LowerPos()-1, charBeforeCursor))
   343         if(iHwrWnd->GetCharBeforeCursor(aData.iCurSel.LowerPos()-1, charBeforeCursor))
   290 		    {
   344 		    {
   291 			TFirstCandidateType candtype = ECandDefaultFirst;
   345 			TFirstCandidateType candtype = ECandDefaultFirst;
   459 // ---------------------------------------------------------------------------
   513 // ---------------------------------------------------------------------------
   460 // Delete the previous charcode and submit the new one
   514 // Delete the previous charcode and submit the new one
   461 // ---------------------------------------------------------------------------
   515 // ---------------------------------------------------------------------------
   462 //
   516 //
   463 void CPeninputFingerHwrArLayout::Replace( const TDesC& aOldCharCode,
   517 void CPeninputFingerHwrArLayout::Replace( const TDesC& aOldCharCode,
   464     const TDesC& aNewCharCode, const TBool aIsPart )
   518     const TDesC& aNewCharCode, const TBool aIsPart)
   465     {
   519     {
   466 	// user tries to correct the previous selection
   520 	// user tries to correct the previous selection
   467     // Delete the previous character and append the new one
   521     // Delete the previous character and append the new one
   468     HBufC* newCharBuf = HBufC::New( aNewCharCode.Length() + KIntLen );
   522     HBufC* newCharBuf = HBufC::New( aNewCharCode.Length() + KIntLen );
   469     if ( newCharBuf )
   523     if ( newCharBuf )
   571     newValue = GetPenTrailColor();
   625     newValue = GetPenTrailColor();
   572     SetBoxPenColor( newValue );
   626     SetBoxPenColor( newValue );
   573 
   627 
   574     iRepositorySetting->Get( KSettingsPenInputLang, newValue );
   628     iRepositorySetting->Get( KSettingsPenInputLang, newValue );
   575     iDataStore->SetLanguageL( newValue );
   629     iDataStore->SetLanguageL( newValue );
   576 
   630     
       
   631 //    TInt displayLang = 0;
       
   632 //    iCommonEngineRepository->Get(KGSDisplayTxtLang,displayLang);
       
   633 //    if(displayLang == ELangArabic)
       
   634 //        {
       
   635 //        iHwrWnd->SetNativeNumMode(ETrue);
       
   636 //        }
       
   637 //    else
       
   638 //        {
       
   639 //        iHwrWnd->SetNativeNumMode(EFalse);
       
   640 //        }
       
   641     iHwrWnd->SetNativeNumMode(iDataStore->IsNativeNumMode());
   577     }
   642     }
   578 
   643 
   579 // ---------------------------------------------------------------------------
   644 // ---------------------------------------------------------------------------
   580 // 
   645 // 
   581 // ---------------------------------------------------------------------------
   646 // ---------------------------------------------------------------------------
   607 
   672 
   608     delete iDataStore;
   673     delete iDataStore;
   609 	delete iStateMgr;
   674 	delete iStateMgr;
   610     delete iGSRepositoryWatcher;
   675     delete iGSRepositoryWatcher;
   611     delete iRepositorySetting;
   676     delete iRepositorySetting;
       
   677 //    delete iCommonEngineRepository;
       
   678     //delete iCallBack;
   612     }
   679     }
   613 
   680 
   614 // ---------------------------------------------------------------------------
   681 // ---------------------------------------------------------------------------
   615 // Create the hwr box window.
   682 // Create the hwr box window.
   616 // ---------------------------------------------------------------------------
   683 // ---------------------------------------------------------------------------
   704             {
   771             {
   705             iHwrWnd->ShowSymbolPage( 0, EPagePosPageNo );
   772             iHwrWnd->ShowSymbolPage( 0, EPagePosPageNo );
   706             }
   773             }
   707             break;    
   774             break;    
   708 		case EHwrCtrlIdBtnEnter:
   775 		case EHwrCtrlIdBtnEnter:
   709             {
   776 		    {
   710 			TBuf<1> bufEnter;
   777 			TBuf<1> bufEnter;
   711             bufEnter.Append( EKeyEnter );
   778             bufEnter.Append( EKeyEnter );
   712             SubmitStringToFep( bufEnter );
   779             SubmitStringToFep( bufEnter );
   713             // close the symbol table
   780             // close the symbol table
   714             iHwrWnd->CloseSymbolTable();
   781             iHwrWnd->CloseSymbolTable();
   747         case EHwrCtrlIdArrowLeft:
   814         case EHwrCtrlIdArrowLeft:
   748             {
   815             {
   749             SignalOwner( ESignalKeyEvent, aData );
   816             SignalOwner( ESignalKeyEvent, aData );
   750             }
   817             }
   751             break;
   818             break;
   752         case EHwrCtrlIdArrowDown:
       
   753             {
       
   754             iHwrWnd->Icf()->HandleArrowBtnEventL( CFepLayoutMultiLineIcf::EArrowDown );
       
   755             }
       
   756             break;
       
   757         case EHwrCtrlIdArrowUp:
       
   758             {
       
   759             iHwrWnd->Icf()->HandleArrowBtnEventL( CFepLayoutMultiLineIcf::EArrowUp );
       
   760             }
       
   761             break;
       
   762         default:
   819         default:
   763             break;
   820             break;
   764         }
   821         }
   765     }
   822     }
   766 
   823 
   771 void CPeninputFingerHwrArLayout::OnBackspaceClickedL()
   828 void CPeninputFingerHwrArLayout::OnBackspaceClickedL()
   772     {
   829     {
   773 	iHwrWnd->CancelWriting();
   830 	iHwrWnd->CancelWriting();
   774     if (iHwrWnd->IsCandidateShowup())
   831     if (iHwrWnd->IsCandidateShowup())
   775         {
   832         {
   776         // goto standby and clear screen	
   833         // goto standby and clear screen
       
   834         if(IsAllowedToSubmitDefaultCandiate())
       
   835             {
       
   836             SignalOwner( ESignalDeleteLastInput, KNullDesC );
       
   837             }
   777 		ChangeCurStateToStandby();
   838 		ChangeCurStateToStandby();
   778         }
   839         }
   779     else
   840     else
   780         {
   841         {
   781         SubmitCharToFep( EKeyBackspace );
   842         SubmitCharToFep( EKeyBackspace );
   816         SubmitStringToFep( buf );
   877         SubmitStringToFep( buf );
   817         }
   878         }
   818     else
   879     else
   819         {
   880         {
   820         TBuf<1> bufBck;
   881         TBuf<1> bufBck;
   821         bufBck.Append( keydata->iScanCode );
   882         TInt convertedCode;
   822         SignalOwner( ESignalKeyEvent, bufBck );
   883         TBool converted = EFalse;
       
   884         converted = RevertSymbolDirection(keydata->iScanCode,convertedCode);
       
   885         bufBck.Append(convertedCode);
       
   886 //        bufBck.Append(keydata->iScanCode);
       
   887         if(converted)
       
   888             {
       
   889             SignalOwner(ESignalArabicSCTChar,bufBck);
       
   890             }
       
   891         else
       
   892             {
       
   893             SignalOwner( ESignalKeyEvent, bufBck );
       
   894             }
   823         }
   895         }
   824         
   896         
   825     // close the symbol table
   897     // close the symbol table
   826     iHwrWnd->CloseSymbolTable();
   898     iHwrWnd->CloseSymbolTable();
   827     }
   899     }
   858 // handler of StrokeStarted event.
   930 // handler of StrokeStarted event.
   859 // ---------------------------------------------------------------------------
   931 // ---------------------------------------------------------------------------
   860 //                                              
   932 //                                              
   861 void CPeninputFingerHwrArLayout::OnHwrStrokeStartedL()
   933 void CPeninputFingerHwrArLayout::OnHwrStrokeStartedL()
   862     {
   934     {
       
   935     //iCallBack->IssueRequestL(); 
   863 	iHwrWnd->HideIndicator();
   936 	iHwrWnd->HideIndicator();
   864 	
   937 	
   865 	// The default candidate cell is not highlight
   938 	// The default candidate cell is not highlight
   866 	iDataStore->SetHighlight(EFalse); 
   939 	iDataStore->SetHighlight(EFalse); 
   867     
   940     
   872 		}
   945 		}
   873     
   946     
   874 	// remember the start writing position.
   947 	// remember the start writing position.
   875 	iIsStrokeOfDrawingCharacerStarted = ETrue;
   948 	iIsStrokeOfDrawingCharacerStarted = ETrue;
   876 	
   949 	
       
   950     iStateMgr->HandleEventL( EEventHwrStrokeStarted, KNullDesC );
       
   951     }
       
   952 
       
   953 void CPeninputFingerHwrArLayout::CallBackL()
       
   954     {
       
   955     iHwrWnd->HideIndicator();
       
   956         
       
   957     // The default candidate cell is not highlight
       
   958     iDataStore->SetHighlight(EFalse); 
       
   959     
       
   960     // close the candidate list if it's currently showing up    
       
   961     if(iHwrWnd->IsCandidateShowup())
       
   962         {
       
   963         iHwrWnd->CloseCandidateList();
       
   964         }
       
   965     
       
   966     // remember the start writing position.
       
   967     iIsStrokeOfDrawingCharacerStarted = ETrue;
       
   968     
   877     iStateMgr->HandleEventL( EEventHwrStrokeStarted, KNullDesC );
   969     iStateMgr->HandleEventL( EEventHwrStrokeStarted, KNullDesC );
   878     }
   970     }
   879 
   971 
   880 // ---------------------------------------------------------------------------
   972 // ---------------------------------------------------------------------------
   881 // handler of StrokeFinished event.
   973 // handler of StrokeFinished event.
   903     iStateMgr->HandleEventL( EEventHwrCharacterTimerOut, ptr );
   995     iStateMgr->HandleEventL( EEventHwrCharacterTimerOut, ptr );
   904     
   996     
   905 	iHwrWnd->OpenCandidateList();
   997 	iHwrWnd->OpenCandidateList();
   906 	}
   998 	}
   907 
   999 
       
  1000 // ---------------------------------------------------------------------------
       
  1001 // get value from repository.
       
  1002 // ---------------------------------------------------------------------------
       
  1003 // 	
       
  1004 TBool CPeninputFingerHwrArLayout::IsAllowedToSubmitDefaultCandiate()	
       
  1005     {
       
  1006 	return (!iIsEditorMFNE);
       
  1007 	}
       
  1008 	
   908 // ---------------------------------------------------------------------------
  1009 // ---------------------------------------------------------------------------
   909 // get value from repository.
  1010 // get value from repository.
   910 // ---------------------------------------------------------------------------
  1011 // ---------------------------------------------------------------------------
   911 // 
  1012 // 
   912 TInt CPeninputFingerHwrArLayout::GetNewValue( 
  1013 TInt CPeninputFingerHwrArLayout::GetNewValue( 
  1031 		}
  1132 		}
  1032     
  1133     
  1033     // set the state to be standby	
  1134     // set the state to be standby	
  1034     iStateMgr->SetState( CPeninputFingerHwrArStateManagerBase::EStateStandBy );
  1135     iStateMgr->SetState( CPeninputFingerHwrArStateManagerBase::EStateStandBy );
  1035     }
  1136     }
       
  1137 // ---------------------------------------------------------------------------
       
  1138 // handler of NumMapping changed event.
       
  1139 // ---------------------------------------------------------------------------
       
  1140 //
       
  1141 void CPeninputFingerHwrArLayout::OnNumMappingChangedL()
       
  1142     {
       
  1143     HBufC* mapping = iDataStore->KeyMappingStringL();
       
  1144 
       
  1145     iHwrWnd->SetNumericMapping( *mapping );
       
  1146 
       
  1147     delete mapping;
       
  1148     }
       
  1149 // ---------------------------------------------------------------------------
       
  1150 // revert special characters direction before sending to editor.
       
  1151 // ---------------------------------------------------------------------------
       
  1152 // 
       
  1153 TBool CPeninputFingerHwrArLayout::RevertSymbolDirection(TInt aInChar, TInt & aOutChar)
       
  1154     {
       
  1155     TBool converted = ETrue;
       
  1156     switch(aInChar)
       
  1157         {
       
  1158         case 0x0028:
       
  1159             {
       
  1160             aOutChar = 0x0029;//convert ( to ).
       
  1161             }
       
  1162             break;
       
  1163         case 0x0029:
       
  1164             {
       
  1165             aOutChar = 0x0028;//convert ) to (.
       
  1166             }
       
  1167             break;
       
  1168         case 0x005B:
       
  1169             {
       
  1170             aOutChar = 0x005D;//convert [ to ].
       
  1171             }
       
  1172             break;
       
  1173         case 0x005D:
       
  1174             {
       
  1175             aOutChar = 0x005B;//convert ] to [.
       
  1176             }
       
  1177             break;
       
  1178         case 0x003C:
       
  1179             {
       
  1180             aOutChar = 0x003E;//convert < to >.
       
  1181             }
       
  1182             break;
       
  1183         case 0x003E:
       
  1184             {
       
  1185             aOutChar = 0x003C;//convert > to <.
       
  1186             }
       
  1187             break;
       
  1188         case 0x007B:
       
  1189             {
       
  1190             aOutChar = 0x007D;//convert { to }.
       
  1191             }
       
  1192             break;
       
  1193         case 0x007D:
       
  1194             {
       
  1195             aOutChar = 0x007B;//convert } to {.
       
  1196             }
       
  1197             break;
       
  1198         default:
       
  1199             aOutChar = aInChar;
       
  1200             converted = EFalse;
       
  1201             break;
       
  1202         }
       
  1203     return converted;
       
  1204     }
  1036 
  1205 
  1037 //End of file
  1206 //End of file