menufw/menufwui/mmwidgets/inc/mmlistboxitemdrawer.h
changeset 0 f72a12da539e
child 4 4d54b72983ae
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     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.14 % << 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      * Checks if item background redrawing is enabled.
       
   242      *
       
   243      * @since S60 v3.0
       
   244      * @return Is background redrawing enabled.
       
   245      */
       
   246     TBool IsRedrawItemBackgroundEnabled() const;
       
   247 
       
   248     /**
       
   249      * Draws empty item ( no subcells ).
       
   250      *
       
   251      * @since S60 v3.0
       
   252      * @param aItemIndex Item index.
       
   253      * @param aItemRectPos Item rectangle position.
       
   254      * @param aViewIsDimmed Is view dimmed.
       
   255      */
       
   256     void DrawEmptyItem( TInt aItemIndex,
       
   257             TPoint aItemRectPos,  TBool aViewIsDimmed ) const;
       
   258 
       
   259     /**
       
   260      * Sets edit mode condition.
       
   261      *
       
   262      * @since S60 v3.0
       
   263      * @param aIsEditMode Is edit mode.
       
   264      */
       
   265     void SetEditModeL( TBool aIsEditMode );
       
   266 
       
   267     /**
       
   268      * Checks if edit mode is running.
       
   269      *
       
   270      * @since S60 v3.0
       
   271      * @return Is edit mode running.
       
   272      */
       
   273     TBool IsEditMode() const;
       
   274 
       
   275     /**
       
   276      * Animates dragged item transition.
       
   277      *
       
   278      * @since S60 v3.0
       
   279      */
       
   280     void AnimateDragItemTransitionL( );
       
   281 
       
   282     /**
       
   283      * Animates swapping of items.
       
   284      *
       
   285      * @since S60 v3.0
       
   286      * @param aItemFrom Start item position (index).
       
   287      * @param aItemTo End item position (index).
       
   288      */
       
   289     void AnimateItemSwapL( TInt aItemFrom, TInt aItemTo );
       
   290 
       
   291     /**
       
   292      * Animate item zoom in.
       
   293      *
       
   294      * @since S60 v3.0
       
   295      * @param aItemIndex Item index of item to be zoomed in.
       
   296      */
       
   297     void AnimateItemZoomInL( TInt aItemIndex );
       
   298 
       
   299     /**
       
   300      * Animate item zoom out.
       
   301      *
       
   302      * @since S60 v3.0
       
   303      * @param aItemIndex Item index of zoomed item.
       
   304      */
       
   305     void AnimateItemZoomOutL( TInt aItemIndex );
       
   306 
       
   307     /**
       
   308      * Checks if item drawer is ready to run new animation.
       
   309      *
       
   310      * @since S60 v3.0
       
   311      * @return Is drawer ready to run animation.
       
   312      */
       
   313     CMmDrawerAnimator* GetAnimator();
       
   314 
       
   315     /**
       
   316      * Draws floating items.
       
   317      *
       
   318      * @since S60 v3.0
       
   319      * @param aCurrentlyDrawnRect Currently drawn item rectangle.
       
   320      */
       
   321     void DrawFloatingItems( TRect aCurrentlyDrawnRect );
       
   322 
       
   323     /**
       
   324      * Gets floating item index.
       
   325      *
       
   326      * @since S60 v3.0
       
   327      * @param aType Floating item type.
       
   328      * @return Floating item index.
       
   329      */
       
   330     TInt GetFloatingItemIndex( TMmFloatingItemType aType ) const;
       
   331 
       
   332     /**
       
   333      * Gets floating item.
       
   334      *
       
   335      * @since S60 v3.0
       
   336      * @param aType Floating item type.
       
   337      * @return Floating item.
       
   338      */
       
   339     TMmFloatingItem& GetFloatingItemL( TMmFloatingItemType aType );
       
   340 
       
   341     /**
       
   342      * Gets number of floating items.
       
   343      *
       
   344      * @since S60 5.0
       
   345      * @param aType Floating item type.
       
   346      * @return Number of floating items.
       
   347      */
       
   348     TInt GetValidFloatingItemCount( TMmFloatingItemType aType );
       
   349 
       
   350     /**
       
   351      * Gets floating items count.
       
   352      *
       
   353      * @since S60 5.0
       
   354      * @return Number of the floating items in the array.
       
   355      */
       
   356     TInt GetFloatingItemCount();
       
   357 
       
   358     /**
       
   359      * Adds floating item to the floating item array.
       
   360      *
       
   361      * @since S60 5.0
       
   362      * @param aFloatingItem Floating item to be added.
       
   363      * @param aPosition Position to add at.
       
   364      */
       
   365     void AddFloatingItemL( TMmFloatingItem& aFloatingItem,
       
   366             TInt aPosition = KErrNotFound );
       
   367 
       
   368     /**
       
   369      * Removes floating item.
       
   370      *
       
   371      * @since S60 5.0
       
   372      * @param aPosition Floating item index to be removed.
       
   373      */
       
   374     void RemoveFloatingItem( TInt aPosition );
       
   375     
       
   376     /**
       
   377      * Removes all floating items.
       
   378      *
       
   379      * @since S60 5.0
       
   380      */
       
   381     void RemoveFloatingItems();
       
   382     
       
   383     /**
       
   384      * Gets floating item at particular index in the
       
   385      * floating item array.
       
   386      *
       
   387      * @since S60 5.0
       
   388      * @param aIndex Index of the floating item in the array.
       
   389      * @return Floating item.
       
   390      */
       
   391     TMmFloatingItem& GetFloatingItemAtIndex( TInt aIndex );
       
   392 
       
   393     /**
       
   394      * Used to set scrollbar visibility flag.
       
   395      *
       
   396      * @since S60 v3.0
       
   397      * @param aIsScrollbarVisible Is scrollbar visible.
       
   398      */
       
   399     void SetScrollbarVisibilityL( TBool aIsScrollbarVisible );
       
   400 
       
   401     /**
       
   402      * Replaces subcell text.
       
   403      *
       
   404      * @since S60 v3.0
       
   405      * @param aText Text which will replace previous text.
       
   406      */
       
   407     void ReplaceSubCellText( const TDesC& aText );
       
   408 
       
   409     /**
       
   410      * Adds subcell marquee element.
       
   411      *
       
   412      * @since S60 v3.0
       
   413      * @param aSubCellTemplate Subcell template data.
       
   414      * @param aIndex Subcell index.
       
   415      * @param aItemIndex Item index.
       
   416      */
       
   417     void AddSubcellMarqueeElementL( TTemplateChild aSubCellTemplate,
       
   418             TInt aIndex, TInt aItemIndex );
       
   419 
       
   420     /**
       
   421      * Sets the marquee adapter.
       
   422      *
       
   423      * @since S60 v3.0
       
   424      * @param aAdapter Marquee adapter.
       
   425      */
       
   426     void SetMarqueeAdapter( CMmMarqueeAdapter* aAdapter );
       
   427 
       
   428     /**
       
   429      * Sets the flag which tells that marquee is currently being drawn.
       
   430      *
       
   431      * @since S60 v3.0
       
   432      * @param aIsMarqueeBeingDrawn Is marquee being drawn.
       
   433      */
       
   434     void SetMarqueeDrawing( TBool aIsMarqueeBeingDrawn );
       
   435 
       
   436     /**
       
   437      * Checks if text is clipped.
       
   438      *
       
   439      * @since S60 v3.0
       
   440      * @param aTemplateChild Subcell template data.
       
   441      * @param aText Text to be clipped.
       
   442      * @return Is text clipped.
       
   443      */
       
   444     TBool IsTextClippedL( TTemplateChild aTemplateChild,
       
   445             const TDesC& aText ) const;
       
   446 
       
   447     /**
       
   448      * Sets the flag which tells that a scrollbar event is running.
       
   449      *
       
   450      * @since S60 v3.0
       
   451      * @param aIsRunning Is scrollbar event running.
       
   452      */
       
   453 	void SetScrollbarEventRunning( TBool aIsRunning );
       
   454 
       
   455     /**
       
   456      * Sets number of columns in view.
       
   457      *
       
   458      * @since S60 v3.0
       
   459      * @param aNumberOfColumns Number of columns in view.
       
   460      */
       
   461 	void SetNumberOfColsInView( TInt aNumberOfColumns );
       
   462 
       
   463 	/**
       
   464 	 * Used in non-touch edit mode to block drawing of move indicators and highlight
       
   465 	 * to clean screen for animation.
       
   466 	 *
       
   467 	 * @since S60 v3.0
       
   468 	 * @param aDrawn Should highlight and move indicators be drawn.
       
   469 	 */
       
   470 	void SetHighlightShown( TBool aDrawn );
       
   471 
       
   472 protected:
       
   473     /**
       
   474      * From CListItemDrawer. Draws an item.
       
   475      *
       
   476      * @since S60 v3.0
       
   477      * @param aItemIndex Item index to be drawn.
       
   478      * @param aItemRectPos Item rectangle position.
       
   479      * @param aItemIsSelected Is item selected.
       
   480      * @param aItemIsCurrent Is item current.
       
   481      * @param aViewIsEmphasized Is view emphasized.
       
   482      * @param aViewIsDimmed Is view dimmed.
       
   483      */
       
   484     void DrawItem( TInt aItemIndex, TPoint aItemRectPos,
       
   485                    TBool aItemIsSelected, TBool aItemIsCurrent,
       
   486                    TBool aViewIsEmphasized, TBool aViewIsDimmed ) const;
       
   487 
       
   488     /**
       
   489      * Draws item according to format text.
       
   490      *
       
   491      * @since S60 v3.0
       
   492      * @param aItemIndex Item index to be drawn.
       
   493      * @param aItemTextRect Item rectangle.
       
   494      * @param aItemIsCurrent Is item current.
       
   495      * @param aViewIsEmphasized Is view emphasized.
       
   496      * @param aItemIsSelected Is item selected.
       
   497      */
       
   498     void DrawItemText( TInt aItemIndex, const TRect& aItemTextRect,
       
   499     		TBool aItemIsCurrent, TBool aViewIsEmphasized,
       
   500     		TBool aItemIsSelected ) const;
       
   501     /**
       
   502      * Draws the actual item contents for the specified item in the specified 
       
   503      * rectangle.
       
   504      *
       
   505      * @param aItemIndex Index of the item to draw. 
       
   506      * @param aActualItemRect Area to draw into. 
       
   507      * @param aItemIsCurrent @c ETrue if the item is current. 
       
   508      * @param aViewIsEmphasized @c ETrue if the view is emphasised. 
       
   509      * @param aViewIsDimmed Ignored
       
   510      * @param aItemIsSelected @c ETrue if the item is selected.
       
   511      */
       
   512     void DrawActualItem(TInt aItemIndex, const TRect& aActualItemRect,
       
   513 			TBool aItemIsCurrent, TBool aViewIsEmphasized, TBool aViewIsDimmed,
       
   514 			TBool aItemIsSelected) const;
       
   515     /**
       
   516      * Draws background and separator lines.
       
   517      *
       
   518      * @since S60 v3.0
       
   519      * @param aItemTextRect Item rectangle.
       
   520      */
       
   521     void DrawBackgroundAndSeparatorLines( const TRect& aItemTextRect ) const;
       
   522 
       
   523     /**
       
   524      * Sets up item currently drawn item subcells.
       
   525      * Also, fills-in/updates the cache information for the item at index
       
   526      * aItemIndex.
       
   527      *
       
   528      * @since S60 v3.0
       
   529      * @param aItemIsCurrent Is item the current item in widget.
       
   530      * @param aItemIndex Item index.
       
   531      */
       
   532     void SetupSubCellsL( TBool aItemIsCurrent, TInt aItemIndex ) const;
       
   533 
       
   534     /**
       
   535      * Sets up subcell to be drawn by listbox data.
       
   536      *
       
   537      * @since S60 v3.0
       
   538      * @param aSubCellTemplate Subcell template data.
       
   539      * @param aIndex Subcell index.
       
   540      * @param aItemIndex Item index.
       
   541      */
       
   542     void SetupSubCellL( TTemplateChild aSubCellTemplate, TInt aIndex,
       
   543             TInt aItemIndex ) const;
       
   544 
       
   545     /**
       
   546      * Sets up "null" subcell to be avoided when drawing.
       
   547      *
       
   548      * @since S60 v3.0
       
   549      * @param aIndex Subcell index.
       
   550      * @param aItemIndex Item index.
       
   551      */
       
   552     void SetupSubNoCellL( TInt aIndex, TInt aItemIndex ) const;
       
   553 
       
   554     /**
       
   555      * Sets up icon for dragged subcell.
       
   556      *
       
   557      * @since S60 v3.0
       
   558      * @param aSubCellTemplate Subcell template data.
       
   559      * @param aIndex Subcell index.
       
   560      * @param aItemIndex Index of dragged item.
       
   561      */
       
   562     void SetupSubIcondDragHighlightCellL( TTemplateChild aSubCellTemplate,
       
   563             TInt aIndex, TInt aItemIndex ) const;
       
   564 
       
   565     /**
       
   566      * Adjusts rectangle of item.
       
   567      *
       
   568      * @since S60 v3.0
       
   569      * @param aItemIndex Item's index which adjust rectangle.
       
   570      * @return Index of item which rectangle should be adjusted.
       
   571      */
       
   572     TRect AdjustItemRect( TInt aItemIndex ) const;
       
   573 
       
   574     /**
       
   575      * Draws the move indicator over the indicated item.
       
   576      *
       
   577      * @since S60 v3.0
       
   578      * @param aItemIndex Item index with move indicator.
       
   579      * @param aActualItemRect The actual rectangle of indicator item.
       
   580      */
       
   581     void DrawActualIndicatorItem( TInt aItemIndex, TRect aActualItemRect );
       
   582 
       
   583     /**
       
   584      * Sets up colors for subcell data.
       
   585      *
       
   586      * @since S60 v3.0
       
   587      * @return Colors for subcell drawing.
       
   588      */
       
   589     CFormattedCellListBoxData::TColors SetupColors( TBool aDragged = EFalse ) const;
       
   590 
       
   591 private:
       
   592 
       
   593     /**
       
   594      * Default constructor.
       
   595      *
       
   596      * @since S60 v3.0
       
   597      * @param  aMmListBoxModel List box model.
       
   598      * @param  aFont Font needed by base constructor.
       
   599      * @param  aFormattedCellData Used to format subcell data in item drawer.
       
   600      * @param  aWidgetType Type of widgte (list/grid).
       
   601      * @param  aTemplateLibrary TemplateLibrary contains items sizes.
       
   602      */
       
   603     CMmListBoxItemDrawer( CMmListBoxModel* aMmListBoxModel,
       
   604             const CFont* aFont,
       
   605             CFormattedCellListBoxData* aFormattedCellData,
       
   606             TMmWidgetType aWidgetType, CMmTemplateLibrary* aTemplateLibrary );
       
   607 
       
   608     /**
       
   609      * 2nd phase constructor.
       
   610      *
       
   611      * @since S60 v3.0
       
   612      */
       
   613     void ConstructL();
       
   614 
       
   615     /**
       
   616      *Draws the item text according to the format defined by a text string.
       
   617      *
       
   618      * @since S60 v3.0
       
   619      * @param aItemIndex Item index to be drawn.
       
   620      * @param aItemTextRect Item rectangle.
       
   621      * @param aItemIsCurrent Is item current.
       
   622      * @param aViewIsEmphasized Is view emphasized.
       
   623      * @param aItemIsSelected Is item selected.
       
   624      */
       
   625     void DoDrawItemTextL( TInt aItemIndex, const TRect& aItemTextRect,
       
   626         TBool aItemIsCurrent, TBool aViewIsEmphasized,
       
   627         TBool aItemIsSelected ) const;
       
   628 
       
   629     /**
       
   630      * Draws an item.
       
   631      *
       
   632      * @since S60 v3.0
       
   633      * @param aItemIndex Item index to be drawn.
       
   634      * @param aItemRectPos Position of item rectangle.
       
   635      * @param aItemIsSelected Is item selected.
       
   636      * @param aItemIsCurrent Is item current.
       
   637      * @param aViewIsEmphasized Is view emphasized.
       
   638      * @param aViewIsDimmed Is view dimmed.
       
   639      */
       
   640     void DoDrawItem(TInt aItemIndex, TPoint aItemRectPos,
       
   641         TBool aItemIsSelected, TBool aItemIsCurrent, TBool aViewIsEmphasized,
       
   642         TBool aViewIsDimmed) const;
       
   643 
       
   644     /**
       
   645      * Sets up backdrop image subcell.
       
   646      *
       
   647      * @since S60 v3.0
       
   648      * @param aTemplateChildArray Array of subcell children where the backdrop subcell template is appended.
       
   649      * @param aItemIndex Index of currently drawn item.
       
   650      * @param aItemText Text used to format item subcell content.
       
   651      * @param aSubcellIncrement Is incremented if backdrop subcell template is appended.
       
   652      */
       
   653     void SetupBackdropSubcellL(
       
   654     		RArray<TTemplateChild>& aTemplateChildArray, TInt aItemIndex,
       
   655             RBuf& aItemText, TInt& aSubcellIncrement ) const;
       
   656 
       
   657     /**
       
   658      * Sets up icon image subcell.
       
   659      *
       
   660      * @since S60 v3.0
       
   661      * @param aTemplateChildArray Array of subcell children where the backdrop subcell template is appended.
       
   662      * @param aChildIndex Index of a template child.
       
   663      * @param aItemIndex Index of currently drawn item.
       
   664      * @param aItemText Text used to format item subcell content.
       
   665      * @param aSubcellIncrement Is incremented if backdrop subcell template is appended.
       
   666      */
       
   667     void SetupIconSubcellL(
       
   668     		RArray<TTemplateChild>& aTemplateChildArray, TInt aChildIndex, TInt aItemIndex,
       
   669     		RBuf& aItemText, TInt& aSubcellIncrement ) const;
       
   670     
       
   671     /**
       
   672      * Determines whether a bitmap of given size needs scaling to be displayed
       
   673      * in a rectangular area of some given target size.
       
   674      * 
       
   675      * This method assumes that the bitmap will always be scaled with aspect
       
   676      * ratio preserved. A bitmap does not need scaling if its size meets either
       
   677      * of the two conditions:
       
   678      * 1. bitmap width is nearly the same* as target area width and bitmap height
       
   679      *    is not greater than target height
       
   680      * 2. bitmap width is not greater that target width and bitmap height is
       
   681      *    nearly the same* as target height.
       
   682      * * nearly the same means that it is exactly the same or differs by at most
       
   683      * 1 pixel.
       
   684      * Please note that a bitmap which is too small (i.e. neither its width or its
       
   685      * height is close to the target width/height) will be regarded as one that
       
   686      * needs scaling. 
       
   687      * 
       
   688      * @param aBmpSize size of the bitmap
       
   689      * @param aTargetSize size of the area where bitmap will be displayed
       
   690      * @return ETrue if bitmap does not need scaling
       
   691      */
       
   692     TBool BitmapFitsIntoTarget( TSize aBmpSize, TSize aTargetSize ) const;
       
   693 
       
   694     /**
       
   695      * Sets up icon text subcell.
       
   696      *
       
   697      * @since S60 v3.0
       
   698      * @param aTemplateChildArray Array of subcell children where the backdrop subcell template is appended.
       
   699      * @param aItemIndex Index of currently drawn item.
       
   700      * @param aItemText Text used to format item subcell content.
       
   701      * @param aSubcellIncrement Is incremented if backdrop subcell template is appended.
       
   702      * @param aChildIndex Index of a template child.
       
   703      */
       
   704     void SetupTextSubcellL(
       
   705     		RArray<TTemplateChild>& aTemplateChildArray, TInt aChildIndex, TInt aItemIndex,
       
   706     		RBuf& aItemText, TInt& aSubcellIncrement ) const;
       
   707 
       
   708     /**
       
   709      * Appends text if there is enough free memory.
       
   710      *
       
   711      * @since S60 v3.0
       
   712      * @param aBuffer Buffer to which the text will be added
       
   713      * @param aTextToAppend Text to add
       
   714      */
       
   715     void AppendText( RBuf& aBuffer, const TDesC& aTextToAppend ) const;
       
   716 
       
   717     /**
       
   718      * Returns true if an item having an index equal to aItemIndex is a
       
   719      * floating and dragged item.
       
   720      *
       
   721      * @param aItemIndex An index of a currently drawn item.
       
   722      * @return ETrue if an item is floating and dragged.
       
   723      */
       
   724     TBool IsFloating( TInt aItemIndex ) const;
       
   725 
       
   726     /**
       
   727      * Returns highlight visibility.
       
   728      *
       
   729      * @param aItemIndex An index of a currently drawn item.
       
   730      * @param aItemIsCurrent Is aItemIndex the current item index.
       
   731      * @param aAllowHighlightForNonDraggedItem Should highlight be shown 
       
   732      * 	(set in case when effects are used).
       
   733      * @return ETrue if highlight is drawn for the actually drawn item.
       
   734      */
       
   735     TBool GetHighlightVisibility(  TInt aItemIndex, 
       
   736     		TBool aItemIsCurrent, TBool aAllowHighlightForNonDraggedItem  ) const;
       
   737     
       
   738     /**
       
   739      * Returns backdrop visibility.
       
   740      *
       
   741      * @param aItemIndex An index of a currently drawn item.
       
   742      * @param aItemIsCurrent Is aItemIndex the current item index.
       
   743      * @return ETrue if backdrop is visible for the currently drawn item.
       
   744      */
       
   745     TBool GetBackdropVisibility( TInt aItemIndex, TBool aItemIsCurrent ) const;
       
   746 
       
   747     /**
       
   748      * Checks if item has specified floating type.
       
   749      *
       
   750      * @param aItemIndex Item index.
       
   751      * @param aFloatingType Floating type to check on the item.
       
   752      * @return ETrue if the item is of the given floating type.
       
   753      */
       
   754     TBool ItemHasFloatingType( TInt aItemIndex, TMmFloatingItemType aFloatingType) const;
       
   755 
       
   756 public:
       
   757     /**
       
   758      * Animator used by drawer to animate item transitions.
       
   759      * Own
       
   760      */
       
   761     CMmDrawerAnimator* iAnimator;
       
   762 
       
   763 private: // Data
       
   764     /**
       
   765      * Listbox model.
       
   766      * Not own.
       
   767      */
       
   768     CMmListBoxModel* iMmModel;
       
   769 
       
   770     /**
       
   771      * Font.
       
   772      */
       
   773     const CFont * iFont;
       
   774 
       
   775     /**
       
   776      * Drawer owner widget type (list/grid).
       
   777      */
       
   778     TMmWidgetType iWidgetType;
       
   779 
       
   780     /**
       
   781      * Is draggable flag.
       
   782      */
       
   783     TBool iDraggable;
       
   784 
       
   785     /**
       
   786      * Widget.
       
   787      */
       
   788     CEikListBox* iWidget;
       
   789 
       
   790     /**
       
   791      * Background context.
       
   792      * Not own.
       
   793      */
       
   794     CAknsBasicBackgroundControlContext * iBgContext;
       
   795 
       
   796     /**
       
   797      * Redraw background flag.
       
   798      */
       
   799     TBool iRedrawBackground;
       
   800 
       
   801     /**
       
   802      * Ratio of zooming animation.
       
   803      */
       
   804     TReal iIconAnimationZoomRatio;
       
   805 
       
   806     /**
       
   807      * Zommed item index.
       
   808      */
       
   809     TInt iZoomIconIndex;
       
   810 
       
   811     /**
       
   812      * Is edit mode flag.
       
   813      */
       
   814     TBool iIsEditMode;
       
   815 
       
   816     /**
       
   817      * Array of floating items.
       
   818      */
       
   819     RArray<TMmFloatingItem> iFloatingItems;
       
   820 
       
   821     /**
       
   822      * Just draw backdrop flag.
       
   823      */
       
   824     TBool iLeftOverAreaUnderAnimatedItem;
       
   825 
       
   826     /**
       
   827      * Is drawn item an indicator item.
       
   828      */
       
   829     TBool iIsIndicatorItem;
       
   830 
       
   831     /**
       
   832      * Marquee adapter.
       
   833      */
       
   834     CMmMarqueeAdapter* iMarqueeAdapter;
       
   835 
       
   836     /**
       
   837      * Subcell item text.
       
   838      */
       
   839     HBufC* iSubcellText;
       
   840 
       
   841     /**
       
   842      * Is marquee being drawn flag;
       
   843      */
       
   844     TBool iIsMarqueeBeingDrawn;
       
   845 
       
   846     /**
       
   847      * Number of columns in widget.
       
   848      */
       
   849     TInt iNumberOfColsInWidget;
       
   850 
       
   851     /**
       
   852      * Original mask of the dragged item.
       
   853      * Not own.
       
   854      */
       
   855     CFbsBitmap* iOriginalMask;
       
   856 
       
   857     /**
       
   858      * Gul Icon of the item dragged.
       
   859      * Not own.
       
   860      */
       
   861     CGulIcon* iGulDragged;
       
   862 
       
   863     /**
       
   864      * Temporary mask of the dragged item.
       
   865      * Not own.
       
   866      */
       
   867     CFbsBitmap* iDragMask;
       
   868 
       
   869     /**
       
   870      * Indicates id original gul had external bitmaps.
       
   871      */
       
   872     TBool iExternalBitamp;
       
   873 
       
   874     /**
       
   875      * Indicates if highlight should be shown.
       
   876      */
       
   877     TBool iHighlightShown;
       
   878 
       
   879     /**
       
   880      * Indicates if move indicators should be drawn.
       
   881      */
       
   882     TBool iDrawMoveIndicators;
       
   883 
       
   884     /**
       
   885      * Template library. Stores template attributes.
       
   886      * Not own.
       
   887      */
       
   888     CMmTemplateLibrary* iTemplateLibrary;
       
   889     
       
   890     /**
       
   891      * Storage for cached items data. The data is updated during normal operation
       
   892      * and used when iUseCache is ETrue.
       
   893      * Own.
       
   894      */
       
   895     CMmItemsDataCache* iItemsDataCache;
       
   896 
       
   897     /**
       
   898      * This flag tells whether to rely on cached data (when possible) or
       
   899      * to obtain data from the model normally. It should be set to ETrue
       
   900      * when drawing performance is critical (e.g. during flick).
       
   901      */
       
   902     TBool iUseCache;
       
   903 
       
   904     /**
       
   905      * Stores information on the last used subcells configuration.
       
   906      * Such information is needed to determine whether it is necessary to
       
   907      * setup subcells before drawing a particular item or is it possible
       
   908      * to skip this step because the subcells are already set properly.  
       
   909      */
       
   910     mutable TMmSubcellsSetupCode iLastSubcellsSetupCode;
       
   911 
       
   912     /**
       
   913      * Set to ETrue if item has backdrop.
       
   914      */
       
   915     mutable TBool iItemHasBackdrop;
       
   916 	};
       
   917 
       
   918 #endif // MMLISTBOXITEMDRAWER_H