uidesigner/com.nokia.sdt.series60.componentlibrary/components/LoadAndScaleIconL.inc
author Dan Podwall <dan.podwall@nokia.com>
Mon, 27 Apr 2009 15:10:32 -0500
branchRCL_2_0
changeset 129 d13aa008da33
parent 2 d760517a8095
permissions -rw-r--r--
merge RCL_2_0 to MCL
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
cawthron
parents:
diff changeset
     1
		<defineLocation id="LOADANDSCALEICONL_METHOD" baseLocation="MAIN_FILE"
cawthron
parents:
diff changeset
     2
			owned="true"
cawthron
parents:
diff changeset
     3
			location="function(${className}::LoadAndScaleIconL(const TDesC&amp;,TInt,TInt,TSize*,TScaleMode))">
cawthron
parents:
diff changeset
     4
			<template><![CDATA[
cawthron
parents:
diff changeset
     5
/**
cawthron
parents:
diff changeset
     6
 *	This routine loads and scales a bitmap or icon.
cawthron
parents:
diff changeset
     7
 *
cawthron
parents:
diff changeset
     8
 *	@param aFileName the MBM or MIF filename
cawthron
parents:
diff changeset
     9
 *	@param aBitmapId the bitmap id
cawthron
parents:
diff changeset
    10
 *	@param aMaskId the mask id or -1 for none
cawthron
parents:
diff changeset
    11
 *	@param aSize the TSize for the icon, or NULL to use real size
cawthron
parents:
diff changeset
    12
 *	@param aScaleMode one of the EAspectRatio* enums when scaling
cawthron
parents:
diff changeset
    13
 *
cawthron
parents:
diff changeset
    14
 */
cawthron
parents:
diff changeset
    15
CGulIcon* ${className}::LoadAndScaleIconL( 
cawthron
parents:
diff changeset
    16
		const TDesC& aFileName,
cawthron
parents:
diff changeset
    17
		TInt aBitmapId, 
cawthron
parents:
diff changeset
    18
		TInt aMaskId, 
cawthron
parents:
diff changeset
    19
		TSize* aSize, 
cawthron
parents:
diff changeset
    20
		TScaleMode aScaleMode )
cawthron
parents:
diff changeset
    21
	{
cawthron
parents:
diff changeset
    22
	CFbsBitmap* bitmap;
cawthron
parents:
diff changeset
    23
	CFbsBitmap* mask;
cawthron
parents:
diff changeset
    24
	AknIconUtils::CreateIconL( bitmap, mask, aFileName, aBitmapId, aMaskId );
cawthron
parents:
diff changeset
    25
	
cawthron
parents:
diff changeset
    26
	TSize size;
cawthron
parents:
diff changeset
    27
	if ( aSize == NULL )
cawthron
parents:
diff changeset
    28
		{
cawthron
parents:
diff changeset
    29
		// Use size from the image header.  In case of SVG,
cawthron
parents:
diff changeset
    30
		// we preserve the image data for a while longer, since ordinarily
cawthron
parents:
diff changeset
    31
		// it is disposed at the first GetContentDimensions() or SetSize() call.
cawthron
parents:
diff changeset
    32
		AknIconUtils::PreserveIconData( bitmap );
cawthron
parents:
diff changeset
    33
		AknIconUtils::GetContentDimensions( bitmap, size );
cawthron
parents:
diff changeset
    34
		}
cawthron
parents:
diff changeset
    35
	else
cawthron
parents:
diff changeset
    36
		{
cawthron
parents:
diff changeset
    37
		size = *aSize;
cawthron
parents:
diff changeset
    38
		}
cawthron
parents:
diff changeset
    39
	
cawthron
parents:
diff changeset
    40
	AknIconUtils::SetSize( bitmap, size, aScaleMode );
cawthron
parents:
diff changeset
    41
	AknIconUtils::SetSize( mask, size, aScaleMode );
cawthron
parents:
diff changeset
    42
	
cawthron
parents:
diff changeset
    43
	if ( aSize == NULL )
cawthron
parents:
diff changeset
    44
		{
cawthron
parents:
diff changeset
    45
		AknIconUtils::DestroyIconData( bitmap );
cawthron
parents:
diff changeset
    46
		}
cawthron
parents:
diff changeset
    47
	
cawthron
parents:
diff changeset
    48
	return CGulIcon::NewL( bitmap, mask );
cawthron
parents:
diff changeset
    49
	}
cawthron
parents:
diff changeset
    50
]]>
cawthron
parents:
diff changeset
    51
			</template>
cawthron
parents:
diff changeset
    52
		</defineLocation>