|
1 /* |
|
2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Defines an internal static factory class AknsItemDataFactory. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "AknsCppPreface.h" |
|
21 |
|
22 #include <eikenv.h> |
|
23 #include <AknIconUtils.h> |
|
24 #include <AknsSrvClient.h> |
|
25 |
|
26 #include "AknsItemDataFactory.h" |
|
27 #include "AknsAlDataAccess.h" |
|
28 #include <AknsConstants.h> |
|
29 #include <AknsImageAttributeData.h> |
|
30 #include "AknsDebug.h" |
|
31 #include <AknsUtils.h> |
|
32 #include "AknsAppSkinInstance.h" |
|
33 #include "AknsFsHandleProvider.h" |
|
34 |
|
35 AKNS_UNDEFINED_METHOD(AknsItemDataFactory::AknsItemDataFactory) |
|
36 |
|
37 // Path to private directory. |
|
38 _LIT(KAknsSrvPrivateLocation, "private\\10207114\\"); |
|
39 |
|
40 // ============================ MEMBER FUNCTIONS =============================== |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // AknsItemDataFactory::CreateL |
|
44 // (documented in the header). |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 CAknsItemData* AknsItemDataFactory::CreateL( const CAknsItemDef* aDef ) |
|
48 { |
|
49 AKNS_TRACE_INFO2("AknsItemDataFactory::CreateL (%i,%i)", |
|
50 aDef->ID().iMajor, aDef->ID().iMinor ); |
|
51 CAknsItemData *resData = NULL; |
|
52 |
|
53 switch( aDef->Type() ) |
|
54 { |
|
55 case EAknsITBitmap: |
|
56 { |
|
57 AKNS_TRACE_INFO("AknsItemDataFactory::CreateL BITMAP"); |
|
58 const CAknsBitmapItemDef* bmpDef = |
|
59 static_cast<const CAknsBitmapItemDef*>(aDef); |
|
60 resData = CreateBitmapL( bmpDef->Filename(), bmpDef->Index(), |
|
61 bmpDef->Attributes() ); |
|
62 break; |
|
63 } |
|
64 case EAknsITMaskedBitmap: |
|
65 { |
|
66 AKNS_TRACE_INFO("AknsItemDataFactory::CreateL MASKEDBITMAP"); |
|
67 const CAknsMaskedBitmapItemDef* bmpDef = |
|
68 static_cast<const CAknsMaskedBitmapItemDef*>(aDef); |
|
69 resData = CreateMaskedBitmapL( bmpDef->Filename(), bmpDef->Index(), |
|
70 bmpDef->MaskIndex(), bmpDef->Attributes() ); |
|
71 break; |
|
72 } |
|
73 case EAknsITColorTable: |
|
74 { |
|
75 AKNS_TRACE_INFO("AknsItemDataFactory::CreateL COLORTABLE"); |
|
76 const CAknsColorTableItemDef* colorDef = |
|
77 static_cast<const CAknsColorTableItemDef*>(aDef); |
|
78 resData = CreateColorTableL( colorDef->NumberOfColors(), |
|
79 colorDef->Colors(), colorDef->Attributes() ); |
|
80 break; |
|
81 } |
|
82 case EAknsITImageTable: |
|
83 { |
|
84 AKNS_TRACE_INFO("AknsItemDataFactory::CreateL IMAGETABLE"); |
|
85 const CAknsImageTableItemDef* imageDef = |
|
86 static_cast<const CAknsImageTableItemDef*>(aDef); |
|
87 resData = CreateImageTableL( imageDef->NumberOfImages(), |
|
88 imageDef->Images(), imageDef->Attributes() ); |
|
89 break; |
|
90 } |
|
91 case EAknsITBmpAnim: |
|
92 { |
|
93 AKNS_TRACE_INFO("AknsItemDataFactory::CreateL BMPANIM"); |
|
94 const CAknsBmpAnimItemDef* animDef = |
|
95 static_cast<const CAknsBmpAnimItemDef*>(aDef); |
|
96 resData = CreateBmpAnimL( animDef->NumberOfImages(), |
|
97 animDef->Images(), animDef->FrameInfos(), |
|
98 animDef->LastFrameBackground(), animDef->FrameInterval(), |
|
99 animDef->PlayMode(), animDef->Flash(), |
|
100 animDef->Attributes() ); |
|
101 break; |
|
102 } |
|
103 case EAknsITString: |
|
104 { |
|
105 AKNS_TRACE_INFO("AknsItemDataFactory::CreateL STRING"); |
|
106 const CAknsStringItemDef* stringDef = |
|
107 static_cast<const CAknsStringItemDef*>(aDef); |
|
108 resData = CreateStringL( stringDef->String() ); |
|
109 break; |
|
110 } |
|
111 case EAknsITEffectQueue: |
|
112 { |
|
113 AKNS_TRACE_INFO("AknsItemDataFactory::CreateL EFFECT QUEUE"); |
|
114 const CAknsEffectQueueItemDef* eqDef = |
|
115 static_cast<const CAknsEffectQueueItemDef*>(aDef); |
|
116 resData = CreateEffectQueueL( eqDef ); |
|
117 break; |
|
118 } |
|
119 case EAknsITAnimation: |
|
120 { |
|
121 AKNS_TRACE_INFO("AknsItemDataFactory::CreateL AL ANIMATION"); |
|
122 const CAknsAnimationItemDef* animDef = |
|
123 static_cast<const CAknsAnimationItemDef*>(aDef); |
|
124 resData = CreateAnimationL( animDef ); |
|
125 break; |
|
126 } |
|
127 case EAknsITUnknown: |
|
128 case EAknsITImage: |
|
129 default: |
|
130 AKNS_TRACE_ERROR("AknsItemDataFactory::CreateL UNSUPPORTED TYPE"); |
|
131 User::Leave( KErrNotSupported ); |
|
132 } |
|
133 |
|
134 if( !resData ) |
|
135 { |
|
136 AKNS_TRACE_ERROR("AknsItemDataFactory::CreateL NOT FOUND"); |
|
137 User::Leave( KErrNotFound ); |
|
138 } |
|
139 |
|
140 return resData; |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // AknsItemDataFactory::CreateBitmapL |
|
145 // (documented in the header). |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 CAknsBitmapItemData* AknsItemDataFactory::CreateBitmapL( |
|
149 const TDesC& aFilename, const TInt aIndex, |
|
150 const TAknsImageAttributeData* aAttributes ) |
|
151 { |
|
152 AKNS_TRACE_INFO("AknsItemDataFactory::CreateBitmapL Started"); |
|
153 |
|
154 CFbsBitmap* bitmap = NULL; |
|
155 |
|
156 if( aFilename.Compare(KAknsSrvRAMBitmapName) == 0 ) |
|
157 { |
|
158 AKNS_TRACE_INFO("AknsItemDataFactory::CreateBitmapL RAMBitmap/Duplicate"); |
|
159 bitmap = new (ELeave) CFbsBitmap; |
|
160 CleanupStack::PushL( bitmap ); |
|
161 User::LeaveIfError( bitmap->Duplicate(aIndex) ); |
|
162 } |
|
163 else |
|
164 { |
|
165 AKNS_TRACE_INFO("AknsItemDataFactory::CreateBitmapL CreateIcon"); |
|
166 AKNS_TRACE_INFO2("AknsItemDataFactory::CreateBitmapL Calling icon utils %S %i", &aFilename, aIndex ); |
|
167 |
|
168 CAknsAppSkinInstance* skininstance = (CAknsAppSkinInstance*)(AknsUtils::SkinInstance()); |
|
169 |
|
170 TInt res = aFilename.FindF(KAknsSrvPrivateLocation); |
|
171 #if defined(_DEBUG) |
|
172 TInt createErr(KErrNone); |
|
173 if (res >= 0) |
|
174 { |
|
175 CAknsFsHandleProvider* provider = CAknsFsHandleProvider::NewL(&(skininstance->iSession), aFilename); |
|
176 // AknIconUtils will call CAknsFsHandleProvider::Finished when it is ready => deletes the object. |
|
177 TRAP( createErr, (bitmap = AknIconUtils::CreateIconL( |
|
178 *provider, aIndex)) ); |
|
179 } |
|
180 else |
|
181 { |
|
182 TRAP( createErr, (bitmap = AknIconUtils::CreateIconL( |
|
183 aFilename, aIndex)) ); |
|
184 } |
|
185 |
|
186 if( createErr != KErrNone ) |
|
187 { |
|
188 AKNS_TRACE_ERROR1("AknsItemDataFactory::CreateBitmapL AknIconUtils failed %i", createErr ); |
|
189 User::Leave( createErr ); |
|
190 } |
|
191 #else |
|
192 if (res >= 0) |
|
193 { |
|
194 CAknsFsHandleProvider* provider = CAknsFsHandleProvider::NewL(&(skininstance->iSession), aFilename); |
|
195 // AknIconUtils will call CAknsFsHandleProvider::Finished when it is ready => deletes the object |
|
196 bitmap = AknIconUtils::CreateIconL( *provider, aIndex ); |
|
197 } |
|
198 else |
|
199 { |
|
200 bitmap = AknIconUtils::CreateIconL( aFilename, aIndex ); |
|
201 } |
|
202 #endif // _DEBUG |
|
203 CleanupStack::PushL( bitmap ); |
|
204 } |
|
205 |
|
206 CAknsBitmapItemData* resData = CAknsBitmapItemData::NewL(); |
|
207 resData->SetBitmap( bitmap ); |
|
208 CleanupStack::Pop( bitmap ); // bitmap (now owned by resData) |
|
209 |
|
210 CleanupStack::PushL( resData ); |
|
211 SetAttributesL( resData, aAttributes ); |
|
212 CleanupStack::Pop( resData ); |
|
213 |
|
214 AKNS_TRACE_INFO("AknsItemDataFactory::CreateBitmapL Success"); |
|
215 |
|
216 return resData; |
|
217 } |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // AknsItemDataFactory::CreateMaskedBitmapL |
|
221 // (documented in the header). |
|
222 // ----------------------------------------------------------------------------- |
|
223 // |
|
224 CAknsMaskedBitmapItemData* AknsItemDataFactory::CreateMaskedBitmapL( |
|
225 const TDesC& aFilename, const TInt aIndex, const TInt aMaskIndex, |
|
226 const TAknsImageAttributeData* aAttributes ) |
|
227 { |
|
228 AKNS_TRACE_INFO("AknsItemDataFactory::CreateMaskedBitmapL Started"); |
|
229 |
|
230 CFbsBitmap* bitmap = NULL; |
|
231 CFbsBitmap* mask = NULL; |
|
232 |
|
233 if( aFilename.Compare(KAknsSrvRAMBitmapName) == 0 ) |
|
234 { |
|
235 AKNS_TRACE_INFO("AknsItemDataFactory::CreateMaskedBitmapL RAMBitmap/Duplicate"); |
|
236 bitmap = new (ELeave) CFbsBitmap; |
|
237 CleanupStack::PushL( bitmap ); |
|
238 mask = new (ELeave) CFbsBitmap; |
|
239 CleanupStack::PushL( mask ); |
|
240 User::LeaveIfError( bitmap->Duplicate(aIndex) ); |
|
241 User::LeaveIfError( mask->Duplicate(aMaskIndex) ); |
|
242 } |
|
243 else |
|
244 { |
|
245 // Make the forthcoming pushes safe (up to level 2) |
|
246 CleanupStack::PushL( static_cast<TAny*>(NULL) ); |
|
247 CleanupStack::PushL( static_cast<TAny*>(NULL) ); |
|
248 CleanupStack::Pop( 2 ); |
|
249 |
|
250 AKNS_TRACE_INFO("AknsItemDataFactory::CreateMaskedBitmapL CreateIcon"); |
|
251 AKNS_TRACE_INFO3("AknsItemDataFactory::CreateMaskedBitmapBitmapL Calling icon utils %S %i %i", &aFilename, aIndex, aMaskIndex ); |
|
252 |
|
253 CAknsAppSkinInstance* skininstance = (CAknsAppSkinInstance*)(AknsUtils::SkinInstance()); |
|
254 |
|
255 TInt res = aFilename.FindF(KAknsSrvPrivateLocation); |
|
256 CAknsFsHandleProvider* provider = NULL; |
|
257 |
|
258 #if defined(_DEBUG) |
|
259 TInt createErr(KErrNone); |
|
260 if (res >= 0) |
|
261 { |
|
262 // AknIconUtils will call CAknsFsHandleProvider::Finished when it is ready => deletes the object |
|
263 provider = CAknsFsHandleProvider::NewL(&(skininstance->iSession), aFilename); |
|
264 TRAP( createErr, (AknIconUtils::CreateIconL( bitmap, mask, |
|
265 *provider, aIndex, aMaskIndex)) ); |
|
266 } |
|
267 else |
|
268 { |
|
269 TRAP( createErr, (AknIconUtils::CreateIconL( bitmap, mask, |
|
270 aFilename, aIndex, aMaskIndex)) ); |
|
271 } |
|
272 |
|
273 if( createErr != KErrNone ) |
|
274 { |
|
275 AKNS_TRACE_ERROR1("AknsItemDataFactory::CreateMaskedBitmapL AknIconUtils failed %i", createErr ); |
|
276 User::Leave( createErr ); |
|
277 } |
|
278 #else |
|
279 if (res >= 0) |
|
280 { |
|
281 provider = CAknsFsHandleProvider::NewL(&(skininstance->iSession), aFilename); |
|
282 // AknIconUtils will call CAknsFsHandleProvider::Finished when it is ready => deletes the object |
|
283 AknIconUtils::CreateIconL( bitmap, mask, *provider, aIndex, aMaskIndex ); |
|
284 } |
|
285 else |
|
286 { |
|
287 AknIconUtils::CreateIconL( bitmap, mask, aFilename, aIndex, aMaskIndex ); |
|
288 } |
|
289 #endif // _DEBUG |
|
290 |
|
291 // These pushes are safe |
|
292 CleanupStack::PushL( bitmap ); |
|
293 CleanupStack::PushL( mask ); |
|
294 } |
|
295 |
|
296 CAknsMaskedBitmapItemData* resData = CAknsMaskedBitmapItemData::NewL(); |
|
297 resData->SetBitmap( bitmap ); |
|
298 resData->SetMask( mask ); |
|
299 CleanupStack::Pop(2); // bitmap, mask (now owned by resData) |
|
300 |
|
301 CleanupStack::PushL( resData ); |
|
302 SetAttributesL( resData, aAttributes ); |
|
303 CleanupStack::Pop( resData ); |
|
304 |
|
305 AKNS_TRACE_INFO("AknsItemDataFactory::CreateMaskedBitmapL Success"); |
|
306 |
|
307 return resData; |
|
308 } |
|
309 |
|
310 // ----------------------------------------------------------------------------- |
|
311 // AknsItemDataFactory::CreateColorTableL |
|
312 // (documented in the header). |
|
313 // ----------------------------------------------------------------------------- |
|
314 // |
|
315 CAknsColorTableItemData* AknsItemDataFactory::CreateColorTableL( |
|
316 const TInt aNumberOfColors, const TAknsColorTableEntry* aColors, |
|
317 const TAknsImageAttributeData* aAttributes ) |
|
318 { |
|
319 CAknsColorTableItemData* resData = CAknsColorTableItemData::NewL(); |
|
320 CleanupStack::PushL( resData ); |
|
321 resData->SetColorsL( aNumberOfColors, aColors ); |
|
322 SetAttributesL( resData, aAttributes ); |
|
323 CleanupStack::Pop( resData ); |
|
324 return resData; |
|
325 } |
|
326 |
|
327 // ----------------------------------------------------------------------------- |
|
328 // AknsItemDataFactory::CreateImageTableL |
|
329 // (documented in the header). |
|
330 // ----------------------------------------------------------------------------- |
|
331 // |
|
332 CAknsImageTableItemData* AknsItemDataFactory::CreateImageTableL( |
|
333 const TInt aNumberOfImages, const TAknsItemID* aImages, |
|
334 const TAknsImageAttributeData* aAttributes ) |
|
335 { |
|
336 CAknsImageTableItemData* resData = CAknsImageTableItemData::NewL(); |
|
337 CleanupStack::PushL( resData ); |
|
338 resData->SetImagesL( aNumberOfImages, aImages ); |
|
339 SetAttributesL( resData, aAttributes ); |
|
340 CleanupStack::Pop( resData ); |
|
341 return resData; |
|
342 } |
|
343 |
|
344 // ----------------------------------------------------------------------------- |
|
345 // AknsItemDataFactory::CreateBmpAnimL |
|
346 // (documented in the header). |
|
347 // ----------------------------------------------------------------------------- |
|
348 // |
|
349 CAknsBmpAnimItemData* AknsItemDataFactory::CreateBmpAnimL( |
|
350 const TInt aNumberOfImages, const TAknsItemID* aImages, |
|
351 const TAknsBmpAnimFrameInfo* aFrameInfos, |
|
352 const TBool aLastFrameBg, const TInt16 aFrameInterval, |
|
353 const TInt16 aPlayMode, const TBool aFlash, |
|
354 const TAknsImageAttributeData* aAttributes ) |
|
355 { |
|
356 CAknsBmpAnimItemData* resData = CAknsBmpAnimItemData::NewL(); |
|
357 CleanupStack::PushL( resData ); |
|
358 resData->SetImagesL( aNumberOfImages, aImages ); |
|
359 resData->SetFrameInfosL( aFrameInfos ); |
|
360 resData->SetLastFrameBackground( aLastFrameBg ); |
|
361 resData->SetFrameInterval( aFrameInterval ); |
|
362 resData->SetPlayMode( aPlayMode ); |
|
363 resData->SetFlash( aFlash ); |
|
364 SetAttributesL( resData, aAttributes ); |
|
365 CleanupStack::Pop( resData ); |
|
366 return resData; |
|
367 } |
|
368 |
|
369 // ----------------------------------------------------------------------------- |
|
370 // AknsItemDataFactory::CreateStringL |
|
371 // (documented in the header). |
|
372 // ----------------------------------------------------------------------------- |
|
373 // |
|
374 CAknsStringItemData* AknsItemDataFactory::CreateStringL( const TDesC& aString ) |
|
375 { |
|
376 CAknsStringItemData* resData = CAknsStringItemData::NewL(); |
|
377 CleanupStack::PushL( resData ); |
|
378 resData->SetStringL( aString ); |
|
379 CleanupStack::Pop( resData ); |
|
380 return resData; |
|
381 } |
|
382 |
|
383 // ----------------------------------------------------------------------------- |
|
384 // AknsItemDataFactory::CreateEffectQueueL |
|
385 // (documented in the header). |
|
386 // ----------------------------------------------------------------------------- |
|
387 // |
|
388 CAknsEffectQueueItemData* AknsItemDataFactory::CreateEffectQueueL( |
|
389 const CAknsEffectQueueItemDef* aDef ) |
|
390 { |
|
391 CAknsEffectQueueItemData* resData = CAknsEffectQueueItemData::NewL(); |
|
392 CleanupStack::PushL( resData ); |
|
393 |
|
394 if( aDef->iInputLayerMode == static_cast<TUint32>( KAknsRlLayerNone ) ) |
|
395 { |
|
396 resData->SetInputLayer( -1 ); |
|
397 } |
|
398 else |
|
399 { |
|
400 resData->SetInputLayer( aDef->iInputLayerIndex ); |
|
401 } |
|
402 resData->SetInputLayerMode( aDef->iInputLayerMode ); |
|
403 |
|
404 if( aDef->iOutputLayerMode == static_cast<TUint32>( KAknsRlLayerNone ) ) |
|
405 { |
|
406 resData->SetOutputLayer( -1 ); |
|
407 } |
|
408 else |
|
409 { |
|
410 resData->SetOutputLayer( aDef->iOutputLayerIndex ); |
|
411 } |
|
412 resData->SetOutputLayerMode( aDef->iOutputLayerMode ); |
|
413 |
|
414 resData->SetRefItem( aDef->iReference ); |
|
415 |
|
416 for( TUint32 i=0; i<aDef->EffectCount(); i++ ) |
|
417 { |
|
418 CAknsEffectCommand* command = CAknsEffectCommand::NewL(); |
|
419 CleanupStack::PushL( command ); |
|
420 CAknsEffectItemDef* cmdDef = aDef->GetEffect( i ); // Not owned |
|
421 |
|
422 command->SetEffectUid( cmdDef->EffectUid() ); |
|
423 |
|
424 TAknsRlRenderOpParam layerConf; |
|
425 layerConf.iInputLayerAStatus = cmdDef->iInputLayerAMode; |
|
426 layerConf.iInputLayerAIndex = cmdDef->iInputLayerAIndex; |
|
427 layerConf.iInputLayerBStatus = cmdDef->iInputLayerBMode; |
|
428 layerConf.iInputLayerBIndex = cmdDef->iInputLayerBIndex; |
|
429 layerConf.iOutputLayerStatus = cmdDef->iOutputLayerMode; |
|
430 layerConf.iOutputLayerIndex = cmdDef->iOutputLayerIndex; |
|
431 command->SetLayerConf( layerConf ); |
|
432 |
|
433 for( TInt a=0; a<cmdDef->ParameterCount(); a++ ) |
|
434 { |
|
435 TAknsRlParameterData prm; |
|
436 TAknsRlGraphicsParam gfxPrm; |
|
437 |
|
438 CAknsEffectParamDef* prmDef = cmdDef->GetParameter( a ); |
|
439 |
|
440 prm.iName = prmDef->GetName(); |
|
441 prm.iType = static_cast<TAknsRlParameterType>( |
|
442 prmDef->GetType() ); |
|
443 |
|
444 switch( prm.iType ) |
|
445 { |
|
446 case EAknsRlParameterTypeNumber: |
|
447 prm.iNumber = prmDef->GetNumber(); |
|
448 break; |
|
449 case EAknsRlParameterTypeString: |
|
450 prm.iString = prmDef->GetString(); |
|
451 break; |
|
452 case EAknsRlParameterTypeGraphics: |
|
453 gfxPrm.iFilename = prmDef->GetFilename(); |
|
454 gfxPrm.iIndex = prmDef->GetBitmapIndex(); |
|
455 gfxPrm.iMaskIndex = prmDef->GetMaskIndex(); |
|
456 prm.iGfx = &gfxPrm; |
|
457 break; |
|
458 } |
|
459 |
|
460 command->AppendParameterL( prm ); |
|
461 } |
|
462 |
|
463 resData->AppendCommandL( command ); |
|
464 CleanupStack::Pop( command ); |
|
465 } |
|
466 |
|
467 CleanupStack::Pop( resData ); |
|
468 return resData; |
|
469 } |
|
470 |
|
471 // ----------------------------------------------------------------------------- |
|
472 // AknsItemDataFactory::CreateAnimationL |
|
473 // (documented in the header). |
|
474 // ----------------------------------------------------------------------------- |
|
475 // |
|
476 CAknsAnimationItemData* AknsItemDataFactory::CreateAnimationL( |
|
477 const CAknsAnimationItemDef* aDef ) |
|
478 { |
|
479 CAknsAnimationItemData* item = CAknsAnimationItemData::NewL(); |
|
480 CleanupStack::PushL( item ); |
|
481 |
|
482 item->SetMinInterval( aDef->MinInterval() ); |
|
483 item->SetMorphing( aDef->Morphing() ); |
|
484 |
|
485 // Determine animation layer configuration |
|
486 if( aDef->iInputLayerMode == TUint32( KAknsRlLayerNone ) ) |
|
487 { |
|
488 item->SetInputLayer( -1 ); |
|
489 } |
|
490 else |
|
491 { |
|
492 item->SetInputLayer( aDef->iInputLayerIndex ); |
|
493 } |
|
494 item->SetInputLayerMode( aDef->iInputLayerMode ); |
|
495 |
|
496 if( aDef->iOutputLayerMode == TUint32( KAknsRlLayerNone ) ) |
|
497 { |
|
498 item->SetOutputLayer( -1 ); |
|
499 } |
|
500 else |
|
501 { |
|
502 item->SetOutputLayer( aDef->iOutputLayerIndex ); |
|
503 } |
|
504 item->SetOutputLayerMode( aDef->iOutputLayerMode ); |
|
505 |
|
506 TInt i, j, count; |
|
507 TAknsRlParameterData paramData; |
|
508 TAknsRlGraphicsParam gfx; |
|
509 |
|
510 struct Local |
|
511 { |
|
512 static void Fill( TAknsRlParameterData& aData, |
|
513 CAknsEffectParamDef& aEffectDef, |
|
514 TAknsRlGraphicsParam* aGfx ) |
|
515 { |
|
516 aData.iName = aEffectDef.GetName(); |
|
517 aData.iType = |
|
518 static_cast<TAknsRlParameterType>( aEffectDef.GetType() ); |
|
519 |
|
520 switch( aData.iType ) |
|
521 { |
|
522 case EAknsRlParameterTypeNumber: |
|
523 aData.iNumber = aEffectDef.GetNumber(); |
|
524 break; |
|
525 case EAknsRlParameterTypeString: |
|
526 aData.iString = aEffectDef.GetString(); |
|
527 break; |
|
528 case EAknsRlParameterTypeGraphics: |
|
529 if( aGfx ) |
|
530 { |
|
531 aGfx->iFilename = aEffectDef.GetFilename(); |
|
532 aGfx->iIndex = aEffectDef.GetBitmapIndex(); |
|
533 aGfx->iMaskIndex = aEffectDef.GetMaskIndex(); |
|
534 aData.iGfx = aGfx; |
|
535 } |
|
536 break; |
|
537 } |
|
538 } |
|
539 }; |
|
540 |
|
541 // Create timing models |
|
542 count = aDef->TimingModelCount(); |
|
543 for( i=0; i < count; i++ ) |
|
544 { |
|
545 CAknsTimingModelDef* timingDef = aDef->TimingModel( i ); |
|
546 CAknsTimingModel* model = CAknsTimingModel::NewL(); |
|
547 CleanupStack::PushL( model ); |
|
548 |
|
549 model->SetTimingModelUid( timingDef->TimingModelUid() ); |
|
550 |
|
551 for( j=0; j < timingDef->ParameterCount(); j++ ) |
|
552 { |
|
553 CAknsEffectParamDef* paramDef = timingDef->Parameter( j ); |
|
554 Local::Fill( paramData, *paramDef, &gfx ); |
|
555 model->AppendParameterL( paramData ); |
|
556 } |
|
557 |
|
558 item->AppendTimingModelL( model ); // Ownership transferred |
|
559 CleanupStack::Pop( model ); |
|
560 } |
|
561 |
|
562 // Create animation values |
|
563 count = aDef->AnimationValueCount(); |
|
564 for( i=0; i < count; i++ ) |
|
565 { |
|
566 CAknsAnimationValueDef* valueDef = aDef->AnimationValue( i ); |
|
567 CAknsAnimationValue* value = CAknsAnimationValue::NewL(); |
|
568 CleanupStack::PushL( value ); |
|
569 |
|
570 value->SetAnimationValueUid( valueDef->AnimationValueUid() ); |
|
571 value->SetTimingModelId( valueDef->TimingModelId() ); |
|
572 |
|
573 for( j=0; j < valueDef->ParameterCount(); j++ ) |
|
574 { |
|
575 CAknsEffectParamDef* paramDef = valueDef->Parameter( j ); |
|
576 Local::Fill( paramData, *paramDef, &gfx ); |
|
577 value->AppendParameterL( paramData ); |
|
578 } |
|
579 |
|
580 item->AppendAnimationValueL( value ); // Ownership transferred |
|
581 CleanupStack::Pop( value ); |
|
582 } |
|
583 |
|
584 // Create animation commands |
|
585 TAknsRlRenderOpParam layerConf; |
|
586 TAknsAlNamedReferenceData refData; |
|
587 count = aDef->AnimationCommandItemCount(); |
|
588 for( i=0; i < count; i++ ) |
|
589 { |
|
590 CAknsAnimationCommandItemDef* cmdDef = aDef->AnimationCommandItem( i ); |
|
591 CAknsAnimationCommand* cmd = CAknsAnimationCommand::NewL(); |
|
592 CleanupStack::PushL( cmd ); |
|
593 |
|
594 cmd->SetEffectUid( cmdDef->EffectUid() ); |
|
595 |
|
596 if( cmdDef->iInputLayerAMode == TUint32( KAknsRlLayerNone ) ) |
|
597 { |
|
598 layerConf.iInputLayerAIndex = -1; |
|
599 } |
|
600 else |
|
601 { |
|
602 layerConf.iInputLayerAIndex = cmdDef->iInputLayerAIndex; |
|
603 } |
|
604 layerConf.iInputLayerAStatus = cmdDef->iInputLayerAMode; |
|
605 |
|
606 if( cmdDef->iInputLayerBMode == TUint32( KAknsRlLayerNone ) ) |
|
607 { |
|
608 layerConf.iInputLayerBIndex = -1; |
|
609 } |
|
610 else |
|
611 { |
|
612 layerConf.iInputLayerBIndex = cmdDef->iInputLayerBIndex; |
|
613 } |
|
614 layerConf.iInputLayerBStatus = cmdDef->iInputLayerBMode; |
|
615 |
|
616 if( cmdDef->iOutputLayerMode == TUint32( KAknsRlLayerNone ) ) |
|
617 { |
|
618 layerConf.iOutputLayerIndex = -1; |
|
619 } |
|
620 else |
|
621 { |
|
622 layerConf.iOutputLayerIndex = cmdDef->iOutputLayerIndex; |
|
623 } |
|
624 layerConf.iOutputLayerStatus = cmdDef->iOutputLayerMode; |
|
625 |
|
626 cmd->SetLayerConf( layerConf ); |
|
627 |
|
628 for( j=0; j < cmdDef->ParameterCount(); j++ ) |
|
629 { |
|
630 CAknsEffectParamDef* paramDef = cmdDef->GetParameter( j ); |
|
631 Local::Fill( paramData, *paramDef, &gfx ); |
|
632 cmd->AppendParameterL( paramData ); |
|
633 } |
|
634 |
|
635 for( j=0; j < cmdDef->NamedReferenceCount(); j++ ) |
|
636 { |
|
637 CAknsNamedReferenceDef* refDef = cmdDef->NamedReference( j ); |
|
638 |
|
639 refData.iName = refDef->Name(); |
|
640 refData.iAnimationValueId = refDef->AnimationValueId(); |
|
641 |
|
642 cmd->AppendNamedReferenceL( refData ); |
|
643 } |
|
644 |
|
645 item->AppendCommandL( cmd ); // Ownership transferred |
|
646 CleanupStack::Pop( cmd ); |
|
647 } |
|
648 |
|
649 // Create size bound parameters |
|
650 TAknsAlSizeBoundParameterData sizeBoundData; |
|
651 count = aDef->SizeBoundParamCount(); |
|
652 for( i=0; i < count; i++ ) |
|
653 { |
|
654 CAknsSizeBoundParamDef* sizeBoundDef = aDef->SizeBoundParam( i ); |
|
655 |
|
656 sizeBoundData.iName = sizeBoundDef->Name(); |
|
657 sizeBoundData.iAnimationValueId = sizeBoundDef->AnimationValueId(); |
|
658 sizeBoundData.iParamFlags = sizeBoundDef->ParamFlags(); |
|
659 |
|
660 item->AppendSizeBoundParamL( sizeBoundData ); |
|
661 } |
|
662 |
|
663 // Create preprocess commands |
|
664 count = aDef->PreprocessCommandCount(); |
|
665 for( i=0; i < count; i++ ) |
|
666 { |
|
667 CAknsEffectCommand* command = CAknsEffectCommand::NewL(); |
|
668 CleanupStack::PushL( command ); |
|
669 CAknsEffectItemDef* cmdDef = aDef->PreprocessCommand( i ); // Not owned |
|
670 |
|
671 command->SetEffectUid( cmdDef->EffectUid() ); |
|
672 |
|
673 if( cmdDef->iInputLayerAMode == TUint32( KAknsRlLayerNone ) ) |
|
674 { |
|
675 layerConf.iInputLayerAIndex = -1; |
|
676 } |
|
677 else |
|
678 { |
|
679 layerConf.iInputLayerAIndex = cmdDef->iInputLayerAIndex; |
|
680 } |
|
681 layerConf.iInputLayerAStatus = cmdDef->iInputLayerAMode; |
|
682 |
|
683 if( cmdDef->iInputLayerBMode == TUint32( KAknsRlLayerNone ) ) |
|
684 { |
|
685 layerConf.iInputLayerBIndex = -1; |
|
686 } |
|
687 else |
|
688 { |
|
689 layerConf.iInputLayerBIndex = cmdDef->iInputLayerBIndex; |
|
690 } |
|
691 layerConf.iInputLayerBStatus = cmdDef->iInputLayerBMode; |
|
692 |
|
693 if( cmdDef->iOutputLayerMode == TUint32( KAknsRlLayerNone ) ) |
|
694 { |
|
695 layerConf.iOutputLayerIndex = -1; |
|
696 } |
|
697 else |
|
698 { |
|
699 layerConf.iOutputLayerIndex = cmdDef->iOutputLayerIndex; |
|
700 } |
|
701 layerConf.iOutputLayerStatus = cmdDef->iOutputLayerMode; |
|
702 |
|
703 command->SetLayerConf( layerConf ); |
|
704 |
|
705 for( TInt a=0; a<cmdDef->ParameterCount(); a++ ) |
|
706 { |
|
707 TAknsRlParameterData prm; |
|
708 TAknsRlGraphicsParam gfxPrm; |
|
709 |
|
710 CAknsEffectParamDef* prmDef = cmdDef->GetParameter( a ); |
|
711 |
|
712 prm.iName = prmDef->GetName(); |
|
713 prm.iType = static_cast<TAknsRlParameterType>( |
|
714 prmDef->GetType() ); |
|
715 |
|
716 switch( prm.iType ) |
|
717 { |
|
718 case EAknsRlParameterTypeNumber: |
|
719 prm.iNumber = prmDef->GetNumber(); |
|
720 break; |
|
721 case EAknsRlParameterTypeString: |
|
722 prm.iString = prmDef->GetString(); |
|
723 break; |
|
724 case EAknsRlParameterTypeGraphics: |
|
725 gfxPrm.iFilename = prmDef->GetFilename(); |
|
726 gfxPrm.iIndex = prmDef->GetBitmapIndex(); |
|
727 gfxPrm.iMaskIndex = prmDef->GetMaskIndex(); |
|
728 prm.iGfx = &gfxPrm; |
|
729 break; |
|
730 } |
|
731 |
|
732 command->AppendParameterL( prm ); |
|
733 } |
|
734 |
|
735 item->AppendPreprocessCommandL( command ); |
|
736 CleanupStack::Pop( command ); |
|
737 } |
|
738 |
|
739 CleanupStack::Pop( item ); |
|
740 return item; |
|
741 } |
|
742 |
|
743 // ----------------------------------------------------------------------------- |
|
744 // AknsItemDataFactory::SetAttributesL |
|
745 // (documented in the header). |
|
746 // ----------------------------------------------------------------------------- |
|
747 // |
|
748 void AknsItemDataFactory::SetAttributesL( CAknsImageItemData* aItemData, |
|
749 const TAknsImageAttributeData* aAttributes ) |
|
750 { |
|
751 if( aAttributes ) |
|
752 { |
|
753 aItemData->SetAttributesL( *aAttributes ); |
|
754 } |
|
755 else |
|
756 { |
|
757 TAknsImageAttributeData defAttr; |
|
758 aItemData->SetAttributesL( defAttr ); |
|
759 } |
|
760 } |
|
761 |
|
762 // End of File |