menufw/hierarchynavigator/hnpresentationmodel/src/hnattrimgprovthememif.cpp
changeset 0 f72a12da539e
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:  image provider for mif file
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <AknsSkinInstance.h>
       
    20 #include <AknsUtils.h>
       
    21 #include <mifconvdefs.h>
       
    22 #include "hnattrimgprovthememif.h"
       
    23 
       
    24 
       
    25 // ============================ MEMBER FUNCTIONS =============================
       
    26 
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // 
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 CHnAttrImgProvThemeMif::CHnAttrImgProvThemeMif( )
       
    33     {
       
    34     }
       
    35 
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // 
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 void CHnAttrImgProvThemeMif::ConstructL( TAknsItemID aSkinId,
       
    42         const TDesC& aFile, TInt aBitmapId, TInt aMaskId )
       
    43     {
       
    44     iSkinId = aSkinId;
       
    45     iFile.Set( aFile );
       
    46     iBitmapId = aBitmapId;
       
    47     iMaskId = aMaskId;
       
    48 
       
    49     CFbsBitmap* bitmap;
       
    50     CFbsBitmap* mask;
       
    51     if ( ValidateIconIds() )
       
    52         {
       
    53         ProvideBitmapL( NULL, bitmap, mask );
       
    54         CreateIconL( bitmap, mask );
       
    55         }
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // 
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 EXPORT_C CHnAttrImgProvThemeMif* CHnAttrImgProvThemeMif::NewL( 
       
    63         TAknsItemID aSkinId, const TDesC& aFile, 
       
    64         TInt aBitmapId, TInt aMaskId )
       
    65     {
       
    66     CHnAttrImgProvThemeMif* self = NewLC( aSkinId, aFile, 
       
    67             aBitmapId, aMaskId );
       
    68     CleanupStack::Pop( self );
       
    69     return self;
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // 
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 TBool CHnAttrImgProvThemeMif::ValidateIconIds()
       
    77     {
       
    78     return ((iSkinId.iMajor != KErrNotFound && iSkinId.iMinor != KErrNotFound)
       
    79             || (iBitmapId >= KMifIdFirst && iMaskId >= KMifIdFirst));
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // 
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 EXPORT_C CHnAttrImgProvThemeMif* CHnAttrImgProvThemeMif::NewLC( 
       
    87         TAknsItemID aSkinId, const TDesC& aFile,
       
    88         TInt aBitmapId, TInt aMaskId )
       
    89     {
       
    90     CHnAttrImgProvThemeMif* self = new( ELeave ) CHnAttrImgProvThemeMif;
       
    91     CleanupStack::PushL( self );
       
    92     self->ConstructL( aSkinId, aFile, aBitmapId, aMaskId );
       
    93     return self;
       
    94     }
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // 
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 CHnAttrImgProvThemeMif::~CHnAttrImgProvThemeMif()
       
   101     {
       
   102     }
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 // 
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 const TDesC8& CHnAttrImgProvThemeMif::Value( )
       
   109     {
       
   110     return iValue;
       
   111     }
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 //
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 void CHnAttrImgProvThemeMif::ProvideBitmapL( TInt /*aId*/, CFbsBitmap*& aBitmap, 
       
   118         CFbsBitmap*& aMaskBitmap )
       
   119     {
       
   120     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   121     AknsUtils::CreateIconL( skin, iSkinId, aBitmap, aMaskBitmap,
       
   122             iFile, iBitmapId, iMaskId );
       
   123     }
       
   124 
       
   125