menufw/menufwui/mmwidgets/inc/mmlistboxitemdrawer.h
branchRCL_3
changeset 83 5456b4e8b3a8
equal deleted inserted replaced
82:5f0182e07bfb 83:5456b4e8b3a8
       
     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:  CMmListBoxItemDrawer
       
    15 *  Version     : %version: MM_38.1.19 % << Don't touch! Updated by Synergy at check-out.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef C_MMLISTBOXITEMDRAWER_H
       
    21 #define C_MMLISTBOXITEMDRAWER_H
       
    22 
       
    23 #include <e32std.h>
       
    24 #include <e32base.h>
       
    25 #include <AknsBasicBackgroundControlContext.h>
       
    26 #include <eikfrlbd.h>
       
    27 #include <AknDef.hrh>
       
    28 #include "mmwidgetsconstants.h"
       
    29 #include "mmtemplatelibrary.h"
       
    30 #include "hniconholder.h"
       
    31 #include "mmsubcellssetupcode.h"
       
    32 
       
    33 class CMmListBoxModel;
       
    34 class TMmFloatingItem;
       
    35 class CMmMarqueeAdapter;
       
    36 class CMmDrawerAnimator;
       
    37 class CMmPostEvaluationProcessor;
       
    38 class CMmItemsDataCache;
       
    39 
       
    40 /**
       
    41  * Used to draw items in widgets. The item drawer is used both by grid
       
    42  * and listbox. Data is used to draw subcells. The subcell templates are fetched
       
    43  * from the template library and set to data to be drawn.
       
    44  *
       
    45  *  @code
       
    46  *  @endcode
       
    47  *  @lib mmwidgets
       
    48  *  @since S60 v3.0
       
    49  *  @ingroup group_mmwidgets
       
    50  */
       
    51 NONSHARABLE_CLASS( CMmListBoxItemDrawer ):
       
    52     public CFormattedCellListBoxItemDrawer
       
    53     {
       
    54 
       
    55     friend class CMmPostEvaluationProcessor;
       
    56 
       
    57 public:
       
    58 
       
    59     /**
       
    60      * Two-phased constructor.
       
    61      *
       
    62      * @since S60 v3.0
       
    63      * @param aMmListBoxModel The listbox model.
       
    64      * @param aFont Font.
       
    65      * @param aFormattedCellData Cell data.
       
    66      * @param aWidgetType Widget type.
       
    67      */
       
    68   static CMmListBoxItemDrawer* NewL(
       
    69           CMmListBoxModel* aMmListBoxModel,
       
    70         const CFont* aFont,
       
    71         CFormattedCellListBoxData* aFormattedCellData,
       
    72         TMmWidgetType aWidgetType,
       
    73         CMmTemplateLibrary* aTemplateLibrary );
       
    74 
       
    75     /**
       
    76      * Two-phased constructor.
       
    77      *
       
    78      * @since S60 v3.0
       
    79      * @param aMmListBoxModel The listbox model.
       
    80      * @param aFont Font.
       
    81      * @param aFormattedCellData Cell data.
       
    82      * @param aWidgetType Widget type.
       
    83      */
       
    84   static CMmListBoxItemDrawer* NewLC(
       
    85           CMmListBoxModel* aMmListBoxModel,
       
    86         const CFont* aFont,
       
    87         CFormattedCellListBoxData* aFormattedCellData,
       
    88         TMmWidgetType aWidgetType,
       
    89         CMmTemplateLibrary* aTemplateLibrary );
       
    90 
       
    91     /**
       
    92      * Destructor.
       
    93      *
       
    94      * @since S60 v3.0
       
    95      */
       
    96     ~CMmListBoxItemDrawer();
       
    97 
       
    98     /**
       
    99      * Enables/disables cached data use.
       
   100      *
       
   101      * When aEnable is true:
       
   102      * Enables the use of cached data when drawing items.
       
   103      * This significantly improves performance.
       
   104      * Do not ever try to use this feature in edit mode.
       
   105      *
       
   106      * When aEnable is false:
       
   107      * Restores the normal mode where data needed for drawing
       
   108      * items is retrieved from the model and the cached data
       
   109      * is updated with the information retrieved from the model
       
   110      *
       
   111      * @param aEnable Self-explanatory.
       
   112      */
       
   113     void EnableCachedDataUse( TBool aEnable );
       
   114 
       
   115     /**
       
   116      * Returns ETrue if item drawer is using cached data.
       
   117      * To start/stop using cached data, use the @c EnableCachedDataUse
       
   118      * method.
       
   119      *
       
   120      * @return ETrue if cached data is used, EFalse otherwise.
       
   121      */
       
   122     TBool CachedDataUseIsEnabled() const;
       
   123 
       
   124     /**
       
   125      * This method should be called whenever items(s) are removed
       
   126      * in order to remove corresponding entries in the local
       
   127      * items data cache.
       
   128      *
       
   129      * @param aItemCount current item count
       
   130      */
       
   131     void TrimCacheSize( TInt aItemCount );
       
   132 
       
   133     /**
       
   134      * Invalidates the cached data for all items.
       
   135      */
       
   136     void InvalidateCache();
       
   137 
       
   138     /**
       
   139      * Get the height of the given item.
       
   140      *
       
   141      * @since S60 v3.0
       
   142      * @param aItemIndex Item index for which height is calculated.
       
   143      * @param aItemIsCurrent Is item the current widget item.
       
   144      * @return Item height.
       
   145      */
       
   146     TInt GetItemHeight( TInt aItemIndex, TBool aItemIsCurrent ) const;
       
   147 
       
   148     /**
       
   149      * Gets size of given item.
       
   150      *
       
   151      * @since S60 v3.0
       
   152      * @param aItemIndex Item index.
       
   153      * @param aItemIsCurrent Is item the current widget item.
       
   154      * @return Size of item.
       
   155      */
       
   156     TSize GetItemSize( TInt aItemIndex, TBool aItemIsCurrent ) const;
       
   157 
       
   158     /**
       
   159      * Gets rect of indicator.
       
   160      *
       
   161      * @since S60 v3.0
       
   162      * @return Rect of indicator.
       
   163      */
       
   164     TRect GetIndicatorRect() const;
       
   165 
       
   166     /**
       
   167      * Setx draggable state
       
   168      *
       
   169      * @since S60 v3.0
       
   170      * @param aDraggable Is draggable.
       
   171      */
       
   172     void SetDraggableL( TBool aDraggable );
       
   173 
       
   174     /**
       
   175      * Sets item which is dragged.
       
   176      *
       
   177      * @since S60 v3.0
       
   178      * @param aDraggedItemIndex Dragged item index.
       
   179      * @param aPoint Dragged point.
       
   180      */
       
   181     void SetDraggedIndexL( TInt aDraggedItemIndex, TPoint aPoint );
       
   182 
       
   183     /**
       
   184      * Sets item which is dragged.
       
   185      *
       
   186      * @since S60 v3.0
       
   187      * @param aCenterPoint Center point of dragged item.
       
   188      */
       
   189     void SetDraggedPointL( TPoint aCenterPoint );
       
   190 
       
   191     /**
       
   192      * Reveales if is possible to drag.
       
   193      *
       
   194      * @since S60 5.0
       
   195      * @return Is draggable.
       
   196      */
       
   197     TBool IsDraggable() const;
       
   198 
       
   199     /**
       
   200      * Sets associated widget.
       
   201      *
       
   202      * @since S60 5.0
       
   203      * @param aView Widget to associated with this drawer.
       
   204      */
       
   205     void SetView( CEikListBox* aView );
       
   206 
       
   207     /**
       
   208      * Get associated widget.
       
   209      *
       
   210      * @since S60 5.0
       
   211      * @return Widget associated with this drawer.
       
   212      */
       
   213     CEikListBox* Widget() const;
       
   214 
       
   215     /**
       
   216      * Gets template library.
       
   217      *
       
   218      * @since S60 5.0
       
   219      * @return Return iTemplateLibrary.
       
   220      */
       
   221     CMmTemplateLibrary* TemplateLibrary();
       
   222 
       
   223     /**
       
   224      * Sets the background context.
       
   225      *
       
   226      * @since S60 5.0
       
   227      * @param aBgContext Background context.
       
   228      */
       
   229   void SetBgContext(
       
   230       CAknsBasicBackgroundControlContext* aBgContext );
       
   231 
       
   232     /**
       
   233      * Sets condition if background should be redrawn.
       
   234      *
       
   235      * @since S60 v3.0
       
   236      * @param aRedraw Should background be redrawn.
       
   237      */
       
   238     void SetRedrawItemBackground( TBool aRedraw );
       
   239 
       
   240     /**
       
   241      * Sets condition if separator line should be drawn.
       
   242      *
       
   243      * @since S60 v3.0
       
   244      * @param aRedraw Should separator line be drawn.
       
   245      */
       
   246     void SetDrawSeparatorLines( TBool aDraw );
       
   247 
       
   248     /**
       
   249      * Checks if item background redrawing is enabled.
       
   250      *
       
   251      * @since S60 v3.0
       
   252      * @return Is background redrawing enabled.
       
   253      */
       
   254     TBool IsRedrawItemBackgroundEnabled() const;
       
   255 
       
   256     /**
       
   257      * Draws empty item ( no subcells ).
       
   258      *
       
   259      * @since S60 v3.0
       
   260      * @param aItemIndex Item index.
       
   261      * @param aItemRectPos Item rectangle position.
       
   262      * @param aViewIsDimmed Is view dimmed.
       
   263      */
       
   264     void DrawEmptyItem( TInt aItemIndex,
       
   265             TPoint aItemRectPos,  TBool aViewIsDimmed ) const;
       
   266 
       
   267     /**
       
   268      * Sets edit mode condition.
       
   269      *
       
   270      * @since S60 v3.0
       
   271      * @param aIsEditMode Is edit mode.
       
   272      */
       
   273     void SetEditModeL( TBool aIsEditMode );
       
   274 
       
   275     /**
       
   276      * Checks if edit mode is running.
       
   277      *
       
   278      * @since S60 v3.0
       
   279      * @return Is edit mode running.
       
   280      */
       
   281     TBool IsEditMode() const;
       
   282 
       
   283     /**
       
   284      * Animates dragged item transition.
       
   285      *
       
   286      * @since S60 v3.0
       
   287      */
       
   288     void AnimateDragItemTransitionL( );
       
   289 
       
   290     /**
       
   291      * Animates swapping of items.
       
   292      *
       
   293      * @since S60 v3.0
       
   294      * @param aItemFrom Start item position (index).
       
   295      * @param aItemTo End item position (index).
       
   296      */
       
   297     void AnimateItemSwapL( TInt aItemFrom, TInt aItemTo );
       
   298 
       
   299     /**
       
   300      * Animate item zoom in.
       
   301      *
       
   302      * @since S60 v3.0
       
   303      * @param aItemIndex Item index of item to be zoomed in.
       
   304      */
       
   305     void AnimateItemZoomInL( TInt aItemIndex );
       
   306 
       
   307     /**
       
   308      * Animate item zoom out.
       
   309      *
       
   310      * @since S60 v3.0
       
   311      * @param aItemIndex Item index of zoomed item.
       
   312      */
       
   313     void AnimateItemZoomOutL( TInt aItemIndex );
       
   314 
       
   315     /**
       
   316      * Checks if item drawer is ready to run new animation.
       
   317      *
       
   318      * @since S60 v3.0
       
   319      * @return Is drawer ready to run animation.
       
   320      */
       
   321     CMmDrawerAnimator* GetAnimator();
       
   322 
       
   323     /**
       
   324      * Draws floating items.
       
   325      *
       
   326      * @since S60 v3.0
       
   327      * @param aCurrentlyDrawnRect Currently drawn item rectangle.
       
   328      */
       
   329     void DrawFloatingItems( TRect aCurrentlyDrawnRect );
       
   330 
       
   331     /**
       
   332      * Gets floating item index.
       
   333      *
       
   334      * @since S60 v3.0
       
   335      * @param aType Floating item type.
       
   336      * @return Floating item index.
       
   337      */
       
   338     TInt GetFloatingItemIndex( TMmFloatingItemType aType ) const;
       
   339 
       
   340     /**
       
   341      * Gets floating item.
       
   342      *
       
   343      * @since S60 v3.0
       
   344      * @param aType Floating item type.
       
   345      * @return Floating item.
       
   346      */
       
   347     TMmFloatingItem& GetFloatingItemL( TMmFloatingItemType aType );
       
   348 
       
   349     /**
       
   350      * Gets number of floating items.
       
   351      *
       
   352      * @since S60 5.0
       
   353      * @param aType Floating item type.
       
   354      * @return Number of floating items.
       
   355      */
       
   356     TInt GetValidFloatingItemCount( TMmFloatingItemType aType );
       
   357 
       
   358     /**
       
   359      * Gets floating items count.
       
   360      *
       
   361      * @since S60 5.0
       
   362      * @return Number of the floating items in the array.
       
   363      */
       
   364     TInt GetFloatingItemCount();
       
   365 
       
   366     /**
       
   367      * Adds floating item to the floating item array.
       
   368      *
       
   369      * @since S60 5.0
       
   370      * @param aFloatingItem Floating item to be added.
       
   371      * @param aPosition Position to add at.
       
   372      */
       
   373     void AddFloatingItemL( TMmFloatingItem& aFloatingItem,
       
   374             TInt aPosition = KErrNotFound );
       
   375 
       
   376     /**
       
   377      * Removes floating item.
       
   378      *
       
   379      * @since S60 5.0
       
   380      * @param aPosition Floating item index to be removed.
       
   381      */
       
   382     void RemoveFloatingItem( TInt aPosition );
       
   383 
       
   384     /**
       
   385      * Removes all floating items.
       
   386      *
       
   387      * @since S60 5.0
       
   388      */
       
   389     void RemoveFloatingItems();
       
   390 
       
   391     /**
       
   392      * Gets floating item at particular index in the
       
   393      * floating item array.
       
   394      *
       
   395      * @since S60 5.0
       
   396      * @param aIndex Index of the floating item in the array.
       
   397      * @return Floating item.
       
   398      */
       
   399     TMmFloatingItem& GetFloatingItemAtIndex( TInt aIndex );
       
   400 
       
   401     /**
       
   402      * Used to set scrollbar visibility flag.
       
   403      *
       
   404      * @since S60 v3.0
       
   405      * @param aIsScrollbarVisible Is scrollbar visible.
       
   406      */
       
   407     void SetScrollbarVisibilityL( TBool aIsScrollbarVisible );
       
   408 
       
   409     /**
       
   410      * Replaces subcell text.
       
   411      *
       
   412      * @since S60 v3.0
       
   413      * @param aText Text which will replace previous text.
       
   414      */
       
   415     void ReplaceSubCellText( const TDesC& aText );
       
   416 
       
   417     /**
       
   418      * Adds subcell marquee element.
       
   419      *
       
   420      * @since S60 v3.0
       
   421      * @param aSubCellTemplate Subcell template data.
       
   422      * @param aIndex Subcell index.
       
   423      * @param aItemIndex Item index.
       
   424      */
       
   425     void AddSubcellMarqueeElementL( TTemplateChild aSubCellTemplate,
       
   426             TInt aIndex, TInt aItemIndex );
       
   427 
       
   428     /**
       
   429      * Sets the marquee adapter.
       
   430      *
       
   431      * @since S60 v3.0
       
   432      * @param aAdapter Marquee adapter.
       
   433      */
       
   434     void SetMarqueeAdapter( CMmMarqueeAdapter* aAdapter );
       
   435 
       
   436     /**
       
   437      * Sets the flag which tells that marquee is currently being drawn.
       
   438      *
       
   439      * @since S60 v3.0
       
   440      * @param aIsMarqueeBeingDrawn Is marquee being drawn.
       
   441      */
       
   442     void SetMarqueeDrawing( TBool aIsMarqueeBeingDrawn );
       
   443 
       
   444     /**
       
   445      * Checks if text is clipped.
       
   446      *
       
   447      * @since S60 v3.0
       
   448      * @param aTemplateChild Subcell template data.
       
   449      * @param aText Text to be clipped.
       
   450      * @return Is text clipped.
       
   451      */
       
   452     TBool IsTextClippedL( TTemplateChild aTemplateChild,
       
   453             const TDesC& aText ) const;
       
   454 
       
   455     /**
       
   456      * Sets the flag which tells that a scrollbar event is running.
       
   457      *
       
   458      * @since S60 v3.0
       
   459      * @param aIsRunning Is scrollbar event running.
       
   460      */
       
   461   void SetScrollbarEventRunning( TBool aIsRunning );
       
   462 
       
   463     /**
       
   464      * Sets number of columns in view.
       
   465      *
       
   466      * @since S60 v3.0
       
   467      * @param aNumberOfColumns Number of columns in view.
       
   468      */
       
   469   void SetNumberOfColsInView( TInt aNumberOfColumns );
       
   470 
       
   471   /**
       
   472    * Used in non-touch edit mode to block drawing of move indicators and highlight
       
   473    * to clean screen for animation.
       
   474    *
       
   475    * @since S60 v3.0
       
   476    * @param aDrawn Should highlight and move indicators be drawn.
       
   477    */
       
   478   void SetHighlightShown( TBool aDrawn );
       
   479 
       
   480     /**
       
   481      * Draws background.
       
   482      *
       
   483      * @since S60 v3.0
       
   484      * @param aItemTextRect Item rectangle.
       
   485      */
       
   486     void DrawBackground( const TRect& aItemTextRect ) const;
       
   487 
       
   488     /**
       
   489      * Animates transition of the dragged item.
       
   490      * The animation starts in the original place of dragging item,
       
   491      * and end in the EDrag floating item position, when item had been start drag.
       
   492      *
       
   493      * @since S60 v5.0
       
   494 	 * @param aDraggedIndex Draged item index to be animated.
       
   495 	 * @param aPoint End position of animated item.
       
   496      */
       
   497     void AnimateDragItemStartL( TInt aDraggedIndex, TPoint aPoint );
       
   498 
       
   499 protected:
       
   500     /**
       
   501      * From CListItemDrawer. Draws an item.
       
   502      *
       
   503      * @since S60 v3.0
       
   504      * @param aItemIndex Item index to be drawn.
       
   505      * @param aItemRectPos Item rectangle position.
       
   506      * @param aItemIsSelected Is item selected.
       
   507      * @param aItemIsCurrent Is item current.
       
   508      * @param aViewIsEmphasized Is view emphasized.
       
   509      * @param aViewIsDimmed Is view dimmed.
       
   510      */
       
   511     void DrawItem( TInt aItemIndex, TPoint aItemRectPos,
       
   512                    TBool aItemIsSelected, TBool aItemIsCurrent,
       
   513                    TBool aViewIsEmphasized, TBool aViewIsDimmed ) const;
       
   514 
       
   515     /**
       
   516      * Draws item according to format text.
       
   517      *
       
   518      * @since S60 v3.0
       
   519      * @param aItemIndex Item index to be drawn.
       
   520      * @param aItemTextRect Item rectangle.
       
   521      * @param aItemIsCurrent Is item current.
       
   522      * @param aViewIsEmphasized Is view emphasized.
       
   523      * @param aItemIsSelected Is item selected.
       
   524      */
       
   525     void DrawItemText( TInt aItemIndex, const TRect& aItemTextRect,
       
   526         TBool aItemIsCurrent, TBool aViewIsEmphasized,
       
   527         TBool aItemIsSelected ) const;
       
   528     /**
       
   529      * Draws the actual item contents for the specified item in the specified
       
   530      * rectangle.
       
   531      *
       
   532      * @param aItemIndex Index of the item to draw.
       
   533      * @param aActualItemRect Area to draw into.
       
   534      * @param aItemIsCurrent @c ETrue if the item is current.
       
   535      * @param aViewIsEmphasized @c ETrue if the view is emphasised.
       
   536      * @param aViewIsDimmed Ignored
       
   537      * @param aItemIsSelected @c ETrue if the item is selected.
       
   538      */
       
   539     void DrawActualItem(TInt aItemIndex, const TRect& aActualItemRect,
       
   540       TBool aItemIsCurrent, TBool aViewIsEmphasized, TBool aViewIsDimmed,
       
   541       TBool aItemIsSelected) const;
       
   542 
       
   543     /**
       
   544      * Sets up item currently drawn item subcells.
       
   545      * Also, fills-in/updates the cache information for the item at index
       
   546      * aItemIndex.
       
   547      *
       
   548      * @since S60 v3.0
       
   549      * @param aItemIsCurrent Is item the current item in widget.
       
   550      * @param aItemIndex Item index.
       
   551      */
       
   552     void SetupSubCellsL( TBool aItemIsCurrent, TInt aItemIndex ) const;
       
   553 
       
   554     /**
       
   555      * Sets up subcell to be drawn by listbox data.
       
   556      *
       
   557      * @since S60 v3.0
       
   558      * @param aSubCellTemplate Subcell template data.
       
   559      * @param aIndex Subcell index.
       
   560      * @param aItemIndex Item index.
       
   561      */
       
   562     void SetupSubCellL( TTemplateChild aSubCellTemplate, TInt aIndex,
       
   563             TInt aItemIndex ) const;
       
   564 
       
   565     /**
       
   566      * Sets up "null" subcell to be avoided when drawing.
       
   567      *
       
   568      * @since S60 v3.0
       
   569      * @param aIndex Subcell index.
       
   570      * @param aItemIndex Item index.
       
   571      */
       
   572     void SetupSubNoCellL( TInt aIndex, TInt aItemIndex ) const;
       
   573 
       
   574     /**
       
   575      * Sets up icon for dragged subcell.
       
   576      *
       
   577      * @since S60 v3.0
       
   578      * @param aSubCellTemplate Subcell template data.
       
   579      * @param aIndex Subcell index.
       
   580      * @param aItemIndex Index of dragged item.
       
   581      */
       
   582     void SetupSubIcondDragHighlightCellL( TTemplateChild aSubCellTemplate,
       
   583             TInt aIndex, TInt aItemIndex ) const;
       
   584 
       
   585     /**
       
   586      * Adjusts rectangle of item.
       
   587      *
       
   588      * @since S60 v3.0
       
   589      * @param aItemIndex Item's index which adjust rectangle.
       
   590      * @return Index of item which rectangle should be adjusted.
       
   591      */
       
   592     TRect AdjustItemRect( TInt aItemIndex ) const;
       
   593 
       
   594     /**
       
   595      * Draws the move indicator over the indicated item.
       
   596      *
       
   597      * @since S60 v3.0
       
   598      * @param aItemIndex Item index with move indicator.
       
   599      * @param aActualItemRect The actual rectangle of indicator item.
       
   600      */
       
   601     void DrawActualIndicatorItem( TInt aItemIndex, TRect aActualItemRect );
       
   602 
       
   603     /**
       
   604      * Sets up colors for subcell data.
       
   605      *
       
   606      * @since S60 v3.0
       
   607      * @return Colors for subcell drawing.
       
   608      */
       
   609     CFormattedCellListBoxData::TColors SetupColors( TBool aDragged = EFalse ) const;
       
   610 
       
   611 private:
       
   612 
       
   613     /**
       
   614      * Default constructor.
       
   615      *
       
   616      * @since S60 v3.0
       
   617      * @param  aMmListBoxModel List box model.
       
   618      * @param  aFont Font needed by base constructor.
       
   619      * @param  aFormattedCellData Used to format subcell data in item drawer.
       
   620      * @param  aWidgetType Type of widgte (list/grid).
       
   621      * @param  aTemplateLibrary TemplateLibrary contains items sizes.
       
   622      */
       
   623     CMmListBoxItemDrawer( CMmListBoxModel* aMmListBoxModel,
       
   624             const CFont* aFont,
       
   625             CFormattedCellListBoxData* aFormattedCellData,
       
   626             TMmWidgetType aWidgetType, CMmTemplateLibrary* aTemplateLibrary );
       
   627 
       
   628     /**
       
   629      * 2nd phase constructor.
       
   630      *
       
   631      * @since S60 v3.0
       
   632      */
       
   633     void ConstructL();
       
   634 
       
   635     /**
       
   636      *Draws the item text according to the format defined by a text string.
       
   637      *
       
   638      * @since S60 v3.0
       
   639      * @param aItemIndex Item index to be drawn.
       
   640      * @param aItemTextRect Item rectangle.
       
   641      * @param aItemIsCurrent Is item current.
       
   642      * @param aViewIsEmphasized Is view emphasized.
       
   643      * @param aItemIsSelected Is item selected.
       
   644      */
       
   645     void DoDrawItemTextL( TInt aItemIndex, const TRect& aItemTextRect,
       
   646         TBool aItemIsCurrent, TBool aViewIsEmphasized,
       
   647         TBool aItemIsSelected ) const;
       
   648 
       
   649     /**
       
   650      * Draws an item.
       
   651      *
       
   652      * @since S60 v3.0
       
   653      * @param aItemIndex Item index to be drawn.
       
   654      * @param aItemRectPos Position of item rectangle.
       
   655      * @param aItemIsSelected Is item selected.
       
   656      * @param aItemIsCurrent Is item current.
       
   657      * @param aViewIsEmphasized Is view emphasized.
       
   658      * @param aViewIsDimmed Is view dimmed.
       
   659      */
       
   660     void DoDrawItem(TInt aItemIndex, TPoint aItemRectPos,
       
   661         TBool aItemIsSelected, TBool aItemIsCurrent, TBool aViewIsEmphasized,
       
   662         TBool aViewIsDimmed) const;
       
   663 
       
   664     /**
       
   665      * Sets up backdrop image subcell.
       
   666      *
       
   667      * @since S60 v3.0
       
   668      * @param aTemplateChildArray Array of subcell children where the backdrop subcell template is appended.
       
   669      * @param aItemIndex Index of currently drawn item.
       
   670      * @param aItemText Text used to format item subcell content.
       
   671      * @param aSubcellIncrement Is incremented if backdrop subcell template is appended.
       
   672      */
       
   673     void SetupBackdropSubcellL(
       
   674         RArray<TTemplateChild>& aTemplateChildArray, TInt aItemIndex,
       
   675             RBuf& aItemText, TInt& aSubcellIncrement ) const;
       
   676 
       
   677     /**
       
   678      * Sets up icon image subcell.
       
   679      *
       
   680      * @since S60 v3.0
       
   681      * @param aTemplateChildArray Array of subcell children where the backdrop subcell template is appended.
       
   682      * @param aChildIndex Index of a template child.
       
   683      * @param aItemIndex Index of currently drawn item.
       
   684      * @param aItemText Text used to format item subcell content.
       
   685      * @param aSubcellIncrement Is incremented if backdrop subcell template is appended.
       
   686      */
       
   687     void SetupIconSubcellL(
       
   688         RArray<TTemplateChild>& aTemplateChildArray, TInt aChildIndex, TInt aItemIndex,
       
   689         RBuf& aItemText, TInt& aSubcellIncrement ) const;
       
   690 
       
   691     /**
       
   692      * Determines whether a bitmap of given size needs scaling to be displayed
       
   693      * in a rectangular area of some given target size.
       
   694      *
       
   695      * This method assumes that the bitmap will always be scaled with aspect
       
   696      * ratio preserved. A bitmap does not need scaling if its size meets either
       
   697      * of the two conditions:
       
   698      * 1. bitmap width is nearly the same* as target area width and bitmap height
       
   699      *    is not greater than target height
       
   700      * 2. bitmap width is not greater that target width and bitmap height is
       
   701      *    nearly the same* as target height.
       
   702      * * nearly the same means that it is exactly the same or differs by at most
       
   703      * 1 pixel.
       
   704      * Please note that a bitmap which is too small (i.e. neither its width or its
       
   705      * height is close to the target width/height) will be regarded as one that
       
   706      * needs scaling.
       
   707      *
       
   708      * @param aBmpSize size of the bitmap
       
   709      * @param aTargetSize size of the area where bitmap will be displayed
       
   710      * @return ETrue if bitmap does not need scaling
       
   711      */
       
   712     TBool BitmapFitsIntoTarget( TSize aBmpSize, TSize aTargetSize ) const;
       
   713 
       
   714     /**
       
   715      * Sets up icon text subcell.
       
   716      *
       
   717      * @since S60 v3.0
       
   718      * @param aTemplateChildArray Array of subcell children where the backdrop subcell template is appended.
       
   719      * @param aItemIndex Index of currently drawn item.
       
   720      * @param aItemText Text used to format item subcell content.
       
   721      * @param aSubcellIncrement Is incremented if backdrop subcell template is appended.
       
   722      * @param aChildIndex Index of a template child.
       
   723      */
       
   724     void SetupTextSubcellL(
       
   725         RArray<TTemplateChild>& aTemplateChildArray, TInt aChildIndex, TInt aItemIndex,
       
   726         RBuf& aItemText, TInt& aSubcellIncrement ) const;
       
   727 
       
   728     /**
       
   729      * Appends text if there is enough free memory.
       
   730      *
       
   731      * @since S60 v3.0
       
   732      * @param aBuffer Buffer to which the text will be added
       
   733      * @param aTextToAppend Text to add
       
   734      */
       
   735     void AppendText( RBuf& aBuffer, const TDesC& aTextToAppend ) const;
       
   736 
       
   737     /**
       
   738      * Returns true if an item having an index equal to aItemIndex is a
       
   739      * floating and dragged item.
       
   740      *
       
   741      * @param aItemIndex An index of a currently drawn item.
       
   742      * @return ETrue if an item is floating and dragged.
       
   743      */
       
   744     TBool IsFloating( TInt aItemIndex ) const;
       
   745 
       
   746     /**
       
   747      * Returns highlight visibility.
       
   748      *
       
   749      * @param aItemIndex An index of a currently drawn item.
       
   750      * @param aItemIsCurrent Is aItemIndex the current item index.
       
   751      * @param aAllowHighlightForNonDraggedItem Should highlight be shown
       
   752      * 	(set in case when effects are used).
       
   753      * @return ETrue if highlight is drawn for the actually drawn item.
       
   754      */
       
   755     TBool GetHighlightVisibility(  TInt aItemIndex,
       
   756         TBool aItemIsCurrent, TBool aAllowHighlightForNonDraggedItem  ) const;
       
   757 
       
   758     /**
       
   759      * Returns backdrop visibility.
       
   760      *
       
   761      * @param aItemIndex An index of a currently drawn item.
       
   762      * @param aItemIsCurrent Is aItemIndex the current item index.
       
   763      * @return ETrue if backdrop is visible for the currently drawn item.
       
   764      */
       
   765     TBool GetBackdropVisibility( TInt aItemIndex, TBool aItemIsCurrent ) const;
       
   766 
       
   767     /**
       
   768      * Checks if item has specified floating type.
       
   769      *
       
   770      * @param aItemIndex Item index.
       
   771      * @param aFloatingType Floating type to check on the item.
       
   772      * @return ETrue if the item is of the given floating type.
       
   773      */
       
   774     TBool ItemHasFloatingType( TInt aItemIndex, TMmFloatingItemType aFloatingType) const;
       
   775 
       
   776 public:
       
   777     /**
       
   778      * Animator used by drawer to animate item transitions.
       
   779      * Own
       
   780      */
       
   781     CMmDrawerAnimator* iAnimator;
       
   782 
       
   783 private: // Data
       
   784     /**
       
   785      * Listbox model.
       
   786      * Not own.
       
   787      */
       
   788     CMmListBoxModel* iMmModel;
       
   789 
       
   790     /**
       
   791      * Font.
       
   792      */
       
   793     const CFont * iFont;
       
   794 
       
   795     /**
       
   796      * Drawer owner widget type (list/grid).
       
   797      */
       
   798     TMmWidgetType iWidgetType;
       
   799 
       
   800     /**
       
   801      * Is draggable flag.
       
   802      */
       
   803     TBool iDraggable;
       
   804 
       
   805     /**
       
   806      * Widget.
       
   807      */
       
   808     CEikListBox* iWidget;
       
   809 
       
   810     /**
       
   811      * Background context.
       
   812      * Not own.
       
   813      */
       
   814     CAknsBasicBackgroundControlContext * iBgContext;
       
   815 
       
   816     /**
       
   817      * Redraw background flag.
       
   818      */
       
   819     TBool iRedrawBackground;
       
   820 
       
   821     /**
       
   822      * Draw separators flag.
       
   823      */
       
   824     TBool iDrawSeparatorLines;
       
   825 
       
   826     /**
       
   827      * Ratio of zooming animation.
       
   828      */
       
   829     TReal iIconAnimationZoomRatio;
       
   830 
       
   831     /**
       
   832      * Zommed item index.
       
   833      */
       
   834     TInt iZoomIconIndex;
       
   835 
       
   836     /**
       
   837      * Is edit mode flag.
       
   838      */
       
   839     TBool iIsEditMode;
       
   840 
       
   841     /**
       
   842      * Array of floating items.
       
   843      */
       
   844     RArray<TMmFloatingItem> iFloatingItems;
       
   845 
       
   846     /**
       
   847      * Just draw backdrop flag.
       
   848      */
       
   849     TBool iLeftOverAreaUnderAnimatedItem;
       
   850 
       
   851     /**
       
   852      * Is drawn item an indicator item.
       
   853      */
       
   854     TBool iIsIndicatorItem;
       
   855 
       
   856     /**
       
   857      * Marquee adapter.
       
   858      */
       
   859     CMmMarqueeAdapter* iMarqueeAdapter;
       
   860 
       
   861     /**
       
   862      * Subcell item text.
       
   863      */
       
   864     HBufC* iSubcellText;
       
   865 
       
   866     /**
       
   867      * Is marquee being drawn flag;
       
   868      */
       
   869     TBool iIsMarqueeBeingDrawn;
       
   870 
       
   871     /**
       
   872      * Number of columns in widget.
       
   873      */
       
   874     TInt iNumberOfColsInWidget;
       
   875 
       
   876     /**
       
   877      * Original mask of the dragged item.
       
   878      * Not own.
       
   879      */
       
   880     CFbsBitmap* iOriginalMask;
       
   881 
       
   882     /**
       
   883      * Gul Icon of the item dragged.
       
   884      * Not own.
       
   885      */
       
   886     CGulIcon* iGulDragged;
       
   887 
       
   888     /**
       
   889      * Temporary mask of the dragged item.
       
   890      * Not own.
       
   891      */
       
   892     CFbsBitmap* iDragMask;
       
   893 
       
   894     /**
       
   895      * Indicates id original gul had external bitmaps.
       
   896      */
       
   897     TBool iExternalBitamp;
       
   898 
       
   899     /**
       
   900      * Indicates if highlight should be shown.
       
   901      */
       
   902     TBool iHighlightShown;
       
   903 
       
   904     /**
       
   905      * Indicates if move indicators should be drawn.
       
   906      */
       
   907     TBool iDrawMoveIndicators;
       
   908 
       
   909     /**
       
   910      * Template library. Stores template attributes.
       
   911      * Not own.
       
   912      */
       
   913     CMmTemplateLibrary* iTemplateLibrary;
       
   914 
       
   915     /**
       
   916      * Storage for cached items data. The data is updated during normal operation
       
   917      * and used when iUseCache is ETrue.
       
   918      * Own.
       
   919      */
       
   920     CMmItemsDataCache* iItemsDataCache;
       
   921 
       
   922     /**
       
   923      * This flag tells whether to rely on cached data (when possible) or
       
   924      * to obtain data from the model normally. It should be set to ETrue
       
   925      * when drawing performance is critical (e.g. during flick).
       
   926      */
       
   927     TBool iUseCache;
       
   928 
       
   929     /**
       
   930      * Stores information on the last used subcells configuration.
       
   931      * Such information is needed to determine whether it is necessary to
       
   932      * setup subcells before drawing a particular item or is it possible
       
   933      * to skip this step because the subcells are already set properly.
       
   934      */
       
   935     mutable TMmSubcellsSetupCode iLastSubcellsSetupCode;
       
   936 
       
   937     /**
       
   938      * Set to ETrue if item has backdrop.
       
   939      */
       
   940     mutable TBool iItemHasBackdrop;
       
   941 
       
   942     /**
       
   943      * Number of subcells in iData.
       
   944      */
       
   945     mutable TInt iCurrentNumberOfSubcellsSet;
       
   946 
       
   947     /**
       
   948      * A structure that stores color information needed to draw an item.
       
   949      */
       
   950     mutable CFormattedCellListBoxData::TColors iColors;
       
   951 
       
   952     /**
       
   953      * ETrue if the item that was last drawn was a floating item.
       
   954      */
       
   955     mutable TBool iLastDrawnItemWasFloating;
       
   956 
       
   957     /**
       
   958      * ETrue if the drawing item is floating item of swap transition type.
       
   959      */
       
   960     mutable TBool iIsSwapFloating;
       
   961 
       
   962   };
       
   963 
       
   964 #endif // MMLISTBOXITEMDRAWER_H