2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Phonebook icon info class definition.
20 #ifndef __PbkIconInfo_H__
21 #define __PbkIconInfo_H__
24 #include <e32base.h> // CBase
25 #include <PbkIconId.hrh> // TPbkIconId
26 #include <AknsItemID.h> // TAknsItemID
28 // FORWARD DECLARATIONS
29 class TResourceReader;
32 class CPbkIconInfoContainer;
33 class MAknsSkinInstance;
38 * Phonebook icon information encapsulating class.
39 * @see CPbkIconInfoContainer
46 * Returns the unique Phonebook icon id of this icon.
47 * @return The unique Phonebook icon id of this icon.
49 IMPORT_C TPbkIconId PbkIconInfoId() const;
52 * Returns the bitmap file name of this icon.
53 * @return The bitmap file name of this icon.
55 IMPORT_C const TDesC& MbmFileName() const;
58 * Returns this icon's id in the bitmap file.
59 * @return This icon's id in the bitmap file.
61 IMPORT_C TInt IconId() const;
64 * Returns this icon's mask id in the bitmap file.
65 * @return This icon's mask id in the bitmap file.
67 IMPORT_C TInt MaskId() const;
70 * Returns this icon's skin id.
71 * @return This icon's skin id.
73 IMPORT_C TAknsItemID SkinId() const;
76 * Returns this icon's color table id.
77 * @return This icon's color table id.
79 TAknsItemID ColorId() const;
82 * Returns this icon's index in the color table.
83 * @return This icon's index in the color table.
85 TInt ColorIndex() const;
88 * Returns this icon's index in the color table.
89 * @return This icon's index in the color table.
91 TInt DefaultColorIndex() const;
93 private: // Interface for CPbkIconInfoContainer
94 friend class CPbkIconInfoContainer;
97 void ReadFromResourceLC(TResourceReader& aReader);
100 private: // Unimplemented functions
101 /// Private, unimplemented copy constructor
102 TPbkIconInfo(const TPbkIconInfo&);
103 /// Private, unimplemented assignment operator
104 TPbkIconInfo& operator=(const TPbkIconInfo&);
106 private: // data members
107 // Own: unique phonebook icon id
108 TPbkIconId iPbkIconInfoId;
113 // Ref: Mbm file name
118 TAknsItemID iColorId;
121 /// Own: Default color index
122 TInt iDefaultColorIndex;
127 * Collection of phonebook icon info objects.
131 class CPbkIconInfoContainer : public CBase
133 public: // Constructors and destructor
135 * Creates a new instance of this class intialized with Phonebook
136 * default icon info from PbkView.rsc. Note that PbkView.rsc has to
137 * be loaded, see RPbkViewResourceFile.
139 * @param aCoeEnv Optional CCoeEnv instance. This function performs
140 * faster if this parameter is provided.
141 * @return A new instance of this class.
143 IMPORT_C static CPbkIconInfoContainer* NewL(CCoeEnv* aCoeEnv=NULL);
146 * Creates a new instance of this class.
148 * @param aReader Resource reader initialized to point to an array
149 * of PBK_ICON_INFO resources.
150 * @return A new instance of this class.
152 IMPORT_C static CPbkIconInfoContainer* NewL(TResourceReader& aReader);
155 * Creates a new instance of this class.
157 * @param aResourceId Resource id of an array of PBK_ICON_INFO
158 * resources. Phonebook default icon info
159 * array's resource id is R_PBK_ICON_INFO_ARRAY
161 * @param aCoeEnv Optional CCoeEnv instance. This function performs
162 * faster if this parameter is provided.
163 * @return A new instance of this class.
165 IMPORT_C static CPbkIconInfoContainer* NewL
166 (TInt aResourceId, CCoeEnv* aCoeEnv=NULL);
171 ~CPbkIconInfoContainer();
175 * Finds a particular TPbkIconInfo in the container.
177 * @param aIconId Id of the icon info to search.
178 * @return Matching icon info or NULL if not found.
180 IMPORT_C const TPbkIconInfo* Find(TPbkIconId aIconId) const;
183 * Creates and returns a CGulIcon object corresponding to the aIconId.
184 * ownership of the returned object is transferred to the client. Returns
185 * NULL if icon id is not in the array.
187 * @param aIconId Phonebook icon id.
188 * @return Icon object corresponding to the icon id. NULL if not found.
190 IMPORT_C CGulIcon* LoadBitmapL(TPbkIconId aIconId) const;
193 * Appends new icon info elements from aResourceId. The resource must
194 * be of PBK_ICON_INFO type.
196 * @param aResourceId Resource id for icon infos to be added.
198 IMPORT_C void AppendIconsFromResourceL(TInt aResourceId);
200 private: // Implementation
201 CPbkIconInfoContainer();
202 void ConstructL(TResourceReader& aReader);
203 void DoAppendIconsFromResourceL(TResourceReader& aReader);
205 private: // data members
206 /// Own: array of icon infos
207 RArray<TPbkIconInfo> iIconArray;
211 * Phonebook icon utilility class. This class is a helper class
212 * for loading skinned bitmaps.
218 * Creates a skinned icon from the aIconInfo information.
219 * @param aSkin Pointer to a skin instance.
220 * @param aBitmap Bitmap to set.
221 * @param aMask Mask to set.
222 * @param aIconInfo Bitmap and mask information.
224 IMPORT_C static void CreateIconL(
225 MAknsSkinInstance* aSkin,
226 CFbsBitmap*& aBitmap,
228 const TPbkIconInfo& aIconInfo);
231 * Creates a skinned icon from the aIconInfo information.
232 * @param aSkin Pointer to a skin instance.
233 * @param aBitmap Bitmap to set.
234 * @param aMask Mask to set.
235 * @param aIconInfo Bitmap and mask information.
237 IMPORT_C static void CreateIconLC(
238 MAknsSkinInstance* aSkin,
239 CFbsBitmap*& aBitmap,
241 const TPbkIconInfo& aIconInfo);
248 #endif // __PbkIconInfo_H__