textinput/peninputcommonlayout/src/peninputlayoutwindowext.cpp
branchRCL_3
changeset 56 8152b1f1763a
parent 50 5a1685599b76
equal deleted inserted replaced
50:5a1685599b76 56:8152b1f1763a
   370         {
   370         {
   371         CFepLayoutMultiLineIcf* multiIcf = 
   371         CFepLayoutMultiLineIcf* multiIcf = 
   372             static_cast<CFepLayoutMultiLineIcf*>( Control(EPeninputWindowCtrlIdMultiLineICF));
   372             static_cast<CFepLayoutMultiLineIcf*>( Control(EPeninputWindowCtrlIdMultiLineICF));
   373             
   373             
   374         multiIcf->SetTextL( aData );
   374         multiIcf->SetTextL( aData );
   375       
   375         }
   376         if ( iLayoutContext->LayoutType() == EPluginInputModeVkb || 
   376     }  
   377              iLayoutContext->LayoutType() == EPluginInputModeFSQ )
   377 
   378             {
   378 EXPORT_C void CPeninputLayoutWindowExt::EnableToneMarker(TBool aEnable)
   379             TInt lang = CPeninputDataConverter::AnyToInt
   379 	{
   380                     ( iLayoutContext->RequestData( EPeninputDataTypeInputLanguage ) );
   380     if (iLayoutContext->LayoutType() != EPluginInputModeVkb && 
   381             TInt curRange = CPeninputDataConverter::AnyToInt
   381     	iLayoutContext->LayoutType() != EPluginInputModeFSQ)
   382         		    ( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );
       
   383         		        
       
   384             if ( lang == ELangVietnamese && curRange == ERangeEnglish )  
       
   385                 {
       
   386                 TBuf<1> preData;
       
   387                 multiIcf->ExtractText( preData, aData.iCurSel.LowerPos()-1, 1 );
       
   388                 iVowelChar = EFalse;
       
   389                 
       
   390                 if ( KNullDesC() != preData )
       
   391                     {
       
   392                     for (TUint i = 0; i < sizeof(VietVowelList) / sizeof(TText); ++i)
       
   393                         {
       
   394                         TBuf<1> buf;
       
   395                         buf.Append( VietVowelList[i] );
       
   396                         if (preData == buf)
       
   397                             {
       
   398                             iVowelChar = ETrue;
       
   399                             break;
       
   400                             }
       
   401                         }
       
   402                     }
       
   403                 CPeninputVkbCtrlExt* vkbCtrl = static_cast<CPeninputVkbCtrlExt*>
       
   404                     ( Control( EPeninutWindowCtrlIdVkbCtrl ) );
       
   405                 vkbCtrl->DimKeySet( iToneSet, !iVowelChar );
       
   406                 }
       
   407             }
       
   408         }
       
   409     else
       
   410     	{
   382     	{
   411         // If in virtual QWERTY mode
   383 		return;
   412 		if ( iLayoutContext->LayoutType() == EPluginInputModeFSQ )
       
   413 			{
       
   414 			TInt lang = CPeninputDataConverter::AnyToInt
       
   415 					( iLayoutContext->RequestData( EPeninputDataTypeInputLanguage ));
       
   416 			TInt curRange = CPeninputDataConverter::AnyToInt
       
   417 					( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ));
       
   418 					
       
   419 			// When writing language is Vietnamese and range is English
       
   420 			if ( lang == ELangVietnamese && curRange == ERangeEnglish )  
       
   421 				{
       
   422 				TBuf<1> charData;
       
   423 				// Get the input character
       
   424 				charData.Append( aData.iText );
       
   425 				iVowelChar = EFalse;
       
   426 				
       
   427                 if ( KNullDesC() != charData )
       
   428                     {
       
   429                     // Check whether the input char is in the list of VietVowelList
       
   430                     for ( TUint i = 0; i < sizeof( VietVowelList ) / sizeof( TText ); ++i )
       
   431                         {
       
   432                         TBuf<1> buf;
       
   433                         buf.Append( VietVowelList[i] );
       
   434                         if ( charData == buf )
       
   435                             {
       
   436                             iVowelChar = ETrue;
       
   437                             break;
       
   438                             }
       
   439                         }
       
   440                     }
       
   441                 
       
   442                 CPeninputVkbCtrlExt* vkbCtrl = static_cast<CPeninputVkbCtrlExt*>
       
   443                     ( Control( EPeninutWindowCtrlIdVkbCtrl ));
       
   444                 // Set the dim status of the tone keys
       
   445                 vkbCtrl->DimKeySet( iToneSet, !iVowelChar );
       
   446 				}
       
   447 			}
       
   448     	}
   384     	}
   449     }  
   385 
   450 
   386     TInt lang = CPeninputDataConverter::AnyToInt
       
   387 			( iLayoutContext->RequestData( EPeninputDataTypeInputLanguage ) );
       
   388 	TInt curRange = CPeninputDataConverter::AnyToInt
       
   389 			( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );
       
   390 
       
   391 	if ( lang != ELangVietnamese || curRange != ERangeEnglish )  
       
   392 		{
       
   393 		return;
       
   394 		}
       
   395 	
       
   396 	iVowelChar = aEnable;
       
   397 	CPeninputVkbCtrlExt* vkbCtrl = static_cast<CPeninputVkbCtrlExt*>
       
   398 		( Control( EPeninutWindowCtrlIdVkbCtrl ) );
       
   399 	vkbCtrl->DimKeySet( iToneSet, !iVowelChar );
       
   400 	}
   451 // ---------------------------------------------------------------------------
   401 // ---------------------------------------------------------------------------
   452 // CPeninputLayoutWindowExt::SetEditorTextL
   402 // CPeninputLayoutWindowExt::SetEditorTextL
   453 // (other items were commented in a header)
   403 // (other items were commented in a header)
   454 // ---------------------------------------------------------------------------
   404 // ---------------------------------------------------------------------------
   455 //
   405 //
   528         file.Close();
   478         file.Close();
   529         
   479         
   530         return ETrue;
   480         return ETrue;
   531         }
   481         }
   532     }
   482     }
   533 
   483   
   534 // ---------------------------------------------------------------------------
       
   535 // CPeninputLayoutWindowExt::CancelDeadKey
       
   536 // (other items were commented in a header)
       
   537 // ---------------------------------------------------------------------------
       
   538 //
       
   539 void CPeninputLayoutWindowExt::CancelDeadKey()
       
   540 	{
       
   541     // Get the dead key status
       
   542 	TInt latchedFlag = CPeninputDataConverter::AnyToInt(
       
   543 		iLayoutContext->RequestData( EAkninputDataTypeLatchedSet ));
       
   544 	// If the DeadKey is latched, cancel it
       
   545 	if ( latchedFlag )
       
   546 		{
       
   547 		RPointerArray<CPeninputVkbLayoutInfo> vkbListInfo;
       
   548 		RPointerArray<CPeninputVkbKeyInfo> keyInfoList;
       
   549 		
       
   550 		// Get the vkb layout list supportted by current writing language
       
   551 		vkbListInfo = iVkbLayout->VkbLayoutInfoList();
       
   552 		TInt vkbListNum = vkbListInfo.Count();
       
   553 		
       
   554 		CVirtualKey* pKey;
       
   555 		TBool deadKeyChange = EFalse;
       
   556 		
       
   557 		// Find the latched DeadKey in all kinds of vkb layout 
       
   558 		// which supportted by current writing language
       
   559 		for ( TInt i = 0; i < vkbListNum && !deadKeyChange ; i++ )
       
   560 			{
       
   561 			// Get the key info list in one vkb layout
       
   562 			keyInfoList = vkbListInfo[i]->KeyInfoList();
       
   563 			TInt keyListNum = keyInfoList.Count();
       
   564 			for ( TInt j = 0; j < keyListNum && !deadKeyChange ; j++ )
       
   565 				{
       
   566 				pKey = keyInfoList[j]->Key();
       
   567 				// If the Dead key is latched
       
   568 				if ( pKey->Latched())
       
   569 					{
       
   570 					// Unlatch the DeadKey
       
   571 					pKey->SetLatched( EFalse );
       
   572 					
       
   573 					// Set the DeadKey state
       
   574 					iLayoutContext->SetData( 
       
   575 						EAkninputDataTypeLatchedSet, &deadKeyChange );
       
   576 					
       
   577 					deadKeyChange = ETrue;
       
   578 					} 
       
   579 				}
       
   580 			}
       
   581 		}	
       
   582 	}
       
   583 
       
   584 // ---------------------------------------------------------------------------
   484 // ---------------------------------------------------------------------------
   585 // CPeninputLayoutWindowExt::ChangeInputLanguageL
   485 // CPeninputLayoutWindowExt::ChangeInputLanguageL
   586 // (other items were commented in a header)
   486 // (other items were commented in a header)
   587 // ---------------------------------------------------------------------------
   487 // ---------------------------------------------------------------------------
   588 //
   488 //
   606         found = CheckResourceExist( GetWindowConfigResFileName( aLangID ) );
   506         found = CheckResourceExist( GetWindowConfigResFileName( aLangID ) );
   607         }
   507         }
   608         
   508         
   609     if ( found ) 
   509     if ( found ) 
   610         {
   510         {
   611         // Remove the dead key's latched status
       
   612 		CancelDeadKey();
       
   613     
       
   614         // Store language
   511         // Store language
   615         iLayoutContext->SetData( EPeninputDataTypeInputLanguage, &aLangID );
   512         iLayoutContext->SetData( EPeninputDataTypeInputLanguage, &aLangID );
   616    
   513    
   617         if ( iLayoutContext->LayoutType() == EPluginInputModeVkb || 
   514         if ( iLayoutContext->LayoutType() == EPluginInputModeVkb || 
   618             iLayoutContext->LayoutType() == EPluginInputModeFSQ )
   515             iLayoutContext->LayoutType() == EPluginInputModeFSQ )
   911 // (other items were commented in a header)
   808 // (other items were commented in a header)
   912 // ---------------------------------------------------------------------------
   809 // ---------------------------------------------------------------------------
   913 //
   810 //
   914 EXPORT_C void CPeninputLayoutWindowExt::ChangeVkbLayout( TInt aVkbLayoutId )
   811 EXPORT_C void CPeninputLayoutWindowExt::ChangeVkbLayout( TInt aVkbLayoutId )
   915     {
   812     {
   916 
   813     TInt latchedFlag = CPeninputDataConverter::AnyToInt(
   917 	// Remove the dead key's latched status
   814                        iLayoutContext->RequestData(EAkninputDataTypeLatchedSet));
   918 	CancelDeadKey();
   815     // If the DeadKey is latched, cancel it and then change the VKB layout
   919 
   816     if(latchedFlag)
       
   817         {
       
   818         RPointerArray<CPeninputVkbLayoutInfo> vkbListInfo;
       
   819         RPointerArray<CPeninputVkbKeyInfo> keyInfoList;
       
   820         
       
   821         vkbListInfo = iVkbLayout->VkbLayoutInfoList();
       
   822         TInt vkbListNum = vkbListInfo.Count();
       
   823         
       
   824         CVirtualKey* pKey;
       
   825         TBool deadKeyChange = EFalse;
       
   826         // Find the latched DeadKey in all the Vkb layout
       
   827         for(TInt i = 0; i < vkbListNum; i++)
       
   828             {
       
   829             // Get key info list in one VKB layout
       
   830             keyInfoList = vkbListInfo[i]->KeyInfoList();
       
   831             TInt keyListNum = keyInfoList.Count();
       
   832             for(TInt j = 0; j < keyListNum; j++)
       
   833                 {
       
   834                 pKey = keyInfoList[j]->Key();
       
   835                 if(pKey->Latched())
       
   836                     {
       
   837                     // Unlatch the DeadKey
       
   838                     pKey->SetLatched(EFalse);
       
   839                     
       
   840                     // Set the DeadKey state
       
   841                     iLayoutContext->SetData(EAkninputDataTypeLatchedSet, &deadKeyChange);
       
   842                     deadKeyChange = ETrue;
       
   843                     break;
       
   844                     } 
       
   845                 }
       
   846             if(deadKeyChange)
       
   847                 {
       
   848                 break;
       
   849                 }
       
   850             }
       
   851         }
   920     
   852     
   921     TInt curVkbId = CPeninputDataConverter::AnyToInt
   853     TInt curVkbId = CPeninputDataConverter::AnyToInt
   922         ( iLayoutContext->RequestData( EPeninputDataTypeVkbLayout ) );
   854         ( iLayoutContext->RequestData( EPeninputDataTypeVkbLayout ) );
   923                            
   855                            
   924     if ( ( curVkbId != aVkbLayoutId ) || ( iLangOrSizeChanged ) )
   856     if ( ( curVkbId != aVkbLayoutId ) || ( iLangOrSizeChanged ) )