50 // --------------------------------------------------------------------------- |
50 // --------------------------------------------------------------------------- |
51 // |
51 // |
52 // --------------------------------------------------------------------------- |
52 // --------------------------------------------------------------------------- |
53 //: |
53 //: |
54 CMmTemplateLibrary::CMmTemplateLibrary() |
54 CMmTemplateLibrary::CMmTemplateLibrary() |
55 : iWidgetType(EWidgetTypeNone), |
55 : iWidgetType(EWidgetTypeNone), |
56 iTemplateSizesMap( &HBuf16Hash, &HBuf16Ident ), |
56 iTemplateSizesMap( &HBuf16Hash, &HBuf16Ident ), |
57 iTemplateChildrenMap( &HBuf16Hash, &HBuf16Ident ), |
57 iTemplateChildrenMap( &HBuf16Hash, &HBuf16Ident ), |
58 iMoveIndicatorRectsMap( &HBuf16Hash, &HBuf16Ident ) |
58 iMoveIndicatorRectsMap( &HBuf16Hash, &HBuf16Ident ) |
59 { |
59 { |
60 // No implementation required |
60 // No implementation required |
61 } |
61 } |
62 // --------------------------------------------------------------------------- |
62 // --------------------------------------------------------------------------- |
63 // |
63 // |
64 // --------------------------------------------------------------------------- |
64 // --------------------------------------------------------------------------- |
65 // |
65 // |
66 CMmTemplateLibrary::~CMmTemplateLibrary() |
66 CMmTemplateLibrary::~CMmTemplateLibrary() |
67 { |
67 { |
68 CleanAndClearCache(); |
68 CleanAndClearCache(); |
69 } |
69 } |
70 // --------------------------------------------------------------------------- |
70 // --------------------------------------------------------------------------- |
71 // |
71 // |
72 // --------------------------------------------------------------------------- |
72 // --------------------------------------------------------------------------- |
73 // |
73 // |
74 void CMmTemplateLibrary::CleanAndClearCache( ) |
74 void CMmTemplateLibrary::CleanAndClearCache( ) |
75 { |
75 { |
76 |
76 |
77 THashMapIter<HBufC8*, TSize> iter( iTemplateSizesMap ); |
77 THashMapIter<HBufC8*, TSize> iter( iTemplateSizesMap ); |
78 while ( HBufC8* const * ptr = iter.NextKey() ) |
78 while ( HBufC8* const * ptr = iter.NextKey() ) |
79 { |
79 { |
80 delete *ptr; |
80 delete *ptr; |
81 } |
81 } |
82 iTemplateSizesMap.Close(); |
82 iTemplateSizesMap.Close(); |
83 |
83 |
84 THashMapIter<HBufC8*, RArray<TTemplateChild> > iter2( iTemplateChildrenMap ); |
84 THashMapIter<HBufC8*, RArray<TTemplateChild> > iter2( iTemplateChildrenMap ); |
85 while ( HBufC8* const * ptr = iter2.NextKey() ) |
85 while ( HBufC8* const * ptr = iter2.NextKey() ) |
86 { |
86 { |
87 iter2.CurrentValue()->Close(); |
87 iter2.CurrentValue()->Close(); |
88 delete *ptr; |
88 delete *ptr; |
89 } |
89 } |
90 iTemplateChildrenMap.Close(); |
90 iTemplateChildrenMap.Close(); |
91 |
91 |
92 THashMapIter<HBufC8*, TRect> iter4( iMoveIndicatorRectsMap ); |
92 THashMapIter<HBufC8*, TRect> iter4( iMoveIndicatorRectsMap ); |
93 while ( HBufC8* const * ptr = iter4.NextKey() ) |
93 while ( HBufC8* const * ptr = iter4.NextKey() ) |
94 { |
94 { |
95 delete *ptr; |
95 delete *ptr; |
96 } |
96 } |
97 iMoveIndicatorRectsMap.Close(); |
97 iMoveIndicatorRectsMap.Close(); |
98 |
98 |
99 } |
99 } |
100 |
100 |
101 // --------------------------------------------------------------------------- |
101 // --------------------------------------------------------------------------- |
102 // |
102 // |
103 // --------------------------------------------------------------------------- |
103 // --------------------------------------------------------------------------- |
104 // |
104 // |
105 EXPORT_C CMmTemplateLibrary* CMmTemplateLibrary::NewL() |
105 EXPORT_C CMmTemplateLibrary* CMmTemplateLibrary::NewL() |
106 { |
106 { |
107 CMmTemplateLibrary* self = CMmTemplateLibrary::NewLC(); |
107 CMmTemplateLibrary* self = CMmTemplateLibrary::NewLC(); |
108 CleanupStack::Pop( self ); |
108 CleanupStack::Pop( self ); |
109 return self; |
109 return self; |
110 } |
110 } |
111 |
111 |
112 // --------------------------------------------------------------------------- |
112 // --------------------------------------------------------------------------- |
113 // |
113 // |
114 // --------------------------------------------------------------------------- |
114 // --------------------------------------------------------------------------- |
115 // |
115 // |
187 { |
187 { |
188 AdjustItemSize( *itemSize, layoutSize, aLandscapeOrientation ); |
188 AdjustItemSize( *itemSize, layoutSize, aLandscapeOrientation ); |
189 } |
189 } |
190 aItemSize = *itemSize; |
190 aItemSize = *itemSize; |
191 } |
191 } |
192 delete lookup_string; |
192 delete lookup_string; |
193 |
193 |
194 return err; |
194 return err; |
195 } |
195 } |
196 |
196 |
197 // --------------------------------------------------------------------------- |
197 // --------------------------------------------------------------------------- |
198 // |
198 // |
199 // --------------------------------------------------------------------------- |
199 // --------------------------------------------------------------------------- |
200 // |
200 // |
201 TSize CMmTemplateLibrary::GetLayoutSizeL( TMmWidgetType aWidgetType, const TDesC8& aTemplate, |
201 TSize CMmTemplateLibrary::GetLayoutSizeL( TMmWidgetType aWidgetType, const TDesC8& aTemplate, |
202 TBool aLandscapeOrientation ) |
202 TBool aLandscapeOrientation ) |
203 { |
203 { |
204 if ( KNullDesC8()== aTemplate ) |
204 if ( KNullDesC8()== aTemplate ) |
205 { |
205 { |
206 User::Leave( -1 ); |
206 User::Leave( -1 ); |
207 } |
207 } |
208 TSize* layoutSize = NULL; |
208 TSize* layoutSize = NULL; |
209 switch ( aWidgetType ) |
209 switch ( aWidgetType ) |
210 { |
210 { |
211 case EGrid: |
211 case EGrid: |
212 { |
212 { |
213 HBufC8* lookup_string = LookupLayoutText( aWidgetType, |
213 HBufC8* lookup_string = LookupLayoutText( aWidgetType, |
214 aTemplate, aLandscapeOrientation ); |
214 aTemplate, aLandscapeOrientation ); |
215 CleanupStack::PushL( lookup_string ); |
215 CleanupStack::PushL( lookup_string ); |
216 layoutSize = iTemplateSizesMap.Find( lookup_string ); |
216 layoutSize = iTemplateSizesMap.Find( lookup_string ); |
217 if (!layoutSize) |
217 if (!layoutSize) |
218 { |
218 { |
219 LoadTemplateL( aWidgetType, aTemplate, aLandscapeOrientation ); |
219 LoadTemplateL( aWidgetType, aTemplate, aLandscapeOrientation ); |
220 layoutSize = iTemplateSizesMap.Find( lookup_string ); |
220 layoutSize = iTemplateSizesMap.Find( lookup_string ); |
221 if( !layoutSize ) |
221 if( !layoutSize ) |
222 User::Panic( KMtlPanic, -1); |
222 User::Panic( KMtlPanic, -1); |
223 } |
223 } |
224 CleanupStack::PopAndDestroy( lookup_string ); |
224 CleanupStack::PopAndDestroy( lookup_string ); |
225 } |
225 } |
226 |
226 |
227 break; |
227 break; |
228 case EListbox: |
228 case EListbox: |
229 return TSize( MmListBox::KCols,0 ); |
229 return TSize( MmListBox::KCols,0 ); |
230 default: |
230 default: |
231 User::Panic( KMtlPanic, -1); |
231 User::Panic( KMtlPanic, -1); |
232 } |
232 } |
233 return *layoutSize; |
233 return *layoutSize; |
234 } |
234 } |
235 |
235 |
236 // --------------------------------------------------------------------------- |
236 // --------------------------------------------------------------------------- |
237 // |
237 // |
238 // --------------------------------------------------------------------------- |
238 // --------------------------------------------------------------------------- |
239 // |
239 // |
240 TRect CMmTemplateLibrary::GetMoveIndicatorRect(TMmWidgetType aWidgetType, |
240 TRect CMmTemplateLibrary::GetMoveIndicatorRect(TMmWidgetType aWidgetType, |
241 const TDesC8& aTemplate, TBool aLandscapeOrientation, |
241 const TDesC8& aTemplate, TBool aLandscapeOrientation, |
242 TBool aHighlighted) |
242 TBool aHighlighted) |
243 { |
243 { |
244 ASSERT( KNullDesC8() != aTemplate && aTemplate.Compare( KEmpty8 ) ); |
244 ASSERT( KNullDesC8() != aTemplate && aTemplate.Compare( KEmpty8 ) ); |
245 |
245 |
246 HBufC8* lookup_string = LookupText(aTemplate, aWidgetType, |
246 HBufC8* lookup_string = LookupText(aTemplate, aWidgetType, |
247 aLandscapeOrientation, aHighlighted ); |
247 aLandscapeOrientation, aHighlighted ); |
248 HBufC8* lookup_indicator_string = LookupIndicatorText( *lookup_string ); |
248 HBufC8* lookup_indicator_string = LookupIndicatorText( *lookup_string ); |
249 |
249 |
250 TRect* itemRect = iMoveIndicatorRectsMap.Find( lookup_indicator_string ); |
250 TRect* itemRect = iMoveIndicatorRectsMap.Find( lookup_indicator_string ); |
251 if (!itemRect) |
251 if (!itemRect) |
252 { |
252 { |
253 TSize itemSize; |
253 TSize itemSize; |
254 GetSize( itemSize, aWidgetType, aTemplate, aLandscapeOrientation, EFalse, GetParentRect( aLandscapeOrientation ) ); |
254 GetSize( itemSize, aWidgetType, aTemplate, aLandscapeOrientation, EFalse, GetParentRect( aLandscapeOrientation ) ); |
255 TRAPD( err, SetupMoveIndicatorTemplateChildrenL( |
255 TRAPD( err, SetupMoveIndicatorTemplateChildrenL( |
256 *lookup_indicator_string, itemSize ) ); |
256 *lookup_indicator_string, itemSize ) ); |
257 if ( KErrNone == err ) |
257 if ( KErrNone == err ) |
258 { |
258 { |
259 itemRect = iMoveIndicatorRectsMap.Find( lookup_indicator_string ); |
259 itemRect = iMoveIndicatorRectsMap.Find( lookup_indicator_string ); |
260 if (!itemRect) |
260 if (!itemRect) |
261 { |
261 { |
262 User::Panic( KMtlPanic, -1); |
262 User::Panic( KMtlPanic, -1); |
263 } |
263 } |
264 } |
264 } |
265 } |
265 } |
266 |
266 |
267 delete lookup_indicator_string; |
267 delete lookup_indicator_string; |
268 delete lookup_string; |
268 delete lookup_string; |
269 return *itemRect; |
269 return *itemRect; |
270 } |
270 } |
271 |
271 |
272 // --------------------------------------------------------------------------- |
272 // --------------------------------------------------------------------------- |
273 // |
273 // |
274 // --------------------------------------------------------------------------- |
274 // --------------------------------------------------------------------------- |
275 // |
275 // |
276 void CMmTemplateLibrary::GetChildrenL(TMmWidgetType aWidgetType, RArray< |
276 void CMmTemplateLibrary::GetChildrenL(TMmWidgetType aWidgetType, RArray< |
277 TTemplateChild>& aArray, const TDesC8& aTemplate, |
277 TTemplateChild>& aArray, const TDesC8& aTemplate, |
278 TBool aLandscapeOrientation, TBool aHighlighted, TBool aIsEditMode) |
278 TBool aLandscapeOrientation, TBool aHighlighted, TBool aIsEditMode) |
279 { |
279 { |
280 ASSERT( KNullDesC8() != aTemplate && aTemplate.Compare( KEmpty8 ) ); |
280 ASSERT( KNullDesC8() != aTemplate && aTemplate.Compare( KEmpty8 ) ); |
281 |
281 |
282 HBufC8* lookup_string = LookupText( aTemplate, aWidgetType, |
282 HBufC8* lookup_string = LookupText( aTemplate, aWidgetType, |
283 aLandscapeOrientation, aHighlighted ); |
283 aLandscapeOrientation, aHighlighted ); |
284 CleanupStack::PushL( lookup_string ); |
284 CleanupStack::PushL( lookup_string ); |
285 RArray<TTemplateChild>* children = iTemplateChildrenMap.Find( lookup_string ); |
285 RArray<TTemplateChild>* children = iTemplateChildrenMap.Find( lookup_string ); |
286 if ( !children ) |
286 if ( !children ) |
287 { |
287 { |
288 LoadTemplateL( aWidgetType, aTemplate, aLandscapeOrientation ); |
288 LoadTemplateL( aWidgetType, aTemplate, aLandscapeOrientation ); |
289 children = iTemplateChildrenMap.Find( lookup_string ); |
289 children = iTemplateChildrenMap.Find( lookup_string ); |
290 if (!children) |
290 if (!children) |
291 { |
291 { |
292 User::Panic( KMtlPanic, -1); |
292 User::Panic( KMtlPanic, -1); |
293 } |
293 } |
294 } |
294 } |
295 CleanupStack::PopAndDestroy( lookup_string ); |
295 CleanupStack::PopAndDestroy( lookup_string ); |
296 for (TInt i = 0; i < children->Count(); i++) |
296 for (TInt i = 0; i < children->Count(); i++) |
297 aArray.AppendL((*children)[i]); |
297 aArray.AppendL((*children)[i]); |
298 if ( aIsEditMode ) |
298 if ( aIsEditMode ) |
299 { |
299 { |
300 TSize size = GetSize( aWidgetType, aTemplate, aLandscapeOrientation, aHighlighted, GetParentRect(aLandscapeOrientation) ); |
300 TSize size = GetSize( aWidgetType, aTemplate, aLandscapeOrientation, aHighlighted, GetParentRect(aLandscapeOrientation) ); |
301 AppendEditModeTemplateL( aArray, size ); |
301 AppendEditModeTemplateL( aArray, size ); |
302 } |
302 } |
303 } |
303 } |
304 |
304 |
305 // --------------------------------------------------------------------------- |
305 // --------------------------------------------------------------------------- |
306 // |
306 // |
307 // --------------------------------------------------------------------------- |
307 // --------------------------------------------------------------------------- |
308 // |
308 // |
309 void CMmTemplateLibrary::GetMoveIndicatorChildrenL(TMmWidgetType aWidgetType, |
309 void CMmTemplateLibrary::GetMoveIndicatorChildrenL(TMmWidgetType aWidgetType, |
310 RArray<TTemplateChild>& aArray, const TDesC8& aTemplate, |
310 RArray<TTemplateChild>& aArray, const TDesC8& aTemplate, |
311 TBool aLandscapeOrientation, TBool aHighlighted) |
311 TBool aLandscapeOrientation, TBool aHighlighted) |
312 { |
312 { |
313 ASSERT( KNullDesC8() != aTemplate && aTemplate.Compare( KEmpty8 ) ); |
313 ASSERT( KNullDesC8() != aTemplate && aTemplate.Compare( KEmpty8 ) ); |
314 |
314 |
315 HBufC8* lookup_string = LookupText(aTemplate, aWidgetType, |
315 HBufC8* lookup_string = LookupText(aTemplate, aWidgetType, |
316 aLandscapeOrientation, aHighlighted ); |
316 aLandscapeOrientation, aHighlighted ); |
317 CleanupStack::PushL( lookup_string ); |
317 CleanupStack::PushL( lookup_string ); |
318 HBufC8* lookup_indicator_string = LookupIndicatorText( *lookup_string ); |
318 HBufC8* lookup_indicator_string = LookupIndicatorText( *lookup_string ); |
319 CleanupStack::PushL( lookup_indicator_string ); |
319 CleanupStack::PushL( lookup_indicator_string ); |
320 |
320 |
321 RArray<TTemplateChild>* children = iTemplateChildrenMap.Find( lookup_indicator_string ); |
321 RArray<TTemplateChild>* children = iTemplateChildrenMap.Find( |
|
322 lookup_indicator_string ); |
322 if ( !children ) |
323 if ( !children ) |
323 { |
324 { |
324 TSize itemSize; |
325 TSize itemSize; |
325 GetSize( itemSize, aWidgetType, aTemplate, aLandscapeOrientation, EFalse, GetParentRect( aLandscapeOrientation ) ); |
326 GetSize( itemSize, aWidgetType, aTemplate, aLandscapeOrientation, |
|
327 EFalse, GetParentRect( aLandscapeOrientation ) ); |
326 SetupMoveIndicatorTemplateChildrenL( *lookup_indicator_string, itemSize ); |
328 SetupMoveIndicatorTemplateChildrenL( *lookup_indicator_string, itemSize ); |
327 children = iTemplateChildrenMap.Find( lookup_indicator_string ); |
329 children = iTemplateChildrenMap.Find( lookup_indicator_string ); |
328 if (!children) |
330 if (!children) |
329 User::Panic( KMtlPanic, -1); |
331 User::Panic( KMtlPanic, -1); |
330 } |
332 } |
331 |
333 |
332 CleanupStack::PopAndDestroy( lookup_indicator_string ); |
334 CleanupStack::PopAndDestroy( lookup_indicator_string ); |
333 CleanupStack::PopAndDestroy( lookup_string ); |
335 CleanupStack::PopAndDestroy( lookup_string ); |
334 |
336 |
335 for (TInt i = 0; i < children->Count(); i++) |
337 for (TInt i = 0; i < children->Count(); i++) |
336 { |
338 { |
337 aArray.AppendL((*children)[i]); |
339 aArray.AppendL((*children)[i]); |
338 } |
340 } |
339 } |
341 } |
340 |
342 |
341 // --------------------------------------------------------------------------- |
343 // --------------------------------------------------------------------------- |
342 // |
344 // |
343 // --------------------------------------------------------------------------- |
345 // --------------------------------------------------------------------------- |
344 // |
346 // |
345 HBufC8* CMmTemplateLibrary::LookupText( const TDesC8& aTemplate, |
347 HBufC8* CMmTemplateLibrary::LookupText( const TDesC8& aTemplate, |
346 TMmWidgetType aWidgetType, TBool aLandscapeOrientation, TBool aHighlighted ) |
348 TMmWidgetType aWidgetType, TBool aLandscapeOrientation, TBool aHighlighted ) |
347 { |
349 { |
348 HBufC8* lookup_string = HBufC8::New( MmTemplateContants::KTemplateChildTextLength ); |
350 HBufC8* lookup_string = HBufC8::New( MmTemplateContants::KTemplateChildTextLength ); |
349 if (lookup_string) |
351 if (lookup_string) |
350 { |
352 { |
351 TPtr8 lookup_string_ptr( lookup_string->Des() ); |
353 TPtr8 lookup_string_ptr( lookup_string->Des() ); |
352 lookup_string_ptr.Append( aTemplate ); |
354 lookup_string_ptr.Append( aTemplate ); |
353 lookup_string_ptr.Append( KColon8 ); |
355 lookup_string_ptr.Append( KColon8 ); |
354 switch ( aWidgetType ) |
356 switch ( aWidgetType ) |
355 { |
357 { |
356 case EListbox: |
358 case EListbox: |
357 lookup_string_ptr.Append( KListbox8 ); |
359 lookup_string_ptr.Append( KListbox8 ); |
358 break; |
360 break; |
359 case EGrid: |
361 case EGrid: |
360 lookup_string_ptr.Append( KGrid8 ); |
362 lookup_string_ptr.Append( KGrid8 ); |
361 break; |
363 break; |
362 } |
364 } |
363 lookup_string_ptr.Append( KColon8 ); |
365 lookup_string_ptr.Append( KColon8 ); |
364 lookup_string_ptr.AppendNum( aLandscapeOrientation ); |
366 lookup_string_ptr.AppendNum( aLandscapeOrientation ); |
365 lookup_string_ptr.Append( KColon8 ); |
367 lookup_string_ptr.Append( KColon8 ); |
366 lookup_string_ptr.AppendNum( aHighlighted ); |
368 lookup_string_ptr.AppendNum( aHighlighted ); |
367 lookup_string_ptr.Append( KColon8 ); |
369 lookup_string_ptr.Append( KColon8 ); |
368 } |
370 } |
369 return lookup_string; |
371 return lookup_string; |
370 } |
372 } |
371 |
373 |
372 // ----------------------------------------------------------------------------- |
374 // ----------------------------------------------------------------------------- |
373 // |
375 // |
374 // ----------------------------------------------------------------------------- |
376 // ----------------------------------------------------------------------------- |
375 // |
377 // |
376 HBufC8* CMmTemplateLibrary::LookupLayoutText( TMmWidgetType aWidgetType, |
378 HBufC8* CMmTemplateLibrary::LookupLayoutText( TMmWidgetType aWidgetType, |
377 const TDesC8& aTemplate, TBool aLandscapeOrientation ) |
379 const TDesC8& aTemplate, TBool aLandscapeOrientation ) |
378 { |
380 { |
379 HBufC8* lookup_string = HBufC8::New( MmTemplateContants::KTemplateChildTextLength ); |
381 HBufC8* lookup_string = HBufC8::New( MmTemplateContants::KTemplateChildTextLength ); |
380 if (lookup_string) |
382 if (lookup_string) |
381 { |
383 { |
382 TPtr8 lookup_string_ptr( lookup_string->Des() ); |
384 TPtr8 lookup_string_ptr( lookup_string->Des() ); |
383 switch ( aWidgetType ) |
385 switch ( aWidgetType ) |
384 { |
386 { |
385 case EListbox: |
387 case EListbox: |
386 lookup_string_ptr.Append( KListbox8 ); |
388 lookup_string_ptr.Append( KListbox8 ); |
387 break; |
389 break; |
388 case EGrid: |
390 case EGrid: |
389 lookup_string_ptr.Append( KGrid8 ); |
391 lookup_string_ptr.Append( KGrid8 ); |
390 break; |
392 break; |
391 } |
393 } |
392 lookup_string_ptr.Append( KColon8 ); |
394 lookup_string_ptr.Append( KColon8 ); |
393 lookup_string_ptr.Append( KColon8 ); |
395 lookup_string_ptr.Append( KColon8 ); |
394 lookup_string_ptr.Append( aTemplate ); |
396 lookup_string_ptr.Append( aTemplate ); |
395 lookup_string_ptr.Append( KColon8 ); |
397 lookup_string_ptr.Append( KColon8 ); |
396 lookup_string_ptr.AppendNum( aLandscapeOrientation ); |
398 lookup_string_ptr.AppendNum( aLandscapeOrientation ); |
397 } |
399 } |
398 return lookup_string; |
400 return lookup_string; |
399 } |
401 } |
400 |
402 |
401 // ----------------------------------------------------------------------------- |
403 // ----------------------------------------------------------------------------- |
402 // |
404 // |
403 // ----------------------------------------------------------------------------- |
405 // ----------------------------------------------------------------------------- |
404 // |
406 // |
405 HBufC8* CMmTemplateLibrary::LookupIndicatorText( const TDesC8& aLookupText ) |
407 HBufC8* CMmTemplateLibrary::LookupIndicatorText( const TDesC8& aLookupText ) |
406 { |
408 { |
407 HBufC8* lookup_string = HBufC8::New( MmTemplateContants::KTemplateChildTextLength ); |
409 HBufC8* lookup_string = HBufC8::New( MmTemplateContants::KTemplateChildTextLength ); |
408 if (lookup_string) |
410 if (lookup_string) |
409 { |
411 { |
410 TPtr8 lookup_string_ptr( lookup_string->Des() ); |
412 TPtr8 lookup_string_ptr( lookup_string->Des() ); |
411 lookup_string_ptr.Append( KMI8 ); |
413 lookup_string_ptr.Append( KMI8 ); |
412 lookup_string_ptr.Append( KColon8 ); |
414 lookup_string_ptr.Append( KColon8 ); |
413 lookup_string_ptr.Append( aLookupText ); |
415 lookup_string_ptr.Append( aLookupText ); |
414 } |
416 } |
415 |
417 |
416 return lookup_string; |
418 return lookup_string; |
417 } |
419 } |
418 |
420 |
419 // ----------------------------------------------------------------------------- |
421 // ----------------------------------------------------------------------------- |
420 // |
422 // |
421 // ----------------------------------------------------------------------------- |
423 // ----------------------------------------------------------------------------- |
422 // |
424 // |
423 void CMmTemplateLibrary::LoadTemplateL( TMmWidgetType aWidgetType, |
425 void CMmTemplateLibrary::LoadTemplateL( TMmWidgetType aWidgetType, |
424 const TDesC8& aTemplate, TBool aLandscapeOrientation ) |
426 const TDesC8& aTemplate, TBool aLandscapeOrientation ) |
425 { |
427 { |
426 iWidgetType = aWidgetType; |
428 iWidgetType = aWidgetType; |
427 DEBUG(("_Mm_:CMmTemplateLibrary::LoadTemplateL IN")); |
429 DEBUG(("_Mm_:CMmTemplateLibrary::LoadTemplateL IN")); |
428 TMmTemplateType mmTemplateType; |
430 TMmTemplateType mmTemplateType; |
429 HBufC8* content = GetTemplateContentL( aTemplate, aWidgetType, mmTemplateType ); |
431 HBufC8* content = GetTemplateContentL( aTemplate, aWidgetType, mmTemplateType ); |
430 CleanupStack::PushL( content ); |
432 CleanupStack::PushL( content ); |
431 RXmlEngDOMImplementation domImpl; |
433 RXmlEngDOMImplementation domImpl; |
432 CleanupClosePushL( domImpl ); |
434 CleanupClosePushL( domImpl ); |
433 RXmlEngDOMParser domParser; |
435 RXmlEngDOMParser domParser; |
434 CleanupClosePushL( domParser ); |
436 CleanupClosePushL( domParser ); |
435 DEBUG(("_Mm_:CMmTemplateLibrary::LoadTemplateL Opening domImpl")); |
437 DEBUG(("_Mm_:CMmTemplateLibrary::LoadTemplateL Opening domImpl")); |
501 // ----------------------------------------------------------------------------- |
503 // ----------------------------------------------------------------------------- |
502 // |
504 // |
503 // ----------------------------------------------------------------------------- |
505 // ----------------------------------------------------------------------------- |
504 // |
506 // |
505 void CMmTemplateLibrary::ProcessElementL(TMmTemplateType aMmTemplateType, |
507 void CMmTemplateLibrary::ProcessElementL(TMmTemplateType aMmTemplateType, |
506 TXmlEngElement aElement, |
508 TXmlEngElement aElement, |
507 const TDesC8& aTemplate, |
509 const TDesC8& aTemplate, |
508 TBool aLandscapeOrientation, |
510 TBool aLandscapeOrientation, |
509 TBool aHighlighted ) |
511 TBool aHighlighted ) |
510 { |
512 { |
511 switch ( aMmTemplateType ) |
513 switch ( aMmTemplateType ) |
512 { |
514 { |
513 case ETemplateTypeLCT: |
515 case ETemplateTypeLCT: |
514 ProcessLCTTemplateElementL(aElement, aTemplate, aLandscapeOrientation, aHighlighted ); |
516 ProcessLCTTemplateElementL(aElement, aTemplate, aLandscapeOrientation, aHighlighted ); |
515 break; |
517 break; |
516 case ETemplateTypeCustom: |
518 case ETemplateTypeCustom: |
517 ProcessCustomTemplateElementL(aElement, aTemplate, aLandscapeOrientation, aHighlighted ); |
519 ProcessCustomTemplateElementL(aElement, aTemplate, aLandscapeOrientation, aHighlighted ); |
518 break; |
520 break; |
519 } |
521 } |
520 } |
522 } |
521 |
523 |
522 // ----------------------------------------------------------------------------- |
524 // ----------------------------------------------------------------------------- |
523 // |
525 // |
524 // ----------------------------------------------------------------------------- |
526 // ----------------------------------------------------------------------------- |
525 // |
527 // |
526 void CMmTemplateLibrary::ProcessLCTTemplateElementL(TXmlEngElement aElement, |
528 void CMmTemplateLibrary::ProcessLCTTemplateElementL(TXmlEngElement aElement, |
527 const TDesC8& aTemplate, |
529 const TDesC8& aTemplate, |
528 TBool aLandscapeOrientation, |
530 TBool aLandscapeOrientation, |
529 TBool aHighlighted ) |
531 TBool aHighlighted ) |
530 { |
532 { |
531 RXmlEngNodeList<TXmlEngElement> layoutElements; |
533 RXmlEngNodeList<TXmlEngElement> layoutElements; |
532 CleanupClosePushL( layoutElements ); |
534 CleanupClosePushL( layoutElements ); |
533 aElement.GetChildElements( layoutElements ); |
535 aElement.GetChildElements( layoutElements ); |
534 TXmlEngElement layoutElement; |
536 TXmlEngElement layoutElement; |
535 TSize itemSize; |
537 TSize itemSize; |
536 while ( layoutElements.HasNext() ) |
538 while ( layoutElements.HasNext() ) |
537 { |
539 { |
538 layoutElement = layoutElements.Next(); |
540 layoutElement = layoutElements.Next(); |
539 |
541 |
540 if ( !layoutElement.Name().Compare( KLayout8 ) ) |
542 if ( !layoutElement.Name().Compare( KLayout8 ) ) |
541 { |
543 { |
542 TPtrC8 lctAtt = layoutElement.AttributeValueL(KLct8); |
544 TPtrC8 lctAtt = layoutElement.AttributeValueL(KLct8); |
543 |
545 |
544 // set layout for grid |
546 // set layout for grid |
545 TInt variety; |
547 TInt variety; |
546 HnConvUtils::Str8ToInt(layoutElement.AttributeValueL(KVariety8), variety); |
548 HnConvUtils::Str8ToInt(layoutElement.AttributeValueL(KVariety8), variety); |
547 |
549 |
548 TSize layoutSize; |
550 TSize layoutSize; |
549 if ( iWidgetType == EGrid ) |
551 if ( iWidgetType == EGrid ) |
550 { |
552 { |
551 layoutSize = MmLCTUtils::GetLayoutSize( lctAtt, variety ); |
553 layoutSize = MmLCTUtils::GetLayoutSize( lctAtt, variety ); |
552 CacheLayoutSizeL( layoutSize, aTemplate, aLandscapeOrientation ); |
554 CacheLayoutSizeL( layoutSize, aTemplate, aLandscapeOrientation ); |
553 } |
555 } |
554 else |
556 else |
555 { |
557 { |
556 layoutSize = GetLayoutSizeL( iWidgetType, aTemplate, aLandscapeOrientation ); |
558 layoutSize = GetLayoutSizeL( iWidgetType, aTemplate, aLandscapeOrientation ); |
557 } |
559 } |
558 |
560 |
559 TAknWindowLineLayout layout; |
561 TAknWindowLineLayout layout; |
560 TSize itemSize = GetLCTSize( lctAtt, variety, layout, aLandscapeOrientation ); |
562 TSize itemSize = GetLCTSize( lctAtt, variety, layout, aLandscapeOrientation ); |
561 |
563 |
562 AdjustItemSize( itemSize, layoutSize, aLandscapeOrientation ); |
564 AdjustItemSize( itemSize, layoutSize, aLandscapeOrientation ); |
563 HBufC8* lookup_string = LookupText( aTemplate, iWidgetType, |
565 HBufC8* lookup_string = LookupText( aTemplate, iWidgetType, |
564 aLandscapeOrientation, aHighlighted ); |
566 aLandscapeOrientation, aHighlighted ); |
565 iTemplateSizesMap.InsertL( lookup_string, itemSize ); |
567 iTemplateSizesMap.InsertL( lookup_string, itemSize ); |
566 |
568 |
567 // setup children |
569 // setup children |
568 RArray< TTemplateChild > childrenDefinition; |
570 RArray< TTemplateChild > childrenDefinition; |
569 CleanupClosePushL( childrenDefinition ); |
571 CleanupClosePushL( childrenDefinition ); |
570 RXmlEngNodeList<TXmlEngElement> childrenElements; |
572 RXmlEngNodeList<TXmlEngElement> childrenElements; |
571 CleanupClosePushL( childrenElements ); |
573 CleanupClosePushL( childrenElements ); |
572 layoutElement.GetChildElements( childrenElements ); |
574 layoutElement.GetChildElements( childrenElements ); |
573 TXmlEngElement childElement; |
575 TXmlEngElement childElement; |
574 while ( childrenElements.HasNext() ) |
576 while ( childrenElements.HasNext() ) |
575 { |
577 { |
576 childElement = childrenElements.Next(); |
578 childElement = childrenElements.Next(); |
577 TPtrC8 name = childElement.Name(); |
579 TPtrC8 name = childElement.Name(); |
578 if ( !name.Compare( KTextVisual8 ) || |
580 if ( !name.Compare( KTextVisual8 ) || |
579 !name.Compare( KImageVisual8 ) ) |
581 !name.Compare( KImageVisual8 ) ) |
580 { |
582 { |
581 TTemplateChild childTemplate; |
583 TTemplateChild childTemplate; |
582 childTemplate.iLct = childElement.AttributeValueL(KLct8); |
584 childTemplate.iLct = childElement.AttributeValueL(KLct8); |
583 TInt variety; |
585 TInt variety; |
584 HnConvUtils::Str8ToInt(childElement.AttributeValueL(KVariety8), variety); |
586 HnConvUtils::Str8ToInt(childElement.AttributeValueL(KVariety8), variety); |
585 childTemplate.iVariety = variety; |
587 childTemplate.iVariety = variety; |
586 |
588 |
587 TPtrC8 ptr = childElement.AttributeValueL(KHAlign8); |
589 TPtrC8 ptr = childElement.AttributeValueL(KHAlign8); |
588 if (!ptr.Compare(KNullDesC8)) |
590 if (!ptr.Compare(KNullDesC8)) |
589 { |
591 { |
590 childTemplate.iHAlign = EManualAlignUndefined; |
592 childTemplate.iHAlign = EManualAlignUndefined; |
591 } |
593 } |
592 else if (!ptr.Compare(KLeft8)) |
594 else if (!ptr.Compare(KLeft8)) |
678 childrenDefinition.AppendL( childTemplate ); |
680 childrenDefinition.AppendL( childTemplate ); |
679 } |
681 } |
680 } |
682 } |
681 CleanupStack::PopAndDestroy( &childrenElements ); |
683 CleanupStack::PopAndDestroy( &childrenElements ); |
682 // save children defintion in map |
684 // save children defintion in map |
683 lookup_string = LookupText(aTemplate, iWidgetType, |
685 lookup_string = LookupText(aTemplate, iWidgetType, |
684 aLandscapeOrientation, aHighlighted ); |
686 aLandscapeOrientation, aHighlighted ); |
685 iTemplateChildrenMap.InsertL(lookup_string, childrenDefinition); |
687 iTemplateChildrenMap.InsertL(lookup_string, childrenDefinition); |
686 CleanupStack::Pop( &childrenDefinition ); |
688 CleanupStack::Pop( &childrenDefinition ); |
687 // we found first layout, it is enough |
689 // we found first layout, it is enough |
688 break; |
690 break; |
689 } |
691 } |
690 } |
692 } |
691 CleanupStack::PopAndDestroy( &layoutElements ); |
693 CleanupStack::PopAndDestroy( &layoutElements ); |
692 } |
694 } |
693 |
695 |
694 // ----------------------------------------------------------------------------- |
696 // ----------------------------------------------------------------------------- |
695 // |
697 // |
696 // ----------------------------------------------------------------------------- |
698 // ----------------------------------------------------------------------------- |
697 // |
699 // |
698 HBufC8* CMmTemplateLibrary::GetTemplateContentL(const TDesC8& aTemplate, |
700 HBufC8* CMmTemplateLibrary::GetTemplateContentL(const TDesC8& aTemplate, |
699 TMmWidgetType aWidgetType, TMmTemplateType& aMmTemplateType) |
701 TMmWidgetType aWidgetType, TMmTemplateType& aMmTemplateType) |
700 { |
702 { |
701 HBufC8* content; |
703 HBufC8* content; |
702 TRAPD( err , GetTemplateFileContentL( content, aTemplate, aWidgetType, aMmTemplateType ) ); |
704 TRAPD( err , GetTemplateFileContentL( content, aTemplate, aWidgetType, aMmTemplateType ) ); |
703 if ( KErrNone != err || !content ) |
705 if ( KErrNone != err || !content ) |
704 { |
706 { |
705 // if LCT template was not loaded try to load a custom template |
707 // if LCT template was not loaded try to load a custom template |
706 TRAPD( err , GetTemplateFileContentL( content, aTemplate, aWidgetType, aMmTemplateType, ETrue ) ); |
708 TRAPD( err , GetTemplateFileContentL( content, aTemplate, aWidgetType, aMmTemplateType, ETrue ) ); |
707 if ( KErrNoMemory == err ) |
709 if ( KErrNoMemory == err ) |
708 { |
710 { |
709 User::Leave( KErrNoMemory ); |
711 User::Leave( KErrNoMemory ); |
710 } |
712 } |
711 if ( KErrNone != err || !content ) |
713 if ( KErrNone != err || !content ) |
712 { |
714 { |
713 User::Panic(KMtlPanic, -1); |
715 User::Panic(KMtlPanic, -1); |
714 } |
716 } |
715 } |
717 } |
716 return content; |
718 return content; |
717 } |
719 } |
718 |
720 |
719 // ----------------------------------------------------------------------------- |
721 // ----------------------------------------------------------------------------- |
720 // |
722 // |
721 // ----------------------------------------------------------------------------- |
723 // ----------------------------------------------------------------------------- |
722 // |
724 // |
723 void CMmTemplateLibrary::GetTemplateFileContentL( HBufC8*& aContent, |
725 void CMmTemplateLibrary::GetTemplateFileContentL( HBufC8*& aContent, |
724 const TDesC8& aTemplate, TMmWidgetType aWidgetType, |
726 const TDesC8& aTemplate, TMmWidgetType aWidgetType, |
725 TMmTemplateType& aMmTemplateType, TBool aLoadCustomTemplate ) |
727 TMmTemplateType& aMmTemplateType, TBool aLoadCustomTemplate ) |
726 { |
728 { |
727 DEBUG(("_Mm_:CMmTemplateLibrary::GetTemplateContentL IN")); |
729 DEBUG(("_Mm_:CMmTemplateLibrary::GetTemplateContentL IN")); |
728 TFileName filename; |
730 TFileName filename; |
729 // create filename egz: akn_logical_template_3.xml |
731 // create filename egz: akn_logical_template_3.xml |
730 filename.Copy(aTemplate); |
732 filename.Copy(aTemplate); |
731 filename.Insert(0, KUnderline ); |
733 filename.Insert(0, KUnderline ); |
732 filename.Insert(0, KAkn ); |
734 filename.Insert(0, KAkn ); |
733 filename.Append( KXmlExt ); |
735 filename.Append( KXmlExt ); |
734 |
736 |
735 // append path egz: z:\\resource\\grid\\lct\\akn_logical_template_3.xml |
737 // append path egz: z:\\resource\\grid\\lct\\akn_logical_template_3.xml |
736 |
738 |
737 if ( !aLoadCustomTemplate ) |
739 if ( !aLoadCustomTemplate ) |
738 { |
740 { |
739 filename.Insert(0, KBslash ); |
741 filename.Insert(0, KBslash ); |
740 filename.Insert(0, KLct ); |
742 filename.Insert(0, KLct ); |
741 } |
743 } |
742 else |
744 else |
743 { |
745 { |
744 filename.Insert(0, KBslash ); |
746 filename.Insert(0, KBslash ); |
745 filename.Insert(0, KCustom ); |
747 filename.Insert(0, KCustom ); |
746 } |
748 } |
747 |
749 |
748 switch (aWidgetType) |
750 switch (aWidgetType) |
749 { |
751 { |
750 case EGrid: |
752 case EGrid: |
751 filename.Insert(0, KBslash ); |
753 filename.Insert(0, KBslash ); |
752 filename.Insert(0, KWidgetTypeGrid); |
754 filename.Insert(0, KWidgetTypeGrid); |
753 break; |
755 break; |
754 case EListbox: |
756 case EListbox: |
755 filename.Insert(0, KBslash ); |
757 filename.Insert(0, KBslash ); |
756 filename.Insert(0, KWidgetTypeList ); |
758 filename.Insert(0, KWidgetTypeList ); |
757 break; |
759 break; |
758 } |
760 } |
759 |
761 |
760 filename.Insert(0, KZResource ); |
762 filename.Insert(0, KZResource ); |
761 |
763 |
762 DEBUG(("\t_Mm_:tail: %S", &filename)); |
764 DEBUG(("\t_Mm_:tail: %S", &filename)); |
763 DEBUG(("_Mm_:CMmTemplateLibrary::GetTemplateContentL OUT")); |
765 DEBUG(("_Mm_:CMmTemplateLibrary::GetTemplateContentL OUT")); |
764 |
766 |
765 // load LCT Template or if it does not exist then load custom template |
767 // load LCT Template or if it does not exist then load custom template |
766 aContent = HnUtils::ReadFileLC(filename); |
768 aContent = HnUtils::ReadFileLC(filename); |
767 CleanupStack::Pop( aContent ); |
769 CleanupStack::Pop( aContent ); |
768 |
770 |
769 if ( aLoadCustomTemplate ) |
771 if ( aLoadCustomTemplate ) |
770 { |
772 { |
771 aMmTemplateType = ETemplateTypeCustom; |
773 aMmTemplateType = ETemplateTypeCustom; |
772 } |
774 } |
773 else |
775 else |
774 { |
776 { |
775 aMmTemplateType = ETemplateTypeLCT; |
777 aMmTemplateType = ETemplateTypeLCT; |
776 } |
778 } |
777 return; |
779 return; |
778 } |
780 } |
779 |
781 |
780 // ----------------------------------------------------------------------------- |
782 // ----------------------------------------------------------------------------- |
781 // |
783 // |
782 // ----------------------------------------------------------------------------- |
784 // ----------------------------------------------------------------------------- |
783 // |
785 // |
784 TSize CMmTemplateLibrary::GetLCTSize( const TDesC8& aLCTTemplate, TInt aVariety, |
786 TSize CMmTemplateLibrary::GetLCTSize( const TDesC8& aLCTTemplate, TInt aVariety, |
785 TAknWindowLineLayout& aWindowLayout, TBool aLandscapeOrientation ) |
787 TAknWindowLineLayout& aWindowLayout, TBool aLandscapeOrientation ) |
786 { |
788 { |
787 TSize size = MmLCTUtils::GetLCTSize( aLCTTemplate, aVariety, |
789 TSize size = MmLCTUtils::GetLCTSize( aLCTTemplate, aVariety, |
788 GetParentRect( aLandscapeOrientation ), aWindowLayout ); |
790 GetParentRect( aLandscapeOrientation ), aWindowLayout ); |
789 return size; |
791 return size; |
790 } |
792 } |
791 |
793 |
792 // ----------------------------------------------------------------------------- |
794 // ----------------------------------------------------------------------------- |
793 // |
795 // |
794 // ----------------------------------------------------------------------------- |
796 // ----------------------------------------------------------------------------- |
795 // |
797 // |
796 void CMmTemplateLibrary::SetupLCTTemplateL(TTemplateChild& aChildTemplate, |
798 void CMmTemplateLibrary::SetupLCTTemplateL(TTemplateChild& aChildTemplate, |
797 TXmlEngElement& aChildElement, TSize aItemSize ) |
799 TXmlEngElement& aChildElement, TSize aItemSize ) |
798 { |
800 { |
799 TPtrC8 name = aChildElement.Name(); |
801 TPtrC8 name = aChildElement.Name(); |
800 aChildTemplate.iData = aChildElement.AttributeValueL(KId8); |
802 aChildTemplate.iData = aChildElement.AttributeValueL(KId8); |
801 SetupTemplateVisualId( aChildTemplate ); |
803 SetupTemplateVisualId( aChildTemplate ); |
802 |
804 |
803 // read attribute name (mm_title, mm_icon) |
805 // read attribute name (mm_title, mm_icon) |
886 aChildTemplate.iTextAlign = static_cast<CGraphicsContext::TTextAlign>(textAlign); |
888 aChildTemplate.iTextAlign = static_cast<CGraphicsContext::TTextAlign>(textAlign); |
887 } |
889 } |
888 } |
890 } |
889 |
891 |
890 CleanupStack::PopAndDestroy( &attributeElements ); |
892 CleanupStack::PopAndDestroy( &attributeElements ); |
891 } |
893 } |
892 |
894 |
893 // ----------------------------------------------------------------------------- |
895 // ----------------------------------------------------------------------------- |
894 // |
896 // |
895 // ----------------------------------------------------------------------------- |
897 // ----------------------------------------------------------------------------- |
896 // |
898 // |
897 void CMmTemplateLibrary::SetupTemplateVisualId(TTemplateChild& aChildTemplate ) |
899 void CMmTemplateLibrary::SetupTemplateVisualId(TTemplateChild& aChildTemplate ) |
898 { |
900 { |
899 if( !aChildTemplate.iData.Compare( KMmBackdropIcon8 )) |
901 if( !aChildTemplate.iData.Compare( KMmBackdropIcon8 )) |
900 { |
902 { |
901 aChildTemplate.iImageVisualId = EImageVisualIdEditMode; |
903 aChildTemplate.iImageVisualId = EImageVisualIdEditMode; |
902 } |
904 } |
903 else |
905 else |
904 { |
906 { |
905 aChildTemplate.iImageVisualId = EImageVisualIdNormalMode; |
907 aChildTemplate.iImageVisualId = EImageVisualIdNormalMode; |
906 } |
908 } |
907 } |
909 } |
908 |
910 |
909 // ----------------------------------------------------------------------------- |
911 // ----------------------------------------------------------------------------- |
910 // |
912 // |
911 // ----------------------------------------------------------------------------- |
913 // ----------------------------------------------------------------------------- |
912 // |
914 // |
913 void CMmTemplateLibrary::AppendEditModeTemplateL( |
915 void CMmTemplateLibrary::AppendEditModeTemplateL( |
914 RArray<TTemplateChild>& aTemplateArray, TSize aSize) |
916 RArray<TTemplateChild>& aTemplateArray, TSize aSize) |
915 { |
917 { |
916 //setup backdrop icon |
918 //setup backdrop icon |
917 TTemplateChild childTemplate; |
919 TTemplateChild childTemplate; |
918 childTemplate.iIsImage = ETrue; |
920 childTemplate.iIsImage = ETrue; |
919 childTemplate.iFontId = EAknLogicalFontSecondaryFont; |
921 childTemplate.iFontId = EAknLogicalFontSecondaryFont; |
920 childTemplate.iTextAlign = CGraphicsContext::ELeft; |
922 childTemplate.iTextAlign = CGraphicsContext::ELeft; |
921 childTemplate.iRectAccordingToParent = TRect( TPoint( 0,0 ), |
923 childTemplate.iRectAccordingToParent = TRect( TPoint( 0,0 ), |
922 TPoint( aSize.iWidth, aSize.iHeight ) ); |
924 TPoint( aSize.iWidth, aSize.iHeight ) ); |
923 childTemplate.iData = TBufC8< MmTemplateContants::KTemplateChildTextLength >( KMmBackdropIcon8 ); |
925 childTemplate.iData = TBufC8< MmTemplateContants::KTemplateChildTextLength >( KMmBackdropIcon8 ); |
924 SetupTemplateVisualId( childTemplate ); |
926 SetupTemplateVisualId( childTemplate ); |
925 aTemplateArray.AppendL( childTemplate ); |
927 aTemplateArray.AppendL( childTemplate ); |
926 } |
928 } |
927 |
929 |
928 |
930 |
929 // ----------------------------------------------------------------------------- |
931 // ----------------------------------------------------------------------------- |
930 // |
932 // |
931 // ----------------------------------------------------------------------------- |
933 // ----------------------------------------------------------------------------- |
932 // |
934 // |
933 void CMmTemplateLibrary::SetupMoveIndicatorTemplateChildrenL( |
935 void CMmTemplateLibrary::SetupMoveIndicatorTemplateChildrenL( |
934 const TDesC8& aLookupString, TSize aItemSize ) |
936 const TDesC8& aLookupString, TSize aItemSize ) |
935 { |
937 { |
936 RArray< TTemplateChild > childrenDefinition; |
938 RArray< TTemplateChild > childrenDefinition; |
937 TTemplateChild childTemplate; |
939 TTemplateChild childTemplate; |
938 childTemplate.iIsImage = ETrue; |
940 childTemplate.iIsImage = ETrue; |
939 childTemplate.iImageVisualId = EImageVisualIdNormalMode; |
941 childTemplate.iImageVisualId = EImageVisualIdNormalMode; |
940 childTemplate.iFontId = EAknLogicalFontSecondaryFont; |
942 childTemplate.iFontId = EAknLogicalFontSecondaryFont; |
941 childTemplate.iTextAlign = CGraphicsContext::ELeft; |
943 childTemplate.iTextAlign = CGraphicsContext::ELeft; |
942 TPoint startingPosition = TPoint( |
944 TPoint startingPosition = TPoint( |
943 MmTemplateContants::KMoveIndicatorStartingPos, |
945 MmTemplateContants::KMoveIndicatorStartingPos, |
944 MmTemplateContants::KMoveIndicatorStartingPos); |
946 MmTemplateContants::KMoveIndicatorStartingPos); |
945 |
947 |
946 //setup move_indicator_arrow_left |
948 //setup move_indicator_arrow_left |
947 childTemplate.iRectAccordingToParent = TRect(TPoint(0,aItemSize.iHeight/2 + startingPosition.iY/2), |
949 childTemplate.iRectAccordingToParent = TRect(TPoint(0,aItemSize.iHeight/2 + startingPosition.iY/2), |
948 TPoint(startingPosition.iX, |
950 TPoint(startingPosition.iX, |
949 startingPosition.iY*3/2 + aItemSize.iHeight/2)); |
951 startingPosition.iY*3/2 + aItemSize.iHeight/2)); |
950 childTemplate.iData = TBufC8< MmTemplateContants::KTemplateChildTextLength>( |
952 childTemplate.iData = TBufC8< MmTemplateContants::KTemplateChildTextLength>( |
951 KMmMoveIndicatorArrowLeft8 ); |
953 KMmMoveIndicatorArrowLeft8 ); |
952 childrenDefinition.AppendL( childTemplate ); |
954 childrenDefinition.AppendL( childTemplate ); |
953 |
955 |
954 //setup move_indicator_arrow_right |
956 //setup move_indicator_arrow_right |
955 childTemplate.iRectAccordingToParent = TRect( |
957 childTemplate.iRectAccordingToParent = TRect( |
956 TPoint(startingPosition.iX + aItemSize.iWidth , aItemSize.iHeight/2 + startingPosition.iY/2), |
958 TPoint(startingPosition.iX + aItemSize.iWidth , aItemSize.iHeight/2 + startingPosition.iY/2), |
957 TPoint(startingPosition.iX*2 + aItemSize.iWidth, |
959 TPoint(startingPosition.iX*2 + aItemSize.iWidth, |
958 startingPosition.iY*3/2 + aItemSize.iHeight/2)); |
960 startingPosition.iY*3/2 + aItemSize.iHeight/2)); |
959 childTemplate.iData = TBufC8< MmTemplateContants::KTemplateChildTextLength>( |
961 childTemplate.iData = TBufC8< MmTemplateContants::KTemplateChildTextLength>( |
960 KMmMoveIndicatorArrowRight8 ); |
962 KMmMoveIndicatorArrowRight8 ); |
961 childrenDefinition.AppendL( childTemplate ); |
963 childrenDefinition.AppendL( childTemplate ); |
962 |
964 |
963 //setup move_indicator_arrow_top |
965 //setup move_indicator_arrow_top |
964 childTemplate.iRectAccordingToParent = TRect(TPoint( aItemSize.iWidth/2 + startingPosition.iX/2, 0 ), |
966 childTemplate.iRectAccordingToParent = TRect(TPoint( aItemSize.iWidth/2 + startingPosition.iX/2, 0 ), |
965 TPoint(aItemSize.iWidth/2 + startingPosition.iX*3/2, startingPosition.iY)); |
967 TPoint(aItemSize.iWidth/2 + startingPosition.iX*3/2, startingPosition.iY)); |
966 childTemplate.iData = TBufC8< MmTemplateContants::KTemplateChildTextLength >( |
968 childTemplate.iData = TBufC8< MmTemplateContants::KTemplateChildTextLength >( |
967 KMmMoveIndicatorArrowTop8 ); |
969 KMmMoveIndicatorArrowTop8 ); |
968 childrenDefinition.AppendL( childTemplate ); |
970 childrenDefinition.AppendL( childTemplate ); |
969 |
971 |
970 //setup move_indicator_arrow_bottom |
972 //setup move_indicator_arrow_bottom |
971 childTemplate.iRectAccordingToParent = TRect( TPoint( aItemSize.iWidth/2 + startingPosition.iX/2, |
973 childTemplate.iRectAccordingToParent = TRect( TPoint( aItemSize.iWidth/2 + startingPosition.iX/2, |
972 aItemSize.iHeight + startingPosition.iY + 2 ), |
974 aItemSize.iHeight + startingPosition.iY + 2 ), |
973 TPoint(aItemSize.iWidth/2 + startingPosition.iX*3/2, |
975 TPoint(aItemSize.iWidth/2 + startingPosition.iX*3/2, |
974 aItemSize.iHeight + 2 *startingPosition.iY)); |
976 aItemSize.iHeight + 2 *startingPosition.iY)); |
975 childTemplate.iData = TBufC8< MmTemplateContants::KTemplateChildTextLength>( |
977 childTemplate.iData = TBufC8< MmTemplateContants::KTemplateChildTextLength>( |
976 KMmMoveIndicatorArrowBottom8 ); |
978 KMmMoveIndicatorArrowBottom8 ); |
977 childrenDefinition.AppendL( childTemplate ); |
979 childrenDefinition.AppendL( childTemplate ); |
978 |
980 |
979 HBufC8* lookup_string = aLookupString.AllocLC(); |
981 HBufC8* lookup_string = aLookupString.AllocLC(); |
980 iTemplateChildrenMap.InsertL(lookup_string, childrenDefinition); |
982 iTemplateChildrenMap.InsertL(lookup_string, childrenDefinition); |
981 CleanupStack::Pop( lookup_string ); |
983 CleanupStack::Pop( lookup_string ); |
982 lookup_string = NULL; |
984 lookup_string = NULL; |
983 |
985 |
984 lookup_string = aLookupString.AllocLC(); |
986 lookup_string = aLookupString.AllocLC(); |
985 TRect rectAccordingToParent = TRect( |
987 TRect rectAccordingToParent = TRect( |
986 TPoint( -startingPosition.iX, -startingPosition.iY), |
988 TPoint( -startingPosition.iX, -startingPosition.iY), |
987 TPoint(2*startingPosition.iX + aItemSize.iWidth , |
989 TPoint(2*startingPosition.iX + aItemSize.iWidth , |
988 2*startingPosition.iY + aItemSize.iHeight) ); |
990 2*startingPosition.iY + aItemSize.iHeight) ); |
989 |
991 |
990 iMoveIndicatorRectsMap.InsertL( lookup_string, rectAccordingToParent ); |
992 iMoveIndicatorRectsMap.InsertL( lookup_string, rectAccordingToParent ); |
991 CleanupStack::Pop( lookup_string ); |
993 CleanupStack::Pop( lookup_string ); |
992 } |
994 } |
993 |
995 |
994 // ----------------------------------------------------------------------------- |
996 // ----------------------------------------------------------------------------- |
995 // |
997 // |
996 // ----------------------------------------------------------------------------- |
998 // ----------------------------------------------------------------------------- |
997 // |
999 // |
998 void CMmTemplateLibrary::SetScrollbarVisibilityL( TBool aIsScrollbarVisible ) |
1000 void CMmTemplateLibrary::SetScrollbarVisibilityL( TBool aIsScrollbarVisible ) |
999 { |
1001 { |
1000 if ( iIsScrollbarVisible != aIsScrollbarVisible ) |
1002 if ( iIsScrollbarVisible != aIsScrollbarVisible ) |
1001 { |
1003 { |
1002 iIsScrollbarVisible = aIsScrollbarVisible; |
1004 iIsScrollbarVisible = aIsScrollbarVisible; |
1003 CleanAndClearCache(); |
1005 CleanAndClearCache(); |
1004 } |
1006 } |
1005 } |
1007 } |
1006 |
1008 |
1007 // ----------------------------------------------------------------------------- |
1009 // ----------------------------------------------------------------------------- |
1008 // |
1010 // |
1009 // ----------------------------------------------------------------------------- |
1011 // ----------------------------------------------------------------------------- |
1010 // |
1012 // |
1049 // ----------------------------------------------------------------------------- |
1051 // ----------------------------------------------------------------------------- |
1050 // |
1052 // |
1051 // ----------------------------------------------------------------------------- |
1053 // ----------------------------------------------------------------------------- |
1052 // |
1054 // |
1053 void CMmTemplateLibrary::AdjustItemWidth(TSize& aItemSize, TSize aLayoutSize, |
1055 void CMmTemplateLibrary::AdjustItemWidth(TSize& aItemSize, TSize aLayoutSize, |
1054 TBool aLandscapeOrientation) |
1056 TBool aLandscapeOrientation) |
1055 { |
1057 { |
1056 if ( iIsScrollbarVisible ) |
1058 if ( iIsScrollbarVisible ) |
1057 { |
1059 { |
1058 aItemSize.iWidth = ( GetParentRect(aLandscapeOrientation).Width() - iScrollbarWidth ) / aLayoutSize.iWidth; |
1060 aItemSize.iWidth = ( GetParentRect(aLandscapeOrientation).Width() - iScrollbarWidth ) / aLayoutSize.iWidth; |
1059 } |
1061 } |
1060 else |
1062 else |
1061 { |
1063 { |
1062 aItemSize.iWidth = GetParentRect(aLandscapeOrientation).Width() / aLayoutSize.iWidth; |
1064 aItemSize.iWidth = GetParentRect(aLandscapeOrientation).Width() / aLayoutSize.iWidth; |
1063 } |
1065 } |
1064 } |
1066 } |
1065 |
1067 |
1066 // ----------------------------------------------------------------------------- |
1068 // ----------------------------------------------------------------------------- |
1067 // |
1069 // |
1068 // ----------------------------------------------------------------------------- |
1070 // ----------------------------------------------------------------------------- |
1069 // |
1071 // |
1070 void CMmTemplateLibrary::UpdateParentRect( TRect aParentRect, TBool aLandscapeOrientation ) |
1072 void CMmTemplateLibrary::UpdateParentRect( TRect aParentRect, TBool aLandscapeOrientation ) |
1071 { |
1073 { |
1072 if( GetParentRect( aLandscapeOrientation ) != aParentRect ) |
1074 if( GetParentRect( aLandscapeOrientation ) != aParentRect ) |
1073 { |
1075 { |
1074 SetParentRect( aLandscapeOrientation, aParentRect ); |
1076 SetParentRect( aLandscapeOrientation, aParentRect ); |
1075 } |
1077 } |
1076 } |
1078 } |
1077 |
1079 |
1078 |
1080 |
1079 // ----------------------------------------------------------------------------- |
1081 // ----------------------------------------------------------------------------- |
1080 // |
1082 // |
1081 // ----------------------------------------------------------------------------- |
1083 // ----------------------------------------------------------------------------- |
1082 // |
1084 // |
1083 TRect CMmTemplateLibrary::GetParentRect( TBool aLandscapeOrientation ) |
1085 TRect CMmTemplateLibrary::GetParentRect( TBool aLandscapeOrientation ) |
1084 { |
1086 { |
1085 if ( aLandscapeOrientation ) |
1087 if ( aLandscapeOrientation ) |
1086 return iParentRectLandscape; |
1088 return iParentRectLandscape; |
1087 else |
1089 else |
1088 return iParentRectPortrait; |
1090 return iParentRectPortrait; |
1089 } |
1091 } |
1090 |
1092 |
1091 // ----------------------------------------------------------------------------- |
1093 // ----------------------------------------------------------------------------- |
1092 // |
1094 // |
1093 // ----------------------------------------------------------------------------- |
1095 // ----------------------------------------------------------------------------- |
1094 // |
1096 // |
1095 void CMmTemplateLibrary::SetParentRect( TBool aLandscapeOrientation, TRect aParentRect) |
1097 void CMmTemplateLibrary::SetParentRect( TBool aLandscapeOrientation, TRect aParentRect) |
1096 { |
1098 { |
1097 if ( aLandscapeOrientation ) |
1099 if ( aLandscapeOrientation ) |
1098 iParentRectLandscape = aParentRect; |
1100 iParentRectLandscape = aParentRect; |
1099 else |
1101 else |
1100 iParentRectPortrait = aParentRect; |
1102 iParentRectPortrait = aParentRect; |
1101 } |
1103 } |
1102 |
1104 |
1103 // ----------------------------------------------------------------------------- |
1105 // ----------------------------------------------------------------------------- |
1104 // |
1106 // |
1105 // ----------------------------------------------------------------------------- |
1107 // ----------------------------------------------------------------------------- |
1106 // |
1108 // |
1107 void CMmTemplateLibrary::AdjustItemSize(TSize& aItemSize, TSize aLayoutSize, |
1109 void CMmTemplateLibrary::AdjustItemSize(TSize& aItemSize, TSize aLayoutSize, |
1108 TBool aLandscapeOrientation) |
1110 TBool aLandscapeOrientation) |
1109 { |
1111 { |
1110 switch ( iWidgetType ) |
1112 switch ( iWidgetType ) |
1111 { |
1113 { |
1112 case EGrid: |
1114 case EGrid: |
1113 aItemSize.iHeight = GetParentRect( aLandscapeOrientation ).Height() / aLayoutSize.iHeight; |
1115 aItemSize.iHeight = GetParentRect( aLandscapeOrientation ).Height() / aLayoutSize.iHeight; |
1114 break; |
1116 break; |
1115 case EListbox: |
1117 case EListbox: |
1116 break; |
1118 break; |
1117 } |
1119 } |
1118 AdjustItemWidth( aItemSize, aLayoutSize, aLandscapeOrientation ); |
1120 AdjustItemWidth( aItemSize, aLayoutSize, aLandscapeOrientation ); |
1119 } |
1121 } |
1120 |
1122 |
1121 // ----------------------------------------------------------------------------- |
1123 // ----------------------------------------------------------------------------- |
1122 // |
1124 // |
1123 // ----------------------------------------------------------------------------- |
1125 // ----------------------------------------------------------------------------- |
1124 // |
1126 // |
1125 void CMmTemplateLibrary::CacheLayoutSizeL(TSize aLayoutSize, |
1127 void CMmTemplateLibrary::CacheLayoutSizeL(TSize aLayoutSize, |
1126 const TDesC8& aTemplate, TBool aLandscapeOrientation) |
1128 const TDesC8& aTemplate, TBool aLandscapeOrientation) |
1127 { |
1129 { |
1128 HBufC8* lookup_layout_text = LookupLayoutText( iWidgetType, |
1130 HBufC8* lookup_layout_text = LookupLayoutText( iWidgetType, |
1129 aTemplate, aLandscapeOrientation ); |
1131 aTemplate, aLandscapeOrientation ); |
1130 |
1132 |
1131 if ( iTemplateSizesMap.Find( lookup_layout_text ) ) |
1133 if ( iTemplateSizesMap.Find( lookup_layout_text ) ) |
1132 { |
1134 { |
1133 delete lookup_layout_text; |
1135 delete lookup_layout_text; |
1134 } |
1136 } |
1135 else |
1137 else |
1136 { |
1138 { |
1137 iTemplateSizesMap.InsertL( lookup_layout_text, aLayoutSize ); |
1139 iTemplateSizesMap.InsertL( lookup_layout_text, aLayoutSize ); |
1138 } |
1140 } |
1139 } |
1141 } |
1140 |
1142 |
1141 // ----------------------------------------------------------------------------- |
1143 // ----------------------------------------------------------------------------- |
1142 // |
1144 // |
1143 // ----------------------------------------------------------------------------- |
1145 // ----------------------------------------------------------------------------- |
1144 // |
1146 // |