internetradio2.0/uicontrolssrc/iriconloader.cpp
changeset 14 896e9dbc5f19
parent 12 608f67c22514
child 15 065198191975
equal deleted inserted replaced
12:608f67c22514 14:896e9dbc5f19
     1 /*
       
     2 * Copyright (c) 2006-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:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <akniconutils.h>
       
    20 #include <gulicon.h>
       
    21 
       
    22 #include "irdebug.h"
       
    23 #include "iriconloader.h"
       
    24 
       
    25 //---------------------------------------------------------------------------- 
       
    26 // Function:CIconFileProvider
       
    27 // this function is the Default constructor
       
    28 //---------------------------------------------------------------------------- 
       
    29 EXPORT_C CIconFileProvider::CIconFileProvider()
       
    30 	{
       
    31 	IRLOG_DEBUG( "CIconFileProvider::CIconFileProvider" );
       
    32 	}
       
    33 
       
    34 
       
    35 //---------------------------------------------------------------------------- 
       
    36 //  CIconFileProvider::NewL(..)
       
    37 //  Creates a new instance of CIconFileProvider view
       
    38 //  @param aRect Sets the control's extent, specifying a rectangle.
       
    39 //  @return An instance of CIconFileProvider
       
    40 //---------------------------------------------------------------------------- 
       
    41 //
       
    42 EXPORT_C CIconFileProvider* CIconFileProvider::NewL(const TDesC& aFilename)
       
    43 	{
       
    44     IRLOG_DEBUG( "CIconFileProvider::NewL" );  
       
    45     CIconFileProvider* self = new (ELeave) CIconFileProvider();
       
    46     CleanupStack::PushL(self);
       
    47     self->ConstructL(aFilename);
       
    48     CleanupStack::Pop( self ); // self
       
    49     IRLOG_DEBUG( "CIconFileProvider::NewL - Exiting." );
       
    50     return self;
       
    51 	}
       
    52 
       
    53 //---------------------------------------------------------------------------- 
       
    54 //  CIconFileProvider::ConstructL(..)
       
    55 //  Second phase constructor
       
    56 //  @param aFilename Full private path of the application
       
    57 //  @return void
       
    58 //---------------------------------------------------------------------------- 
       
    59 //
       
    60 void CIconFileProvider::ConstructL(const TDesC& aFilename)
       
    61 	{
       
    62     IRLOG_DEBUG( "CIconFileProvider::ConstructL" );
       
    63 	iFilename = aFilename.AllocL();
       
    64     IRLOG_DEBUG( "CIconFileProvider::ConstructL - Exiting." );
       
    65 	}
       
    66 
       
    67 
       
    68 //---------------------------------------------------------------------------- 
       
    69 // CIconFileProvider:: ~CIconFileProvider()
       
    70 // Default Destructor
       
    71 //----------------------------------------------------------------------------
       
    72 CIconFileProvider::	~CIconFileProvider()
       
    73 	{
       
    74 	IRLOG_DEBUG( "CIconFileProvider::~CIconFileProvider" );
       
    75 	delete iFilename;
       
    76 	}
       
    77 
       
    78 
       
    79 //---------------------------------------------------------------------------- 
       
    80 //  CIconFileProvider::CreateIconL(..)
       
    81 //  Creates an icon.
       
    82 //  The icon is created by loading the image bitmap identified by aBitmapId 
       
    83 //  and the mask identified by aMaskId. It returns a pointer to the icon and 
       
    84 // transfers ownership.
       
    85 //---------------------------------------------------------------------------- 
       
    86 //
       
    87 EXPORT_C CGulIcon* CIconFileProvider::CreateIconL(TInt aBitmapId,
       
    88 	TInt aMaskId) const
       
    89 	{
       
    90     IRLOG_DEBUG( "CIconFileProvider::CreateIconL" );
       
    91 	CGulIcon* icon = CGulIcon::NewL();
       
    92 	CFbsBitmap* mask = NULL;
       
    93 	CFbsBitmap* bitmap = NULL;
       
    94 	AknIconUtils::CreateIconL(bitmap , mask , *iFilename, aBitmapId , aMaskId);    
       
    95 	icon->SetBitmap(bitmap);
       
    96 	icon->SetMask(mask);
       
    97     IRLOG_DEBUG( "CIconFileProvider::CreateIconL - Exiting." );
       
    98 	return icon;
       
    99 	}
       
   100 
       
   101 //---------------------------------------------------------------------------- 
       
   102 //  CIconFileProvider::CreateIconL(.)
       
   103 //  Creates an icon.
       
   104 //  The icon is created by loading the image bitmap identified by aBitmapId.
       
   105 //  It returns a pointer to the icon and transfers ownership.
       
   106 //  @param aBitmapId The bitmap ID.
       
   107 //  @param aMaskId The bitmap mask ID.
       
   108 //  @return A pointer to the icon
       
   109 //---------------------------------------------------------------------------- 
       
   110 //
       
   111 EXPORT_C CFbsBitmap* CIconFileProvider::CreateIconL(TInt aBitmapId) const
       
   112 	{
       
   113     IRLOG_DEBUG( "CIconFileProvider::CreateIconL" );
       
   114 	if(aBitmapId!=-1)
       
   115 		{
       
   116 		CFbsBitmap* bitmap = NULL;
       
   117 		
       
   118 		//The icon is created by loading the image bitmap identified
       
   119 		// by aBitmapId.
       
   120 		bitmap = AknIconUtils::CreateIconL(*iFilename, aBitmapId);    
       
   121 		return bitmap;
       
   122 		}
       
   123     IRLOG_DEBUG( "CIconFileProvider::CreateIconL - Exiting." );
       
   124 	return NULL;
       
   125 	}
       
   126