williamr@4
|
1 |
/*
|
williamr@4
|
2 |
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@4
|
3 |
* All rights reserved.
|
williamr@4
|
4 |
* This component and the accompanying materials are made available
|
williamr@4
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
williamr@4
|
6 |
* which accompanies this distribution, and is available
|
williamr@4
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
williamr@4
|
8 |
*
|
williamr@4
|
9 |
* Initial Contributors:
|
williamr@4
|
10 |
* Nokia Corporation - initial contribution.
|
williamr@4
|
11 |
*
|
williamr@4
|
12 |
* Contributors:
|
williamr@4
|
13 |
*
|
williamr@4
|
14 |
* Description: Defines a public interface class MAknsSkinInstance and related
|
williamr@4
|
15 |
* enumerations.
|
williamr@4
|
16 |
*
|
williamr@4
|
17 |
*/
|
williamr@4
|
18 |
|
williamr@4
|
19 |
|
williamr@4
|
20 |
#ifndef AKNSSKININSTANCE_H
|
williamr@4
|
21 |
#define AKNSSKININSTANCE_H
|
williamr@4
|
22 |
|
williamr@4
|
23 |
// INCLUDES
|
williamr@4
|
24 |
#include <e32std.h>
|
williamr@4
|
25 |
|
williamr@4
|
26 |
#include <AknsDataContext.h>
|
williamr@4
|
27 |
#include <AknsItemData.h>
|
williamr@4
|
28 |
|
williamr@4
|
29 |
// FORWARD DECLARATIONS
|
williamr@4
|
30 |
class CFbsBitGc;
|
williamr@4
|
31 |
class CAknsItemDef;
|
williamr@4
|
32 |
|
williamr@4
|
33 |
// DATA TYPES
|
williamr@4
|
34 |
|
williamr@4
|
35 |
/**
|
williamr@4
|
36 |
* Type enumeration for skin client errors.
|
williamr@4
|
37 |
*
|
williamr@4
|
38 |
* @since 2.0
|
williamr@4
|
39 |
*/
|
williamr@4
|
40 |
enum TAknsClientError
|
williamr@4
|
41 |
{
|
williamr@4
|
42 |
/**
|
williamr@4
|
43 |
* Unspecified error.
|
williamr@4
|
44 |
*/
|
williamr@4
|
45 |
EAknsClientErrorUnspecified = 0,
|
williamr@4
|
46 |
|
williamr@4
|
47 |
/**
|
williamr@4
|
48 |
* Out of memory.
|
williamr@4
|
49 |
*
|
williamr@4
|
50 |
* @since 2.5
|
williamr@4
|
51 |
*/
|
williamr@4
|
52 |
EAknsClientErrorOOM = -4
|
williamr@4
|
53 |
};
|
williamr@4
|
54 |
|
williamr@4
|
55 |
/**
|
williamr@4
|
56 |
* Type enumeration for the last skin change reason.
|
williamr@4
|
57 |
*
|
williamr@4
|
58 |
* @since 3.1
|
williamr@4
|
59 |
*
|
williamr@4
|
60 |
*/
|
williamr@4
|
61 |
enum TAknsSkinChangeReason
|
williamr@4
|
62 |
{
|
williamr@4
|
63 |
// For normal skin change events, ie. all item change
|
williamr@4
|
64 |
ENormalSkinChange = 0,
|
williamr@4
|
65 |
// When a morphing state is changed, ie. only backgrounds change
|
williamr@4
|
66 |
EMorphingStateChange = 1,
|
williamr@4
|
67 |
// When the wallpaper is changed, ie. only the wallpaper change
|
williamr@4
|
68 |
EWallpaperChange = 2
|
williamr@4
|
69 |
};
|
williamr@4
|
70 |
|
williamr@4
|
71 |
|
williamr@4
|
72 |
// CLASS DECLARATION
|
williamr@4
|
73 |
|
williamr@4
|
74 |
/**
|
williamr@4
|
75 |
* Interface to skin instance.
|
williamr@4
|
76 |
* Skin instance is a singleton object that can be retrieved using
|
williamr@4
|
77 |
* AknsUtils::SkinInstance(). It maintains item cache, but also
|
williamr@4
|
78 |
* local item definition list and root data context. While skin instance
|
williamr@4
|
79 |
* can be used directly by client code, it is often easier to use utility
|
williamr@4
|
80 |
* methods provided in AknsUtils and AknsDrawUtils.
|
williamr@4
|
81 |
*
|
williamr@4
|
82 |
* This is a public interface class that contains no exported functions.
|
williamr@4
|
83 |
* The class is not intended for derivation outside the library.
|
williamr@4
|
84 |
*
|
williamr@4
|
85 |
* @since 2.0
|
williamr@4
|
86 |
*/
|
williamr@4
|
87 |
class MAknsSkinInstance
|
williamr@4
|
88 |
{
|
williamr@4
|
89 |
public: // Constructors and destructor
|
williamr@4
|
90 |
|
williamr@4
|
91 |
/**
|
williamr@4
|
92 |
* Destructor for internal use.
|
williamr@4
|
93 |
* Destructor is reserved for internal use and should be never
|
williamr@4
|
94 |
* called by client code on singleton instance.
|
williamr@4
|
95 |
*
|
williamr@4
|
96 |
* @internal
|
williamr@4
|
97 |
*/
|
williamr@4
|
98 |
inline virtual ~MAknsSkinInstance() {}
|
williamr@4
|
99 |
|
williamr@4
|
100 |
public: // New functions - Item data
|
williamr@4
|
101 |
|
williamr@4
|
102 |
/**
|
williamr@4
|
103 |
* Returns root data context.
|
williamr@4
|
104 |
* Root data context is used by other data context instances to
|
williamr@4
|
105 |
* indicate data reservations and releases. It may also be used
|
williamr@4
|
106 |
* directly by application code, if no other context is available.
|
williamr@4
|
107 |
* Nearest data context can be retrieved using
|
williamr@4
|
108 |
* AknsUtils::DataContext(MObjectProvider* aMop) utility method.
|
williamr@4
|
109 |
*
|
williamr@4
|
110 |
* @since 2.0
|
williamr@4
|
111 |
*
|
williamr@4
|
112 |
* @return Pointer to root data context. Skin instance still owns the
|
williamr@4
|
113 |
* data context and its lifetime is that of skin instance itself.
|
williamr@4
|
114 |
*/
|
williamr@4
|
115 |
virtual MAknsDataContext* RootDataContext() =0;
|
williamr@4
|
116 |
|
williamr@4
|
117 |
/**
|
williamr@4
|
118 |
* Returns (and constructs if necessary) cached item data object.
|
williamr@4
|
119 |
* The method first searches the cache for the specified item.
|
williamr@4
|
120 |
* If none is found, it creates and caches a new instance of the
|
williamr@4
|
121 |
* item data.
|
williamr@4
|
122 |
*
|
williamr@4
|
123 |
* @since 2.0
|
williamr@4
|
124 |
*
|
williamr@4
|
125 |
* @param aID Item ID of the item to be retrieved.
|
williamr@4
|
126 |
*
|
williamr@4
|
127 |
* @param aType Type of the item.
|
williamr@4
|
128 |
*
|
williamr@4
|
129 |
* @return Item data for the specified item, or @c NULL value if
|
williamr@4
|
130 |
* none was found or an error occured. The caller can assume that a
|
williamr@4
|
131 |
* non-NULL value is a pointer that can be casted to the subclass
|
williamr@4
|
132 |
* corresponding to aType.
|
williamr@4
|
133 |
*
|
williamr@4
|
134 |
* @par Exceptions:
|
williamr@4
|
135 |
* Since this is a non-leaving method, the skin instance may perform
|
williamr@4
|
136 |
* error handling, e.g., by instructing the system to switch to the
|
williamr@4
|
137 |
* default skin.
|
williamr@4
|
138 |
*/
|
williamr@4
|
139 |
virtual CAknsItemData* GetCachedItemData( const TAknsItemID& aID,
|
williamr@4
|
140 |
const TAknsItemType aType ) =0;
|
williamr@4
|
141 |
|
williamr@4
|
142 |
/**
|
williamr@4
|
143 |
* Returns (and constructs if necessary) cached item data object.
|
williamr@4
|
144 |
* The method first searches the cache for the specified item.
|
williamr@4
|
145 |
* If none is found, it creates and caches a new instance of the
|
williamr@4
|
146 |
* item data.
|
williamr@4
|
147 |
*
|
williamr@4
|
148 |
* This overload can be used to retrieve items if the type of the
|
williamr@4
|
149 |
* item is not known beforehand. In other cases, the first overload
|
williamr@4
|
150 |
* shold be preferred, since it may be considerably faster.
|
williamr@4
|
151 |
*
|
williamr@4
|
152 |
* @since 2.0
|
williamr@4
|
153 |
*
|
williamr@4
|
154 |
* @param aID Item ID of the item to be retrieved.
|
williamr@4
|
155 |
*
|
williamr@4
|
156 |
* @return Item data for the specified item, or @c NULL value if
|
williamr@4
|
157 |
* none was found or an error occured.
|
williamr@4
|
158 |
*
|
williamr@4
|
159 |
* @par Exceptions:
|
williamr@4
|
160 |
* Since this is a non-leaving method, the skin instance may perform
|
williamr@4
|
161 |
* error handling, e.g., by instructing the system to switch to the
|
williamr@4
|
162 |
* default skin.
|
williamr@4
|
163 |
*/
|
williamr@4
|
164 |
virtual CAknsItemData* GetCachedItemData( const TAknsItemID& aID ) =0;
|
williamr@4
|
165 |
|
williamr@4
|
166 |
/**
|
williamr@4
|
167 |
* Creates a new non-cached item data object.
|
williamr@4
|
168 |
* The method constructs a new instance of item data of the specified
|
williamr@4
|
169 |
* skin item and returns it.
|
williamr@4
|
170 |
*
|
williamr@4
|
171 |
* @since 2.0
|
williamr@4
|
172 |
*
|
williamr@4
|
173 |
* @param aID Item ID of the item to be created.
|
williamr@4
|
174 |
*
|
williamr@4
|
175 |
* @param aType Type of the item.
|
williamr@4
|
176 |
*
|
williamr@4
|
177 |
* @return Newly created item data object. Ownership of the object is
|
williamr@4
|
178 |
* transferred to the caller. If no item definition for the specified
|
williamr@4
|
179 |
* ID was found, @c NULL value is returned. The caller can assume that
|
williamr@4
|
180 |
* a non-NULL value is a pointer that can be casted to the subclass
|
williamr@4
|
181 |
* corresponding to aType.
|
williamr@4
|
182 |
*
|
williamr@4
|
183 |
* @par Exceptions:
|
williamr@4
|
184 |
* If item data construction fails, function leaves with an error code.
|
williamr@4
|
185 |
*/
|
williamr@4
|
186 |
virtual CAknsItemData* CreateUncachedItemDataL( const TAknsItemID& aID,
|
williamr@4
|
187 |
const TAknsItemType aType ) =0;
|
williamr@4
|
188 |
|
williamr@4
|
189 |
/**
|
williamr@4
|
190 |
* Creates a new non-cached item data object.
|
williamr@4
|
191 |
* The method constructs a new instance of item data of the specified
|
williamr@4
|
192 |
* skin item and returns it.
|
williamr@4
|
193 |
*
|
williamr@4
|
194 |
* This overload can be used to create items if the type of the
|
williamr@4
|
195 |
* item is not known beforehand. In other cases, the first overload
|
williamr@4
|
196 |
* shold be preferred, since it may be considerably faster.
|
williamr@4
|
197 |
*
|
williamr@4
|
198 |
* @since 2.0
|
williamr@4
|
199 |
*
|
williamr@4
|
200 |
* @param aID Item ID of the item to be created.
|
williamr@4
|
201 |
*
|
williamr@4
|
202 |
* @return Newly created item data object. Ownership of the object is
|
williamr@4
|
203 |
* transferred to the caller. If no item definition for the specified
|
williamr@4
|
204 |
* ID was found, @c NULL value is returned.
|
williamr@4
|
205 |
*
|
williamr@4
|
206 |
* @par Exceptions:
|
williamr@4
|
207 |
* If item data construction fails, function leaves with an error code.
|
williamr@4
|
208 |
*/
|
williamr@4
|
209 |
virtual CAknsItemData* CreateUncachedItemDataL( const TAknsItemID& aID ) =0;
|
williamr@4
|
210 |
|
williamr@4
|
211 |
public: // New functions - Item definitions
|
williamr@4
|
212 |
|
williamr@4
|
213 |
/**
|
williamr@4
|
214 |
* Sets local item definition.
|
williamr@4
|
215 |
* Adds (or replaces if one already exists) a local item definition.
|
williamr@4
|
216 |
*
|
williamr@4
|
217 |
* @since 2.0
|
williamr@4
|
218 |
*
|
williamr@4
|
219 |
* @param aDef New local item definition. Ownership of definition object
|
williamr@4
|
220 |
* is transferred to skin instance and caller should make no access
|
williamr@4
|
221 |
* to it after this call.
|
williamr@4
|
222 |
*
|
williamr@4
|
223 |
* @par Exceptions:
|
williamr@4
|
224 |
* If an error occurs, function leaves with an error code. Item
|
williamr@4
|
225 |
* definition object is either added into local definition list or
|
williamr@4
|
226 |
* destroyed depending on when the error occured.
|
williamr@4
|
227 |
*
|
williamr@4
|
228 |
* @par Note:
|
williamr@4
|
229 |
* Since the method always assumes ownership of @c aDef, it must
|
williamr@4
|
230 |
* not be pushed into the cleanup stack.
|
williamr@4
|
231 |
*/
|
williamr@4
|
232 |
virtual void SetLocalItemDefL( CAknsItemDef* aDef ) =0;
|
williamr@4
|
233 |
|
williamr@4
|
234 |
/**
|
williamr@4
|
235 |
* Enables or disables change notifications.
|
williamr@4
|
236 |
* When enabled, resource change events are sent to the application when
|
williamr@4
|
237 |
* item definitions change. If a change occurs when events are disabled,
|
williamr@4
|
238 |
* it will be sent (collated, only one event) when events are re-enabled.
|
williamr@4
|
239 |
*
|
williamr@4
|
240 |
* @since 2.0
|
williamr@4
|
241 |
*
|
williamr@4
|
242 |
* @param aEnabled ETrue to enable events, EFalse to disable them.
|
williamr@4
|
243 |
*/
|
williamr@4
|
244 |
virtual void SetChangeEventsEnabled( TBool aEnabled ) =0;
|
williamr@4
|
245 |
|
williamr@4
|
246 |
public: // New functions - Error handling
|
williamr@4
|
247 |
|
williamr@4
|
248 |
/**
|
williamr@4
|
249 |
* Notifies the skin instance about an error condition.
|
williamr@4
|
250 |
* Errors that can be reported to the skin instance include incorrect
|
williamr@4
|
251 |
* skin content (e.g., a bitmap that can not be constructed) or
|
williamr@4
|
252 |
* out of memory situations. The error condition is usually handled by
|
williamr@4
|
253 |
* switching to the default system skin. Error notifications will be
|
williamr@4
|
254 |
* ignored when there is no reasonable recovery operation available.
|
williamr@4
|
255 |
*
|
williamr@4
|
256 |
* @since 2.0
|
williamr@4
|
257 |
*
|
williamr@4
|
258 |
* @param aError Error type. Currently only EAknsClientErrorUnspecified
|
williamr@4
|
259 |
* is supported.
|
williamr@4
|
260 |
*/
|
williamr@4
|
261 |
virtual void NotifyClientError( const TAknsClientError aError ) =0;
|
williamr@4
|
262 |
|
williamr@4
|
263 |
public: // New functions - querying the skin change reason.
|
williamr@4
|
264 |
/**
|
williamr@4
|
265 |
* Queries the last skin change reason. This function can be used
|
williamr@4
|
266 |
* to query the last reason why skin change occurred. Usually client
|
williamr@4
|
267 |
* would use this inside the HandleResourceChange call. If no skin
|
williamr@4
|
268 |
* change events have been reported for the application, the function
|
williamr@4
|
269 |
* returns ENormalSkinChange.
|
williamr@4
|
270 |
*
|
williamr@4
|
271 |
* @since 3.1
|
williamr@4
|
272 |
*
|
williamr@4
|
273 |
* @return the last skin change reason.
|
williamr@4
|
274 |
*/
|
williamr@4
|
275 |
virtual TAknsSkinChangeReason SkinChangeReason() = 0;
|
williamr@4
|
276 |
|
williamr@4
|
277 |
public:
|
williamr@4
|
278 |
/**
|
williamr@4
|
279 |
* Removes all local item defs from this instance set by
|
williamr@4
|
280 |
* SetLocalItemDefL
|
williamr@4
|
281 |
*/
|
williamr@4
|
282 |
virtual void RemoveLocalItemDefs() = 0;
|
williamr@4
|
283 |
|
williamr@4
|
284 |
/**
|
williamr@4
|
285 |
* Checks whether a skin update is currently being done.
|
williamr@4
|
286 |
*
|
williamr@4
|
287 |
* @since 5.0
|
williamr@4
|
288 |
*/
|
williamr@4
|
289 |
virtual TBool IsUpdateInProgress() = 0;
|
williamr@4
|
290 |
};
|
williamr@4
|
291 |
|
williamr@4
|
292 |
#endif // AKNSSKININSTANCE_H
|
williamr@4
|
293 |
|
williamr@4
|
294 |
// End of File
|