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.
14 * Description: Defines a public interface class MAknsSkinInstance and related
20 #ifndef AKNSSKININSTANCE_H
21 #define AKNSSKININSTANCE_H
26 #include <AknsDataContext.h>
27 #include <AknsItemData.h>
29 // FORWARD DECLARATIONS
36 * Type enumeration for skin client errors.
45 EAknsClientErrorUnspecified = 0,
52 EAknsClientErrorOOM = -4
56 * Type enumeration for the last skin change reason.
61 enum TAknsSkinChangeReason
63 // For normal skin change events, ie. all item change
64 ENormalSkinChange = 0,
65 // When a morphing state is changed, ie. only backgrounds change
66 EMorphingStateChange = 1,
67 // When the wallpaper is changed, ie. only the wallpaper change
75 * Interface to skin instance.
76 * Skin instance is a singleton object that can be retrieved using
77 * AknsUtils::SkinInstance(). It maintains item cache, but also
78 * local item definition list and root data context. While skin instance
79 * can be used directly by client code, it is often easier to use utility
80 * methods provided in AknsUtils and AknsDrawUtils.
82 * This is a public interface class that contains no exported functions.
83 * The class is not intended for derivation outside the library.
87 class MAknsSkinInstance
89 public: // Constructors and destructor
92 * Destructor for internal use.
93 * Destructor is reserved for internal use and should be never
94 * called by client code on singleton instance.
98 inline virtual ~MAknsSkinInstance() {}
100 public: // New functions - Item data
103 * Returns root data context.
104 * Root data context is used by other data context instances to
105 * indicate data reservations and releases. It may also be used
106 * directly by application code, if no other context is available.
107 * Nearest data context can be retrieved using
108 * AknsUtils::DataContext(MObjectProvider* aMop) utility method.
112 * @return Pointer to root data context. Skin instance still owns the
113 * data context and its lifetime is that of skin instance itself.
115 virtual MAknsDataContext* RootDataContext() =0;
118 * Returns (and constructs if necessary) cached item data object.
119 * The method first searches the cache for the specified item.
120 * If none is found, it creates and caches a new instance of the
125 * @param aID Item ID of the item to be retrieved.
127 * @param aType Type of the item.
129 * @return Item data for the specified item, or @c NULL value if
130 * none was found or an error occured. The caller can assume that a
131 * non-NULL value is a pointer that can be casted to the subclass
132 * corresponding to aType.
135 * Since this is a non-leaving method, the skin instance may perform
136 * error handling, e.g., by instructing the system to switch to the
139 virtual CAknsItemData* GetCachedItemData( const TAknsItemID& aID,
140 const TAknsItemType aType ) =0;
143 * Returns (and constructs if necessary) cached item data object.
144 * The method first searches the cache for the specified item.
145 * If none is found, it creates and caches a new instance of the
148 * This overload can be used to retrieve items if the type of the
149 * item is not known beforehand. In other cases, the first overload
150 * shold be preferred, since it may be considerably faster.
154 * @param aID Item ID of the item to be retrieved.
156 * @return Item data for the specified item, or @c NULL value if
157 * none was found or an error occured.
160 * Since this is a non-leaving method, the skin instance may perform
161 * error handling, e.g., by instructing the system to switch to the
164 virtual CAknsItemData* GetCachedItemData( const TAknsItemID& aID ) =0;
167 * Creates a new non-cached item data object.
168 * The method constructs a new instance of item data of the specified
169 * skin item and returns it.
173 * @param aID Item ID of the item to be created.
175 * @param aType Type of the item.
177 * @return Newly created item data object. Ownership of the object is
178 * transferred to the caller. If no item definition for the specified
179 * ID was found, @c NULL value is returned. The caller can assume that
180 * a non-NULL value is a pointer that can be casted to the subclass
181 * corresponding to aType.
184 * If item data construction fails, function leaves with an error code.
186 virtual CAknsItemData* CreateUncachedItemDataL( const TAknsItemID& aID,
187 const TAknsItemType aType ) =0;
190 * Creates a new non-cached item data object.
191 * The method constructs a new instance of item data of the specified
192 * skin item and returns it.
194 * This overload can be used to create items if the type of the
195 * item is not known beforehand. In other cases, the first overload
196 * shold be preferred, since it may be considerably faster.
200 * @param aID Item ID of the item to be created.
202 * @return Newly created item data object. Ownership of the object is
203 * transferred to the caller. If no item definition for the specified
204 * ID was found, @c NULL value is returned.
207 * If item data construction fails, function leaves with an error code.
209 virtual CAknsItemData* CreateUncachedItemDataL( const TAknsItemID& aID ) =0;
211 public: // New functions - Item definitions
214 * Sets local item definition.
215 * Adds (or replaces if one already exists) a local item definition.
219 * @param aDef New local item definition. Ownership of definition object
220 * is transferred to skin instance and caller should make no access
221 * to it after this call.
224 * If an error occurs, function leaves with an error code. Item
225 * definition object is either added into local definition list or
226 * destroyed depending on when the error occured.
229 * Since the method always assumes ownership of @c aDef, it must
230 * not be pushed into the cleanup stack.
232 virtual void SetLocalItemDefL( CAknsItemDef* aDef ) =0;
235 * Enables or disables change notifications.
236 * When enabled, resource change events are sent to the application when
237 * item definitions change. If a change occurs when events are disabled,
238 * it will be sent (collated, only one event) when events are re-enabled.
242 * @param aEnabled ETrue to enable events, EFalse to disable them.
244 virtual void SetChangeEventsEnabled( TBool aEnabled ) =0;
246 public: // New functions - Error handling
249 * Notifies the skin instance about an error condition.
250 * Errors that can be reported to the skin instance include incorrect
251 * skin content (e.g., a bitmap that can not be constructed) or
252 * out of memory situations. The error condition is usually handled by
253 * switching to the default system skin. Error notifications will be
254 * ignored when there is no reasonable recovery operation available.
258 * @param aError Error type. Currently only EAknsClientErrorUnspecified
261 virtual void NotifyClientError( const TAknsClientError aError ) =0;
263 public: // New functions - querying the skin change reason.
265 * Queries the last skin change reason. This function can be used
266 * to query the last reason why skin change occurred. Usually client
267 * would use this inside the HandleResourceChange call. If no skin
268 * change events have been reported for the application, the function
269 * returns ENormalSkinChange.
273 * @return the last skin change reason.
275 virtual TAknsSkinChangeReason SkinChangeReason() = 0;
279 * Removes all local item defs from this instance set by
282 virtual void RemoveLocalItemDefs() = 0;
285 * Checks whether a skin update is currently being done.
289 virtual TBool IsUpdateInProgress() = 0;
292 #endif // AKNSSKININSTANCE_H