textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutvkb.cpp
branchRCL_3
changeset 20 ebd48d2de13c
parent 18 b1ea1642412e
child 21 ecbabf52600f
equal deleted inserted replaced
19:ac7e4d1d9209 20:ebd48d2de13c
    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"
       
    31 const TInt KFadingParamBlack = 128;
    30 const TInt KFadingParamBlack = 128;
    32 const TInt KFadingParamWhite = 192;
    31 const TInt KFadingParamWhite = 192;
    33 const TInt KDefaultBubbleSize = 50;
    32 const TInt KDefaultBubbleSize = 50;
    34 
    33 
    35 // ======== MEMBER FUNCTIONS ========
    34 // ======== MEMBER FUNCTIONS ========
    93                                 iFadingParamBlack(KFadingParamBlack),
    92                                 iFadingParamBlack(KFadingParamBlack),
    94                                 iFadingParamWhite(KFadingParamWhite),
    93                                 iFadingParamWhite(KFadingParamWhite),
    95                                 iKeyNormalSkinId(KAknsIIDNone),
    94                                 iKeyNormalSkinId(KAknsIIDNone),
    96                                 iKeyHighlightSkinId(KAknsIIDNone),
    95                                 iKeyHighlightSkinId(KAknsIIDNone),
    97                                 iKeyDimSkinId(KAknsIIDNone),
    96                                 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 );
       
   106     }
   105     }
   107     
   106     
   108 // ---------------------------------------------------------------------------
   107 // ---------------------------------------------------------------------------
   109 // CVirtualKeyboard::~CVirtualKeyboard
   108 // CVirtualKeyboard::~CVirtualKeyboard
   110 // Destructor
   109 // Destructor
   111 // ---------------------------------------------------------------------------
   110 // ---------------------------------------------------------------------------
   112 //
   111 //
   113 EXPORT_C CVirtualKeyboard::~CVirtualKeyboard()
   112 EXPORT_C CVirtualKeyboard::~CVirtualKeyboard()
   114     {
   113     {
   115     delete iExt;
       
   116     if ( iBubbleCtrl )
   114     if ( iBubbleCtrl )
   117         delete iBubbleCtrl;
   115         delete iBubbleCtrl;
   118     if ( iPreviewBubbleRenderer )
       
   119         {
       
   120         iPreviewBubbleRenderer->Detach();
       
   121         iPreviewBubbleRenderer = NULL;
       
   122         }
       
   123     
   116     
   124     //free keys
   117     //free keys
   125     iKeyArray.ResetAndDestroy();
   118     iKeyArray.ResetAndDestroy();
   126     iKeyArray.Close();
   119     iKeyArray.Close();
   127     
   120     
   155     iNonIrregularKeyBmpList.Close();
   148     iNonIrregularKeyBmpList.Close();
   156     
   149     
   157     DestroyIrregularBmps();
   150     DestroyIrregularBmps();
   158     
   151     
   159     delete iShiftIcon;
   152     delete iShiftIcon;
   160     delete iStarIcon;
       
   161     }
   153     }
   162 
   154 
   163 // ---------------------------------------------------------------------------
   155 // ---------------------------------------------------------------------------
   164 // CVirtualKeyboard::ConstructL
   156 // CVirtualKeyboard::ConstructL
   165 // 2nd phase constructor
   157 // 2nd phase constructor
   187         }
   179         }
   188         
   180         
   189     if (iIrregularKey)
   181     if (iIrregularKey)
   190         {
   182         {
   191         ConstructIrregularBmps();    
   183         ConstructIrregularBmps();    
   192         }  
   184         }        
   193     iExt = new(ELeave) CFepUiKeyboardExt;      
       
   194     }
   185     }
   195 
   186 
   196 // ---------------------------------------------------------------------------
   187 // ---------------------------------------------------------------------------
   197 // CVirtualKeyboard::AddKeyL
   188 // CVirtualKeyboard::AddKeyL
   198 // Add a key to key board
   189 // Add a key to key board
   206         
   197         
   207         //create key control
   198         //create key control
   208         CVirtualKeyCtrl* ctrl = CreateKeyCtrlL(aKey,EFalse);//CVirtualKeyCtrl::NewL(this,aKey);
   199         CVirtualKeyCtrl* ctrl = CreateKeyCtrlL(aKey,EFalse);//CVirtualKeyCtrl::NewL(this,aKey);
   209 #ifdef RD_TACTILE_FEEDBACK 
   200 #ifdef RD_TACTILE_FEEDBACK 
   210         //Advanced Tactile feedback REQ417-47932
   201         //Advanced Tactile feedback REQ417-47932
   211         ctrl->SetTactileFeedbackType(ETouchFeedbackSensitiveInput);
   202         ctrl->SetTactileFeedbackType(ETouchFeedbackSensitiveKeypad);
   212         UiLayout()->RegisterFeedbackArea(reinterpret_cast<TInt>(ctrl),ctrl->Rect(),ETouchFeedbackSensitiveInput);
   203         UiLayout()->RegisterFeedbackArea(reinterpret_cast<TInt>(ctrl),ctrl->Rect(),ETouchFeedbackSensitiveKeypad);
   213 #endif	  
   204 #endif	  
   214         CleanupStack::PushL(ctrl);
   205         CleanupStack::PushL(ctrl);
   215         AddKeyControlL(ctrl);
   206         AddKeyControlL(ctrl);
   216         CleanupStack::Pop();
   207         CleanupStack::Pop();
   217         if (aKey->ScanCode() == -1)
   208         if (aKey->ScanCode() == -1)
   235         //create key control
   226         //create key control
   236         //CVirtualRawKeyCtrl* ctrl = CVirtualRawKeyCtrl::NewL(this,aKey);
   227         //CVirtualRawKeyCtrl* ctrl = CVirtualRawKeyCtrl::NewL(this,aKey);
   237         CVirtualRawKeyCtrl* ctrl = static_cast<CVirtualRawKeyCtrl*>(CreateKeyCtrlL(aKey,ETrue));
   228         CVirtualRawKeyCtrl* ctrl = static_cast<CVirtualRawKeyCtrl*>(CreateKeyCtrlL(aKey,ETrue));
   238 #ifdef RD_TACTILE_FEEDBACK 
   229 #ifdef RD_TACTILE_FEEDBACK 
   239         //Advanced Tactile feedback REQ417-47932
   230         //Advanced Tactile feedback REQ417-47932
   240         ctrl->SetTactileFeedbackType(ETouchFeedbackSensitiveInput);
   231         ctrl->SetTactileFeedbackType(ETouchFeedbackSensitiveKeypad);
   241         UiLayout()->RegisterFeedbackArea(reinterpret_cast<TInt>(ctrl),ctrl->Rect(),ETouchFeedbackSensitiveInput);            
   232         UiLayout()->RegisterFeedbackArea(reinterpret_cast<TInt>(ctrl),ctrl->Rect(),ETouchFeedbackSensitiveKeypad);            
   242         
   233         
   243 #endif	        
   234 #endif	        
   244         CleanupStack::PushL(ctrl);
   235         CleanupStack::PushL(ctrl);
   245         AddKeyControlL(ctrl);
   236         AddKeyControlL(ctrl);
   246         CleanupStack::Pop();
   237         CleanupStack::Pop();
   386     {
   377     {
   387     if(!AbleToDraw())
   378     if(!AbleToDraw())
   388     	return;    
   379     	return;    
   389     const TRect& keyboardRect = Rect();
   380     const TRect& keyboardRect = Rect();
   390 
   381 
   391     if(UiLayout()->NotDrawToLayoutDevice() && !Bitmap())
   382     if (iNeedDrawBackground)
   392         {
       
   393         TRAP_IGNORE(CreateBmpDevL());
       
   394         }
       
   395 
       
   396     if ( NeedRedrawBg())
       
   397         {
   383         {
   398         CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
   384         CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
   399 
   385 
   400         //mask bitmaps
   386         //mask bitmaps
   401       if (!iIrregularKey)
   387       if (!iIrregularKey)
   453     {
   439     {
   454     if ( iBubbleCtrl )
   440     if ( iBubbleCtrl )
   455         {
   441         {
   456         iBubbleCtrl->Close();
   442         iBubbleCtrl->Close();
   457         }
   443         }
   458     if( iPreviewBubbleRenderer )
       
   459         {
       
   460         iPreviewBubbleRenderer->ClearBubble();
       
   461         }
       
   462     }
   444     }
   463 
   445 
   464 void CVirtualKeyboard::DrawBubble(CVirtualKey* aKey)
   446 void CVirtualKeyboard::DrawBubble(CVirtualKey* aKey)
   465     {
   447     {
   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         }
       
   476     
   448     
   477     if ( aKey && !aKey->Dimmed() && iBubbleCtrl && iIsShowBubble)
   449     if ( aKey && !aKey->Dimmed() && iBubbleCtrl && iIsShowBubble)
   478         {
   450         {
   479         TRect rect = iBubbleCtrl->Rect();
   451         TRect rect = iBubbleCtrl->Rect();
   480         TRect parentWndRect = Rect();       
   452         TRect parentWndRect = Rect();       
   492             }
   464             }
   493         else
   465         else
   494             {
   466             {
   495             rect.iTl.iX = x1;     
   467             rect.iTl.iX = x1;     
   496             rect.iBr.iX = x2;                 
   468             rect.iBr.iX = x2;                 
   497             
       
   498             TPoint vkbpos = Rect().iTl;
       
   499             rect.Move( vkbpos.iX, 0 );
       
   500             }
   469             }
   501         
   470         
   502         rect.iTl.iY = iBubbleVerticalMargin + aKey->Rect().iTl.iY - 
   471         rect.iTl.iY = iBubbleVerticalMargin + aKey->Rect().iTl.iY - 
   503                       iBubbleSize.iHeight + Rect().iTl.iY;
   472                       iBubbleSize.iHeight + Rect().iTl.iY;
   504         rect.iBr.iY = iBubbleVerticalMargin + aKey->Rect().iTl.iY + Rect().iTl.iY;
   473         rect.iBr.iY = iBubbleVerticalMargin + aKey->Rect().iTl.iY + Rect().iTl.iY;
   505         
   474 		
   506         TPoint org = UiLayout()->Position();
       
   507         rect.Move( org.iX, org.iY ); //now is in screen coord-sys
       
   508         
       
   509 		if( aKey->DisplayUnicode() && aKey->DisplayUnicode()->Length() != 0 )
   475 		if( aKey->DisplayUnicode() && aKey->DisplayUnicode()->Length() != 0 )
   510 			{
   476 			{
   511 			TRAP_IGNORE(iBubbleCtrl->SetTextL(*aKey->DisplayUnicode()));		
   477 			TRAP_IGNORE(iBubbleCtrl->SetTextL(*aKey->DisplayUnicode()));		
   512 			}
   478 			}
   513         else
   479         else
   517         iBubbleCtrl->Popup(rect);
   483         iBubbleCtrl->Popup(rect);
   518         }
   484         }
   519     }
   485     }
   520 
   486 
   521 EXPORT_C void CVirtualKeyboard::ShowBubble(TBool aFlag)
   487 EXPORT_C void CVirtualKeyboard::ShowBubble(TBool aFlag)
   522     {
   488     {  
       
   489     TBool flag = iBubbleCtrl ? ETrue : EFalse;
   523     iIsShowBubble = aFlag;
   490     iIsShowBubble = aFlag;
   524 
       
   525     if( iPreviewBubbleRenderer )
       
   526         {
       
   527         iPreviewBubbleRenderer->ShowBubble( aFlag );
       
   528         return;
       
   529         }
       
   530     TBool flag = iBubbleCtrl ? ETrue : EFalse;
       
   531     if ( flag != aFlag )
   491     if ( flag != aFlag )
   532         {
   492         {
   533         if(!flag)
   493         if(!flag)
   534             {
   494             {
   535             TRAP_IGNORE(iBubbleCtrl = CBubbleCtrl::NewL(TRect(0,0,0,0),UiLayout(),-0xFFFF));
   495             TRAP_IGNORE(iBubbleCtrl = CBubbleCtrl::NewL(TRect(0,0,0,0),UiLayout(),-0xFFFF));
   536             if(iBubbleCtrl && UiLayout()->NotDrawToLayoutDevice())
       
   537                 {
       
   538                 TRAP_IGNORE(iBubbleCtrl->CreateBmpDevL());
       
   539                 }
       
   540             iBubbleSize = TSize(KDefaultBubbleSize,KDefaultBubbleSize);
   496             iBubbleSize = TSize(KDefaultBubbleSize,KDefaultBubbleSize);
   541             }
   497             }
   542         }
   498         }
   543     }
   499     }
   544     
   500     
   558     {
   514     {
   559     if ( iBubbleCtrl )
   515     if ( iBubbleCtrl )
   560         {
   516         {
   561         iBubbleCtrl->SetBitmapParam(aBmpId,aMaskBmpId,aBgSkinId);
   517         iBubbleCtrl->SetBitmapParam(aBmpId,aMaskBmpId,aBgSkinId);
   562         }
   518         }
   563     if( iPreviewBubbleRenderer )
       
   564         {
       
   565         iPreviewBubbleRenderer->SetBubbleBitmapParam( aBmpId,aMaskBmpId,aBgSkinId );
       
   566         }
       
   567     }
   519     }
   568         
   520         
   569 EXPORT_C void CVirtualKeyboard::SetBubbleSize(const TSize& aSize)
   521 EXPORT_C void CVirtualKeyboard::SetBubbleSize(const TSize& aSize)
   570     {
   522     {
   571     iBubbleSize = aSize;
   523     iBubbleSize = aSize;
   580     {
   532     {
   581     if ( iBubbleCtrl )
   533     if ( iBubbleCtrl )
   582         {
   534         {
   583         iBubbleCtrl->SetTextFormat(aTextFormat);    
   535         iBubbleCtrl->SetTextFormat(aTextFormat);    
   584         }
   536         }
   585     if( iPreviewBubbleRenderer )
       
   586         {
       
   587         iPreviewBubbleRenderer->SetTextFormat( aTextFormat );
       
   588         }
       
   589     }
   537     }
   590 
   538 
   591 EXPORT_C void CVirtualKeyboard::SetFrameDiff(TInt aLeftDiff, TInt aTopDiff,
   539 EXPORT_C void CVirtualKeyboard::SetFrameDiff(TInt aLeftDiff, TInt aTopDiff,
   592                                              TInt aRightDiff,TInt aBottomDiff)
   540                                              TInt aRightDiff,TInt aBottomDiff)
   593     {
   541     {
   594     if ( iBubbleCtrl )
   542     if ( iBubbleCtrl )
   595         {
   543         {
   596         iBubbleCtrl->SetFrameDiff(aLeftDiff,aTopDiff,aRightDiff,aBottomDiff);    
   544         iBubbleCtrl->SetFrameDiff(aLeftDiff,aTopDiff,aRightDiff,aBottomDiff);    
   597         }
   545         }        
   598     if ( iPreviewBubbleRenderer )
       
   599         {
       
   600         iPreviewBubbleRenderer->SetFrameDiff( aLeftDiff, aTopDiff, aRightDiff, aBottomDiff );
       
   601         }
       
   602     }
   546     }
   603        
   547        
   604 EXPORT_C CFepUiBaseCtrl* CVirtualKeyboard::HandlePointerMoveEventL(const TPoint& aPt)
   548 EXPORT_C CFepUiBaseCtrl* CVirtualKeyboard::HandlePointerMoveEventL(const TPoint& aPt)
   605     {
   549     {
   606     if(iWndControl)
   550     if(iWndControl)
  1144 EXPORT_C void CVirtualKeyboard::SetShiftIcon( CPenInputColorIcon* aIcon )
  1088 EXPORT_C void CVirtualKeyboard::SetShiftIcon( CPenInputColorIcon* aIcon )
  1145 	{
  1089 	{
  1146 	delete iShiftIcon;
  1090 	delete iShiftIcon;
  1147 	iShiftIcon = aIcon;	
  1091 	iShiftIcon = aIcon;	
  1148 	}
  1092 	}
  1149 
       
  1150 EXPORT_C void CVirtualKeyboard::SetStarIcon( CPenInputColorIcon* aIcon )
       
  1151 	{
       
  1152 	delete iStarIcon;
       
  1153 	iStarIcon = aIcon;	
       
  1154 	}
       
  1155 
       
  1156 /*
  1093 /*
  1157 EXPORT_C CFepUiBaseCtrl* CVirtualKeyboard::HandlePointerDownEventL(const TPoint& aPoint)
  1094 EXPORT_C CFepUiBaseCtrl* CVirtualKeyboard::HandlePointerDownEventL(const TPoint& aPoint)
  1158     {
  1095     {
  1159     return CControlGroup::HandlePointerDownEventL(aPoint);
  1096     return CControlGroup::HandlePointerDownEventL(aPoint);
  1160     }
  1097     }
  1166 
  1103 
  1167 EXPORT_C CFepUiBaseCtrl* CVirtualKeyboard::HandlePointerMoveEventL(const TPoint& aPoint)
  1104 EXPORT_C CFepUiBaseCtrl* CVirtualKeyboard::HandlePointerMoveEventL(const TPoint& aPoint)
  1168     {
  1105     {
  1169     return CControlGroup::HandlePointerMoveEventL(aPoint);
  1106     return CControlGroup::HandlePointerMoveEventL(aPoint);
  1170     }
  1107     }
  1171     */
  1108     */				 
  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     }
       
  1190 //end of implementation of class CVirtualKeyboard
  1109 //end of implementation of class CVirtualKeyboard
  1191     
  1110     
  1192 // Implementation of Class CVirtualKey
  1111 // Implementation of Class CVirtualKey
  1193 
  1112 
  1194 // ---------------------------------------------------------------------------
  1113 // ---------------------------------------------------------------------------
  1347     iLatched = aFlag;
  1266     iLatched = aFlag;
  1348     if(iKeyCtrl)
  1267     if(iKeyCtrl)
  1349         {
  1268         {
  1350         //find key        
  1269         //find key        
  1351         //iKeyboard->DrawKey(this);
  1270         //iKeyboard->DrawKey(this);
  1352         if ( !aFlag )
       
  1353             {
       
  1354             iKeyCtrl->UpdateChangedArea(EFalse);
       
  1355             }
       
  1356         iKeyCtrl->Draw();
  1271         iKeyCtrl->Draw();
  1357         }
  1272         }
  1358     }
  1273     }
  1359 
  1274 
  1360 // ---------------------------------------------------------------------------
  1275 // ---------------------------------------------------------------------------
  1453     if ( iKeyCtrl )
  1368     if ( iKeyCtrl )
  1454         {
  1369         {
  1455         iKeyCtrl->Hide( aHide );
  1370         iKeyCtrl->Hide( aHide );
  1456         }
  1371         }
  1457     }
  1372     }
  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         
       
  1645 //end of implementation of Class CVirtualKey    
  1373 //end of implementation of Class CVirtualKey