// ---------------------------------------------------------------------------
// 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 );
            }
        }

    }
Пример #2
0
// -----------------------------------------------------------------------------
// 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 );
        }
    }
Пример #3
0
// -----------------------------------------------------------------------------
// CTestSDKSkins::TestMBIDSetMaskL
// -----------------------------------------------------------------------------
TInt CTestSDKSkins::TestMBIDSetMaskL( CStifItemParser& /*aItem*/ )
    {
    CAknsMaskedBitmapItemData* itemData = CAknsMaskedBitmapItemData::NewL();
    CleanupStack::PushL( itemData );
    STIF_ASSERT_NOT_NULL( itemData );

    CFbsBitmap* bitMapMask = new (ELeave) CFbsBitmap;
    CleanupStack::PushL( bitMapMask );
    itemData->SetMask( bitMapMask );
    
    STIF_ASSERT_TRUE( bitMapMask == itemData->Mask() );
    
    CleanupStack::Pop( bitMapMask );
    CleanupStack::PopAndDestroy( itemData );
    
    return KErrNone;
    
    }
// ---------------------------------------------------------------------------
// 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 );
            }
        }

    }