diff -r e7aa27f58ae1 -r e1b6206813b4 emailuis/emailui/src/OverlayControl.cpp --- a/emailuis/emailui/src/OverlayControl.cpp Tue Feb 02 00:02:40 2010 +0200 +++ b/emailuis/emailui/src/OverlayControl.cpp Fri Feb 19 22:37:30 2010 +0200 @@ -30,7 +30,6 @@ { delete iBitmap; delete iMask; - delete iSolidMask; } COverlayControl* COverlayControl::NewL( CCoeControl* aParent, MOverlayControlObserver* aObserver, @@ -45,9 +44,8 @@ void COverlayControl::ConstructL( CCoeControl* aParent, const TRect& aRect, TInt aBitmapId, TInt aMaskId ) { - iSolidMask = new(ELeave) CFbsBitmap(); - CreateWindowL( aParent ); + SetContainerWindowL( *aParent ); TFileName iconFileName; TFsEmailUiUtility::GetFullIconFileNameL( iconFileName ); @@ -72,137 +70,41 @@ if( iMask ) { AknIconUtils::SetSize( iMask, aRect.Size() ); - - // Create a solid version of the mask, too - TRAP_IGNORE( - CopyBitmapL( *iMask, *iSolidMask ); - AdjustAlpha( *iSolidMask, KSolidTransparencyFactor ); - ); - - UpdateMask(); } CCoeControl::SetRect( aRect ); } -void COverlayControl::CopyBitmapL( const CFbsBitmap& aSource, CFbsBitmap& aDest ) - { - TSize size = aSource.SizeInPixels(); - TInt dataSize = aSource.DataStride() * size.iHeight; - User::LeaveIfError( aDest.Create( size, aSource.DisplayMode() ) ); - - CFbsBitGc* bitCtx; - CFbsBitmapDevice* bitDev = CFbsBitmapDevice::NewL( &aDest ); - CleanupStack::PushL( bitDev ); - User::LeaveIfError( bitDev->CreateContext( bitCtx ) ); - CleanupStack::PushL( bitCtx ); - bitCtx->BitBlt( TRect( size ).iTl, &aSource ); - CleanupStack::PopAndDestroy( 2 ); // bitCtx, bitDev - } - -void COverlayControl::AdjustAlpha( CFbsBitmap& aBitmap, TReal aFactor ) - { - aBitmap.LockHeap(); - TUint8* data = (TUint8*)aBitmap.DataAddress(); - TSize size = aBitmap.SizeInPixels(); - TInt dataSize = aBitmap.DataStride() * size.iHeight; - for( TInt i = 0; i KMaxTUint8 ) - { - value = KMaxTUint8; - } - data[ i ] = value; - } - } - aBitmap.UnlockHeap(); - } - void COverlayControl::HandlePointerEventL( const TPointerEvent& aPointerEvent ) { CCoeControl::HandlePointerEventL( aPointerEvent ); - - // Do hit test for the pointer event - TBool hit = EFalse; - TSize size = Size(); - if( aPointerEvent.iPosition.iX >= 0 && - aPointerEvent.iPosition.iY >= 0 && - aPointerEvent.iPosition.iX < size.iWidth && - aPointerEvent.iPosition.iY < size.iHeight ) - { - hit = ETrue; - } - - if( aPointerEvent.iType == TPointerEvent::EButton1Up ) + if( iObserver ) { - SetPointerCapture( EFalse ); - UpdateButtonState( EFalse ); - - // Notify the events only if released on top of the control - if( iObserver && hit ) - { - // Do not let leaves disturb the system - TRAP_IGNORE( - iObserver->HandleOverlayPointerEventL( this, aPointerEvent ); - ); - } + // Do not let leaves disturb the system + TRAP_IGNORE( + iObserver->HandleOverlayPointerEventL( this, aPointerEvent )); } - else if( aPointerEvent.iType == TPointerEvent::EButton1Down ) - { - UpdateButtonState( ETrue ); - SetGloballyCapturing( ETrue ); - SetPointerCapture( ETrue ); - } - else if( aPointerEvent.iType == TPointerEvent::EDrag ) - { - // Update the button UI according to hit result - UpdateButtonState( hit ); - } - } - -void COverlayControl::UpdateButtonState( TBool aButtonDown ) - { - if( iDownState != aButtonDown ) - { - iDownState = aButtonDown; - UpdateMask(); - } - } + } void COverlayControl::MakeVisible( TBool aVisible ) { if( !aVisible ) { - UpdateButtonState( EFalse ); SetPointerCapture( EFalse ); } + else + { + DrawDeferred(); + } CCoeControl::MakeVisible( aVisible ); } -void COverlayControl::UpdateMask() - { - CFbsBitmap* mask = iMask; - if( iDownState ) - { - mask = iSolidMask; - } - if( mask ) - { - Window().SetTransparencyBitmap( *mask ); - } - } - void COverlayControl::Draw( const TRect& ) const { CWindowGc& gc = SystemGc(); - if( iBitmap ) { TSize size = iBitmap->SizeInPixels(); - gc.BitBlt( TPoint( 0, 0 ), iBitmap ); - } + gc.BitBltMasked(Position(),iBitmap,TRect( TPoint(0,0), size),iMask, ETrue); + } }