textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutvkb.cpp
branchRCL_3
changeset 44 ecbabf52600f
parent 43 ebd48d2de13c
equal deleted inserted replaced
43:ebd48d2de13c 44:ecbabf52600f
    25 #include "peninputlayoutbubblectrl.h"
    25 #include "peninputlayoutbubblectrl.h"
    26 #include "peninputlayoutvirtualkeyctrl.h"
    26 #include "peninputlayoutvirtualkeyctrl.h"
    27 #include "peninputlayoutvkb.h"
    27 #include "peninputlayoutvkb.h"
    28 #include "peninputpluginutils.h"
    28 #include "peninputpluginutils.h"
    29 
    29 
       
    30 #include "peninputvkbpreviewbubblerenderer.h"
    30 const TInt KFadingParamBlack = 128;
    31 const TInt KFadingParamBlack = 128;
    31 const TInt KFadingParamWhite = 192;
    32 const TInt KFadingParamWhite = 192;
    32 const TInt KDefaultBubbleSize = 50;
    33 const TInt KDefaultBubbleSize = 50;
    33 
    34 
    34 // ======== MEMBER FUNCTIONS ========
    35 // ======== MEMBER FUNCTIONS ========
    92                                 iFadingParamBlack(KFadingParamBlack),
    93                                 iFadingParamBlack(KFadingParamBlack),
    93                                 iFadingParamWhite(KFadingParamWhite),
    94                                 iFadingParamWhite(KFadingParamWhite),
    94                                 iKeyNormalSkinId(KAknsIIDNone),
    95                                 iKeyNormalSkinId(KAknsIIDNone),
    95                                 iKeyHighlightSkinId(KAknsIIDNone),
    96                                 iKeyHighlightSkinId(KAknsIIDNone),
    96                                 iKeyDimSkinId(KAknsIIDNone),
    97                                 iKeyDimSkinId(KAknsIIDNone),
    97                                 iNeedDrawBackground(ETrue),
       
    98                                 iIrregularKey(aIrregular),
    98                                 iIrregularKey(aIrregular),
    99                                 iBubbleCtrl(NULL),
    99                                 iBubbleCtrl(NULL),
   100                                 iBubbleVerticalMargin(0),                                
   100                                 iBubbleVerticalMargin(0),                                
   101                                 iKeyTextColorGroup(INVALID_COLOR_GROUP)
   101                                 iKeyTextColorGroup(INVALID_COLOR_GROUP)
   102     {
   102     {
   103     iFontSpec = aFontSpec;   
   103     iFontSpec = aFontSpec;   
   104     SetControlType(ECtrlVirtualKeyboard);
   104     SetControlType(ECtrlVirtualKeyboard);
       
   105     iBubbleSize = TSize( KDefaultBubbleSize, KDefaultBubbleSize );
   105     }
   106     }
   106     
   107     
   107 // ---------------------------------------------------------------------------
   108 // ---------------------------------------------------------------------------
   108 // CVirtualKeyboard::~CVirtualKeyboard
   109 // CVirtualKeyboard::~CVirtualKeyboard
   109 // Destructor
   110 // Destructor
   110 // ---------------------------------------------------------------------------
   111 // ---------------------------------------------------------------------------
   111 //
   112 //
   112 EXPORT_C CVirtualKeyboard::~CVirtualKeyboard()
   113 EXPORT_C CVirtualKeyboard::~CVirtualKeyboard()
   113     {
   114     {
       
   115     delete iExt;
   114     if ( iBubbleCtrl )
   116     if ( iBubbleCtrl )
   115         delete iBubbleCtrl;
   117         delete iBubbleCtrl;
       
   118     if ( iPreviewBubbleRenderer )
       
   119         {
       
   120         iPreviewBubbleRenderer->Detach();
       
   121         iPreviewBubbleRenderer = NULL;
       
   122         }
   116     
   123     
   117     //free keys
   124     //free keys
   118     iKeyArray.ResetAndDestroy();
   125     iKeyArray.ResetAndDestroy();
   119     iKeyArray.Close();
   126     iKeyArray.Close();
   120     
   127     
   148     iNonIrregularKeyBmpList.Close();
   155     iNonIrregularKeyBmpList.Close();
   149     
   156     
   150     DestroyIrregularBmps();
   157     DestroyIrregularBmps();
   151     
   158     
   152     delete iShiftIcon;
   159     delete iShiftIcon;
       
   160     delete iStarIcon;
   153     }
   161     }
   154 
   162 
   155 // ---------------------------------------------------------------------------
   163 // ---------------------------------------------------------------------------
   156 // CVirtualKeyboard::ConstructL
   164 // CVirtualKeyboard::ConstructL
   157 // 2nd phase constructor
   165 // 2nd phase constructor
   179         }
   187         }
   180         
   188         
   181     if (iIrregularKey)
   189     if (iIrregularKey)
   182         {
   190         {
   183         ConstructIrregularBmps();    
   191         ConstructIrregularBmps();    
   184         }        
   192         }  
       
   193     iExt = new(ELeave) CFepUiKeyboardExt;      
   185     }
   194     }
   186 
   195 
   187 // ---------------------------------------------------------------------------
   196 // ---------------------------------------------------------------------------
   188 // CVirtualKeyboard::AddKeyL
   197 // CVirtualKeyboard::AddKeyL
   189 // Add a key to key board
   198 // Add a key to key board
   197         
   206         
   198         //create key control
   207         //create key control
   199         CVirtualKeyCtrl* ctrl = CreateKeyCtrlL(aKey,EFalse);//CVirtualKeyCtrl::NewL(this,aKey);
   208         CVirtualKeyCtrl* ctrl = CreateKeyCtrlL(aKey,EFalse);//CVirtualKeyCtrl::NewL(this,aKey);
   200 #ifdef RD_TACTILE_FEEDBACK 
   209 #ifdef RD_TACTILE_FEEDBACK 
   201         //Advanced Tactile feedback REQ417-47932
   210         //Advanced Tactile feedback REQ417-47932
   202         ctrl->SetTactileFeedbackType(ETouchFeedbackSensitiveKeypad);
   211         ctrl->SetTactileFeedbackType(ETouchFeedbackSensitiveInput);
   203         UiLayout()->RegisterFeedbackArea(reinterpret_cast<TInt>(ctrl),ctrl->Rect(),ETouchFeedbackSensitiveKeypad);
   212         UiLayout()->RegisterFeedbackArea(reinterpret_cast<TInt>(ctrl),ctrl->Rect(),ETouchFeedbackSensitiveInput);
   204 #endif	  
   213 #endif	  
   205         CleanupStack::PushL(ctrl);
   214         CleanupStack::PushL(ctrl);
   206         AddKeyControlL(ctrl);
   215         AddKeyControlL(ctrl);
   207         CleanupStack::Pop();
   216         CleanupStack::Pop();
   208         if (aKey->ScanCode() == -1)
   217         if (aKey->ScanCode() == -1)
   226         //create key control
   235         //create key control
   227         //CVirtualRawKeyCtrl* ctrl = CVirtualRawKeyCtrl::NewL(this,aKey);
   236         //CVirtualRawKeyCtrl* ctrl = CVirtualRawKeyCtrl::NewL(this,aKey);
   228         CVirtualRawKeyCtrl* ctrl = static_cast<CVirtualRawKeyCtrl*>(CreateKeyCtrlL(aKey,ETrue));
   237         CVirtualRawKeyCtrl* ctrl = static_cast<CVirtualRawKeyCtrl*>(CreateKeyCtrlL(aKey,ETrue));
   229 #ifdef RD_TACTILE_FEEDBACK 
   238 #ifdef RD_TACTILE_FEEDBACK 
   230         //Advanced Tactile feedback REQ417-47932
   239         //Advanced Tactile feedback REQ417-47932
   231         ctrl->SetTactileFeedbackType(ETouchFeedbackSensitiveKeypad);
   240         ctrl->SetTactileFeedbackType(ETouchFeedbackSensitiveInput);
   232         UiLayout()->RegisterFeedbackArea(reinterpret_cast<TInt>(ctrl),ctrl->Rect(),ETouchFeedbackSensitiveKeypad);            
   241         UiLayout()->RegisterFeedbackArea(reinterpret_cast<TInt>(ctrl),ctrl->Rect(),ETouchFeedbackSensitiveInput);            
   233         
   242         
   234 #endif	        
   243 #endif	        
   235         CleanupStack::PushL(ctrl);
   244         CleanupStack::PushL(ctrl);
   236         AddKeyControlL(ctrl);
   245         AddKeyControlL(ctrl);
   237         CleanupStack::Pop();
   246         CleanupStack::Pop();
   377     {
   386     {
   378     if(!AbleToDraw())
   387     if(!AbleToDraw())
   379     	return;    
   388     	return;    
   380     const TRect& keyboardRect = Rect();
   389     const TRect& keyboardRect = Rect();
   381 
   390 
   382     if (iNeedDrawBackground)
   391     if(UiLayout()->NotDrawToLayoutDevice() && !Bitmap())
       
   392         {
       
   393         TRAP_IGNORE(CreateBmpDevL());
       
   394         }
       
   395 
       
   396     if ( NeedRedrawBg())
   383         {
   397         {
   384         CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
   398         CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
   385 
   399 
   386         //mask bitmaps
   400         //mask bitmaps
   387       if (!iIrregularKey)
   401       if (!iIrregularKey)
   439     {
   453     {
   440     if ( iBubbleCtrl )
   454     if ( iBubbleCtrl )
   441         {
   455         {
   442         iBubbleCtrl->Close();
   456         iBubbleCtrl->Close();
   443         }
   457         }
       
   458     if( iPreviewBubbleRenderer )
       
   459         {
       
   460         iPreviewBubbleRenderer->ClearBubble();
       
   461         }
   444     }
   462     }
   445 
   463 
   446 void CVirtualKeyboard::DrawBubble(CVirtualKey* aKey)
   464 void CVirtualKeyboard::DrawBubble(CVirtualKey* aKey)
   447     {
   465     {
       
   466     if( iPreviewBubbleRenderer )
       
   467         {
       
   468         if ( iIsShowBubble )
       
   469             {
       
   470             TPoint org = UiLayout()->Position();
       
   471             TPoint vkbpos = Rect().iTl;
       
   472             iPreviewBubbleRenderer->DrawBubble( aKey, vkbpos, org, iBubbleSize );
       
   473             }
       
   474         return;
       
   475         }
   448     
   476     
   449     if ( aKey && !aKey->Dimmed() && iBubbleCtrl && iIsShowBubble)
   477     if ( aKey && !aKey->Dimmed() && iBubbleCtrl && iIsShowBubble)
   450         {
   478         {
   451         TRect rect = iBubbleCtrl->Rect();
   479         TRect rect = iBubbleCtrl->Rect();
   452         TRect parentWndRect = Rect();       
   480         TRect parentWndRect = Rect();       
   464             }
   492             }
   465         else
   493         else
   466             {
   494             {
   467             rect.iTl.iX = x1;     
   495             rect.iTl.iX = x1;     
   468             rect.iBr.iX = x2;                 
   496             rect.iBr.iX = x2;                 
       
   497             
       
   498             TPoint vkbpos = Rect().iTl;
       
   499             rect.Move( vkbpos.iX, 0 );
   469             }
   500             }
   470         
   501         
   471         rect.iTl.iY = iBubbleVerticalMargin + aKey->Rect().iTl.iY - 
   502         rect.iTl.iY = iBubbleVerticalMargin + aKey->Rect().iTl.iY - 
   472                       iBubbleSize.iHeight + Rect().iTl.iY;
   503                       iBubbleSize.iHeight + Rect().iTl.iY;
   473         rect.iBr.iY = iBubbleVerticalMargin + aKey->Rect().iTl.iY + Rect().iTl.iY;
   504         rect.iBr.iY = iBubbleVerticalMargin + aKey->Rect().iTl.iY + Rect().iTl.iY;
   474 		
   505         
       
   506         TPoint org = UiLayout()->Position();
       
   507         rect.Move( org.iX, org.iY ); //now is in screen coord-sys
       
   508         
   475 		if( aKey->DisplayUnicode() && aKey->DisplayUnicode()->Length() != 0 )
   509 		if( aKey->DisplayUnicode() && aKey->DisplayUnicode()->Length() != 0 )
   476 			{
   510 			{
   477 			TRAP_IGNORE(iBubbleCtrl->SetTextL(*aKey->DisplayUnicode()));		
   511 			TRAP_IGNORE(iBubbleCtrl->SetTextL(*aKey->DisplayUnicode()));		
   478 			}
   512 			}
   479         else
   513         else
   483         iBubbleCtrl->Popup(rect);
   517         iBubbleCtrl->Popup(rect);
   484         }
   518         }
   485     }
   519     }
   486 
   520 
   487 EXPORT_C void CVirtualKeyboard::ShowBubble(TBool aFlag)
   521 EXPORT_C void CVirtualKeyboard::ShowBubble(TBool aFlag)
   488     {  
   522     {
       
   523     iIsShowBubble = aFlag;
       
   524 
       
   525     if( iPreviewBubbleRenderer )
       
   526         {
       
   527         iPreviewBubbleRenderer->ShowBubble( aFlag );
       
   528         return;
       
   529         }
   489     TBool flag = iBubbleCtrl ? ETrue : EFalse;
   530     TBool flag = iBubbleCtrl ? ETrue : EFalse;
   490     iIsShowBubble = aFlag;
       
   491     if ( flag != aFlag )
   531     if ( flag != aFlag )
   492         {
   532         {
   493         if(!flag)
   533         if(!flag)
   494             {
   534             {
   495             TRAP_IGNORE(iBubbleCtrl = CBubbleCtrl::NewL(TRect(0,0,0,0),UiLayout(),-0xFFFF));
   535             TRAP_IGNORE(iBubbleCtrl = CBubbleCtrl::NewL(TRect(0,0,0,0),UiLayout(),-0xFFFF));
       
   536             if(iBubbleCtrl && UiLayout()->NotDrawToLayoutDevice())
       
   537                 {
       
   538                 TRAP_IGNORE(iBubbleCtrl->CreateBmpDevL());
       
   539                 }
   496             iBubbleSize = TSize(KDefaultBubbleSize,KDefaultBubbleSize);
   540             iBubbleSize = TSize(KDefaultBubbleSize,KDefaultBubbleSize);
   497             }
   541             }
   498         }
   542         }
   499     }
   543     }
   500     
   544     
   514     {
   558     {
   515     if ( iBubbleCtrl )
   559     if ( iBubbleCtrl )
   516         {
   560         {
   517         iBubbleCtrl->SetBitmapParam(aBmpId,aMaskBmpId,aBgSkinId);
   561         iBubbleCtrl->SetBitmapParam(aBmpId,aMaskBmpId,aBgSkinId);
   518         }
   562         }
       
   563     if( iPreviewBubbleRenderer )
       
   564         {
       
   565         iPreviewBubbleRenderer->SetBubbleBitmapParam( aBmpId,aMaskBmpId,aBgSkinId );
       
   566         }
   519     }
   567     }
   520         
   568         
   521 EXPORT_C void CVirtualKeyboard::SetBubbleSize(const TSize& aSize)
   569 EXPORT_C void CVirtualKeyboard::SetBubbleSize(const TSize& aSize)
   522     {
   570     {
   523     iBubbleSize = aSize;
   571     iBubbleSize = aSize;
   532     {
   580     {
   533     if ( iBubbleCtrl )
   581     if ( iBubbleCtrl )
   534         {
   582         {
   535         iBubbleCtrl->SetTextFormat(aTextFormat);    
   583         iBubbleCtrl->SetTextFormat(aTextFormat);    
   536         }
   584         }
       
   585     if( iPreviewBubbleRenderer )
       
   586         {
       
   587         iPreviewBubbleRenderer->SetTextFormat( aTextFormat );
       
   588         }
   537     }
   589     }
   538 
   590 
   539 EXPORT_C void CVirtualKeyboard::SetFrameDiff(TInt aLeftDiff, TInt aTopDiff,
   591 EXPORT_C void CVirtualKeyboard::SetFrameDiff(TInt aLeftDiff, TInt aTopDiff,
   540                                              TInt aRightDiff,TInt aBottomDiff)
   592                                              TInt aRightDiff,TInt aBottomDiff)
   541     {
   593     {
   542     if ( iBubbleCtrl )
   594     if ( iBubbleCtrl )
   543         {
   595         {
   544         iBubbleCtrl->SetFrameDiff(aLeftDiff,aTopDiff,aRightDiff,aBottomDiff);    
   596         iBubbleCtrl->SetFrameDiff(aLeftDiff,aTopDiff,aRightDiff,aBottomDiff);    
   545         }        
   597         }
       
   598     if ( iPreviewBubbleRenderer )
       
   599         {
       
   600         iPreviewBubbleRenderer->SetFrameDiff( aLeftDiff, aTopDiff, aRightDiff, aBottomDiff );
       
   601         }
   546     }
   602     }
   547        
   603        
   548 EXPORT_C CFepUiBaseCtrl* CVirtualKeyboard::HandlePointerMoveEventL(const TPoint& aPt)
   604 EXPORT_C CFepUiBaseCtrl* CVirtualKeyboard::HandlePointerMoveEventL(const TPoint& aPt)
   549     {
   605     {
   550     if(iWndControl)
   606     if(iWndControl)
  1088 EXPORT_C void CVirtualKeyboard::SetShiftIcon( CPenInputColorIcon* aIcon )
  1144 EXPORT_C void CVirtualKeyboard::SetShiftIcon( CPenInputColorIcon* aIcon )
  1089 	{
  1145 	{
  1090 	delete iShiftIcon;
  1146 	delete iShiftIcon;
  1091 	iShiftIcon = aIcon;	
  1147 	iShiftIcon = aIcon;	
  1092 	}
  1148 	}
       
  1149 
       
  1150 EXPORT_C void CVirtualKeyboard::SetStarIcon( CPenInputColorIcon* aIcon )
       
  1151 	{
       
  1152 	delete iStarIcon;
       
  1153 	iStarIcon = aIcon;	
       
  1154 	}
       
  1155 
  1093 /*
  1156 /*
  1094 EXPORT_C CFepUiBaseCtrl* CVirtualKeyboard::HandlePointerDownEventL(const TPoint& aPoint)
  1157 EXPORT_C CFepUiBaseCtrl* CVirtualKeyboard::HandlePointerDownEventL(const TPoint& aPoint)
  1095     {
  1158     {
  1096     return CControlGroup::HandlePointerDownEventL(aPoint);
  1159     return CControlGroup::HandlePointerDownEventL(aPoint);
  1097     }
  1160     }
  1103 
  1166 
  1104 EXPORT_C CFepUiBaseCtrl* CVirtualKeyboard::HandlePointerMoveEventL(const TPoint& aPoint)
  1167 EXPORT_C CFepUiBaseCtrl* CVirtualKeyboard::HandlePointerMoveEventL(const TPoint& aPoint)
  1105     {
  1168     {
  1106     return CControlGroup::HandlePointerMoveEventL(aPoint);
  1169     return CControlGroup::HandlePointerMoveEventL(aPoint);
  1107     }
  1170     }
  1108     */				 
  1171     */
       
  1172 EXPORT_C void CVirtualKeyboard::SetPreviewBubbleRenderer( MPeninputVkbPreviewBubbleRenderer* aRenderer )
       
  1173     {
       
  1174     if ( ( NULL != aRenderer ) && ( aRenderer == iPreviewBubbleRenderer ) )
       
  1175         {
       
  1176         return;
       
  1177         }
       
  1178     
       
  1179     if( iPreviewBubbleRenderer )
       
  1180         {
       
  1181         iPreviewBubbleRenderer->Detach();
       
  1182         }
       
  1183     
       
  1184     iPreviewBubbleRenderer = aRenderer;
       
  1185     if ( aRenderer )
       
  1186         {
       
  1187         aRenderer->Attach();
       
  1188         }
       
  1189     }
  1109 //end of implementation of class CVirtualKeyboard
  1190 //end of implementation of class CVirtualKeyboard
  1110     
  1191     
  1111 // Implementation of Class CVirtualKey
  1192 // Implementation of Class CVirtualKey
  1112 
  1193 
  1113 // ---------------------------------------------------------------------------
  1194 // ---------------------------------------------------------------------------
  1266     iLatched = aFlag;
  1347     iLatched = aFlag;
  1267     if(iKeyCtrl)
  1348     if(iKeyCtrl)
  1268         {
  1349         {
  1269         //find key        
  1350         //find key        
  1270         //iKeyboard->DrawKey(this);
  1351         //iKeyboard->DrawKey(this);
       
  1352         if ( !aFlag )
       
  1353             {
       
  1354             iKeyCtrl->UpdateChangedArea(EFalse);
       
  1355             }
  1271         iKeyCtrl->Draw();
  1356         iKeyCtrl->Draw();
  1272         }
  1357         }
  1273     }
  1358     }
  1274 
  1359 
  1275 // ---------------------------------------------------------------------------
  1360 // ---------------------------------------------------------------------------
  1368     if ( iKeyCtrl )
  1453     if ( iKeyCtrl )
  1369         {
  1454         {
  1370         iKeyCtrl->Hide( aHide );
  1455         iKeyCtrl->Hide( aHide );
  1371         }
  1456         }
  1372     }
  1457     }
       
  1458 
       
  1459 void CFepUiKeyboardExt::CreateBmpDevL(const TDisplayMode &aMode )
       
  1460     {
       
  1461     if(iBitmap && iHighlightDev && iHighlightGc && iHighlightKeyBmp && iHighlightKeyDev && 
       
  1462             iNormalKeyBmp && iNormalKeyDev && iDimmedKeyBmp && iDimmedKeyDev && iKeyGc)
       
  1463         return;
       
  1464     
       
  1465     delete iBitmap;
       
  1466     delete iHighlightDev; 
       
  1467     delete iHighlightGc; 
       
  1468     delete iHighlightKeyBmp; 
       
  1469     delete iHighlightKeyDev; 
       
  1470     delete iNormalKeyBmp; 
       
  1471     delete iNormalKeyDev; 
       
  1472     delete iDimmedKeyBmp; 
       
  1473     delete iDimmedKeyDev;
       
  1474     delete iKeyGc;
       
  1475 
       
  1476     iBitmap = 0;
       
  1477     iHighlightDev = 0 ; 
       
  1478     iHighlightGc = 0 ; 
       
  1479     iHighlightKeyBmp = 0 ; 
       
  1480     iHighlightKeyDev = 0 ; 
       
  1481     iNormalKeyBmp = 0 ; 
       
  1482     iNormalKeyDev = 0 ; 
       
  1483     iDimmedKeyBmp = 0 ; 
       
  1484     iDimmedKeyDev = 0;
       
  1485     iKeyGc = 0;
       
  1486     
       
  1487     iBitmap = new ( ELeave ) CFbsBitmap;    
       
  1488     User::LeaveIfError( iBitmap->Create( TSize(1,1), aMode) );
       
  1489     
       
  1490     iHighlightDev = CFbsBitmapDevice::NewL(iBitmap);
       
  1491     
       
  1492     iHighlightGc = CFbsBitGc::NewL();
       
  1493     iHighlightGc->Reset();
       
  1494     
       
  1495 
       
  1496     iHighlightKeyBmp = new ( ELeave ) CFbsBitmap;    
       
  1497     User::LeaveIfError( iHighlightKeyBmp->Create( TSize(1,1), aMode) );    
       
  1498     iHighlightKeyDev = CFbsBitmapDevice::NewL(iHighlightKeyBmp);
       
  1499 
       
  1500     iNormalKeyBmp = new ( ELeave ) CFbsBitmap;    
       
  1501     User::LeaveIfError( iNormalKeyBmp->Create( TSize(1,1), aMode) );    
       
  1502     iNormalKeyDev = CFbsBitmapDevice::NewL(iNormalKeyBmp);
       
  1503 
       
  1504     iDimmedKeyBmp = new ( ELeave ) CFbsBitmap;    
       
  1505     User::LeaveIfError( iDimmedKeyBmp->Create( TSize(1,1), aMode) );    
       
  1506     iDimmedKeyDev = CFbsBitmapDevice::NewL(iDimmedKeyBmp);
       
  1507     
       
  1508     iKeyGc = CFbsBitGc::NewL();
       
  1509     iKeyGc->Reset();   
       
  1510     
       
  1511     iHighlightKeyResourceChanged = ETrue;
       
  1512     iNormalKeyResourceChanged = ETrue;   
       
  1513     }
       
  1514 
       
  1515 void CVirtualKeyboard::CreateBmpDevL()
       
  1516     {
       
  1517     iExt->CreateBmpDevL(UiLayout()->LayoutOwner()->BitmapDevice()->DisplayMode());
       
  1518     }
       
  1519 
       
  1520 EXPORT_C void CVirtualKeyboard::HandleResourceChange(TInt aType)
       
  1521     {
       
  1522     if(aType == KPenInputOwnDeviceChange)
       
  1523         {
       
  1524         if(UiLayout()->NotDrawToLayoutDevice())
       
  1525             {
       
  1526             TRAP_IGNORE(CreateBmpDevL());
       
  1527             }
       
  1528         }
       
  1529     else if(aType == KPenInputOwnDeviceResourceChange)
       
  1530         {
       
  1531         iExt->iHighlightKeyResourceChanged = ETrue;
       
  1532         iExt->iNormalKeyResourceChanged = ETrue;
       
  1533         }    
       
  1534     else
       
  1535     	{
       
  1536         CControlGroup::HandleResourceChange(aType);
       
  1537         }
       
  1538     }
       
  1539     
       
  1540 CFbsBitmap* CVirtualKeyboard::PrepareMaskBmpL(CFbsBitGc* aGc, const TDisplayMode& aMode, const TRect& aRect)
       
  1541     {
       
  1542     CFbsBitmap* mask = new(ELeave) CFbsBitmap();
       
  1543     CleanupStack::PushL(mask);
       
  1544     User::LeaveIfError( mask->Create( aRect.Size(), aMode) );
       
  1545     CFbsBitmapDevice* maskDev = CFbsBitmapDevice::NewL(mask);
       
  1546     const TRgb KOpaqueMask = TRgb(KOpaqueColor);
       
  1547     DrawBackgroundToDevice(aRect,maskDev,NULL,KOpaqueMask,KOpaqueMask,EFalse);
       
  1548     delete maskDev;
       
  1549     CleanupStack::Pop(mask);
       
  1550     return mask;
       
  1551     }
       
  1552 CFbsBitmap* CVirtualKeyboard::PrepareKeyBmpL(CFbsBitGc* aGc, const TDisplayMode& aMode, const TRect& aRect,
       
  1553         const TRect& aInnerRect,const TAknsItemID& aFrameID, const TAknsItemID& aCenterID, const TRect& aKeyRect)
       
  1554     {
       
  1555     CFbsBitmap* key = new(ELeave) CFbsBitmap();
       
  1556     CleanupStack::PushL(key);
       
  1557     User::LeaveIfError( key->Create( aRect.Size(), aMode) );
       
  1558     
       
  1559     CFbsBitmapDevice* dev = CFbsBitmapDevice::NewL(key);
       
  1560     CleanupStack::PushL(dev);
       
  1561     
       
  1562     CFbsBitGc* keyGc = CFbsBitGc::NewL();
       
  1563     keyGc->Reset();
       
  1564     CleanupStack::PushL(keyGc);
       
  1565     
       
  1566     keyGc->Activate(dev);
       
  1567     
       
  1568     CFbsBitGc* layoutGc = static_cast<CFbsBitGc*>(
       
  1569                             UiLayout()->LayoutOwner()->BitmapContext());
       
  1570     layoutGc->Activate(UiLayout()->LayoutOwner()->BitmapDevice()); 
       
  1571     
       
  1572     keyGc->BitBlt(TPoint(0,0),*layoutGc,aKeyRect);
       
  1573     
       
  1574     AknsDrawUtils::DrawFrame(AknsUtils::SkinInstance(), 
       
  1575                              *keyGc, 
       
  1576                              aRect, 
       
  1577                              aInnerRect,
       
  1578                              aFrameID, 
       
  1579                              aCenterID);
       
  1580 
       
  1581     layoutGc->Activate(UiLayout()->LayoutOwner()->BitmapDevice());    
       
  1582     
       
  1583     CleanupStack::PopAndDestroy(2);
       
  1584     CleanupStack::Pop(key);
       
  1585     
       
  1586     return key;
       
  1587     }
       
  1588 
       
  1589 TBool CVirtualKeyboard::PrepareKeyBmp(CFbsBitmap* aBmp,CFbsBitmapDevice* aDev,const TRect& aRect, 
       
  1590                         const TRect& aInnerRect,const TAknsItemID& aFrameID, const TAknsItemID& aCenterID, const TRect& aKeyRect)
       
  1591     {
       
  1592 
       
  1593     aBmp->Resize(aRect.Size());
       
  1594     aDev->Resize(aRect.Size());
       
  1595     iExt->iKeyGc->Activate(aDev);
       
  1596     iExt->iKeyGc->Resized();        
       
  1597 
       
  1598     TRect r = aRect;
       
  1599     r.Move(-r.iTl.iX, -r.iTl.iY);
       
  1600    
       
  1601     CFbsBitmap* keyBmp = NULL;
       
  1602     TRect inner = aInnerRect;
       
  1603     TPoint off = aInnerRect.iTl - aRect.iTl;
       
  1604     inner.Move(-inner.iTl.iX + off.iX, -inner.iTl.iY + off.iY);
       
  1605     TRAP_IGNORE(keyBmp = PrepareKeyBmpL(iExt->iKeyGc,
       
  1606                         UiLayout()->LayoutOwner()->BitmapDevice()->DisplayMode(),
       
  1607                         r,inner,aFrameID,aCenterID,aKeyRect));
       
  1608     if(!keyBmp)
       
  1609         {
       
  1610         return EFalse;
       
  1611         }
       
  1612 
       
  1613     iExt->iKeyGc->BitBlt(TPoint(0,0), keyBmp,r);      
       
  1614 
       
  1615     delete keyBmp;        
       
  1616     return ETrue;
       
  1617     }
       
  1618 
       
  1619 TBool CVirtualKeyboard::PrepareHighlightKeyBmp(const TRect& aRect, const TRect& aInnerRect, const TRect& aKeyRect)
       
  1620     {
       
  1621     if(HighightKeyBmp()->SizeInPixels() != aRect.Size() || iExt->iHighlightKeyResourceChanged)
       
  1622         {
       
  1623         iExt->iHighlightKeyResourceChanged = EFalse;
       
  1624         return PrepareKeyBmp(HighightKeyBmp(),HighlightKeyDev(),aRect,aInnerRect
       
  1625                                 ,KeySkinId(EKeyBmpHighlight),KAknsIIDDefault,aKeyRect);
       
  1626         
       
  1627         }
       
  1628     
       
  1629     return ETrue;
       
  1630     }
       
  1631     
       
  1632 TBool CVirtualKeyboard::PrepareNormalKeyBmp(const TRect& aRect, const TRect& aInnerRect, const TRect& aKeyRect)
       
  1633     {
       
  1634     if(NormalKeyBmp()->SizeInPixels() != aRect.Size() || iExt->iNormalKeyResourceChanged)
       
  1635         {
       
  1636         iExt->iNormalKeyResourceChanged = EFalse; 
       
  1637         return PrepareKeyBmp(NormalKeyBmp(),NormalKeyDev(),aRect,aInnerRect
       
  1638                             ,KeySkinId(EKeyBmpNormal),KAknsIIDDefault,aKeyRect);
       
  1639                            
       
  1640         }
       
  1641         
       
  1642     return ETrue;
       
  1643     }
       
  1644         
  1373 //end of implementation of Class CVirtualKey    
  1645 //end of implementation of Class CVirtualKey