class Alf::ResourcePool |
Resoure pool is responsible of controlling commonly used image resources in an application. The resources will be indentified by tags, which are not case sensitive.
// create image resources resourcePool->createLogicalImageResource( "qgn_indi_find_glass" ); resourcePool->setInitialSize( "qgn_indi_find_glass", XYMetric( 64, 64 ) ); resourcePool->setAspectRatio( "qgn_indi_find_glass", ResourcePool::aspectRatioPreserved ); resourcePool->createImageResource( "my_face", pic0001.jpg ); // utilize the resource imageVisual->setImage( resourcePool->getImageResource( "qgn_indi_find_glass" ) ); sharpImageVisual->setImage( resourcePool->getImageResource( "my_face" ), XYMetric( 256, 256 ) ); // when the resource in not used anymore, the resource can be deleted resourcePool->deleteImageResource( "qgn_indi_find_glass" ); resourcePool->deleteImageResource( "my_face" );
Public Member Functions | |
---|---|
ResourcePool (CAlfTextureManager &, ResourcePool *) | |
~ResourcePool () | |
OSN_IMPORT void | createFileImageResource (const Utf8 *, const UString &, TAlfTextureFlags ) |
OSN_IMPORT void | createLogicalImageResource (const Utf8 *) |
OSN_IMPORT void | createThemeImageResource (const Utf8 *, const UString &) |
OSN_IMPORT void | deleteImageResource (const Utf8 *) |
OSN_IMPORT TAlfImage | getImageResource (const Utf8 *) |
OSN_IMPORT TAlfImage | getImageResource (const Utf8 *, const TAlfXYMetric &) |
OSN_IMPORT bool | hasImageResource (const Utf8 *) |
OSN_IMPORT void | setAspectRatio (const Utf8 *, AspectRatio ) |
OSN_IMPORT void | setInitialSize (const Utf8 *, const TAlfXYMetric &) |
Public Member Enumerations | |
---|---|
enum | AspectRatio { aspectRatioPreserved = 0, aspectRatioPreservedAndUnusedSpaceRemoved = 1, aspectRatioNotPreserved = 2, aspectRatioPreservedSlice = 3 } |
Private Attributes | |
---|---|
auto_ptr < ResourcePoolImpl > | mResourcePoolImpl |
OSN_IMPORT | ResourcePool | ( | CAlfTextureManager & | aTextureManager, |
ResourcePool * | aParentPool = NULL | |||
) |
Constructs a resource pool
CAlfTextureManager & aTextureManager | Used texture manager. |
ResourcePool * aParentPool = NULL | Chained parent pool (optional) - not supported currently |
OSN_IMPORT void | createFileImageResource | ( | const Utf8 * | aTag, |
const UString & | aFileName, | |||
TAlfTextureFlags | aFlag = EAlfTextureFlagLoadAnimAsImage | |||
) |
Creates an image resource based on a file name. The aFileName can be a full path with the drive letter or it can be relative path to the texture manager defaul path
TextureManager::setImagePath()
const Utf8 * aTag | Resource tag. |
const UString & aFileName | File name. |
TAlfTextureFlags aFlag = EAlfTextureFlagLoadAnimAsImage | How to convert the bitmap to texture default all fileimages will be treated as nonanimated |
OSN_IMPORT void | createLogicalImageResource | ( | const Utf8 * | aTag | ) |
Creates an image resource based on a logical name. The name will be also used as the image resource tag because the logical name is unique in the system.
The logical name should be format "qgn_xxx_xxx" i.e. as stated in the S60 reference icons document.
The KAknsIIDQgnXxxXxx format works for a while but it will be deprecated -> use the qgn_xxx_xxx format.
invalid_argument |
if the tag cannot be matched with any logical name |
const Utf8 * aTag | Resource tag. NULL terminated 8-bit string |
OSN_IMPORT void | createThemeImageResource | ( | const Utf8 * | aTag, |
const UString & | aThemeDefinition | |||
) |
Creates an image resource based on a theme definition. This definition may concists of several different theme systems.
Currently supported formats: #1 S60 Skin; s60;mifFilePath;mifImageIndex;mifMaskIndex;majorID;minorId
s60: literal "s60", which specifies that the following item definition is based on the S60 Skin system mifFilePath: literal into the multibitmap file (mif/mbm). Can be empty. mifImageIndex:unsigned integer which is the index to the mifFilePath. Only used if mifFilePath is given. mifMaskIndex: unsigned integer which is the mask index to the mifFilePath. Only used if mifFilePath is given. majorID: unsigned integer or hexadecimal starting with 0x of the Major skin ID. Can be empty. minorId: unsigned integer or hexadecimal starting with 0x of the Minor skin ID. Only used if majorID is given.
examples: "s60;;;;268457670;76" // 0x100056c6;0x4c -> KAknsIIDQgnIndiFindGlass "s60;c:\myFile.mif;1;2;;" "s60;myMbmFile.mbm;435;;2342345;234" // If skin ID not found, use mbm file with index 435 (no mask)
invalid_argument |
theme definition is not supported. |
const Utf8 * aTag | Resource tag. |
const UString & aThemeDefinition | Definition of the theme element. |
OSN_IMPORT void | deleteImageResource | ( | const Utf8 * | aTag | ) |
Deletes image resource
const Utf8 * aTag | Resource tag. |
OSN_IMPORT TAlfImage | getImageResource | ( | const Utf8 * | aTag | ) |
Finds a image resource with the given tag. The initial size or system default size is used.
If the given resource is not found, the Image::hasTexture() returns false.
invalid_argument |
if the resource is found but cannot be instantiated |
const Utf8 * aTag | Resource tag. |
OSN_IMPORT TAlfImage | getImageResource | ( | const Utf8 * | aTag, |
const TAlfXYMetric & | aSizeHint | |||
) |
Finds a image resouce with the given tag. The size hint may be used to find/re-rasterize the image resource.
If the given resource is not found, the Image::hasTexture() returns false.
invalid_argument |
if the resource is found but cannot be instantiated |
const Utf8 * aTag | Resource tag. |
const TAlfXYMetric & aSizeHint | Rasteration size hint (only Pixel and RelativeToDisplay supported) |
OSN_IMPORT bool | hasImageResource | ( | const Utf8 * | aTag | ) | const |
Checks if the given resource identifier exists.
const Utf8 * aTag | Resource tag. |
OSN_IMPORT void | setAspectRatio | ( | const Utf8 * | aTag, |
AspectRatio | aAspectRatio | |||
) |
Sets aspect ratio mode. This affects to the aspect ratio of the loaded image resource. The new setting will take place when the image resource is loaded.
Currently only SVG icons are supported. For file image loading, the aspect ratio is preserved.
The blitting of the image resource can still scale and change the aspect ratio of the drawn image.
const Utf8 * aTag | Resource tag. |
AspectRatio aAspectRatio | Used aspect ratio. |
OSN_IMPORT void | setInitialSize | ( | const Utf8 * | aTag, |
const TAlfXYMetric & | aInitialSizeHint | |||
) |
Sets initial/default loading size for the image resource. The given size is only a hint and the resource pool may used it or ignore it. Without the initial size hint, the image will be rasterized to size determined by the resource pool. The initial size hint can be overridden with the appropriate getImageResource() function.
const Utf8 * aTag | Resource tag. |
const TAlfXYMetric & aInitialSizeHint | Initial/default size hint (only Pixel and RelativeToDisplay supported) |
aspectRatioPreserved = 0 | |
aspectRatioPreservedAndUnusedSpaceRemoved = 1 | |
aspectRatioNotPreserved = 2 | |
aspectRatioPreservedSlice = 3 |
auto_ptr < ResourcePoolImpl > | mResourcePoolImpl | [private] |
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.