|
1 /* |
|
2 * Copyright (c) 2007 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "mmtemplatelibrary.h" |
|
21 #include "mmlctutils.h" |
|
22 #include "mmwidgetsconstants.h" |
|
23 #include <hnutils.h> |
|
24 #include <gdi.h> |
|
25 #include <hnconvutils.h> |
|
26 #include "menudebug.h" |
|
27 #include <hnglobals.h> |
|
28 #include <AknUtils.h> |
|
29 #include <AknDef.hrh> |
|
30 |
|
31 |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 TUint32 HBuf16Hash( HBufC8* const & aBuf ) |
|
38 { |
|
39 return DefaultHash::Des8(*aBuf); |
|
40 } |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 TBool HBuf16Ident( HBufC8* const & aL, HBufC8* const & aR ) |
|
46 { |
|
47 return DefaultIdentity::Des8(*aL, *aR); |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 // --------------------------------------------------------------------------- |
|
53 //: |
|
54 CMmTemplateLibrary::CMmTemplateLibrary() |
|
55 : iWidgetType(EWidgetTypeNone), |
|
56 iTemplateSizesMap( &HBuf16Hash, &HBuf16Ident ), |
|
57 iTemplateChildrenMap( &HBuf16Hash, &HBuf16Ident ), |
|
58 iMoveIndicatorRectsMap( &HBuf16Hash, &HBuf16Ident ) |
|
59 { |
|
60 // No implementation required |
|
61 } |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 CMmTemplateLibrary::~CMmTemplateLibrary() |
|
67 { |
|
68 CleanAndClearCache(); |
|
69 } |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 void CMmTemplateLibrary::CleanAndClearCache( ) |
|
75 { |
|
76 |
|
77 THashMapIter<HBufC8*, TSize> iter( iTemplateSizesMap ); |
|
78 while ( HBufC8* const * ptr = iter.NextKey() ) |
|
79 { |
|
80 delete *ptr; |
|
81 } |
|
82 iTemplateSizesMap.Close(); |
|
83 |
|
84 THashMapIter<HBufC8*, RArray<TTemplateChild> > iter2( iTemplateChildrenMap ); |
|
85 while ( HBufC8* const * ptr = iter2.NextKey() ) |
|
86 { |
|
87 iter2.CurrentValue()->Close(); |
|
88 delete *ptr; |
|
89 } |
|
90 iTemplateChildrenMap.Close(); |
|
91 |
|
92 THashMapIter<HBufC8*, TRect> iter4( iMoveIndicatorRectsMap ); |
|
93 while ( HBufC8* const * ptr = iter4.NextKey() ) |
|
94 { |
|
95 delete *ptr; |
|
96 } |
|
97 iMoveIndicatorRectsMap.Close(); |
|
98 |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 EXPORT_C CMmTemplateLibrary* CMmTemplateLibrary::NewL() |
|
106 { |
|
107 CMmTemplateLibrary* self = CMmTemplateLibrary::NewLC(); |
|
108 CleanupStack::Pop( self ); |
|
109 return self; |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 EXPORT_C CMmTemplateLibrary* CMmTemplateLibrary::NewLC() |
|
117 { |
|
118 CMmTemplateLibrary* self = new( ELeave ) CMmTemplateLibrary(); |
|
119 CleanupStack::PushL( self ); |
|
120 self->ConstructL(); |
|
121 return self; |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 void CMmTemplateLibrary::ConstructL() |
|
129 { |
|
130 //No implementation needed. |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 TSize CMmTemplateLibrary::GetSize( TMmWidgetType aWidgetType, const TDesC8& aTemplate, |
|
138 TBool aLandscapeOrientation, TBool aHighlighted, TRect aParentRect ) |
|
139 { |
|
140 TSize result; |
|
141 GetSize(result, aWidgetType, aTemplate, aLandscapeOrientation, |
|
142 aHighlighted, aParentRect ); |
|
143 return result; |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 // --------------------------------------------------------------------------- |
|
149 // |
|
150 TInt CMmTemplateLibrary::GetSize( TSize& aItemSize, |
|
151 TMmWidgetType aWidgetType, const TDesC8& aTemplate, |
|
152 TBool aLandscapeOrientation, TBool aHighlighted, TRect aParentRect ) |
|
153 { |
|
154 if ( KNullDesC8()== aTemplate || aParentRect == TRect(TPoint(0,0), TPoint(0,0)) |
|
155 || !aTemplate.Compare( KEmpty8 ) ) |
|
156 { |
|
157 return KErrNotFound; |
|
158 } |
|
159 UpdateParentRect( aParentRect, aLandscapeOrientation ); |
|
160 |
|
161 TInt err( KErrNone ); |
|
162 HBufC8* lookup_string = LookupText( aTemplate, aWidgetType, iZoom, |
|
163 aLandscapeOrientation, aHighlighted ); |
|
164 |
|
165 TSize* itemSize = iTemplateSizesMap.Find( lookup_string ); |
|
166 if ( !itemSize ) |
|
167 { |
|
168 TRAP( err, LoadTemplateL( aWidgetType, aTemplate, aLandscapeOrientation ) ); |
|
169 if ( err == KErrNone ) |
|
170 { |
|
171 itemSize = iTemplateSizesMap.Find( lookup_string ); |
|
172 if( !itemSize ) |
|
173 { |
|
174 User::Panic( KMtlPanic, KErrNotFound ); |
|
175 } |
|
176 aItemSize = *itemSize; |
|
177 } |
|
178 } |
|
179 else |
|
180 { |
|
181 iWidgetType = aWidgetType; |
|
182 TSize layoutSize; |
|
183 TInt err( KErrNone ); |
|
184 TRAP( err, layoutSize = GetLayoutSizeL( iWidgetType, aTemplate, |
|
185 aLandscapeOrientation ) ); |
|
186 if( err == KErrNone ) |
|
187 { |
|
188 AdjustItemSize( *itemSize, layoutSize, aLandscapeOrientation ); |
|
189 } |
|
190 aItemSize = *itemSize; |
|
191 } |
|
192 delete lookup_string; |
|
193 |
|
194 return err; |
|
195 } |
|
196 |
|
197 // --------------------------------------------------------------------------- |
|
198 // |
|
199 // --------------------------------------------------------------------------- |
|
200 // |
|
201 TSize CMmTemplateLibrary::GetLayoutSizeL( TMmWidgetType aWidgetType, const TDesC8& aTemplate, |
|
202 TBool aLandscapeOrientation ) |
|
203 { |
|
204 if ( KNullDesC8()== aTemplate ) |
|
205 { |
|
206 User::Leave( -1 ); |
|
207 } |
|
208 TSize* layoutSize = NULL; |
|
209 switch ( aWidgetType ) |
|
210 { |
|
211 case EGrid: |
|
212 { |
|
213 HBufC8* lookup_string = LookupLayoutText( aWidgetType, iZoom, |
|
214 aTemplate, aLandscapeOrientation ); |
|
215 CleanupStack::PushL( lookup_string ); |
|
216 layoutSize = iTemplateSizesMap.Find( lookup_string ); |
|
217 if (!layoutSize) |
|
218 { |
|
219 LoadTemplateL( aWidgetType, aTemplate, aLandscapeOrientation ); |
|
220 layoutSize = iTemplateSizesMap.Find( lookup_string ); |
|
221 if( !layoutSize ) |
|
222 User::Panic( KMtlPanic, -1); |
|
223 } |
|
224 CleanupStack::PopAndDestroy( lookup_string ); |
|
225 } |
|
226 |
|
227 break; |
|
228 case EListbox: |
|
229 return TSize( MmListBox::KCols,0 ); |
|
230 default: |
|
231 User::Panic( KMtlPanic, -1); |
|
232 } |
|
233 return *layoutSize; |
|
234 } |
|
235 |
|
236 // --------------------------------------------------------------------------- |
|
237 // |
|
238 // --------------------------------------------------------------------------- |
|
239 // |
|
240 TRect CMmTemplateLibrary::GetMoveIndicatorRect(TMmWidgetType aWidgetType, |
|
241 const TDesC8& aTemplate, TBool aLandscapeOrientation, |
|
242 TBool aHighlighted) |
|
243 { |
|
244 ASSERT( KNullDesC8() != aTemplate && aTemplate.Compare( KEmpty8 ) ); |
|
245 |
|
246 HBufC8* lookup_string = LookupText(aTemplate, aWidgetType, iZoom, |
|
247 aLandscapeOrientation, aHighlighted ); |
|
248 HBufC8* lookup_indicator_string = LookupIndicatorText( *lookup_string ); |
|
249 |
|
250 TRect* itemRect = iMoveIndicatorRectsMap.Find( lookup_indicator_string ); |
|
251 if (!itemRect) |
|
252 { |
|
253 TSize itemSize; |
|
254 GetSize( itemSize, aWidgetType, aTemplate, aLandscapeOrientation, EFalse, GetParentRect( aLandscapeOrientation ) ); |
|
255 TRAPD( err, SetupMoveIndicatorTemplateChildrenL( |
|
256 *lookup_indicator_string, itemSize ) ); |
|
257 if ( KErrNone == err ) |
|
258 { |
|
259 itemRect = iMoveIndicatorRectsMap.Find( lookup_indicator_string ); |
|
260 if (!itemRect) |
|
261 { |
|
262 User::Panic( KMtlPanic, -1); |
|
263 } |
|
264 } |
|
265 } |
|
266 |
|
267 delete lookup_indicator_string; |
|
268 delete lookup_string; |
|
269 return *itemRect; |
|
270 } |
|
271 |
|
272 // --------------------------------------------------------------------------- |
|
273 // |
|
274 // --------------------------------------------------------------------------- |
|
275 // |
|
276 void CMmTemplateLibrary::GetChildrenL(TMmWidgetType aWidgetType, RArray< |
|
277 TTemplateChild>& aArray, const TDesC8& aTemplate, |
|
278 TBool aLandscapeOrientation, TBool aHighlighted, TBool aIsEditMode) |
|
279 { |
|
280 ASSERT( KNullDesC8() != aTemplate && aTemplate.Compare( KEmpty8 ) ); |
|
281 |
|
282 HBufC8* lookup_string = LookupText( aTemplate, aWidgetType, iZoom, |
|
283 aLandscapeOrientation, aHighlighted ); |
|
284 CleanupStack::PushL( lookup_string ); |
|
285 RArray<TTemplateChild>* children = iTemplateChildrenMap.Find( lookup_string ); |
|
286 if ( !children ) |
|
287 { |
|
288 LoadTemplateL( aWidgetType, aTemplate, aLandscapeOrientation ); |
|
289 children = iTemplateChildrenMap.Find( lookup_string ); |
|
290 if (!children) |
|
291 { |
|
292 User::Panic( KMtlPanic, -1); |
|
293 } |
|
294 } |
|
295 CleanupStack::PopAndDestroy( lookup_string ); |
|
296 for (TInt i = 0; i < children->Count(); i++) |
|
297 aArray.AppendL((*children)[i]); |
|
298 if ( aIsEditMode ) |
|
299 { |
|
300 TSize size = GetSize( aWidgetType, aTemplate, aLandscapeOrientation, aHighlighted, GetParentRect(aLandscapeOrientation) ); |
|
301 AppendEditModeTemplateL( aArray, size ); |
|
302 } |
|
303 } |
|
304 |
|
305 // --------------------------------------------------------------------------- |
|
306 // |
|
307 // --------------------------------------------------------------------------- |
|
308 // |
|
309 void CMmTemplateLibrary::GetMoveIndicatorChildrenL(TMmWidgetType aWidgetType, |
|
310 RArray<TTemplateChild>& aArray, const TDesC8& aTemplate, |
|
311 TBool aLandscapeOrientation, TBool aHighlighted) |
|
312 { |
|
313 ASSERT( KNullDesC8() != aTemplate && aTemplate.Compare( KEmpty8 ) ); |
|
314 |
|
315 HBufC8* lookup_string = LookupText(aTemplate, aWidgetType, iZoom, |
|
316 aLandscapeOrientation, aHighlighted ); |
|
317 CleanupStack::PushL( lookup_string ); |
|
318 HBufC8* lookup_indicator_string = LookupIndicatorText( *lookup_string ); |
|
319 CleanupStack::PushL( lookup_indicator_string ); |
|
320 |
|
321 RArray<TTemplateChild>* children = iTemplateChildrenMap.Find( lookup_indicator_string ); |
|
322 if ( !children ) |
|
323 { |
|
324 TSize itemSize; |
|
325 GetSize( itemSize, aWidgetType, aTemplate, aLandscapeOrientation, EFalse, GetParentRect( aLandscapeOrientation ) ); |
|
326 SetupMoveIndicatorTemplateChildrenL( *lookup_indicator_string, itemSize ); |
|
327 children = iTemplateChildrenMap.Find( lookup_indicator_string ); |
|
328 if (!children) |
|
329 User::Panic( KMtlPanic, -1); |
|
330 } |
|
331 |
|
332 CleanupStack::PopAndDestroy( lookup_indicator_string ); |
|
333 CleanupStack::PopAndDestroy( lookup_string ); |
|
334 |
|
335 for (TInt i = 0; i < children->Count(); i++) |
|
336 { |
|
337 aArray.AppendL((*children)[i]); |
|
338 } |
|
339 } |
|
340 |
|
341 // --------------------------------------------------------------------------- |
|
342 // |
|
343 // --------------------------------------------------------------------------- |
|
344 // |
|
345 HBufC8* CMmTemplateLibrary::LookupText( const TDesC8& aTemplate, |
|
346 TMmWidgetType aWidgetType, TAknUiZoom aZoom, TBool aLandscapeOrientation, |
|
347 TBool aHighlighted ) |
|
348 { |
|
349 HBufC8* lookup_string = HBufC8::New( MmTemplateContants::KTemplateChildTextLength ); |
|
350 if (lookup_string) |
|
351 { |
|
352 TPtr8 lookup_string_ptr( lookup_string->Des() ); |
|
353 lookup_string_ptr.Append( aTemplate ); |
|
354 lookup_string_ptr.Append( KColon8 ); |
|
355 switch ( aWidgetType ) |
|
356 { |
|
357 case EListbox: |
|
358 lookup_string_ptr.Append( KListbox8 ); |
|
359 break; |
|
360 case EGrid: |
|
361 lookup_string_ptr.Append( KGrid8 ); |
|
362 break; |
|
363 } |
|
364 lookup_string_ptr.Append( KColon8 ); |
|
365 lookup_string_ptr.AppendNum( aLandscapeOrientation ); |
|
366 lookup_string_ptr.Append( KColon8 ); |
|
367 lookup_string_ptr.AppendNum( aHighlighted ); |
|
368 lookup_string_ptr.Append( KColon8 ); |
|
369 switch ( aZoom ) |
|
370 { |
|
371 case EAknUiZoomLarge : |
|
372 lookup_string_ptr.Append( KZoomLarge8 ); |
|
373 break; |
|
374 case EAknUiZoomSmall : |
|
375 lookup_string_ptr.Append( KZoomSmall8 ); |
|
376 break; |
|
377 default : |
|
378 lookup_string_ptr.Append( KZoomNormal8 ); |
|
379 break; |
|
380 } |
|
381 } |
|
382 return lookup_string; |
|
383 } |
|
384 |
|
385 // ----------------------------------------------------------------------------- |
|
386 // |
|
387 // ----------------------------------------------------------------------------- |
|
388 // |
|
389 HBufC8* CMmTemplateLibrary::LookupLayoutText( TMmWidgetType aWidgetType, |
|
390 TAknUiZoom aZoom, const TDesC8& aTemplate, TBool aLandscapeOrientation ) |
|
391 { |
|
392 HBufC8* lookup_string = HBufC8::New( MmTemplateContants::KTemplateChildTextLength ); |
|
393 if (lookup_string) |
|
394 { |
|
395 TPtr8 lookup_string_ptr( lookup_string->Des() ); |
|
396 switch ( aWidgetType ) |
|
397 { |
|
398 case EListbox: |
|
399 lookup_string_ptr.Append( KListbox8 ); |
|
400 break; |
|
401 case EGrid: |
|
402 lookup_string_ptr.Append( KGrid8 ); |
|
403 break; |
|
404 } |
|
405 lookup_string_ptr.Append( KColon8 ); |
|
406 switch ( aZoom ) |
|
407 { |
|
408 case EAknUiZoomLarge: |
|
409 lookup_string_ptr.Append( KZoomLarge8 ); |
|
410 break; |
|
411 case EAknUiZoomSmall : |
|
412 lookup_string_ptr.Append( KZoomSmall8 ); |
|
413 break; |
|
414 default: |
|
415 lookup_string_ptr.Append( KZoomNormal8 ); |
|
416 break; |
|
417 } |
|
418 lookup_string_ptr.Append( KColon8 ); |
|
419 lookup_string_ptr.Append( aTemplate ); |
|
420 lookup_string_ptr.Append( KColon8 ); |
|
421 lookup_string_ptr.AppendNum( aLandscapeOrientation ); |
|
422 } |
|
423 return lookup_string; |
|
424 } |
|
425 |
|
426 // ----------------------------------------------------------------------------- |
|
427 // |
|
428 // ----------------------------------------------------------------------------- |
|
429 // |
|
430 HBufC8* CMmTemplateLibrary::LookupIndicatorText( const TDesC8& aLookupText ) |
|
431 { |
|
432 HBufC8* lookup_string = HBufC8::New( MmTemplateContants::KTemplateChildTextLength ); |
|
433 if (lookup_string) |
|
434 { |
|
435 TPtr8 lookup_string_ptr( lookup_string->Des() ); |
|
436 lookup_string_ptr.Append( KMI8 ); |
|
437 lookup_string_ptr.Append( KColon8 ); |
|
438 lookup_string_ptr.Append( aLookupText ); |
|
439 } |
|
440 |
|
441 return lookup_string; |
|
442 } |
|
443 |
|
444 // ----------------------------------------------------------------------------- |
|
445 // |
|
446 // ----------------------------------------------------------------------------- |
|
447 // |
|
448 void CMmTemplateLibrary::LoadTemplateL( TMmWidgetType aWidgetType, |
|
449 const TDesC8& aTemplate, TBool aLandscapeOrientation ) |
|
450 { |
|
451 iWidgetType = aWidgetType; |
|
452 DEBUG(("_Mm_:CMmTemplateLibrary::LoadTemplateL IN")); |
|
453 TMmTemplateType mmTemplateType; |
|
454 HBufC8* content = GetTemplateContentL( aTemplate, aWidgetType, mmTemplateType ); |
|
455 CleanupStack::PushL( content ); |
|
456 RXmlEngDOMImplementation domImpl; |
|
457 CleanupClosePushL( domImpl ); |
|
458 RXmlEngDOMParser domParser; |
|
459 CleanupClosePushL( domParser ); |
|
460 DEBUG(("_Mm_:CMmTemplateLibrary::LoadTemplateL Opening domImpl")); |
|
461 domImpl.OpenL(); |
|
462 User::LeaveIfError( domParser.Open( domImpl ) ); |
|
463 DEBUG(("_Mm_:CMmTemplateLibrary::LoadTemplateL parsing content...")); |
|
464 RXmlEngDocument xmlDoc = domParser.ParseL( *content ); |
|
465 CleanupClosePushL( xmlDoc ); |
|
466 |
|
467 // first orientation |
|
468 RXmlEngNodeList<TXmlEngElement> orientElements; |
|
469 CleanupClosePushL( orientElements ); |
|
470 xmlDoc.DocumentElement().GetChildElements( orientElements ); |
|
471 TXmlEngElement orientationElement; |
|
472 while ( orientElements.HasNext() ) |
|
473 { |
|
474 orientationElement = orientElements.Next(); |
|
475 DEBUG(("_Mm_:CMmTemplateLibrary::LoadTemplateL Reading orientation")); |
|
476 TPtrC8 name = orientationElement.Name(); |
|
477 DEBUG8(("\t_Mm_:orientation: %S", &name)); |
|
478 if ( !name.Compare( KOrientation8 ) ) |
|
479 { |
|
480 TBool landscapeOrientation(EFalse); |
|
481 if (orientationElement.AttributeValueL(KId8) == KLandscape8) |
|
482 landscapeOrientation = ETrue; |
|
483 if ( landscapeOrientation != aLandscapeOrientation ) |
|
484 { |
|
485 continue; |
|
486 } |
|
487 RXmlEngNodeList<TXmlEngElement> elements; |
|
488 orientationElement.GetChildElements( elements ); |
|
489 CleanupClosePushL( elements ); |
|
490 TXmlEngElement element; |
|
491 while ( elements.HasNext() ) |
|
492 { |
|
493 element = elements.Next(); |
|
494 DEBUG(("_Mm_:iMmTemplateType != EMmTemplateMoveIndicator")); |
|
495 if (element.AttributeValueL(KId8) == KHighlight8) |
|
496 { |
|
497 DEBUG(("_Mm_:AttributeValueL - id == highlight")); |
|
498 ProcessElementL( mmTemplateType, element, aTemplate, landscapeOrientation, ETrue ); |
|
499 DEBUG(("ProcesElementL END")); |
|
500 } |
|
501 else if (element.AttributeValueL(KId8) == KNoHighlight8) |
|
502 { |
|
503 DEBUG(("_Mm_:AttributeValueL - id == nohighlight")); |
|
504 ProcessElementL( mmTemplateType, element, aTemplate, landscapeOrientation, EFalse ); |
|
505 DEBUG(("ProcesElementL END")); |
|
506 if ( aWidgetType == EGrid ) |
|
507 { |
|
508 DEBUG(("_Mm_:aWidgetType == EGrid")); |
|
509 ProcessElementL( mmTemplateType, element, aTemplate, landscapeOrientation, ETrue ); |
|
510 DEBUG(("ProcesElementL END")); |
|
511 } |
|
512 } |
|
513 } |
|
514 CleanupStack::PopAndDestroy( &elements ); |
|
515 } |
|
516 } |
|
517 |
|
518 CleanupStack::PopAndDestroy( &orientElements ); |
|
519 CleanupStack::PopAndDestroy( &xmlDoc ); |
|
520 CleanupStack::PopAndDestroy( &domParser ); |
|
521 CleanupStack::PopAndDestroy( &domImpl ); |
|
522 CleanupStack::PopAndDestroy(content); |
|
523 DEBUG(("_Mm_:CMmTemplateLibrary::LoadTemplateL OUT")); |
|
524 } |
|
525 |
|
526 // ----------------------------------------------------------------------------- |
|
527 // |
|
528 // ----------------------------------------------------------------------------- |
|
529 // |
|
530 void CMmTemplateLibrary::ProcessElementL(TMmTemplateType aMmTemplateType, |
|
531 TXmlEngElement aElement, |
|
532 const TDesC8& aTemplate, |
|
533 TBool aLandscapeOrientation, |
|
534 TBool aHighlighted ) |
|
535 { |
|
536 switch ( aMmTemplateType ) |
|
537 { |
|
538 case ETemplateTypeLCT: |
|
539 ProcessLCTTemplateElementL(aElement, aTemplate, aLandscapeOrientation, aHighlighted ); |
|
540 break; |
|
541 case ETemplateTypeCustom: |
|
542 ProcessCustomTemplateElementL(aElement, aTemplate, aLandscapeOrientation, aHighlighted ); |
|
543 break; |
|
544 } |
|
545 } |
|
546 |
|
547 // ----------------------------------------------------------------------------- |
|
548 // |
|
549 // ----------------------------------------------------------------------------- |
|
550 // |
|
551 void CMmTemplateLibrary::ProcessLCTTemplateElementL(TXmlEngElement aElement, |
|
552 const TDesC8& aTemplate, |
|
553 TBool aLandscapeOrientation, |
|
554 TBool aHighlighted ) |
|
555 { |
|
556 RXmlEngNodeList<TXmlEngElement> layoutElements; |
|
557 CleanupClosePushL( layoutElements ); |
|
558 aElement.GetChildElements( layoutElements ); |
|
559 TXmlEngElement layoutElement; |
|
560 TSize itemSize; |
|
561 while ( layoutElements.HasNext() ) |
|
562 { |
|
563 layoutElement = layoutElements.Next(); |
|
564 |
|
565 if ( !layoutElement.Name().Compare( KLayout8 ) ) |
|
566 { |
|
567 TPtrC8 lctAtt = layoutElement.AttributeValueL(KLct8); |
|
568 |
|
569 // set layout for grid |
|
570 TInt variety; |
|
571 if ( Zoom() == EAknUiZoomLarge && iWidgetType == EGrid) |
|
572 { |
|
573 HnConvUtils::Str8ToInt(layoutElement.AttributeValueL(KVarietyZoom8), variety); |
|
574 } |
|
575 else |
|
576 { |
|
577 HnConvUtils::Str8ToInt(layoutElement.AttributeValueL(KVariety8), variety); |
|
578 } |
|
579 |
|
580 TSize layoutSize; |
|
581 if ( iWidgetType == EGrid ) |
|
582 { |
|
583 layoutSize = MmLCTUtils::GetLayoutSize( lctAtt, variety ); |
|
584 CacheLayoutSizeL( layoutSize, aTemplate, aLandscapeOrientation ); |
|
585 } |
|
586 else |
|
587 { |
|
588 layoutSize = GetLayoutSizeL( iWidgetType, aTemplate, aLandscapeOrientation ); |
|
589 } |
|
590 |
|
591 TAknWindowLineLayout layout; |
|
592 TSize itemSize = GetLCTSize( lctAtt, variety, layout, aLandscapeOrientation ); |
|
593 |
|
594 AdjustItemSize( itemSize, layoutSize, aLandscapeOrientation ); |
|
595 HBufC8* lookup_string = LookupText( aTemplate, iWidgetType, iZoom, |
|
596 aLandscapeOrientation, aHighlighted ); |
|
597 iTemplateSizesMap.InsertL( lookup_string, itemSize ); |
|
598 |
|
599 // setup children |
|
600 RArray< TTemplateChild > childrenDefinition; |
|
601 CleanupClosePushL( childrenDefinition ); |
|
602 RXmlEngNodeList<TXmlEngElement> childrenElements; |
|
603 CleanupClosePushL( childrenElements ); |
|
604 layoutElement.GetChildElements( childrenElements ); |
|
605 TXmlEngElement childElement; |
|
606 while ( childrenElements.HasNext() ) |
|
607 { |
|
608 childElement = childrenElements.Next(); |
|
609 TPtrC8 name = childElement.Name(); |
|
610 if ( !name.Compare( KTextVisual8 ) || |
|
611 !name.Compare( KImageVisual8 ) ) |
|
612 { |
|
613 TTemplateChild childTemplate; |
|
614 childTemplate.iLct = childElement.AttributeValueL(KLct8); |
|
615 TInt variety; |
|
616 if ( Zoom() != EAknUiZoomNormal && iWidgetType == EGrid ) |
|
617 { |
|
618 HnConvUtils::Str8ToInt(childElement.AttributeValueL(KVarietyZoom8), variety); |
|
619 } |
|
620 else |
|
621 { |
|
622 HnConvUtils::Str8ToInt(childElement.AttributeValueL(KVariety8), variety); |
|
623 } |
|
624 childTemplate.iVariety = variety; |
|
625 |
|
626 TPtrC8 ptr = childElement.AttributeValueL(KHAlign8); |
|
627 if (!ptr.Compare(KNullDesC8)) |
|
628 { |
|
629 childTemplate.iHAlign = EManualAlignUndefined; |
|
630 } |
|
631 else if (!ptr.Compare(KLeft8)) |
|
632 { |
|
633 childTemplate.iHAlign = EManualAlignLeft; |
|
634 } |
|
635 else if (!ptr.Compare(KCenter8)) |
|
636 { |
|
637 childTemplate.iHAlign = EManualAlignCenter; |
|
638 } |
|
639 else if (!ptr.Compare(KRight8)) |
|
640 { |
|
641 childTemplate.iHAlign = EManualAlignRight; |
|
642 } |
|
643 |
|
644 SetupLCTTemplateL( childTemplate, childElement, itemSize ); |
|
645 childrenDefinition.AppendL( childTemplate ); |
|
646 } |
|
647 } |
|
648 CleanupStack::PopAndDestroy( &childrenElements ); |
|
649 // save children defintion in map |
|
650 lookup_string = LookupText(aTemplate, iWidgetType, iZoom, |
|
651 aLandscapeOrientation, aHighlighted ); |
|
652 iTemplateChildrenMap.InsertL(lookup_string, childrenDefinition); |
|
653 CleanupStack::Pop( &childrenDefinition ); |
|
654 break; |
|
655 } |
|
656 } |
|
657 CleanupStack::PopAndDestroy( &layoutElements ); |
|
658 } |
|
659 |
|
660 // ----------------------------------------------------------------------------- |
|
661 // |
|
662 // ----------------------------------------------------------------------------- |
|
663 // |
|
664 void CMmTemplateLibrary::ProcessCustomTemplateElementL(TXmlEngElement aElement, |
|
665 const TDesC8& aTemplate, |
|
666 TBool aLandscapeOrientation, |
|
667 TBool aHighlighted ) |
|
668 { |
|
669 RXmlEngNodeList<TXmlEngElement> layoutElements; |
|
670 CleanupClosePushL( layoutElements ); |
|
671 aElement.GetChildElements( layoutElements ); |
|
672 TXmlEngElement layoutElement; |
|
673 while ( layoutElements.HasNext() ) |
|
674 { |
|
675 layoutElement = layoutElements.Next(); |
|
676 if ( !layoutElement.Name().Compare( KLayout8 ) ) |
|
677 { |
|
678 TSize itemSize; |
|
679 // set sizes |
|
680 TInt height; |
|
681 TInt width; |
|
682 HBufC8* lookup_string; |
|
683 |
|
684 HnConvUtils::Str8ToInt(layoutElement.AttributeValueL(KHeight8), height); |
|
685 HnConvUtils::Str8ToInt(layoutElement.AttributeValueL(KWidth8), width); |
|
686 lookup_string = LookupText( aTemplate, iWidgetType, iZoom, |
|
687 aLandscapeOrientation, aHighlighted ); |
|
688 itemSize = TSize( width, height ); |
|
689 |
|
690 |
|
691 TSize layoutSize = ( aLandscapeOrientation ) ? |
|
692 TSize( MmGrid::KColsLandscapeZoomNormal, MmGrid::KRowsLandscapeZoomNormal ): |
|
693 TSize( MmGrid::KColsPortraitZoomNormal, MmGrid::KRowsPortraitZoomNormal ) ; |
|
694 layoutSize = ( iWidgetType == EGrid ) ? layoutSize: TSize(MmListBox::KCols,0); |
|
695 CacheLayoutSizeL( layoutSize, aTemplate, aLandscapeOrientation ); |
|
696 |
|
697 AdjustItemWidth( itemSize, layoutSize, aLandscapeOrientation ); |
|
698 iTemplateSizesMap.InsertL(lookup_string, itemSize); |
|
699 |
|
700 // set children |
|
701 RArray< TTemplateChild > childrenDefinition; |
|
702 CleanupClosePushL( childrenDefinition ); |
|
703 |
|
704 RXmlEngNodeList<TXmlEngElement> childrenElements; |
|
705 CleanupClosePushL( childrenElements ); |
|
706 layoutElement.GetChildElements( childrenElements ); |
|
707 TXmlEngElement childElement; |
|
708 while ( childrenElements.HasNext() ) |
|
709 { |
|
710 childElement = childrenElements.Next(); |
|
711 TPtrC8 name = childElement.Name(); |
|
712 if ( !name.Compare( KTextVisual8 ) || |
|
713 !name.Compare( KImageVisual8 ) ) |
|
714 { |
|
715 TTemplateChild childTemplate; |
|
716 SetupCustomTemplateL( childTemplate, childElement ); |
|
717 childrenDefinition.AppendL( childTemplate ); |
|
718 } |
|
719 } |
|
720 CleanupStack::PopAndDestroy( &childrenElements ); |
|
721 // save children defintion in map |
|
722 lookup_string = LookupText(aTemplate, iWidgetType, iZoom, |
|
723 aLandscapeOrientation, aHighlighted ); |
|
724 iTemplateChildrenMap.InsertL(lookup_string, childrenDefinition); |
|
725 CleanupStack::Pop( &childrenDefinition ); |
|
726 // we found first layout, it is enough |
|
727 break; |
|
728 } |
|
729 } |
|
730 CleanupStack::PopAndDestroy( &layoutElements ); |
|
731 } |
|
732 |
|
733 // ----------------------------------------------------------------------------- |
|
734 // |
|
735 // ----------------------------------------------------------------------------- |
|
736 // |
|
737 HBufC8* CMmTemplateLibrary::GetTemplateContentL(const TDesC8& aTemplate, |
|
738 TMmWidgetType aWidgetType, TMmTemplateType& aMmTemplateType) |
|
739 { |
|
740 HBufC8* content; |
|
741 TRAPD( err , GetTemplateFileContentL( content, aTemplate, aWidgetType, aMmTemplateType ) ); |
|
742 if ( KErrNone != err || !content ) |
|
743 { |
|
744 // if LCT template was not loaded try to load a custom template |
|
745 TRAPD( err , GetTemplateFileContentL( content, aTemplate, aWidgetType, aMmTemplateType, ETrue ) ); |
|
746 if ( KErrNoMemory == err ) |
|
747 { |
|
748 User::Leave( KErrNoMemory ); |
|
749 } |
|
750 if ( KErrNone != err || !content ) |
|
751 { |
|
752 User::Panic(KMtlPanic, -1); |
|
753 } |
|
754 } |
|
755 return content; |
|
756 } |
|
757 |
|
758 // ----------------------------------------------------------------------------- |
|
759 // |
|
760 // ----------------------------------------------------------------------------- |
|
761 // |
|
762 void CMmTemplateLibrary::GetTemplateFileContentL( HBufC8*& aContent, |
|
763 const TDesC8& aTemplate, TMmWidgetType aWidgetType, |
|
764 TMmTemplateType& aMmTemplateType, TBool aLoadCustomTemplate ) |
|
765 { |
|
766 DEBUG(("_Mm_:CMmTemplateLibrary::GetTemplateContentL IN")); |
|
767 TFileName filename; |
|
768 // create filename egz: akn_logical_template_3.xml |
|
769 filename.Copy(aTemplate); |
|
770 filename.Insert(0, KUnderline ); |
|
771 filename.Insert(0, KAkn ); |
|
772 filename.Append( KXmlExt ); |
|
773 |
|
774 // append path egz: z:\\resource\\grid\\lct\\akn_logical_template_3.xml |
|
775 |
|
776 if ( !aLoadCustomTemplate ) |
|
777 { |
|
778 filename.Insert(0, KBslash ); |
|
779 filename.Insert(0, KLct ); |
|
780 } |
|
781 else |
|
782 { |
|
783 filename.Insert(0, KBslash ); |
|
784 filename.Insert(0, KCustom ); |
|
785 } |
|
786 |
|
787 switch (aWidgetType) |
|
788 { |
|
789 case EGrid: |
|
790 filename.Insert(0, KBslash ); |
|
791 filename.Insert(0, KWidgetTypeGrid); |
|
792 break; |
|
793 case EListbox: |
|
794 filename.Insert(0, KBslash ); |
|
795 filename.Insert(0, KWidgetTypeList ); |
|
796 break; |
|
797 } |
|
798 |
|
799 filename.Insert(0, KZResource ); |
|
800 |
|
801 DEBUG(("\t_Mm_:tail: %S", &filename)); |
|
802 DEBUG(("_Mm_:CMmTemplateLibrary::GetTemplateContentL OUT")); |
|
803 |
|
804 // load LCT Template or if it does not exist then load custom template |
|
805 aContent = HnUtils::ReadFileLC(filename); |
|
806 CleanupStack::Pop( aContent ); |
|
807 |
|
808 if ( aLoadCustomTemplate ) |
|
809 { |
|
810 aMmTemplateType = ETemplateTypeCustom; |
|
811 } |
|
812 else |
|
813 { |
|
814 aMmTemplateType = ETemplateTypeLCT; |
|
815 } |
|
816 return; |
|
817 } |
|
818 |
|
819 // ----------------------------------------------------------------------------- |
|
820 // |
|
821 // ----------------------------------------------------------------------------- |
|
822 // |
|
823 TSize CMmTemplateLibrary::GetLCTSize( const TDesC8& aLCTTemplate, TInt aVariety, |
|
824 TAknWindowLineLayout& aWindowLayout, TBool aLandscapeOrientation ) |
|
825 { |
|
826 TSize size = MmLCTUtils::GetLCTSize( aLCTTemplate, aVariety, |
|
827 GetParentRect( aLandscapeOrientation ), aWindowLayout ); |
|
828 return size; |
|
829 } |
|
830 |
|
831 // ----------------------------------------------------------------------------- |
|
832 // |
|
833 // ----------------------------------------------------------------------------- |
|
834 // |
|
835 void CMmTemplateLibrary::SetupLCTTemplateL(TTemplateChild& aChildTemplate, |
|
836 TXmlEngElement& aChildElement, TSize aItemSize ) |
|
837 { |
|
838 TPtrC8 name = aChildElement.Name(); |
|
839 aChildTemplate.iData = aChildElement.AttributeValueL(KId8); |
|
840 SetupTemplateVisualId( aChildTemplate ); |
|
841 |
|
842 // read attribute name (mm_title, mm_icon) |
|
843 RXmlEngNodeList<TXmlEngElement> attributeElements; |
|
844 CleanupClosePushL( attributeElements ); |
|
845 aChildElement.GetChildElements( attributeElements ); |
|
846 TXmlEngElement attElement; |
|
847 while ( attributeElements.HasNext() ) |
|
848 { |
|
849 attElement = attributeElements.Next(); |
|
850 TPtrC8 nameAtt = attElement.AttributeValueL(KName8); |
|
851 if ( !name.Compare( KTextVisual8 ) && |
|
852 !nameAtt.Compare( KText8 ) ) |
|
853 { |
|
854 MmLCTUtils::SetupTextSubCellTemplate( aItemSize, aChildTemplate ); |
|
855 } |
|
856 else if ( !name.Compare( KImageVisual8 ) && |
|
857 !nameAtt.Compare( KImagePath8 ) ) |
|
858 { |
|
859 MmLCTUtils::SetupGraphicSubCellTemplate(aItemSize, aChildTemplate); |
|
860 AdjustIconPosition(aItemSize, aChildTemplate); |
|
861 } |
|
862 } |
|
863 CleanupStack::PopAndDestroy( &attributeElements ); |
|
864 } |
|
865 |
|
866 // ----------------------------------------------------------------------------- |
|
867 // |
|
868 // ----------------------------------------------------------------------------- |
|
869 // |
|
870 void CMmTemplateLibrary::SetupCustomTemplateL(TTemplateChild& aChildTemplate, |
|
871 TXmlEngElement& aChildElement) |
|
872 { |
|
873 TPtrC8 name = aChildElement.Name(); |
|
874 TInt positionx; TInt positiony; |
|
875 TInt height; TInt width; |
|
876 |
|
877 HnConvUtils::Str8ToInt(aChildElement.AttributeValueL(KPositionX8), positionx); |
|
878 HnConvUtils::Str8ToInt(aChildElement.AttributeValueL(KPositionY8), positiony); |
|
879 HnConvUtils::Str8ToInt(aChildElement.AttributeValueL(KHeight8), height); |
|
880 HnConvUtils::Str8ToInt(aChildElement.AttributeValueL(KWidth8), width); |
|
881 aChildTemplate.iRectAccordingToParent = TRect( TPoint(positionx,positiony), TSize(width, height) ); |
|
882 |
|
883 aChildTemplate.iData = aChildElement.AttributeValueL(KId8); |
|
884 SetupTemplateVisualId( aChildTemplate ); |
|
885 |
|
886 // read attribute name (mm_title, mm_icon) |
|
887 RXmlEngNodeList<TXmlEngElement> attributeElements; |
|
888 CleanupClosePushL( attributeElements ); |
|
889 aChildElement.GetChildElements( attributeElements ); |
|
890 TXmlEngElement attElement; |
|
891 while ( attributeElements.HasNext() ) |
|
892 { |
|
893 attElement = attributeElements.Next(); |
|
894 TPtrC8 nameAtt = attElement.AttributeValueL(KName8); |
|
895 if ( !name.Compare( KTextVisual8 ) && |
|
896 !nameAtt.Compare( KText8 ) ) |
|
897 { |
|
898 aChildTemplate.iIsImage = EFalse; |
|
899 } |
|
900 else if ( !name.Compare( KImageVisual8 ) && |
|
901 !nameAtt.Compare( KImagePath8 ) ) |
|
902 { |
|
903 aChildTemplate.iIsImage = ETrue; |
|
904 aChildTemplate.iFontId = EAknLogicalFontSecondaryFont; |
|
905 aChildTemplate.iTextAlign = CGraphicsContext::ELeft ; |
|
906 } |
|
907 else if ( !name.Compare( KTextVisual8 ) && |
|
908 !nameAtt.Compare( KStyle8 ) ) |
|
909 { |
|
910 TPtrC8 font = attElement.AttributeValueL(KTargetValue8); |
|
911 if ( !font.Compare( KQfnPrimarySmall8 ) ) |
|
912 { |
|
913 aChildTemplate.iFontId = EAknLogicalFontPrimarySmallFont; |
|
914 } |
|
915 else |
|
916 { |
|
917 aChildTemplate.iFontId = EAknLogicalFontSecondaryFont; |
|
918 } |
|
919 } |
|
920 else if ( !name.Compare( KTextVisual8 ) && |
|
921 !nameAtt.Compare( KHorizontalAlign8 ) ) |
|
922 { |
|
923 TInt textAlign; |
|
924 HnConvUtils::Str8ToInt(attElement.AttributeValueL(KTargetValue8), textAlign); |
|
925 aChildTemplate.iTextAlign = static_cast<CGraphicsContext::TTextAlign>(textAlign); |
|
926 } |
|
927 } |
|
928 |
|
929 CleanupStack::PopAndDestroy( &attributeElements ); |
|
930 } |
|
931 |
|
932 // ----------------------------------------------------------------------------- |
|
933 // |
|
934 // ----------------------------------------------------------------------------- |
|
935 // |
|
936 void CMmTemplateLibrary::SetupTemplateVisualId(TTemplateChild& aChildTemplate ) |
|
937 { |
|
938 if( !aChildTemplate.iData.Compare( KMmBackdropIcon8 )) |
|
939 { |
|
940 aChildTemplate.iImageVisualId = EImageVisualIdEditMode; |
|
941 } |
|
942 else |
|
943 { |
|
944 aChildTemplate.iImageVisualId = EImageVisualIdNormalMode; |
|
945 } |
|
946 } |
|
947 |
|
948 // ----------------------------------------------------------------------------- |
|
949 // |
|
950 // ----------------------------------------------------------------------------- |
|
951 // |
|
952 void CMmTemplateLibrary::AppendEditModeTemplateL( |
|
953 RArray<TTemplateChild>& aTemplateArray, TSize aSize) |
|
954 { |
|
955 //setup backdrop icon |
|
956 TTemplateChild childTemplate; |
|
957 childTemplate.iIsImage = ETrue; |
|
958 childTemplate.iFontId = EAknLogicalFontSecondaryFont; |
|
959 childTemplate.iTextAlign = CGraphicsContext::ELeft; |
|
960 childTemplate.iRectAccordingToParent = TRect( TPoint( 0,0 ), |
|
961 TPoint( aSize.iWidth, aSize.iHeight ) ); |
|
962 childTemplate.iData = TBufC8< MmTemplateContants::KTemplateChildTextLength >( KMmBackdropIcon8 ); |
|
963 SetupTemplateVisualId( childTemplate ); |
|
964 aTemplateArray.AppendL( childTemplate ); |
|
965 } |
|
966 |
|
967 |
|
968 // ----------------------------------------------------------------------------- |
|
969 // |
|
970 // ----------------------------------------------------------------------------- |
|
971 // |
|
972 void CMmTemplateLibrary::SetupMoveIndicatorTemplateChildrenL( |
|
973 const TDesC8& aLookupString, TSize aItemSize ) |
|
974 { |
|
975 RArray< TTemplateChild > childrenDefinition; |
|
976 TTemplateChild childTemplate; |
|
977 childTemplate.iIsImage = ETrue; |
|
978 childTemplate.iImageVisualId = EImageVisualIdNormalMode; |
|
979 childTemplate.iFontId = EAknLogicalFontSecondaryFont; |
|
980 childTemplate.iTextAlign = CGraphicsContext::ELeft; |
|
981 TPoint startingPosition = TPoint( |
|
982 MmTemplateContants::KMoveIndicatorStartingPos, |
|
983 MmTemplateContants::KMoveIndicatorStartingPos); |
|
984 |
|
985 //setup move_indicator_arrow_left |
|
986 childTemplate.iRectAccordingToParent = TRect(TPoint(0,aItemSize.iHeight/2 + startingPosition.iY/2), |
|
987 TPoint(startingPosition.iX, |
|
988 startingPosition.iY*3/2 + aItemSize.iHeight/2)); |
|
989 childTemplate.iData = TBufC8< MmTemplateContants::KTemplateChildTextLength>( |
|
990 KMmMoveIndicatorArrowLeft8 ); |
|
991 childrenDefinition.AppendL( childTemplate ); |
|
992 |
|
993 //setup move_indicator_arrow_right |
|
994 childTemplate.iRectAccordingToParent = TRect( |
|
995 TPoint(startingPosition.iX + aItemSize.iWidth , aItemSize.iHeight/2 + startingPosition.iY/2), |
|
996 TPoint(startingPosition.iX*2 + aItemSize.iWidth, |
|
997 startingPosition.iY*3/2 + aItemSize.iHeight/2)); |
|
998 childTemplate.iData = TBufC8< MmTemplateContants::KTemplateChildTextLength>( |
|
999 KMmMoveIndicatorArrowRight8 ); |
|
1000 childrenDefinition.AppendL( childTemplate ); |
|
1001 |
|
1002 //setup move_indicator_arrow_top |
|
1003 childTemplate.iRectAccordingToParent = TRect(TPoint( aItemSize.iWidth/2 + startingPosition.iX/2, 0 ), |
|
1004 TPoint(aItemSize.iWidth/2 + startingPosition.iX*3/2, startingPosition.iY)); |
|
1005 childTemplate.iData = TBufC8< MmTemplateContants::KTemplateChildTextLength >( |
|
1006 KMmMoveIndicatorArrowTop8 ); |
|
1007 childrenDefinition.AppendL( childTemplate ); |
|
1008 |
|
1009 //setup move_indicator_arrow_bottom |
|
1010 childTemplate.iRectAccordingToParent = TRect( TPoint( aItemSize.iWidth/2 + startingPosition.iX/2, |
|
1011 aItemSize.iHeight + startingPosition.iY + 2 ), |
|
1012 TPoint(aItemSize.iWidth/2 + startingPosition.iX*3/2, |
|
1013 aItemSize.iHeight + 2 *startingPosition.iY)); |
|
1014 childTemplate.iData = TBufC8< MmTemplateContants::KTemplateChildTextLength>( |
|
1015 KMmMoveIndicatorArrowBottom8 ); |
|
1016 childrenDefinition.AppendL( childTemplate ); |
|
1017 |
|
1018 HBufC8* lookup_string = aLookupString.AllocLC(); |
|
1019 iTemplateChildrenMap.InsertL(lookup_string, childrenDefinition); |
|
1020 CleanupStack::Pop( lookup_string ); |
|
1021 lookup_string = NULL; |
|
1022 |
|
1023 lookup_string = aLookupString.AllocLC(); |
|
1024 TRect rectAccordingToParent = TRect( |
|
1025 TPoint( -startingPosition.iX, -startingPosition.iY), |
|
1026 TPoint(2*startingPosition.iX + aItemSize.iWidth , |
|
1027 2*startingPosition.iY + aItemSize.iHeight) ); |
|
1028 |
|
1029 iMoveIndicatorRectsMap.InsertL( lookup_string, rectAccordingToParent ); |
|
1030 CleanupStack::Pop( lookup_string ); |
|
1031 } |
|
1032 |
|
1033 // ----------------------------------------------------------------------------- |
|
1034 // |
|
1035 // ----------------------------------------------------------------------------- |
|
1036 // |
|
1037 void CMmTemplateLibrary::SetScrollbarVisibilityL( TBool aIsScrollbarVisible ) |
|
1038 { |
|
1039 if ( iIsScrollbarVisible != aIsScrollbarVisible ) |
|
1040 { |
|
1041 iIsScrollbarVisible = aIsScrollbarVisible; |
|
1042 CleanAndClearCache(); |
|
1043 } |
|
1044 } |
|
1045 |
|
1046 // ----------------------------------------------------------------------------- |
|
1047 // |
|
1048 // ----------------------------------------------------------------------------- |
|
1049 // |
|
1050 TBool CMmTemplateLibrary::GetScrollbarVisibility() |
|
1051 { |
|
1052 return iIsScrollbarVisible; |
|
1053 } |
|
1054 |
|
1055 // ----------------------------------------------------------------------------- |
|
1056 // |
|
1057 // ----------------------------------------------------------------------------- |
|
1058 // |
|
1059 void CMmTemplateLibrary::SetScrollbarWidthL( TInt aScrollbarWidth ) |
|
1060 { |
|
1061 if ( iIsScrollbarVisible ) |
|
1062 { |
|
1063 if ( iScrollbarWidth != aScrollbarWidth ) |
|
1064 { |
|
1065 iScrollbarWidth = aScrollbarWidth; |
|
1066 CleanAndClearCache(); |
|
1067 } |
|
1068 } |
|
1069 else |
|
1070 { |
|
1071 if ( iScrollbarWidth != 0 ) |
|
1072 { |
|
1073 iScrollbarWidth = 0; |
|
1074 CleanAndClearCache(); |
|
1075 } |
|
1076 } |
|
1077 } |
|
1078 |
|
1079 // ----------------------------------------------------------------------------- |
|
1080 // |
|
1081 // ----------------------------------------------------------------------------- |
|
1082 // |
|
1083 TInt CMmTemplateLibrary::ScrollbarWidth() |
|
1084 { |
|
1085 return iScrollbarWidth; |
|
1086 } |
|
1087 |
|
1088 // ----------------------------------------------------------------------------- |
|
1089 // |
|
1090 // ----------------------------------------------------------------------------- |
|
1091 // |
|
1092 void CMmTemplateLibrary::AdjustItemWidth(TSize& aItemSize, TSize aLayoutSize, |
|
1093 TBool aLandscapeOrientation) |
|
1094 { |
|
1095 if ( iIsScrollbarVisible ) |
|
1096 { |
|
1097 aItemSize.iWidth = ( GetParentRect(aLandscapeOrientation).Width() - iScrollbarWidth ) / aLayoutSize.iWidth; |
|
1098 } |
|
1099 else |
|
1100 { |
|
1101 aItemSize.iWidth = GetParentRect(aLandscapeOrientation).Width() / aLayoutSize.iWidth; |
|
1102 } |
|
1103 } |
|
1104 |
|
1105 // ----------------------------------------------------------------------------- |
|
1106 // |
|
1107 // ----------------------------------------------------------------------------- |
|
1108 // |
|
1109 void CMmTemplateLibrary::UpdateParentRect( TRect aParentRect, TBool aLandscapeOrientation ) |
|
1110 { |
|
1111 if( GetParentRect( aLandscapeOrientation ) != aParentRect ) |
|
1112 { |
|
1113 SetParentRect( aLandscapeOrientation, aParentRect ); |
|
1114 } |
|
1115 } |
|
1116 |
|
1117 |
|
1118 // ----------------------------------------------------------------------------- |
|
1119 // |
|
1120 // ----------------------------------------------------------------------------- |
|
1121 // |
|
1122 TRect CMmTemplateLibrary::GetParentRect( TBool aLandscapeOrientation ) |
|
1123 { |
|
1124 if ( aLandscapeOrientation ) |
|
1125 return iParentRectLandscape; |
|
1126 else |
|
1127 return iParentRectPortrait; |
|
1128 } |
|
1129 |
|
1130 // ----------------------------------------------------------------------------- |
|
1131 // |
|
1132 // ----------------------------------------------------------------------------- |
|
1133 // |
|
1134 void CMmTemplateLibrary::SetParentRect( TBool aLandscapeOrientation, TRect aParentRect) |
|
1135 { |
|
1136 if ( aLandscapeOrientation ) |
|
1137 iParentRectLandscape = aParentRect; |
|
1138 else |
|
1139 iParentRectPortrait = aParentRect; |
|
1140 } |
|
1141 |
|
1142 // ----------------------------------------------------------------------------- |
|
1143 // |
|
1144 // ----------------------------------------------------------------------------- |
|
1145 // |
|
1146 void CMmTemplateLibrary::AdjustItemSize(TSize& aItemSize, TSize aLayoutSize, |
|
1147 TBool aLandscapeOrientation) |
|
1148 { |
|
1149 switch ( iWidgetType ) |
|
1150 { |
|
1151 case EGrid: |
|
1152 aItemSize.iHeight = GetParentRect( aLandscapeOrientation ).Height() / aLayoutSize.iHeight; |
|
1153 break; |
|
1154 case EListbox: |
|
1155 break; |
|
1156 } |
|
1157 AdjustItemWidth( aItemSize, aLayoutSize, aLandscapeOrientation ); |
|
1158 } |
|
1159 |
|
1160 // ----------------------------------------------------------------------------- |
|
1161 // |
|
1162 // ----------------------------------------------------------------------------- |
|
1163 // |
|
1164 TAknUiZoom CMmTemplateLibrary::Zoom( ) |
|
1165 { |
|
1166 return iZoom; |
|
1167 } |
|
1168 |
|
1169 // ----------------------------------------------------------------------------- |
|
1170 // |
|
1171 // ----------------------------------------------------------------------------- |
|
1172 // |
|
1173 void CMmTemplateLibrary::SetZoom( TAknUiZoom aZoom ) |
|
1174 { |
|
1175 if ( (EAknUiZoomLarge == aZoom) |
|
1176 || (EAknUiZoomSmall == aZoom) ) |
|
1177 { |
|
1178 iZoom = aZoom; |
|
1179 } |
|
1180 else |
|
1181 { |
|
1182 iZoom = EAknUiZoomNormal; |
|
1183 } |
|
1184 } |
|
1185 |
|
1186 // ----------------------------------------------------------------------------- |
|
1187 // |
|
1188 // ----------------------------------------------------------------------------- |
|
1189 // |
|
1190 void CMmTemplateLibrary::CacheLayoutSizeL(TSize aLayoutSize, |
|
1191 const TDesC8& aTemplate, TBool aLandscapeOrientation) |
|
1192 { |
|
1193 HBufC8* lookup_layout_text = LookupLayoutText( iWidgetType, iZoom, |
|
1194 aTemplate, aLandscapeOrientation ); |
|
1195 |
|
1196 if ( iTemplateSizesMap.Find( lookup_layout_text ) ) |
|
1197 { |
|
1198 delete lookup_layout_text; |
|
1199 } |
|
1200 else |
|
1201 { |
|
1202 iTemplateSizesMap.InsertL( lookup_layout_text, aLayoutSize ); |
|
1203 } |
|
1204 } |
|
1205 |
|
1206 // ----------------------------------------------------------------------------- |
|
1207 // |
|
1208 // ----------------------------------------------------------------------------- |
|
1209 // |
|
1210 void CMmTemplateLibrary::AdjustIconPosition(TSize aParentSize, |
|
1211 TTemplateChild& aTemplateChild) |
|
1212 { |
|
1213 switch (aTemplateChild.iHAlign) |
|
1214 { |
|
1215 case EManualAlignLeft: |
|
1216 break; |
|
1217 case EManualAlignCenter: |
|
1218 { |
|
1219 TInt rectWidth = |
|
1220 aTemplateChild.iRectAccordingToParent.Size().iWidth; |
|
1221 TInt lX = (aParentSize.iWidth - rectWidth) / 2; |
|
1222 aTemplateChild.iRectAccordingToParent.Move(lX |
|
1223 - aTemplateChild.iRectAccordingToParent.iTl.iX, 0); |
|
1224 break; |
|
1225 } |
|
1226 case EManualAlignRight: |
|
1227 break; |
|
1228 default: |
|
1229 break; |
|
1230 } |
|
1231 } |
|
1232 |
|
1233 // End of file |