textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutvkb.cpp
branchRCL_3
changeset 19 5e18d8c489d6
parent 12 4eb1ae11334f
child 22 1bbdde98cc2d
equal deleted inserted replaced
18:c8fb4cf7b3ae 19:5e18d8c489d6
    93                                 iFadingParamBlack(KFadingParamBlack),
    93                                 iFadingParamBlack(KFadingParamBlack),
    94                                 iFadingParamWhite(KFadingParamWhite),
    94                                 iFadingParamWhite(KFadingParamWhite),
    95                                 iKeyNormalSkinId(KAknsIIDNone),
    95                                 iKeyNormalSkinId(KAknsIIDNone),
    96                                 iKeyHighlightSkinId(KAknsIIDNone),
    96                                 iKeyHighlightSkinId(KAknsIIDNone),
    97                                 iKeyDimSkinId(KAknsIIDNone),
    97                                 iKeyDimSkinId(KAknsIIDNone),
    98                                 iNeedDrawBackground(ETrue),
       
    99                                 iIrregularKey(aIrregular),
    98                                 iIrregularKey(aIrregular),
   100                                 iBubbleCtrl(NULL),
    99                                 iBubbleCtrl(NULL),
   101                                 iBubbleVerticalMargin(0),                                
   100                                 iBubbleVerticalMargin(0),                                
   102                                 iKeyTextColorGroup(INVALID_COLOR_GROUP)
   101                                 iKeyTextColorGroup(INVALID_COLOR_GROUP)
   103     {
   102     {
   111 // Destructor
   110 // Destructor
   112 // ---------------------------------------------------------------------------
   111 // ---------------------------------------------------------------------------
   113 //
   112 //
   114 EXPORT_C CVirtualKeyboard::~CVirtualKeyboard()
   113 EXPORT_C CVirtualKeyboard::~CVirtualKeyboard()
   115     {
   114     {
       
   115     delete iExt;
   116     if ( iBubbleCtrl )
   116     if ( iBubbleCtrl )
   117         delete iBubbleCtrl;
   117         delete iBubbleCtrl;
   118     if ( iPreviewBubbleRenderer )
   118     if ( iPreviewBubbleRenderer )
   119         {
   119         {
   120         iPreviewBubbleRenderer->Detach();
   120         iPreviewBubbleRenderer->Detach();
   187         }
   187         }
   188         
   188         
   189     if (iIrregularKey)
   189     if (iIrregularKey)
   190         {
   190         {
   191         ConstructIrregularBmps();    
   191         ConstructIrregularBmps();    
   192         }        
   192         }  
       
   193     iExt = new(ELeave) CFepUiKeyboardExt;      
   193     }
   194     }
   194 
   195 
   195 // ---------------------------------------------------------------------------
   196 // ---------------------------------------------------------------------------
   196 // CVirtualKeyboard::AddKeyL
   197 // CVirtualKeyboard::AddKeyL
   197 // Add a key to key board
   198 // Add a key to key board
   385     {
   386     {
   386     if(!AbleToDraw())
   387     if(!AbleToDraw())
   387     	return;    
   388     	return;    
   388     const TRect& keyboardRect = Rect();
   389     const TRect& keyboardRect = Rect();
   389 
   390 
   390     if (iNeedDrawBackground)
   391     if(UiLayout()->NotDrawToLayoutDevice() && !Bitmap())
       
   392         {
       
   393         TRAP_IGNORE(CreateBmpDevL());
       
   394         }
       
   395 
       
   396     if ( NeedRedrawBg())
   391         {
   397         {
   392         CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
   398         CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
   393 
   399 
   394         //mask bitmaps
   400         //mask bitmaps
   395       if (!iIrregularKey)
   401       if (!iIrregularKey)
   525     if ( flag != aFlag )
   531     if ( flag != aFlag )
   526         {
   532         {
   527         if(!flag)
   533         if(!flag)
   528             {
   534             {
   529             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                 iBubbleCtrl->CreateBmpDevL();
       
   539                 }
   530             iBubbleSize = TSize(KDefaultBubbleSize,KDefaultBubbleSize);
   540             iBubbleSize = TSize(KDefaultBubbleSize,KDefaultBubbleSize);
   531             }
   541             }
   532         }
   542         }
   533     }
   543     }
   534     
   544     
  1439     if ( iKeyCtrl )
  1449     if ( iKeyCtrl )
  1440         {
  1450         {
  1441         iKeyCtrl->Hide( aHide );
  1451         iKeyCtrl->Hide( aHide );
  1442         }
  1452         }
  1443     }
  1453     }
       
  1454 
       
  1455 void CFepUiKeyboardExt::CreateBmpDevL(const TDisplayMode &aMode )
       
  1456     {
       
  1457     if(iBitmap && iHighlightDev && iHighlightGc && iHighlightKeyBmp && iHighlightKeyDev && 
       
  1458             iNormalKeyBmp && iNormalKeyDev && iDimmedKeyBmp && iDimmedKeyDev && iKeyGc)
       
  1459         return;
       
  1460     
       
  1461     delete iBitmap;
       
  1462     delete iHighlightDev; 
       
  1463     delete iHighlightGc; 
       
  1464     delete iHighlightKeyBmp; 
       
  1465     delete iHighlightKeyDev; 
       
  1466     delete iNormalKeyBmp; 
       
  1467     delete iNormalKeyDev; 
       
  1468     delete iDimmedKeyBmp; 
       
  1469     delete iDimmedKeyDev;
       
  1470     delete iKeyGc;
       
  1471 
       
  1472     iBitmap = 0;
       
  1473     iHighlightDev = 0 ; 
       
  1474     iHighlightGc = 0 ; 
       
  1475     iHighlightKeyBmp = 0 ; 
       
  1476     iHighlightKeyDev = 0 ; 
       
  1477     iNormalKeyBmp = 0 ; 
       
  1478     iNormalKeyDev = 0 ; 
       
  1479     iDimmedKeyBmp = 0 ; 
       
  1480     iDimmedKeyDev = 0;
       
  1481     iKeyGc = 0;
       
  1482     
       
  1483     iBitmap = new ( ELeave ) CFbsBitmap;    
       
  1484     User::LeaveIfError( iBitmap->Create( TSize(1,1), aMode) );
       
  1485     
       
  1486     iHighlightDev = CFbsBitmapDevice::NewL(iBitmap);
       
  1487     
       
  1488     iHighlightGc = CFbsBitGc::NewL();
       
  1489     iHighlightGc->Reset();
       
  1490     
       
  1491 
       
  1492     iHighlightKeyBmp = new ( ELeave ) CFbsBitmap;    
       
  1493     User::LeaveIfError( iHighlightKeyBmp->Create( TSize(1,1), aMode) );    
       
  1494     iHighlightKeyDev = CFbsBitmapDevice::NewL(iHighlightKeyBmp);
       
  1495 
       
  1496     iNormalKeyBmp = new ( ELeave ) CFbsBitmap;    
       
  1497     User::LeaveIfError( iNormalKeyBmp->Create( TSize(1,1), aMode) );    
       
  1498     iNormalKeyDev = CFbsBitmapDevice::NewL(iNormalKeyBmp);
       
  1499 
       
  1500     iDimmedKeyBmp = new ( ELeave ) CFbsBitmap;    
       
  1501     User::LeaveIfError( iDimmedKeyBmp->Create( TSize(1,1), aMode) );    
       
  1502     iDimmedKeyDev = CFbsBitmapDevice::NewL(iDimmedKeyBmp);
       
  1503     
       
  1504     iKeyGc = CFbsBitGc::NewL();
       
  1505     iKeyGc->Reset();   
       
  1506     }
       
  1507 
       
  1508 void CVirtualKeyboard::CreateBmpDevL()
       
  1509     {
       
  1510     iExt->CreateBmpDevL(UiLayout()->LayoutOwner()->BitmapDevice()->DisplayMode());
       
  1511     }
       
  1512 
       
  1513 EXPORT_C void CVirtualKeyboard::HandleResourceChange(TInt aType)
       
  1514     {
       
  1515     if(aType == KPenInputOwnDeviceChange)
       
  1516         {
       
  1517         if(UiLayout()->NotDrawToLayoutDevice())
       
  1518             {
       
  1519             TRAP_IGNORE(CreateBmpDevL());
       
  1520             }
       
  1521         }
       
  1522     else
       
  1523         CControlGroup::HandleResourceChange(aType);
       
  1524     }
       
  1525     
       
  1526 CFbsBitmap* CVirtualKeyboard::PrepareMaskBmpL(CFbsBitGc* aGc, const TDisplayMode& aMode, const TRect& aRect)
       
  1527     {
       
  1528     CFbsBitmap* mask = new(ELeave) CFbsBitmap();
       
  1529     CleanupStack::PushL(mask);
       
  1530     User::LeaveIfError( mask->Create( aRect.Size(), aMode) );
       
  1531     CFbsBitmapDevice* maskDev = CFbsBitmapDevice::NewL(mask);
       
  1532     const TRgb KOpaqueMask = TRgb(KOpaqueColor);
       
  1533     DrawBackgroundToDevice(aRect,maskDev,NULL,KOpaqueMask,KOpaqueMask,EFalse);
       
  1534     delete maskDev;
       
  1535     CleanupStack::Pop(mask);
       
  1536     return mask;
       
  1537     }
       
  1538 CFbsBitmap* CVirtualKeyboard::PrepareKeyBmpL(CFbsBitGc* aGc, const TDisplayMode& aMode, const TRect& aRect,
       
  1539         const TRect& aInnerRect,const TAknsItemID& aFrameID, const TAknsItemID& aCenterID, const TRect& aKeyRect)
       
  1540     {
       
  1541     CFbsBitmap* key = new(ELeave) CFbsBitmap();
       
  1542     CleanupStack::PushL(key);
       
  1543     User::LeaveIfError( key->Create( aRect.Size(), aMode) );
       
  1544     
       
  1545     CFbsBitmapDevice* dev = CFbsBitmapDevice::NewL(key);
       
  1546     CleanupStack::PushL(dev);
       
  1547     
       
  1548     CFbsBitGc* keyGc = CFbsBitGc::NewL();
       
  1549     keyGc->Reset();
       
  1550     CleanupStack::PushL(keyGc);
       
  1551     
       
  1552     keyGc->Activate(dev);
       
  1553     
       
  1554     CFbsBitGc* layoutGc = static_cast<CFbsBitGc*>(
       
  1555                             UiLayout()->LayoutOwner()->BitmapContext());
       
  1556     layoutGc->Activate(UiLayout()->LayoutOwner()->BitmapDevice()); 
       
  1557     
       
  1558     keyGc->BitBlt(TPoint(0,0),*layoutGc,aKeyRect);
       
  1559     
       
  1560     AknsDrawUtils::DrawFrame(AknsUtils::SkinInstance(), 
       
  1561                              *keyGc, 
       
  1562                              aRect, 
       
  1563                              aInnerRect,
       
  1564                              aFrameID, 
       
  1565                              aCenterID);
       
  1566 
       
  1567     layoutGc->Activate(UiLayout()->LayoutOwner()->BitmapDevice());    
       
  1568     
       
  1569     CleanupStack::PopAndDestroy(2);
       
  1570     CleanupStack::Pop(key);
       
  1571     
       
  1572     return key;
       
  1573     }
       
  1574 
       
  1575 TBool CVirtualKeyboard::PrepareKeyBmp(CFbsBitmap* aBmp,CFbsBitmapDevice* aDev,const TRect& aRect, 
       
  1576                         const TRect& aInnerRect,const TAknsItemID& aFrameID, const TAknsItemID& aCenterID, const TRect& aKeyRect)
       
  1577     {
       
  1578 
       
  1579     aBmp->Resize(aRect.Size());
       
  1580     aDev->Resize(aRect.Size());
       
  1581     iExt->iKeyGc->Activate(aDev);
       
  1582     iExt->iKeyGc->Resized();        
       
  1583 
       
  1584     TRect r = aRect;
       
  1585     r.Move(-r.iTl.iX, -r.iTl.iY);
       
  1586    
       
  1587     CFbsBitmap* keyBmp = NULL;
       
  1588     TRect inner = aInnerRect;
       
  1589     TPoint off = aInnerRect.iTl - aRect.iTl;
       
  1590     inner.Move(-inner.iTl.iX + off.iX, -inner.iTl.iY + off.iY);
       
  1591     TRAP_IGNORE(keyBmp = PrepareKeyBmpL(iExt->iKeyGc,
       
  1592                         UiLayout()->LayoutOwner()->BitmapDevice()->DisplayMode(),
       
  1593                         r,inner,aFrameID,aCenterID,aKeyRect));
       
  1594     if(!keyBmp)
       
  1595         {
       
  1596         return EFalse;
       
  1597         }
       
  1598 
       
  1599     iExt->iKeyGc->BitBlt(TPoint(0,0), keyBmp,r);      
       
  1600 
       
  1601     delete keyBmp;        
       
  1602     return ETrue;
       
  1603     }
  1444 //end of implementation of Class CVirtualKey    
  1604 //end of implementation of Class CVirtualKey