williamr@2: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@4: // under the terms of "Eclipse Public License v1.0" williamr@2: // which accompanies this distribution, and is available williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: #ifndef __EIKRUTIL_H__ williamr@2: #define __EIKRUTIL_H__ williamr@2: williamr@2: #include williamr@2: #include williamr@2: williamr@2: class CFbsFont; williamr@2: class CEikonEnv; williamr@2: class CWsScreenDevice; williamr@2: class TResourceReader; williamr@2: williamr@2: williamr@2: /** Provides utilities for reading standard resources. williamr@2: williamr@2: @publishedAll williamr@2: @released */ williamr@2: NONSHARABLE_CLASS(EikResourceUtils) williamr@2: { williamr@2: public: williamr@2: inline static CFbsFont* CreateScreenFontL(TResourceReader& aResourceReader,CWsScreenDevice& aScreenDevice); williamr@2: IMPORT_C static CFbsFont* CreateScreenFontL(TInt aResourceId,CEikonEnv* aEnv=NULL); williamr@2: inline static TInt8 ReadTInt8L(TInt aResourceId,CEikonEnv* aEnv=NULL); williamr@2: inline static TInt16 ReadTInt16L(TInt aResourceId,CEikonEnv* aEnv=NULL); williamr@2: inline static TInt32 ReadTInt32L(TInt aResourceId,CEikonEnv* aEnv=NULL); williamr@2: IMPORT_C static CColorArray* CreateColorArrayL(TInt aResourceId,CEikonEnv* aEnv=NULL); williamr@2: IMPORT_C static CColorArray* CreateColorArrayLC(TInt aResourceId,CEikonEnv* aEnv=NULL); williamr@2: private: williamr@2: enum TResourceTypeInt { EResourceInt8,EResourceInt16,EResourceInt32 }; williamr@2: private: williamr@2: IMPORT_C static TInt32 ReadResourceIntL(TInt aResourceId, CEikonEnv* aEnv, TResourceTypeInt aSize); williamr@2: EikResourceUtils(); williamr@2: }; williamr@2: williamr@2: /** Create a screen font from resource. williamr@2: williamr@2: Creates a font for the specified screen device by reading a font UID and font williamr@2: flags from the given position in a resource. Returns a pointer to the font williamr@2: and transfers ownership. williamr@2: williamr@2: @param aResourceReader The resource reader to use to read the font. williamr@2: @param aScreenDevice The screen device for which the font will be created. williamr@2: @return Screen font object. */ williamr@2: inline CFbsFont* EikResourceUtils::CreateScreenFontL(TResourceReader& aResourceReader,CWsScreenDevice& aScreenDevice) williamr@2: { return(ResourceUtils::CreateScreenFontL(aResourceReader,aScreenDevice)); } williamr@2: williamr@2: /** Gets the 8 bit signed integer held in a specified resource location. williamr@2: williamr@2: @param aResourceId The location in the resource to be read. williamr@2: @param aEnv The UI environment. williamr@2: @return The eight bits that follow the specified location in the resource. */ williamr@2: inline TInt8 EikResourceUtils::ReadTInt8L(TInt aResourceId,CEikonEnv* aEnv) williamr@2: { return static_cast(ReadResourceIntL(aResourceId,aEnv,EResourceInt8)); } williamr@2: williamr@2: /** Gets the 16 bit signed integer held in a specified resource location. williamr@2: williamr@2: @param aResourceId The location in the resource to be read. williamr@2: @param aEnv The UI environment. williamr@2: @return The 16 bits that follow the specified location in the resource. */ williamr@2: inline TInt16 EikResourceUtils::ReadTInt16L(TInt aResourceId,CEikonEnv* aEnv) williamr@2: { return static_cast(ReadResourceIntL(aResourceId,aEnv,EResourceInt16)); } williamr@2: williamr@2: /** Gets the 32 bit signed integer held in a specified resource location. williamr@2: williamr@2: @param aResourceId The location in the resource to be read. williamr@2: @param aEnv The UI environment. williamr@2: @return The 32 bits that follow the specified location in the resource. */ williamr@2: inline TInt32 EikResourceUtils::ReadTInt32L(TInt aResourceId,CEikonEnv* aEnv) williamr@2: { return static_cast(ReadResourceIntL(aResourceId,aEnv,EResourceInt32)); } williamr@2: williamr@2: #endif // __EIKRUTIL_H__