|
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: Base class of node visualizer. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "emailtrace.h" |
|
20 #include <AknsUtils.h> |
|
21 #include <AknsSkinInstance.h> |
|
22 #include <biditext.h> |
|
23 |
|
24 #include "fstreenodevisualizerbase.h" |
|
25 #include "fstreelist.h" |
|
26 #include "fslayoutmanager.h" |
|
27 #include "fsalftextstylemanager.h" |
|
28 |
|
29 // <cmail> SF |
|
30 #include <alf/alfgradientbrush.h> |
|
31 #include <alf/alfimagebrush.h> |
|
32 #include <alf/alfanchorlayout.h> |
|
33 #include <alf/alfcontrol.h> |
|
34 #include <alf/alftexture.h> |
|
35 #include <alf/alfimage.h> |
|
36 #include <alf/alfenv.h> |
|
37 #include <alf/alftextstyle.h> |
|
38 #include <alf/alftextvisual.h> |
|
39 #include <alf/alfmappingfunctions.h> |
|
40 // </cmail> |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // C++ destructor. |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 CFsTreeNodeVisualizerBase::~CFsTreeNodeVisualizerBase() |
|
47 { |
|
48 FUNC_LOG; |
|
49 if (iLayout) |
|
50 { |
|
51 iLayout->Env().CancelCustomCommands(this); |
|
52 iLayout->RemoveAndDestroyAllD(); |
|
53 } |
|
54 } |
|
55 |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // Returns visualizer's type. |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 TFsTreeItemVisualizerType CFsTreeNodeVisualizerBase::Type() const |
|
62 { |
|
63 FUNC_LOG; |
|
64 return EFsTreeItemVisualizerBase; |
|
65 } |
|
66 |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // Sets the alignment for text item. |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 void CFsTreeNodeVisualizerBase::SetTextAlign( |
|
73 const TAlfAlignHorizontal aAlign ) |
|
74 { |
|
75 FUNC_LOG; |
|
76 iTextAlign = aAlign; |
|
77 } |
|
78 |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // The function sets item's text color for the focused state. |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 void CFsTreeNodeVisualizerBase::SetFocusedStateTextColor( const TRgb& aColor ) |
|
85 { |
|
86 FUNC_LOG; |
|
87 iIsCustomTextFocusedColor = ETrue; |
|
88 iFocusedTextColor = aColor; |
|
89 } |
|
90 |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // The function returns item's text color for the focused state. |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 TRgb CFsTreeNodeVisualizerBase::FocusedStateTextColor() const |
|
97 { |
|
98 FUNC_LOG; |
|
99 return iFocusedTextColor; |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // The function sets item's text color for the normal (unfocused) state. |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 void CFsTreeNodeVisualizerBase::SetNormalStateTextColor( const TRgb& aColor ) |
|
107 { |
|
108 FUNC_LOG; |
|
109 iIsCustomTextNormalColor = ETrue; |
|
110 iNormalTextColor = aColor; |
|
111 } |
|
112 |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // The function returns item's text color for the normal (unfocused) state. |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 TRgb CFsTreeNodeVisualizerBase::NormalStateTextColor() const |
|
119 { |
|
120 FUNC_LOG; |
|
121 |
|
122 return iNormalTextColor; |
|
123 } |
|
124 |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // The function sets the style of item's text. |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 void CFsTreeNodeVisualizerBase::SetTextStyleId ( const TInt aTextStyleId ) |
|
131 { |
|
132 FUNC_LOG; |
|
133 iIsCustomTextStyle = ETrue; |
|
134 iTextStyleId = aTextStyleId; |
|
135 } |
|
136 |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // The function returns the style of item's text. |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 TInt CFsTreeNodeVisualizerBase::TextStyleId () const |
|
143 { |
|
144 FUNC_LOG; |
|
145 TInt styleId(0); |
|
146 if ( iIsCustomTextStyle ) |
|
147 { |
|
148 styleId = iTextStyleId; |
|
149 } |
|
150 else |
|
151 { |
|
152 TRAP_IGNORE( styleId = ModifiedStyleIdL() ); |
|
153 } |
|
154 return styleId; |
|
155 } |
|
156 |
|
157 |
|
158 // --------------------------------------------------------------------------- |
|
159 // From class MFsTreeItemVisualizer. |
|
160 // Sets multiple flags for an item at one time. |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 void CFsTreeNodeVisualizerBase::SetFlags( TUint32 aFlags ) |
|
164 { |
|
165 FUNC_LOG; |
|
166 iFlags = aFlags; |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // From class MFsTreeItemVisualizer. |
|
171 // Returns flags of the item visualizer. |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 TUint32 CFsTreeNodeVisualizerBase::Flags() |
|
175 { |
|
176 FUNC_LOG; |
|
177 return iFlags; |
|
178 } |
|
179 |
|
180 // --------------------------------------------------------------------------- |
|
181 // From class MFsTreeItemVisualizer. |
|
182 // Sets visualized item's state to marked/unmarked. |
|
183 // --------------------------------------------------------------------------- |
|
184 // |
|
185 void CFsTreeNodeVisualizerBase::SetMarked( TBool aFlag ) |
|
186 { |
|
187 FUNC_LOG; |
|
188 if ( aFlag ) |
|
189 { |
|
190 iFlags |= KFsTreeListItemMarked; |
|
191 } |
|
192 else |
|
193 { |
|
194 iFlags &= ~KFsTreeListItemMarked; |
|
195 } |
|
196 } |
|
197 |
|
198 // --------------------------------------------------------------------------- |
|
199 // From class MFsTreeItemVisualizer. |
|
200 // Returns mark/unmark state of the item's visualization. |
|
201 // --------------------------------------------------------------------------- |
|
202 // |
|
203 TBool CFsTreeNodeVisualizerBase::IsMarked() const |
|
204 { |
|
205 FUNC_LOG; |
|
206 return iFlags & KFsTreeListItemMarked ? ETrue : EFalse; |
|
207 } |
|
208 |
|
209 // --------------------------------------------------------------------------- |
|
210 // From class MFsTreeItemVisualizer. |
|
211 // Sets visualized item's state to dimmed/not dimmed. |
|
212 // --------------------------------------------------------------------------- |
|
213 // |
|
214 void CFsTreeNodeVisualizerBase::SetDimmed( TBool aFlag ) |
|
215 { |
|
216 FUNC_LOG; |
|
217 if ( aFlag ) |
|
218 { |
|
219 iFlags |= KFsTreeListItemDimmed; |
|
220 } |
|
221 else |
|
222 { |
|
223 iFlags &= ~KFsTreeListItemDimmed; |
|
224 } |
|
225 } |
|
226 |
|
227 // --------------------------------------------------------------------------- |
|
228 // From class MFsTreeItemVisualizer. |
|
229 // Returns dimmed/not dimmed state of the item's visualization. |
|
230 // --------------------------------------------------------------------------- |
|
231 // |
|
232 TBool CFsTreeNodeVisualizerBase::IsDimmed() const |
|
233 { |
|
234 FUNC_LOG; |
|
235 return iFlags & KFsTreeListItemDimmed ? ETrue : EFalse; |
|
236 } |
|
237 |
|
238 |
|
239 // --------------------------------------------------------------------------- |
|
240 // From class MFsTreeItemVisualizer. |
|
241 // Sets the size of the item visualization when item is not in expanded state. |
|
242 // --------------------------------------------------------------------------- |
|
243 // |
|
244 void CFsTreeNodeVisualizerBase::SetSize( const TSize aSize ) |
|
245 { |
|
246 FUNC_LOG; |
|
247 iSize = aSize; |
|
248 } |
|
249 |
|
250 |
|
251 // --------------------------------------------------------------------------- |
|
252 // From class MFsTreeItemVisualizer. |
|
253 // Returns the size of an item in a normal (not expanded) state. |
|
254 // --------------------------------------------------------------------------- |
|
255 // |
|
256 TSize CFsTreeNodeVisualizerBase::Size() const |
|
257 { |
|
258 FUNC_LOG; |
|
259 if ( iFlags & KFsTreeListItemManagedLayout ) |
|
260 { |
|
261 CFsLayoutManager::TFsLayoutMetrics normalSizeMetrics (CFsLayoutManager::EFsLmListSingleFsDycPane); |
|
262 TRect parentLayoutRect(0,0,0,0); |
|
263 TSize size(0,0); |
|
264 TBool retVal(EFalse); |
|
265 |
|
266 retVal = CFsLayoutManager::LayoutMetricsSize( |
|
267 parentLayoutRect, |
|
268 normalSizeMetrics, |
|
269 size ); |
|
270 |
|
271 if ( !retVal ) |
|
272 { |
|
273 size = iSize; |
|
274 } |
|
275 |
|
276 return size; |
|
277 } |
|
278 else |
|
279 { |
|
280 return iSize; |
|
281 } |
|
282 } |
|
283 |
|
284 // --------------------------------------------------------------------------- |
|
285 // From class MFsTreeItemVisualizer. |
|
286 // Sets the item's visualization state to expanded. |
|
287 // --------------------------------------------------------------------------- |
|
288 // |
|
289 void CFsTreeNodeVisualizerBase::SetExtended( const TBool aFlag ) |
|
290 { |
|
291 FUNC_LOG; |
|
292 if ( aFlag ) |
|
293 { |
|
294 iFlags |= KFsTreeListItemExtended; |
|
295 } |
|
296 else |
|
297 { |
|
298 iFlags &= ~KFsTreeListItemExtended; |
|
299 } |
|
300 } |
|
301 |
|
302 // --------------------------------------------------------------------------- |
|
303 // From class MFsTreeItemVisualizer. |
|
304 // Returns expanded/not expanded state of the item visualization. |
|
305 // --------------------------------------------------------------------------- |
|
306 // |
|
307 TBool CFsTreeNodeVisualizerBase::IsExtended() const |
|
308 { |
|
309 FUNC_LOG; |
|
310 return iFlags & KFsTreeListItemExtended ? ETrue : EFalse; |
|
311 } |
|
312 |
|
313 // --------------------------------------------------------------------------- |
|
314 // From class MFsTreeItemVisualizer. |
|
315 // Sets if an item can be in expanded state or not. |
|
316 // --------------------------------------------------------------------------- |
|
317 // |
|
318 void CFsTreeNodeVisualizerBase::SetExtendable( TBool aFlag ) |
|
319 { |
|
320 FUNC_LOG; |
|
321 if ( aFlag ) |
|
322 { |
|
323 iFlags |= KFsTreeListItemExtendable; |
|
324 } |
|
325 else |
|
326 { |
|
327 iFlags &= ~KFsTreeListItemExtendable; |
|
328 } |
|
329 } |
|
330 |
|
331 // --------------------------------------------------------------------------- |
|
332 // From class MFsTreeItemVisualizer. |
|
333 // Returns an information if item can be in expanded state. |
|
334 // --------------------------------------------------------------------------- |
|
335 // |
|
336 TBool CFsTreeNodeVisualizerBase::IsExtendable( ) |
|
337 { |
|
338 FUNC_LOG; |
|
339 return iFlags & KFsTreeListItemExtendable ? ETrue : EFalse; |
|
340 } |
|
341 |
|
342 // --------------------------------------------------------------------------- |
|
343 // From class MFsTreeItemVisualizer. |
|
344 // Returns an information if item can be focusable. |
|
345 // --------------------------------------------------------------------------- |
|
346 // |
|
347 TBool CFsTreeNodeVisualizerBase::IsFocusable( ) const |
|
348 { |
|
349 FUNC_LOG; |
|
350 return iFlags & KFsTreeListItemFocusable ? ETrue : EFalse; |
|
351 } |
|
352 |
|
353 // --------------------------------------------------------------------------- |
|
354 // From class MFsTreeItemVisualizer. |
|
355 // Sets the item's ability to receive focus. |
|
356 // --------------------------------------------------------------------------- |
|
357 // |
|
358 void CFsTreeNodeVisualizerBase::SetFocusable( const TBool aFlag ) |
|
359 { |
|
360 FUNC_LOG; |
|
361 if ( aFlag ) |
|
362 { |
|
363 iFlags |= KFsTreeListItemFocusable; |
|
364 } |
|
365 else |
|
366 { |
|
367 iFlags &= ~KFsTreeListItemFocusable; |
|
368 } |
|
369 } |
|
370 |
|
371 // --------------------------------------------------------------------------- |
|
372 // From class MFsTreeItemVisualizer. |
|
373 // Sets the size of the item visualization area when item is in expanded |
|
374 // state. |
|
375 // --------------------------------------------------------------------------- |
|
376 // |
|
377 void CFsTreeNodeVisualizerBase::SetExtendedSize( |
|
378 const TSize aExtendedSize ) |
|
379 { |
|
380 FUNC_LOG; |
|
381 iExtendedSize = aExtendedSize; |
|
382 } |
|
383 |
|
384 // --------------------------------------------------------------------------- |
|
385 // From class MFsTreeItemVisualizer. |
|
386 // Returns the size of an item in expanded state. |
|
387 // --------------------------------------------------------------------------- |
|
388 // |
|
389 TSize CFsTreeNodeVisualizerBase::ExtendedSize() const |
|
390 { |
|
391 FUNC_LOG; |
|
392 if ( iFlags & KFsTreeListItemManagedLayout ) |
|
393 { |
|
394 CFsLayoutManager::TFsLayoutMetrics extendedSizeMetrics( CFsLayoutManager::EFsLmListMediumLineX2 ); |
|
395 TRect parentLayoutRect(0,0,0,0); |
|
396 TSize extSize(0,0); |
|
397 TBool retVal(EFalse); |
|
398 |
|
399 retVal = CFsLayoutManager::LayoutMetricsSize( |
|
400 parentLayoutRect, |
|
401 extendedSizeMetrics, |
|
402 extSize ); |
|
403 |
|
404 if ( !retVal ) |
|
405 { |
|
406 extSize = iExtendedSize; |
|
407 } |
|
408 |
|
409 return extSize; |
|
410 } |
|
411 else |
|
412 { |
|
413 return iExtendedSize; |
|
414 } |
|
415 } |
|
416 |
|
417 // --------------------------------------------------------------------------- |
|
418 // From class MFsTreeItemVisualizer. |
|
419 // Sets visualized item's state to hidden/visible. |
|
420 // --------------------------------------------------------------------------- |
|
421 // |
|
422 void CFsTreeNodeVisualizerBase::SetHidden( TBool aFlag ) |
|
423 { |
|
424 FUNC_LOG; |
|
425 if ( aFlag ) |
|
426 { |
|
427 iFlags |= KFsTreeListItemHidden; |
|
428 } |
|
429 else |
|
430 { |
|
431 iFlags &= ~KFsTreeListItemHidden; |
|
432 } |
|
433 } |
|
434 |
|
435 // --------------------------------------------------------------------------- |
|
436 // From class MFsTreeItemVisualizer. |
|
437 // Returns an information if the item is hidden or not. |
|
438 // --------------------------------------------------------------------------- |
|
439 // |
|
440 TBool CFsTreeNodeVisualizerBase::IsHidden() |
|
441 { |
|
442 FUNC_LOG; |
|
443 return iFlags & KFsTreeListItemHidden ? ETrue : EFalse; |
|
444 } |
|
445 |
|
446 // --------------------------------------------------------------------------- |
|
447 // From MFsTreeItemVisualizer. |
|
448 // Enables or disables text shadow. |
|
449 // --------------------------------------------------------------------------- |
|
450 // |
|
451 void CFsTreeNodeVisualizerBase::EnableTextShadow( |
|
452 const TBool aShadowOn ) |
|
453 { |
|
454 FUNC_LOG; |
|
455 if (aShadowOn) |
|
456 { |
|
457 iFlags |= KFsTreeListItemTextShadow; |
|
458 } |
|
459 else |
|
460 { |
|
461 iFlags &= ~KFsTreeListItemTextShadow; |
|
462 } |
|
463 } |
|
464 |
|
465 // --------------------------------------------------------------------------- |
|
466 // From class MFsTreeItemVisualizer. |
|
467 // Sets text indentation. |
|
468 // --------------------------------------------------------------------------- |
|
469 void CFsTreeNodeVisualizerBase::SetIndentation( |
|
470 const TInt aIndentation ) |
|
471 { |
|
472 FUNC_LOG; |
|
473 iTextIndentation = aIndentation; |
|
474 } |
|
475 |
|
476 |
|
477 // --------------------------------------------------------------------------- |
|
478 // From MFsTreeItemVisualizer. |
|
479 // Sets item background color. |
|
480 // --------------------------------------------------------------------------- |
|
481 // |
|
482 void CFsTreeNodeVisualizerBase::SetBackgroundColor(const TRgb aColor) |
|
483 { |
|
484 FUNC_LOG; |
|
485 iBackgroundColor = aColor; |
|
486 iBackgroundState = EFsNodeBackgroundColor; |
|
487 } |
|
488 |
|
489 // --------------------------------------------------------------------------- |
|
490 // From MFsTreeItemVisualizer. |
|
491 // Returns background color if it's set. |
|
492 // --------------------------------------------------------------------------- |
|
493 // |
|
494 TBool CFsTreeNodeVisualizerBase::GetBackgroundColor( TRgb& aColor ) |
|
495 { |
|
496 FUNC_LOG; |
|
497 TBool retVal(EFalse); |
|
498 |
|
499 if ( iBackgroundState == EFsNodeBackgroundColor ) |
|
500 { |
|
501 aColor = iBackgroundColor; |
|
502 retVal = ETrue; |
|
503 } |
|
504 return retVal; |
|
505 } |
|
506 |
|
507 // --------------------------------------------------------------------------- |
|
508 // From MFsTreeItemVisualizer. |
|
509 // Sets item background texture. |
|
510 // --------------------------------------------------------------------------- |
|
511 // |
|
512 void CFsTreeNodeVisualizerBase::SetBackgroundTexture( |
|
513 const CAlfTexture& aTexture) |
|
514 { |
|
515 FUNC_LOG; |
|
516 iBackgroundTexture = &aTexture; |
|
517 iBackgroundState = EFsNodeBackgroundTexture; |
|
518 } |
|
519 |
|
520 // --------------------------------------------------------------------------- |
|
521 // From MFsTreeItemVisualizer. |
|
522 // Returns background texture if it's set. |
|
523 // --------------------------------------------------------------------------- |
|
524 // |
|
525 TBool CFsTreeNodeVisualizerBase::GetBackgroundTexture( const CAlfTexture*& aTexture ) |
|
526 { |
|
527 FUNC_LOG; |
|
528 TBool retVal(EFalse); |
|
529 if ( iBackgroundState == EFsNodeBackgroundTexture ) |
|
530 { |
|
531 aTexture = iBackgroundTexture; |
|
532 retVal = ETrue; |
|
533 } |
|
534 return retVal; |
|
535 } |
|
536 |
|
537 // <cmail> |
|
538 // --------------------------------------------------------------------------- |
|
539 // From MFsTreeItemVisualizer. |
|
540 // Sets item background brush. |
|
541 // --------------------------------------------------------------------------- |
|
542 // |
|
543 void CFsTreeNodeVisualizerBase::SetBackgroundBrush( CAlfBrush* aBrush ) |
|
544 { |
|
545 FUNC_LOG; |
|
546 iBackgroundBrush = aBrush; |
|
547 iBackgroundState = EFsNodeBackgroundBrush; |
|
548 } |
|
549 |
|
550 // --------------------------------------------------------------------------- |
|
551 // From MFsTreeItemVisualizer. |
|
552 // Returns item background brush and opacity. |
|
553 // --------------------------------------------------------------------------- |
|
554 // |
|
555 TBool CFsTreeNodeVisualizerBase::GetBackgroundBrush( CAlfBrush*& aBrush ) |
|
556 { |
|
557 FUNC_LOG; |
|
558 TBool retVal( EFalse ); |
|
559 if ( iBackgroundState == EFsNodeBackgroundBrush && iBackgroundBrush ) |
|
560 { |
|
561 aBrush = iBackgroundBrush; |
|
562 retVal = ETrue; |
|
563 } |
|
564 |
|
565 return retVal; |
|
566 } |
|
567 // </cmail> |
|
568 |
|
569 // --------------------------------------------------------------------------- |
|
570 // From MFsTreeItemVisualizer. |
|
571 // Clears item background. |
|
572 // --------------------------------------------------------------------------- |
|
573 // |
|
574 void CFsTreeNodeVisualizerBase::ClearBackground( ) |
|
575 { |
|
576 FUNC_LOG; |
|
577 iBackgroundState = EFsNodeBackgroundNone; |
|
578 } |
|
579 |
|
580 // --------------------------------------------------------------------------- |
|
581 // Returns reference to the item's main layout |
|
582 // --------------------------------------------------------------------------- |
|
583 // |
|
584 CAlfLayout& CFsTreeNodeVisualizerBase::Layout() const |
|
585 { |
|
586 FUNC_LOG; |
|
587 return (static_cast<CAlfLayout&>(*iLayout)); |
|
588 } |
|
589 |
|
590 // --------------------------------------------------------------------------- |
|
591 // Sets menu for item |
|
592 // --------------------------------------------------------------------------- |
|
593 // |
|
594 void CFsTreeNodeVisualizerBase::SetMenu( CFsTreeList* aMenu ) |
|
595 { |
|
596 FUNC_LOG; |
|
597 iMenu = aMenu; |
|
598 iFlags |= KFsTreeListItemHasMenu; |
|
599 } |
|
600 |
|
601 // --------------------------------------------------------------------------- |
|
602 // Returns CFsTreeList object contaning menu items |
|
603 // --------------------------------------------------------------------------- |
|
604 // |
|
605 CFsTreeList* CFsTreeNodeVisualizerBase::Menu() const |
|
606 { |
|
607 FUNC_LOG; |
|
608 return iMenu; |
|
609 } |
|
610 |
|
611 // --------------------------------------------------------------------------- |
|
612 // This functions sets wether an item should always be in extended state. |
|
613 // --------------------------------------------------------------------------- |
|
614 // |
|
615 void CFsTreeNodeVisualizerBase::SetAlwaysExtended( TBool aAlwaysExtended ) |
|
616 { |
|
617 FUNC_LOG; |
|
618 if ( aAlwaysExtended ) |
|
619 { |
|
620 iFlags |= KFsTreeListItemAlwaysExtended; |
|
621 } |
|
622 else |
|
623 { |
|
624 iFlags &= ~KFsTreeListItemAlwaysExtended; |
|
625 } |
|
626 } |
|
627 |
|
628 // --------------------------------------------------------------------------- |
|
629 // This function returns wether an item is always in extended state. |
|
630 // --------------------------------------------------------------------------- |
|
631 // |
|
632 TBool CFsTreeNodeVisualizerBase::IsAlwaysExtended( ) const |
|
633 { |
|
634 FUNC_LOG; |
|
635 return iFlags & KFsTreeListItemAlwaysExtended ? ETrue : EFalse; |
|
636 } |
|
637 |
|
638 |
|
639 // --------------------------------------------------------------------------- |
|
640 // From class MFsTreeItemVisualizer. |
|
641 // A call to this function means that the visualization of empty root |
|
642 // becomes visible and should draw itself within specified parent layout. |
|
643 // --------------------------------------------------------------------------- |
|
644 // |
|
645 void CFsTreeNodeVisualizerBase::ShowL( CAlfLayout& /*aParentLayout*/, |
|
646 const TUint /*aTimeout*/ ) |
|
647 { |
|
648 FUNC_LOG; |
|
649 } |
|
650 |
|
651 // --------------------------------------------------------------------------- |
|
652 // From class MFsTreeItemVisualizer. |
|
653 // Stub. |
|
654 // --------------------------------------------------------------------------- |
|
655 // |
|
656 void CFsTreeNodeVisualizerBase::UpdateL( const MFsTreeItemData& /*aData*/, |
|
657 TBool /*aFocused*/, |
|
658 const TUint /*aLevel*/, |
|
659 CAlfTexture*& /*aMarkIcon*/, |
|
660 CAlfTexture*& /*aMenuIcon*/, |
|
661 const TUint /*aTimeout*/, |
|
662 TBool /*aUpdateData*/) |
|
663 { |
|
664 FUNC_LOG; |
|
665 } |
|
666 |
|
667 // --------------------------------------------------------------------------- |
|
668 // From class MFsTreeItemVisualizer. |
|
669 // Stub. |
|
670 // --------------------------------------------------------------------------- |
|
671 // |
|
672 void CFsTreeNodeVisualizerBase::Hide( const TInt /*aTimeout*/ ) |
|
673 { |
|
674 FUNC_LOG; |
|
675 } |
|
676 |
|
677 |
|
678 // --------------------------------------------------------------------------- |
|
679 // From class MFsTreeItemVisualizer. |
|
680 // Stub. |
|
681 // --------------------------------------------------------------------------- |
|
682 // |
|
683 void CFsTreeNodeVisualizerBase::MarqueeL(const TFsTextMarqueeType /*aMarqueeType*/, |
|
684 const TUint /*aMarqueeSpeed*/, |
|
685 const TInt /*aMarqueeStartDelay*/, |
|
686 const TInt /*aMarqueeCycleStartDelay*/, |
|
687 const TInt /*aMarqueeRepetitions*/) |
|
688 { |
|
689 FUNC_LOG; |
|
690 } |
|
691 |
|
692 |
|
693 // --------------------------------------------------------------------------- |
|
694 // From MAlfEventHandler. Stub. |
|
695 // --------------------------------------------------------------------------- |
|
696 // |
|
697 TBool CFsTreeNodeVisualizerBase::OfferEventL(const TAlfEvent& /*aEvent*/) |
|
698 { |
|
699 FUNC_LOG; |
|
700 return EFalse; |
|
701 } |
|
702 |
|
703 |
|
704 // --------------------------------------------------------------------------- |
|
705 // Sets the text style manager for the item visualizer. |
|
706 // --------------------------------------------------------------------------- |
|
707 // |
|
708 void CFsTreeNodeVisualizerBase::SetTextStyleManager( |
|
709 CFsAlfTextStyleManager& aManager ) |
|
710 { |
|
711 FUNC_LOG; |
|
712 iTextStyleManager = &aManager; |
|
713 } |
|
714 |
|
715 |
|
716 // --------------------------------------------------------------------------- |
|
717 // Sets the text stroke weight for the item visualizer. |
|
718 // --------------------------------------------------------------------------- |
|
719 // |
|
720 void CFsTreeNodeVisualizerBase::SetTextBold( const TBool aIsBold ) |
|
721 { |
|
722 FUNC_LOG; |
|
723 if (aIsBold) |
|
724 { |
|
725 iFlags |= KFsTreeListItemTextBold; |
|
726 } |
|
727 else |
|
728 { |
|
729 iFlags &= ~KFsTreeListItemTextBold; |
|
730 } |
|
731 } |
|
732 |
|
733 |
|
734 // --------------------------------------------------------------------------- |
|
735 // Gets the text stroke weight for the item visualizer. |
|
736 // --------------------------------------------------------------------------- |
|
737 // |
|
738 TBool CFsTreeNodeVisualizerBase::IsTextBold( ) const |
|
739 { |
|
740 FUNC_LOG; |
|
741 return iFlags & KFsTreeListItemTextBold; |
|
742 } |
|
743 |
|
744 |
|
745 // --------------------------------------------------------------------------- |
|
746 // Function gets text color for a focused item. The color is taken from the |
|
747 // skin if skin support is on, if not then a default value is used. |
|
748 // --------------------------------------------------------------------------- |
|
749 // |
|
750 TRgb CFsTreeNodeVisualizerBase::FocusedStateTextSkinColor( ) |
|
751 { |
|
752 FUNC_LOG; |
|
753 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
754 TRgb textColor; |
|
755 // First try to get the FS specific text color |
|
756 if( AknsUtils::GetCachedColor( skin, textColor, |
|
757 KAknsIIDFsHighlightColors, EAknsCIFsHighlightColorsCG1 ) != KErrNone ) |
|
758 { |
|
759 // If FS specific text color not found, try to get the |
|
760 // normal Avkon list highlight text color |
|
761 if( AknsUtils::GetCachedColor( skin, textColor, |
|
762 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG10 ) != KErrNone ) |
|
763 { |
|
764 textColor = KRgbBlack; |
|
765 } |
|
766 } |
|
767 return textColor; |
|
768 } |
|
769 |
|
770 // --------------------------------------------------------------------------- |
|
771 // Function gets text color for a non focused item. The color is taken from |
|
772 // the skin if skin support is on, if not then a default value is used. |
|
773 // --------------------------------------------------------------------------- |
|
774 // |
|
775 TRgb CFsTreeNodeVisualizerBase::NormalStateTextSkinColor( ) |
|
776 { |
|
777 FUNC_LOG; |
|
778 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
779 TRgb textColor; |
|
780 if ( AknsUtils::GetCachedColor( skin, textColor, |
|
781 KAknsIIDFsTextColors, EAknsCIFsTextColorsCG3 ) != KErrNone ) |
|
782 { |
|
783 textColor = KRgbBlack; |
|
784 } |
|
785 return textColor; |
|
786 } |
|
787 |
|
788 // --------------------------------------------------------------------------- |
|
789 // Returns horizontal alignment of the displayed text in respect to current layout. |
|
790 // --------------------------------------------------------------------------- |
|
791 // |
|
792 TAlfAlignHorizontal CFsTreeNodeVisualizerBase::CurrentTextAlignmentL( TAlfAlignHorizontal aAlignment, |
|
793 TDesC* aText, |
|
794 CAlfTextVisual* aVisual) |
|
795 { |
|
796 FUNC_LOG; |
|
797 TAlfAlignHorizontal align (aAlignment); |
|
798 TBool isMirrored( EFalse ); |
|
799 |
|
800 isMirrored = CFsLayoutManager::IsMirrored(); |
|
801 |
|
802 if ( align == EAlfAlignHLocale ) |
|
803 { |
|
804 if ( aText && aVisual ) |
|
805 { |
|
806 TInt textWidth(0), visualWidth(0); |
|
807 textWidth = aVisual->SubstringExtents(0, aVisual->Text().Length()).Width(); |
|
808 visualWidth = aVisual->Size().Target().iX; |
|
809 |
|
810 if ( textWidth >= visualWidth ) |
|
811 { |
|
812 TBool found(EFalse); |
|
813 TBidiText * bidiText = TBidiText::NewL(aText->Length() + 1, 1); |
|
814 TBidiText::TDirectionality direction = bidiText->TextDirectionality( *aText, &found ); |
|
815 delete bidiText; |
|
816 if ( direction == TBidiText::ELeftToRight ) |
|
817 { |
|
818 align = EAlfAlignHLeft; |
|
819 } |
|
820 else |
|
821 { //direction == TBidiText::ERightToLeft |
|
822 align = EAlfAlignHRight; |
|
823 } |
|
824 } |
|
825 else |
|
826 { |
|
827 if ( isMirrored ) |
|
828 { |
|
829 align = EAlfAlignHRight; |
|
830 } |
|
831 else |
|
832 { |
|
833 align = EAlfAlignHLeft; |
|
834 } |
|
835 } |
|
836 } |
|
837 } |
|
838 else if ( isMirrored ) |
|
839 {//convert left <-> right in mirrored layout |
|
840 if ( align == EAlfAlignHLeft ) |
|
841 { |
|
842 align = EAlfAlignHRight; |
|
843 } |
|
844 else if ( align == EAlfAlignHRight ) |
|
845 { |
|
846 align = EAlfAlignHLeft; |
|
847 } |
|
848 } |
|
849 |
|
850 return align; |
|
851 } |
|
852 |
|
853 |
|
854 // --------------------------------------------------------------------------- |
|
855 // Returns text style id used in the node. |
|
856 // --------------------------------------------------------------------------- |
|
857 // |
|
858 TInt CFsTreeNodeVisualizerBase::ModifiedStyleIdL( ) const |
|
859 { |
|
860 FUNC_LOG; |
|
861 TInt styleId(iTextStyleId); |
|
862 TCharFormat charFormat; |
|
863 |
|
864 if ( iIsCustomTextStyle ) |
|
865 { |
|
866 CAlfTextStyle* textStyle( iOwnerControl.Env().TextStyleManager().TextStyle( styleId ) ); |
|
867 HBufC* name = textStyle->TypefaceNameL(); |
|
868 charFormat.iFontSpec.iTypeface.iName = name->Left( KMaxTypefaceNameLength ); |
|
869 delete name; |
|
870 |
|
871 charFormat.iFontSpec.iHeight = textStyle->TextSizeInTwips(); |
|
872 charFormat.iFontPresentation.iTextColor = textStyle->TextColor(); |
|
873 |
|
874 charFormat.iFontPresentation.iStrikethrough = textStyle->IsStrikeThrough() ? EStrikethroughOn : EStrikethroughOff; |
|
875 charFormat.iFontPresentation.iUnderline = textStyle->IsUnderline() ? EUnderlineOn : EUnderlineOff; |
|
876 |
|
877 } |
|
878 else |
|
879 { |
|
880 TRect parentRect( Size() ); |
|
881 CFsLayoutManager::TFsText text; |
|
882 |
|
883 CFsLayoutManager::LayoutMetricsText( parentRect,CFsLayoutManager::EFsLmListMediumLineT3T1, text, 0 ); |
|
884 |
|
885 charFormat.iFontSpec = text.iFont->FontSpecInTwips(); |
|
886 } |
|
887 |
|
888 |
|
889 TBool isBold(EFalse); |
|
890 isBold = iFlags & KFsTreeListItemTextBold; |
|
891 if ( isBold ) |
|
892 { |
|
893 charFormat.iFontSpec.iFontStyle.SetStrokeWeight( EStrokeWeightBold ); |
|
894 } |
|
895 else |
|
896 { |
|
897 charFormat.iFontSpec.iFontStyle.SetStrokeWeight( EStrokeWeightNormal ); |
|
898 } |
|
899 |
|
900 if ( iTextStyleManager ) |
|
901 { |
|
902 styleId = iTextStyleManager->GetStyleIDL( charFormat ); |
|
903 } |
|
904 |
|
905 return styleId; |
|
906 } |
|
907 |
|
908 |
|
909 // --------------------------------------------------------------------------- |
|
910 // Method to set text font height in twips. |
|
911 // --------------------------------------------------------------------------- |
|
912 // |
|
913 void CFsTreeNodeVisualizerBase::SetFontHeight(const TInt aHeightInTwips) |
|
914 { |
|
915 FUNC_LOG; |
|
916 iFontHeight = aHeightInTwips; |
|
917 } |
|
918 |
|
919 |
|
920 // --------------------------------------------------------------------------- |
|
921 // Gets height of a text font in twips. |
|
922 // --------------------------------------------------------------------------- |
|
923 // |
|
924 TInt CFsTreeNodeVisualizerBase::FontHeight() const |
|
925 { |
|
926 FUNC_LOG; |
|
927 return iFontHeight; |
|
928 } |
|
929 |
|
930 |
|
931 // --------------------------------------------------------------------------- |
|
932 // Method to set text font height in pixels. |
|
933 // --------------------------------------------------------------------------- |
|
934 // |
|
935 void CFsTreeNodeVisualizerBase::SetFontHeightInPixels(const TInt aHeightInPixels) |
|
936 { |
|
937 FUNC_LOG; |
|
938 TZoomFactor devicemap(CCoeEnv::Static()->ScreenDevice()); |
|
939 devicemap.SetZoomFactor(TZoomFactor::EZoomOneToOne); |
|
940 TInt heightInTwips = devicemap.VerticalPixelsToTwips(aHeightInPixels); |
|
941 |
|
942 iFontHeight = heightInTwips; |
|
943 } |
|
944 |
|
945 |
|
946 // --------------------------------------------------------------------------- |
|
947 // Gets height of a text font in pixels. |
|
948 // --------------------------------------------------------------------------- |
|
949 // |
|
950 TInt CFsTreeNodeVisualizerBase::FontHeightInPixels() const |
|
951 { |
|
952 FUNC_LOG; |
|
953 TZoomFactor devicemap(CCoeEnv::Static()->ScreenDevice()); |
|
954 devicemap.SetZoomFactor(TZoomFactor::EZoomOneToOne); |
|
955 |
|
956 return devicemap.VerticalTwipsToPixels(iFontHeight); |
|
957 } |
|
958 |
|
959 |
|
960 // --------------------------------------------------------------------------- |
|
961 // Second phase constructor. |
|
962 // --------------------------------------------------------------------------- |
|
963 // |
|
964 void CFsTreeNodeVisualizerBase::ConstructL( ) |
|
965 { |
|
966 FUNC_LOG; |
|
967 //get default skin values |
|
968 iNormalTextColor = NormalStateTextSkinColor(); |
|
969 iFocusedTextColor = FocusedStateTextSkinColor(); |
|
970 } |
|
971 |
|
972 |
|
973 // --------------------------------------------------------------------------- |
|
974 // From class MFsTreeNodeVisualizer. |
|
975 // Sets visualized node's state to rolled/unrolled. |
|
976 // --------------------------------------------------------------------------- |
|
977 // |
|
978 void CFsTreeNodeVisualizerBase::SetExpanded( TBool aFlag, const MFsTreeItemData* /*aData*/ ) |
|
979 { |
|
980 FUNC_LOG; |
|
981 if ( aFlag ) |
|
982 { |
|
983 iFlags |= KFsTreeListNodeExpanded; |
|
984 } |
|
985 else |
|
986 { |
|
987 iFlags &= ~KFsTreeListNodeExpanded; |
|
988 } |
|
989 } |
|
990 |
|
991 |
|
992 // --------------------------------------------------------------------------- |
|
993 // From class MFsTreeNodeVisualizer. |
|
994 // Returns rolled/unrolled state of the node's visualization. |
|
995 // --------------------------------------------------------------------------- |
|
996 // |
|
997 TBool CFsTreeNodeVisualizerBase::IsExpanded() const |
|
998 { |
|
999 FUNC_LOG; |
|
1000 return iFlags & KFsTreeListNodeExpanded ? ETrue : EFalse; |
|
1001 } |
|
1002 |
|
1003 |
|
1004 // --------------------------------------------------------------------------- |
|
1005 // C++ constructor. |
|
1006 // --------------------------------------------------------------------------- |
|
1007 // |
|
1008 CFsTreeNodeVisualizerBase::CFsTreeNodeVisualizerBase( |
|
1009 CAlfControl& aOwnerControl) |
|
1010 : iOwnerControl(aOwnerControl), |
|
1011 iLayout(NULL), |
|
1012 iFlags(KFsTreeListNodeExpanded|KFsTreeListItemFocusable| |
|
1013 KFsTreeListItemManagedLayout), |
|
1014 iTextAlign( EAlfAlignHLocale ), |
|
1015 iTextIndentation( KFsDefaultIndentation ), |
|
1016 iIsCustomTextNormalColor(EFalse), |
|
1017 iIsCustomTextFocusedColor(EFalse), |
|
1018 iTextStyleId ( EAlfTextStyleNormal ), |
|
1019 iIsCustomTextStyle( EFalse ), |
|
1020 iFontHeight(0), |
|
1021 iBackgroundState( EFsNodeBackgroundNone ) |
|
1022 { |
|
1023 FUNC_LOG; |
|
1024 |
|
1025 } |
|
1026 |
|
1027 // --------------------------------------------------------------------------- |
|
1028 // Set layouting hints |
|
1029 // --------------------------------------------------------------------------- |
|
1030 // |
|
1031 void CFsTreeNodeVisualizerBase::SetLayoutHints( const TUint aHints ) |
|
1032 { |
|
1033 FUNC_LOG; |
|
1034 iLayoutHints |= aHints; |
|
1035 } |
|
1036 |
|
1037 // --------------------------------------------------------------------------- |
|
1038 // Check if hint is set |
|
1039 // --------------------------------------------------------------------------- |
|
1040 // |
|
1041 TBool CFsTreeNodeVisualizerBase::IsLayoutHintSet( const TLayoutHint aHint ) const |
|
1042 { |
|
1043 FUNC_LOG; |
|
1044 return iLayoutHints & aHint; |
|
1045 } |