textinput/peninputcommonlayout/src/peninputlayoutwindowext.cpp
changeset 27 694fa80c203c
parent 24 fc42a86c98e3
child 35 0f326f2e628e
equal deleted inserted replaced
24:fc42a86c98e3 27:694fa80c203c
     1 /*
       
     2 * Copyright (c) 2002-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:  common layout window for UI interface of VKB and HWR
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // System includes
       
    20 #include <coemain.h>
       
    21 
       
    22 #include <AknFepGlobalEnums.h>
       
    23 #include <aknfeppeninputenums.h>
       
    24 #include <peninputpluginutils.h>
       
    25 #include <peninputcmdparam.h>            // Use global signal
       
    26 #include <peninputlayoutmultilineicf.h>
       
    27 #include <peninputeventbutton.h>
       
    28 #include <peninputmultimodebutton.h>
       
    29 #include <peninputdragbutton.h>
       
    30 #include <peninputlayoutchoicelist.h>
       
    31 #include <peninputlayout.h>
       
    32 #include <peninputrangebar.h>
       
    33 #include <bautils.h>
       
    34 #include <AknIconUtils.h>
       
    35 #include <AknLayoutDef.h>
       
    36 #include <AknUtils.h>
       
    37 #include <aknlayoutscalable_avkon.cdl.h>
       
    38 #include <AknsUtils.h>
       
    39 //#include <peninputcmdparam.h>
       
    40 #include <aknFepVietnameseInputTables.h>
       
    41 
       
    42 // User includes
       
    43 #include "peninputdataconverter.h"
       
    44 #include "peninputrangebarinfo.h"
       
    45 #include "peninputlayoutwindowext.h"
       
    46 #include "peninputclientlayoutinfo.h"
       
    47 #include "peninputdataprovider.h"
       
    48 #include "peninputlayoutcontext.h"
       
    49 #include "peninputvkbctrlext.h"
       
    50 #include "peninputnumerickeymappingmgr.h"
       
    51 
       
    52 // Constants
       
    53 const TInt KIntLengthForByte = 8;
       
    54 const TInt KPeninputLayoutWindowUnitWidth = 12;
       
    55 const TInt KInvalidIndex = -1;
       
    56 
       
    57 //const TInt32 KInvalidResId = -1;
       
    58 //const TInt KInvalidImg = -1 ;
       
    59 const TUint32 KDefaultTextColor = 0x000000;
       
    60 const TUint32 KDefaultShadowTextColor = 0xffffff;
       
    61 //const TInt KNotSupportSkin = -1;
       
    62 
       
    63 const TInt KIntSizeToInt16 = 2;
       
    64 const TInt KMaxNumericString = 32;
       
    65 
       
    66 // ======== MEMBER FUNCTIONS ========
       
    67 
       
    68 // ------------------------------------------------------------------------
       
    69 // CPeninputLayoutWindowExt::CPeninputLayoutWindowExt
       
    70 // (other items were commented in a header)
       
    71 // ------------------------------------------------------------------------
       
    72 //
       
    73 EXPORT_C CPeninputLayoutWindowExt::CPeninputLayoutWindowExt( 
       
    74     CFepUiLayout* aUiLayout, MPeninputLayoutContext* aLayoutContext )
       
    75     : CAknFepCtrlBaseWindowExt( aUiLayout, EPeninutWindowCtrlIdBaseWindow ), 
       
    76      iConfigInfo( NULL ), iLayoutContext( aLayoutContext ),
       
    77     iLastUsedTotalColumns( KPeninputLayoutWindowUnitWidth ),
       
    78     iFirstTimeConstruct( ETrue ),
       
    79     iSwitchFontSet(EFalse),
       
    80     iUnitSizeChange(EFalse)
       
    81     { 
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // CPeninputLayoutWindowExt::ConstructL
       
    86 // (other items were commented in a header)
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 EXPORT_C void CPeninputLayoutWindowExt::ConstructL()
       
    90     {
       
    91     BaseConstructL();  
       
    92 
       
    93     if( iLayoutContext->LayoutType() == EPluginInputModeVkb ||
       
    94         iLayoutContext->LayoutType() == EPluginInputModeFSQ )
       
    95         {
       
    96         iVkbLayout = CAknFepCtrlVkbLayout::NewL(); 
       
    97         }
       
    98     else
       
    99         {
       
   100         iVkbLayout = NULL;
       
   101         }
       
   102         
       
   103     CCoeEnv* coeEnv = CCoeEnv::Static();
       
   104     	
       
   105     // Set up resources
       
   106     TFileName resFileName = GetWindowResFileName();
       
   107     BaflUtils::NearestLanguageFile(coeEnv->FsSession(), resFileName );
       
   108     iWinResId = coeEnv->AddResourceFileL( resFileName );
       
   109         
       
   110     //TResourceReader reader;
       
   111     
       
   112     //coeEnv->CreateResourceReaderLC( reader, GetWindowResId() );
       
   113     SetResourceId( GetWindowResId() );
       
   114     ConstructFromResourceL();
       
   115     
       
   116     if (!iKeyMappingMgr)
       
   117         {
       
   118         // if key mapping mgr is not constructed in ConstructFromResourceL, need to 
       
   119         // construct it here
       
   120         TResourceReader resReader;
       
   121         CCoeEnv::Static()->CreateResourceReaderLC(resReader, GetNumKeymappingResId());
       
   122         iKeyMappingMgr = CPeninputNumericKepMappingMgr::NewL(resReader);
       
   123         CleanupStack::PopAndDestroy(1);
       
   124         }
       
   125 
       
   126     CreateAllControlsL();
       
   127     SetControlsFont();
       
   128     }
       
   129 
       
   130 // ---------------------------------------------------------------------------
       
   131 // CPeninputLayoutWindowExt::~CPeninputLayoutWindowExt
       
   132 // (other items were commented in a header)
       
   133 // ---------------------------------------------------------------------------
       
   134 //
       
   135 EXPORT_C CPeninputLayoutWindowExt::~CPeninputLayoutWindowExt()
       
   136     {
       
   137     delete iConfigInfo;
       
   138     delete iKeyMappingMgr;
       
   139     delete iVkbLayout;    
       
   140     // Delete resource file from CoeEnv
       
   141     CCoeEnv::Static()->DeleteResourceFile( iWinResId );
       
   142     
       
   143     CCoeEnv::Static()->DeleteResourceFile( iConfigResId );
       
   144     
       
   145     delete iToneSet;   
       
   146     }
       
   147 
       
   148 // ---------------------------------------------------------------------------
       
   149 // CPeninputLayoutWindowExt::SizeChanged
       
   150 // (other items were commented in a header)
       
   151 // ---------------------------------------------------------------------------
       
   152 //
       
   153 EXPORT_C void CPeninputLayoutWindowExt::SizeChanged( TBool /*aLandscapeStyle*/ )
       
   154     {
       
   155     iLangOrSizeChanged = ETrue;    
       
   156     ReadLafForShadow();
       
   157 	ResetLastColRow();
       
   158     
       
   159     if ( iConfigInfo )
       
   160         {        
       
   161         ChangeClientSize();        
       
   162         }
       
   163         
       
   164     //ReadLafForShadow( rect );
       
   165     
       
   166     TInt style = EPeninputPositionChangeBrJustify;
       
   167     TBuf<KIntSizeToInt16> bufStyle;
       
   168     bufStyle = ( TUint16* )&style;
       
   169     HandleControlEvent(EPeninputLayoutEventMovePosition, NULL, bufStyle);           
       
   170         
       
   171     iLangOrSizeChanged = EFalse;
       
   172     }
       
   173 
       
   174 // ---------------------------------------------------------------------------
       
   175 // CPeninputLayoutWindowExt::ReadLafForShadow
       
   176 // (other items were commented in a header).
       
   177 // ---------------------------------------------------------------------------
       
   178 //
       
   179 void CPeninputLayoutWindowExt::ReadLafForShadow()
       
   180     {
       
   181     TAknWindowLineLayout shadowPane;
       
   182     TAknWindowLineLayout shadowTl;
       
   183     TAknWindowLineLayout shadowBr;
       
   184     TAknLayoutRect shadowRect;
       
   185     TAknLayoutRect shadowTlRect;
       
   186     TAknLayoutRect shadowBrRect;
       
   187 
       
   188     shadowPane = AknLayoutScalable_Avkon::bg_popup_fep_shadow_pane(1).LayoutLine();
       
   189     shadowRect.LayoutRect(TRect(), shadowPane);
       
   190 
       
   191     shadowTl = AknLayoutScalable_Avkon::bg_popup_fep_shadow_pane_g1().LayoutLine();
       
   192     shadowTlRect.LayoutRect(shadowRect.Rect(), shadowTl);
       
   193 
       
   194     shadowBr = AknLayoutScalable_Avkon::bg_popup_fep_shadow_pane_g8().LayoutLine();
       
   195     shadowBrRect.LayoutRect(shadowRect.Rect(), shadowBr);
       
   196     
       
   197     iShadowTlWidth = shadowTlRect.Rect().Size().iWidth;
       
   198     iShadowTlHeight = shadowTlRect.Rect().Size().iHeight;
       
   199     iShadowBrWidth = shadowBrRect.Rect().Size().iWidth;
       
   200     iShadowBrHeight = shadowBrRect.Rect().Size().iHeight;
       
   201     }
       
   202     
       
   203 // ---------------------------------------------------------------------------
       
   204 // CPeninputLayoutWindowExt::SizeChanged
       
   205 // (other items were commented in a header).
       
   206 // ---------------------------------------------------------------------------
       
   207 //
       
   208 EXPORT_C void CPeninputLayoutWindowExt::SizeChangedForBaseWindow( TInt /*aTotalColumns*/ )
       
   209     {
       
   210     }
       
   211 // ---------------------------------------------------------------------------
       
   212 // CPeninputLayoutWindowExt::HandleControlEvent
       
   213 // (other items were commented in a header)
       
   214 // ---------------------------------------------------------------------------
       
   215 //
       
   216 EXPORT_C void CPeninputLayoutWindowExt::HandleControlEvent( TInt aEventType,
       
   217     CFepUiBaseCtrl* aCtrl, const TDesC& aEventData )
       
   218     {
       
   219     // Call this function in base class
       
   220     CAknFepCtrlBaseWindowExt::HandleControlEvent( aEventType, 
       
   221         aCtrl, aEventData );
       
   222     
       
   223     TInt* data = ( TInt* ) aEventData.Ptr(); 
       
   224     
       
   225     switch ( aEventType )
       
   226         {
       
   227         case EEventButtonUp:
       
   228         	{
       
   229         	// check current range
       
   230 		    TInt curRange = CPeninputDataConverter::AnyToInt
       
   231 		        ( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );		    
       
   232         	if( aCtrl->ControlId() == EPeninutWindowCtrlIdShiftBtn)
       
   233 	        	{
       
   234 	        	  if ( ( curRange == ERangeEnglish )  || ( curRange == ERangeAccent ) 
       
   235         			   || ( ConfigInfo()->CaseSensitive() && ( curRange == ERangeNative ) ) )
       
   236 	        	  	{
       
   237 	        		CAknFepCtrlMultiModeButton* button = 
       
   238 					static_cast<CAknFepCtrlMultiModeButton*>( aCtrl );
       
   239 		        	TInt realCase = button->GetRealCaseByMode( button->CurrentMode() );	     	       		
       
   240 					HandleMergedBtnClicked( realCase );
       
   241 	        		}
       
   242 		       	else
       
   243 		       		{
       
   244 		       		HandleShiftAndCapslockBtnClicked();
       
   245 		       		TInt shiftStatus = CPeninputDataConverter::AnyToInt
       
   246 				        ( iLayoutContext->RequestData( EPeninputDataTypeShiftDown ) );
       
   247 				    ChangeMergedButtonStatus( shiftStatus, 0 );
       
   248 		       		}				
       
   249 	        	}
       
   250 
       
   251         	}
       
   252         	break;
       
   253         case EPeninputLayoutEventSwitchLanguage:
       
   254             {
       
   255             TRAP_IGNORE( ChangeInputLanguageL( *data ) );                
       
   256             }
       
   257             break;
       
   258         case EPeninputLayoutEventRange: 
       
   259             {
       
   260             HandleRangeEvent( *data );
       
   261             }
       
   262             break;
       
   263         case EPeninputLayoutEventRangeLoop:
       
   264             {
       
   265             HandleRangeLoopEvent( *data );
       
   266             }
       
   267             break;
       
   268         case EPeninputLayoutEventShift: 
       
   269             {
       
   270             HandleShiftAndCapslockBtnClicked();
       
   271             }
       
   272             break;
       
   273         case EPeninputLayoutEventCapslock:
       
   274             {
       
   275             HandleCapslockBtnClicked();
       
   276             } 
       
   277             break;
       
   278         case EPeninputLayoutEventMovePosition:
       
   279             {
       
   280             TInt style = *( ( TUint16* ) aEventData.Ptr() );
       
   281             ChangeLayoutPosition( style );
       
   282             }
       
   283             break;
       
   284         case EPeninputLayoutEventSetPermittedRange:
       
   285             {
       
   286             if ( *data & ERangeNative )
       
   287                 {
       
   288                 *data = *data | ERangeAccent | ERangeNativeNumber 
       
   289                     | ERangeMixedText | ERangeMixedNumber;
       
   290                 }
       
   291             else if(*data & ERangeEnglish)
       
   292                 {
       
   293                 *data = *data | ERangeAccent;
       
   294                 }
       
   295 
       
   296             iLayoutContext->SetData( EPeninputDataTypePermittedRange, data );
       
   297             
       
   298             // Set range of range bar component
       
   299             CFepUiBaseCtrl* bar = 
       
   300                 Control( EPeninutWindowCtrlIdRangeBar );
       
   301             if ( bar ) 
       
   302                 {
       
   303                 CAknFepCtrlRangeBar* rangebar = 
       
   304                     static_cast<CAknFepCtrlRangeBar*>( bar );
       
   305                 rangebar->SetPermittedRanges( *data );             
       
   306                 }                     
       
   307             }
       
   308             break;  
       
   309         case EPeninputLayoutEventSetPermittedCase:
       
   310             {
       
   311             // Update data:case
       
   312             iLayoutContext->SetData( EPeninputDataTypePermittedCase, data );
       
   313             
       
   314             // Set range of case
       
   315             CFepUiBaseCtrl* bar = 
       
   316                 Control( EPeninutWindowCtrlIdRangeBar );
       
   317             if ( bar ) 
       
   318                 {
       
   319                 CAknFepCtrlRangeBar* rangebar = 
       
   320                     static_cast<CAknFepCtrlRangeBar*>( bar );
       
   321             
       
   322                 rangebar->SetPermittedCase( ERangeEnglish, ECaseUpper, 
       
   323                     ( *data & ECaseUpper) != 0 );
       
   324                 rangebar->SetPermittedCase( ERangeEnglish, ECaseLower, 
       
   325                     ( *data & ECaseLower) != 0 );
       
   326                 rangebar->SetPermittedCase( ERangeEnglish, ECaseText, 
       
   327                     ( *data & ECaseText) != 0 );
       
   328                 }
       
   329             }
       
   330             break;
       
   331         case EPeninputLayoutEventSetCase:
       
   332             {
       
   333             DoCaseChange( *data );
       
   334             }
       
   335             break;
       
   336         case EEventSizeChanged:
       
   337             {
       
   338             //if icf editor size changed, we need to inform owner
       
   339             if(aCtrl->ControlId() == EPeninutWindowCtrlIdInputContextField ||  
       
   340                aCtrl->ControlId() == EPeninputWindowCtrlIdMultiLineICF)
       
   341                 {
       
   342                 iLayoutContext->Sendkey( ESignalLayoutICFLengthChanged, KNullDesC );
       
   343                 }
       
   344             }
       
   345             break;
       
   346         default:
       
   347             break;
       
   348         }   
       
   349     }
       
   350 
       
   351 // ---------------------------------------------------------------------------
       
   352 // CPeninputLayoutWindowExt::SetEditorTextL
       
   353 // (other items were commented in a header)
       
   354 // ---------------------------------------------------------------------------
       
   355 //
       
   356 EXPORT_C void CPeninputLayoutWindowExt::SetEditorTextL( 
       
   357     const TFepInputContextFieldData& aData )
       
   358     {
       
   359     if (Control(EPeninutWindowCtrlIdInputContextField))
       
   360         {
       
   361         static_cast<CFepInputContextField*>( Control(EPeninutWindowCtrlIdInputContextField))->SetTextL( aData );
       
   362         return;
       
   363         }
       
   364     
       
   365     if (Control(EPeninputWindowCtrlIdMultiLineICF))
       
   366         {
       
   367         CFepLayoutMultiLineIcf* multiIcf = 
       
   368             static_cast<CFepLayoutMultiLineIcf*>( Control(EPeninputWindowCtrlIdMultiLineICF));
       
   369             
       
   370         multiIcf->SetTextL( aData );
       
   371       
       
   372         if ( iLayoutContext->LayoutType() == EPluginInputModeVkb || 
       
   373              iLayoutContext->LayoutType() == EPluginInputModeFSQ )
       
   374             {
       
   375             TInt lang = CPeninputDataConverter::AnyToInt
       
   376                     ( iLayoutContext->RequestData( EPeninputDataTypeInputLanguage ) );
       
   377             TInt curRange = CPeninputDataConverter::AnyToInt
       
   378         		    ( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );
       
   379         		        
       
   380             if ( lang == ELangVietnamese && curRange == ERangeEnglish )  
       
   381                 {
       
   382                 TBuf<1> preData;
       
   383                 multiIcf->ExtractText( preData, aData.iCurSel.LowerPos()-1, 1 );
       
   384                 iVowelChar = EFalse;
       
   385                 
       
   386                 if ( KNullDesC() != preData )
       
   387                     {
       
   388                     for (TUint i = 0; i < sizeof(VietVowelList) / sizeof(TText); ++i)
       
   389                         {
       
   390                         TBuf<1> buf;
       
   391                         buf.Append( VietVowelList[i] );
       
   392                         if (preData == buf)
       
   393                             {
       
   394                             iVowelChar = ETrue;
       
   395                             break;
       
   396                             }
       
   397                         }
       
   398                     }
       
   399                 CPeninputVkbCtrlExt* vkbCtrl = static_cast<CPeninputVkbCtrlExt*>
       
   400                     ( Control( EPeninutWindowCtrlIdVkbCtrl ) );
       
   401                 vkbCtrl->DimKeySet( iToneSet, !iVowelChar );
       
   402                 }
       
   403             }
       
   404         }
       
   405     }  
       
   406 
       
   407 // ---------------------------------------------------------------------------
       
   408 // CPeninputLayoutWindowExt::SetEditorTextL
       
   409 // (other items were commented in a header)
       
   410 // ---------------------------------------------------------------------------
       
   411 //
       
   412 EXPORT_C void CPeninputLayoutWindowExt::SetTextIsSecret( TBool aData )
       
   413     {
       
   414     if ( Control(EPeninutWindowCtrlIdInputContextField))
       
   415         {
       
   416         static_cast<CFepInputContextField*>
       
   417         (Control(EPeninutWindowCtrlIdInputContextField))->SetTextIsSecret( aData );
       
   418         }
       
   419     else if (Control(EPeninputWindowCtrlIdMultiLineICF))
       
   420         {
       
   421         static_cast<CFepLayoutMultiLineIcf*>
       
   422         (Control(EPeninputWindowCtrlIdMultiLineICF))->SetTextIsSecret( aData );
       
   423         }
       
   424     }  
       
   425     
       
   426 void CPeninputLayoutWindowExt::SetNumberGrouping( TBool aData )
       
   427     {
       
   428     if (Control(EPeninputWindowCtrlIdMultiLineICF))
       
   429         {
       
   430         static_cast<CFepLayoutMultiLineIcf*>
       
   431         (Control(EPeninputWindowCtrlIdMultiLineICF))->SetNumberGrouping( aData );
       
   432         }
       
   433     }
       
   434     
       
   435 
       
   436 // ---------------------------------------------------------------------------
       
   437 // CPeninputLayoutWindowExt::DoClose
       
   438 // (other items were commented in a header)
       
   439 // ---------------------------------------------------------------------------
       
   440 //
       
   441 EXPORT_C TBool CPeninputLayoutWindowExt::DoClose()
       
   442     {
       
   443     // Send EVkbEventWindowClose to layout
       
   444     this->ReportEvent( EPeninputLayoutEventClose, KNullDesC );
       
   445     
       
   446     // Return true which will permit the window close
       
   447     return EFalse;
       
   448     }
       
   449 
       
   450     
       
   451 // ---------------------------------------------------------------------------
       
   452 // Get layout config method. It does a lasy initialization for a instance of
       
   453 // CPeninputLayoutWindowExt::ConfigInfo
       
   454 // (other items were commented in a header)
       
   455 // ---------------------------------------------------------------------------
       
   456 //
       
   457 EXPORT_C CPeninputLayoutConfig* CPeninputLayoutWindowExt::ConfigInfo() const
       
   458     {
       
   459     return iConfigInfo;
       
   460     }
       
   461 
       
   462 // ---------------------------------------------------------------------------
       
   463 // CPeninputLayoutWindowExt::CheckResourceExist
       
   464 // (other items were commented in a header)
       
   465 // ---------------------------------------------------------------------------
       
   466 //
       
   467 TBool CPeninputLayoutWindowExt::CheckResourceExist( const TDesC& aFileName )
       
   468     {
       
   469     RFile file;
       
   470     
       
   471     if ( !aFileName.Length() )
       
   472         {
       
   473         return EFalse;
       
   474         }
       
   475         
       
   476     TInt rs = file.Open( CCoeEnv::Static()->FsSession(), aFileName, EFileRead );
       
   477     
       
   478     if ( rs == KErrNotFound )
       
   479         {
       
   480         return EFalse;  
       
   481         }
       
   482     else
       
   483         {
       
   484         file.Close();
       
   485         
       
   486         return ETrue;
       
   487         }
       
   488     }
       
   489   
       
   490 // ---------------------------------------------------------------------------
       
   491 // CPeninputLayoutWindowExt::ChangeInputLanguageL
       
   492 // (other items were commented in a header)
       
   493 // ---------------------------------------------------------------------------
       
   494 //
       
   495 EXPORT_C void CPeninputLayoutWindowExt::ChangeInputLanguageL( TInt aLangID )
       
   496     {
       
   497     // Determine whether a new language id is same as existing one, 
       
   498     if ( ConfigInfo() )
       
   499         {
       
   500         // If language not changed, exit this function
       
   501         if ( ConfigInfo()->Language() == aLangID )
       
   502             {
       
   503             return;
       
   504             }
       
   505         }
       
   506 
       
   507     // First check file exist or not
       
   508     TBool found = CheckResourceExist( GetWindowConfigResFileName( aLangID ) );
       
   509     if ( !found )
       
   510         {
       
   511         aLangID = ELangEnglish;        
       
   512         found = CheckResourceExist( GetWindowConfigResFileName( aLangID ) );
       
   513         }
       
   514         
       
   515     if ( found ) 
       
   516         {
       
   517         // Store language
       
   518         iLayoutContext->SetData( EPeninputDataTypeInputLanguage, &aLangID );
       
   519    
       
   520         if ( iLayoutContext->LayoutType() == EPluginInputModeVkb || 
       
   521             iLayoutContext->LayoutType() == EPluginInputModeFSQ )
       
   522             {       
       
   523             CFepUiBaseCtrl* ctrl = 
       
   524                 Control( EPeninutWindowCtrlIdVkbCtrl );
       
   525             if ( ctrl )
       
   526                 {
       
   527                 ( static_cast<CPeninputVkbCtrlExt*>( ctrl ) )->Reset();
       
   528                 }
       
   529             } 
       
   530 
       
   531         // Re-construct config info 
       
   532         if ( iConfigInfo )
       
   533             {
       
   534             delete iConfigInfo;
       
   535             iConfigInfo = NULL;
       
   536             }
       
   537             
       
   538         if (iConfigResId)
       
   539             {
       
   540             CCoeEnv::Static()->DeleteResourceFile( iConfigResId );
       
   541             }
       
   542             
       
   543         // construct resource utils
       
   544         
       
   545         CCoeEnv* coeEnv = CCoeEnv::Static();
       
   546         
       
   547         // Set up resources
       
   548         TFileName resFileName = GetWindowConfigResFileName( aLangID );
       
   549         BaflUtils::NearestLanguageFile(coeEnv->FsSession(), resFileName );
       
   550         iConfigResId = coeEnv->AddResourceFileL( resFileName );
       
   551         
       
   552         TResourceReader reader;
       
   553 
       
   554         coeEnv->CreateResourceReaderLC( reader, GetWindowConfigResId() );  
       
   555         if ( iLayoutContext->LayoutType() == EPluginInputModeVkb || 
       
   556             iLayoutContext->LayoutType() == EPluginInputModeFSQ )
       
   557             {
       
   558             iVkbLayout->Reset(); 
       
   559             }
       
   560         iConfigInfo = CPeninputLayoutConfig::NewL( *iVkbLayout, reader ); 
       
   561         
       
   562         // Pop and destroy reader
       
   563         CleanupStack::PopAndDestroy( 1 ); 
       
   564         	       
       
   565         // Re-construct rangebar
       
   566         ChangeRangeBarL();
       
   567 
       
   568 	    //Reset range and layoutid
       
   569 	    TInt range = -1;
       
   570 	    iLayoutContext->SetData( EPeninputDataTypeCurrentRange, &range );
       
   571 	    iLayoutContext->SetData( EPeninputDataTypeClientLayout, &range );
       
   572 	    ResetLastColRow();
       
   573 	    iLangOrSizeChanged = ETrue;
       
   574 	    
       
   575 	    CFepUiBaseCtrl* icfCtrl = Control( EPeninputWindowCtrlIdMultiLineICF );
       
   576         if ( icfCtrl )
       
   577             {
       
   578             static_cast<CFepLayoutMultiLineIcf*>(icfCtrl)->SetLanguageId( aLangID );
       
   579             }
       
   580 		
       
   581 	    delete iToneSet;
       
   582 	    iToneSet = NULL;
       
   583 	        
       
   584 	    if ( aLangID == ELangVietnamese )
       
   585             {
       
   586             iToneSet = HBufC::NewL( KNumberOfToneMarks );
       
   587         
       
   588             for (TInt index = 0; index < KNumberOfToneMarks; index ++)
       
   589                 {
       
   590                 iToneSet->Des().Append( VietToneMatrix[0][index] );
       
   591                 }
       
   592             }
       
   593 	    }
       
   594     }
       
   595     
       
   596 // ---------------------------------------------------------------------------
       
   597 // CPeninputLayoutWindowExt::ChangeRangeBarL
       
   598 // (other items were commented in a header)
       
   599 // ---------------------------------------------------------------------------
       
   600 //
       
   601 void CPeninputLayoutWindowExt::ChangeRangeBarL()
       
   602     {
       
   603     // Read range bar from config into and reconstruct range button
       
   604     if ( iConfigInfo )
       
   605         {
       
   606         TInt resid = iConfigInfo->RangebarResId();
       
   607         CFepUiBaseCtrl* bar = 
       
   608             Control( EPeninutWindowCtrlIdRangeBar );
       
   609             
       
   610         if ( bar ) 
       
   611             {
       
   612             CAknFepCtrlRangeBar* rangebar = 
       
   613                 static_cast<CAknFepCtrlRangeBar*>( bar );
       
   614             
       
   615             CAknFepCtrlRangeBar::TRangeBarActionStyle style = 
       
   616                 ( CAknFepCtrlRangeBar::TRangeBarActionStyle )
       
   617                 iConfigInfo->RangeBarInfo()->RangeStyle();
       
   618                 
       
   619             rangebar->SetActionStyle( style );
       
   620                             
       
   621             TResourceReader reader;
       
   622             
       
   623             CCoeEnv::Static()->CreateResourceReaderLC( reader, resid ); 
       
   624             
       
   625             rangebar->ConstructFromResourceL( reader );
       
   626             
       
   627             // Pop and destroy reader
       
   628             CleanupStack::PopAndDestroy( 1 );
       
   629             }
       
   630         }
       
   631     }
       
   632   
       
   633 // ---------------------------------------------------------------------------
       
   634 // CPeninputLayoutWindowExt::ChangeRange
       
   635 // (other items were commented in a header)
       
   636 // ---------------------------------------------------------------------------
       
   637 //
       
   638 EXPORT_C void CPeninputLayoutWindowExt::ChangeRange( TInt aRange, TInt aVkbLayoutId, 
       
   639                                                      TBool aNotify )
       
   640     {
       
   641     TInt curRange = CPeninputDataConverter::AnyToInt
       
   642         ( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );
       
   643     TInt curVkbLayout = CPeninputDataConverter::AnyToInt
       
   644         ( iLayoutContext->RequestData( EPeninputDataTypeVkbLayout ) );
       
   645 
       
   646     CFepUiBaseCtrl* bar = 
       
   647         Control( EPeninutWindowCtrlIdRangeBar );
       
   648     CAknFepCtrlRangeBar* rangebar = 
       
   649         static_cast<CAknFepCtrlRangeBar*>( bar );
       
   650         
       
   651     if ( rangebar )
       
   652         {
       
   653         rangebar->ActiveRange( aRange );
       
   654         }
       
   655         
       
   656     if (curRange != aRange || curVkbLayout != aVkbLayoutId || aRange == ERangeAccent)
       
   657         {
       
   658         // Update data:range
       
   659         if (curRange != aRange)
       
   660             iLayoutContext->SetData( EPeninputDataTypeCurrentRange, &aRange );
       
   661             
       
   662         // Change client layout
       
   663         CPeninputRangeBarInfo* rangeBarInfo = iConfigInfo->RangeBarInfo();
       
   664         CPeninputRangeInfo* rangeInfo = rangeBarInfo->FindRange(aRange);
       
   665         
       
   666         __ASSERT_DEBUG(rangeInfo, User::Panic(_L("Commonlayout-Invalid Range"), aRange));
       
   667 
       
   668         ChangeClientLayout(rangeInfo->ClientLayoutId());
       
   669         
       
   670         // Notify fep the new range
       
   671         if (aNotify)
       
   672             {
       
   673             TBuf<KIntLengthForByte> buf;
       
   674             CPeninputDataConverter::IntToDesc( aRange, buf );
       
   675             iLayoutContext->Sendkey( ESignalRange, buf );
       
   676             
       
   677 	        // When change range mannually, make the entire window visible
       
   678 	        TInt style = EPeninputPositionChangeBrJustify;
       
   679 	        TBuf<KIntSizeToInt16> bufStyle;
       
   680 	        bufStyle = ( TUint16* )&style;
       
   681 	        HandleControlEvent(EPeninputLayoutEventMovePosition, NULL, bufStyle);           
       
   682             }
       
   683 
       
   684         // Change vkb layout
       
   685         if ( iLayoutContext->LayoutType() == EPluginInputModeVkb ||
       
   686             iLayoutContext->LayoutType() == EPluginInputModeFSQ )
       
   687             {
       
   688             if ( ( aRange == ERangeEnglish ) || ( aRange == ERangeAccent ) 
       
   689                 || ( aRange == ERangeNativeNumber )
       
   690                 || ( ConfigInfo()->CaseSensitive() 
       
   691                 && ( aRange == ERangeNative ) ) )
       
   692                 {
       
   693                 // Change shift and capslock button status according to the current case
       
   694                 TInt curCase = CPeninputDataConverter::AnyToInt
       
   695                     ( iLayoutContext->RequestData( EPeninputDataTypeCase ) );
       
   696                 TInt shfit;  
       
   697                 TInt capslock;  
       
   698                 
       
   699                 CPeninputDataConverter::ShiftCapslockByCase( curCase, 
       
   700                     shfit, capslock );      
       
   701 
       
   702                 iLayoutContext->SetData( EPeninputDataTypeShiftDown, &shfit );
       
   703                 //ChangeButtonStatus( shfit, EPeninutWindowCtrlIdShiftBtn );
       
   704                 iLayoutContext->SetData( EPeninputDataTypeCapslockDown, &capslock );
       
   705                 //ChangeButtonStatus( capslock, EPeninutWindowCtrlIdCapslockBtn );                
       
   706                 ChangeMergedButtonStatus( shfit, capslock );
       
   707                 
       
   708                 TInt caseid = CaseByShiftCapslockStatus();
       
   709                 TInt vkblayoutid = 
       
   710                     ConfigInfo()->ShiftCapsSingleVkbLayoutId( aRange, caseid );
       
   711                                 
       
   712                 if ( aRange == ERangeAccent ) 
       
   713                     {
       
   714                     TInt curAccentIndex = CPeninputDataConverter::AnyToInt
       
   715                         ( iLayoutContext->RequestData( EPeninputDataTypeCurrentAccent ) );
       
   716                     vkblayoutid = vkblayoutid + curAccentIndex * 2;
       
   717                     }      
       
   718                     
       
   719                 // Change vkb layout
       
   720                 ChangeVkbLayout( vkblayoutid );
       
   721                 }
       
   722             else
       
   723                 {
       
   724                 TInt flag = 0;
       
   725                 
       
   726                 iLayoutContext->SetData( EPeninputDataTypeShiftDown, &flag );
       
   727                 //ChangeButtonStatus( 0, EPeninutWindowCtrlIdShiftBtn );
       
   728                 iLayoutContext->SetData( EPeninputDataTypeCapslockDown, &flag );
       
   729                 //ChangeButtonStatus( 0, EPeninutWindowCtrlIdCapslockBtn );
       
   730                 ChangeMergedButtonStatus( 0, 0 );
       
   731      
       
   732                 // Change vkb layout
       
   733                 if ( aVkbLayoutId )
       
   734                     {
       
   735                     ChangeVkbLayout( aVkbLayoutId );                   
       
   736                     }
       
   737                 else
       
   738                     {
       
   739                     ChangeVkbLayout( rangeInfo->VkbLayoutId() );  
       
   740                     }                
       
   741                 }
       
   742             }
       
   743             
       
   744         }
       
   745         
       
   746     if ( ( iLayoutContext->LayoutType() == EPluginInputModeVkb ||
       
   747         iLayoutContext->LayoutType() == EPluginInputModeFSQ )
       
   748           && ( curRange == ERangeNumber || curRange == ERangeNativeNumber )
       
   749           && ( curRange == aRange ) )
       
   750         {
       
   751         // Dimmed some keys if needed  
       
   752         DimKeys();                 
       
   753         }                        
       
   754     }
       
   755 
       
   756 // ---------------------------------------------------------------------------
       
   757 // CPeninputLayoutWindowExt::ChangeClientLayout
       
   758 // (other items were commented in a header)
       
   759 // ---------------------------------------------------------------------------
       
   760 //
       
   761 EXPORT_C void CPeninputLayoutWindowExt::ChangeClientLayout( 
       
   762     TInt aClientLayoutId )
       
   763     {
       
   764     TInt curClientId = CPeninputDataConverter::AnyToInt
       
   765         ( iLayoutContext->RequestData( EPeninputDataTypeClientLayout ) );
       
   766 
       
   767     if ( curClientId != aClientLayoutId )
       
   768         {
       
   769         CPeninputClientLayoutInfo* clientLayout = 
       
   770             ConfigInfo()->FindClientLayoutInfo( aClientLayoutId );
       
   771             
       
   772         __ASSERT_DEBUG( clientLayout, User::Panic(_L("Commonlayout-Invalid ClientLayout"), aClientLayoutId));
       
   773 
       
   774         SetLafLayOut( clientLayout->Rows(), clientLayout->Columns() );
       
   775         
       
   776         //SizeChangedForBaseWindow( clientLayout->Columns() );
       
   777 
       
   778         // Re-Orginize all controls according to the configuration
       
   779         ReorganizeControls( aClientLayoutId, ETrue );
       
   780       
       
   781         // Update data:client layout id
       
   782         iLayoutContext->SetData( EPeninputDataTypeClientLayout, 
       
   783                                  &aClientLayoutId );
       
   784         }
       
   785     }
       
   786 
       
   787 // ---------------------------------------------------------------------------
       
   788 // CPeninputLayoutWindowExt::ChangeVkbLayout
       
   789 // (other items were commented in a header)
       
   790 // ---------------------------------------------------------------------------
       
   791 //
       
   792 EXPORT_C void CPeninputLayoutWindowExt::ChangeVkbLayout( TInt aVkbLayoutId )
       
   793     {
       
   794     TInt latchedFlag = CPeninputDataConverter::AnyToInt(
       
   795                        iLayoutContext->RequestData(EAkninputDataTypeLatchedSet));
       
   796     // If the DeadKey is latched, cancel it and then change the VKB layout
       
   797     if(latchedFlag)
       
   798         {
       
   799         RPointerArray<CPeninputVkbLayoutInfo> vkbListInfo;
       
   800         RPointerArray<CPeninputVkbKeyInfo> keyInfoList;
       
   801         
       
   802         vkbListInfo = iVkbLayout->VkbLayoutInfoList();
       
   803         TInt vkbListNum = vkbListInfo.Count();
       
   804         
       
   805         CVirtualKey* pKey;
       
   806         TBool deadKeyChange = EFalse;
       
   807         // Find the latched DeadKey in all the Vkb layout
       
   808         for(TInt i = 0; i < vkbListNum; i++)
       
   809             {
       
   810             // Get key info list in one VKB layout
       
   811             keyInfoList = vkbListInfo[i]->KeyInfoList();
       
   812             TInt keyListNum = keyInfoList.Count();
       
   813             for(TInt j = 0; j < keyListNum; j++)
       
   814                 {
       
   815                 pKey = keyInfoList[j]->Key();
       
   816                 if(pKey->Latched())
       
   817                     {
       
   818                     // Unlatch the DeadKey
       
   819                     pKey->SetLatched(EFalse);
       
   820                     
       
   821                     // Set the DeadKey state
       
   822                     iLayoutContext->SetData(EAkninputDataTypeLatchedSet, &deadKeyChange);
       
   823                     deadKeyChange = ETrue;
       
   824                     break;
       
   825                     } 
       
   826                 }
       
   827             if(deadKeyChange)
       
   828                 {
       
   829                 break;
       
   830                 }
       
   831             }
       
   832         }
       
   833     
       
   834     TInt curVkbId = CPeninputDataConverter::AnyToInt
       
   835         ( iLayoutContext->RequestData( EPeninputDataTypeVkbLayout ) );
       
   836                            
       
   837     if ( ( curVkbId != aVkbLayoutId ) || ( iLangOrSizeChanged ) )
       
   838         {
       
   839         iLangOrSizeChanged = EFalse;
       
   840         // Update data : vkb layout id
       
   841         iLayoutContext->SetData( EPeninputDataTypeVkbLayout, &aVkbLayoutId );
       
   842 
       
   843         iVkbLayout->ChangeVkbLayout( aVkbLayoutId );        
       
   844         SetVkbLayoutSize();
       
   845         
       
   846         TInt curClientId = CPeninputDataConverter::AnyToInt 
       
   847            ( iLayoutContext->RequestData( EPeninputDataTypeClientLayout ) );
       
   848         CPeninputControlInfo* vkbInfo = iConfigInfo->FindClientLayoutInfo 
       
   849             ( curClientId )->FindControlInfo( EPeninutWindowCtrlIdVkbCtrl );
       
   850     
       
   851         TRect rect;
       
   852         CPeninputVkbCtrlExt* vkbCtrl = static_cast<CPeninputVkbCtrlExt*>
       
   853             ( Control(EPeninutWindowCtrlIdVkbCtrl));
       
   854       
       
   855           
       
   856         CPeninputVkbLayoutInfo* vkblayout = 
       
   857             ConfigInfo()->FindVkbLayoutInfo( aVkbLayoutId );  
       
   858       
       
   859         if ( vkbCtrl && vkblayout )
       
   860             {
       
   861             DimKeys(); 
       
   862             
       
   863             // Make the true draw
       
   864             UpdateArea( vkbCtrl->Rect(),  EFalse ); 
       
   865             }     
       
   866         }        
       
   867     }
       
   868 
       
   869 // --------------------------------------------------------------------------
       
   870 // CPeninputLayoutWindowExt::HandleRangeEvent
       
   871 // (other items were commented in a header)
       
   872 // --------------------------------------------------------------------------
       
   873 //
       
   874 EXPORT_C void CPeninputLayoutWindowExt::HandleRangeEvent( TInt aRange )
       
   875     {                                 
       
   876     TInt curRange = CPeninputDataConverter::AnyToInt 
       
   877         ( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );
       
   878   
       
   879     CPeninputRangeBarInfo* rangeBar = iConfigInfo->RangeBarInfo();
       
   880     if ( !rangeBar )
       
   881         {
       
   882         return;
       
   883         }
       
   884 
       
   885     CPeninputRangeInfo* rangeInfo = rangeBar->FindRange( aRange );
       
   886     
       
   887     if ( !rangeInfo )
       
   888         {
       
   889         return;
       
   890         }
       
   891       
       
   892     TInt responseStyle = rangeInfo->ResponseStyle();
       
   893     if ( responseStyle == EPeninputRangeResponseNoAction )
       
   894         {
       
   895         return; 
       
   896         }
       
   897     
       
   898     if (curRange != aRange && responseStyle == EPeninputRangeResponseSwitchRange)
       
   899         {
       
   900         TInt index = KInvalidIndex;
       
   901 
       
   902         if ( aRange == ERangeAccent )
       
   903             {
       
   904             index = 0;
       
   905             }
       
   906         iLayoutContext->SetData( EPeninputDataTypeCurrentAccent, &index );
       
   907 
       
   908         ChangeRange( aRange );     
       
   909         }
       
   910     else if ( responseStyle == EPeninputRangeResponsePopupChoiceItem )
       
   911         {
       
   912         PopupChoiceList();
       
   913         }
       
   914     }
       
   915 
       
   916 // --------------------------------------------------------------------------
       
   917 // CPeninputLayoutWindowExt::HandleRangeLoopEvent
       
   918 // (other items were commented in a header)
       
   919 // --------------------------------------------------------------------------
       
   920 //
       
   921 EXPORT_C void CPeninputLayoutWindowExt::HandleRangeLoopEvent( TInt aLoop )
       
   922     {
       
   923     TInt curRange = CPeninputDataConverter::AnyToInt
       
   924         ( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );
       
   925                 
       
   926     CFepUiBaseCtrl* ctrl = Control( EPeninutWindowCtrlIdRangeBar );
       
   927     CAknFepCtrlRangeBar* rangebar = static_cast<CAknFepCtrlRangeBar*>( ctrl );
       
   928   
       
   929     if ( rangebar )
       
   930         {
       
   931         TRAP_IGNORE( rangebar->SetCaseL( curRange, aLoop ) );
       
   932       
       
   933         if ( ( curRange == ERangeEnglish ) || ( ConfigInfo()->CaseSensitive()
       
   934             && ( curRange == ERangeNative ) ) )
       
   935             {
       
   936             TInt curCase = rangebar->GetCase( curRange );
       
   937 
       
   938             // Store case in the data manager, the engine will 
       
   939             // get notice at the same time
       
   940             iLayoutContext->SetData( EPeninputDataTypeCase, &curCase );
       
   941           
       
   942             // Notify fep the new case
       
   943             TBuf<KIntLengthForByte> buf;
       
   944             CPeninputDataConverter::IntToDesc( curCase, buf );
       
   945             iLayoutContext->Sendkey( ESignalCaseMode, buf );
       
   946             }    
       
   947         }
       
   948     }
       
   949 
       
   950 // --------------------------------------------------------------------------
       
   951 // CPeninputLayoutWindowExt::CaseByShiftCapslockStatus
       
   952 // (other items were commented in a header)
       
   953 // --------------------------------------------------------------------------
       
   954 //
       
   955 EXPORT_C TInt CPeninputLayoutWindowExt::CaseByShiftCapslockStatus()
       
   956     {
       
   957     TInt shiftStatus = CPeninputDataConverter::AnyToInt 
       
   958         ( iLayoutContext->RequestData( EPeninputDataTypeShiftDown ) );
       
   959     TInt capslockStatus = CPeninputDataConverter::AnyToInt 
       
   960         ( iLayoutContext->RequestData( EPeninputDataTypeCapslockDown ) );
       
   961         
       
   962     return ( capslockStatus * 2 + shiftStatus );
       
   963     }
       
   964     
       
   965 // ---------------------------------------------------------------------------
       
   966 // CPeninputLayoutWindow::HandleShiftBtnClicked
       
   967 // (other items were commented in a header)
       
   968 // ---------------------------------------------------------------------------
       
   969 //
       
   970 EXPORT_C void CPeninputLayoutWindowExt::HandleMergedBtnClicked( TInt aCase )
       
   971 	{
       
   972 	switch( aCase )
       
   973 		{
       
   974 		case ECaseLower:
       
   975 		    {
       
   976 			HandleCapslockBtnClicked();
       
   977 		    }
       
   978 		    break;
       
   979 		case ECaseUpper:
       
   980 			{
       
   981 			HandleShiftBtnClicked();
       
   982 			}
       
   983 			break;
       
   984 		case ECaseText:
       
   985 //		case ECaseInverseText:
       
   986 			{
       
   987 			// Current case is Text, equals shift button
       
   988 			//HandleCapslockBtnClicked();			
       
   989 			HandleShiftAndCapslockBtnClicked();
       
   990 			}
       
   991 			break;	
       
   992 		default:
       
   993 			break;
       
   994 		}
       
   995 		
       
   996 	}
       
   997 
       
   998 // ---------------------------------------------------------------------------
       
   999 // CPeninputLayoutWindowExt::HandleShiftBtnClicked
       
  1000 // (other items were commented in a header)
       
  1001 // ---------------------------------------------------------------------------
       
  1002 //
       
  1003 EXPORT_C void CPeninputLayoutWindowExt::HandleShiftBtnClicked()
       
  1004     {
       
  1005     TInt curRange = CPeninputDataConverter::AnyToInt
       
  1006         ( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );
       
  1007     
       
  1008     TInt shiftStatus = CPeninputDataConverter::AnyToInt
       
  1009         ( iLayoutContext->RequestData( EPeninputDataTypeShiftDown ) );
       
  1010     TInt capslockStatus = CPeninputDataConverter::AnyToInt
       
  1011         ( iLayoutContext->RequestData( EPeninputDataTypeCapslockDown ) );
       
  1012          
       
  1013     // Update data
       
  1014     if ( iLayoutContext->IsCapsLockPermitted() )
       
  1015     	{
       
  1016     	if ( curRange == ERangeEnglish || curRange == ERangeAccent 
       
  1017 	        || ( ConfigInfo()->CaseSensitive() && curRange == ERangeNative ) )
       
  1018 		    {
       
  1019 	        capslockStatus = !capslockStatus;
       
  1020 	        ChangeMergedButtonStatus( shiftStatus, capslockStatus );
       
  1021 	        iLayoutContext->SetData( EPeninputDataTypeCapslockDown, &capslockStatus );   
       
  1022 		    }
       
  1023     	}
       
  1024     else
       
  1025     	{
       
  1026     	if ( iLayoutContext->IsShiftPermitted() )
       
  1027     		{
       
  1028     		shiftStatus = !shiftStatus;
       
  1029 	        ChangeMergedButtonStatus( shiftStatus, capslockStatus );
       
  1030 	        iLayoutContext->SetData( EPeninputDataTypeShiftDown, &shiftStatus );
       
  1031     		}
       
  1032     	}	
       
  1033   
       
  1034     // Update vkb layout
       
  1035     TInt  caseid = CaseByShiftCapslockStatus();
       
  1036     
       
  1037     TInt vkbLayout = iConfigInfo->ShiftCapsSingleVkbLayoutId( curRange, 
       
  1038                                                               caseid );
       
  1039                                                
       
  1040     TInt responseStyle = 
       
  1041         iConfigInfo->RangeBarInfo()->FindRange( curRange )->ResponseStyle();
       
  1042     if ( ( curRange == ERangeAccent ) 
       
  1043         && ( responseStyle == EPeninputRangeResponsePopupChoiceItem ) )
       
  1044         {
       
  1045         TInt curAccentIndex = CPeninputDataConverter::AnyToInt
       
  1046             ( iLayoutContext->RequestData( EPeninputDataTypeCurrentAccent ) );
       
  1047         vkbLayout = vkbLayout + curAccentIndex * 2;
       
  1048         }
       
  1049         
       
  1050     ChangeVkbLayout( vkbLayout );
       
  1051     
       
  1052     // Synchronize case if needed    
       
  1053     if ( ( curRange == ERangeEnglish )  || ( curRange == ERangeAccent ) 
       
  1054         || ( ConfigInfo()->CaseSensitive() && ( curRange == ERangeNative ) ) )
       
  1055         {
       
  1056         // Notify fep the new case
       
  1057         TBuf<KIntLengthForByte> buf;
       
  1058         TInt fepcase = CPeninputDataConverter::FepCaseByCaseId( caseid );
       
  1059         iLayoutContext->SetData( EPeninputDataTypeCase, &fepcase );
       
  1060         CPeninputDataConverter::IntToDesc( fepcase, buf );
       
  1061         iLayoutContext->Sendkey( ESignalCaseMode, buf );
       
  1062         }
       
  1063     }
       
  1064 
       
  1065 // ---------------------------------------------------------------------------
       
  1066 // CPeninputLayoutWindowExt::HandleCapslockBtnClicked
       
  1067 // (other items were commented in a header)
       
  1068 // ---------------------------------------------------------------------------
       
  1069 //
       
  1070 EXPORT_C void CPeninputLayoutWindowExt::HandleCapslockBtnClicked()
       
  1071     {
       
  1072     TInt curRange = CPeninputDataConverter::AnyToInt
       
  1073         ( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );
       
  1074 
       
  1075     TInt capslockStatus = CPeninputDataConverter::AnyToInt
       
  1076         ( iLayoutContext->RequestData( EPeninputDataTypeCapslockDown ) );
       
  1077     TInt shiftStatus = CPeninputDataConverter::AnyToInt
       
  1078         ( iLayoutContext->RequestData( EPeninputDataTypeShiftDown ) );
       
  1079         
       
  1080     if ( iLayoutContext->IsShiftPermitted() )
       
  1081     	{
       
  1082     	if ( curRange == ERangeEnglish || curRange == ERangeAccent || 
       
  1083             ( ConfigInfo()->CaseSensitive() && curRange == ERangeNative ) )
       
  1084 	        {
       
  1085 	        shiftStatus = !shiftStatus;
       
  1086 	        ChangeMergedButtonStatus( shiftStatus, capslockStatus );
       
  1087 	        iLayoutContext->SetData( EPeninputDataTypeShiftDown, &shiftStatus );   
       
  1088 	        }
       
  1089     	}
       
  1090     else
       
  1091     	{
       
  1092     	if ( iLayoutContext->IsCapsLockPermitted() )
       
  1093     		{
       
  1094     		capslockStatus = !capslockStatus;
       
  1095 	        ChangeMergedButtonStatus( shiftStatus, capslockStatus );
       
  1096 	        iLayoutContext->SetData( EPeninputDataTypeCapslockDown, &capslockStatus );
       
  1097     		}
       
  1098     	}
       
  1099             
       
  1100     // Update vkb layout
       
  1101     TInt  caseid = CaseByShiftCapslockStatus(); 
       
  1102     TInt vkbLayout = iConfigInfo->ShiftCapsSingleVkbLayoutId( curRange, 
       
  1103                                                               caseid );
       
  1104                                              
       
  1105     TInt responseStyle = 
       
  1106         iConfigInfo->RangeBarInfo()->FindRange( curRange )->ResponseStyle();
       
  1107     if ( ( curRange == ERangeAccent ) 
       
  1108         && ( responseStyle == EPeninputRangeResponsePopupChoiceItem ) )
       
  1109         {
       
  1110         TInt curAccentIndex = CPeninputDataConverter::AnyToInt
       
  1111             ( iLayoutContext->RequestData( EPeninputDataTypeCurrentAccent ) );
       
  1112         vkbLayout = vkbLayout + curAccentIndex * 2;
       
  1113         }
       
  1114             
       
  1115     ChangeVkbLayout( vkbLayout );
       
  1116     
       
  1117     // Synchronize case if needed
       
  1118     if ( ( curRange == ERangeEnglish )  || ( curRange == ERangeAccent ) 
       
  1119         || ( ConfigInfo()->CaseSensitive() && ( curRange == ERangeNative ) ) )
       
  1120         {
       
  1121         // Notify fep the new case
       
  1122         TBuf<KIntLengthForByte> buf;
       
  1123         TInt fepcase = CPeninputDataConverter::FepCaseByCaseId( caseid );
       
  1124         iLayoutContext->SetData( EPeninputDataTypeCase, &fepcase );
       
  1125         CPeninputDataConverter::IntToDesc( fepcase, buf );
       
  1126         iLayoutContext->Sendkey( ESignalCaseMode, buf );
       
  1127         }
       
  1128     }
       
  1129     
       
  1130 EXPORT_C void CPeninputLayoutWindowExt::HandleShiftAndCapslockBtnClicked()
       
  1131     {
       
  1132     TInt curRange = CPeninputDataConverter::AnyToInt
       
  1133         ( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );
       
  1134     
       
  1135     TInt shiftStatus = CPeninputDataConverter::AnyToInt
       
  1136         ( iLayoutContext->RequestData( EPeninputDataTypeShiftDown ) );
       
  1137     TInt capslockStatus = CPeninputDataConverter::AnyToInt
       
  1138         ( iLayoutContext->RequestData( EPeninputDataTypeCapslockDown ) );
       
  1139      
       
  1140     if ( shiftStatus )
       
  1141         {
       
  1142         shiftStatus = 0;
       
  1143         }
       
  1144     else
       
  1145         {
       
  1146         shiftStatus = 1;
       
  1147         }
       
  1148         
       
  1149     // Update data
       
  1150     iLayoutContext->SetData( EPeninputDataTypeShiftDown, &shiftStatus );
       
  1151         
       
  1152     if ( iLayoutContext->IsCapsLockPermitted() )
       
  1153     	{
       
  1154     	if ( curRange == ERangeEnglish || curRange == ERangeAccent 
       
  1155 	        || ( ConfigInfo()->CaseSensitive() && curRange == ERangeNative ) )
       
  1156 		    {
       
  1157 	        capslockStatus = !capslockStatus;
       
  1158 	        ChangeMergedButtonStatus( shiftStatus, capslockStatus );
       
  1159 	        iLayoutContext->SetData( EPeninputDataTypeCapslockDown, &capslockStatus );   
       
  1160 		    }
       
  1161     	}
       
  1162     else
       
  1163     	{
       
  1164     	if ( iLayoutContext->IsShiftPermitted() )
       
  1165     		{
       
  1166     		shiftStatus = !shiftStatus;
       
  1167 	        ChangeMergedButtonStatus( shiftStatus, capslockStatus );
       
  1168 	        iLayoutContext->SetData( EPeninputDataTypeShiftDown, &shiftStatus );
       
  1169     		}
       
  1170     	}
       
  1171 	
       
  1172     // Update vkb layout
       
  1173     TInt  caseid = CaseByShiftCapslockStatus();
       
  1174     
       
  1175     TInt vkbLayout = iConfigInfo->ShiftCapsSingleVkbLayoutId( curRange, 
       
  1176                                                               caseid );
       
  1177                                                
       
  1178     TInt responseStyle = 
       
  1179         iConfigInfo->RangeBarInfo()->FindRange( curRange )->ResponseStyle();
       
  1180     if ( ( curRange == ERangeAccent ) 
       
  1181         && ( responseStyle == EPeninputRangeResponsePopupChoiceItem ) )
       
  1182         {
       
  1183         TInt curAccentIndex = CPeninputDataConverter::AnyToInt
       
  1184             ( iLayoutContext->RequestData( EPeninputDataTypeCurrentAccent ) );
       
  1185         vkbLayout = vkbLayout + curAccentIndex * 2;
       
  1186         }
       
  1187         
       
  1188     ChangeVkbLayout( vkbLayout );
       
  1189     
       
  1190     // Synchronize case if needed    
       
  1191     if ( ( curRange == ERangeEnglish )  || ( curRange == ERangeAccent ) 
       
  1192         || ( ConfigInfo()->CaseSensitive() && ( curRange == ERangeNative ) ) )
       
  1193         {
       
  1194         // Notify fep the new case
       
  1195         TBuf<KIntLengthForByte> buf;
       
  1196         TInt fepcase = CPeninputDataConverter::FepCaseByCaseId( caseid );
       
  1197         iLayoutContext->SetData( EPeninputDataTypeCase, &fepcase );
       
  1198         CPeninputDataConverter::IntToDesc( fepcase, buf );
       
  1199         iLayoutContext->Sendkey( ESignalCaseMode, buf );
       
  1200         }
       
  1201     
       
  1202     
       
  1203     }
       
  1204 
       
  1205 // ---------------------------------------------------------------------------
       
  1206 // CPeninputLayoutWindowExt::DimKeys
       
  1207 // (other items were commented in a header)
       
  1208 // ---------------------------------------------------------------------------
       
  1209 //
       
  1210 void CPeninputLayoutWindowExt::DimKeys()
       
  1211     {
       
  1212     TRAP_IGNORE(DimKeysL());
       
  1213     }
       
  1214 void CPeninputLayoutWindowExt::DimKeysL()
       
  1215     {
       
  1216     CPeninputVkbCtrlExt* vkbCtrl = static_cast<CPeninputVkbCtrlExt*>
       
  1217         ( Control( EPeninutWindowCtrlIdVkbCtrl ) );
       
  1218     vkbCtrl->CancelDims();
       
  1219     TInt currentRange = CPeninputDataConverter::AnyToInt 
       
  1220         ( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );
       
  1221     TInt permitRange = CPeninputDataConverter::AnyToInt
       
  1222         ( iLayoutContext->RequestData( EPeninputDataTypePermittedRange ) ); 
       
  1223     TInt keyMapping = CPeninputDataConverter::AnyToInt 
       
  1224         ( iLayoutContext->RequestData( EPeninputDataTypeNumericKeymap ) );
       
  1225     TInt inputLang = CPeninputDataConverter::AnyToInt
       
  1226         ( iLayoutContext->RequestData( EPeninputDataTypeInputLanguage ) );
       
  1227          
       
  1228     if ( currentRange == ERangeNumber && 
       
  1229             (permitRange == ERangeNumber || 
       
  1230                     permitRange == ERangeNativeNumber || 
       
  1231                     permitRange == (ERangeNumber | ERangeNativeNumber)) )
       
  1232         {
       
  1233         HBufC* rs = NULL;
       
  1234         if ( keyMapping == EKeymapFromResource )
       
  1235             {
       
  1236             HBufC* customRes = 
       
  1237                            (HBufC*) iLayoutContext->RequestData(EAknFepDataTypeUseDefinedResource);
       
  1238             _LIT(KTenNumbers,"0123456789");
       
  1239             rs = HBufC::NewL(KTenNumbers().Length() + customRes->Length());
       
  1240             rs->Des().Copy(*customRes);
       
  1241             rs->Des().Append(KTenNumbers);
       
  1242             }
       
  1243         else
       
  1244             {
       
  1245             TRAP_IGNORE( rs = iKeyMappingMgr->KeyMappingStringL( keyMapping ); );
       
  1246             }
       
  1247         
       
  1248         if( rs )
       
  1249             {
       
  1250             vkbCtrl->DimKeys( rs );
       
  1251             delete rs;
       
  1252             }
       
  1253         }
       
  1254     else if ( currentRange == ERangeNativeNumber && 
       
  1255             (permitRange == ERangeNumber || 
       
  1256                     permitRange == ERangeNativeNumber || 
       
  1257                     permitRange == (ERangeNumber | ERangeNativeNumber)) )
       
  1258         {
       
  1259         HBufC* rs = NULL;
       
  1260         TRAP_IGNORE( rs = GetKeyMappingStringL( keyMapping, inputLang ) );
       
  1261         if( rs )
       
  1262             {
       
  1263             vkbCtrl->DimKeys( rs );
       
  1264             delete rs;
       
  1265             }
       
  1266         }
       
  1267     
       
  1268     else if ( (currentRange == ERangeNative || currentRange == ERangeEnglish) && CPeninputDataConverter::AnyToInt
       
  1269         ( iLayoutContext->RequestData( EPeninputDataTypeInputLanguage ) ) == ELangVietnamese )
       
  1270         {
       
  1271         vkbCtrl->DimKeySet( iToneSet, !iVowelChar );
       
  1272         }
       
  1273         
       
  1274     vkbCtrl->Draw();
       
  1275     }
       
  1276 
       
  1277 // ---------------------------------------------------------------------------
       
  1278 // CPeninputLayoutWindowExt::AddControlL
       
  1279 // (other items were commented in a header)
       
  1280 // ---------------------------------------------------------------------------
       
  1281 //
       
  1282 EXPORT_C void CPeninputLayoutWindowExt::AddNotOwnedControl( 
       
  1283     CFepUiBaseCtrl* aControl )
       
  1284     {
       
  1285     //do nothing if we already has the control.
       
  1286     if ( KErrNotFound != ControlList().Find( aControl ) )
       
  1287         {
       
  1288         return;
       
  1289         }
       
  1290     
       
  1291     if ( aControl )
       
  1292         {
       
  1293         ( const_cast<RPointerArray<CFepUiBaseCtrl>&>
       
  1294             ( ControlList() ) ).Append( aControl );
       
  1295         }
       
  1296     } 
       
  1297 // ---------------------------------------------------------------------------
       
  1298 // CPeninputLayoutWindowExt::ChangeButtonStatus
       
  1299 // (other items were commented in a header)
       
  1300 // ---------------------------------------------------------------------------
       
  1301 //
       
  1302 EXPORT_C void CPeninputLayoutWindowExt::ChangeButtonStatus( const TInt aIsDown, 
       
  1303     const TInt aControlId )
       
  1304     {
       
  1305     CAknFepCtrlEventButton* button = 
       
  1306         static_cast<CAknFepCtrlEventButton*>
       
  1307         (ControlById( aControlId ) );
       
  1308 
       
  1309     if ( button )
       
  1310         {
       
  1311         button->SetHighlight( aIsDown == 0 ? EFalse : ETrue );
       
  1312         } 
       
  1313     }
       
  1314 
       
  1315 // ---------------------------------------------------------------------------
       
  1316 // CPeninputLayoutWindow::ChangeButtonStatus
       
  1317 // (other items were commented in a header)
       
  1318 // ---------------------------------------------------------------------------
       
  1319 // 
       
  1320 EXPORT_C void CPeninputLayoutWindowExt::ChangeMergedButtonStatus( 
       
  1321 											const TInt aIsShiftCase, 
       
  1322     								 		const TInt aIsCapslockCase )
       
  1323 	{
       
  1324 	CAknFepCtrlMultiModeButton* button = 
       
  1325 		static_cast<CAknFepCtrlMultiModeButton*>
       
  1326         (ControlById( EPeninutWindowCtrlIdShiftBtn ) );
       
  1327     
       
  1328     if( !button )
       
  1329         {
       
  1330         return;
       
  1331         }
       
  1332     switch ( aIsCapslockCase * 2 + aIsShiftCase )
       
  1333         {
       
  1334         case 1: // text case        
       
  1335             {
       
  1336             TRAP_IGNORE( button->SetCurrentModeL( EBtnBmpActive, 1 ) );			
       
  1337 	    	button->SetHighlight( ETrue );
       
  1338             }
       
  1339             break; 
       
  1340         case 2: // upper case
       
  1341             {
       
  1342             TRAP_IGNORE( button->SetCurrentModeL( EBtnBmpActive, 2 ) );	
       
  1343             button->SetHighlight( ETrue );
       
  1344             }
       
  1345         	break;
       
  1346         default:
       
  1347             {
       
  1348             TRAP_IGNORE( button->SetCurrentModeL( EBtnBmpActive, 0 ) );	
       
  1349         	button->SetHighlight( EFalse );
       
  1350             }
       
  1351             break;
       
  1352 	    }
       
  1353 	}    								 	
       
  1354 // ---------------------------------------------------------------------------
       
  1355 // CPeninputLayoutWindowExt::ChangeLayoutPosition
       
  1356 // (other items were commented in a header)
       
  1357 // ---------------------------------------------------------------------------
       
  1358 //               
       
  1359 EXPORT_C void CPeninputLayoutWindowExt::ChangeLayoutPosition( TInt aJustifyStyle )
       
  1360     {        
       
  1361     if ( iLayoutContext->LayoutType() == EPluginInputModeFSQ )
       
  1362         {
       
  1363         TopLeftJustify();
       
  1364         return;
       
  1365         }
       
  1366     switch ( aJustifyStyle )
       
  1367         {
       
  1368         case EPeninputPositionChangeBrJustify:
       
  1369             {
       
  1370             BottomRightJustify();
       
  1371             }         
       
  1372             break;
       
  1373         case EPeninputPositionChangeDataQuery:
       
  1374             {
       
  1375             //BottomRightJustify();
       
  1376             DataQueryJustify();
       
  1377             }
       
  1378             break;
       
  1379         default:
       
  1380             {
       
  1381             TopLeftJustify();
       
  1382             }
       
  1383             break;
       
  1384         }
       
  1385     }
       
  1386 
       
  1387 // ---------------------------------------------------------------------------
       
  1388 // CPeninputLayoutWindowExt::SetWindowRect
       
  1389 // (other items were commented in a header)
       
  1390 // ---------------------------------------------------------------------------
       
  1391 //      
       
  1392 EXPORT_C void CPeninputLayoutWindowExt::SetWindowRect( const TRect& aRect )
       
  1393     {
       
  1394     //we should know the layout size now
       
  1395     if(iLayoutContext->LayoutType() == EPluginInputModeFSQ)
       
  1396         {
       
  1397         SetRect( aRect );
       
  1398         UiLayout()->SetRect(aRect);
       
  1399         }
       
  1400     else
       
  1401         {
       
  1402 	    TRect rect = aRect;
       
  1403 
       
  1404 
       
  1405 	    TRect shadowRect = TRect( TPoint(), 
       
  1406 	                              TSize( aRect.Width() + iShadowBrWidth + iShadowTlWidth,
       
  1407 	                                     aRect.Height() + iShadowTlHeight + iShadowBrHeight)
       
  1408 	                            );
       
  1409 	                            
       
  1410 	    rect.Move( TPoint(iShadowTlWidth, iShadowTlHeight) - rect.iTl );
       
  1411 	    
       
  1412 	    SetRect( rect );  
       
  1413 	    RootControl()->SetRect( rect );
       
  1414 	    UiLayout()->SetShadowRect( shadowRect );  	
       
  1415 	    }
       
  1416     }
       
  1417     
       
  1418 
       
  1419 // -----------------------------------------------------------------------------
       
  1420 // CPeninputLayoutWindowExt::SetSwitchBtnFont
       
  1421 // (other items were commented in a header).
       
  1422 // -----------------------------------------------------------------------------
       
  1423 //
       
  1424 EXPORT_C void CPeninputLayoutWindowExt::SetSwitchBtnFont(CAknFepCtrlEventButton& aSwitchBtn)
       
  1425     {
       
  1426     // read switch font laf info only when need
       
  1427     if (CPeninputDataConverter::AnyToInt(
       
  1428         iLayoutContext->RequestData(EAkninputDataTypeSizeChanging)) ||(!iSwitchFontSet))
       
  1429     	{
       
  1430         TAknTextLineLayout langSwitch;
       
  1431         TAknTextLineLayout langSwitchShadow;
       
  1432 
       
  1433         switch( iLayoutContext->LayoutType() )
       
  1434             {
       
  1435             case EPluginInputModeVkb:
       
  1436             case EPluginInputModeFSQ:
       
  1437                 {
       
  1438                 langSwitch = 
       
  1439                     AknLayoutScalable_Avkon::cell_vkb_side_pane_t1().LayoutLine();
       
  1440                 langSwitchShadow = 
       
  1441                     AknLayoutScalable_Avkon::cell_vkb_side_pane_t1_copy1().LayoutLine();
       
  1442                 }
       
  1443                 break;
       
  1444             case EPluginInputModeHwr:
       
  1445                 {
       
  1446                 langSwitch = 
       
  1447                     AknLayoutScalable_Avkon::cell_hwr_side_pane_t1().LayoutLine();
       
  1448                 langSwitchShadow = 
       
  1449                     AknLayoutScalable_Avkon::cell_hwr_side_pane_t1_copy1().LayoutLine();
       
  1450                 }
       
  1451                 break;
       
  1452             default:
       
  1453                 {
       
  1454                 return;
       
  1455                 }
       
  1456             }
       
  1457         
       
  1458         iSwitchFont = langSwitch.iFont;
       
  1459         iSwitchShadowFont = langSwitchShadow.iFont;
       
  1460     	}
       
  1461     
       
  1462     aSwitchBtn.SetFont(AknLayoutUtils::FontFromId(iSwitchFont, NULL));
       
  1463     aSwitchBtn.SetShadowFont(AknLayoutUtils::FontFromId(iSwitchShadowFont, NULL));
       
  1464     iSwitchFontSet = ETrue;
       
  1465     }
       
  1466 
       
  1467 // ---------------------------------------------------------------------------
       
  1468 // CPeninputLayoutWindowExt::TopLeftJustify
       
  1469 // (other items were commented in a header)
       
  1470 // ---------------------------------------------------------------------------
       
  1471 //   
       
  1472 EXPORT_C void CPeninputLayoutWindowExt::SetSwitchBtnTextColor(CAknFepCtrlEventButton& aSwitchBtn)
       
  1473     {
       
  1474     TRgb textColor;
       
  1475     TInt error = AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
       
  1476                                            textColor,
       
  1477                                            KAknsIIDQsnTextColors,
       
  1478                                            EAknsCIQsnTextColorsCG59);
       
  1479 
       
  1480     if (error != KErrNone)
       
  1481         {
       
  1482     	textColor = TRgb(KDefaultTextColor);
       
  1483         }
       
  1484         
       
  1485     aSwitchBtn.SetFontColor( textColor );   
       
  1486     
       
  1487     TRgb shadowTextColor;    
       
  1488     error = AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
       
  1489                                       shadowTextColor,
       
  1490                                       KAknsIIDQsnTextColors,
       
  1491                                       EAknsCIQsnTextColorsCG62);
       
  1492                                       
       
  1493     if (error != KErrNone)
       
  1494         {
       
  1495     	shadowTextColor = TRgb(KDefaultShadowTextColor);
       
  1496         }
       
  1497     
       
  1498     aSwitchBtn.SetShadowFontColor( shadowTextColor );
       
  1499     }
       
  1500     
       
  1501 // ---------------------------------------------------------------------------
       
  1502 // CPeninputLayoutWindowExt::TopLeftJustify
       
  1503 // (other items were commented in a header)
       
  1504 // ---------------------------------------------------------------------------
       
  1505 //   
       
  1506 void CPeninputLayoutWindowExt::TopLeftJustify()
       
  1507     {
       
  1508     // Read position from datamgr 
       
  1509     TSize layoutSize = UiLayout()->Rect().Size();
       
  1510     
       
  1511     TPoint tl = UiLayout()->Position();
       
  1512     
       
  1513     TPoint oldBr = tl + layoutSize;
       
  1514     
       
  1515     if ( tl.iX < 0 )
       
  1516         {
       
  1517         tl.iX = 0;
       
  1518         }
       
  1519     
       
  1520     if ( tl.iY < 0 )
       
  1521         {
       
  1522         tl.iY = 0;  
       
  1523         }
       
  1524         
       
  1525     TPoint br = tl + layoutSize;          
       
  1526 
       
  1527     if ( br != oldBr )
       
  1528         {
       
  1529         //Write the new position into CenRep
       
  1530         TInt x = 0;
       
  1531         TInt y = 0;
       
  1532         x = 0x0000FFFF & br.iX;
       
  1533         y = 0xFFFF0000 & ( br.iY << 16 );
       
  1534         TInt pos = x | y;
       
  1535         iLayoutContext->SetData( EPeninputDataTypeWindowPosition, &pos );
       
  1536         }
       
  1537         
       
  1538     UiLayout()->LayoutOwner()->SetPosition( tl );
       
  1539     }
       
  1540 
       
  1541 // ---------------------------------------------------------------------------
       
  1542 // CPeninputLayoutWindowExt::BottomRightJustify
       
  1543 // (other items were commented in a header).
       
  1544 // ---------------------------------------------------------------------------
       
  1545 //    
       
  1546 void CPeninputLayoutWindowExt::BottomRightJustify()
       
  1547     {
       
  1548     // Read position from datamgr 
       
  1549     TSize layoutSize( UiLayout()->Rect().Size() );
       
  1550 
       
  1551     TPoint oldbr;
       
  1552     TPoint br;
       
  1553     TPoint tl;
       
  1554 
       
  1555     TSize screenSize = *( ( TSize* ) iLayoutContext->RequestData
       
  1556                             ( EPeninputDataTypeScreenSize ) );
       
  1557     
       
  1558     TInt windowPosition = CPeninputDataConverter::AnyToInt
       
  1559         ( iLayoutContext->RequestData( EPeninputDataTypeWindowPosition ) );
       
  1560 
       
  1561     oldbr.iX = windowPosition & 0x0000FFFF;
       
  1562     oldbr.iY = ( windowPosition & 0xFFFF0000 ) >> 16;
       
  1563     
       
  1564     br = oldbr;
       
  1565         
       
  1566     // Check the top left point is in screen
       
  1567     if (br.iX > screenSize.iWidth)
       
  1568         {
       
  1569     	br.iX = screenSize.iWidth;
       
  1570         }
       
  1571     if( br.iY > screenSize.iHeight )
       
  1572         {
       
  1573     	br.iY = screenSize.iHeight;
       
  1574         }
       
  1575 
       
  1576     tl.iX = br.iX - layoutSize.iWidth;
       
  1577     tl.iY = br.iY - layoutSize.iHeight;
       
  1578     
       
  1579     if ( tl.iX < 0 )
       
  1580         {
       
  1581         tl.iX = 0;
       
  1582         br.iX = layoutSize.iWidth;
       
  1583         }
       
  1584 
       
  1585     if ( tl.iY < 0 )
       
  1586         {
       
  1587         tl.iY = 0;  
       
  1588         br.iY = layoutSize.iHeight;
       
  1589         }
       
  1590         
       
  1591     if ( oldbr != br )
       
  1592         {
       
  1593         //Write the new position into CenRep
       
  1594         TInt x = 0;
       
  1595         TInt y = 0;
       
  1596         x = 0x0000FFFF & br.iX;
       
  1597         y = 0xFFFF0000 & ( br.iY << 16 );
       
  1598         TInt pos = x | y;
       
  1599         iLayoutContext->SetData( EPeninputDataTypeWindowPosition, &pos );
       
  1600         }
       
  1601         
       
  1602     UiLayout()->LayoutOwner()->SetPosition( tl );
       
  1603     }
       
  1604 
       
  1605 // ---------------------------------------------------------------------------
       
  1606 // CPeninputLayoutWindowExt::DataQueryJustify
       
  1607 // (other items were commented in a header)
       
  1608 // ---------------------------------------------------------------------------
       
  1609 //   
       
  1610 void CPeninputLayoutWindowExt::DataQueryJustify()
       
  1611     {
       
  1612     TRect* dataQueryRect = ( TRect* )( iLayoutContext->RequestData
       
  1613         ( EPeninputDataTypeDataQueryDlgRect) );
       
  1614     
       
  1615     TRect rect = TRect( UiLayout()->Position(), UiLayout()->Rect().Size() );
       
  1616     
       
  1617 	CCoeEnv* coeEnv = CCoeEnv::Static();
       
  1618     TPixelsTwipsAndRotation ptSize;     
       
  1619     coeEnv->ScreenDevice()->GetDefaultScreenSizeAndRotation(ptSize);    
       
  1620 
       
  1621 	// Landscape mode: move window to the br of the screen
       
  1622     if (ptSize.iPixelSize.iWidth > ptSize.iPixelSize.iHeight)
       
  1623     	{
       
  1624     	rect.SetRect(ptSize.iPixelSize.iWidth - rect.Width(), 
       
  1625     			     ptSize.iPixelSize.iHeight/2 - rect.Height()/2,
       
  1626     			     ptSize.iPixelSize.iWidth, 
       
  1627     			     ptSize.iPixelSize.iHeight/2 + rect.Height()/2);
       
  1628     	}
       
  1629 	// Portrait mode: dodge the dataquery   	
       
  1630     else if ( rect.Intersects( *dataQueryRect ) )
       
  1631         {
       
  1632         TInt Y = dataQueryRect->iTl.iY;
       
  1633         TInt height = rect.iBr.iY - rect.iTl.iY;
       
  1634         rect.iTl.iY = Y - height;
       
  1635         rect.iBr.iY = Y;
       
  1636         
       
  1637         if( rect.iTl.iY <0 )
       
  1638             {
       
  1639             rect.iTl.iY = 0;
       
  1640             rect.iBr.iY = height;
       
  1641             }
       
  1642         }
       
  1643 
       
  1644     //Write the new position into CenRep
       
  1645     TInt x = 0;
       
  1646     TInt y = 0;
       
  1647     x = 0x0000FFFF & rect.iBr.iX;
       
  1648     y = 0xFFFF0000 & ( rect.iBr.iY << 16 );
       
  1649     TInt pos = x | y;
       
  1650     iLayoutContext->SetData( EPeninputDataTypeWindowPosition, &pos );          
       
  1651 
       
  1652     //Set the layout position
       
  1653     UiLayout()->LayoutOwner()->SetPosition( rect.iTl );
       
  1654     }
       
  1655 
       
  1656 TBool CPeninputLayoutWindowExt::CreateCustomControlL( TInt16 /*aControlId*/, TInt32 /*aImageId*/ )
       
  1657 	{
       
  1658 	return EFalse;	
       
  1659 	}
       
  1660     
       
  1661 // ---------------------------------------------------------------------------
       
  1662 // CPeninputLayoutWindowExt::Draw
       
  1663 // (other items were commented in a header)
       
  1664 // ---------------------------------------------------------------------------
       
  1665 // 
       
  1666 EXPORT_C void CPeninputLayoutWindowExt::Draw()
       
  1667     {    
       
  1668     // Draw shadow
       
  1669     CAknFepCtrlBaseWindowExt::Draw();
       
  1670     UpdateArea(UiLayout()->Rect(), EFalse);   
       
  1671     }
       
  1672        
       
  1673 // ---------------------------------------------------------------------------
       
  1674 // CPeninputLayoutWindowExt::GetKeyMappingStringL
       
  1675 // (other items were commented in a header)
       
  1676 // ---------------------------------------------------------------------------
       
  1677 //     
       
  1678 HBufC* CPeninputLayoutWindowExt::GetKeyMappingStringL(TInt aKeyMapping,
       
  1679     const TInt aLang )
       
  1680     {
       
  1681     HBufC* rs = NULL;
       
  1682     if ( aKeyMapping == EKeymapFromResource )
       
  1683         {
       
  1684         HBufC* customRes = (HBufC*) iLayoutContext->RequestData(EAknFepDataTypeUseDefinedResource);
       
  1685         _LIT(KTenNumbers,"0123456789");
       
  1686         TBuf<KMaxNumericString> numbers;
       
  1687         if( aLang == ELangArabic )
       
  1688             {
       
  1689             numbers.Format( _L("%c%c%c%c%c%c%c%c%c%c"),
       
  1690                 0x0660, 0x0661, 0x0662,
       
  1691                 0x0663, 0x0664, 0x0665,
       
  1692                 0x0666, 0x0667, 0x0668, 0x0669 );
       
  1693             }
       
  1694         else if( aLang == ELangUrdu || aLang == ELangFarsi )
       
  1695             {
       
  1696             numbers.Format( _L("%c%c%c%c%c%c%c%c%c%c"),
       
  1697                 0x06F0, 0x06F1, 0x06F2,
       
  1698                 0x06F3, 0x06F4, 0x06F5,
       
  1699                 0x06F6, 0x06F7, 0x06F8, 0x06F9 );
       
  1700             }
       
  1701         else if( aLang == ELangHindi )
       
  1702             {
       
  1703             numbers.Format( _L("%c%c%c%c%c%c%c%c%c%c"),
       
  1704                 0x0966, 0x0967, 0x0968,
       
  1705                 0x0969, 0x096a, 0x096b,
       
  1706                 0x096c, 0x096d, 0x096e, 0x096f );
       
  1707             }
       
  1708         else if( aLang == ELangThai )
       
  1709             {
       
  1710             numbers.Format( _L("%c%c%c%c%c%c%c%c%c%c"),
       
  1711                 0x0E50, 0x0E51, 0x0E52,
       
  1712                 0x0E53, 0x0E54, 0x0E55,
       
  1713                 0x0E56, 0x0E57, 0x0E58, 0x0E59 );        
       
  1714             }
       
  1715         else
       
  1716             {
       
  1717             numbers = KTenNumbers;
       
  1718             }
       
  1719             
       
  1720         rs = HBufC::NewL(numbers.Length() + customRes->Length());
       
  1721         rs->Des().Copy(*customRes);
       
  1722         rs->Des().Append(numbers);
       
  1723         }
       
  1724     else
       
  1725         {
       
  1726         rs = iKeyMappingMgr->KeyMappingStringL( aKeyMapping, aLang );
       
  1727         }
       
  1728         
       
  1729     return rs;     
       
  1730     }
       
  1731        
       
  1732 // ---------------------------------------------------------------------------
       
  1733 // CPeninputLayoutWindowExt::SetEnableSwitchToHwr
       
  1734 // (other items were commented in a header)
       
  1735 // ---------------------------------------------------------------------------
       
  1736 //     
       
  1737 EXPORT_C void CPeninputLayoutWindowExt::SetEnableSwitchToHwr(TBool aEnable)
       
  1738     {
       
  1739     CAknFepCtrlEventButton* switchToHwrBtn = static_cast<CAknFepCtrlEventButton*>
       
  1740         ( Control( EPeninutWindowCtrlIdSwitchToHwrBtn ) );
       
  1741 
       
  1742     if ( aEnable )    
       
  1743         {
       
  1744         switchToHwrBtn->SetDimmed(EFalse);
       
  1745         }
       
  1746     else
       
  1747         {
       
  1748         switchToHwrBtn->SetDimmed(ETrue);
       
  1749         switchToHwrBtn->SetActive(EFalse);
       
  1750         } 
       
  1751     }
       
  1752 
       
  1753 // ---------------------------------------------------------------------------
       
  1754 // CPeninputLayoutWindowExt::SetEnableSettingBtn
       
  1755 // (other items were commented in a header)
       
  1756 // ---------------------------------------------------------------------------
       
  1757 //     
       
  1758 EXPORT_C void CPeninputLayoutWindowExt::SetEnableSettingBtn(TBool aEnable)
       
  1759     {
       
  1760     CAknFepCtrlEventButton* optionBtn = static_cast<CAknFepCtrlEventButton*>
       
  1761         (Control( EPeninutWindowCtrlIdOptionBtn ) );
       
  1762             
       
  1763     if ( aEnable )    
       
  1764         {
       
  1765         optionBtn->SetDimmed(EFalse);
       
  1766         }
       
  1767     else
       
  1768         {
       
  1769         optionBtn->SetDimmed(ETrue);
       
  1770         optionBtn->SetActive(EFalse);
       
  1771         } 
       
  1772     }
       
  1773         
       
  1774 // ---------------------------------------------------------------------------
       
  1775 // CPeninputLayoutWindowExt::ReconfigUnitSize
       
  1776 // (other items were commented in a header)
       
  1777 // ---------------------------------------------------------------------------
       
  1778 //     
       
  1779 EXPORT_C TBool CPeninputLayoutWindowExt::ReconfigUnitSize(TInt /*aClientLayoutId*/)
       
  1780     {
       
  1781     return EFalse;
       
  1782     }
       
  1783     
       
  1784 EXPORT_C void CPeninputLayoutWindowExt::SetLafLayOut(TInt /*aRows*/, TInt /*aColumns*/)
       
  1785     {
       
  1786     
       
  1787     }
       
  1788 
       
  1789 EXPORT_C void CPeninputLayoutWindowExt::SetVkbLayoutSize()
       
  1790     {
       
  1791     
       
  1792     }
       
  1793 EXPORT_C void CPeninputLayoutWindowExt::OnInputLanguageChange()
       
  1794     {
       
  1795     if ( iLayoutContext->LayoutType() == EPluginInputModeVkb )
       
  1796         {       
       
  1797         CFepUiBaseCtrl* ctrl = 
       
  1798             Control( EPeninutWindowCtrlIdVkbCtrl );
       
  1799         if ( ctrl )
       
  1800             {
       
  1801             ( static_cast<CPeninputVkbCtrlExt*>( ctrl ) )->Reset();
       
  1802             }
       
  1803         } 
       
  1804     }
       
  1805     
       
  1806 void CPeninputLayoutWindowExt::AddCustomControlGroupL(CFepUiBaseCtrl* aCtrl)
       
  1807 	{
       
  1808 	AddControlL(aCtrl);
       
  1809 	}
       
  1810 
       
  1811 void CPeninputLayoutWindowExt::ResetLastColRow()
       
  1812 	{
       
  1813     iLastUsedTotalColumns = 0;
       
  1814     iLastUsedTotalRows = 0;
       
  1815 	}
       
  1816 
       
  1817 
       
  1818 EXPORT_C void CPeninputLayoutWindowExt::SetTextAlignmentL( TInt aAlignment )	
       
  1819 	{
       
  1820 	CFepLayoutMultiLineIcf* icf = 
       
  1821 	    static_cast<CFepLayoutMultiLineIcf*>( Control(EPeninputWindowCtrlIdMultiLineICF));
       
  1822 	    
       
  1823 	if ( icf && ConfigInfo()->Language() != ELangNone )
       
  1824 		{
       
  1825 		icf->SetTextAlignmentL( aAlignment, ConfigInfo()->Language() );
       
  1826 		}
       
  1827 	}
       
  1828 	
       
  1829 //End Of File