textinput/peninputfingerhwrar/src/peninputfingerhwrarsymboltable.cpp
branchRCL_3
changeset 19 ac7e4d1d9209
parent 12 5e18d8c489d6
equal deleted inserted replaced
18:b1ea1642412e 19:ac7e4d1d9209
    39 #include "peninputfingerhwrarevent.h"
    39 #include "peninputfingerhwrarevent.h"
    40 #include "peninputfingerhwrarcontrolid.h"
    40 #include "peninputfingerhwrarcontrolid.h"
    41 #include "peninputfingerhwrarstoreconstants.h"
    41 #include "peninputfingerhwrarstoreconstants.h"
    42 #include "peninputfingerhwrarmultipagevkb.h"
    42 #include "peninputfingerhwrarmultipagevkb.h"
    43 #include "peninputfingerhwrarsymboltable.h"
    43 #include "peninputfingerhwrarsymboltable.h"
    44 
    44 #include "peninputfingerhwarvkbutility.h"
    45 
    45 
    46 //CONST DEFINATION
    46 //CONST DEFINATION
    47 const TInt KSymbolButtonInnerPadding = 6;
    47 const TInt KSymbolButtonInnerPadding = 6;
    48 
    48 
    49 // ---------------------------------------------------------------------------
    49 // ---------------------------------------------------------------------------
   214 // ---------------------------------------------------------------------------
   214 // ---------------------------------------------------------------------------
   215 // SizeChanged
   215 // SizeChanged
   216 // ---------------------------------------------------------------------------
   216 // ---------------------------------------------------------------------------
   217 //	
   217 //	
   218 void CPeninputArabicFingerHwrSymbolTable::SizeChanged(
   218 void CPeninputArabicFingerHwrSymbolTable::SizeChanged(
   219                      const TRect aVirtualKeypadRect, const RArray<TRect> aBtnRects,
   219                      const TRect aVirtualKeypadRect, const RArray<TRect> & aBtnRects,
   220                      const TInt aKeypadRow, const TInt aKeypadCol, TBool aIsLandscape)
   220                      const TInt aKeypadRow, const TInt aKeypadCol, TBool aIsLandscape)
   221     {
   221     {
       
   222 	ASSERT(aBtnRects.Count() > 0);
       
   223 	
   222 	iIsLandscape = aIsLandscape;
   224 	iIsLandscape = aIsLandscape;
   223 	
   225 	
   224 	// relayout the button
   226 	// relayout the button
   225 	TRect pageBtnRect(aBtnRects[0]);
   227 	TRect pageBtnRect = aBtnRects[0];
   226 
   228     
   227 	if(aIsLandscape)
   229 	if(aIsLandscape)
   228 	    {
   230 	    {
   229 	    i2Page1Btn->Hide(EFalse);
   231 	    i2Page1Btn->Hide(EFalse);
   230 	    i2Page2Btn->Hide(EFalse);
   232 	    i2Page2Btn->Hide(EFalse);
   231 	    
   233 	    
   251 	// relayout the virtual key pad
   253 	// relayout the virtual key pad
   252 	iMutiPageKeypad->SetRect(aVirtualKeypadRect);
   254 	iMutiPageKeypad->SetRect(aVirtualKeypadRect);
   253 	
   255 	
   254 	iMutiPageKeypad->UpdatePaging(aKeypadRow,aKeypadCol);
   256 	iMutiPageKeypad->UpdatePaging(aKeypadRow,aKeypadCol);
   255 	}
   257 	}
   256 	
   258 
   257 // ---------------------------------------------------------------------------
   259 // ---------------------------------------------------------------------------
   258 // create symbol table keypad.
   260 // create symbol table keypad.
   259 // ---------------------------------------------------------------------------
   261 // ---------------------------------------------------------------------------
   260 //
   262 //
   261 void CPeninputArabicFingerHwrSymbolTable::CreateVirtualKeypadL()
   263 void CPeninputArabicFingerHwrSymbolTable::CreateVirtualKeypadL()
   328     TRect rcInner = aRect;
   330     TRect rcInner = aRect;
   329     rcInner.Shrink( aXPadding, aYPadding );
   331     rcInner.Shrink( aXPadding, aYPadding );
   330     aButton->SizeChanged( aRect, rcInner, aReloadImages );
   332     aButton->SizeChanged( aRect, rcInner, aReloadImages );
   331     }
   333     }
   332 
   334 
   333 void CPeninputArabicFingerHwrSymbolTable::OnActivate()
       
   334     {
       
   335     CControlGroup::OnActivate();
       
   336 	}
       
   337 
       
   338 // ---------------------------------------------------------------------------
   335 // ---------------------------------------------------------------------------
   339 //  Read control's background info.
   336 //  Read control's background info.
   340 // ---------------------------------------------------------------------------
   337 // ---------------------------------------------------------------------------
   341 //	
   338 //	
   342 void CPeninputArabicFingerHwrSymbolTable::ConstructFromResourceL()
   339 void CPeninputArabicFingerHwrSymbolTable::ConstructFromResourceL()
   420 // Load virtual keys image
   417 // Load virtual keys image
   421 // ---------------------------------------------------------------------------
   418 // ---------------------------------------------------------------------------
   422 //	
   419 //	
   423 void CPeninputArabicFingerHwrSymbolTable::LoadVkbKeyImageL(TInt aResId, const TSize& aKeySize)
   420 void CPeninputArabicFingerHwrSymbolTable::LoadVkbKeyImageL(TInt aResId, const TSize& aKeySize)
   424     {
   421     {
   425 	TResourceReader reader;    
   422     PeninputFingerHwrArVkbUtility::LoadVkbKeyImageL(*iMutiPageKeypad,aResId,aKeySize);	    
   426     CCoeEnv::Static()->CreateResourceReaderLC( reader, aResId );      
       
   427     
       
   428     TPtrC bmpFileName = reader.ReadTPtrC();
       
   429     TInt32 imgMajorSkinId = reader.ReadInt32();
       
   430     TAknsItemID id;
       
   431     
       
   432     TSize keySize = aKeySize;
       
   433     
       
   434     for ( TInt index = 0; index <= EKeyBmpLastType ; index += 2 )
       
   435         { 
       
   436         // Get the image ids and mask ids from resource
       
   437         TInt bmpId = reader.ReadInt16(); 
       
   438         TInt bmpMskId = reader.ReadInt16();
       
   439         
       
   440         // read skin item id
       
   441         const TInt skinitemid = reader.ReadInt16();
       
   442         id.Set( TInt( imgMajorSkinId ), skinitemid );
       
   443         
       
   444         if ( bmpId != KInvalidImg )
       
   445             {
       
   446             CFbsBitmap* bmp = NULL;
       
   447             CFbsBitmap* maskbmp = NULL;
       
   448 
       
   449             if ( bmpMskId != KInvalidImg )
       
   450                 {
       
   451                 AknsUtils::CreateIconL( AknsUtils::SkinInstance(),
       
   452                    id, bmp, maskbmp, bmpFileName, bmpId, bmpMskId );
       
   453                 
       
   454                 // set maskbmp and size
       
   455                 AknIconUtils::SetSize( maskbmp, keySize, EAspectRatioNotPreserved );
       
   456                 iMutiPageKeypad->SetNonIrregularKeyBitmapL( 
       
   457                 TVirtualKeyBmpType( EKeyBmpNormal + index + 1 ), maskbmp );
       
   458                 }
       
   459             else
       
   460                 {
       
   461                 AknsUtils::CreateIconL( AknsUtils::SkinInstance(), id, 
       
   462                     bmp, bmpFileName, bmpId );
       
   463                 }
       
   464             // set bmp and size
       
   465             AknIconUtils::SetSize( bmp, keySize, EAspectRatioNotPreserved );
       
   466             iMutiPageKeypad->SetNonIrregularKeyBitmapL( 
       
   467                 TVirtualKeyBmpType( EKeyBmpNormal + index ), bmp );
       
   468             }       
       
   469         }
       
   470     // Pop and destroy reader
       
   471     CleanupStack::PopAndDestroy( 1 );        
       
   472 	}
   423 	}
   473 
   424 
   474 // ---------------------------------------------------------------------------
   425 // ---------------------------------------------------------------------------
   475 // Load virtual keys
   426 // Load virtual keys
   476 // ---------------------------------------------------------------------------
   427 // ---------------------------------------------------------------------------
   477 //	
   428 //	
   478 void CPeninputArabicFingerHwrSymbolTable::LoadVirtualKeypadKeyL(const TInt aResId, const RArray<TRect>& aCellRects)
   429 void CPeninputArabicFingerHwrSymbolTable::LoadVirtualKeypadKeyL(const TInt aResId, const RArray<TRect>& aCellRects)
   479     {
   430     {
   480 	iMutiPageKeypad->SetResourceId(aResId);
   431 	PeninputFingerHwrArVkbUtility::LoadVirtualKeypadKeyL(*iMutiPageKeypad,aResId,aCellRects);
   481 	
   432 	}
   482 	TResourceReader reader;
       
   483     CCoeEnv::Static()->CreateResourceReaderLC( reader, aResId );
       
   484 
       
   485     // construct keys
       
   486     TInt resKeyCount = reader.ReadInt16();
       
   487     TInt existsKeyCount = iMutiPageKeypad->KeyArray().Count();
       
   488     TInt rectCount = aCellRects.Count();
       
   489     
       
   490     for ( TInt i = 0; i < resKeyCount; i++ )
       
   491         {
       
   492         if ( i < existsKeyCount )
       
   493             {
       
   494             CVirtualKey* vk = iMutiPageKeypad->KeyArray()[i];
       
   495             UpdateVkbKeyL( vk, reader, aCellRects[i%rectCount] );
       
   496             }
       
   497         else
       
   498             {
       
   499             CVirtualKey* vk = CreateVkbKeyL( reader, aCellRects[i%rectCount] );
       
   500             CleanupStack::PushL( vk );
       
   501             iMutiPageKeypad->AddKeyL( vk );
       
   502             
       
   503             CleanupStack::Pop( vk );
       
   504             }
       
   505         }
       
   506     
       
   507     CleanupStack::PopAndDestroy( 1 ); // reader
       
   508     
       
   509     iMutiPageKeypad->Draw();
       
   510     iMutiPageKeypad->UpdateArea( iMutiPageKeypad->Rect() );
       
   511 	}
       
   512 
       
   513 // ---------------------------------------------------------------------------
       
   514 // create virtual key.
       
   515 // ---------------------------------------------------------------------------
       
   516 //
       
   517 CVirtualKey* CPeninputArabicFingerHwrSymbolTable::CreateVkbKeyL( TResourceReader& aReader, 
       
   518     const TRect aKeyRect )
       
   519     {
       
   520     CHBufCArray* keytexts = CHBufCArray::NewL();
       
   521     CleanupStack::PushL( keytexts );
       
   522     
       
   523     for ( TInt i = 0; i <= EPosLast; i++ )
       
   524         {
       
   525         HBufC* unicode = aReader.ReadHBufCL();
       
   526         keytexts->Array().AppendL( unicode );
       
   527         }
       
   528 
       
   529     TInt keyscancode = aReader.ReadInt16();
       
   530 
       
   531     HBufC* text = keytexts->Array()[0];
       
   532     
       
   533     CVirtualKey* vk = NULL;
       
   534     if ( text )
       
   535         {
       
   536         vk = CVirtualKey::NewL( *text, keyscancode, aKeyRect, aKeyRect, 0 );
       
   537         }
       
   538     else 
       
   539         {
       
   540         vk = CVirtualKey::NewL( KNullDesC, keyscancode, aKeyRect, aKeyRect, 0 );
       
   541         }
       
   542 
       
   543     CleanupStack::PopAndDestroy( keytexts ); //keytexts
       
   544 
       
   545     
       
   546     TRect innerrect = aKeyRect;
       
   547     innerrect.Shrink( TSize(2, 2) );
       
   548     vk->SetInnerRect( innerrect );
       
   549     
       
   550     return vk;
       
   551     }
       
   552 
       
   553 // ---------------------------------------------------------------------------
       
   554 // update virtual key info.
       
   555 // ---------------------------------------------------------------------------
       
   556 //
       
   557 void CPeninputArabicFingerHwrSymbolTable::UpdateVkbKeyL( CVirtualKey* aVirtualKey, 
       
   558     TResourceReader& aReader, const TRect aKeyRect )
       
   559     {
       
   560     CHBufCArray* keytexts = CHBufCArray::NewL();
       
   561     CleanupStack::PushL( keytexts );
       
   562     
       
   563     for ( TInt i = 0; i <= EPosLast; i++ )
       
   564         {
       
   565         HBufC* unicode = aReader.ReadHBufCL();
       
   566         keytexts->Array().AppendL( unicode );
       
   567         }
       
   568 
       
   569     TInt keyscancode = aReader.ReadInt16();
       
   570 
       
   571     HBufC* text = keytexts->Array()[0];
       
   572     if ( text )
       
   573         {
       
   574         aVirtualKey->SetKeyData( *text );
       
   575         }
       
   576     else
       
   577         {
       
   578         aVirtualKey->SetKeyData( KNullDesC );
       
   579         }
       
   580     
       
   581     aVirtualKey->SetKeyScancode( keyscancode );
       
   582 
       
   583     CleanupStack::PopAndDestroy( keytexts ); //keytexts
       
   584 
       
   585     aVirtualKey->SetRect(aKeyRect);
       
   586     TRect innerrect = aKeyRect;
       
   587     innerrect.Shrink( TSize(2,2) );
       
   588     aVirtualKey->SetInnerRect( innerrect );
       
   589     }
       
   590 
   433 
   591 // ---------------------------------------------------------------------------
   434 // ---------------------------------------------------------------------------
   592 // Navigate the symbol page
   435 // Navigate the symbol page
   593 // ---------------------------------------------------------------------------
   436 // ---------------------------------------------------------------------------
   594 //
   437 //
   689 //
   532 //
   690 void CPeninputArabicFingerHwrSymbolTable::Draw()
   533 void CPeninputArabicFingerHwrSymbolTable::Draw()
   691     {
   534     {
   692 	if(AbleToDraw())
   535 	if(AbleToDraw())
   693         {
   536         {
   694         //Draw button area background.
       
   695 //		DrawOpaqueMaskBackground( Rect() );
       
   696 //	    DrawOpaqueMaskBackground();
       
   697         DrawOpaqueMaskBackground(iMutiPageKeypad->Rect());
   537         DrawOpaqueMaskBackground(iMutiPageKeypad->Rect());
   698 		if( BackgroundBmp() && BackgroundBmp()->SizeInPixels() != Rect().Size() )
   538 		if( BackgroundBmp() && BackgroundBmp()->SizeInPixels() != Rect().Size() )
   699 			{
   539 			{
   700 			AknIconUtils::SetSize(BackgroundBmp(), Rect().Size(), EAspectRatioNotPreserved);
   540 			AknIconUtils::SetSize(BackgroundBmp(), Rect().Size(), EAspectRatioNotPreserved);
   701 			}
   541 			}
   702         // draw background
   542         // draw background    
   703 //		DrawBackground();    
       
   704         DrawBackground(iMutiPageKeypad->Rect());
   543         DrawBackground(iMutiPageKeypad->Rect());
       
   544         
   705         // draw group		
   545         // draw group		
   706 		CControlGroup::Draw();
   546 		CControlGroup::Draw();
   707 		
   547 		
   708 		// bitblt the new content to screen
   548 		// bitblt the new content to screen
   709 		UpdateArea(iRect);
   549 		UpdateArea(iRect);