textinput/peninputfingerhwr/src/peninputfingerhwrwnd.cpp
changeset 0 eb1f2e154e89
child 3 f5a1e66df979
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     1 /*
       
     2 * Copyright (c) 2009 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:  Implementation of main window of finger hwr.
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE
       
    19 #include <peninputfingerhwrcn.rsg>
       
    20 #include <aknlayoutscalable_apps.cdl.h>
       
    21 #include <aknLayoutscalable_avkon.cdl.h>
       
    22 #include <peninputlayoutmultilineicf.h>
       
    23 #include <peninputdropdownlist.h>
       
    24 #include <peninputrepeatbutton.h>
       
    25 #include <AknLayoutDef.h>
       
    26 #include <AknUtils.h>
       
    27 #include <AknsUtils.h>
       
    28 #include <akniconutils.h>
       
    29 #include <coemain.h>
       
    30 #include <S32MEM.h>
       
    31 #include <peninputlayoutchoicelist.h>
       
    32 #include <aknfeppeninputenums.h>
       
    33 #include <AknFepGlobalEnums.h>
       
    34 #include <peninputlayoutinputmodechoice.h>
       
    35 #include <peninputrepeatbutton.h>
       
    36 #include <peninputlayout.h>
       
    37 #include <peninputlayoutbubblectrl.h>
       
    38 #include <peninputlayoutvkb.h>
       
    39 
       
    40 #include <peninputmultiimagebutton.h>
       
    41 
       
    42 #include "peninputfingerhwrwnd.h"
       
    43 #include "peninputfingerhwrlafmanager.h"
       
    44 #include "peninputfingerhwrevent.h"
       
    45 #include "peninputfingerhwrcontrolid.h"
       
    46 #include "peninputfingerhwrstoreconstants.h"
       
    47 #include "peninputfingerhwrlayout.h"
       
    48 #include "peninputfingerhwrdatastore.h"
       
    49 #include "peninputlayouthwrwnd.h"
       
    50 
       
    51 #include "peninputmultipagevkb.h"
       
    52 #include "peninputfingerhwrrangeselector.h"
       
    53 #include "hbufcarray.h"
       
    54 
       
    55 const TUint32 KDefaultTextColor = 0x000000;
       
    56 const TUint KDefaultFrameColor = 0x000000;
       
    57 const TUint32 KDefaultWriteBoxBgColor = 0xdddddd;
       
    58 const TUint32 KDefaultWriteBoxFrameColor = 0x000000;
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // Symbian Constructor
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 CPeninputFingerHwrWnd* CPeninputFingerHwrWnd::NewL( CFepUiLayout* aFepUiLayout,
       
    65     TInt aControlId, TBool aLandscapeStyle )
       
    66     {
       
    67     CPeninputFingerHwrWnd* self = NewLC( aFepUiLayout, aControlId, aLandscapeStyle );
       
    68     CleanupStack::Pop( self );
       
    69 
       
    70     return self;
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // Symbian Constructor
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 CPeninputFingerHwrWnd* CPeninputFingerHwrWnd::NewLC( CFepUiLayout* aFepUiLayout, 
       
    78     TInt aControlId, TBool aLandscapeStyle )
       
    79     {
       
    80     CPeninputFingerHwrWnd* self = new ( ELeave ) CPeninputFingerHwrWnd( aFepUiLayout, aControlId );
       
    81     CleanupStack::PushL( self );
       
    82     self->ConstructL( aLandscapeStyle );
       
    83 
       
    84     return self;
       
    85     }
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // c++ destructor
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 CPeninputFingerHwrWnd::~CPeninputFingerHwrWnd()
       
    92     {
       
    93     //delete by it's owner
       
    94     iContextField    = NULL;
       
    95 
       
    96 #ifndef RD_INTELLIGENT_TEXT_INPUT    
       
    97     iFixEngSymbolList1 = NULL;
       
    98     iFixEngSymbolList2 = NULL;
       
    99 #endif
       
   100 
       
   101     iCandidateList   = NULL;
       
   102     iPredictList     = NULL;
       
   103     iWritingBox      = NULL;
       
   104     
       
   105     iCloseBtn        = NULL;
       
   106     iOptionBtn       = NULL;
       
   107     iImeSwitchBtn    = NULL;
       
   108     iBackspaceBtn    = NULL;
       
   109     iArrowLeftBtn    = NULL; 
       
   110     iArrowRightBtn   = NULL;
       
   111     iArrowUpBtn      = NULL;
       
   112     iArrowDownBtn    = NULL; 
       
   113     iRangeSpecialBtn = NULL;
       
   114     iRangeSelector   = NULL;
       
   115     
       
   116     iSctPage0Btn = NULL;
       
   117     iSctPage1Btn = NULL;
       
   118     iSctPage2Btn = NULL;
       
   119     
       
   120     iVirtualNumpad = NULL;
       
   121     iVirtualSctpad = NULL;    
       
   122     iVirtualSctpadFix = NULL;
       
   123     iRangeSelector = NULL;
       
   124     iInputModeSwitch = NULL; 
       
   125     
       
   126     delete iLafManager;
       
   127     iLafManager = NULL;
       
   128     }
       
   129 
       
   130 // ---------------------------------------------------------------------------
       
   131 // Construct control from resource.
       
   132 // ---------------------------------------------------------------------------
       
   133 //
       
   134 void CPeninputFingerHwrWnd::ConstructFromResourceL()
       
   135     {
       
   136     if ( iResourceId == KInvalidResId )
       
   137         {
       
   138         User::Leave( KErrArgument );
       
   139         }
       
   140 
       
   141     TResourceReader reader;
       
   142     CCoeEnv::Static()->CreateResourceReaderLC( reader, iResourceId );
       
   143 
       
   144     TInt supportskin = reader.ReadInt16();
       
   145     
       
   146     if ( iFirstTimeConstruct && ( supportskin != KNotSupportSkin ) )
       
   147         {
       
   148         UiLayout()->AddControlL( this );
       
   149         }
       
   150     
       
   151     // read shadow resources
       
   152     TInt32 shadow = reader.ReadInt32();
       
   153     ReadShadowInfoL( shadow );
       
   154     
       
   155     // read icf resource
       
   156     TInt32 icf = reader.ReadInt32();
       
   157     ReadICFInfoL( icf );
       
   158      
       
   159 
       
   160     if ( iFirstTimeConstruct )
       
   161         {
       
   162         const TInt32 boxwndResId = reader.ReadInt32();
       
   163         const TInt32 bgImageResId = reader.ReadInt32();
       
   164   
       
   165         ReadWritingBoxInfoL( boxwndResId );
       
   166         ReadBackgroundInfoL( bgImageResId );
       
   167         }
       
   168     else
       
   169         {
       
   170         CControlGroup::ConstructFromResourceL();
       
   171 
       
   172         const TInt32 boxwndResId = reader.ReadInt32();
       
   173         const TInt32 bgImageResId = reader.ReadInt32();
       
   174         ReadWritingBoxInfoL( boxwndResId );
       
   175         ReadBackgroundInfoL( bgImageResId );
       
   176         }    
       
   177 
       
   178     CleanupStack::PopAndDestroy(); // reader
       
   179 
       
   180     // read keypad image info
       
   181     if ( iVirtualNumpad )
       
   182         {
       
   183         TSize keysize = iLafManager->VirtualNumpadCellSize().Size();
       
   184         LoadVkbKeyImageL( iVirtualNumpad, R_FINGER_HWR_NUMPAD_IMAGE, keysize );
       
   185         
       
   186         RArray<TRect> rects;
       
   187         CleanupClosePushL( rects );
       
   188         iLafManager->GetVirtualKeyRects( rects );
       
   189         LoadVirtualNumpadKeysL( R_FINGER_HWR_NUMPAD, rects );
       
   190         CleanupStack::PopAndDestroy(); //rects
       
   191         }
       
   192     
       
   193     if ( iVirtualSctpad )
       
   194         {
       
   195         TSize keysize = iLafManager->VirtualSctpadCellSize().Size();
       
   196         LoadVkbKeyImageL( iVirtualSctpad, R_FINGER_HWR_SCTPAD_IMAGE, keysize );
       
   197         
       
   198         RArray<TRect> rects;
       
   199         CleanupClosePushL( rects );
       
   200         iLafManager->GetVirtualKeyRects( rects );
       
   201         LoadVirtualSctpadKeysL( R_FINGER_HWR_SCTPAD, rects );
       
   202         CleanupStack::PopAndDestroy(); //rects
       
   203         }
       
   204     
       
   205     if ( iVirtualSctpadFix )
       
   206         {
       
   207         TSize keysize = iLafManager->FixVirtualSctpadCellSize().Size();
       
   208         LoadVkbKeyImageL( iVirtualSctpadFix, R_FINGER_HWR_SCTPAD_IMAGE, keysize );
       
   209         
       
   210         RArray<TRect> rects;
       
   211         CleanupClosePushL( rects );
       
   212         iLafManager->GetFixVirtualKeyRects( rects );
       
   213         LoadFixVirtualSctpadKeysL( R_FINGER_HWR_SCTPAD_FIX, rects );
       
   214         CleanupStack::PopAndDestroy(); //rects        
       
   215         }
       
   216         
       
   217     if (!iFirstTimeConstruct)
       
   218     	{
       
   219     	Draw();
       
   220     	}
       
   221     
       
   222     iFirstTimeConstruct = EFalse;  
       
   223     }
       
   224 
       
   225 
       
   226 // ---------------------------------------------------------------------------
       
   227 // Draw window.
       
   228 // ---------------------------------------------------------------------------
       
   229 //
       
   230 void CPeninputFingerHwrWnd::Draw()
       
   231     { 
       
   232     DrawOpaqueMaskBackground( Rect() );
       
   233 
       
   234     if( BackgroundBmp() && BackgroundBmp()->SizeInPixels() != Rect().Size() )
       
   235         {
       
   236     	AknIconUtils::SetSize(BackgroundBmp(), Rect().Size(), EAspectRatioNotPreserved);
       
   237         }
       
   238 
       
   239 	DrawBackground();    
       
   240          
       
   241     CControlGroup::Draw();
       
   242     
       
   243     UpdateArea( Rect(), EFalse );
       
   244     }
       
   245 
       
   246 // ---------------------------------------------------------------------------
       
   247 // Resize.
       
   248 // ---------------------------------------------------------------------------
       
   249 //
       
   250 void CPeninputFingerHwrWnd::SizeChangedL( TBool /*aLandscapeStyle*/ )
       
   251     {
       
   252     iLafManager->ReadLafInfo();
       
   253     ResetLayoutL();
       
   254   
       
   255     if ( iLafManager->IsLandscape() )
       
   256         {
       
   257         iPredictList->SetCandExpandType( CFepCtrlDropdownList::ECandExpandUpward );
       
   258         }
       
   259     else
       
   260         {
       
   261         iPredictList->SetCandExpandType( CFepCtrlDropdownList::ECandExpandDownward );
       
   262         }    
       
   263             
       
   264     iCandidateList->SizeChanged( iLafManager->CandidateUnitWidth(),
       
   265             iLafManager->CandidateUnitHeight(), 
       
   266             iLafManager->CandidateUnitWidth(), 
       
   267             iLafManager->CandidateLTPos(), 
       
   268             KCandidateCountPerRow,
       
   269             1 );
       
   270             
       
   271     iPredictList->SizeChanged( iLafManager->CandidateUnitWidth(),
       
   272             iLafManager->CandidateUnitHeight(),
       
   273             iLafManager->CandidateUnitWidth(), 
       
   274             iLafManager->PredictiveLTPos(),
       
   275             KPredictiveCountPerRow,
       
   276             KPredictiveRowCount );
       
   277 
       
   278     if ( iFixEngSymbolList1 )
       
   279         {
       
   280         iFixEngSymbolList1->SizeChanged( iLafManager->CandidateUnitWidth(),
       
   281                 iLafManager->CandidateUnitHeight(), 
       
   282                 iLafManager->CandidateUnitWidth(), 
       
   283                 iLafManager->CandidateLTPos(), 
       
   284                 KCandidateCountPerRow,
       
   285                 1 );        
       
   286         }
       
   287     
       
   288     if ( iFixEngSymbolList2 )
       
   289         {
       
   290         iFixEngSymbolList2->SizeChanged( iLafManager->CandidateUnitWidth(),
       
   291                 iLafManager->CandidateUnitHeight(), 
       
   292                 iLafManager->CandidateUnitWidth(), 
       
   293                 iLafManager->PredictiveLTPos(), 
       
   294                 KPredictiveCountPerRow,
       
   295                 1 );             
       
   296         }
       
   297     
       
   298     iContextField->SetTextMargin ( iLafManager->IcfLeftMargin(),
       
   299             iLafManager->IcfRightMargin(),
       
   300             iLafManager->IcfTopMargin(),
       
   301             iLafManager->IcfBottomMargin() );
       
   302     
       
   303     iContextField->SetLineSpace( iLafManager->IcfLineSpaceMargin() );                          
       
   304     iContextField->SizeChangedL( iLafManager->IcfRect(), 
       
   305             iLafManager->IcfTextHeight(),
       
   306             iLafManager->IcfFont()->FontMaxHeight(),
       
   307             iLafManager->IcfFont() );
       
   308 }
       
   309 
       
   310 // ---------------------------------------------------------------------------
       
   311 // accept editor's text alignment.
       
   312 // ---------------------------------------------------------------------------
       
   313 //
       
   314 void CPeninputFingerHwrWnd::SetTextAlignmentL( TInt aAlignment, TInt aLangId )  
       
   315     {
       
   316     if ( iContextField )
       
   317         {
       
   318         iContextField->SetTextAlignmentL( aAlignment, aLangId );
       
   319         }
       
   320     }
       
   321 
       
   322 // ---------------------------------------------------------------------------
       
   323 // accept editor's text
       
   324 // ---------------------------------------------------------------------------
       
   325 //
       
   326 void CPeninputFingerHwrWnd::SetEditorTextL( const TFepInputContextFieldData& aData )
       
   327     {
       
   328     if ( iContextField )
       
   329         {
       
   330         iContextField->SetTextL( aData );
       
   331         }
       
   332     }
       
   333 
       
   334 // ---------------------------------------------------------------------------
       
   335 // accept editor's promopt txt.
       
   336 // ---------------------------------------------------------------------------
       
   337 //
       
   338 void CPeninputFingerHwrWnd::SetPromptTextL( TUint8* aPromoptData )
       
   339     {
       
   340     RDesReadStream readStream;
       
   341 
       
   342     TPtr8 countPtr( aPromoptData, 2*sizeof( TInt ), 2*sizeof( TInt ) );
       
   343     readStream.Open( countPtr );
       
   344     CleanupClosePushL( readStream );
       
   345     const TInt dataCount = readStream.ReadInt32L();
       
   346     const TInt textCount = readStream.ReadInt32L();
       
   347     CleanupStack::PopAndDestroy( &readStream );
       
   348     
       
   349     TPtr8 ptr( aPromoptData+2*sizeof( TInt ), dataCount+textCount, dataCount+textCount );            
       
   350     readStream.Open( ptr );
       
   351     CleanupClosePushL( readStream );
       
   352     
       
   353     HBufC8* dataBuf = HBufC8::NewLC( dataCount );
       
   354     TPtr8 dataBufPtr = dataBuf->Des();
       
   355     readStream.ReadL( dataBufPtr, dataCount );
       
   356 
       
   357     TFepPromptText* pIcfData = reinterpret_cast<TFepPromptText*>( const_cast<TUint8*>( dataBufPtr.Ptr() ) );
       
   358 
       
   359     HBufC* textBuf;
       
   360     if ( textCount > 0 )
       
   361         {
       
   362         textBuf = HBufC::NewLC( textCount/2 );
       
   363         TPtr textBufPtr = textBuf->Des();
       
   364         readStream.ReadL( textBufPtr, textCount/2 );
       
   365         iContextField->SetPromptTextL( textBuf->Des(), ETrue );
       
   366         CleanupStack::PopAndDestroy( textBuf );
       
   367         }
       
   368     else
       
   369         {
       
   370         iContextField->SetPromptTextL( KNullDesC, ETrue );
       
   371         }
       
   372 
       
   373     CleanupStack::PopAndDestroy( dataBuf );
       
   374     CleanupStack::PopAndDestroy( &readStream );        
       
   375     }
       
   376  
       
   377 // ---------------------------------------------------------------------------
       
   378 // Dim option button
       
   379 // ---------------------------------------------------------------------------
       
   380 //
       
   381 void CPeninputFingerHwrWnd::SetEnableSettingBtn(const TBool aEnable)
       
   382     {
       
   383     if ( aEnable )    
       
   384         {
       
   385         iOptionBtn->SetDimmed(EFalse);
       
   386         }
       
   387     else
       
   388         {
       
   389         iOptionBtn->SetDimmed(ETrue);
       
   390         iOptionBtn->SetActive(EFalse);
       
   391         }
       
   392     
       
   393     }
       
   394 
       
   395 // ---------------------------------------------------------------------------
       
   396 // accept editor's bubble text.
       
   397 // ---------------------------------------------------------------------------
       
   398 //
       
   399 void CPeninputFingerHwrWnd::SetBubbleTextL( const TDesC& aInfo )
       
   400     {
       
   401     if ( aInfo.Length() > 0 )
       
   402         {
       
   403         iContextField->ShowBubble( aInfo, iContextField->MsgBubbleCtrl()->Rect() );
       
   404         }
       
   405     else
       
   406         {
       
   407         iContextField->HideBubble();
       
   408         }    
       
   409     }
       
   410 
       
   411 // ---------------------------------------------------------------------------
       
   412 // accept editor's char ranges restriction.
       
   413 // ---------------------------------------------------------------------------
       
   414 //
       
   415 void CPeninputFingerHwrWnd::SetPermittedRanges( const TInt aPermittedRanges )
       
   416     {
       
   417     if(aPermittedRanges == 0)
       
   418         return;
       
   419     
       
   420     iPermittedRanges = aPermittedRanges;
       
   421     
       
   422     iRangeSelector->SetPermittedRanges( aPermittedRanges );    
       
   423     }
       
   424 
       
   425 // ---------------------------------------------------------------------------
       
   426 // accept editor's number mapping restriction.
       
   427 // ---------------------------------------------------------------------------
       
   428 //
       
   429 void CPeninputFingerHwrWnd::SetNumericMapping( const TDesC& aNumMapping )
       
   430     {
       
   431     //format of aNumMapping is "0123456789******"
       
   432     
       
   433     //char offset in aNumMapping
       
   434     //cell 0 using aNumMapping[KNumOffsets[0]]
       
   435     //cell 1 using aNumMapping[KNumOffsets[1]]
       
   436     const TInt KNumOffsets[] = 
       
   437         {
       
   438          1,  2,  3, 15,
       
   439          4,  5,  6, 14,
       
   440          7,  8,  9, 13,
       
   441         10,  0, 11, 12
       
   442         };
       
   443     
       
   444     TInt maxMappingItemCount = sizeof(KNumOffsets)/sizeof(TInt);
       
   445     TInt mappingItemCount = aNumMapping.Length();
       
   446     
       
   447     //numberpad
       
   448     TInt keyCount = iVirtualNumpad->KeyArray().Count();
       
   449     for ( TInt i = 0; i < keyCount; i++ )
       
   450         {
       
   451         CVirtualKey* vk = iVirtualNumpad->KeyArray()[i];
       
   452         
       
   453         TInt offset = ( i < maxMappingItemCount ) ? KNumOffsets[i] : -1;
       
   454         
       
   455         if ( offset > -1  && offset < mappingItemCount )
       
   456             {
       
   457             TUint16 unicode = aNumMapping[offset];
       
   458             vk->SetKeyData( aNumMapping.Mid( offset,1 ) );
       
   459             vk->SetKeyScancode( unicode );
       
   460             vk->SetDimmed( EFalse );
       
   461             }
       
   462         else
       
   463             {
       
   464             vk->SetKeyData( KNullDesC );
       
   465             vk->SetKeyScancode( 0xFFFF );
       
   466             vk->SetDimmed( EFalse );
       
   467             }
       
   468         }
       
   469     
       
   470     //sctpad
       
   471     keyCount = iVirtualSctpad->KeyArray().Count();
       
   472     
       
   473     if ( iPermittedRanges == ERangeNumber )
       
   474         {
       
   475         for ( TInt i = 0; i < keyCount; i++ )
       
   476             {
       
   477             CVirtualKey* vk = iVirtualSctpad->KeyArray()[i];
       
   478             TInt pos = aNumMapping.Find( vk->KeyUnicodes() );
       
   479             vk->SetDimmed( pos == KErrNotFound );
       
   480             }
       
   481         }
       
   482     else
       
   483         {
       
   484         for ( TInt i = 0; i < keyCount; i++ )
       
   485             {
       
   486             CVirtualKey* vk = iVirtualSctpad->KeyArray()[i];
       
   487             vk->SetDimmed( EFalse );
       
   488             }        
       
   489         }
       
   490     
       
   491     //sync feedback
       
   492     UpdateAllVirtualKeysFeedback( CurrentCharRange() );
       
   493     }
       
   494 
       
   495 // ---------------------------------------------------------------------------
       
   496 // accept editor's input language.
       
   497 // ---------------------------------------------------------------------------
       
   498 //
       
   499 void CPeninputFingerHwrWnd::SetInputLanguage( const TInt aLanguageId )
       
   500     {
       
   501     // special punctuations
       
   502     const TInt KSpecialPuncPos[] = { 14, 15 };
       
   503     const TInt KSpecialChsPunc[] = { 0x300A, 0x300B };
       
   504     const TInt KSpecialChtPunc[] = { 0x300C, 0x300D };
       
   505 
       
   506     TBool isCht = ( ELangHongKongChinese == aLanguageId ) || 
       
   507                   ( ELangTaiwanChinese == aLanguageId );
       
   508     
       
   509     TInt specialPuncCount = sizeof(KSpecialPuncPos)/sizeof(TInt);
       
   510     
       
   511     
       
   512     for ( TInt i = 0; i < specialPuncCount; i++ )
       
   513         {
       
   514         TInt keypos = KSpecialPuncPos[i];        
       
   515         TInt charcode = isCht ? KSpecialChtPunc[i] : KSpecialChsPunc[i];
       
   516 
       
   517         CVirtualKey* vk = iVirtualSctpad->KeyArray()[keypos];
       
   518         if ( vk )
       
   519             {
       
   520             TBuf<1> buf;
       
   521             buf.Append( charcode );
       
   522             vk->SetKeyData( buf );
       
   523             vk->SetKeyScancode( charcode );
       
   524             }
       
   525         }
       
   526     }
       
   527 
       
   528 // ---------------------------------------------------------------------------
       
   529 // get strokes from hwr writing box.
       
   530 // ---------------------------------------------------------------------------
       
   531 //
       
   532 const RArray<TPoint>& CPeninputFingerHwrWnd::StrokeList()
       
   533     {
       
   534     return iWritingBox->StrokeList();
       
   535     }
       
   536 
       
   537 // ---------------------------------------------------------------------------
       
   538 // set end mark of hwr
       
   539 // ---------------------------------------------------------------------------
       
   540 //
       
   541 void CPeninputFingerHwrWnd::SetStrokeEndMark( const TPoint& aEndMark )
       
   542     {
       
   543     iWritingBox->SetStrokeEndMark( aEndMark );
       
   544     }
       
   545 
       
   546 // ---------------------------------------------------------------------------
       
   547 // set pen color of hwr writing.
       
   548 // ---------------------------------------------------------------------------
       
   549 //
       
   550 void CPeninputFingerHwrWnd::SetBoxPenColor( const TInt aPenColor )
       
   551     {
       
   552     iWritingBox->SetPenColor( aPenColor );
       
   553     }
       
   554     
       
   555 // ---------------------------------------------------------------------------
       
   556 // set pen size of hwr writing.
       
   557 // ---------------------------------------------------------------------------
       
   558 //  
       
   559 void CPeninputFingerHwrWnd::SetBoxPenSize( const TSize aPenSize )
       
   560     {
       
   561     iWritingBox->SetPenSize( aPenSize );
       
   562     }
       
   563 
       
   564 // ---------------------------------------------------------------------------
       
   565 // set writing speed hwr writing.
       
   566 // ---------------------------------------------------------------------------
       
   567 //
       
   568 void CPeninputFingerHwrWnd::SetBoxWritingSpeed( const TTimeIntervalMicroSeconds32& aCharDelay )
       
   569     {
       
   570     iWritingBox->SetCharacterDelay( aCharDelay );
       
   571     iWritingBox->SetStrokeDelay( 90000 );   
       
   572     }
       
   573 
       
   574 // ---------------------------------------------------------------------------
       
   575 // retrieve rect of hwr writingbox.
       
   576 // ---------------------------------------------------------------------------
       
   577 //
       
   578 TRect CPeninputFingerHwrWnd::WritingBoxRect()
       
   579     {
       
   580     return iWritingBox->Rect();
       
   581     }
       
   582 
       
   583 
       
   584 // ---------------------------------------------------------------------------
       
   585 // Cancel wrting
       
   586 // ---------------------------------------------------------------------------
       
   587 //
       
   588 void CPeninputFingerHwrWnd::CancelWriting()
       
   589     {
       
   590     iWritingBox->CancelCharWriting();
       
   591     }
       
   592 
       
   593 // ---------------------------------------------------------------------------
       
   594 // Popup ime switch list.
       
   595 // ---------------------------------------------------------------------------
       
   596 //
       
   597 void CPeninputFingerHwrWnd::PopupImeSwitcher()
       
   598     {
       
   599     TRAP_IGNORE( iInputModeSwitch->PopUpSwitchListL( iImeSwitchBtn->Rect() ) );
       
   600     }
       
   601 
       
   602 
       
   603 // ---------------------------------------------------------------------------
       
   604 // show range selection list.
       
   605 // ---------------------------------------------------------------------------
       
   606 //
       
   607 void CPeninputFingerHwrWnd::ShowRangeDropList( TInt aDirect )
       
   608     {
       
   609     iRangeSelector->SetCurRange( iCurCharRangeNoSct, iCurCharRange == iCurCharRangeNoSct );
       
   610     iRangeSelector->Popup( aDirect );
       
   611     }
       
   612 
       
   613 // ---------------------------------------------------------------------------
       
   614 // cancel range selection.
       
   615 // ---------------------------------------------------------------------------
       
   616 //
       
   617 void CPeninputFingerHwrWnd::CancelRangeDropList()
       
   618     {
       
   619     iRangeSelector->CancelPopup();
       
   620     
       
   621     UpdateArea( Rect(), EFalse );
       
   622     }
       
   623 
       
   624 // ---------------------------------------------------------------------------
       
   625 // test whether the range selection list is visible.
       
   626 // ---------------------------------------------------------------------------
       
   627 //
       
   628 TBool CPeninputFingerHwrWnd::RangeDropListVisible()
       
   629     {
       
   630     return iRangeSelector ? iRangeSelector->IsPopup() : EFalse;
       
   631     }
       
   632 
       
   633 
       
   634 // ---------------------------------------------------------------------------
       
   635 // Change SCT page.
       
   636 // ---------------------------------------------------------------------------
       
   637 //
       
   638 void CPeninputFingerHwrWnd::ShowSctPage( TInt aPageNo, TInt aPos )
       
   639     {
       
   640     switch ( aPos )
       
   641         {
       
   642         case EPagePosPageNo:
       
   643             {
       
   644             iVirtualSctpad->NavToPage( aPageNo );
       
   645             }
       
   646             break;
       
   647         default:
       
   648             break;
       
   649         }
       
   650     UpdateSctPageButtonsUi();
       
   651     UpdateAllVirtualKeysFeedback( EFingerHwrSymbolRange );
       
   652     }
       
   653 
       
   654 // ---------------------------------------------------------------------------
       
   655 // sync sct paging buttons.
       
   656 // ---------------------------------------------------------------------------
       
   657 //
       
   658 void CPeninputFingerHwrWnd::UpdateSctPageButtonsUi()
       
   659     {
       
   660     TInt curpage = iVirtualSctpad->CurPageIndex();
       
   661     TInt pagecount = iVirtualSctpad->PageCount();
       
   662     
       
   663     iSctPage0Btn->Hide( curpage != 0 );
       
   664     iSctPage1Btn->Hide( curpage != 1 );
       
   665     iSctPage2Btn->Hide( curpage != 2 );
       
   666     
       
   667     }
       
   668 
       
   669 // ---------------------------------------------------------------------------
       
   670 // retrieve the ICF control.
       
   671 // ---------------------------------------------------------------------------
       
   672 //
       
   673 CFepLayoutMultiLineIcf* CPeninputFingerHwrWnd::Icf()
       
   674     {
       
   675     return iContextField;
       
   676     }
       
   677 
       
   678 // ---------------------------------------------------------------------------
       
   679 // retrieve the predictive List control. 
       
   680 // ---------------------------------------------------------------------------
       
   681 //
       
   682 CFepCtrlDropdownList* CPeninputFingerHwrWnd::PredictiveList()
       
   683     {
       
   684     return iPredictList;
       
   685     }  
       
   686 
       
   687 // ---------------------------------------------------------------------------
       
   688 // retrieve the candicate list control.
       
   689 // ---------------------------------------------------------------------------
       
   690 //
       
   691 CFepCtrlDropdownList* CPeninputFingerHwrWnd::CandidateList()
       
   692     {
       
   693     return iCandidateList;
       
   694     }
       
   695 
       
   696 // ---------------------------------------------------------------------------
       
   697 // cancel all popped list.
       
   698 // ---------------------------------------------------------------------------
       
   699 //
       
   700 void CPeninputFingerHwrWnd::CancelAllPopList()
       
   701     {
       
   702     if ( iRangeSelector->IsPopup() )
       
   703         {
       
   704         iRangeSelector->CancelPopup();
       
   705         }    
       
   706     }
       
   707 
       
   708 // ---------------------------------------------------------------------------
       
   709 // Update layout
       
   710 // ---------------------------------------------------------------------------
       
   711 //
       
   712 void CPeninputFingerHwrWnd::UpdateLayout( const TBool aIsStandby, const TBool aReloadCandicate, const TBool aReloadPredictive )
       
   713     {
       
   714     TRAP_IGNORE( UpdateLayoutL( aIsStandby, aReloadCandicate, aReloadPredictive ) );
       
   715     }
       
   716 
       
   717 // ---------------------------------------------------------------------------
       
   718 // Update layout
       
   719 // ---------------------------------------------------------------------------
       
   720 //
       
   721 void CPeninputFingerHwrWnd::UpdateLayoutL( const TBool aIsStandby, 
       
   722     const TBool aReloadCandicate, const TBool aReloadPredictive )
       
   723     {
       
   724     // Set the candidates when dropdown list is shown
       
   725     if ( !aIsStandby )
       
   726         {
       
   727         typedef CFepCtrlDropdownList::TListType TDropListType;
       
   728         
       
   729         CPeninputFingerHwrLayout* hwrLayout = NULL;
       
   730         hwrLayout = static_cast<CPeninputFingerHwrLayout*>( UiLayout() );
       
   731         CPeninputFingerHwrDataStore& datastore = hwrLayout->DataStore();
       
   732         
       
   733         const RPointerArray<HBufC>& candidates = datastore.Candidate();
       
   734         const RPointerArray<HBufC>& predictives = datastore.Predictive();
       
   735         
       
   736         TDropListType expandable = CFepCtrlDropdownList::EListExpandableWithBubble;
       
   737         TDropListType unexpandable = CFepCtrlDropdownList::EListNoExpandableWithBubble;
       
   738         
       
   739         if ( datastore.PrimaryRange() == ERangeNative )
       
   740             {
       
   741             iCandidateList->Hide( EFalse );
       
   742             iPredictList->Hide( EFalse );
       
   743             
       
   744             if ( aReloadCandicate )
       
   745                 {
       
   746                 iCandidateList->SetCandidatesL( candidates, unexpandable );
       
   747                 }
       
   748             
       
   749             SetCandHighlightCell();
       
   750 
       
   751             // Re draw preview bubble after drawing highlight cell
       
   752             iCandidateList->ReDrawBubble();
       
   753             iPredictList->ReDrawBubble();
       
   754                
       
   755             if ( aReloadPredictive )
       
   756                 {
       
   757                 iPredictList->SetCandidatesL( predictives, expandable );
       
   758                 }
       
   759             }
       
   760         else if ( datastore.PrimaryRange() == ERangeEnglish )
       
   761             {
       
   762 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   763             iCandidateList->Hide(EFalse);
       
   764             iPredictList->Hide(EFalse);
       
   765             
       
   766             if ( aReloadCandicate )
       
   767                 {
       
   768                 iCandidateList->SetCandidatesL( candidates, unexpandable );
       
   769                 }
       
   770             
       
   771             if ( aReloadPredictive )
       
   772                 {
       
   773                 TBool canExpand = datastore.PredictiveCount() > KCandidateCount;
       
   774                 TDropListType type = canExpand ? expandable : unexpandable;
       
   775                 iPredictList->SetCandidatesL( predictives, type );
       
   776                 }
       
   777             
       
   778             SetCandHighlightCell();
       
   779                  
       
   780             // Re draw preview bubble after drawing highlight cell
       
   781             iCandidateList->ReDrawBubble();
       
   782             iPredictList->ReDrawBubble();
       
   783             
       
   784 #else
       
   785 
       
   786             if(!iCandidateList->Hiden() && !iPredictList->Hiden())
       
   787                 {
       
   788                 if ( aReloadPredictive )
       
   789                     {
       
   790                     iCandidateList->SetCandidatesL( candidates, unexpandable );
       
   791                     iPredictList->SetCandidatesL( predictives, unexpandable );
       
   792                     }
       
   793                 iPredictList->SetHighlightCell( 0 );  
       
   794                 
       
   795                 // Re draw preview bubble after drawing highlight cell
       
   796                 iCandidateList->ReDrawBubble();
       
   797                 iPredictList->ReDrawBubble();
       
   798                 }
       
   799             
       
   800             if(!iFixEngSymbolList1->Hiden() && !iFixEngSymbolList2->Hiden())
       
   801                 {
       
   802                 iFixEngSymbolList1->SetCandidatesL( candidates, unexpandable );
       
   803                 iFixEngSymbolList2->SetCandidatesL( predictives,unexpandable );              
       
   804                 }
       
   805 #endif            
       
   806             }
       
   807         }
       
   808     else
       
   809         {
       
   810         // hide all the dropdown list in standby state
       
   811         iCandidateList->Hide( ETrue );
       
   812         iPredictList->Hide( ETrue );
       
   813         
       
   814         //todo : fix EVWG-7U76JF, 2 lines
       
   815         iCandidateList->ClearBubble();
       
   816         iPredictList->ClearBubble();
       
   817         
       
   818 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
   819         iFixEngSymbolList1->Hide( ETrue );
       
   820         iFixEngSymbolList2->Hide( ETrue );
       
   821 #endif
       
   822 
       
   823         }            
       
   824     
       
   825     iArrowLeftBtn->Hide( !aIsStandby );
       
   826     iArrowRightBtn->Hide( !aIsStandby );
       
   827     iArrowUpBtn->Hide( !aIsStandby );
       
   828     iArrowDownBtn->Hide( !aIsStandby );
       
   829     
       
   830     iOptionBtn->Hide( !aIsStandby );
       
   831     iImeSwitchBtn->Hide( !aIsStandby );
       
   832     }
       
   833 
       
   834 // ---------------------------------------------------------------------------
       
   835 // Set highlight candidate cell when expand another list.
       
   836 // ---------------------------------------------------------------------------
       
   837 // 
       
   838 void CPeninputFingerHwrWnd::SetCandHighlightCell()
       
   839     {
       
   840     // if expand predictive list upward before charactor time out,
       
   841     // the candidate list will cover on expand predictive list.
       
   842     // To avoid this problem, add this function.
       
   843     CPeninputFingerHwrLayout* hwrLayout = NULL;
       
   844     hwrLayout = static_cast<CPeninputFingerHwrLayout*>( UiLayout() );
       
   845     CPeninputFingerHwrDataStore& datastore = hwrLayout->DataStore();    
       
   846     
       
   847     CFepUiBaseCtrl* capCtrl = RootControl()->CtrlCapPointer();
       
   848     
       
   849     if(!(capCtrl && capCtrl->ControlId() == EHwrCtrlIdPredictiveList && 
       
   850          iPredictList->CandExpandType() == CFepCtrlDropdownList::ECandExpandUpward)) 
       
   851         {
       
   852         // Set and draw highlight cell
       
   853         iCandidateList->SetHighlightCell( 0, datastore.Highlight() );
       
   854         }
       
   855     else
       
   856         {
       
   857         // Just set the highlight cell without draw
       
   858         iCandidateList->SetHighlightCell( 0, datastore.Highlight(), EFalse );
       
   859         }
       
   860     }
       
   861       
       
   862      
       
   863 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
   864 // ---------------------------------------------------------------------------
       
   865 // hide or show two eng-symbol candidate lists.
       
   866 // ---------------------------------------------------------------------------
       
   867 //
       
   868 void CPeninputFingerHwrWnd::HideTwoRowEngSymbolList( const TBool aIsHide )
       
   869     {
       
   870     iCandidateList->Hide( !aIsHide );
       
   871     iPredictList->Hide( !aIsHide );
       
   872     iFixEngSymbolList1->Hide( aIsHide );
       
   873     iFixEngSymbolList2->Hide( aIsHide );
       
   874     }
       
   875 #endif
       
   876 
       
   877 // ---------------------------------------------------------------------------
       
   878 // dim arrow buttons.
       
   879 // ---------------------------------------------------------------------------
       
   880 //
       
   881 void CPeninputFingerHwrWnd::DimArrowKeys( TBool aDimArrow )
       
   882    {
       
   883    iArrowLeftBtn->SetDimmed( aDimArrow );   
       
   884    iArrowRightBtn->SetDimmed( aDimArrow );   
       
   885    iArrowUpBtn->SetDimmed( aDimArrow );   
       
   886    iArrowDownBtn->SetDimmed( aDimArrow ); 
       
   887    }
       
   888 
       
   889 // ---------------------------------------------------------------------------
       
   890 // change layout to specified char range.
       
   891 // ---------------------------------------------------------------------------
       
   892 //
       
   893 void CPeninputFingerHwrWnd::TryToChangeCharRange( TInt aCharRange )
       
   894     {
       
   895     //CancelPopup must be called before LayoutStandby????
       
   896     //if not, pointer is captured, unregister feedback area will failed.
       
   897     if ( iRangeSelector->IsPopup() )
       
   898         {
       
   899         iRangeSelector->CancelPopup();
       
   900         }
       
   901     
       
   902     if ( iCurCharRange != aCharRange )
       
   903         {
       
   904         switch ( aCharRange )
       
   905             {
       
   906             case EFingerHwrNativeRange:
       
   907                 {
       
   908                 iCurCharRange = EFingerHwrNativeRange;
       
   909                 iCurCharRangeNoSct = EFingerHwrNativeRange;
       
   910                 LayoutStandbyChinese();
       
   911                 }
       
   912                 break;
       
   913             case EFingerHwrEnglishRange:
       
   914                 {
       
   915                 iCurCharRange = EFingerHwrEnglishRange;
       
   916                 iCurCharRangeNoSct = EFingerHwrEnglishRange;
       
   917                 LayoutStandbyEnglish();
       
   918                 }
       
   919                 break;
       
   920             case EFingerHwrNumberRange:
       
   921                 {
       
   922                 iCurCharRange = EFingerHwrNumberRange;
       
   923                 iCurCharRangeNoSct = EFingerHwrNumberRange;
       
   924                 LayoutStandbyNumeric();
       
   925                 }
       
   926                 break;
       
   927             case EFingerHwrSymbolRange:
       
   928                 {
       
   929                 iCurCharRange = EFingerHwrSymbolRange;
       
   930                 LayoutStandbySymbol();
       
   931                 }
       
   932                 break; 
       
   933             default:
       
   934                 break;
       
   935             }
       
   936         TRAP_IGNORE(ReloadWritingGuideLinesL());
       
   937         }
       
   938 
       
   939     iRangeSelector->SetCurRange( iCurCharRangeNoSct, iCurCharRange == iCurCharRangeNoSct );
       
   940     }
       
   941 
       
   942 // ---------------------------------------------------------------------------
       
   943 // retrieve char range of layout, including sct.
       
   944 // ---------------------------------------------------------------------------
       
   945 //
       
   946 TInt CPeninputFingerHwrWnd::CurrentCharRange()
       
   947     {
       
   948     return iCurCharRange;
       
   949     }
       
   950 
       
   951 // ---------------------------------------------------------------------------
       
   952 // restore the char range saved before sct.
       
   953 // ---------------------------------------------------------------------------
       
   954 //
       
   955 TInt CPeninputFingerHwrWnd::RestoreNonSctLayout()
       
   956     {
       
   957     TInt rangeFlag = ERangeInvalid;
       
   958     
       
   959     switch ( iCurCharRangeNoSct )
       
   960         {
       
   961         case EFingerHwrNativeRange:
       
   962             {
       
   963             rangeFlag = ERangeNative;
       
   964             }
       
   965             break;
       
   966         case EFingerHwrEnglishRange:
       
   967             {
       
   968             rangeFlag = ERangeEnglish;
       
   969             }
       
   970             break;
       
   971         case EFingerHwrNumberRange:
       
   972             {
       
   973             rangeFlag = ERangeNumber;
       
   974             }
       
   975             break;
       
   976         default:
       
   977             {
       
   978             rangeFlag = ERangeInvalid;
       
   979             }
       
   980             break;
       
   981         }
       
   982     TryToChangeCharRange( iCurCharRangeNoSct );
       
   983     return rangeFlag;
       
   984     }
       
   985 
       
   986 // ---------------------------------------------------------------------------
       
   987 // c++ constructor
       
   988 // ---------------------------------------------------------------------------
       
   989 //
       
   990 CPeninputFingerHwrWnd::CPeninputFingerHwrWnd( 
       
   991     CFepUiLayout* aFepUiLayout, TInt aControlId )
       
   992     : CControlGroup( aFepUiLayout,aControlId ), iFirstTimeConstruct( ETrue )
       
   993     {
       
   994     iInEditWordQueryDlg = EFalse;
       
   995     }
       
   996     
       
   997 // ---------------------------------------------------------------------------
       
   998 // Symbian second-phase constructor
       
   999 // ---------------------------------------------------------------------------
       
  1000 //
       
  1001 void CPeninputFingerHwrWnd::ConstructL( TBool /*aLandscapeStyle*/ )
       
  1002     {
       
  1003     BaseConstructL();    
       
  1004     
       
  1005     iLafManager = CPeninputFingerHwrLAFManager::NewL();
       
  1006     iLafManager->ReadLafInfo();
       
  1007     
       
  1008     //crate writing 
       
  1009     CreateWritingBoxL();
       
  1010     
       
  1011     //create icf 
       
  1012     CreateContextFieldL();
       
  1013     
       
  1014     //create candidate lists
       
  1015     CreateCandidateListL();
       
  1016     
       
  1017     //create predictive lists
       
  1018     CreatePredictListL();
       
  1019     
       
  1020     //create virtual num pad
       
  1021     CreateVirtualNumpadL();
       
  1022     
       
  1023     //create virtual sct pad
       
  1024     CreateVirtualSctpadL();
       
  1025     
       
  1026     //create space and backspace virtual pad
       
  1027     CreateFixVirtualSctpadL();
       
  1028 
       
  1029     //create control buttons
       
  1030     CreateButtonsL();
       
  1031     
       
  1032     //create range selecor
       
  1033     iRangeSelector = CPeninputFingerHwrRangeSelector::NewL( 
       
  1034         UiLayout(), EHwrCtrlIdRangeSelector );
       
  1035     AddControlL( iRangeSelector );
       
  1036     
       
  1037     //create ime selector
       
  1038     iInputModeSwitch = CPeninputLayoutInputmodelChoice::NewL( 
       
  1039         UiLayout(), EHwrCtrlIdInputModeSwitcher, 
       
  1040         EPluginInputModeFingerHwr );
       
  1041     
       
  1042     iInputModeSwitch->SetListSkinID( KAknsIIDQsnFrList, KAknsIIDQsnFrPopupSub );
       
  1043     UiLayout()->AddControlL( iInputModeSwitch );
       
  1044     iInputModeSwitch->AddEventObserver( UiLayout() );    
       
  1045     
       
  1046     iCurCharRangeNoSct = EFingerHwrNativeRange;
       
  1047     iCurCharRange      = EFingerHwrNativeRange;
       
  1048     ResetLayoutL();
       
  1049     
       
  1050     LayoutStandbyChinese();
       
  1051     }
       
  1052     
       
  1053 // ---------------------------------------------------------------------------
       
  1054 // create icf.
       
  1055 // ---------------------------------------------------------------------------
       
  1056 //
       
  1057 void CPeninputFingerHwrWnd::CreateContextFieldL()
       
  1058     {
       
  1059     const CFont* icffont =iLafManager->IcfFont(); 
       
  1060     
       
  1061     iContextField = CFepLayoutMultiLineIcf::NewL( 
       
  1062         iLafManager->IcfRect(), 
       
  1063         UiLayout(), 
       
  1064         EHwrCtrlIdInputContextField, 
       
  1065         icffont->HeightInPixels(),
       
  1066         icffont->FontMaxHeight(),
       
  1067         icffont );
       
  1068 
       
  1069     iContextField->SetTextMargin ( iLafManager->IcfLeftMargin(),
       
  1070                       iLafManager->IcfRightMargin(),
       
  1071                       iLafManager->IcfTopMargin(),
       
  1072                       iLafManager->IcfBottomMargin() );
       
  1073                       
       
  1074     iContextField->SetLineSpace( iLafManager->IcfLineSpaceMargin() );                         
       
  1075  
       
  1076     iContextField->SizeChangedL( iLafManager->IcfRect(), 
       
  1077                       iLafManager->IcfTextHeight(),
       
  1078                       iLafManager->IcfFont()->FontMaxHeight(),
       
  1079                       iLafManager->IcfFont() );
       
  1080 
       
  1081     TAknWindowLineLayout bubbleLineLayout = AknLayoutScalable_Apps::popup_char_count_window().LayoutLine();
       
  1082     TAknTextLineLayout bubbleTextLayout = AknLayoutScalable_Apps::popup_char_count_window_t1( 0 ).LayoutLine();
       
  1083     
       
  1084     iContextField->MsgBubbleCtrl()->SetTextFormat( bubbleTextLayout );
       
  1085     iContextField->MsgBubbleCtrl()->SetTextColorIndex( EAknsCIQsnTextColorsCG67 );
       
  1086     //Change the ID when ID into release
       
  1087     iContextField->MsgBubbleCtrl()->SetBitmapParam( NULL,
       
  1088                                           NULL,
       
  1089                                           KAknsIIDQsnFrInputPreviewSideL,
       
  1090                                           KAknsIIDQsnFrInputPreviewMiddle,
       
  1091                                           KAknsIIDQsnFrInputPreviewSideR );  
       
  1092     iContextField->SetMsgBubbleCtrlSize( TSize( bubbleLineLayout.iW,bubbleLineLayout.iH ) );    
       
  1093     
       
  1094 
       
  1095     //transfer to headerPane
       
  1096     AddControlL( iContextField );
       
  1097     
       
  1098     //add layout as event observer
       
  1099     iContextField->AddEventObserver( UiLayout() );
       
  1100     iContextField->SetFocus();
       
  1101 
       
  1102     }
       
  1103 
       
  1104 // ---------------------------------------------------------------------------
       
  1105 // create candidate lists.
       
  1106 // ---------------------------------------------------------------------------
       
  1107 //
       
  1108 void CPeninputFingerHwrWnd::CreateCandidateListL()
       
  1109     {  
       
  1110     TDropdownListDrawInfo candiDrawInfo( 
       
  1111             KAknsIIDQsnFrFunctionButtonInactive, 
       
  1112             KAknsIIDQsnFrFunctionButtonNormal,
       
  1113             KAknsIIDQsnFrFunctionButtonPressed,
       
  1114             KAknsIIDQsnFrItutButtonCandiSideL,
       
  1115             KAknsIIDQsnFrItutButtonCandiMiddle,
       
  1116             KAknsIIDQsnFrItutButtonCandiSideR,
       
  1117             KAknsIIDQsnFrItutButtonCandiPressedSideL,
       
  1118             KAknsIIDQsnFrItutButtonCandiPressedMiddle,
       
  1119             KAknsIIDQsnFrItutButtonCandiPressedSideR,
       
  1120             TRgb( 194, 221, 242 ),
       
  1121             ETrue );
       
  1122 
       
  1123     TInt unitWidth = iLafManager->CandidateUnitWidth();
       
  1124     TInt unitHeight = iLafManager->CandidateUnitHeight();
       
  1125     TPoint ltPosition = iLafManager->CandidateLTPos();
       
  1126     iCandidateList = CFepCtrlDropdownList::NewL( UiLayout(),
       
  1127             EHwrCtrlIdCandidateList, 
       
  1128             R_FSHWR_CANDIDATE_DROP_DOWN_LIST, ltPosition, 
       
  1129             TSize(unitWidth, unitHeight), KCandidateCountPerRow, 1 );  
       
  1130             
       
  1131     AddControlL( iCandidateList );
       
  1132 
       
  1133     const CFont *font = iLafManager->CandidateFont();
       
  1134     TInt horizontalMargin = iLafManager->CandidateHorizontalMargin();
       
  1135     TInt verticalMargin = iLafManager->CandidateVerticalMargin();
       
  1136     iCandidateList->SetCellMargin( horizontalMargin, verticalMargin );
       
  1137     iCandidateList->SetFont( font );
       
  1138     
       
  1139     // set the needed events
       
  1140     iCandidateList->SetEventIdForCandidateSelected( EHwrEventCandidateSelected );
       
  1141     iCandidateList->AddEventObserver( UiLayout() );
       
  1142     
       
  1143     // hide the candidate list
       
  1144     iCandidateList->Hide( ETrue );
       
  1145     iCandidateList->SetDropdownListImgID( candiDrawInfo );
       
  1146     
       
  1147 
       
  1148 #ifndef RD_INTELLIGENT_TEXT_INPUT    
       
  1149     iFixEngSymbolList1 = CFepCtrlDropdownList::NewL( UiLayout(),
       
  1150                                                  EHwrCtrlIdFixEngSymbolList,
       
  1151                                                  R_FSHWR_CANDIDATE_DROP_DOWN_LIST,
       
  1152                                                  ltPosition,
       
  1153                                                  TSize( unitWidth, unitHeight ),
       
  1154                                                  KCandidateCountPerRow,
       
  1155                                                  1 );
       
  1156     
       
  1157     AddControlL( iFixEngSymbolList1 );
       
  1158     
       
  1159     iFixEngSymbolList1->SetCellMargin( horizontalMargin, verticalMargin );
       
  1160     iFixEngSymbolList1->SetFont( font );
       
  1161     iFixEngSymbolList1->SetEventIdForCandidateSelected( EHwrEventCandidateSelected );
       
  1162     iFixEngSymbolList1->AddEventObserver( UiLayout() );
       
  1163     
       
  1164     // hide the candidate list
       
  1165     iFixEngSymbolList1->Hide( ETrue );
       
  1166     iFixEngSymbolList1->SetDropdownListImgID( candiDrawInfo );
       
  1167     
       
  1168 #endif
       
  1169     }
       
  1170 
       
  1171 // ---------------------------------------------------------------------------
       
  1172 // create predictive lists.
       
  1173 // ---------------------------------------------------------------------------
       
  1174 //
       
  1175 void CPeninputFingerHwrWnd::CreatePredictListL()
       
  1176     {                                       
       
  1177     TDropdownListDrawInfo predicDrawInfo( 
       
  1178             KAknsIIDQsnFrFunctionButtonInactive, 
       
  1179             KAknsIIDQsnFrFunctionButtonNormal,
       
  1180             KAknsIIDQsnFrFunctionButtonPressed,
       
  1181             KAknsIIDQsnFrItutButtonComposeSideL,
       
  1182             KAknsIIDQsnFrItutButtonComposeMiddle,
       
  1183             KAknsIIDQsnFrItutButtonComposeSideR,
       
  1184             KAknsIIDQsnFrItutButtonComposePressedSideL,
       
  1185             KAknsIIDQsnFrItutButtonComposePressedSideR,
       
  1186             KAknsIIDQsnFrItutButtonComposePressedMiddle,
       
  1187             TRgb( 194, 221, 242 ),
       
  1188             ETrue );     
       
  1189 
       
  1190     TInt unitWidth = iLafManager->CandidateUnitWidth();
       
  1191     TInt unitHeight = iLafManager->CandidateUnitHeight();
       
  1192     TPoint ltPosition = iLafManager->PredictiveLTPos();
       
  1193     iPredictList = CFepCtrlDropdownList::NewL( UiLayout(),
       
  1194                                                EHwrCtrlIdPredictiveList,
       
  1195                                                R_FSHWR_PREDICT_DROP_DOWN_LIST,
       
  1196                                                ltPosition,
       
  1197                                                TSize( unitWidth, unitHeight ),
       
  1198                                                KPredictiveCountPerRow,
       
  1199                                                KPredictiveRowCount );  
       
  1200   
       
  1201     if ( iLafManager->IsLandscape() )
       
  1202         {
       
  1203         iPredictList->SetCandExpandType( CFepCtrlDropdownList::ECandExpandUpward );
       
  1204         }
       
  1205           
       
  1206     AddControlL( iPredictList );
       
  1207     
       
  1208     const CFont *font = iLafManager->CandidateFont();
       
  1209     TInt horizontalMargin = iLafManager->CandidateHorizontalMargin();
       
  1210     TInt verticalMargin = iLafManager->CandidateVerticalMargin();
       
  1211     iPredictList->SetCellMargin( horizontalMargin, verticalMargin );
       
  1212     iPredictList->SetFont( font );
       
  1213     
       
  1214     // set the needed events
       
  1215     iPredictList->SetEventIdForCandidateSelected( EHwrEventPredictiveSelected );
       
  1216     iPredictList->SetEventIdForNextPageCandidate( EHwrEventGetNextCandidatePage );
       
  1217     iPredictList->AddEventObserver( UiLayout() );
       
  1218     
       
  1219     // hide the predictive list
       
  1220     iPredictList->Hide( ETrue );
       
  1221     iPredictList->SetDropdownListImgID( predicDrawInfo );
       
  1222     
       
  1223     
       
  1224 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  1225     TDropdownListDrawInfo candiDrawInfo( 
       
  1226             KAknsIIDQsnFrFunctionButtonInactive, 
       
  1227             KAknsIIDQsnFrFunctionButtonNormal,
       
  1228             KAknsIIDQsnFrFunctionButtonPressed,
       
  1229             KAknsIIDQsnFrItutButtonCandiSideL,
       
  1230             KAknsIIDQsnFrItutButtonCandiMiddle,
       
  1231             KAknsIIDQsnFrItutButtonCandiSideR,
       
  1232             KAknsIIDQsnFrItutButtonCandiPressedSideL,
       
  1233             KAknsIIDQsnFrItutButtonCandiPressedMiddle,
       
  1234             KAknsIIDQsnFrItutButtonCandiPressedSideR,
       
  1235             TRgb( 194, 221, 242 ),
       
  1236             ETrue );
       
  1237     
       
  1238     iFixEngSymbolList2 = CFepCtrlDropdownList::NewL( UiLayout(),
       
  1239                                                  EHwrCtrlIdFixEngSymbolList,
       
  1240                                                  R_FSHWR_CANDIDATE_DROP_DOWN_LIST,
       
  1241                                                  ltPosition,
       
  1242                                                  TSize( unitWidth, unitHeight ),
       
  1243                                                  KCandidateCountPerRow,
       
  1244                                                  1 );
       
  1245     
       
  1246     AddControlL( iFixEngSymbolList2 );
       
  1247     
       
  1248     iFixEngSymbolList2->SetCellMargin( horizontalMargin, verticalMargin );
       
  1249     iFixEngSymbolList2->SetFont( font );
       
  1250     iFixEngSymbolList2->SetEventIdForCandidateSelected( EHwrEventCandidateSelected );
       
  1251     iFixEngSymbolList2->AddEventObserver( UiLayout() );
       
  1252     
       
  1253     // hide the candidate list
       
  1254     iFixEngSymbolList2->Hide( ETrue );
       
  1255     iFixEngSymbolList2->SetDropdownListImgID( candiDrawInfo );
       
  1256 #endif  
       
  1257     }
       
  1258     
       
  1259 // ---------------------------------------------------------------------------
       
  1260 // create writing box.
       
  1261 // ---------------------------------------------------------------------------
       
  1262 //
       
  1263 void CPeninputFingerHwrWnd::CreateWritingBoxL()
       
  1264     {
       
  1265     iWritingBox = CTransparentHwrWnd::NewL( TRect( 0,0,0,0 ), UiLayout(), 
       
  1266                                             EHwrCtrlIdWritingBox, EFalse );
       
  1267     
       
  1268     AddControlL( iWritingBox );
       
  1269     
       
  1270     
       
  1271     //set it to window
       
  1272     iWritingBox->SetStrokeEndMark( TPoint( -1,0 ) );
       
  1273     iWritingBox->AddEventObserver( UiLayout() );
       
  1274     iWritingBox->EnableTraceOutsideWindow( EFalse );
       
  1275     iWritingBox->SetWndTransparencyFactor( 0 );
       
  1276 
       
  1277     iWritingBox->InstallPenTraceDecoratorL( KNullDesC );
       
  1278     }
       
  1279 
       
  1280 // ---------------------------------------------------------------------------
       
  1281 // create all function buttons.
       
  1282 // ---------------------------------------------------------------------------
       
  1283 //
       
  1284 void CPeninputFingerHwrWnd::CreateButtonsL()
       
  1285     {
       
  1286     iCloseBtn = CreateEventBtnL( EHwrCtrlIdClose, R_AKN_FEP_HWR_CLOSE );
       
  1287     iOptionBtn = CreateEventBtnL( EHwrCtrlIdLanguageOption, R_AKN_FEP_HWR_OPTION );
       
  1288     iImeSwitchBtn = CreateEventBtnL( EHwrCtrlIdVkbSwitcher, R_AKN_FEP_HWR_VKB );
       
  1289     
       
  1290     iBackspaceBtn = CreateRepBtnL( EHwrCtrlIdBackspace, R_AKN_FEP_HWR_BACK_SPACE, 
       
  1291         EHwrEventKeyBack, EKeyBackspace );
       
  1292     iArrowLeftBtn = CreateRepBtnL( EHwrCtrlIdArrowLeft, R_AKN_FEP_HWR_ARROWLEFT, 
       
  1293         EHwrEventNavKeyClicked, EKeyLeftArrow );
       
  1294     iArrowRightBtn = CreateRepBtnL( EHwrCtrlIdArrowRight, R_AKN_FEP_HWR_ARROWRIGHT, 
       
  1295         EHwrEventNavKeyClicked, EKeyRightArrow );
       
  1296     iArrowUpBtn = CreateRepBtnL( EHwrCtrlIdArrowUp, R_AKN_FEP_HWR_ARROWUP, 
       
  1297         EHwrEventNavKeyClicked, EKeyUpArrow );
       
  1298     iArrowDownBtn = CreateRepBtnL( EHwrCtrlIdArrowDown, R_AKN_FEP_HWR_ARROWDOWN, 
       
  1299         EHwrEventNavKeyClicked, EKeyDownArrow );
       
  1300     
       
  1301     iRangeSpecialBtn = CreateEventBtnL( EHwrCtrlIdSymbolButton, R_AKN_FEP_HWR_RANGE_SPECIAL );
       
  1302     
       
  1303     iSctPage0Btn  = CreateEventBtnL( EHwrCtrlIdSctPage0Btn, R_AKN_FEP_HWR_SCT_PAGE_1 );
       
  1304     iSctPage1Btn  = CreateEventBtnL( EHwrCtrlIdSctPage1Btn, R_AKN_FEP_HWR_SCT_PAGE_2 );
       
  1305     iSctPage2Btn  = CreateEventBtnL( EHwrCtrlIdSctPage2Btn, R_AKN_FEP_HWR_SCT_PAGE_3 );
       
  1306     }
       
  1307 
       
  1308 // ---------------------------------------------------------------------------
       
  1309 // create virtual number pad.
       
  1310 // ---------------------------------------------------------------------------
       
  1311 //
       
  1312 void CPeninputFingerHwrWnd::CreateVirtualNumpadL()
       
  1313     {
       
  1314     TFontSpec spec;
       
  1315 
       
  1316     iVirtualNumpad = CVirtualKeyboard::NewL( 
       
  1317         TRect( 0,0,0,0 ),
       
  1318         UiLayout(),
       
  1319         EHwrCtrlIdNumpad,
       
  1320         spec );
       
  1321     AddControlL( iVirtualNumpad );
       
  1322     iVirtualNumpad->AddEventObserver( UiLayout() );
       
  1323 
       
  1324     iVirtualNumpad->SetResourceId( KInvalidResId );
       
  1325     
       
  1326     // read keypad image info
       
  1327     TSize keysize = iLafManager->VirtualNumpadCellSize().Size();
       
  1328     
       
  1329     
       
  1330     LoadVkbKeyImageL( iVirtualNumpad, R_FINGER_HWR_NUMPAD_IMAGE, keysize );
       
  1331     
       
  1332     RArray<TRect> rects;
       
  1333     CleanupClosePushL( rects );
       
  1334     
       
  1335     iLafManager->GetVirtualKeyRects( rects );
       
  1336     LoadVirtualNumpadKeysL( R_FINGER_HWR_NUMPAD, rects );
       
  1337     
       
  1338     CleanupStack::PopAndDestroy(); //rects
       
  1339     
       
  1340     iVirtualNumpad->SetKeyTextColorGroup( EAknsCIQsnTextColorsCG68 );
       
  1341     iVirtualNumpad->SetDrawOpaqueBackground( EFalse );
       
  1342     }
       
  1343 
       
  1344 // ---------------------------------------------------------------------------
       
  1345 // create virtual sct pad.
       
  1346 // ---------------------------------------------------------------------------
       
  1347 //
       
  1348 void CPeninputFingerHwrWnd::CreateVirtualSctpadL()
       
  1349     {
       
  1350     TFontSpec spec;
       
  1351 
       
  1352     iVirtualSctpad = CMultiPageVirtualKeyboard::NewL( 
       
  1353         iLafManager->CtrlRect(EHwrCtrlIdSctpad),
       
  1354         UiLayout(),
       
  1355         EHwrCtrlIdSctpad,
       
  1356         spec );
       
  1357     AddControlL( iVirtualSctpad );
       
  1358     iVirtualSctpad->AddEventObserver( UiLayout() );
       
  1359     
       
  1360     iVirtualSctpad->SetResourceId( KInvalidResId );
       
  1361     
       
  1362     // read keypad image info
       
  1363     TSize keysize = iLafManager->VirtualSctpadCellSize().Size();
       
  1364 
       
  1365     LoadVkbKeyImageL( iVirtualSctpad, R_FINGER_HWR_SCTPAD_IMAGE, keysize );
       
  1366     
       
  1367     RArray<TRect> rects;
       
  1368     CleanupClosePushL( rects );
       
  1369     
       
  1370     iLafManager->GetVirtualKeyRects( rects );
       
  1371     LoadVirtualSctpadKeysL( R_FINGER_HWR_SCTPAD, rects );
       
  1372     
       
  1373     CleanupStack::PopAndDestroy();//rects
       
  1374     
       
  1375     TInt rows = iLafManager->VirtualSctpadRowCount();
       
  1376     TInt cols = iLafManager->VirtualSctpadColCount();
       
  1377     iVirtualSctpad->UpdatePaging( rows, cols );
       
  1378     
       
  1379     iVirtualSctpad->SetKeyTextColorGroup( EAknsCIQsnTextColorsCG68 );
       
  1380     iVirtualSctpad->SetDrawOpaqueBackground( EFalse );    
       
  1381     }
       
  1382 
       
  1383 
       
  1384 // ---------------------------------------------------------------------------
       
  1385 // create virtual sct pad.
       
  1386 // ---------------------------------------------------------------------------
       
  1387 //
       
  1388 void CPeninputFingerHwrWnd::CreateFixVirtualSctpadL()
       
  1389     {
       
  1390     TFontSpec spec;
       
  1391 
       
  1392     iVirtualSctpadFix = CVirtualKeyboard::NewL( 
       
  1393         iLafManager->CtrlRect(EHwrCtrlIdSctpadFix),
       
  1394         UiLayout(),
       
  1395         EHwrCtrlIdSctpadFix,
       
  1396         spec );
       
  1397     AddControlL( iVirtualSctpadFix );
       
  1398     iVirtualSctpadFix->AddEventObserver( UiLayout() );
       
  1399     
       
  1400     iVirtualSctpadFix->SetResourceId( KInvalidResId );
       
  1401     
       
  1402     // read keypad image info
       
  1403     TSize keysize = iLafManager->FixVirtualSctpadCellSize().Size();
       
  1404 
       
  1405     LoadVkbKeyImageL( iVirtualSctpadFix, R_FINGER_HWR_SCTPAD_IMAGE, keysize );
       
  1406     
       
  1407     RArray<TRect> rects;
       
  1408     CleanupClosePushL( rects );
       
  1409     
       
  1410     iLafManager->GetFixVirtualKeyRects( rects );
       
  1411     LoadFixVirtualSctpadKeysL( R_FINGER_HWR_SCTPAD_FIX, rects );
       
  1412     
       
  1413     CleanupStack::PopAndDestroy();//rects
       
  1414     
       
  1415     iVirtualSctpadFix->SetKeyTextColorGroup( EAknsCIQsnTextColorsCG68 );
       
  1416     iVirtualSctpadFix->SetDrawOpaqueBackground( EFalse );    
       
  1417     }
       
  1418 
       
  1419 // ---------------------------------------------------------------------------
       
  1420 // EventButton creation helper.
       
  1421 // ---------------------------------------------------------------------------
       
  1422 //
       
  1423 CAknFepCtrlEventButton* CPeninputFingerHwrWnd::CreateEventBtnL( TInt aCtrlId, 
       
  1424     TInt32 aResId, TInt aEvent/*= 0xFFFF*/,TInt aUnicode/*=0*/ )
       
  1425     {
       
  1426     CAknFepCtrlEventButton* button = CAknFepCtrlEventButton::NewL( 
       
  1427         UiLayout(), aCtrlId, aEvent, aUnicode,
       
  1428         KAknsIIDQsnFrFunctionButtonNormal,
       
  1429         KAknsIIDQsnFrFunctionButtonPressed,
       
  1430         KAknsIIDQsnFrFunctionButtonInactive );
       
  1431     
       
  1432     button->SetResourceId( aResId );
       
  1433     button->ConstructFromResourceL();
       
  1434     button->AddEventObserver( UiLayout() );        
       
  1435     AddControlL( button );
       
  1436     return button;
       
  1437     }
       
  1438 
       
  1439 // ---------------------------------------------------------------------------
       
  1440 // RepeatButton creation helper.
       
  1441 // ---------------------------------------------------------------------------
       
  1442 //
       
  1443 CAknFepCtrlRepeatButton* CPeninputFingerHwrWnd::CreateRepBtnL( const TInt aCtrlId, 
       
  1444     TInt32 aResId, const TInt aEvent, const TInt aUnicode )
       
  1445     {
       
  1446     CAknFepCtrlRepeatButton* button = CAknFepCtrlRepeatButton::NewL( 
       
  1447         UiLayout(), aCtrlId, aEvent, aUnicode,
       
  1448         KAknsIIDQsnFrFunctionButtonNormal,
       
  1449         KAknsIIDQsnFrFunctionButtonPressed,
       
  1450         KAknsIIDQsnFrFunctionButtonInactive );
       
  1451     
       
  1452     button->SetResourceId( aResId );
       
  1453     button->ConstructFromResourceL( );
       
  1454     button->AddEventObserver( UiLayout() );
       
  1455     AddControlL( button );
       
  1456     
       
  1457     return button;
       
  1458     }
       
  1459 
       
  1460 // ---------------------------------------------------------------------------
       
  1461 // load virtual number pad images. 
       
  1462 // ---------------------------------------------------------------------------
       
  1463 //
       
  1464 void CPeninputFingerHwrWnd::LoadVkbKeyImageL( CVirtualKeyboard* aVkb, 
       
  1465     TInt aResId, const TSize& aKeySize )
       
  1466     {
       
  1467     TResourceReader reader;    
       
  1468     CCoeEnv::Static()->CreateResourceReaderLC( reader, aResId );      
       
  1469     
       
  1470     TPtrC bmpFileName = reader.ReadTPtrC();
       
  1471     TInt32 imgMajorSkinId = reader.ReadInt32();
       
  1472     TAknsItemID id;
       
  1473     
       
  1474     TSize keySize = aKeySize;
       
  1475     
       
  1476     for ( TInt index = 0; index <= EKeyBmpLastType ; index += 2 )
       
  1477         { 
       
  1478         // Get the image ids and mask ids from resource
       
  1479         TInt bmpId = reader.ReadInt16(); 
       
  1480         TInt bmpMskId = reader.ReadInt16();
       
  1481         
       
  1482         // read skin item id
       
  1483         const TInt skinitemid = reader.ReadInt16();
       
  1484         id.Set( TInt( imgMajorSkinId ), skinitemid );
       
  1485         
       
  1486         if ( bmpId != KInvalidImg )
       
  1487             {
       
  1488             CFbsBitmap* bmp = NULL;
       
  1489             CFbsBitmap* maskbmp = NULL;
       
  1490 
       
  1491             if ( bmpMskId != KInvalidImg )
       
  1492                 {
       
  1493                 AknsUtils::CreateIconL( AknsUtils::SkinInstance(),
       
  1494                    id, bmp, maskbmp, bmpFileName, bmpId, bmpMskId );
       
  1495                 
       
  1496                 // set maskbmp and size
       
  1497                 AknIconUtils::SetSize( maskbmp, keySize, EAspectRatioNotPreserved );
       
  1498                 aVkb->SetNonIrregularKeyBitmapL( 
       
  1499                         TVirtualKeyBmpType( EKeyBmpNormal + index + 1 ), maskbmp );
       
  1500                 }
       
  1501             else
       
  1502                 {
       
  1503                 AknsUtils::CreateIconL( AknsUtils::SkinInstance(), id, 
       
  1504                     bmp, bmpFileName, bmpId );
       
  1505                 }
       
  1506             // set bmp and size
       
  1507             AknIconUtils::SetSize( bmp, keySize, EAspectRatioNotPreserved );
       
  1508             aVkb->SetNonIrregularKeyBitmapL( 
       
  1509                 TVirtualKeyBmpType( EKeyBmpNormal + index ), bmp );
       
  1510             }       
       
  1511         }
       
  1512     // Pop and destroy reader
       
  1513     CleanupStack::PopAndDestroy( 1 );           
       
  1514     }
       
  1515 
       
  1516 
       
  1517 // ---------------------------------------------------------------------------
       
  1518 // create virtual key.
       
  1519 // ---------------------------------------------------------------------------
       
  1520 //
       
  1521 CVirtualKey* CPeninputFingerHwrWnd::CreateVkbKeyL( TResourceReader& aReader, 
       
  1522     const TRect aKeyRect )
       
  1523     {
       
  1524     CHBufCArray* keytexts = CHBufCArray::NewL();
       
  1525     CleanupStack::PushL( keytexts );
       
  1526     
       
  1527     for ( TInt i = 0; i <= EPosLast; i++ )
       
  1528         {
       
  1529         HBufC* unicode = aReader.ReadHBufCL();
       
  1530         keytexts->Array().AppendL( unicode );
       
  1531         }
       
  1532 
       
  1533     TInt keyscancode = aReader.ReadInt16();
       
  1534 
       
  1535     HBufC* text = keytexts->Array()[0];
       
  1536     
       
  1537     CVirtualKey* vk = NULL;
       
  1538     if ( text )
       
  1539         {
       
  1540         vk = CVirtualKey::NewL( *text, keyscancode, aKeyRect, aKeyRect, 0 );
       
  1541         }
       
  1542     else 
       
  1543         {
       
  1544         vk = CVirtualKey::NewL( KNullDesC, keyscancode, aKeyRect, aKeyRect, 0 );
       
  1545         }
       
  1546 
       
  1547     CleanupStack::PopAndDestroy( keytexts ); //keytexts
       
  1548 
       
  1549 
       
  1550     TRect innerrect = aKeyRect;
       
  1551     innerrect.Shrink( TSize(10, 10) );
       
  1552     vk->SetInnerRect( innerrect );
       
  1553     
       
  1554     return vk;
       
  1555     }
       
  1556 
       
  1557 
       
  1558 // ---------------------------------------------------------------------------
       
  1559 // update virtual key info.
       
  1560 // ---------------------------------------------------------------------------
       
  1561 //
       
  1562 void CPeninputFingerHwrWnd::UpdateVkbKeyL( CVirtualKey* aVirtualKey, 
       
  1563     TResourceReader& aReader, const TRect aKeyRect )
       
  1564     {
       
  1565     CHBufCArray* keytexts = CHBufCArray::NewL();
       
  1566     CleanupStack::PushL( keytexts );
       
  1567     
       
  1568     for ( TInt i = 0; i <= EPosLast; i++ )
       
  1569         {
       
  1570         HBufC* unicode = aReader.ReadHBufCL();
       
  1571         keytexts->Array().AppendL( unicode );
       
  1572         }
       
  1573 
       
  1574     TInt keyscancode = aReader.ReadInt16();
       
  1575 
       
  1576     HBufC* text = keytexts->Array()[0];
       
  1577     if ( text )
       
  1578         {
       
  1579         aVirtualKey->SetKeyData( *text );
       
  1580         }
       
  1581     else
       
  1582         {
       
  1583         aVirtualKey->SetKeyData( KNullDesC );
       
  1584         }
       
  1585     
       
  1586     aVirtualKey->SetKeyScancode( keyscancode );
       
  1587 
       
  1588     CleanupStack::PopAndDestroy( keytexts ); //keytexts
       
  1589 
       
  1590 
       
  1591     TRect innerrect = aKeyRect;
       
  1592     innerrect.Shrink( TSize(10,10) );
       
  1593     aVirtualKey->SetInnerRect( innerrect );
       
  1594    
       
  1595     }
       
  1596 
       
  1597 // ---------------------------------------------------------------------------
       
  1598 // load virtual number keys.
       
  1599 // ---------------------------------------------------------------------------
       
  1600 //
       
  1601 void CPeninputFingerHwrWnd::LoadVirtualNumpadKeysL( 
       
  1602     const TInt aResId, const RArray<TRect>& aCellRects )
       
  1603     {
       
  1604     iVirtualNumpad->SetResourceId( aResId );
       
  1605     
       
  1606     TAknTextLineLayout txtlayout = iLafManager->NumpadKeyTxtLayout();
       
  1607     iVirtualNumpad->SetTextLineLayout( txtlayout );
       
  1608     
       
  1609     TInt fontid = txtlayout.FontId();
       
  1610     const CFont* font = AknLayoutUtils::FontFromId( fontid );
       
  1611     iVirtualNumpad->SetFont( font );
       
  1612     
       
  1613 
       
  1614     TResourceReader reader;
       
  1615     CCoeEnv::Static()->CreateResourceReaderLC( reader, aResId );
       
  1616 
       
  1617 
       
  1618     // construct keys
       
  1619     TInt resKeyCount = reader.ReadInt16();
       
  1620     TInt existsKeyCount = iVirtualNumpad->KeyArray().Count();
       
  1621     TInt rectCount = aCellRects.Count();
       
  1622     
       
  1623     for ( TInt i = 0; i < resKeyCount; i++ )
       
  1624         {
       
  1625         if ( i < existsKeyCount )
       
  1626             {
       
  1627             CVirtualKey* vk = iVirtualNumpad->KeyArray()[i];
       
  1628             UpdateVkbKeyL( vk, reader, aCellRects[i%rectCount] );
       
  1629             }
       
  1630         else
       
  1631             {
       
  1632             CVirtualKey* vk = CreateVkbKeyL( reader, aCellRects[i%rectCount] );
       
  1633             CleanupStack::PushL( vk );
       
  1634             iVirtualNumpad->AddKeyL( vk );
       
  1635             CleanupStack::Pop( vk );
       
  1636             }
       
  1637         }    
       
  1638     CleanupStack::PopAndDestroy( 1 ); // reader
       
  1639     
       
  1640     iVirtualNumpad->Draw();
       
  1641     iVirtualNumpad->UpdateArea( iVirtualNumpad->Rect() );
       
  1642     }
       
  1643 
       
  1644 
       
  1645 // ---------------------------------------------------------------------------
       
  1646 // load virtual sct keys.
       
  1647 // ---------------------------------------------------------------------------
       
  1648 //
       
  1649 void CPeninputFingerHwrWnd::LoadVirtualSctpadKeysL( const TInt aResId, 
       
  1650     const RArray<TRect>& aCellRects )
       
  1651     {
       
  1652     iVirtualSctpad->SetResourceId( aResId );
       
  1653     
       
  1654     TAknTextLineLayout txtlayout = iLafManager->SctpadKeyTxtLayout();
       
  1655     iVirtualSctpad->SetTextLineLayout( txtlayout );
       
  1656     
       
  1657     TInt fontid = txtlayout.FontId();
       
  1658     const CFont* font = AknLayoutUtils::FontFromId( fontid );
       
  1659     iVirtualSctpad->SetFont( font );
       
  1660     
       
  1661 
       
  1662     TResourceReader reader;
       
  1663     CCoeEnv::Static()->CreateResourceReaderLC( reader, aResId );
       
  1664 
       
  1665     // construct keys
       
  1666     TInt resKeyCount = reader.ReadInt16();
       
  1667     TInt existsKeyCount = iVirtualSctpad->KeyArray().Count();
       
  1668     TInt rectCount = aCellRects.Count();
       
  1669     
       
  1670     for ( TInt i = 0; i < resKeyCount; i++ )
       
  1671         {
       
  1672         if ( i < existsKeyCount )
       
  1673             {
       
  1674             CVirtualKey* vk = iVirtualSctpad->KeyArray()[i];
       
  1675             UpdateVkbKeyL( vk, reader, aCellRects[i%rectCount] );
       
  1676             }
       
  1677         else
       
  1678             {
       
  1679             CVirtualKey* vk = CreateVkbKeyL( reader, aCellRects[i%rectCount] );
       
  1680             CleanupStack::PushL( vk );
       
  1681             iVirtualSctpad->AddKeyL( vk );
       
  1682             CleanupStack::Pop( vk );
       
  1683             }
       
  1684         }
       
  1685     
       
  1686     CleanupStack::PopAndDestroy( 1 ); // reader
       
  1687     
       
  1688     iVirtualSctpad->Draw();
       
  1689     iVirtualSctpad->UpdateArea( iVirtualSctpad->Rect() );
       
  1690     
       
  1691     }
       
  1692 
       
  1693 // ---------------------------------------------------------------------------
       
  1694 // load virtual sct keys.
       
  1695 // ---------------------------------------------------------------------------
       
  1696 //
       
  1697 void CPeninputFingerHwrWnd::LoadFixVirtualSctpadKeysL( const TInt aResId, 
       
  1698     const RArray<TRect>& aCellRects )
       
  1699     {
       
  1700     iVirtualSctpadFix->SetResourceId( aResId );
       
  1701     
       
  1702     TAknTextLineLayout txtlayout = iLafManager->FixSctpadKeyTxtLayout();
       
  1703     iVirtualSctpadFix->SetTextLineLayout( txtlayout );
       
  1704     
       
  1705     TInt fontid = txtlayout.FontId();
       
  1706     const CFont* font = AknLayoutUtils::FontFromId( fontid );
       
  1707     iVirtualSctpadFix->SetFont( font );
       
  1708     
       
  1709 
       
  1710     TResourceReader reader;
       
  1711     CCoeEnv::Static()->CreateResourceReaderLC( reader, aResId );
       
  1712 
       
  1713     // construct keys
       
  1714     TInt resKeyCount = reader.ReadInt16();
       
  1715     TInt existsKeyCount = iVirtualSctpadFix->KeyArray().Count();
       
  1716     TInt rectCount = aCellRects.Count();
       
  1717     
       
  1718     for ( TInt i = 0; i < resKeyCount; i++ )
       
  1719         {
       
  1720         if ( i < existsKeyCount )
       
  1721             {
       
  1722             CVirtualKey* vk = iVirtualSctpadFix->KeyArray()[i];
       
  1723             UpdateVkbKeyL( vk, reader, aCellRects[i] );
       
  1724             }
       
  1725         else
       
  1726             {
       
  1727             CVirtualKey* vk = CreateVkbKeyL( reader, aCellRects[i] );
       
  1728             CleanupStack::PushL( vk );
       
  1729             iVirtualSctpadFix->AddKeyL( vk );
       
  1730             CleanupStack::Pop( vk );
       
  1731             }
       
  1732         }
       
  1733     
       
  1734     CleanupStack::PopAndDestroy( 1 ); // reader
       
  1735     
       
  1736     iVirtualSctpadFix->Draw();
       
  1737     iVirtualSctpadFix->UpdateArea( iVirtualSctpadFix->Rect() );
       
  1738     
       
  1739     }
       
  1740 
       
  1741 // ---------------------------------------------------------------------------
       
  1742 //  relayout full ui, reset all controls position. 
       
  1743 // ---------------------------------------------------------------------------
       
  1744 //
       
  1745 void CPeninputFingerHwrWnd::ResetLayoutL()
       
  1746     {
       
  1747     TRect rcScreen = iLafManager->LayoutRect();
       
  1748     SetRect( rcScreen );
       
  1749    
       
  1750     TRect rect;
       
  1751     
       
  1752     //Move ICF
       
  1753     rect = iLafManager->CtrlRect( iContextField->ControlId() );
       
  1754     iContextField->SetRect( rect );
       
  1755 
       
  1756     //Move Writing box
       
  1757     rect = iLafManager->CtrlRect( iWritingBox->ControlId() );
       
  1758     iWritingBox->SetRect( rect );
       
  1759     
       
  1760     //Move Virtual Numpad
       
  1761     if ( iVirtualNumpad )
       
  1762         {
       
  1763         rect = iLafManager->CtrlRect( iVirtualNumpad->ControlId() );
       
  1764         iVirtualNumpad->SetRect( rect );
       
  1765 
       
  1766         const RPointerArray<CVirtualKey>& keys = iVirtualNumpad->KeyArray();
       
  1767         RArray<TRect> rects;
       
  1768         iLafManager->GetVirtualKeyRects( rects );
       
  1769         
       
  1770         const TInt count = keys.Count();
       
  1771         for ( TInt i = 0; i < count; i++ )
       
  1772             {
       
  1773             CVirtualKey* vk = keys[i];
       
  1774             vk->SetRect( rects[i] );
       
  1775             }
       
  1776         rects.Reset();
       
  1777         rects.Close();
       
  1778         }
       
  1779     
       
  1780     //move virtual Sctpad
       
  1781     if ( iVirtualSctpad )
       
  1782         {
       
  1783         rect = iLafManager->CtrlRect( iVirtualSctpad->ControlId() );
       
  1784         iVirtualSctpad->SetRect( rect );
       
  1785         
       
  1786         const RPointerArray<CVirtualKey>& keys = iVirtualSctpad->KeyArray();
       
  1787         RArray<TRect> rects;
       
  1788         iLafManager->GetVirtualKeyRects( rects );
       
  1789         
       
  1790         TInt n = rects.Count(); //num of cells in one page
       
  1791         for ( TInt i = 0; i < keys.Count(); i++ )
       
  1792             {
       
  1793             CVirtualKey* vk = keys[i];
       
  1794             vk->SetRect( rects[i%n] );
       
  1795             }
       
  1796         rects.Reset();
       
  1797         rects.Close();
       
  1798         }
       
  1799 
       
  1800     //move virtual Sctpad 
       
  1801     if ( iVirtualSctpadFix )
       
  1802         {
       
  1803         rect = iLafManager->CtrlRect( iVirtualSctpadFix->ControlId() );
       
  1804         iVirtualSctpadFix->SetRect( rect );
       
  1805         
       
  1806         const RPointerArray<CVirtualKey>& keys = iVirtualSctpadFix->KeyArray();
       
  1807         RArray<TRect> rects;
       
  1808         iLafManager->GetFixVirtualKeyRects( rects );
       
  1809         
       
  1810         TInt n = rects.Count(); //
       
  1811         for ( TInt i = 0; i < keys.Count(); i++ )
       
  1812             {
       
  1813             CVirtualKey* vk = keys[i];
       
  1814             vk->SetRect( rects[i] );
       
  1815             }
       
  1816         rects.Reset();
       
  1817         rects.Close();
       
  1818         }
       
  1819     
       
  1820     //Move buttons
       
  1821     TSize siBtnPadding = iLafManager->ButtonInnerPadding();
       
  1822     TInt pdx = siBtnPadding.iWidth;
       
  1823     TInt pdy = siBtnPadding.iHeight;
       
  1824     
       
  1825     rect = iLafManager->CtrlRect( iCloseBtn->ControlId() );
       
  1826     MoveIconButton( iCloseBtn, rect, pdx, pdy, ETrue );
       
  1827    
       
  1828     rect = iLafManager->CtrlRect( iRangeSpecialBtn->ControlId() );
       
  1829     MoveIconButton( iRangeSpecialBtn, rect,  pdx, pdy, ETrue );
       
  1830     
       
  1831     rect = iLafManager->CtrlRect( iBackspaceBtn->ControlId() );
       
  1832     MoveIconButton( iBackspaceBtn, rect,  pdx, pdy, ETrue );
       
  1833 
       
  1834     rect = iLafManager->CtrlRect( iArrowUpBtn->ControlId() );
       
  1835     MoveIconButton( iArrowUpBtn, rect,  pdx, pdy, ETrue );
       
  1836     
       
  1837     rect = iLafManager->CtrlRect( iArrowLeftBtn->ControlId() );
       
  1838     MoveIconButton( iArrowLeftBtn, rect,  pdx, pdy, ETrue );
       
  1839     
       
  1840     rect = iLafManager->CtrlRect( iArrowRightBtn->ControlId() );
       
  1841     MoveIconButton( iArrowRightBtn,   rect,  pdx, pdy, ETrue );
       
  1842 
       
  1843     rect = iLafManager->CtrlRect( iArrowDownBtn->ControlId() );
       
  1844     MoveIconButton( iArrowDownBtn,    rect,  pdx, pdy, ETrue );
       
  1845     
       
  1846     rect = iLafManager->CtrlRect( iOptionBtn->ControlId() );
       
  1847     MoveIconButton( iOptionBtn, rect,  pdx, pdy, ETrue );
       
  1848     
       
  1849     rect = iLafManager->CtrlRect( iImeSwitchBtn->ControlId() );
       
  1850     MoveIconButton( iImeSwitchBtn,    rect,  pdx, pdy, ETrue );
       
  1851     
       
  1852     rect = iLafManager->CtrlRect( iSctPage0Btn->ControlId() );
       
  1853     MoveSwitchPageButton( iSctPage0Btn, rect,  pdx, pdy, ETrue );
       
  1854     
       
  1855     rect = iLafManager->CtrlRect( iSctPage1Btn->ControlId() );
       
  1856     MoveSwitchPageButton( iSctPage1Btn, rect,  pdx, pdy, ETrue );
       
  1857 
       
  1858     rect = iLafManager->CtrlRect( iSctPage2Btn->ControlId() );
       
  1859     MoveSwitchPageButton( iSctPage2Btn, rect,  pdx, pdy, ETrue );
       
  1860     
       
  1861     //save range buttons position
       
  1862     iRectOfRangeBtn = iLafManager->CtrlRect( iRangeSelector->ControlId() ); 
       
  1863     
       
  1864     //move range selector
       
  1865     iRangeSelector->SetRect( iRectOfRangeBtn );
       
  1866     iRangeSelector->SetBaseRect( iRectOfRangeBtn );
       
  1867     }
       
  1868 
       
  1869 
       
  1870 // ---------------------------------------------------------------------------
       
  1871 //  layout for chinese range standby.
       
  1872 // ---------------------------------------------------------------------------
       
  1873 //
       
  1874 void CPeninputFingerHwrWnd::LayoutStandbyChinese()
       
  1875     {
       
  1876     
       
  1877     iCandidateList->Hide( ETrue );
       
  1878     iPredictList->Hide( ETrue );
       
  1879     
       
  1880 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  1881     iFixEngSymbolList1->Hide( ETrue );
       
  1882     iFixEngSymbolList2->Hide( ETrue );
       
  1883 #endif
       
  1884 
       
  1885     iWritingBox->Hide( EFalse );
       
  1886     iVirtualNumpad->Hide( ETrue );
       
  1887     iVirtualSctpad->Hide( ETrue );
       
  1888     iVirtualSctpadFix->Hide( ETrue );
       
  1889     
       
  1890     iArrowLeftBtn->Hide( EFalse );
       
  1891     iArrowRightBtn->Hide( EFalse );
       
  1892     iArrowUpBtn->Hide( EFalse );
       
  1893     iArrowDownBtn->Hide( EFalse );
       
  1894     iOptionBtn->Hide( EFalse );
       
  1895     iImeSwitchBtn->Hide( EFalse );    
       
  1896     
       
  1897     iSctPage0Btn->Hide( ETrue );
       
  1898     iSctPage1Btn->Hide( ETrue );
       
  1899     iSctPage2Btn->Hide( ETrue );
       
  1900     
       
  1901     iRangeSpecialBtn->SetHighlight( EFalse );
       
  1902     
       
  1903     UpdateAllVirtualKeysFeedback( EFingerHwrNativeRange );
       
  1904     }
       
  1905 
       
  1906 // ---------------------------------------------------------------------------
       
  1907 //  layout for english range standby.
       
  1908 // ---------------------------------------------------------------------------
       
  1909 //
       
  1910 void CPeninputFingerHwrWnd::LayoutStandbyEnglish()
       
  1911     {
       
  1912     iCandidateList->Hide( ETrue );
       
  1913     iPredictList->Hide( ETrue );
       
  1914     
       
  1915 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  1916     iFixEngSymbolList1->Hide( ETrue );
       
  1917     iFixEngSymbolList2->Hide( ETrue );
       
  1918 #endif
       
  1919    
       
  1920     iWritingBox->Hide( EFalse );
       
  1921     iVirtualNumpad->Hide( ETrue );
       
  1922     iVirtualSctpad->Hide( ETrue );
       
  1923     iVirtualSctpadFix->Hide( ETrue );
       
  1924     
       
  1925     iArrowLeftBtn->Hide( EFalse );
       
  1926     iArrowRightBtn->Hide( EFalse );
       
  1927     iArrowUpBtn->Hide( EFalse );
       
  1928     iArrowDownBtn->Hide( EFalse );
       
  1929     iOptionBtn->Hide( EFalse );
       
  1930     iImeSwitchBtn->Hide( EFalse );      
       
  1931 
       
  1932     iSctPage0Btn->Hide( ETrue );
       
  1933     iSctPage1Btn->Hide( ETrue );
       
  1934     iSctPage2Btn->Hide( ETrue );
       
  1935     
       
  1936     iRangeSpecialBtn->SetHighlight( EFalse );
       
  1937     
       
  1938     UpdateAllVirtualKeysFeedback( EFingerHwrEnglishRange );
       
  1939     }
       
  1940 
       
  1941 // ---------------------------------------------------------------------------
       
  1942 //  layout for number range standby.
       
  1943 // ---------------------------------------------------------------------------
       
  1944 //
       
  1945 void CPeninputFingerHwrWnd::LayoutStandbyNumeric()
       
  1946     {
       
  1947     iCandidateList->Hide( ETrue );
       
  1948     iPredictList->Hide( ETrue );
       
  1949     
       
  1950 #ifndef RD_INTELLIGENT_TEXT_INPUT    
       
  1951     iFixEngSymbolList1->Hide( ETrue );
       
  1952     iFixEngSymbolList2->Hide( ETrue );
       
  1953 #endif
       
  1954    
       
  1955     iWritingBox->Hide( ETrue );
       
  1956     iVirtualNumpad->Hide( EFalse );
       
  1957     iVirtualSctpad->Hide( ETrue );
       
  1958     iVirtualSctpadFix->Hide( ETrue );
       
  1959     
       
  1960     iArrowLeftBtn->Hide( EFalse );
       
  1961     iArrowRightBtn->Hide( EFalse );
       
  1962     iArrowUpBtn->Hide( EFalse );
       
  1963     iArrowDownBtn->Hide( EFalse );
       
  1964     iOptionBtn->Hide( EFalse );
       
  1965     iImeSwitchBtn->Hide( EFalse );
       
  1966 
       
  1967     iSctPage0Btn->Hide( ETrue );
       
  1968     iSctPage1Btn->Hide( ETrue );
       
  1969     iSctPage2Btn->Hide( ETrue );
       
  1970     
       
  1971     iRangeSpecialBtn->SetHighlight( EFalse );
       
  1972     
       
  1973     UpdateAllVirtualKeysFeedback( EFingerHwrNumberRange );
       
  1974     }
       
  1975 
       
  1976 // ---------------------------------------------------------------------------
       
  1977 //  layout for symbol range standby.
       
  1978 // ---------------------------------------------------------------------------
       
  1979 //
       
  1980 void CPeninputFingerHwrWnd::LayoutStandbySymbol()
       
  1981     {
       
  1982     iCandidateList->Hide( ETrue );
       
  1983     iPredictList->Hide( ETrue );
       
  1984     
       
  1985 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  1986     iFixEngSymbolList1->Hide( ETrue );
       
  1987     iFixEngSymbolList2->Hide( ETrue );
       
  1988 #endif
       
  1989    
       
  1990     iWritingBox->Hide( ETrue );
       
  1991     iVirtualNumpad->Hide( ETrue );
       
  1992     iVirtualSctpad->Hide( EFalse );
       
  1993     iVirtualSctpadFix->Hide( EFalse );
       
  1994     
       
  1995     iArrowLeftBtn->Hide( ETrue );
       
  1996     iArrowRightBtn->Hide( ETrue );
       
  1997     iArrowUpBtn->Hide( ETrue );
       
  1998     iArrowDownBtn->Hide( ETrue );
       
  1999     iOptionBtn->Hide( EFalse );
       
  2000     iImeSwitchBtn->Hide( EFalse );  
       
  2001     
       
  2002     iRangeSpecialBtn->SetHighlight( ETrue );
       
  2003 
       
  2004     TInt pageno = ( iCurCharRangeNoSct == EFingerHwrNativeRange ) ? 0 : 1;
       
  2005     ShowSctPage( pageno, EPagePosPageNo );
       
  2006     
       
  2007     UpdateAllVirtualKeysFeedback( EFingerHwrSymbolRange );
       
  2008     
       
  2009     UiLayout()->RootControl()->ReDrawRect( iVirtualSctpadFix->Rect() );
       
  2010     UpdateArea( iVirtualSctpadFix->Rect() );
       
  2011     }
       
  2012 
       
  2013 
       
  2014 // ---------------------------------------------------------------------------
       
  2015 //  EventButton layout helper. Move button to specified rect.
       
  2016 // ---------------------------------------------------------------------------
       
  2017 //
       
  2018 void CPeninputFingerHwrWnd::MoveIconButton( CAknFepCtrlEventButton* aButton, 
       
  2019     const TRect& aRect, TInt aXPadding, TInt aYPadding, TBool aReloadImages )
       
  2020     {
       
  2021     if ( !aButton )
       
  2022         {
       
  2023         return;
       
  2024         }
       
  2025     
       
  2026     aButton->SetRect( aRect );
       
  2027     TRect rcInner = aRect;
       
  2028     if (  rcInner.Width()> rcInner.Height() )
       
  2029         {
       
  2030             TInt dx = ( rcInner.Width() - rcInner.Height() ) / 2;
       
  2031             rcInner.Move( dx, 0 );
       
  2032             rcInner.SetWidth( rcInner.Height() );
       
  2033         }
       
  2034     else
       
  2035         {
       
  2036         TInt dy = ( rcInner.Height() - rcInner.Width() ) / 2;
       
  2037         rcInner.Move( 0, dy );
       
  2038         rcInner.SetHeight( rcInner.Width() );        
       
  2039         }
       
  2040 
       
  2041     rcInner.Shrink( aXPadding, aYPadding );
       
  2042     aButton->SizeChanged( aRect, rcInner, aReloadImages );
       
  2043     }
       
  2044     
       
  2045 // ---------------------------------------------------------------------------
       
  2046 //  EventButton layout helper. 
       
  2047 // ---------------------------------------------------------------------------
       
  2048 //
       
  2049 void CPeninputFingerHwrWnd::MoveSwitchPageButton( CAknFepCtrlEventButton* aButton, 
       
  2050     const TRect& aRect, TInt aXPadding, TInt aYPadding, TBool aReloadImages )
       
  2051     {
       
  2052     if ( !aButton )
       
  2053         {
       
  2054         return;
       
  2055         }
       
  2056     
       
  2057     aButton->SetRect( aRect );
       
  2058     TRect rcInner = aRect;
       
  2059 
       
  2060     rcInner.Shrink( aXPadding + 5, aYPadding );
       
  2061     aButton->SizeChanged( aRect, rcInner, aReloadImages );
       
  2062     }    
       
  2063 
       
  2064 
       
  2065 // ---------------------------------------------------------------------------
       
  2066 //  Read control's shadow info.
       
  2067 // ---------------------------------------------------------------------------
       
  2068 //
       
  2069 void CPeninputFingerHwrWnd::ReadShadowInfoL( const TInt aResId )
       
  2070     {
       
  2071     TResourceReader resReader;
       
  2072     CCoeEnv::Static()->CreateResourceReaderLC( resReader, aResId );
       
  2073      
       
  2074     TPtrC bmpFileName = resReader.ReadTPtrC();
       
  2075     TInt32 imgMajorSkinId = resReader.ReadInt32();
       
  2076 
       
  2077     TAknsItemID id;
       
  2078     TInt skinitemid;
       
  2079     
       
  2080     MAknsSkinInstance* skininstance = AknsUtils::SkinInstance();
       
  2081 
       
  2082     for ( TInt i = 0; i < KShadowBmpBr + 1; i++ )
       
  2083     	{
       
  2084         const TInt16 bmpId = resReader.ReadInt16();
       
  2085         const TInt16 bmpMskId = resReader.ReadInt16();
       
  2086         skinitemid = resReader.ReadInt16();
       
  2087         
       
  2088         id.Set( TInt( imgMajorSkinId ), skinitemid );
       
  2089     	
       
  2090         if ( bmpId != KInvalidImg )
       
  2091         	{
       
  2092             CFbsBitmap* shadowImg = NULL;
       
  2093             CFbsBitmap* shadowMaskImg = NULL;
       
  2094 
       
  2095             if ( bmpMskId != KInvalidImg )
       
  2096                 {
       
  2097                 AknsUtils::CreateIconL( skininstance, 
       
  2098                                        id,
       
  2099                                        shadowImg,
       
  2100                                        shadowMaskImg,
       
  2101                                        bmpFileName,
       
  2102                                        bmpId,
       
  2103                                        bmpMskId );
       
  2104                 }
       
  2105             else
       
  2106                 {
       
  2107                 AknsUtils::CreateIconL( skininstance,
       
  2108                                        id,
       
  2109                                        shadowImg,
       
  2110                                        bmpFileName,
       
  2111                                        bmpId );
       
  2112                 }
       
  2113             
       
  2114             SetShadowBmp( shadowImg, shadowMaskImg, TShadowBitmapIndex( i ) );
       
  2115         	}
       
  2116     	}
       
  2117     CleanupStack::PopAndDestroy( 1 ); // reader
       
  2118     
       
  2119     }
       
  2120     
       
  2121 // ---------------------------------------------------------------------------
       
  2122 //  Read control's background info.
       
  2123 // ---------------------------------------------------------------------------
       
  2124 //
       
  2125 void CPeninputFingerHwrWnd::ReadBackgroundInfoL( const TInt aResId )
       
  2126     {
       
  2127     if ( aResId == 0 )
       
  2128         return;
       
  2129     
       
  2130     if ( BackgroundBmp() )
       
  2131         {
       
  2132         CFbsBitmap* bkBmp = BackgroundBmp();
       
  2133         delete bkBmp;   
       
  2134         SetBackgroundBmp( NULL );
       
  2135         }
       
  2136     if ( BkMaskBmp() )
       
  2137         {
       
  2138         CFbsBitmap* bkMaskBmp = BkMaskBmp();
       
  2139         delete bkMaskBmp;
       
  2140         SetBackgroundMaskBmp( NULL );
       
  2141         }    
       
  2142 
       
  2143     TResourceReader resReader;
       
  2144     CCoeEnv::Static()->CreateResourceReaderLC( resReader, aResId ); 
       
  2145      
       
  2146     TPtrC bmpFileName = resReader.ReadTPtrC();
       
  2147     TInt32 imgMajorSkinId = resReader.ReadInt32();
       
  2148 
       
  2149     TAknsItemID id;
       
  2150     TInt skinitemid;
       
  2151     
       
  2152     MAknsSkinInstance* skininstance = AknsUtils::SkinInstance();
       
  2153     const TInt16 bmpId = resReader.ReadInt16();
       
  2154     const TInt16 bmpMskId = resReader.ReadInt16();
       
  2155     skinitemid = resReader.ReadInt16();   
       
  2156     id.Set( TInt( imgMajorSkinId ), skinitemid );
       
  2157     
       
  2158     if ( bmpId != KInvalidImg )
       
  2159         {
       
  2160         CFbsBitmap* backgroundImg = NULL;
       
  2161         CFbsBitmap* backgroundMaskImg = NULL;
       
  2162         if ( bmpMskId != KInvalidImg )
       
  2163             {
       
  2164             AknsUtils::CreateIconL( skininstance, id, backgroundImg,
       
  2165                     backgroundMaskImg, bmpFileName, bmpId, bmpMskId );
       
  2166             }
       
  2167         else
       
  2168             {
       
  2169             AknsUtils::CreateIconL( skininstance, id, backgroundImg,
       
  2170                     bmpFileName, bmpId );
       
  2171             }
       
  2172        
       
  2173         SetBackgroundBmp( backgroundImg );
       
  2174         SetBackgroundMaskBmp( backgroundMaskImg );           
       
  2175         }
       
  2176     CleanupStack::PopAndDestroy( 1 ); //reader
       
  2177     }
       
  2178 
       
  2179 // ---------------------------------------------------------------------------
       
  2180 //  read icf appearance info.
       
  2181 // ---------------------------------------------------------------------------
       
  2182 //
       
  2183 void CPeninputFingerHwrWnd::ReadICFInfoL( const TInt aResId )
       
  2184     {
       
  2185     if ( aResId == 0 )
       
  2186         {
       
  2187         return;
       
  2188         }
       
  2189 
       
  2190     TResourceReader icfreader;
       
  2191     CCoeEnv::Static()->CreateResourceReaderLC( icfreader, aResId );
       
  2192          
       
  2193     TInt32 colorMajorSkinId = icfreader.ReadInt32();
       
  2194     TInt skinitemid = icfreader.ReadInt16();
       
  2195     TInt coloridx = icfreader.ReadInt16();
       
  2196 
       
  2197     TAknsItemID colorid;
       
  2198     colorid.Set( TInt( colorMajorSkinId ), skinitemid );
       
  2199 
       
  2200     TRgb icftextcolor;
       
  2201     MAknsSkinInstance* skininstance = AknsUtils::SkinInstance();
       
  2202     TInt error = AknsUtils::GetCachedColor( skininstance, icftextcolor,
       
  2203             colorid, coloridx );
       
  2204 
       
  2205     if ( error != KErrNone )
       
  2206         {
       
  2207         icftextcolor = TRgb( KDefaultTextColor );
       
  2208         }
       
  2209 
       
  2210     iContextField->SetTextColorL( icftextcolor );    
       
  2211     
       
  2212     // Set highlight color
       
  2213     TRgb icfhightlightcolor;
       
  2214     error = AknsUtils::GetCachedColor( skininstance, 
       
  2215                                        icfhightlightcolor, 
       
  2216                                        KAknsIIDQsnHighlightColors,
       
  2217                                        EAknsCIQsnHighlightColorsCG2 ); 
       
  2218     if ( error == KErrNone ) 
       
  2219         {
       
  2220         iContextField->SetTextSelColorL( icfhightlightcolor );
       
  2221         }
       
  2222 
       
  2223     skinitemid = icfreader.ReadInt16();
       
  2224     coloridx = icfreader.ReadInt16();
       
  2225     
       
  2226     colorid.Set( TInt( colorMajorSkinId ), skinitemid );
       
  2227     
       
  2228     TRgb icfframecolor;
       
  2229     error = AknsUtils::GetCachedColor( skininstance, icfframecolor, 
       
  2230             colorid, coloridx );
       
  2231 
       
  2232     if ( error != KErrNone )
       
  2233         {
       
  2234     	icfframecolor = TRgb( KDefaultFrameColor );
       
  2235         }
       
  2236 
       
  2237     iContextField->SetBorderColor( icfframecolor );
       
  2238     iContextField->SetBgImgSkinId( KAknsIIDQsnFrCall2Rect );
       
  2239     CleanupStack::PopAndDestroy( 1 ); // icfreader       
       
  2240     }
       
  2241 
       
  2242 // ---------------------------------------------------------------------------
       
  2243 //  read writingbox appearance info.
       
  2244 // ---------------------------------------------------------------------------
       
  2245 //
       
  2246 void CPeninputFingerHwrWnd::ReadWritingBoxInfoL( const TInt aResId )
       
  2247     {
       
  2248     if ( aResId == 0 )
       
  2249 	{
       
  2250 	return;
       
  2251 	}
       
  2252 
       
  2253     TResourceReader reader;
       
  2254     CCoeEnv::Static()->CreateResourceReaderLC( reader, aResId );
       
  2255 
       
  2256     // get write box bg color
       
  2257     TInt32 colorMajorSkinId = reader.ReadInt32();
       
  2258     TInt skinitemid = reader.ReadInt16();
       
  2259     TInt coloridx = reader.ReadInt16();
       
  2260 
       
  2261     TAknsItemID colorid;
       
  2262     colorid.Set( TInt( colorMajorSkinId ), skinitemid );
       
  2263 
       
  2264     TRgb boxcolor;
       
  2265     MAknsSkinInstance* skininstance = AknsUtils::SkinInstance();
       
  2266     TInt error = AknsUtils::GetCachedColor( skininstance, 
       
  2267                                            boxcolor, 
       
  2268                                            colorid, 
       
  2269                                            coloridx );
       
  2270 
       
  2271     if ( error != KErrNone )
       
  2272         {
       
  2273         boxcolor = TRgb( KDefaultWriteBoxBgColor );
       
  2274         }
       
  2275     
       
  2276     iWritingBoxBkColor = boxcolor;
       
  2277     iWritingBox->SetBkColor( boxcolor );
       
  2278 
       
  2279     skinitemid = reader.ReadInt16();
       
  2280     coloridx = reader.ReadInt16();
       
  2281     
       
  2282     colorid.Set( TInt( colorMajorSkinId ), skinitemid );
       
  2283     
       
  2284     TRgb boxframecolor;
       
  2285     error = AknsUtils::GetCachedColor( skininstance, 
       
  2286                                       boxframecolor, 
       
  2287                                       colorid, 
       
  2288                                       coloridx );
       
  2289 
       
  2290     if ( error != KErrNone )
       
  2291         {
       
  2292     	boxframecolor = TRgb( KDefaultWriteBoxFrameColor );
       
  2293         }
       
  2294     
       
  2295     iWritingBoxFrameColor = boxframecolor;
       
  2296     iWritingBox->SetFrameCol( boxframecolor );
       
  2297 
       
  2298     CleanupStack::PopAndDestroy(); // reader
       
  2299     
       
  2300     ReloadWritingGuideLinesL();
       
  2301     }
       
  2302     
       
  2303 // ---------------------------------------------------------------------------
       
  2304 //  update feedback state of all virtual keys.
       
  2305 // ---------------------------------------------------------------------------
       
  2306 //
       
  2307 void CPeninputFingerHwrWnd::UpdateAllVirtualKeysFeedback( TInt aType )
       
  2308     {
       
  2309     if ( !UiLayout()->SupportTactileFeedback() ) 
       
  2310         {
       
  2311         // return ; 
       
  2312         // CFepUiLayout::OnActivate() is incorrect
       
  2313         // SupportTactileFeedback return is false when touch is about to active
       
  2314         }
       
  2315     
       
  2316     TBool isNumpad = ( aType == EFingerHwrNumberRange ) ? ETrue : EFalse;
       
  2317     TBool isSctpad = ( aType == EFingerHwrSymbolRange ) ? ETrue : EFalse;
       
  2318     
       
  2319     //update numpad keys
       
  2320     TInt keyCount = iVirtualNumpad->KeyArray().Count();
       
  2321     for ( TInt i = 0; i < keyCount; i++ )
       
  2322         {
       
  2323         CVirtualKey* vk = iVirtualNumpad->KeyArray()[i];
       
  2324         TBool enable = !vk->Dimmed() &&  isNumpad;
       
  2325         iVirtualNumpad->EnableKeyFeedback( vk, enable );
       
  2326         }
       
  2327     
       
  2328     //update sctpad keys
       
  2329     keyCount = iVirtualSctpad->KeyArray().Count();
       
  2330     TInt pageSize = iVirtualSctpad->PageSize();
       
  2331     TInt curPage = iVirtualSctpad->CurPageIndex();
       
  2332     for ( TInt i = 0; i < keyCount; i++ )
       
  2333         {
       
  2334         CVirtualKey* vk = iVirtualSctpad->KeyArray()[i];
       
  2335         TInt page = i / pageSize;
       
  2336         TBool enable = !vk->Dimmed() &&  isSctpad && ( page == curPage );
       
  2337         iVirtualSctpad->EnableKeyFeedback( vk, enable );
       
  2338         }
       
  2339     }
       
  2340 
       
  2341 
       
  2342 void CPeninputFingerHwrWnd::ReloadWritingGuideLinesL()
       
  2343     {
       
  2344     TInt resid = -1;
       
  2345     
       
  2346     if( iCurCharRange == EFingerHwrNativeRange )
       
  2347         {
       
  2348         resid = R_FINGER_HWR_GUIDELINE_CHS;
       
  2349         }
       
  2350     else if( iCurCharRange == EFingerHwrEnglishRange )
       
  2351         {
       
  2352         resid = R_FINGER_HWR_GUIDELINE_ENG;
       
  2353         }
       
  2354     else 
       
  2355         {
       
  2356         return;
       
  2357         }
       
  2358 
       
  2359     TResourceReader reader;
       
  2360     CCoeEnv::Static()->CreateResourceReaderLC( reader, resid );
       
  2361 
       
  2362     TPtrC fileName = reader.ReadTPtrC();
       
  2363     TInt32 majorSkinId = reader.ReadInt32();
       
  2364     TInt16 indexOfColor = reader.ReadInt16();
       
  2365     
       
  2366     TInt16 imageid = reader.ReadInt16();
       
  2367     TInt16 maskid = reader.ReadInt16();
       
  2368     TInt16 skinid = reader.ReadInt16();
       
  2369     
       
  2370     TAknsItemID id;
       
  2371     id.Set( TInt( majorSkinId ), skinid );
       
  2372     
       
  2373     CFbsBitmap* bmpImage = NULL;
       
  2374     CFbsBitmap* bmpMask = NULL;
       
  2375     
       
  2376     //AknsUtils::CreateIconL(AknsUtils::SkinInstance(), id, bmpImage, bmpMask, bmpFileName, imageid,maskid);
       
  2377     
       
  2378     TRgb colorBkgnd = iWritingBoxBkColor;
       
  2379     TRgb colorGuideLine = AKN_LAF_COLOR( 0 ); 
       
  2380     if ( ETrue )
       
  2381         {
       
  2382         TRgb color1 = colorBkgnd;
       
  2383         TRgb color2 = colorGuideLine;
       
  2384         
       
  2385         TInt k = 64;
       
  2386         TInt brightness = Max( color1.Red(), color1.Green() );
       
  2387         brightness = Max( brightness, color1.Blue() );
       
  2388         
       
  2389         color2 = ( brightness > 128 ) ? TRgb(0,0,0) : TRgb(255,255,255);
       
  2390 
       
  2391         TInt r = ( color1.Red()  * ( 256 - k ) + color2.Red()   * k ) / 256;
       
  2392         TInt g = ( color1.Green()* ( 256 - k ) + color2.Green() * k ) / 256;
       
  2393         TInt b = ( color1.Blue() * ( 256 - k ) + color2.Blue()  * k ) / 256;
       
  2394 
       
  2395         colorGuideLine = TRgb(r,g,b);
       
  2396         }
       
  2397     
       
  2398     AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(),
       
  2399             id, KAknsIIDQsnIconColors, -1,
       
  2400             bmpImage, bmpMask, fileName, imageid, maskid,
       
  2401             colorGuideLine );
       
  2402     
       
  2403     CleanupStack::PushL( bmpImage ); //1
       
  2404     CleanupStack::PushL( bmpMask );  //2
       
  2405     
       
  2406     TSize imgsize = iLafManager->CtrlRect(EHwrCtrlIdWritingBox).Size();
       
  2407     
       
  2408     AknIconUtils::SetSize( bmpImage, imgsize, EAspectRatioNotPreserved );
       
  2409     AknIconUtils::SetSize( bmpMask, imgsize, EAspectRatioNotPreserved );
       
  2410     
       
  2411     //prepare to merge
       
  2412     CFbsBitmap* bmpMerged = new(ELeave) CFbsBitmap();
       
  2413     CleanupStack::PushL( bmpMerged );   //3
       
  2414     bmpMerged->Create( imgsize, BitmapDevice()->DisplayMode() );
       
  2415     
       
  2416     CFbsBitmapDevice* dev=CFbsBitmapDevice::NewL( bmpMerged );
       
  2417     CleanupStack::PushL( dev );         //4
       
  2418     
       
  2419     CFbsBitGc* gc = CFbsBitGc::NewL();
       
  2420     CleanupStack::PushL( gc );          //5
       
  2421     
       
  2422     //merge image and mask to dest
       
  2423     TRect rcImage( TPoint(0,0), imgsize );
       
  2424     gc->Activate( dev );
       
  2425     gc->SetPenStyle( CGraphicsContext::ENullPen );
       
  2426     gc->SetBrushColor( colorBkgnd );
       
  2427     gc->SetBrushStyle( CGraphicsContext::ESolidBrush );
       
  2428     gc->DrawRect( rcImage );
       
  2429     gc->SetBrushStyle( CGraphicsContext::ENullBrush );
       
  2430     gc->BitBltMasked( TPoint(0,0), bmpImage, rcImage, bmpMask, EFalse );
       
  2431     
       
  2432     CleanupStack::PopAndDestroy( 2 ); //gc, dev
       
  2433     
       
  2434     iWritingBox->SetBackgroundBitmapL( bmpMerged );
       
  2435     iWritingBox->SetBackgroundMaskBitmapL( bmpMask );
       
  2436     
       
  2437     CleanupStack::Pop( 2 );           //bmpMerged, bmpMask
       
  2438     CleanupStack::PopAndDestroy( 1 ); //bmpImage
       
  2439     CleanupStack::PopAndDestroy();    //reader
       
  2440     
       
  2441     iWritingBox->ReDrawRect( iWritingBox->Rect() );
       
  2442     iWritingBox->UpdateArea( iWritingBox->Rect() );    
       
  2443     }
       
  2444 
       
  2445 void CPeninputFingerHwrWnd::ShowBubble(TInt aShow)
       
  2446     {
       
  2447     if (aShow > 0)
       
  2448         {
       
  2449     	TRect outrect,innerrect;          
       
  2450         
       
  2451         
       
  2452         
       
  2453         
       
  2454         iCandidateList->ShowBubble(ETrue);
       
  2455         iPredictList->ShowBubble(ETrue);
       
  2456          
       
  2457 #ifndef RD_INTELLIGENT_TEXT_INPUT    
       
  2458         iFixEngSymbolList1->ShowBubble(ETrue);
       
  2459         iFixEngSymbolList2->ShowBubble(ETrue);
       
  2460 #endif
       
  2461      	// Set priview popup size
       
  2462         iCandidateList->SetBubbleBitmapParam(NULL,NULL,KAknsIIDQsnFrInputCharPreview);
       
  2463 
       
  2464     	outrect = iLafManager->PreviewBubbleRect();  
       
  2465     	innerrect = iLafManager->PreviewBubbleInnerRect();
       
  2466     	iCandidateList->SetTextFormat(iLafManager->PreviewBubbleTextLayout());
       
  2467     	iCandidateList->SetBubbleTextFont(iLafManager->PreviewBubbleFont());
       
  2468     	iCandidateList->SetBubbleSize(TSize(outrect.Width(),outrect.Height()));  // Read laf
       
  2469     	iCandidateList->SetFrameDiff(innerrect.iTl.iX - outrect.iTl.iX,
       
  2470     	               innerrect.iTl.iY - outrect.iTl.iY,
       
  2471     	               outrect.iBr.iX - innerrect.iBr.iX,
       
  2472     	               outrect.iBr.iY - innerrect.iBr.iY);
       
  2473 
       
  2474         iPredictList->SetBubbleBitmapParam(NULL,NULL,KAknsIIDQsnFrInputCharPreview);
       
  2475     	iPredictList->SetTextFormat(iLafManager->PreviewBubbleTextLayout());
       
  2476     	iPredictList->SetBubbleTextFont(iLafManager->PreviewBubbleFont());
       
  2477     	iPredictList->SetBubbleSize(TSize(outrect.Width(),outrect.Height()));  // Read laf
       
  2478     	iPredictList->SetFrameDiff(innerrect.iTl.iX - outrect.iTl.iX,
       
  2479     	               innerrect.iTl.iY - outrect.iTl.iY,
       
  2480     	               outrect.iBr.iX - innerrect.iBr.iX,
       
  2481     	               outrect.iBr.iY - innerrect.iBr.iY);
       
  2482 
       
  2483 #ifndef RD_INTELLIGENT_TEXT_INPUT    
       
  2484         iFixEngSymbolList1->SetBubbleBitmapParam(NULL,NULL,KAknsIIDQsnFrInputCharPreview);
       
  2485     	iFixEngSymbolList1->SetTextFormat(iLafManager->PreviewBubbleTextLayout());
       
  2486     	iFixEngSymbolList1->SetBubbleTextFont(iLafManager->PreviewBubbleFont());
       
  2487     	iFixEngSymbolList1->SetBubbleSize(TSize(outrect.Width(),outrect.Height()));  // Read laf
       
  2488     	iFixEngSymbolList1->SetFrameDiff(innerrect.iTl.iX - outrect.iTl.iX,
       
  2489     	               innerrect.iTl.iY - outrect.iTl.iY,
       
  2490     	               outrect.iBr.iX - innerrect.iBr.iX,
       
  2491     	               outrect.iBr.iY - innerrect.iBr.iY);
       
  2492 
       
  2493         iFixEngSymbolList2->SetBubbleBitmapParam(NULL,NULL,KAknsIIDQsnFrInputCharPreview);
       
  2494     	iFixEngSymbolList2->SetTextFormat(iLafManager->PreviewBubbleTextLayout());
       
  2495     	iFixEngSymbolList2->SetBubbleTextFont(iLafManager->PreviewBubbleFont());
       
  2496     	iFixEngSymbolList2->SetBubbleSize(TSize(outrect.Width(),outrect.Height()));  // Read laf
       
  2497     	iFixEngSymbolList2->SetFrameDiff(innerrect.iTl.iX - outrect.iTl.iX,
       
  2498     	               innerrect.iTl.iY - outrect.iTl.iY,
       
  2499     	               outrect.iBr.iX - innerrect.iBr.iX,
       
  2500     	               outrect.iBr.iY - innerrect.iBr.iY);
       
  2501 #endif
       
  2502  
       
  2503         }
       
  2504     else
       
  2505         {
       
  2506         iCandidateList->ShowBubble(EFalse);
       
  2507         iPredictList->ShowBubble(EFalse);
       
  2508 #ifndef RD_INTELLIGENT_TEXT_INPUT    
       
  2509         iFixEngSymbolList1->ShowBubble(EFalse);
       
  2510         iFixEngSymbolList2->ShowBubble(EFalse);
       
  2511 #endif             
       
  2512         }
       
  2513     }    
       
  2514 //  End Of File