// ----------------------------------------------------------------------------- // CTestSDKSkins::TestMBIDDestroyAndSetMaskL // ----------------------------------------------------------------------------- TInt CTestSDKSkins::TestMBIDDestroyAndSetMaskL( CStifItemParser& /*aItem*/ ) { CAknsMaskedBitmapItemData* itemData = CAknsMaskedBitmapItemData::NewL(); CleanupStack::PushL( itemData ); STIF_ASSERT_NOT_NULL( itemData ); CFbsBitmap* bitMapMask = new (ELeave) CFbsBitmap; CleanupStack::PushL( bitMapMask ); itemData->DestroyAndSetBitmap( bitMapMask ); CleanupStack::Pop( bitMapMask ); CleanupStack::PopAndDestroy( itemData ); return KErrNone; }
// --------------------------------------------------------------------------- // CAknBatteryStrength::DrawInNormalStatusPane // --------------------------------------------------------------------------- // void CAknBatteryStrength::DrawInNormalStatusPane( const TRect& /*aRect*/ ) const { CWindowGc& gc = SystemGc(); TRect rect( Rect() ); MAknsSkinInstance* skin = AknsUtils::SkinInstance(); // Draws battery strength bar CAknsMaskedBitmapItemData* bitmap = NULL; if ( skin ) { bitmap = static_cast<CAknsMaskedBitmapItemData*>( skin->GetCachedItemData( KAknsIIDQgnIndiBatteryStrength, EAknsITMaskedBitmap ) ); if ( bitmap ) { if ( bitmap->Bitmap() ) { AknIconUtils::SetSize( bitmap->Bitmap(), Size() ); } if ( bitmap->Mask() ) { AknIconUtils::SetSize( bitmap->Mask(), Size() ); } gc.BitBltMasked( TPoint( rect.iTl.iX, iDefaultBatteryBitmapOffset ), bitmap->Bitmap(), TRect( 0, iDefaultBatteryBitmapOffset, rect.Width(), rect.Height() ), bitmap->Mask(), ETrue ); } } if ( !bitmap ) { if ( iDefaultBatteryIndicatorBitmap && iDefaultBatteryIndicatorBitmapMask ) { gc.BitBltMasked( TPoint( rect.iTl.iX, iDefaultBatteryBitmapOffset ), iDefaultBatteryIndicatorBitmap, TRect( 0, iDefaultBatteryBitmapOffset, rect.Width(), rect.Height() ), iDefaultBatteryIndicatorBitmapMask, ETrue ); } } }
// ----------------------------------------------------------------------------- // AknsUtils::CreateIconLC // ----------------------------------------------------------------------------- // EXPORT_C void AknsUtils::CreateIconLC( MAknsSkinInstance* aInstance, const TAknsItemID& aID, CFbsBitmap*& aBitmap, CFbsBitmap*& aMask, const TDesC& aFilename, const TInt aFileBitmapId, const TInt aFileMaskId ) { CFbsBitmap* bitmap = NULL; CFbsBitmap* mask = NULL; TBool fallback = EFalse; if( aInstance ) { CAknsMaskedBitmapItemData* bmpData = static_cast<CAknsMaskedBitmapItemData*>( aInstance->CreateUncachedItemDataL( aID, EAknsITMaskedBitmap ) ); CleanupStack::PushL( bmpData ); if( bmpData && bmpData->Bitmap() && bmpData->Mask() ) { // Detach bitmaps bitmap = bmpData->Bitmap(); bmpData->SetBitmap( NULL ); mask = bmpData->Mask(); bmpData->SetMask( NULL ); } CleanupStack::PopAndDestroy( bmpData ); } if( bitmap ) // Mask is also loaded { CleanupStack::PushL( mask ); CleanupStack::PushL( bitmap ); } else { if( !aFilename.Length() ) { User::Leave( KErrNotFound ); } // Fallback AknIconUtils::CreateIconLC( bitmap, mask, aFilename, aFileBitmapId, aFileMaskId ); fallback = ETrue; } if( (bitmap && mask) || fallback) { // Ownership transferred aBitmap = bitmap; aMask = mask; } else { User::Leave( KErrUnknown ); } }
// --------------------------------------------------------------------------- // CAknBatteryStrength::DrawInFlatStatusPane // --------------------------------------------------------------------------- // void CAknBatteryStrength::DrawInFlatStatusPane( const TRect& /*aRect*/ ) const { CWindowGc& gc = SystemGc(); TRect rect( Rect() ); MAknsSkinInstance* skin = AknsUtils::SkinInstance(); // Draws battery strength bar CAknsMaskedBitmapItemData* bitmapData = NULL; if ( skin ) { bitmapData = static_cast<CAknsMaskedBitmapItemData*>( skin->GetCachedItemData( KAknsIIDQgnIndiBatteryStrength, EAknsITMaskedBitmap ) ); if ( bitmapData ) { CFbsBitmap* bitmap = bitmapData->Bitmap(); if ( bitmap ) AknIconUtils::SetSize( bitmap, TSize( rect.Width(), rect.Height() ), EAspectRatioNotPreserved ); TPoint point( 0, iFlatBatteryBitmapOffset ); if ( bitmap && !AknLayoutUtils::LayoutMirrored() ) { point = TPoint( rect.iBr.iX - bitmap->SizeInPixels().iWidth, iFlatBatteryBitmapOffset); } gc.BitBltMasked( point, bitmap, TRect(0,iFlatBatteryBitmapOffset, rect.Width(), rect.Height()), bitmapData->Mask(), ETrue ); } } if ( !bitmapData ) { if ( iFlatBatteryIndicatorBitmap && iFlatBatteryIndicatorBitmapMask ) { TPoint point( 0, iFlatBatteryBitmapOffset ); if ( !AknLayoutUtils::LayoutMirrored() ) { point = TPoint( rect.iBr.iX - iFlatBatteryIndicatorBitmap->SizeInPixels().iWidth, iFlatBatteryBitmapOffset ); } gc.BitBltMasked( point, iFlatBatteryIndicatorBitmap, TRect( 0, iFlatBatteryBitmapOffset, rect.Width(), rect.Height() ), iFlatBatteryIndicatorBitmapMask, ETrue ); } } }
// ----------------------------------------------------------------------------- // AknsDrawUtils::DrawBackground() // (commented in the header). // ----------------------------------------------------------------------------- EXPORT_C TBool AknsDrawUtils::DrawBackground( MAknsSkinInstance* aInstance, MAknsControlContext* aContext, const CCoeControl* aControl, CBitmapContext& aGc, const TPoint& aDstPos, const TRect& aControlRect, const TInt aDrawParam ) { TInt drawParam = aDrawParam; TInt originalParam = aDrawParam; TBool retVal = EFalse; TBool blitFailed = EFalse; TBool blit = EFalse; TBool blitAttempted = EFalse; if ( !&aGc ) { return retVal; } MAknsControlContext* parentContext = GetParentContext( aContext ); if( parentContext ) { retVal = DrawBackground( aInstance, parentContext, aControl, aGc, aDstPos, aControlRect, aDrawParam ); drawParam |= KAknsDrawParamNoClearUnderImage; } else if( drawParam & KAknsDrawParamBottomLevelRGBOnly ) { drawParam |= KAknsDrawParamRGBOnly; } originalParam = drawParam; if( aContext ) { aContext->UpdateContext(); } TAknsBackground* bgLayout = RetrieveBackgroundLayout( aContext ); TAknsItemID imgIID( KAknsIIDNone ); CAknsImageItemData* imgData = RetrieveBackgroundImage( aInstance, bgLayout, imgIID ); // chained background if (imgData && imgData->ParentIID() != KAknsIIDNone) { TAknsItemID parentiid = imgData->ParentIID(); TRect parentDrawRect = imgData->DrawRect(); imgData = RetrieveKnownBackgroundImage( aInstance, parentiid ); if (imgData) { imgData->SetDrawRect(parentDrawRect); drawParam |= KAknsDrawParamChained ; } } TPoint paDelta = GetParentAbsoluteDelta( bgLayout, aControl ); TRect drawRect = aControlRect; drawRect.Move( aDstPos-aControlRect.iTl ); paDelta += aControlRect.iTl-aDstPos; if (!(aDrawParam & KAknsDrawParamPrepareOnly)) { aGc.SetPenStyle(CGraphicsContext::ENullPen); aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); } if ( !(aDrawParam & KAknsDrawParamIgnoreLayerMask)) { if( imgData ) { blitAttempted = ETrue; if( (drawParam&KAknsDrawParamNoClearUnderImage)==0 ) { blit = BlitAndClear( aInstance, aGc, drawRect, imgData, imgIID, bgLayout, paDelta, drawParam ); } else { blit = Blit( aInstance, aGc, drawRect, imgData, imgIID, bgLayout, paDelta, drawParam ); } if ( !blit ) { blitFailed = ETrue; } } else { if( !(drawParam&KAknsDrawParamNoClearUnderImage) && !(drawParam&KAknsDrawParamPrepareOnly) ) { // Clear only if permitted aGc.DrawRect( drawRect ); } } } if( bgLayout ) { if (!(aDrawParam & KAknsDrawParamIgnoreLayerMask) && aContext->IsCompatibleWithType(EAknsControlContextTypeMasked)) { CAknsMaskedLayerBackgroundControlContext* layeredCxt = static_cast<CAknsMaskedLayerBackgroundControlContext*>(aContext); if (layeredCxt->iOffScreenBmp) { CAknsMaskedBitmapItemData* maskedImgData = NULL; TRAPD( err, maskedImgData = CAknsMaskedBitmapItemData::NewL() ); if ( err != KErrNone ) { return EFalse; } maskedImgData->SetBitmap(layeredCxt->iOffScreenBmp); maskedImgData->SetMask(layeredCxt->iLayerMask); TAknsBackground* childLayout = bgLayout->iNext; blitAttempted = ETrue; blit = Blit( aInstance, aGc, drawRect, maskedImgData, KAknsIIDNone, childLayout, paDelta, drawParam ); if ( !blit ) { blitFailed = ETrue; } maskedImgData->SetBitmap(NULL); maskedImgData->SetMask(NULL); delete maskedImgData; if (!(aDrawParam & KAknsDrawParamPrepareOnly)) { aGc.SetPenStyle(CGraphicsContext::ESolidPen); aGc.SetBrushStyle(CGraphicsContext::ENullBrush); } retVal = !blitFailed; return retVal; } } if (!aContext->IsCompatibleWithType(EAknsControlContextTypeFrame)) { // special handling for frames drawParam|=KAknsDrawParamNoClearUnderImage; originalParam|=KAknsDrawParamNoClearUnderImage; } TAknsBackground* nextLayout = bgLayout->iNext; while( nextLayout && ((drawParam & KAknsDrawParamLimitToFirstLevel) == 0) ) { imgData = RetrieveKnownBackgroundImage( aInstance, nextLayout->iImageID ); if (imgData && imgData->ParentIID() != KAknsIIDNone) { TAknsItemID parentiid = imgData->ParentIID(); TRect parentDrawRect = imgData->DrawRect(); imgData = RetrieveKnownBackgroundImage( aInstance, parentiid ); if (imgData) { imgData->SetDrawRect(parentDrawRect); drawParam |= KAknsDrawParamChained ; } } else { drawParam=originalParam; } if( imgData ) { blitAttempted = ETrue; blit = BlitAndClear( aInstance, aGc, drawRect, imgData, nextLayout->iImageID, nextLayout, paDelta, drawParam ); if ( !blit ) { blitFailed = ETrue; } } nextLayout = nextLayout->iNext; } } if (!(aDrawParam & KAknsDrawParamPrepareOnly)) { aGc.SetPenStyle(CGraphicsContext::ESolidPen); aGc.SetBrushStyle(CGraphicsContext::ENullBrush); } // If Blit failed, or was not even attempted => return EFalse if ( blitFailed ) { retVal = EFalse; } else if ( !retVal ) { retVal = blitAttempted; } return retVal; }