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, |
|
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, |
|
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, |
|
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, |
|
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, |
|
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, TBool aLandscapeOrientation, TBool aHighlighted ) |
|
347 { |
|
348 HBufC8* lookup_string = HBufC8::New( MmTemplateContants::KTemplateChildTextLength ); |
|
349 if (lookup_string) |
|
350 { |
|
351 TPtr8 lookup_string_ptr( lookup_string->Des() ); |
|
352 lookup_string_ptr.Append( aTemplate ); |
|
353 lookup_string_ptr.Append( KColon8 ); |
|
354 switch ( aWidgetType ) |
|
355 { |
|
356 case EListbox: |
|
357 lookup_string_ptr.Append( KListbox8 ); |
|
358 break; |
|
359 case EGrid: |
|
360 lookup_string_ptr.Append( KGrid8 ); |
|
361 break; |
|
362 } |
|
363 lookup_string_ptr.Append( KColon8 ); |
|
364 lookup_string_ptr.AppendNum( aLandscapeOrientation ); |
|
365 lookup_string_ptr.Append( KColon8 ); |
|
366 lookup_string_ptr.AppendNum( aHighlighted ); |
|
367 lookup_string_ptr.Append( KColon8 ); |
|
368 } |
|
369 return lookup_string; |
|
370 } |
|
371 |
|
372 // ----------------------------------------------------------------------------- |
|
373 // |
|
374 // ----------------------------------------------------------------------------- |
|
375 // |
|
376 HBufC8* CMmTemplateLibrary::LookupLayoutText( TMmWidgetType aWidgetType, |
|
377 const TDesC8& aTemplate, TBool aLandscapeOrientation ) |
|
378 { |
|
379 HBufC8* lookup_string = HBufC8::New( MmTemplateContants::KTemplateChildTextLength ); |
|
380 if (lookup_string) |
|
381 { |
|
382 TPtr8 lookup_string_ptr( lookup_string->Des() ); |
|
383 switch ( aWidgetType ) |
|
384 { |
|
385 case EListbox: |
|
386 lookup_string_ptr.Append( KListbox8 ); |
|
387 break; |
|
388 case EGrid: |
|
389 lookup_string_ptr.Append( KGrid8 ); |
|
390 break; |
|
391 } |
|
392 lookup_string_ptr.Append( KColon8 ); |
|
393 lookup_string_ptr.Append( KColon8 ); |
|
394 lookup_string_ptr.Append( aTemplate ); |
|
395 lookup_string_ptr.Append( KColon8 ); |
|
396 lookup_string_ptr.AppendNum( aLandscapeOrientation ); |
|
397 } |
|
398 return lookup_string; |
|
399 } |
|
400 |
|
401 // ----------------------------------------------------------------------------- |
|
402 // |
|
403 // ----------------------------------------------------------------------------- |
|
404 // |
|
405 HBufC8* CMmTemplateLibrary::LookupIndicatorText( const TDesC8& aLookupText ) |
|
406 { |
|
407 HBufC8* lookup_string = HBufC8::New( MmTemplateContants::KTemplateChildTextLength ); |
|
408 if (lookup_string) |
|
409 { |
|
410 TPtr8 lookup_string_ptr( lookup_string->Des() ); |
|
411 lookup_string_ptr.Append( KMI8 ); |
|
412 lookup_string_ptr.Append( KColon8 ); |
|
413 lookup_string_ptr.Append( aLookupText ); |
|
414 } |
|
415 |
|
416 return lookup_string; |
|
417 } |
|
418 |
|
419 // ----------------------------------------------------------------------------- |
|
420 // |
|
421 // ----------------------------------------------------------------------------- |
|
422 // |
|
423 void CMmTemplateLibrary::LoadTemplateL( TMmWidgetType aWidgetType, |
|
424 const TDesC8& aTemplate, TBool aLandscapeOrientation ) |
|
425 { |
|
426 iWidgetType = aWidgetType; |
|
427 DEBUG(("_Mm_:CMmTemplateLibrary::LoadTemplateL IN")); |
|
428 TMmTemplateType mmTemplateType; |
|
429 HBufC8* content = GetTemplateContentL( aTemplate, aWidgetType, mmTemplateType ); |
|
430 CleanupStack::PushL( content ); |
|
431 RXmlEngDOMImplementation domImpl; |
|
432 CleanupClosePushL( domImpl ); |
|
433 RXmlEngDOMParser domParser; |
|
434 CleanupClosePushL( domParser ); |
|
435 DEBUG(("_Mm_:CMmTemplateLibrary::LoadTemplateL Opening domImpl")); |
|
436 domImpl.OpenL(); |
|
437 User::LeaveIfError( domParser.Open( domImpl ) ); |
|
438 DEBUG(("_Mm_:CMmTemplateLibrary::LoadTemplateL parsing content...")); |
|
439 RXmlEngDocument xmlDoc = domParser.ParseL( *content ); |
|
440 CleanupClosePushL( xmlDoc ); |
|
441 |
|
442 // first orientation |
|
443 RXmlEngNodeList<TXmlEngElement> orientElements; |
|
444 CleanupClosePushL( orientElements ); |
|
445 xmlDoc.DocumentElement().GetChildElements( orientElements ); |
|
446 TXmlEngElement orientationElement; |
|
447 while ( orientElements.HasNext() ) |
|
448 { |
|
449 orientationElement = orientElements.Next(); |
|
450 DEBUG(("_Mm_:CMmTemplateLibrary::LoadTemplateL Reading orientation")); |
|
451 TPtrC8 name = orientationElement.Name(); |
|
452 DEBUG8(("\t_Mm_:orientation: %S", &name)); |
|
453 if ( !name.Compare( KOrientation8 ) ) |
|
454 { |
|
455 TBool landscapeOrientation(EFalse); |
|
456 if (orientationElement.AttributeValueL(KId8) == KLandscape8) |
|
457 landscapeOrientation = ETrue; |
|
458 if ( landscapeOrientation != aLandscapeOrientation ) |
|
459 { |
|
460 continue; |
|
461 } |
|
462 RXmlEngNodeList<TXmlEngElement> elements; |
|
463 orientationElement.GetChildElements( elements ); |
|
464 CleanupClosePushL( elements ); |
|
465 TXmlEngElement element; |
|
466 while ( elements.HasNext() ) |
|
467 { |
|
468 element = elements.Next(); |
|
469 DEBUG(("_Mm_:iMmTemplateType != EMmTemplateMoveIndicator")); |
|
470 if (element.AttributeValueL(KId8) == KHighlight8) |
|
471 { |
|
472 DEBUG(("_Mm_:AttributeValueL - id == highlight")); |
|
473 ProcessElementL( mmTemplateType, element, aTemplate, landscapeOrientation, ETrue ); |
|
474 DEBUG(("ProcesElementL END")); |
|
475 } |
|
476 else if (element.AttributeValueL(KId8) == KNoHighlight8) |
|
477 { |
|
478 DEBUG(("_Mm_:AttributeValueL - id == nohighlight")); |
|
479 ProcessElementL( mmTemplateType, element, aTemplate, landscapeOrientation, EFalse ); |
|
480 DEBUG(("ProcesElementL END")); |
|
481 if ( aWidgetType == EGrid ) |
|
482 { |
|
483 DEBUG(("_Mm_:aWidgetType == EGrid")); |
|
484 ProcessElementL( mmTemplateType, element, aTemplate, landscapeOrientation, ETrue ); |
|
485 DEBUG(("ProcesElementL END")); |
|
486 } |
|
487 } |
|
488 } |
|
489 CleanupStack::PopAndDestroy( &elements ); |
|
490 } |
|
491 } |
|
492 |
|
493 CleanupStack::PopAndDestroy( &orientElements ); |
|
494 CleanupStack::PopAndDestroy( &xmlDoc ); |
|
495 CleanupStack::PopAndDestroy( &domParser ); |
|
496 CleanupStack::PopAndDestroy( &domImpl ); |
|
497 CleanupStack::PopAndDestroy(content); |
|
498 DEBUG(("_Mm_:CMmTemplateLibrary::LoadTemplateL OUT")); |
|
499 } |
|
500 |
|
501 // ----------------------------------------------------------------------------- |
|
502 // |
|
503 // ----------------------------------------------------------------------------- |
|
504 // |
|
505 void CMmTemplateLibrary::ProcessElementL(TMmTemplateType aMmTemplateType, |
|
506 TXmlEngElement aElement, |
|
507 const TDesC8& aTemplate, |
|
508 TBool aLandscapeOrientation, |
|
509 TBool aHighlighted ) |
|
510 { |
|
511 switch ( aMmTemplateType ) |
|
512 { |
|
513 case ETemplateTypeLCT: |
|
514 ProcessLCTTemplateElementL(aElement, aTemplate, aLandscapeOrientation, aHighlighted ); |
|
515 break; |
|
516 case ETemplateTypeCustom: |
|
517 ProcessCustomTemplateElementL(aElement, aTemplate, aLandscapeOrientation, aHighlighted ); |
|
518 break; |
|
519 } |
|
520 } |
|
521 |
|
522 // ----------------------------------------------------------------------------- |
|
523 // |
|
524 // ----------------------------------------------------------------------------- |
|
525 // |
|
526 void CMmTemplateLibrary::ProcessLCTTemplateElementL(TXmlEngElement aElement, |
|
527 const TDesC8& aTemplate, |
|
528 TBool aLandscapeOrientation, |
|
529 TBool aHighlighted ) |
|
530 { |
|
531 RXmlEngNodeList<TXmlEngElement> layoutElements; |
|
532 CleanupClosePushL( layoutElements ); |
|
533 aElement.GetChildElements( layoutElements ); |
|
534 TXmlEngElement layoutElement; |
|
535 TSize itemSize; |
|
536 while ( layoutElements.HasNext() ) |
|
537 { |
|
538 layoutElement = layoutElements.Next(); |
|
539 |
|
540 if ( !layoutElement.Name().Compare( KLayout8 ) ) |
|
541 { |
|
542 TPtrC8 lctAtt = layoutElement.AttributeValueL(KLct8); |
|
543 |
|
544 // set layout for grid |
|
545 TInt variety; |
|
546 HnConvUtils::Str8ToInt(layoutElement.AttributeValueL(KVariety8), variety); |
|
547 |
|
548 TSize layoutSize; |
|
549 if ( iWidgetType == EGrid ) |
|
550 { |
|
551 layoutSize = MmLCTUtils::GetLayoutSize( lctAtt, variety ); |
|
552 CacheLayoutSizeL( layoutSize, aTemplate, aLandscapeOrientation ); |
|
553 } |
|
554 else |
|
555 { |
|
556 layoutSize = GetLayoutSizeL( iWidgetType, aTemplate, aLandscapeOrientation ); |
|
557 } |
|
558 |
|
559 TAknWindowLineLayout layout; |
|
560 TSize itemSize = GetLCTSize( lctAtt, variety, layout, aLandscapeOrientation ); |
|
561 |
|
562 AdjustItemSize( itemSize, layoutSize, aLandscapeOrientation ); |
|
563 HBufC8* lookup_string = LookupText( aTemplate, iWidgetType, |
|
564 aLandscapeOrientation, aHighlighted ); |
|
565 iTemplateSizesMap.InsertL( lookup_string, itemSize ); |
|
566 |
|
567 // setup children |
|
568 RArray< TTemplateChild > childrenDefinition; |
|
569 CleanupClosePushL( childrenDefinition ); |
|
570 RXmlEngNodeList<TXmlEngElement> childrenElements; |
|
571 CleanupClosePushL( childrenElements ); |
|
572 layoutElement.GetChildElements( childrenElements ); |
|
573 TXmlEngElement childElement; |
|
574 while ( childrenElements.HasNext() ) |
|
575 { |
|
576 childElement = childrenElements.Next(); |
|
577 TPtrC8 name = childElement.Name(); |
|
578 if ( !name.Compare( KTextVisual8 ) || |
|
579 !name.Compare( KImageVisual8 ) ) |
|
580 { |
|
581 TTemplateChild childTemplate; |
|
582 childTemplate.iLct = childElement.AttributeValueL(KLct8); |
|
583 TInt variety; |
|
584 HnConvUtils::Str8ToInt(childElement.AttributeValueL(KVariety8), variety); |
|
585 childTemplate.iVariety = variety; |
|
586 |
|
587 TPtrC8 ptr = childElement.AttributeValueL(KHAlign8); |
|
588 if (!ptr.Compare(KNullDesC8)) |
|
589 { |
|
590 childTemplate.iHAlign = EManualAlignUndefined; |
|
591 } |
|
592 else if (!ptr.Compare(KLeft8)) |
|
593 { |
|
594 childTemplate.iHAlign = EManualAlignLeft; |
|
595 } |
|
596 else if (!ptr.Compare(KCenter8)) |
|
597 { |
|
598 childTemplate.iHAlign = EManualAlignCenter; |
|
599 } |
|
600 else if (!ptr.Compare(KRight8)) |
|
601 { |
|
602 childTemplate.iHAlign = EManualAlignRight; |
|
603 } |
|
604 |
|
605 SetupLCTTemplateL( childTemplate, childElement, itemSize ); |
|
606 childrenDefinition.AppendL( childTemplate ); |
|
607 } |
|
608 } |
|
609 CleanupStack::PopAndDestroy( &childrenElements ); |
|
610 // save children defintion in map |
|
611 lookup_string = LookupText(aTemplate, iWidgetType, |
|
612 aLandscapeOrientation, aHighlighted ); |
|
613 iTemplateChildrenMap.InsertL(lookup_string, childrenDefinition); |
|
614 CleanupStack::Pop( &childrenDefinition ); |
|
615 break; |
|
616 } |
|
617 } |
|
618 CleanupStack::PopAndDestroy( &layoutElements ); |
|
619 } |
|
620 |
|
621 // ----------------------------------------------------------------------------- |
|
622 // |
|
623 // ----------------------------------------------------------------------------- |
|
624 // |
|
625 void CMmTemplateLibrary::ProcessCustomTemplateElementL(TXmlEngElement aElement, |
|
626 const TDesC8& aTemplate, |
|
627 TBool aLandscapeOrientation, |
|
628 TBool aHighlighted ) |
|
629 { |
|
630 RXmlEngNodeList<TXmlEngElement> layoutElements; |
|
631 CleanupClosePushL( layoutElements ); |
|
632 aElement.GetChildElements( layoutElements ); |
|
633 TXmlEngElement layoutElement; |
|
634 while ( layoutElements.HasNext() ) |
|
635 { |
|
636 layoutElement = layoutElements.Next(); |
|
637 if ( !layoutElement.Name().Compare( KLayout8 ) ) |
|
638 { |
|
639 TSize itemSize; |
|
640 // set sizes |
|
641 TInt height; |
|
642 TInt width; |
|
643 HBufC8* lookup_string; |
|
644 |
|
645 HnConvUtils::Str8ToInt(layoutElement.AttributeValueL(KHeight8), height); |
|
646 HnConvUtils::Str8ToInt(layoutElement.AttributeValueL(KWidth8), width); |
|
647 lookup_string = LookupText( aTemplate, iWidgetType, |
|
648 aLandscapeOrientation, aHighlighted ); |
|
649 itemSize = TSize( width, height ); |
|
650 |
|
651 |
|
652 TSize layoutSize = ( aLandscapeOrientation ) ? |
|
653 TSize( MmGrid::KColsLandscapeZoomNormal, MmGrid::KRowsLandscapeZoomNormal ): |
|
654 TSize( MmGrid::KColsPortraitZoomNormal, MmGrid::KRowsPortraitZoomNormal ) ; |
|
655 layoutSize = ( iWidgetType == EGrid ) ? layoutSize: TSize(MmListBox::KCols,0); |
|
656 CacheLayoutSizeL( layoutSize, aTemplate, aLandscapeOrientation ); |
|
657 |
|
658 AdjustItemWidth( itemSize, layoutSize, aLandscapeOrientation ); |
|
659 iTemplateSizesMap.InsertL(lookup_string, itemSize); |
|
660 |
|
661 // set children |
|
662 RArray< TTemplateChild > childrenDefinition; |
|
663 CleanupClosePushL( childrenDefinition ); |
|
664 |
|
665 RXmlEngNodeList<TXmlEngElement> childrenElements; |
|
666 CleanupClosePushL( childrenElements ); |
|
667 layoutElement.GetChildElements( childrenElements ); |
|
668 TXmlEngElement childElement; |
|
669 while ( childrenElements.HasNext() ) |
|
670 { |
|
671 childElement = childrenElements.Next(); |
|
672 TPtrC8 name = childElement.Name(); |
|
673 if ( !name.Compare( KTextVisual8 ) || |
|
674 !name.Compare( KImageVisual8 ) ) |
|
675 { |
|
676 TTemplateChild childTemplate; |
|
677 SetupCustomTemplateL( childTemplate, childElement ); |
|
678 childrenDefinition.AppendL( childTemplate ); |
|
679 } |
|
680 } |
|
681 CleanupStack::PopAndDestroy( &childrenElements ); |
|
682 // save children defintion in map |
|
683 lookup_string = LookupText(aTemplate, iWidgetType, |
|
684 aLandscapeOrientation, aHighlighted ); |
|
685 iTemplateChildrenMap.InsertL(lookup_string, childrenDefinition); |
|
686 CleanupStack::Pop( &childrenDefinition ); |
|
687 // we found first layout, it is enough |
|
688 break; |
|
689 } |
|
690 } |
|
691 CleanupStack::PopAndDestroy( &layoutElements ); |
|
692 } |
|
693 |
|
694 // ----------------------------------------------------------------------------- |
|
695 // |
|
696 // ----------------------------------------------------------------------------- |
|
697 // |
|
698 HBufC8* CMmTemplateLibrary::GetTemplateContentL(const TDesC8& aTemplate, |
|
699 TMmWidgetType aWidgetType, TMmTemplateType& aMmTemplateType) |
|
700 { |
|
701 HBufC8* content; |
|
702 TRAPD( err , GetTemplateFileContentL( content, aTemplate, aWidgetType, aMmTemplateType ) ); |
|
703 if ( KErrNone != err || !content ) |
|
704 { |
|
705 // if LCT template was not loaded try to load a custom template |
|
706 TRAPD( err , GetTemplateFileContentL( content, aTemplate, aWidgetType, aMmTemplateType, ETrue ) ); |
|
707 if ( KErrNoMemory == err ) |
|
708 { |
|
709 User::Leave( KErrNoMemory ); |
|
710 } |
|
711 if ( KErrNone != err || !content ) |
|
712 { |
|
713 User::Panic(KMtlPanic, -1); |
|
714 } |
|
715 } |
|
716 return content; |
|
717 } |
|
718 |
|
719 // ----------------------------------------------------------------------------- |
|
720 // |
|
721 // ----------------------------------------------------------------------------- |
|
722 // |
|
723 void CMmTemplateLibrary::GetTemplateFileContentL( HBufC8*& aContent, |
|
724 const TDesC8& aTemplate, TMmWidgetType aWidgetType, |
|
725 TMmTemplateType& aMmTemplateType, TBool aLoadCustomTemplate ) |
|
726 { |
|
727 DEBUG(("_Mm_:CMmTemplateLibrary::GetTemplateContentL IN")); |
|
728 TFileName filename; |
|
729 // create filename egz: akn_logical_template_3.xml |
|
730 filename.Copy(aTemplate); |
|
731 filename.Insert(0, KUnderline ); |
|
732 filename.Insert(0, KAkn ); |
|
733 filename.Append( KXmlExt ); |
|
734 |
|
735 // append path egz: z:\\resource\\grid\\lct\\akn_logical_template_3.xml |
|
736 |
|
737 if ( !aLoadCustomTemplate ) |
|
738 { |
|
739 filename.Insert(0, KBslash ); |
|
740 filename.Insert(0, KLct ); |
|
741 } |
|
742 else |
|
743 { |
|
744 filename.Insert(0, KBslash ); |
|
745 filename.Insert(0, KCustom ); |
|
746 } |
|
747 |
|
748 switch (aWidgetType) |
|
749 { |
|
750 case EGrid: |
|
751 filename.Insert(0, KBslash ); |
|
752 filename.Insert(0, KWidgetTypeGrid); |
|
753 break; |
|
754 case EListbox: |
|
755 filename.Insert(0, KBslash ); |
|
756 filename.Insert(0, KWidgetTypeList ); |
|
757 break; |
|
758 } |
|
759 |
|
760 filename.Insert(0, KZResource ); |
|
761 |
|
762 DEBUG(("\t_Mm_:tail: %S", &filename)); |
|
763 DEBUG(("_Mm_:CMmTemplateLibrary::GetTemplateContentL OUT")); |
|
764 |
|
765 // load LCT Template or if it does not exist then load custom template |
|
766 aContent = HnUtils::ReadFileLC(filename); |
|
767 CleanupStack::Pop( aContent ); |
|
768 |
|
769 if ( aLoadCustomTemplate ) |
|
770 { |
|
771 aMmTemplateType = ETemplateTypeCustom; |
|
772 } |
|
773 else |
|
774 { |
|
775 aMmTemplateType = ETemplateTypeLCT; |
|
776 } |
|
777 return; |
|
778 } |
|
779 |
|
780 // ----------------------------------------------------------------------------- |
|
781 // |
|
782 // ----------------------------------------------------------------------------- |
|
783 // |
|
784 TSize CMmTemplateLibrary::GetLCTSize( const TDesC8& aLCTTemplate, TInt aVariety, |
|
785 TAknWindowLineLayout& aWindowLayout, TBool aLandscapeOrientation ) |
|
786 { |
|
787 TSize size = MmLCTUtils::GetLCTSize( aLCTTemplate, aVariety, |
|
788 GetParentRect( aLandscapeOrientation ), aWindowLayout ); |
|
789 return size; |
|
790 } |
|
791 |
|
792 // ----------------------------------------------------------------------------- |
|
793 // |
|
794 // ----------------------------------------------------------------------------- |
|
795 // |
|
796 void CMmTemplateLibrary::SetupLCTTemplateL(TTemplateChild& aChildTemplate, |
|
797 TXmlEngElement& aChildElement, TSize aItemSize ) |
|
798 { |
|
799 TPtrC8 name = aChildElement.Name(); |
|
800 aChildTemplate.iData = aChildElement.AttributeValueL(KId8); |
|
801 SetupTemplateVisualId( aChildTemplate ); |
|
802 |
|
803 // read attribute name (mm_title, mm_icon) |
|
804 RXmlEngNodeList<TXmlEngElement> attributeElements; |
|
805 CleanupClosePushL( attributeElements ); |
|
806 aChildElement.GetChildElements( attributeElements ); |
|
807 TXmlEngElement attElement; |
|
808 while ( attributeElements.HasNext() ) |
|
809 { |
|
810 attElement = attributeElements.Next(); |
|
811 TPtrC8 nameAtt = attElement.AttributeValueL(KName8); |
|
812 if ( !name.Compare( KTextVisual8 ) && |
|
813 !nameAtt.Compare( KText8 ) ) |
|
814 { |
|
815 MmLCTUtils::SetupTextSubCellTemplate( aItemSize, aChildTemplate ); |
|
816 } |
|
817 else if ( !name.Compare( KImageVisual8 ) && |
|
818 !nameAtt.Compare( KImagePath8 ) ) |
|
819 { |
|
820 MmLCTUtils::SetupGraphicSubCellTemplate(aItemSize, aChildTemplate); |
|
821 AdjustIconPosition(aItemSize, aChildTemplate); |
|
822 } |
|
823 } |
|
824 CleanupStack::PopAndDestroy( &attributeElements ); |
|
825 } |
|
826 |
|
827 // ----------------------------------------------------------------------------- |
|
828 // |
|
829 // ----------------------------------------------------------------------------- |
|
830 // |
|
831 void CMmTemplateLibrary::SetupCustomTemplateL(TTemplateChild& aChildTemplate, |
|
832 TXmlEngElement& aChildElement) |
|
833 { |
|
834 TPtrC8 name = aChildElement.Name(); |
|
835 TInt positionx; TInt positiony; |
|
836 TInt height; TInt width; |
|
837 |
|
838 HnConvUtils::Str8ToInt(aChildElement.AttributeValueL(KPositionX8), positionx); |
|
839 HnConvUtils::Str8ToInt(aChildElement.AttributeValueL(KPositionY8), positiony); |
|
840 HnConvUtils::Str8ToInt(aChildElement.AttributeValueL(KHeight8), height); |
|
841 HnConvUtils::Str8ToInt(aChildElement.AttributeValueL(KWidth8), width); |
|
842 aChildTemplate.iRectAccordingToParent = TRect( TPoint(positionx,positiony), TSize(width, height) ); |
|
843 |
|
844 aChildTemplate.iData = aChildElement.AttributeValueL(KId8); |
|
845 SetupTemplateVisualId( aChildTemplate ); |
|
846 |
|
847 // read attribute name (mm_title, mm_icon) |
|
848 RXmlEngNodeList<TXmlEngElement> attributeElements; |
|
849 CleanupClosePushL( attributeElements ); |
|
850 aChildElement.GetChildElements( attributeElements ); |
|
851 TXmlEngElement attElement; |
|
852 while ( attributeElements.HasNext() ) |
|
853 { |
|
854 attElement = attributeElements.Next(); |
|
855 TPtrC8 nameAtt = attElement.AttributeValueL(KName8); |
|
856 if ( !name.Compare( KTextVisual8 ) && |
|
857 !nameAtt.Compare( KText8 ) ) |
|
858 { |
|
859 aChildTemplate.iIsImage = EFalse; |
|
860 } |
|
861 else if ( !name.Compare( KImageVisual8 ) && |
|
862 !nameAtt.Compare( KImagePath8 ) ) |
|
863 { |
|
864 aChildTemplate.iIsImage = ETrue; |
|
865 aChildTemplate.iFontId = EAknLogicalFontSecondaryFont; |
|
866 aChildTemplate.iTextAlign = CGraphicsContext::ELeft ; |
|
867 } |
|
868 else if ( !name.Compare( KTextVisual8 ) && |
|
869 !nameAtt.Compare( KStyle8 ) ) |
|
870 { |
|
871 TPtrC8 font = attElement.AttributeValueL(KTargetValue8); |
|
872 if ( !font.Compare( KQfnPrimarySmall8 ) ) |
|
873 { |
|
874 aChildTemplate.iFontId = EAknLogicalFontPrimarySmallFont; |
|
875 } |
|
876 else |
|
877 { |
|
878 aChildTemplate.iFontId = EAknLogicalFontSecondaryFont; |
|
879 } |
|
880 } |
|
881 else if ( !name.Compare( KTextVisual8 ) && |
|
882 !nameAtt.Compare( KHorizontalAlign8 ) ) |
|
883 { |
|
884 TInt textAlign; |
|
885 HnConvUtils::Str8ToInt(attElement.AttributeValueL(KTargetValue8), textAlign); |
|
886 aChildTemplate.iTextAlign = static_cast<CGraphicsContext::TTextAlign>(textAlign); |
|
887 } |
|
888 } |
|
889 |
|
890 CleanupStack::PopAndDestroy( &attributeElements ); |
|
891 } |
|
892 |
|
893 // ----------------------------------------------------------------------------- |
|
894 // |
|
895 // ----------------------------------------------------------------------------- |
|
896 // |
|
897 void CMmTemplateLibrary::SetupTemplateVisualId(TTemplateChild& aChildTemplate ) |
|
898 { |
|
899 if( !aChildTemplate.iData.Compare( KMmBackdropIcon8 )) |
|
900 { |
|
901 aChildTemplate.iImageVisualId = EImageVisualIdEditMode; |
|
902 } |
|
903 else |
|
904 { |
|
905 aChildTemplate.iImageVisualId = EImageVisualIdNormalMode; |
|
906 } |
|
907 } |
|
908 |
|
909 // ----------------------------------------------------------------------------- |
|
910 // |
|
911 // ----------------------------------------------------------------------------- |
|
912 // |
|
913 void CMmTemplateLibrary::AppendEditModeTemplateL( |
|
914 RArray<TTemplateChild>& aTemplateArray, TSize aSize) |
|
915 { |
|
916 //setup backdrop icon |
|
917 TTemplateChild childTemplate; |
|
918 childTemplate.iIsImage = ETrue; |
|
919 childTemplate.iFontId = EAknLogicalFontSecondaryFont; |
|
920 childTemplate.iTextAlign = CGraphicsContext::ELeft; |
|
921 childTemplate.iRectAccordingToParent = TRect( TPoint( 0,0 ), |
|
922 TPoint( aSize.iWidth, aSize.iHeight ) ); |
|
923 childTemplate.iData = TBufC8< MmTemplateContants::KTemplateChildTextLength >( KMmBackdropIcon8 ); |
|
924 SetupTemplateVisualId( childTemplate ); |
|
925 aTemplateArray.AppendL( childTemplate ); |
|
926 } |
|
927 |
|
928 |
|
929 // ----------------------------------------------------------------------------- |
|
930 // |
|
931 // ----------------------------------------------------------------------------- |
|
932 // |
|
933 void CMmTemplateLibrary::SetupMoveIndicatorTemplateChildrenL( |
|
934 const TDesC8& aLookupString, TSize aItemSize ) |
|
935 { |
|
936 RArray< TTemplateChild > childrenDefinition; |
|
937 TTemplateChild childTemplate; |
|
938 childTemplate.iIsImage = ETrue; |
|
939 childTemplate.iImageVisualId = EImageVisualIdNormalMode; |
|
940 childTemplate.iFontId = EAknLogicalFontSecondaryFont; |
|
941 childTemplate.iTextAlign = CGraphicsContext::ELeft; |
|
942 TPoint startingPosition = TPoint( |
|
943 MmTemplateContants::KMoveIndicatorStartingPos, |
|
944 MmTemplateContants::KMoveIndicatorStartingPos); |
|
945 |
|
946 //setup move_indicator_arrow_left |
|
947 childTemplate.iRectAccordingToParent = TRect(TPoint(0,aItemSize.iHeight/2 + startingPosition.iY/2), |
|
948 TPoint(startingPosition.iX, |
|
949 startingPosition.iY*3/2 + aItemSize.iHeight/2)); |
|
950 childTemplate.iData = TBufC8< MmTemplateContants::KTemplateChildTextLength>( |
|
951 KMmMoveIndicatorArrowLeft8 ); |
|
952 childrenDefinition.AppendL( childTemplate ); |
|
953 |
|
954 //setup move_indicator_arrow_right |
|
955 childTemplate.iRectAccordingToParent = TRect( |
|
956 TPoint(startingPosition.iX + aItemSize.iWidth , aItemSize.iHeight/2 + startingPosition.iY/2), |
|
957 TPoint(startingPosition.iX*2 + aItemSize.iWidth, |
|
958 startingPosition.iY*3/2 + aItemSize.iHeight/2)); |
|
959 childTemplate.iData = TBufC8< MmTemplateContants::KTemplateChildTextLength>( |
|
960 KMmMoveIndicatorArrowRight8 ); |
|
961 childrenDefinition.AppendL( childTemplate ); |
|
962 |
|
963 //setup move_indicator_arrow_top |
|
964 childTemplate.iRectAccordingToParent = TRect(TPoint( aItemSize.iWidth/2 + startingPosition.iX/2, 0 ), |
|
965 TPoint(aItemSize.iWidth/2 + startingPosition.iX*3/2, startingPosition.iY)); |
|
966 childTemplate.iData = TBufC8< MmTemplateContants::KTemplateChildTextLength >( |
|
967 KMmMoveIndicatorArrowTop8 ); |
|
968 childrenDefinition.AppendL( childTemplate ); |
|
969 |
|
970 //setup move_indicator_arrow_bottom |
|
971 childTemplate.iRectAccordingToParent = TRect( TPoint( aItemSize.iWidth/2 + startingPosition.iX/2, |
|
972 aItemSize.iHeight + startingPosition.iY + 2 ), |
|
973 TPoint(aItemSize.iWidth/2 + startingPosition.iX*3/2, |
|
974 aItemSize.iHeight + 2 *startingPosition.iY)); |
|
975 childTemplate.iData = TBufC8< MmTemplateContants::KTemplateChildTextLength>( |
|
976 KMmMoveIndicatorArrowBottom8 ); |
|
977 childrenDefinition.AppendL( childTemplate ); |
|
978 |
|
979 HBufC8* lookup_string = aLookupString.AllocLC(); |
|
980 iTemplateChildrenMap.InsertL(lookup_string, childrenDefinition); |
|
981 CleanupStack::Pop( lookup_string ); |
|
982 lookup_string = NULL; |
|
983 |
|
984 lookup_string = aLookupString.AllocLC(); |
|
985 TRect rectAccordingToParent = TRect( |
|
986 TPoint( -startingPosition.iX, -startingPosition.iY), |
|
987 TPoint(2*startingPosition.iX + aItemSize.iWidth , |
|
988 2*startingPosition.iY + aItemSize.iHeight) ); |
|
989 |
|
990 iMoveIndicatorRectsMap.InsertL( lookup_string, rectAccordingToParent ); |
|
991 CleanupStack::Pop( lookup_string ); |
|
992 } |
|
993 |
|
994 // ----------------------------------------------------------------------------- |
|
995 // |
|
996 // ----------------------------------------------------------------------------- |
|
997 // |
|
998 void CMmTemplateLibrary::SetScrollbarVisibilityL( TBool aIsScrollbarVisible ) |
|
999 { |
|
1000 if ( iIsScrollbarVisible != aIsScrollbarVisible ) |
|
1001 { |
|
1002 iIsScrollbarVisible = aIsScrollbarVisible; |
|
1003 CleanAndClearCache(); |
|
1004 } |
|
1005 } |
|
1006 |
|
1007 // ----------------------------------------------------------------------------- |
|
1008 // |
|
1009 // ----------------------------------------------------------------------------- |
|
1010 // |
|
1011 TBool CMmTemplateLibrary::GetScrollbarVisibility() |
|
1012 { |
|
1013 return iIsScrollbarVisible; |
|
1014 } |
|
1015 |
|
1016 // ----------------------------------------------------------------------------- |
|
1017 // |
|
1018 // ----------------------------------------------------------------------------- |
|
1019 // |
|
1020 void CMmTemplateLibrary::SetScrollbarWidthL( TInt aScrollbarWidth ) |
|
1021 { |
|
1022 if ( iIsScrollbarVisible ) |
|
1023 { |
|
1024 if ( iScrollbarWidth != aScrollbarWidth ) |
|
1025 { |
|
1026 iScrollbarWidth = aScrollbarWidth; |
|
1027 CleanAndClearCache(); |
|
1028 } |
|
1029 } |
|
1030 else |
|
1031 { |
|
1032 if ( iScrollbarWidth != 0 ) |
|
1033 { |
|
1034 iScrollbarWidth = 0; |
|
1035 CleanAndClearCache(); |
|
1036 } |
|
1037 } |
|
1038 } |
|
1039 |
|
1040 // ----------------------------------------------------------------------------- |
|
1041 // |
|
1042 // ----------------------------------------------------------------------------- |
|
1043 // |
|
1044 TInt CMmTemplateLibrary::ScrollbarWidth() |
|
1045 { |
|
1046 return iScrollbarWidth; |
|
1047 } |
|
1048 |
|
1049 // ----------------------------------------------------------------------------- |
|
1050 // |
|
1051 // ----------------------------------------------------------------------------- |
|
1052 // |
|
1053 void CMmTemplateLibrary::AdjustItemWidth(TSize& aItemSize, TSize aLayoutSize, |
|
1054 TBool aLandscapeOrientation) |
|
1055 { |
|
1056 if ( iIsScrollbarVisible ) |
|
1057 { |
|
1058 aItemSize.iWidth = ( GetParentRect(aLandscapeOrientation).Width() - iScrollbarWidth ) / aLayoutSize.iWidth; |
|
1059 } |
|
1060 else |
|
1061 { |
|
1062 aItemSize.iWidth = GetParentRect(aLandscapeOrientation).Width() / aLayoutSize.iWidth; |
|
1063 } |
|
1064 } |
|
1065 |
|
1066 // ----------------------------------------------------------------------------- |
|
1067 // |
|
1068 // ----------------------------------------------------------------------------- |
|
1069 // |
|
1070 void CMmTemplateLibrary::UpdateParentRect( TRect aParentRect, TBool aLandscapeOrientation ) |
|
1071 { |
|
1072 if( GetParentRect( aLandscapeOrientation ) != aParentRect ) |
|
1073 { |
|
1074 SetParentRect( aLandscapeOrientation, aParentRect ); |
|
1075 } |
|
1076 } |
|
1077 |
|
1078 |
|
1079 // ----------------------------------------------------------------------------- |
|
1080 // |
|
1081 // ----------------------------------------------------------------------------- |
|
1082 // |
|
1083 TRect CMmTemplateLibrary::GetParentRect( TBool aLandscapeOrientation ) |
|
1084 { |
|
1085 if ( aLandscapeOrientation ) |
|
1086 return iParentRectLandscape; |
|
1087 else |
|
1088 return iParentRectPortrait; |
|
1089 } |
|
1090 |
|
1091 // ----------------------------------------------------------------------------- |
|
1092 // |
|
1093 // ----------------------------------------------------------------------------- |
|
1094 // |
|
1095 void CMmTemplateLibrary::SetParentRect( TBool aLandscapeOrientation, TRect aParentRect) |
|
1096 { |
|
1097 if ( aLandscapeOrientation ) |
|
1098 iParentRectLandscape = aParentRect; |
|
1099 else |
|
1100 iParentRectPortrait = aParentRect; |
|
1101 } |
|
1102 |
|
1103 // ----------------------------------------------------------------------------- |
|
1104 // |
|
1105 // ----------------------------------------------------------------------------- |
|
1106 // |
|
1107 void CMmTemplateLibrary::AdjustItemSize(TSize& aItemSize, TSize aLayoutSize, |
|
1108 TBool aLandscapeOrientation) |
|
1109 { |
|
1110 switch ( iWidgetType ) |
|
1111 { |
|
1112 case EGrid: |
|
1113 aItemSize.iHeight = GetParentRect( aLandscapeOrientation ).Height() / aLayoutSize.iHeight; |
|
1114 break; |
|
1115 case EListbox: |
|
1116 break; |
|
1117 } |
|
1118 AdjustItemWidth( aItemSize, aLayoutSize, aLandscapeOrientation ); |
|
1119 } |
|
1120 |
|
1121 // ----------------------------------------------------------------------------- |
|
1122 // |
|
1123 // ----------------------------------------------------------------------------- |
|
1124 // |
|
1125 void CMmTemplateLibrary::CacheLayoutSizeL(TSize aLayoutSize, |
|
1126 const TDesC8& aTemplate, TBool aLandscapeOrientation) |
|
1127 { |
|
1128 HBufC8* lookup_layout_text = LookupLayoutText( iWidgetType, |
|
1129 aTemplate, aLandscapeOrientation ); |
|
1130 |
|
1131 if ( iTemplateSizesMap.Find( lookup_layout_text ) ) |
|
1132 { |
|
1133 delete lookup_layout_text; |
|
1134 } |
|
1135 else |
|
1136 { |
|
1137 iTemplateSizesMap.InsertL( lookup_layout_text, aLayoutSize ); |
|
1138 } |
|
1139 } |
|
1140 |
|
1141 // ----------------------------------------------------------------------------- |
|
1142 // |
|
1143 // ----------------------------------------------------------------------------- |
|
1144 // |
|
1145 void CMmTemplateLibrary::AdjustIconPosition(TSize aParentSize, |
|
1146 TTemplateChild& aTemplateChild) |
|
1147 { |
|
1148 switch (aTemplateChild.iHAlign) |
|
1149 { |
|
1150 case EManualAlignLeft: |
|
1151 break; |
|
1152 case EManualAlignCenter: |
|
1153 { |
|
1154 TInt rectWidth = |
|
1155 aTemplateChild.iRectAccordingToParent.Size().iWidth; |
|
1156 TInt lX = (aParentSize.iWidth - rectWidth) / 2; |
|
1157 aTemplateChild.iRectAccordingToParent.Move(lX |
|
1158 - aTemplateChild.iRectAccordingToParent.iTl.iX, 0); |
|
1159 break; |
|
1160 } |
|
1161 case EManualAlignRight: |
|
1162 break; |
|
1163 default: |
|
1164 break; |
|
1165 } |
|
1166 } |
|
1167 |
|
1168 // End of file |
|