uifw/AvKon/src/AknBatteryStrength.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Battery strength indicator control.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "AknBatteryStrength.h"
       
    21 #include "aknconsts.h"
       
    22 #include "AknUtils.h"
       
    23 #include "AknBitmapMirrorUtils.h"
       
    24 #include "aknenv.h"
       
    25 #include "AknIconUtils.h"
       
    26 #include "AknStatuspaneUtils.h"
       
    27 #include "aknappui.h"
       
    28 
       
    29 #include <avkon.mbg>
       
    30 #include <AknsDrawUtils.h>
       
    31 #include <eikenv.h>
       
    32 #include <eikspane.h>
       
    33 #include "AknDef.h"
       
    34 #include <layoutmetadata.cdl.h>
       
    35 
       
    36 #include <AknTasHook.h>
       
    37 const TInt KBatteryStrengthLevels = 7;
       
    38 const TInt KScaleFactor           = 10000;
       
    39 
       
    40 
       
    41 // ---------------------------------------------------------------------------
       
    42 // CAknBatteryStrength::CAknBatteryStrength
       
    43 // Default constructor.
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 CAknBatteryStrength::CAknBatteryStrength()
       
    47     {
       
    48     }
       
    49 
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // CAknBatteryStrength::~CAknBatteryStrength
       
    53 // Destructor.
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 CAknBatteryStrength::~CAknBatteryStrength()
       
    57     {
       
    58     AKNTASHOOK_REMOVE();
       
    59     AknsUtils::DeregisterControlPosition( this );
       
    60 
       
    61     delete iDefaultBatteryIndicatorBitmap;
       
    62     delete iDefaultBatteryIndicatorBitmapMask;
       
    63 
       
    64     delete iFlatBatteryIndicatorBitmap;
       
    65     delete iFlatBatteryIndicatorBitmapMask;
       
    66 
       
    67     delete iStaconLeftSideBatteryIndicatorBitmap;
       
    68     delete iStaconLeftSideBatteryIndicatorBitmapMask;
       
    69     delete iStaconRightSideBatteryIndicatorBitmap;
       
    70     delete iStaconRightSideBatteryIndicatorBitmapMask;
       
    71     }
       
    72 
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // CAknBatteryStrength::NewL
       
    76 // Two-phased constructor.
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 CAknBatteryStrength* CAknBatteryStrength::NewL()
       
    80     {
       
    81     CAknBatteryStrength* self = CAknBatteryStrength::NewLC();
       
    82     CleanupStack::Pop( self );
       
    83     return self;
       
    84     }
       
    85 
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // CAknBatteryStrength::NewLC
       
    89 // Two-phased constructor.
       
    90 // ---------------------------------------------------------------------------
       
    91 //
       
    92 CAknBatteryStrength* CAknBatteryStrength::NewLC()
       
    93     {
       
    94     CAknBatteryStrength* self = new (ELeave) CAknBatteryStrength;
       
    95     CleanupStack::PushL( self );
       
    96     AKNTASHOOK_ADDL( self, "CAknBatteryStrength" );
       
    97     return self;
       
    98     }
       
    99 
       
   100 
       
   101 // ---------------------------------------------------------------------------
       
   102 // CAknBatteryStrength::SizeChanged
       
   103 // ---------------------------------------------------------------------------
       
   104 //
       
   105 void CAknBatteryStrength::SizeChanged()
       
   106     {
       
   107     TSize size( Size() );
       
   108 
       
   109     if ( AknStatuspaneUtils::StaconPaneActive() )
       
   110         {
       
   111         TRAP_IGNORE( LoadStaconBitmapsL() );
       
   112         if ( iStaconLeftSideBatteryIndicatorBitmap )
       
   113             {
       
   114             AknIconUtils::SetSize(
       
   115                 iStaconLeftSideBatteryIndicatorBitmap,
       
   116                 size,
       
   117                 EAspectRatioPreservedAndUnusedSpaceRemoved );
       
   118             }
       
   119 
       
   120         if ( iStaconRightSideBatteryIndicatorBitmap )
       
   121             {
       
   122             AknIconUtils::SetSize(
       
   123                 iStaconRightSideBatteryIndicatorBitmap,
       
   124                 size,
       
   125                 EAspectRatioPreservedAndUnusedSpaceRemoved );
       
   126             }
       
   127 
       
   128         iLastStaconSize = size;
       
   129         }
       
   130     else if ( AknStatuspaneUtils::FlatLayoutActive() )
       
   131         {
       
   132         TRAP_IGNORE( LoadFlatBitmapsL() );
       
   133         if ( iFlatBatteryIndicatorBitmap )
       
   134             {
       
   135             AknIconUtils::SetSize( iFlatBatteryIndicatorBitmap,
       
   136                                    size,
       
   137                                    EAspectRatioNotPreserved );
       
   138             }
       
   139 
       
   140         iLastFlatSize = size;
       
   141         }
       
   142     else if ( AknStatuspaneUtils::ExtendedLayoutActive() )
       
   143         {
       
   144         TRAP_IGNORE( LoadDefaultBitmapsL() );
       
   145         if ( iDefaultBatteryIndicatorBitmap )
       
   146             {
       
   147             AknIconUtils::SetSize( iDefaultBatteryIndicatorBitmap,
       
   148                                    size,
       
   149                                    EAspectRatioNotPreserved );
       
   150             }
       
   151 
       
   152         iLastDefaultSize = size;
       
   153         }
       
   154     else
       
   155         {
       
   156         TRAP_IGNORE( LoadDefaultBitmapsL() );
       
   157         if ( iDefaultBatteryIndicatorBitmap )
       
   158             {
       
   159             AknIconUtils::SetSize( iDefaultBatteryIndicatorBitmap, size );
       
   160             }
       
   161         iLastDefaultSize = size;
       
   162         }
       
   163 
       
   164     SetBatteryLevel( iBatteryLevel ); // refreshes battery level offsets
       
   165     AknsUtils::RegisterControlPosition( this );
       
   166     }
       
   167 
       
   168 
       
   169 // ---------------------------------------------------------------------------
       
   170 // CAknBatteryStrength::PositionChanged
       
   171 // ---------------------------------------------------------------------------
       
   172 //
       
   173 void CAknBatteryStrength::PositionChanged()
       
   174     {
       
   175     AknsUtils::RegisterControlPosition( this );
       
   176     if ( AknStatuspaneUtils::StaconPaneActive() )
       
   177         {
       
   178         TRAP_IGNORE( LoadStaconBitmapsL() );
       
   179         }
       
   180     }
       
   181 
       
   182 
       
   183 // ---------------------------------------------------------------------------
       
   184 // CAknBatteryStrength::Draw
       
   185 // ---------------------------------------------------------------------------
       
   186 //
       
   187 void CAknBatteryStrength::Draw( const TRect& /*aRect*/ ) const
       
   188     {
       
   189     if ( AknStatuspaneUtils::StaconPaneActive() )
       
   190         {
       
   191         DrawInStaconPane( Rect() );
       
   192         }
       
   193     else if ( AknStatuspaneUtils::FlatLayoutActive() )
       
   194         {
       
   195         DrawInFlatStatusPane( Rect() );
       
   196         }
       
   197     else
       
   198         {
       
   199         DrawInNormalStatusPane( Rect() );
       
   200         }
       
   201     }
       
   202 
       
   203 
       
   204 // ---------------------------------------------------------------------------
       
   205 // CAknBatteryStrength::BatteryLevel
       
   206 // ---------------------------------------------------------------------------
       
   207 //
       
   208 TInt CAknBatteryStrength::BatteryLevel()
       
   209     {
       
   210     return iBatteryLevel;
       
   211     }
       
   212 
       
   213 
       
   214 // ---------------------------------------------------------------------------
       
   215 // CAknBatteryStrength::SetBatteryLevel
       
   216 // ---------------------------------------------------------------------------
       
   217 //
       
   218 void CAknBatteryStrength::SetBatteryLevel( TInt aLevel )
       
   219     {
       
   220     TBool legalValue  =
       
   221         ( ( aLevel <= KBatteryLevelMax ) &&
       
   222           ( aLevel >= KBatteryLevelMin ) );
       
   223 
       
   224     if ( !legalValue )
       
   225         {
       
   226         // Battery level value is not changed if wrong value was given.
       
   227         return;
       
   228         }
       
   229 
       
   230     TSize size( Size() );
       
   231 
       
   232     iBatteryLevel = aLevel;
       
   233 
       
   234     if ( iBatteryLevel == KBatteryLevelMin )
       
   235         {
       
   236         iDefaultBatteryBitmapOffset = size.iHeight;
       
   237         iFlatBatteryBitmapOffset    = size.iHeight;
       
   238         iStaconBatteryBitmapOffset  = 0;
       
   239         }
       
   240 
       
   241     // Offsets are calculated from the battery strength area
       
   242     // because the battery strength level layouts return
       
   243     // wrong values in some cases.
       
   244     else if ( AknStatuspaneUtils::FlatLayoutActive() )
       
   245         {
       
   246         TInt stepSize =
       
   247             size.iHeight * KScaleFactor / KBatteryStrengthLevels;
       
   248 
       
   249         iFlatBatteryBitmapOffset =
       
   250             size.iHeight - ( stepSize * iBatteryLevel / KScaleFactor );
       
   251         }
       
   252     else if ( AknStatuspaneUtils::StaconPaneActive() )
       
   253         {
       
   254         TInt stepSize = size.iHeight * KScaleFactor / KBatteryStrengthLevels;
       
   255         iStaconBatteryBitmapOffset = stepSize * iBatteryLevel / KScaleFactor;
       
   256         }
       
   257     else // normal statuspane
       
   258         {
       
   259         TInt stepSize =
       
   260             size.iHeight * KScaleFactor / KBatteryStrengthLevels;
       
   261 
       
   262         iDefaultBatteryBitmapOffset =
       
   263             size.iHeight - ( stepSize * iBatteryLevel / KScaleFactor );
       
   264         }
       
   265     }
       
   266 
       
   267 
       
   268 // ---------------------------------------------------------------------------
       
   269 // CAknBatteryStrength::LoadDefaultBitmapsL
       
   270 // ---------------------------------------------------------------------------
       
   271 //
       
   272 void CAknBatteryStrength::LoadDefaultBitmapsL()
       
   273     {
       
   274     if ( iDefaultBatteryIndicatorBitmap &&
       
   275          iDefaultBatteryIndicatorBitmapMask &&
       
   276          iLastDefaultSize == Size() )
       
   277         {
       
   278         return;
       
   279         }
       
   280     else
       
   281         {
       
   282         delete iDefaultBatteryIndicatorBitmap;
       
   283         iDefaultBatteryIndicatorBitmap = NULL;
       
   284         delete iDefaultBatteryIndicatorBitmapMask;
       
   285         iDefaultBatteryIndicatorBitmapMask = NULL;
       
   286         }
       
   287 
       
   288     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   289 
       
   290     AknsUtils::CreateIconL( skin,
       
   291                             KAknsIIDQgnIndiBatteryStrength,
       
   292                             iDefaultBatteryIndicatorBitmap,
       
   293                             iDefaultBatteryIndicatorBitmapMask,
       
   294                             KAvkonBitmapFile,
       
   295                             EMbmAvkonQgn_indi_battery_strength,
       
   296                             EMbmAvkonQgn_indi_battery_strength_mask );
       
   297 
       
   298     if ( AknStatuspaneUtils::ExtendedLayoutActive() )
       
   299         {
       
   300         AknIconUtils::SetSize( iDefaultBatteryIndicatorBitmap,
       
   301                                Size(),
       
   302                                EAspectRatioNotPreserved );
       
   303         }
       
   304     else
       
   305         {
       
   306         AknIconUtils::SetSize( iDefaultBatteryIndicatorBitmap,
       
   307                                Size() );
       
   308         }
       
   309 
       
   310     CFbsBitmap* itemIsSkinned = AknsUtils::GetCachedBitmap(
       
   311             skin, KAknsIIDQgnIndiBatteryStrength );
       
   312     if ( AknLayoutUtils::LayoutMirrored() && !itemIsSkinned )
       
   313         {
       
   314         CFbsBitmap* tmpBitmap =
       
   315             AknBitmapMirrorUtils::HorizontallyMirrorBitmapL(
       
   316                 iDefaultBatteryIndicatorBitmap );
       
   317 
       
   318         CFbsBitmap* tmpBitmapMask =
       
   319             AknBitmapMirrorUtils::HorizontallyMirrorBitmapL(
       
   320                 iDefaultBatteryIndicatorBitmapMask );
       
   321 
       
   322         delete iDefaultBatteryIndicatorBitmap;
       
   323         iDefaultBatteryIndicatorBitmap = tmpBitmap;
       
   324         delete iDefaultBatteryIndicatorBitmapMask;
       
   325         iDefaultBatteryIndicatorBitmapMask = tmpBitmapMask;
       
   326         }
       
   327     }
       
   328 
       
   329 
       
   330 // ---------------------------------------------------------------------------
       
   331 // CAknBatteryStrength::LoadStaconBitmapsL
       
   332 // ---------------------------------------------------------------------------
       
   333 //
       
   334 void CAknBatteryStrength::LoadStaconBitmapsL()
       
   335     {
       
   336     // stacon bitmaps
       
   337     TBool iconsExistForActiveStaconLayout = EFalse;
       
   338     if ( AknStatuspaneUtils::StaconSoftKeysLeft() )
       
   339         {
       
   340         if ( iStaconRightSideBatteryIndicatorBitmap &&
       
   341              iStaconRightSideBatteryIndicatorBitmapMask )
       
   342             {
       
   343             iconsExistForActiveStaconLayout = ETrue;
       
   344             }
       
   345         }
       
   346     else if ( AknStatuspaneUtils::StaconSoftKeysRight() )
       
   347         {
       
   348         if ( iStaconLeftSideBatteryIndicatorBitmap &&
       
   349              iStaconLeftSideBatteryIndicatorBitmapMask )
       
   350             {
       
   351             iconsExistForActiveStaconLayout = ETrue;
       
   352             }
       
   353         }
       
   354 
       
   355 
       
   356     if ( iconsExistForActiveStaconLayout &&
       
   357          iLastStaconSize == Size() )
       
   358         {
       
   359         // Bitmaps exist and size hasn't changed.
       
   360         return;
       
   361         }
       
   362     else
       
   363         {
       
   364         delete iStaconRightSideBatteryIndicatorBitmap;
       
   365         iStaconRightSideBatteryIndicatorBitmap = NULL;
       
   366         delete iStaconRightSideBatteryIndicatorBitmapMask;
       
   367         iStaconRightSideBatteryIndicatorBitmapMask = NULL;
       
   368 
       
   369         delete iStaconLeftSideBatteryIndicatorBitmap;
       
   370         iStaconLeftSideBatteryIndicatorBitmap = NULL;
       
   371         delete iStaconLeftSideBatteryIndicatorBitmapMask;
       
   372         iStaconLeftSideBatteryIndicatorBitmapMask = NULL;
       
   373         }
       
   374 
       
   375     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   376 
       
   377     TRAPD( err, AknsUtils::CreateIconL( skin,
       
   378                                         KAknsIIDQgnIndiBatteryStrengthLsc,
       
   379                                         iStaconLeftSideBatteryIndicatorBitmap,
       
   380                                         iStaconLeftSideBatteryIndicatorBitmapMask,
       
   381                                         KAvkonBitmapFile,
       
   382                                         EMbmAvkonQgn_indi_battery_strength_lsc,
       
   383                                         EMbmAvkonQgn_indi_battery_strength_lsc_mask ) );
       
   384 
       
   385     // Only icon for right sk situation exists, we mirror graphics here if needed.
       
   386     if ( AknStatuspaneUtils::StaconSoftKeysLeft() )
       
   387         {
       
   388         if ( err == KErrNone )
       
   389             {
       
   390             AknIconUtils::SetSize( iStaconLeftSideBatteryIndicatorBitmap,
       
   391                                    Size(),
       
   392                                    EAspectRatioPreservedAndUnusedSpaceRemoved );
       
   393 
       
   394             CFbsBitmap* tmpBitmap =
       
   395                 AknBitmapMirrorUtils::HorizontallyMirrorBitmapL(
       
   396                     iStaconLeftSideBatteryIndicatorBitmap );
       
   397 
       
   398             CFbsBitmap* tmpBitmapMask =
       
   399                 AknBitmapMirrorUtils::HorizontallyMirrorBitmapL(
       
   400                     iStaconLeftSideBatteryIndicatorBitmapMask );
       
   401 
       
   402             delete iStaconRightSideBatteryIndicatorBitmap;
       
   403             iStaconRightSideBatteryIndicatorBitmap = tmpBitmap;
       
   404             delete iStaconRightSideBatteryIndicatorBitmapMask;
       
   405             iStaconRightSideBatteryIndicatorBitmapMask = tmpBitmapMask;
       
   406             }
       
   407         }
       
   408 
       
   409     // Delete unnecessary bitmaps to save RAM
       
   410     if ( AknStatuspaneUtils::StaconSoftKeysLeft() )
       
   411         {
       
   412         delete iStaconLeftSideBatteryIndicatorBitmap;
       
   413         iStaconLeftSideBatteryIndicatorBitmap = NULL;
       
   414         delete iStaconLeftSideBatteryIndicatorBitmapMask;
       
   415         iStaconLeftSideBatteryIndicatorBitmapMask = NULL;
       
   416         }
       
   417     else if ( AknStatuspaneUtils::StaconSoftKeysRight() )
       
   418         {
       
   419         delete iStaconRightSideBatteryIndicatorBitmap;
       
   420         iStaconRightSideBatteryIndicatorBitmap = NULL;
       
   421         delete iStaconRightSideBatteryIndicatorBitmapMask;
       
   422         iStaconRightSideBatteryIndicatorBitmapMask = NULL;
       
   423         }
       
   424     }
       
   425 
       
   426 
       
   427 // ---------------------------------------------------------------------------
       
   428 // CAknBatteryStrength::LoadFlatBitmapsL
       
   429 // ---------------------------------------------------------------------------
       
   430 //
       
   431 void CAknBatteryStrength::LoadFlatBitmapsL()
       
   432     {
       
   433     if ( iFlatBatteryIndicatorBitmap &&
       
   434          iFlatBatteryIndicatorBitmapMask &&
       
   435          iLastFlatSize == Size() )
       
   436         {
       
   437         return;
       
   438         }
       
   439     else
       
   440         {
       
   441         delete iFlatBatteryIndicatorBitmap;
       
   442         iFlatBatteryIndicatorBitmap = NULL;
       
   443         delete iFlatBatteryIndicatorBitmapMask;
       
   444         iFlatBatteryIndicatorBitmapMask = NULL;
       
   445         }
       
   446 
       
   447     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   448 
       
   449     // Flat bitmaps
       
   450     AknsUtils::CreateIconL( skin,
       
   451                             KAknsIIDQgnIndiBatteryStrength,
       
   452                             iFlatBatteryIndicatorBitmap,
       
   453                             iFlatBatteryIndicatorBitmapMask,
       
   454                             KAvkonBitmapFile,
       
   455                             EMbmAvkonQgn_indi_battery_strength,
       
   456                             EMbmAvkonQgn_indi_battery_strength_mask );
       
   457 
       
   458     AknIconUtils::SetSize( iFlatBatteryIndicatorBitmap,
       
   459                            Size(),
       
   460                            EAspectRatioNotPreserved );
       
   461 
       
   462     CFbsBitmap*  itemIsSkinned = AknsUtils::GetCachedBitmap(
       
   463             skin, KAknsIIDQgnIndiBatteryStrength );
       
   464     if ( AknLayoutUtils::LayoutMirrored() && !itemIsSkinned )
       
   465         {
       
   466         CFbsBitmap* tmpBitmap =
       
   467             AknBitmapMirrorUtils::HorizontallyMirrorBitmapL(
       
   468                 iFlatBatteryIndicatorBitmap );
       
   469 
       
   470         CFbsBitmap* tmpBitmapMask =
       
   471             AknBitmapMirrorUtils::HorizontallyMirrorBitmapL(
       
   472                 iFlatBatteryIndicatorBitmapMask );
       
   473 
       
   474         delete iFlatBatteryIndicatorBitmap;
       
   475         iFlatBatteryIndicatorBitmap = tmpBitmap;
       
   476         delete iFlatBatteryIndicatorBitmapMask;
       
   477         iFlatBatteryIndicatorBitmapMask = tmpBitmapMask;
       
   478         }
       
   479     }
       
   480 
       
   481 
       
   482 // ---------------------------------------------------------------------------
       
   483 // CAknBatteryStrength::DeleteBitmaps
       
   484 // ---------------------------------------------------------------------------
       
   485 //
       
   486 void CAknBatteryStrength::DeleteBitmaps()
       
   487     {
       
   488     delete iDefaultBatteryIndicatorBitmap;
       
   489     iDefaultBatteryIndicatorBitmap = NULL;
       
   490 
       
   491     delete iDefaultBatteryIndicatorBitmapMask;
       
   492     iDefaultBatteryIndicatorBitmapMask = NULL;
       
   493 
       
   494     delete iFlatBatteryIndicatorBitmap;
       
   495     iFlatBatteryIndicatorBitmap = NULL;
       
   496 
       
   497     delete iFlatBatteryIndicatorBitmapMask;
       
   498     iFlatBatteryIndicatorBitmapMask = NULL;
       
   499 
       
   500     delete iStaconLeftSideBatteryIndicatorBitmap;
       
   501     iStaconLeftSideBatteryIndicatorBitmap = NULL;
       
   502 
       
   503     delete iStaconLeftSideBatteryIndicatorBitmapMask;
       
   504     iStaconLeftSideBatteryIndicatorBitmapMask = NULL;
       
   505 
       
   506     delete iStaconRightSideBatteryIndicatorBitmap;
       
   507     iStaconRightSideBatteryIndicatorBitmap = NULL;
       
   508 
       
   509     delete iStaconRightSideBatteryIndicatorBitmapMask;
       
   510     iStaconRightSideBatteryIndicatorBitmapMask = NULL;
       
   511     }
       
   512 
       
   513 
       
   514 // ---------------------------------------------------------------------------
       
   515 // CAknBatteryStrength::HandleResourceChange
       
   516 // ---------------------------------------------------------------------------
       
   517 //
       
   518 void CAknBatteryStrength::HandleResourceChange( TInt aType )
       
   519     {
       
   520     if ( aType==KEikDynamicLayoutVariantSwitch ||
       
   521          aType == KEikColorResourceChange ||
       
   522          aType == KAknsMessageSkinChange)
       
   523         {
       
   524         DeleteBitmaps(); // SizeChanged reloads needed bitmaps
       
   525         SizeChanged();
       
   526 
       
   527         if ( aType == KEikDynamicLayoutVariantSwitch )
       
   528             {
       
   529             SetBatteryLevel( iBatteryLevel ); // refreshes battery level offsets
       
   530             }
       
   531 
       
   532         DrawDeferred();
       
   533         }
       
   534     }
       
   535 
       
   536 
       
   537 // ---------------------------------------------------------------------------
       
   538 // CAknBatteryStrength::DrawInNormalStatusPane
       
   539 // ---------------------------------------------------------------------------
       
   540 //
       
   541 void CAknBatteryStrength::DrawInNormalStatusPane( const TRect& /*aRect*/ ) const
       
   542     {
       
   543     CWindowGc& gc = SystemGc();
       
   544 
       
   545     TRect rect( Rect() );
       
   546     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   547 
       
   548     // Draws battery strength bar
       
   549     CAknsMaskedBitmapItemData* bitmap = NULL;
       
   550 
       
   551     if ( skin )
       
   552         {
       
   553         bitmap = static_cast<CAknsMaskedBitmapItemData*>(
       
   554             skin->GetCachedItemData(
       
   555                 KAknsIIDQgnIndiBatteryStrength, EAknsITMaskedBitmap ) );
       
   556         if ( bitmap )
       
   557             {
       
   558             if ( bitmap->Bitmap() )
       
   559                 {
       
   560                 AknIconUtils::SetSize( bitmap->Bitmap(),
       
   561                                        Size() );
       
   562                 }
       
   563             if ( bitmap->Mask() )
       
   564                 {
       
   565                 AknIconUtils::SetSize( bitmap->Mask(),
       
   566                                        Size() );
       
   567                 }
       
   568 
       
   569             gc.BitBltMasked(
       
   570                 TPoint( rect.iTl.iX, iDefaultBatteryBitmapOffset ),
       
   571                 bitmap->Bitmap(),
       
   572                 TRect( 0,
       
   573                        iDefaultBatteryBitmapOffset,
       
   574                        rect.Width(),
       
   575                        rect.Height() ),
       
   576                 bitmap->Mask(),
       
   577                 ETrue );
       
   578             }
       
   579         }
       
   580 
       
   581     if ( !bitmap )
       
   582         {
       
   583         if ( iDefaultBatteryIndicatorBitmap &&
       
   584              iDefaultBatteryIndicatorBitmapMask )
       
   585             {
       
   586             gc.BitBltMasked(
       
   587                 TPoint( rect.iTl.iX, iDefaultBatteryBitmapOffset ),
       
   588                 iDefaultBatteryIndicatorBitmap,
       
   589                 TRect( 0,
       
   590                        iDefaultBatteryBitmapOffset,
       
   591                        rect.Width(),
       
   592                        rect.Height() ),
       
   593                 iDefaultBatteryIndicatorBitmapMask,
       
   594                 ETrue );
       
   595             }
       
   596         }
       
   597 
       
   598     }
       
   599 
       
   600 
       
   601 // ---------------------------------------------------------------------------
       
   602 // CAknBatteryStrength::DrawInStaconPane
       
   603 // ---------------------------------------------------------------------------
       
   604 //
       
   605 void CAknBatteryStrength::DrawInStaconPane( const TRect& /*aRect*/ ) const
       
   606     {
       
   607     CWindowGc& gc = SystemGc();
       
   608 
       
   609     CFbsBitmap* bitmap = NULL;
       
   610     CFbsBitmap* mask   = NULL;
       
   611 
       
   612     TRect rect( Rect() );
       
   613 
       
   614     if ( AknStatuspaneUtils::StaconSoftKeysLeft() )
       
   615         {
       
   616         bitmap = iStaconRightSideBatteryIndicatorBitmap;
       
   617         mask   = iStaconRightSideBatteryIndicatorBitmapMask;
       
   618         }
       
   619     else
       
   620         {
       
   621         bitmap = iStaconLeftSideBatteryIndicatorBitmap;
       
   622         mask   = iStaconLeftSideBatteryIndicatorBitmapMask;
       
   623         }
       
   624 
       
   625     TPoint point( rect.iTl );
       
   626     if ( AknStatuspaneUtils::StaconSoftKeysLeft() && bitmap )
       
   627         {
       
   628         point = TPoint( rect.iBr.iX - bitmap->SizeInPixels().iWidth,
       
   629                         rect.iTl.iY );
       
   630         }
       
   631 
       
   632     if ( bitmap && mask )
       
   633         {
       
   634         gc.BitBltMasked(
       
   635             point,
       
   636             bitmap,
       
   637             TRect( 0, 0, rect.Width(), iStaconBatteryBitmapOffset ),
       
   638             mask,
       
   639             ETrue );
       
   640         }
       
   641 
       
   642     }
       
   643 
       
   644 
       
   645 // ---------------------------------------------------------------------------
       
   646 // CAknBatteryStrength::DrawInFlatStatusPane
       
   647 // ---------------------------------------------------------------------------
       
   648 //
       
   649 void CAknBatteryStrength::DrawInFlatStatusPane( const TRect& /*aRect*/ ) const
       
   650     {
       
   651     CWindowGc& gc = SystemGc();
       
   652 
       
   653     TRect rect( Rect() );
       
   654     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   655 
       
   656     // Draws battery strength bar
       
   657     CAknsMaskedBitmapItemData* bitmapData = NULL;
       
   658 
       
   659     if ( skin )
       
   660         {
       
   661         bitmapData = static_cast<CAknsMaskedBitmapItemData*>(
       
   662             skin->GetCachedItemData(
       
   663                 KAknsIIDQgnIndiBatteryStrength, EAknsITMaskedBitmap ) );
       
   664         if ( bitmapData )
       
   665             {
       
   666             CFbsBitmap* bitmap = bitmapData->Bitmap();
       
   667 
       
   668             if ( bitmap )
       
   669                 AknIconUtils::SetSize( bitmap,
       
   670                                        TSize( rect.Width(),
       
   671                                               rect.Height() ),
       
   672                                               EAspectRatioNotPreserved );
       
   673 
       
   674             TPoint point( 0, iFlatBatteryBitmapOffset );
       
   675             if ( bitmap && !AknLayoutUtils::LayoutMirrored() )
       
   676                 {
       
   677                 point = TPoint( rect.iBr.iX - bitmap->SizeInPixels().iWidth,
       
   678                                 iFlatBatteryBitmapOffset);
       
   679                 }
       
   680 
       
   681             gc.BitBltMasked(
       
   682                 point,
       
   683                 bitmap, TRect(0,iFlatBatteryBitmapOffset,
       
   684                 rect.Width(),
       
   685                 rect.Height()),
       
   686                 bitmapData->Mask(), ETrue );
       
   687             }
       
   688         }
       
   689 
       
   690     if ( !bitmapData )
       
   691         {
       
   692         if ( iFlatBatteryIndicatorBitmap && iFlatBatteryIndicatorBitmapMask )
       
   693             {
       
   694             TPoint point( 0, iFlatBatteryBitmapOffset );
       
   695             if ( !AknLayoutUtils::LayoutMirrored() )
       
   696                 {
       
   697                 point = TPoint(
       
   698                     rect.iBr.iX - iFlatBatteryIndicatorBitmap->SizeInPixels().iWidth,
       
   699                     iFlatBatteryBitmapOffset );
       
   700                 }
       
   701             gc.BitBltMasked(
       
   702                 point,
       
   703                 iFlatBatteryIndicatorBitmap,
       
   704                 TRect( 0,
       
   705                        iFlatBatteryBitmapOffset,
       
   706                        rect.Width(),
       
   707                        rect.Height() ),
       
   708                 iFlatBatteryIndicatorBitmapMask,
       
   709                 ETrue );
       
   710             }
       
   711         }
       
   712 
       
   713     }
       
   714 
       
   715 
       
   716 // ---------------------------------------------------------------------------
       
   717 // CAknBatteryStrength::SetRecharging
       
   718 // ---------------------------------------------------------------------------
       
   719 //
       
   720 void CAknBatteryStrength::SetRecharging( TBool aRecharging )
       
   721     {
       
   722     iRecharging = aRecharging;
       
   723     }
       
   724 
       
   725 
       
   726 // ---------------------------------------------------------------------------
       
   727 // CAknBatteryStrength::Recharging
       
   728 // ---------------------------------------------------------------------------
       
   729 //
       
   730 TBool CAknBatteryStrength::Recharging()
       
   731     {
       
   732     return iRecharging;
       
   733     }
       
   734 
       
   735 //  End of File