|
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 item visualizer. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef FSTREEITEMVISUALIZERBASE_H_ |
|
20 #define FSTREEITEMVISUALIZERBASE_H_ |
|
21 |
|
22 #include <e32base.h> |
|
23 //<cmail> removed __FS_ALFRED_SUPPORT flag |
|
24 //#include <fsconfig.h> |
|
25 //</cmail> removed __FS_ALFRED_SUPPORT flag |
|
26 // <cmail> SF |
|
27 #include <alf/alfeventhandler.h> |
|
28 // </cmail> |
|
29 #include "fstreeitemvisualizer.h" |
|
30 #include "fslayoutmanager.h" |
|
31 |
|
32 class TRgb; |
|
33 |
|
34 class CAlfLayout; |
|
35 class CAlfTexture; |
|
36 class CAlfBrush; |
|
37 class CAlfAnchorLayout; |
|
38 class CAlfControl; |
|
39 class CFsAlfTextStyleManager; |
|
40 class CAlfTextVisual; |
|
41 |
|
42 |
|
43 /** |
|
44 * CFsTreeItemVisualizerBase is a base class implementing methods common for |
|
45 * all tree items. |
|
46 * |
|
47 * Thic class is a concrete implementation for the MFsTreeItemVisualizer |
|
48 * interface. |
|
49 * |
|
50 * @code |
|
51 * |
|
52 * @endcode |
|
53 * |
|
54 * @lib |
|
55 */ |
|
56 NONSHARABLE_CLASS(CFsTreeItemVisualizerBase) : public CBase, |
|
57 public MFsTreeItemVisualizer, |
|
58 public MAlfEventHandler |
|
59 { |
|
60 |
|
61 public: |
|
62 |
|
63 /** |
|
64 * C++ destructor |
|
65 */ |
|
66 virtual ~CFsTreeItemVisualizerBase(); |
|
67 |
|
68 |
|
69 public: |
|
70 |
|
71 /** |
|
72 * Returns the type of the item's visualizer. |
|
73 */ |
|
74 virtual TFsTreeItemVisualizerType Type() const; |
|
75 |
|
76 /** |
|
77 * Sets horizontal alignment of the displayed plain text. |
|
78 * |
|
79 * For AH layout EAlfAlignHLeft is internally converted to EAlfAlignHRight |
|
80 * and EAlfAlignHRight is converted to EAlfAlignHLeft. |
|
81 * |
|
82 * EAlfAlignHLocale (default setting) - alignment set according to text directionality |
|
83 * |
|
84 * @param aAlign Horizontal text alignment type. |
|
85 */ |
|
86 virtual void SetTextAlign( const TAlfAlignHorizontal aAlign ); |
|
87 |
|
88 /** |
|
89 * The function sets item's text color for the focused state. |
|
90 * |
|
91 * @param aColor New color to be set. |
|
92 */ |
|
93 virtual void SetFocusedStateTextColor( TRgb& aColor ); |
|
94 |
|
95 /** |
|
96 * The function returns item's text color for the focused state. |
|
97 */ |
|
98 virtual TRgb FocusedStateTextColor() const; |
|
99 |
|
100 /** |
|
101 * The function sets item's text color for the normal (unfocused) state. |
|
102 * |
|
103 * @param aColor New color to be set. |
|
104 */ |
|
105 virtual void SetNormalStateTextColor( TRgb& aColor ); |
|
106 |
|
107 /** |
|
108 * The function returns item's text color for the normal (unfocused) state |
|
109 */ |
|
110 virtual TRgb NormalStateTextColor() const; |
|
111 |
|
112 /** |
|
113 * The function sets the style of item's text. |
|
114 * |
|
115 * @param aTextStyleId Text style ID provided by the text style manager. |
|
116 */ |
|
117 virtual void SetTextStyleId ( const TInt aTextStyleId ); |
|
118 |
|
119 /** |
|
120 * The function returns the style of item's text. |
|
121 * |
|
122 * @return Text style ID provided by the text style manager. |
|
123 */ |
|
124 virtual TInt TextStyleId () const; |
|
125 |
|
126 /** |
|
127 * From MFsTreeItemVisualizer. |
|
128 * Sets multiple flags for an item at one time. |
|
129 * |
|
130 * @param aFlags Flags for item visualizer. |
|
131 */ |
|
132 virtual void SetFlags( TUint32 aFlags ); |
|
133 |
|
134 /** |
|
135 * From MFsTreeItemVisualizer. |
|
136 * Returns flags of the item visualizer. |
|
137 * |
|
138 * @return Item visualizer's flags value. |
|
139 */ |
|
140 virtual TUint32 Flags(); |
|
141 |
|
142 /** |
|
143 * From MFsTreeItemVisualizer. |
|
144 * Sets visualized item's state to marked/unmarked. |
|
145 * |
|
146 * @param aFlag ETrue to visualize item as marked. |
|
147 */ |
|
148 virtual void SetMarked( TBool aFlag ); |
|
149 |
|
150 /** |
|
151 * From MFsTreeItemVisualizer. |
|
152 * Returns mark/unmark state of the item's visualization. |
|
153 * |
|
154 * @return ETrue if item is visualized as marked. |
|
155 */ |
|
156 virtual TBool IsMarked() const; |
|
157 |
|
158 /** |
|
159 * From MFsTreeItemVisualizer. |
|
160 * Sets visualized item's state to dimmed/not dimmed. |
|
161 * |
|
162 * @param aFlag ETrue to visualize item as dimmed. |
|
163 */ |
|
164 virtual void SetDimmed( TBool aFlag ); |
|
165 |
|
166 /** |
|
167 * From MFsTreeItemVisualizer. |
|
168 * Returns dimmed/not dimmed state of the item's visualization. |
|
169 * |
|
170 * @return ETrue if item is visualized as dimmed. |
|
171 */ |
|
172 virtual TBool IsDimmed() const; |
|
173 |
|
174 /** |
|
175 * From MFsTreeItemVisualizer. |
|
176 * Sets the size of the item visualization when item is not in expanded |
|
177 * state. |
|
178 * |
|
179 * @param aSize Size in pixels of the an when it is not expanded. |
|
180 */ |
|
181 virtual void SetSize( const TSize aSize ); |
|
182 |
|
183 /** |
|
184 * From MFsTreeItemVisualizer. |
|
185 * Returns the size of an item in a normal (not extended) state. |
|
186 * |
|
187 * @return Size in pixels of an item when it is not extended. |
|
188 */ |
|
189 virtual TSize Size() const; |
|
190 |
|
191 /** |
|
192 * From MFsTreeItemVisualizer. |
|
193 * Sets the item's visualization state to expanded. This state is used to |
|
194 * preview more data of an item. |
|
195 * |
|
196 * @param aFlag ETrue to visualize item as expanded. |
|
197 */ |
|
198 virtual void SetExtended( const TBool aFlag ); |
|
199 |
|
200 /** |
|
201 * From MFsTreeItemVisualizer. |
|
202 * Returns expanded/not expanded state of the item visualization. |
|
203 * |
|
204 * @return ETrue if item is visualized as expanded. |
|
205 */ |
|
206 virtual TBool IsExtended() const; |
|
207 |
|
208 /** |
|
209 * From MFsTreeItemVisualizer. |
|
210 * Sets if an item can be in expanded state or not. |
|
211 * |
|
212 * @param aFlag ETrue if item can be in expanded state. |
|
213 */ |
|
214 virtual void SetExtendable( TBool aFlag ); |
|
215 |
|
216 /** |
|
217 * From MFsTreeItemVisualizer. |
|
218 * Returns an information if item can be in expanded state. |
|
219 * |
|
220 * @return ETrue if item can be in expanded state. |
|
221 */ |
|
222 virtual TBool IsExtendable( ); |
|
223 |
|
224 /** |
|
225 * From MFsTreeItemVisualizer |
|
226 * Returns an information if item can be focused. |
|
227 * |
|
228 * @return ETrue if item can be focused. |
|
229 */ |
|
230 virtual TBool IsFocusable( ) const; |
|
231 |
|
232 /** |
|
233 * From MFsTreeItemVisualizer |
|
234 * Used to set/unset item's ability to receive focus. |
|
235 * |
|
236 * @param aFlag ETrue if item can be focused. |
|
237 */ |
|
238 virtual void SetFocusable( const TBool aFlag ); |
|
239 |
|
240 /** |
|
241 * From MFsTreeItemVisualizer. |
|
242 * Sets the size of the item visualization area when item is in expanded |
|
243 * state. |
|
244 * |
|
245 * @param aSize Size in pixels of the item when it is expanded. |
|
246 */ |
|
247 virtual void SetExtendedSize( const TSize aSize ); |
|
248 |
|
249 /** |
|
250 * From MFsTreeItemVisualizer. |
|
251 * Returns the size of an item in expanded state. |
|
252 * |
|
253 * @return Size in pixels of the item when it is in expanded state. |
|
254 */ |
|
255 virtual TSize ExtendedSize() const; |
|
256 |
|
257 /** |
|
258 * From MFsTreeItemVisualizer. |
|
259 * Sets visualized item's state to hidden/visible. |
|
260 * |
|
261 * @param ETrue if item should be visualized as hidden. |
|
262 */ |
|
263 virtual void SetHidden( TBool aFlag ); |
|
264 |
|
265 /** |
|
266 * From MFsTreeItemVisualizer. |
|
267 * Returns an information if the item is hidden or not. |
|
268 * |
|
269 * @return ETrue if item is hiddden, EFalse if item is visible. |
|
270 */ |
|
271 virtual TBool IsHidden() ; |
|
272 |
|
273 /** |
|
274 * From MFsTreeItemVisualizer. |
|
275 * Enables or disables text shadow. |
|
276 * |
|
277 * @param aShadowOn Pass ETrue if shadow should be enabled |
|
278 * EFalse otherwise. |
|
279 */ |
|
280 virtual void EnableTextShadow( const TBool aShadowOn = ETrue ); |
|
281 |
|
282 /** |
|
283 * From MFsTreeItemVisualizer. |
|
284 * Sets text indentation. |
|
285 * |
|
286 * @param aIndentation Indentation in pixels. |
|
287 */ |
|
288 virtual void SetIndentation( const TInt aIndentation = 0 ); |
|
289 |
|
290 /** |
|
291 * From MFsTreeItemVisualizer. |
|
292 * Sets item background color. |
|
293 * |
|
294 * @param aColor New background color. |
|
295 */ |
|
296 virtual void SetBackgroundColor( const TRgb aColor ); |
|
297 |
|
298 /** |
|
299 * From MFsTreeItemVisualizer. |
|
300 * Returns background color if it's set. |
|
301 * |
|
302 * @param aColor Out parameter. Contains background color. |
|
303 * |
|
304 * @return ETrue if background color is set, EFalse otherwise. |
|
305 */ |
|
306 virtual TBool GetBackgroundColor( TRgb& aColor ); |
|
307 |
|
308 /** |
|
309 * From MFsTreeItemVisualizer. |
|
310 * Sets item background texture. |
|
311 * |
|
312 * @param aTexture New background texture. |
|
313 */ |
|
314 virtual void SetBackgroundTexture( const CAlfTexture& aTexture ); |
|
315 |
|
316 // <cmail> |
|
317 /** |
|
318 * From MFsTreeItemVisualizer. |
|
319 * Sets item background brush. Ownership not transfered. |
|
320 * |
|
321 * @param aBrush New background brush. |
|
322 */ |
|
323 virtual void SetBackgroundBrush( CAlfBrush* aBrush ); |
|
324 |
|
325 /** |
|
326 * From MFsTreeItemVisualizer. |
|
327 * Returns item background brush. |
|
328 * |
|
329 * @param aBrush Out parameter. Contains pointer to a background brush. |
|
330 * |
|
331 * @return ETrue if background brush is set, EFalse otherwise. |
|
332 */ |
|
333 virtual TBool GetBackgroundBrush( CAlfBrush*& aBrush ); |
|
334 // </cmail> |
|
335 |
|
336 /** |
|
337 * From MFsTreeItemVisualizer. |
|
338 * Returns background texture if it's set. |
|
339 * |
|
340 * @param aTexture Out parameter. Contains pointer to a texture. |
|
341 * |
|
342 * @return ETrue if background texture is set, EFalse otherwise. |
|
343 */ |
|
344 virtual TBool GetBackgroundTexture( const CAlfTexture*& aTexture ); |
|
345 |
|
346 /** |
|
347 * From MFsTreeItemVisualizer. |
|
348 * Clears item background. |
|
349 */ |
|
350 virtual void ClearBackground( ); |
|
351 |
|
352 /** |
|
353 * Sets menu for item |
|
354 * @param aMenu CTreeList object containing menu items |
|
355 */ |
|
356 virtual void SetMenu( CFsTreeList* aMenu ); |
|
357 |
|
358 /** |
|
359 * Returns CFsTreeList object contaning menu items |
|
360 * @return Menu for item. |
|
361 */ |
|
362 virtual CFsTreeList* Menu() const; |
|
363 |
|
364 /** |
|
365 * This functions sets wether an item should always be in extended state. |
|
366 * |
|
367 * @param ETrue if item should always be in extended state. |
|
368 */ |
|
369 virtual void SetAlwaysExtended( TBool aAlwaysExtended ); |
|
370 |
|
371 /** |
|
372 * This function returns wether an item is always in extended state. |
|
373 * |
|
374 * @return ETrue if item is always in extended state. |
|
375 */ |
|
376 virtual TBool IsAlwaysExtended( ) const; |
|
377 |
|
378 /** |
|
379 * Sets the text style manager for the item visualizer. |
|
380 * |
|
381 * @param aManager Reference to the text style manager. |
|
382 */ |
|
383 virtual void SetTextStyleManager( CFsAlfTextStyleManager& aManager ); |
|
384 |
|
385 /** |
|
386 * Sets the text stroke weight for the item visualizer. |
|
387 * |
|
388 * @param aIsBold ETrue if the text shoul be bold. |
|
389 */ |
|
390 virtual void SetTextBold( const TBool aIsBold ); |
|
391 |
|
392 /** |
|
393 * Method to set text font height in twips. |
|
394 * |
|
395 * @param aHeightInTwips Text font height to be set. |
|
396 */ |
|
397 virtual void SetFontHeight(const TInt aHeightInTwips); |
|
398 |
|
399 /** |
|
400 * Gets height of a text font in twips. |
|
401 * |
|
402 * @return Height of the font in twips |
|
403 */ |
|
404 virtual TInt FontHeight() const; |
|
405 |
|
406 /** |
|
407 * Method to set text font height in pixels. |
|
408 * |
|
409 * @param aHeightInPixels Text font height to be set. |
|
410 */ |
|
411 virtual void SetFontHeightInPixels(const TInt aHeightInPixels); |
|
412 |
|
413 /** |
|
414 * Gets height of a text font in pixels. |
|
415 * |
|
416 * @return Height of the font in pixels. |
|
417 */ |
|
418 virtual TInt FontHeightInPixels() const; |
|
419 |
|
420 /** |
|
421 * Gets the text stroke weight for the item visualizer. |
|
422 * |
|
423 * @return ETrue if the text is be bold. |
|
424 */ |
|
425 virtual TBool IsTextBold( ) const; |
|
426 |
|
427 /** |
|
428 * |
|
429 */ |
|
430 virtual CAlfLayout& Layout() const; |
|
431 |
|
432 /** |
|
433 * |
|
434 */ |
|
435 virtual void ShowL( CAlfLayout& aParentLayout, |
|
436 const TUint aTimeout = 0 ); |
|
437 |
|
438 /** |
|
439 * |
|
440 */ |
|
441 virtual void UpdateL( const MFsTreeItemData& aData, |
|
442 TBool aFocused, |
|
443 const TUint aLevel, |
|
444 CAlfTexture*& aMarkIcon, |
|
445 CAlfTexture*& aMenuIcon, |
|
446 const TUint aTimeout = 0, |
|
447 TBool aUpdateData = ETrue); |
|
448 |
|
449 /** |
|
450 * |
|
451 */ |
|
452 virtual void Hide( const TInt aTimeout = 0 ); |
|
453 |
|
454 /** |
|
455 * From MFsTreeItemVisualizer. |
|
456 * This method marquees the text in tree item if it is too long. |
|
457 * |
|
458 * @param aMarqueeType Type of marquee. |
|
459 * @param aMarqueeSpeed Speed of marquee in pixels per second. |
|
460 * @param aMarqueeStartDelay Marquee's start delay in miliseconds. |
|
461 * @param aMarqueeCycleStartDelay Marquee cycle's start delay. |
|
462 * @param aMarqueeRepetitions Number of marquee's cycles. |
|
463 */ |
|
464 virtual void MarqueeL(const TFsTextMarqueeType aMarqueeType, |
|
465 const TUint aMarqueeSpeed, |
|
466 const TInt aMarqueeStartDelay, |
|
467 const TInt aMarqueeCycleStartDelay, |
|
468 const TInt aMarqueeRepetitions); |
|
469 |
|
470 /** |
|
471 * From MAlfEventHandler. |
|
472 * Called when an input event is being offered to this object. |
|
473 */ |
|
474 virtual TBool OfferEventL(const TAlfEvent& aEvent); |
|
475 |
|
476 public: |
|
477 |
|
478 /* |
|
479 * Layouting hints for the visualizers. Hints are binary flags so they can be mixed. |
|
480 */ |
|
481 enum TLayoutHint |
|
482 { |
|
483 ENormalLayout = 0, |
|
484 // Use folder layout for item visualizers |
|
485 EFolderLayout = (1<<0), |
|
486 // Item visualizers are in popup |
|
487 EPopupLayout = (1<<1) |
|
488 }; |
|
489 |
|
490 public: |
|
491 |
|
492 /** |
|
493 * Set layout hint(s). Given hints are ORed so previously set flags will remain. |
|
494 */ |
|
495 virtual void SetLayoutHints( const TUint aHints ); |
|
496 |
|
497 /** |
|
498 * Check if given layout hint is set. |
|
499 */ |
|
500 virtual TBool IsLayoutHintSet( const TLayoutHint aHint ) const; |
|
501 |
|
502 protected: |
|
503 |
|
504 /** |
|
505 * C++ constructor |
|
506 */ |
|
507 CFsTreeItemVisualizerBase(CAlfControl& aOwnerControl); |
|
508 |
|
509 /** |
|
510 * Second phase constructor |
|
511 * |
|
512 */ |
|
513 void ConstructL( ); |
|
514 |
|
515 protected: |
|
516 |
|
517 /** |
|
518 * Function gets text color for a focused item. The color is taken from |
|
519 * the skin if skin support is on, if not then a default value is used. |
|
520 * |
|
521 * @return aTextColor Text's color. |
|
522 */ |
|
523 virtual TRgb FocusedStateTextSkinColor( ); |
|
524 |
|
525 /** |
|
526 * Function gets text color for a non focused item. The color is taken |
|
527 * from the skin if skin support is on, if not then a default value is |
|
528 * used. |
|
529 * |
|
530 * @return aTextColor Text's color. |
|
531 */ |
|
532 virtual TRgb NormalStateTextSkinColor( ); |
|
533 |
|
534 /** |
|
535 * Returns horizontal alignment of the displayed text in respect to |
|
536 * current layout. |
|
537 * |
|
538 * For AH layout EAlfAlignHLeft is internally converted to EAlfAlignHRight |
|
539 * and EAlfAlignHRight is converted to EAlfAlignHLeft. |
|
540 * |
|
541 * @param aAlign Horizontal text alignment type. |
|
542 */ |
|
543 virtual TAlfAlignHorizontal CurrentTextAlignmentL( TAlfAlignHorizontal aAlignment, |
|
544 TDesC* aText, |
|
545 CAlfTextVisual* aVisual); |
|
546 |
|
547 |
|
548 /** |
|
549 * Returns text style id used in the item. |
|
550 */ |
|
551 virtual TInt ModifiedStyleIdL( ) const; |
|
552 |
|
553 protected: |
|
554 |
|
555 /** |
|
556 * State of the background: clear, color, texture. |
|
557 */ |
|
558 enum TFsItemBackgroundState |
|
559 { |
|
560 EFsItemBackgroundNone, |
|
561 EFsItemBackgroundColor, |
|
562 EFsItemBackgroundTexture, |
|
563 // <cmail> this feature is waiting for title divider bg graphics |
|
564 EFsItemBackgroundBrush |
|
565 // </cmail> |
|
566 }; |
|
567 |
|
568 protected: |
|
569 |
|
570 /* |
|
571 * A parent control for the tree visualizer. |
|
572 */ |
|
573 CAlfControl& iOwnerControl; |
|
574 |
|
575 /* |
|
576 * Parent layout of the item layout, typically list layout. |
|
577 * Not own. |
|
578 */ |
|
579 CAlfLayout* iParentLayout; |
|
580 |
|
581 /** |
|
582 * Main layout for the plain text item. |
|
583 * Own. |
|
584 */ |
|
585 CAlfAnchorLayout* iLayout; |
|
586 |
|
587 /* |
|
588 * Visualizer's state flag. |
|
589 */ |
|
590 TUint32 iFlags; |
|
591 |
|
592 /* |
|
593 * Horizontal text alignment in visual. |
|
594 */ |
|
595 TAlfAlignHorizontal iTextAlign; |
|
596 |
|
597 /* |
|
598 * Item's size. |
|
599 */ |
|
600 TSize iSize; |
|
601 |
|
602 /* |
|
603 * Item's extended size. |
|
604 */ |
|
605 TSize iExtendedSize; |
|
606 |
|
607 /** |
|
608 * CFsTreeList containing menu for item |
|
609 */ |
|
610 CFsTreeList* iMenu; |
|
611 |
|
612 /** |
|
613 * Text indetation in pixels. |
|
614 */ |
|
615 TInt iTextIndentation; |
|
616 |
|
617 /** |
|
618 * Custom color set for a text in normal state. |
|
619 * ETrue custom color set, EFalse use color from the skin. |
|
620 */ |
|
621 TBool iIsCustomTextNormalColor; |
|
622 |
|
623 /** |
|
624 * Text's color in normal (unfocused) state. |
|
625 */ |
|
626 TRgb iNormalTextColor; |
|
627 |
|
628 /** |
|
629 * Custom color set for a text in focused state. |
|
630 * ETrue custom color set, EFalse use color from the skin. |
|
631 */ |
|
632 TBool iIsCustomTextFocusedColor; |
|
633 |
|
634 /** |
|
635 * Text's color in focused state. |
|
636 */ |
|
637 TRgb iFocusedTextColor; |
|
638 |
|
639 /** |
|
640 * Text's style. The id comes from CAlfTextStyleManager. |
|
641 */ |
|
642 TInt iTextStyleId; |
|
643 |
|
644 /** |
|
645 * ETrue if custom text style is used. EFalse text style taken from layout manager. |
|
646 */ |
|
647 TBool iIsCustomTextStyle; |
|
648 |
|
649 /** |
|
650 * Item's text style manager. |
|
651 */ |
|
652 CFsAlfTextStyleManager* iTextStyleManager; |
|
653 |
|
654 /** |
|
655 * Font height |
|
656 */ |
|
657 TInt iFontHeight; |
|
658 |
|
659 /** |
|
660 * State of the background: clear, color, texture. |
|
661 */ |
|
662 TFsItemBackgroundState iBackgroundState; |
|
663 |
|
664 /* |
|
665 * Background color. |
|
666 */ |
|
667 TRgb iBackgroundColor; |
|
668 |
|
669 /** |
|
670 * Background texture. |
|
671 * Not own. |
|
672 */ |
|
673 const CAlfTexture* iBackgroundTexture; |
|
674 |
|
675 /** |
|
676 * Background brush. |
|
677 * Not own. |
|
678 */ |
|
679 CAlfBrush* iBackgroundBrush; |
|
680 |
|
681 /** |
|
682 * Layouting hints. @see CFsTreeItemVisualizerBase::TLayoutHint |
|
683 */ |
|
684 TUint iLayoutHints; |
|
685 }; |
|
686 |
|
687 #endif /*FSTREEITEMVISUALIZERBASE_H_*/ |