2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
18 #if !defined(__EIKCLBD_H__)
26 #include <babitflags.h> // for TBitFlags32
30 class CColumnListBoxDataExtension;
31 class MAknsControlContext;
34 class CAknsEffectAnim;
35 class CAknsListBoxBackgroundControlContext;
37 class TAknWindowLineLayout;
38 class TAknTextLineLayout;
39 class TAknWindowComponentLayout;
40 class TAknTextComponentLayout;
41 class MAknsSkinInstance;
44 * A callback interface for overriding highlight animation input layer
45 * preparation in derived classes. Usually drawing the background under the
46 * highlight rect will yield the right kind of result. The size of the render
47 * target is equal to item cell size.
51 class MColumnListBoxAnimBackgroundDrawer
56 * Draws the background under the current highlight.
58 * Should be implemented in the derived class .
60 * @param aGc bitmapped graphics context to be drawn.
61 * @return @c ETrue if Succeeded.
63 virtual TBool DrawHighlightAnimBackground( CFbsBitGc& aGc ) const = 0;
67 * The @c CColumnListBoxData class handles the data required to draw a column
70 * The class performs drawing for @c CColumnListBoxItemDrawer. Columns are
71 * numbered from 0 from left to right, and extra column data can be set
74 * N.B.: The standard width of a column drawn by @c CColumnListListBoxData is
75 * 0 pixels, so at the very least a column width should be set for each column
76 * in a column list box.
78 * This class is not intended for user derivation.
80 class CColumnListBoxData : public CListBoxData
82 friend class CColumnListBoxDataExtension;
86 * Represents the colours used within the border and for the optional
87 * single pixel border outlines.
89 * These colours are stored using @c TRgb values.
96 * C++ default constructor.
107 * Stores background color.
112 * Stores highLighted text color.
114 TRgb iHighlightedText;
117 * Stores highlighted background colour.
119 TRgb iHighlightedBack;
125 * Two-phased constructor.
127 * Allocates and constructs a column list box data object.
129 * Constructs an array in which the column data is held.
131 * @return New @c CColumnListBoxData.
133 IMPORT_C static CColumnListBoxData* NewL();
138 IMPORT_C ~CColumnListBoxData();
143 * Gets the index of the last defined column.
145 * @return The index of the last defined column or @c KErrNotFound if no
146 * column has been defined.
148 IMPORT_C TInt LastColumn() const;
151 * Gets the specified column’s width in pixels.
153 * @param aColumn The index of the column for which the width is obtained.
154 * @return The specified column’s width in pixels. Zero is returned if no
155 * column exists at the specified index.
157 IMPORT_C TInt ColumnWidthPixel(TInt aColumn) const;
160 * Sets the specified column’s width in pixels.
162 * If the column does not exist, one is added at the specified index,
163 * with the specifed width.
165 * @param aColumn The index of the column for which the width is to be set.
166 * @param aWidth The width in pixels.
168 IMPORT_C void SetColumnWidthPixelL(TInt aColumn,TInt aWidth);
173 IMPORT_C TInt ColumnHorizontalGap(TInt aColumn) const;
178 IMPORT_C void SetColumnHorizontalGapL(TInt aColumn,TInt aGap);
181 * Gets column's baseline.
183 * @param aColumn target column.
184 * @return Vertical position.
186 IMPORT_C TInt ColumnBaselinePos(TInt aColumn) const;
189 * Sets columns baseline position.
191 * @param aColumn Target column.
192 * @param aPos Wanted position.
194 IMPORT_C void SetColumnBaselinePosL(TInt aColumn,TInt aPos);
197 * Gets column's margins.
199 * @param aColumn Target column.
200 * @return The columns margins.
202 IMPORT_C TMargins ColumnMargins(TInt aColumn) const;
205 * Sets column's margins.
207 * @param aColumn Target column.
208 * @param aMargins Wanted margins.
210 IMPORT_C void SetColumnMarginsL(TInt aColumn,TMargins aMargins);
213 * Gets font used by the column.
215 * @param aColumn Target column.
218 IMPORT_C const CFont* ColumnFont(TInt aColumn) const;
221 * Sets column's font.
223 * @param aColumn Target column.
224 * @param aFont Wanted font.
226 IMPORT_C void SetColumnFontL(TInt aColumn,const CFont* aFont);
229 * Gets the text alignment for the specified column.
231 * @param aColumn The index of the column for which the alignment
233 * @return The text alignment for the specified column. The default
236 IMPORT_C CGraphicsContext::TTextAlign ColumnAlignment(TInt aColumn) const;
239 * Sets the text alignment for the specified column.
241 * If the column does not exist, it is added with the specified index
244 * @param aColumn The index of the column for which alignment is set.
245 * @param aAlign The text alignment to use. The default is @c ELeft.
247 IMPORT_C void SetColumnAlignmentL(TInt aColumn,
248 CGraphicsContext::TTextAlign aAlign);
253 IMPORT_C CGraphicsContext::TPenStyle ColumnSeparatorStyle(
258 IMPORT_C void SetColumnSeparatorStyleL(TInt aColumn,
259 CGraphicsContext::TPenStyle aStyle);
262 * Checks whether the column is optional.
264 * @param aColumn Target column.
265 * @return @c ETrue if the column is optional.
267 IMPORT_C TBool ColumnIsOptional(TInt aColumn) const;
270 * Sets whether the column is optional.
272 * @param aColumn Target column.
273 * @param aIsOptional Wanted setting, @c ETrue if column is optional.
275 IMPORT_C void SetOptionalColumnL(TInt aColumn,TBool aIsOptional);
278 * Checks whether the column contains graphics.
280 * @param aColumn Target column.
281 * @return @c ETrue if column contains graphics.
283 IMPORT_C TBool ColumnIsGraphics(TInt aColumn) const;
286 * Sets whether the column shows graphics.
288 * @param aColumn Target column.
289 * @param aIsGraphics Wanted setting.
291 IMPORT_C void SetGraphicsColumnL(TInt aColumn,TBool aIsGraphics);
294 * Checks if the column is a number.
296 * @param aColumn Target column.
297 * @return @c ETrue if it is a number.
299 IMPORT_C TBool ColumnIsNumber(TInt aColumn) const;
302 * Sets whether the column is a number.
304 * @param aColumn Target columun.
305 * @param aIsNumber Wanted setting. @c ETrue if it is a number.
307 IMPORT_C void SetNumberColumnL(TInt aColumn,TBool aIsNumber);
310 * Gets the icon array.
312 * These icons contain the bitmaps that are displayed in graphical columns.
314 * @return Pointer to the icon array.
316 IMPORT_C CArrayPtr<CGulIcon>* IconArray() const;
321 * @param aArray Wanted icon collection .
323 IMPORT_C void SetIconArray(CArrayPtr<CGulIcon>* aArray);
326 * Gets TextClipGap, the gap between words in a text clip, for the
329 * @param aSubCellIndex Index to target column.
330 * @return TextClipGap.
332 IMPORT_C TInt ColumnTextClipGap(TInt aSubCellIndex) const;
335 * Sets columns TextClipGap, the gap between words in a text clip.
337 * @param aSubCellIndex Index of the target column.
338 * @param aSize Wanted TextClipGap size.
340 IMPORT_C void SetColumnTextClipGapL(TInt aSubCellIndex, TInt aSize);
343 * Gets the specified font for the specified column.
345 * @param aItemProperties Whether the required font is:
346 * bold, italic, bold and italic or normal.
347 * @param aColumn The index of the column for which the font is obtained.
348 * @return The specified column’s, specified font. Null, the
349 * default, if no font is set for the column.
351 IMPORT_C CFont* Font(const TListItemProperties& aItemProperties,
355 * Gets the specified column’s surrounding rectangle.
357 * @param aColumn The index of the column for which the rectangle
359 * @param aRect On return contains the specified column’s rectangle.
360 * @return @c ETrue if successful. @c EFalse if a non-existent column
363 IMPORT_C TBool MakeColumnRect( TInt aColumn, TRect& aRect );
366 * Draws a single row.
368 * The text @c aText is parsed into columns and is split using
369 * @c KColumnListSeparator. Text or bitmaps are drawn according to whether
370 * the column has been set as a graphical column
371 * (see @c SetGraphicsColumnL()). Column cells within the row are drawn
372 * from left to right.
374 * @param aItemProperties The properties of each column in the row.
375 * @param aGc The graphics context to draw into.
376 * @param aText The text to parse and draw.
377 * @param aRect Bounding rectangle for the entire row.
378 * @param aHighlight @c ETrue to draw the item highlighted.
379 * @c EFalse otherwise.
380 * @param aColors The colours to use if the item is highlighted.
382 IMPORT_C virtual void Draw(const TListItemProperties& aItemProperties,
387 const TColors& aColors) const;
392 void DrawSimple(const TListItemProperties& aItemProperties, CWindowGc& aGc,const TDesC* aText,const TRect& aRect,TBool aHighlight,const TColors& aColors) const;
394 * Sets position of listbox line.
396 * @param aPosition Wanted position.
398 IMPORT_C void SetSeparatorLinePosition(
399 TAknSeparatorLinePosition aPosition);
402 * Gives out separator line position.
404 * @return Separator position.
406 IMPORT_C TAknSeparatorLinePosition SeparatorLinePosition() const;
412 * Gives out layout data for separator line drawing.
414 * @return Requested layout data.
416 IMPORT_C CAknLayoutData *LayoutData() const;
422 * Checks if the layout has been initialized.
424 * @return @c ETrue if initialized.
426 IMPORT_C TBool LayoutInit() const;
432 * Sets the initialization .
434 * @param aValue Wanted value (@c ETrue = initialized).
436 IMPORT_C void SetLayoutInit(TBool aValue) const;
439 * Enables / disables underlining per text column,
440 * if and only if @c TListItemProperties also has underlining enabled.
441 * If this method is not called and @c TListItemProperties has underlining
442 * enabled, drawing will revert to old style where only first text column
443 * will be underlined.
446 * @param aUnderlinedColumns Bitmask of columns to be underlined.
448 IMPORT_C void SetColumnUnderlined( TBitFlags32 aUnderlinedColumns );
453 TInt iColumn; // Must be first entry
457 const CFont* iBaseFont;
458 TInt iActualFontIndex;
462 CGraphicsContext::TTextAlign iAlign;
463 CGraphicsContext::TPenStyle iSeparator;
466 // the next are for storing x-coordinates of a column for the drawing algorithm.
468 __MUTABLE TInt iEndX;
473 * C++ default constructor.
475 IMPORT_C CColumnListBoxData();
478 * A second phase constructor.
480 * Highlight animation will be created by default (if it is provided
483 IMPORT_C void ConstructLD();
486 * Second phase constructor for subclasses that want to override highlight
487 * animation creation.
490 * @param aAnimationIID Skin item identifier of the constructed animation.
491 * Passing @c KAknsIIDNone will disable highlight animation.
493 IMPORT_C void ConstructLD( const TAknsItemID& aAnimationIID );
497 IMPORT_C TInt ColumnX(TInt aColumn) const;
498 IMPORT_C void SetColumnXL(TInt aColumn,TInt aX) const; // note, const! (do not affect external state)
500 IMPORT_C TInt ColumnEndX(TInt aColumn) const;
501 IMPORT_C void SetColumnEndXL(TInt aColumn,TInt aEndX) const; // note, Const!
503 void AddColumnL(TInt aColumn);
504 SColumn& At(TInt aArrayIndex);
505 const SColumn& At(TInt aArrayIndex) const;
506 TBool FindColumnIndex(TInt& aArrayIndex,TInt aColumn) const;
507 void FindColumnIndexOrAddL(TInt& aArrayIndex,TInt aColumn);
508 TInt AddActualFontL(const CFont* aBaseFont);
509 void SetUnderlineStyle( TListItemProperties aProperties, CWindowGc& aGc, TInt aColumn ) const;
510 void DoConstructL( const TAknsItemID& aAnimationIID );
514 * Gets @c CCoeControl for component.
516 * @return Pointer to the used @c CCoeControl.
518 IMPORT_C CCoeControl *Control() const;
521 * Sets @c CCoeControl for current component.
523 * @param aControl Current listbox control instance, cannot be any
526 IMPORT_C void SetControl(CCoeControl *aControl);
529 * Gets background skin context.
531 * @return Component's skin control context.
533 IMPORT_C MAknsControlContext* SkinBackgroundContext() const;
536 * Sets background skin context. Changes ownership as well.
538 * @param aContext Wanted background skin control context.
540 void SetSkinBackgroundContext(
541 CAknsListBoxBackgroundControlContext *aContext);
545 * Sets style for the skin fot list tiles.
547 * @param aId Wanted skins item ID.
548 * @param aTileRect Skin tile size.
550 IMPORT_C void SetSkinStyle(const TAknsItemID *aId,
551 const TRect &aTileRect);
554 * Sets skin style for the end of the list.
556 * @param aId Wanted skins item ID.
557 * @param aRect Skin tile size.
559 IMPORT_C void SetListEndSkinStyle(const TAknsItemID *aId,
563 * Sets skin for the highlighted frame.
565 * @param aFrameId Wanted skin's item ID for the frame.
566 * @param aFrameCenterId Wanted skin's item ID for the center of the frame.
568 IMPORT_C void SetSkinHighlightFrame(const TAknsItemID *aFrameId,
569 const TAknsItemID *aFrameCenterId);
572 * Enables/Disables skin.
574 * @param aEnabled Sets whether the skins are enable or disabled
575 * @c ETrue for enabling skins.
577 IMPORT_C void SetSkinEnabledL(TBool aEnabled);
580 * Creates a pictograph interface for the @c CColumnListBoxData.
582 void CreatePictographInterfaceL();
585 * Creates a marquee control for the @c CColumnListBoxData and redraw.
587 void CreateMarqueeControlL();
590 * Resets marquee control.
595 * Gets current marquee item index.
597 * @return Current marquee item index.
599 TInt CurrentMarqueeItemIndex();
602 * Sets the index for current marquee item.
604 * @param aIndex Item index.
606 void SetCurrentMarqueeItemIndex(TInt aIndex);
609 * Enables or disables the marquee.
611 * @param aEnable @c ETrue = On. @c EFalse = Off.
613 IMPORT_C void EnableMarqueeL(TBool aEnable);
616 * Sets the font attached to the cell for each row separately.
618 * @param aRow Index number of the row.
619 * @param aColumn Index number of the column.
620 * @param aFont Font to be used.
622 IMPORT_C void SetColumnFontForRowL(TInt aRow,
627 * Gets the font attached to the row and cell.
629 * @param aRow Index number of the row.
630 * @param aColumn Index number of the column.
631 * @return Font handle.
633 IMPORT_C const CFont* RowAndColumnFont(TInt aRow,TInt aColumn) const;
636 * Sets the current list item index. Since S60 2.6 causes highlight
637 * animation tochange its background (only if the current item index
638 * changes). Do not call this method if the index is not the current
642 * @param aIndex The new index for the current item.
644 void SetCurrentItemIndex(TInt aIndex);
647 * Sets the subcell icon size.
650 * @param aIndex Index of the sub cell.
651 * @param aSize Size of the sub cell icon.
653 IMPORT_C void SetSubCellIconSize(TInt aIndex, TSize aSize);
656 * Gets subcell icon size.
658 * @param aIndex Index of the wanted subcell.
659 * @return Size of the subcell.
661 TSize GetSubCellIconSize(TInt aIndex);
664 * Gets the highlight animation .
667 * @return @c CAknsEffectAnim that is used for when the highlighted list
668 * is drawn. May return NULL, in this case the normal skinned
669 * highlight should be drawn. This pointer is valid only during
670 * the draw -> you should not store it locally outside draw scope.
672 IMPORT_C const CAknsEffectAnim* HighlightAnim() const;
675 * This method should be called before drawing animated highlight. It will
676 * sync the animation with the background under the current highlight (only
677 * when current item index has changed).
681 IMPORT_C void AboutToDrawHighlightAnim() const;
684 * Sets the observer for overriding default highlight input layer drawing
685 * functionality. Note that you should still call
686 * @c AboutToDrawHighlightAnim (it will call the observer if it is set).
689 * @param aDrawer New background drawer.
691 IMPORT_C void SetHighlightAnimBackgroundDrawer(
692 MColumnListBoxAnimBackgroundDrawer* aDrawer );
695 * Changes item cell size & resizes highlight animation. Called by list
696 * when item cell size changes. If you are using non-standard highlight
697 * sizes make sure to sync the list item cell size.
700 * @param aSizeInPixels New size in pixels for the Item cell.
702 IMPORT_C void SetItemCellSize( const TSize& aSizeInPixels );
705 * @return ETrue if highlight animation exists, EFalse otherwise.
709 IMPORT_C TBool HasHighlightAnim() const;
711 * The preferred method for drawing highlight animation in derived classes.
712 * Before calling this method you should check that highlight animation
713 * exists by calling HasHighlightAnim. In case of draw failure you should
714 * default to normal skinned highlight drawing. For example:
716 * TBool drawOk = EFalse;
718 * if( HasHighlightAnim() )
720 * drawOk = DrawHighlightAnim( gc, rect );
725 * ...do normal skinned draw
728 * @param aGc Graphics context for blitting animation frame
729 * @param aRect Target rect for blitting animation frame
730 * @return The draw status, ETrue if drawing was ok, EFalse otherwise.
734 IMPORT_C TBool DrawHighlightAnim( CBitmapContext& aGc, const TRect& aRect ) const;
739 * Called when the @c CColumnListBoxData is unselected. Informs the
740 * @c CColumnListBoxData extension that the focus has been lost.
745 * Handles changing of an resource. Only supports skin change.
747 * @param aType Defines the resource that has changed.
749 void HandleResourceChange( TInt aType );
752 * Setup skin control context for handling background skins.
753 * if no skin control context is found one is created.
755 void SetupSkinContextL();
760 * @param aTextColor Wanted colour.
762 void SetESSTextColor(TRgb aTextColor);
765 * Sets text colour for highlighted text.
767 * @param aHighlightedTextColor Wanted colour.
769 void SetESSHighlightedTextColor(TRgb aHighlightedTextColor);
771 IMPORT_C void SetGraphicSubCellL(TInt aSubCell,const TAknWindowLineLayout &aGraphicLayout);
772 IMPORT_C void SetTextSubCellL(TInt aSubCell,const TAknTextLineLayout &aTextLayout);
773 IMPORT_C void SetConditionalSubCellL(TInt aSubCell, const TAknTextLineLayout &aTextLayout,TInt aAffectedSubCell);
774 IMPORT_C void SubCellsMightIntersect( const TBool aMightIntersect );
776 IMPORT_C void SetStretchableGraphicSubCellL(TInt aSubCell,
777 const TAknWindowComponentLayout& aNormalLayout,
778 const TAknWindowComponentLayout& aStretchedLayout);
779 IMPORT_C void SetStretchableTextSubCellL(TInt aSubCell,
780 const TAknTextComponentLayout& aNormalLayout,
781 const TAknTextComponentLayout& aStretchedLayout);
782 IMPORT_C void SetStretchableConditionalSubCellL(TInt aSubCell,
783 const TAknTextComponentLayout& aNormalLayout,
784 const TAknTextComponentLayout& aStretchedLayout,
786 TInt aStretchedSubCell );
787 IMPORT_C void ResetSLSubCellArray();
788 TBool UsesScalableLayoutData() const;
789 void EnableStretching(const TBool aEnabled);
790 IMPORT_C TBool StretchingEnabled() const;
794 * Wraps the text drawing functinality with & without marquee into one
795 * function, so that inherited classes can modify their own drawing
796 * behaviour more easily.
799 * @param aGc Window graphics context controller.
800 * @param aTextRect The area where the text is drawn.
801 * @param aText The whole text. Not clipped.
802 * @param aClippedText Clipped / truncated text.
803 * @param aBaselineOffset An offset from the top of the box to the text
805 * @param aAlign The text alignment mode (default is left, rather
806 * than centre or right).
807 * @param aFont Wanted font.
808 * @param aHighlight Does the current item have highlight.
809 * @param aIsTextClipped Is the current item clipped.
811 IMPORT_C void DrawText(CWindowGc& aGc,
812 const TRect& aTextRect,
814 const TDesC& aClippedText,
815 const TInt aBaselineOffset,
816 const CGraphicsContext::TTextAlign aAlign,
818 const TBool aHighlight,
819 const TBool aIsTextClipped) const;
823 * Customizes marquee default behaviour.
825 * Use this before enabling marquee ( @c EnableMarqueeL() ), otherwise
826 * marquee behaviour will change during animation.
829 * @param aLoops Max number of loops to be executed.
830 * @param aScrollAmount The amount of pixels scrolled per
832 * @param aScrollDelay The interval between iterations.
834 IMPORT_C void SetMarqueeParams(const TInt aLoops,
835 const TInt aScrollAmount,
836 const TInt aScrollDelay);
839 * Customizes marquee default behaviour.
842 * @param aLoops Max number of loops to be executed.
843 * @param aScrollAmount The amount of pixels scrolled per iteration.
844 * @param aScrollDelay The interval between iterations.
845 * @param aInterval The interval between frame updates.
847 IMPORT_C void SetMarqueeParams(const TInt aLoops,
848 const TInt aScrollAmount,
849 const TInt aScrollDelay,
850 const TInt aInterval);
852 * Tells whether current item has clipped text cells
854 * @return bitfield of clipped columns
856 IMPORT_C TUint32 CurrentItemTextWasClipped() const;
859 * Returns ETrue if kinetic scrolling is enabled.
862 * @return ETrue if kinetic scrolling feature is enabled.
864 TBool KineticScrollingEnabled() const;
867 void DrawHighLight( CWindowGc& aGc, const TRect& aRect,
869 MAknsSkinInstance* aSkin ) const;
871 void CheckIfSubCellsIntersect( TAknTextLineLayout* aLayouts,
872 TBool* aResults, const TDesC& aText,
873 const TRect& aItemRect ) const;
877 void BitBltColored( CWindowGc& aGc,
879 const CGulIcon* aIcon,
882 const TRect& aGraphicRect ) const;
887 CArrayFix<SColumn>* iColumnArray;
888 CColumnListBoxDataExtension *iExtension;
891 #endif // __EIKCLBD_H__