menufw/menufwui/mmwidgets/src/mmlistboxitemdrawer.cpp
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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <eikfrlb.h>
       
    20 #include "mmwidgetsconstants.h"
       
    21 #include "hnconvutils.h"
       
    22 #include <gdi.h>
       
    23 #include <AknIconArray.h>
       
    24 #include <AknsConstants.h>
       
    25 #include <AknFontAccess.h>
       
    26 #include <aknlistboxtfx.h>
       
    27 #include <layoutmetadata.cdl.h>
       
    28 #include <AknIconUtils.h>
       
    29 #include <AknBidiTextUtils.h>
       
    30 #include <AknDef.hrh>
       
    31 #include <AknLayoutFont.h>
       
    32 
       
    33 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
    34 #include <aknlistloadertfx.h>
       
    35 #include <aknlistboxtfxinternal.h>
       
    36 #endif
       
    37 
       
    38 #include <AknsLayeredBackgroundControlContext.h>
       
    39 #include <AknsListBoxBackgroundControlContext.h>
       
    40 #include "bitmaptransforms.h"
       
    41 #include "mmwidgetsconstants.h"
       
    42 #include "mmlistbox.h"
       
    43 #include "mmtemplatelibrary.h"
       
    44 #include "mmlistboxitemdrawer.h"
       
    45 #include "mmlistboxmodel.h"
       
    46 #include "mmdraweranimator.h"
       
    47 #include "mmmarqueeadapter.h"
       
    48 #include "mmfloatingitem.h"
       
    49 #include "mmgridview.h"
       
    50 #include "mmcacheforitem.h"
       
    51 #include "mmitemsdatacache.h"
       
    52 #include "mmwidgetcontainer.h"
       
    53 #include "hnsuitemodel.h"
       
    54 #include "menudebug.h"
       
    55 
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 CMmListBoxItemDrawer::CMmListBoxItemDrawer(
       
    62         CMmListBoxModel* aMmListBoxModel,
       
    63 	    const CFont* aFont,
       
    64 	    CFormattedCellListBoxData* aFormattedCellData,
       
    65 	    TMmWidgetType aWidgetType,
       
    66 	    CMmTemplateLibrary* aTemplateLibrary )
       
    67 	: CFormattedCellListBoxItemDrawer( aMmListBoxModel , aFont, aFormattedCellData),
       
    68 	iFont(aFont), iLeftOverAreaUnderAnimatedItem(EFalse)
       
    69 	{
       
    70 	iWidgetType = aWidgetType;
       
    71 	iTemplateLibrary = aTemplateLibrary;
       
    72 	iMmModel = aMmListBoxModel;
       
    73 	iRedrawBackground = ETrue;
       
    74 	iZoomIconIndex = -1;
       
    75 	iIconAnimationZoomRatio = 1;
       
    76     SetFlags( CListItemDrawer::EDisableHighlight );
       
    77 	}
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 CMmListBoxItemDrawer::~CMmListBoxItemDrawer()
       
    84 	{
       
    85 	iFloatingItems.Close();
       
    86 	delete iItemsDataCache;
       
    87 	delete iAnimator;
       
    88 	delete iSubcellText;
       
    89 	delete ColumnData()->IconArray();
       
    90     ColumnData()->SetIconArray( NULL );
       
    91 	}
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 // -----------------------------------------------------------------------------
       
    96 //
       
    97 void CMmListBoxItemDrawer::EnableCachedDataUse( TBool aEnable )
       
    98     {
       
    99     __ASSERT_DEBUG( !( aEnable && IsEditMode() ), User::Invariant() );
       
   100     iUseCache = aEnable;
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 TBool CMmListBoxItemDrawer::CachedDataUseIsEnabled() const
       
   108     {
       
   109     return iUseCache;
       
   110     }
       
   111 
       
   112 // -----------------------------------------------------------------------------
       
   113 //
       
   114 // -----------------------------------------------------------------------------
       
   115 //
       
   116 void CMmListBoxItemDrawer::TrimCacheSize( TInt aItemCount )
       
   117     {
       
   118     iItemsDataCache->Trim( aItemCount );
       
   119     }
       
   120 
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 // -----------------------------------------------------------------------------
       
   124 //
       
   125 void CMmListBoxItemDrawer::InvalidateCache()
       
   126     {
       
   127     iItemsDataCache->Invalidate();
       
   128     }
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 CMmListBoxItemDrawer* CMmListBoxItemDrawer::NewLC(
       
   135         CMmListBoxModel* aMmListBoxModel,
       
   136 	    const CFont* aFont,
       
   137 	    CFormattedCellListBoxData* aFormattedCellData,
       
   138 	    TMmWidgetType aWidgetType,
       
   139 	    CMmTemplateLibrary* aTemplateLibrary )
       
   140 	{
       
   141 	CMmListBoxItemDrawer* self = new (ELeave)CMmListBoxItemDrawer(
       
   142 			aMmListBoxModel, aFont, aFormattedCellData, aWidgetType,
       
   143 			aTemplateLibrary );
       
   144 	CleanupStack::PushL(self);
       
   145 	self->ConstructL();
       
   146 	return self;
       
   147 	}
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 //
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 CMmListBoxItemDrawer* CMmListBoxItemDrawer::NewL(
       
   154         CMmListBoxModel* aMmListBoxModel,
       
   155 	    const CFont* aFont,
       
   156 	    CFormattedCellListBoxData* aFormattedCellData,
       
   157 	    TMmWidgetType aWidgetType,
       
   158 	    CMmTemplateLibrary* aTemplateLibrary )
       
   159 	{
       
   160 	CMmListBoxItemDrawer* self = CMmListBoxItemDrawer::NewLC(
       
   161 	    aMmListBoxModel, aFont, aFormattedCellData, aWidgetType,
       
   162         aTemplateLibrary );
       
   163 	CleanupStack::Pop( self );
       
   164 	return self;
       
   165 
       
   166 	}
       
   167 
       
   168 // -----------------------------------------------------------------------------
       
   169 //
       
   170 // -----------------------------------------------------------------------------
       
   171 //
       
   172 void CMmListBoxItemDrawer::SetView(CEikListBox * aView)
       
   173     {
       
   174     iWidget = aView;
       
   175     }
       
   176 
       
   177 // -----------------------------------------------------------------------------
       
   178 //
       
   179 // -----------------------------------------------------------------------------
       
   180 //
       
   181 CEikListBox* CMmListBoxItemDrawer::Widget() const
       
   182     {
       
   183     return iWidget;
       
   184     }
       
   185 
       
   186 // -----------------------------------------------------------------------------
       
   187 //
       
   188 // -----------------------------------------------------------------------------
       
   189 //
       
   190 void CMmListBoxItemDrawer::ConstructL()
       
   191 	{
       
   192 	iAnimator = CMmDrawerAnimator::NewL( *this );
       
   193 	iItemsDataCache = CMmItemsDataCache::NewL();
       
   194 	iIsEditMode = EFalse;
       
   195 	iHighlightShown = EFalse;
       
   196 	iDrawMoveIndicators = ETrue;
       
   197 	}
       
   198 
       
   199 // ----xm-------------------------------------------------------------------------
       
   200 //
       
   201 // -----------------------------------------------------------------------------
       
   202 //
       
   203 void CMmListBoxItemDrawer::DrawEmptyItem( TInt aItemIndex,
       
   204         TPoint aItemRectPos,  TBool aViewIsDimmed ) const
       
   205     {
       
   206     TRect r( aItemRectPos, iItemCellSize );
       
   207 
       
   208     CFormattedCellListBoxItemDrawer::DrawEmptyItem( aItemIndex, aItemRectPos,
       
   209         aViewIsDimmed );
       
   210 
       
   211     const_cast<CMmListBoxItemDrawer*>(this)->DrawFloatingItems(r);
       
   212     }
       
   213 
       
   214 // -----------------------------------------------------------------------------
       
   215 //
       
   216 // -----------------------------------------------------------------------------
       
   217 //
       
   218 TInt CMmListBoxItemDrawer::GetFloatingItemIndex(TMmFloatingItemType aType) const
       
   219     {
       
   220     TInt ret (KErrNotFound);
       
   221     TInt i(iFloatingItems.Count()-1);
       
   222     for(; i >= 0; i--)
       
   223         {
       
   224         if (iFloatingItems[i].GetFloatingItemType() == aType)
       
   225             {
       
   226             ret = i;
       
   227             break;
       
   228             }
       
   229         }
       
   230 
       
   231     return ret;
       
   232     }
       
   233 
       
   234 // -----------------------------------------------------------------------------
       
   235 //
       
   236 // -----------------------------------------------------------------------------
       
   237 //
       
   238 TMmFloatingItem& CMmListBoxItemDrawer::GetFloatingItemL(TMmFloatingItemType aType)
       
   239     {
       
   240     TInt index = GetFloatingItemIndex(aType);
       
   241     User::LeaveIfError( index );
       
   242     return iFloatingItems[ index ];
       
   243     }
       
   244 
       
   245 // -----------------------------------------------------------------------------
       
   246 //
       
   247 // -----------------------------------------------------------------------------
       
   248 //
       
   249 void CMmListBoxItemDrawer::AnimateDragItemTransitionL()
       
   250     {
       
   251     iAnimator->AnimateDragItemTransitionL();
       
   252     iAnimator->Trigger();
       
   253     }
       
   254 
       
   255 // -----------------------------------------------------------------------------
       
   256 //
       
   257 // -----------------------------------------------------------------------------
       
   258 //
       
   259 void CMmListBoxItemDrawer::AnimateItemSwapL( TInt aItemFrom, TInt aItemTo )
       
   260     {
       
   261     iAnimator->AnimateItemSwapL( aItemFrom, aItemTo );
       
   262     iAnimator->Trigger();
       
   263     }
       
   264 
       
   265 // -----------------------------------------------------------------------------
       
   266 //
       
   267 // -----------------------------------------------------------------------------
       
   268 //
       
   269 void CMmListBoxItemDrawer::AnimateItemZoomInL( TInt aItemIndex )
       
   270     {
       
   271     iAnimator->AnimateItemZoomL( aItemIndex, ETrue );
       
   272     iAnimator->Trigger();
       
   273     }
       
   274 
       
   275 // -----------------------------------------------------------------------------
       
   276 //
       
   277 // -----------------------------------------------------------------------------
       
   278 //
       
   279 void CMmListBoxItemDrawer::AnimateItemZoomOutL( TInt aItemIndex )
       
   280     {
       
   281     iAnimator->AnimateItemZoomL( aItemIndex, EFalse );
       
   282     iAnimator->Trigger();
       
   283     }
       
   284 
       
   285 // -----------------------------------------------------------------------------
       
   286 //
       
   287 // -----------------------------------------------------------------------------
       
   288 //
       
   289 void CMmListBoxItemDrawer::DrawFloatingItems(TRect currentlyDrawnRect)
       
   290     {
       
   291     SetRedrawItemBackground( EFalse );
       
   292     for(TInt i(iFloatingItems.Count()-1); i >= 0 ; i--)
       
   293         {
       
   294         TMmFloatingItemType type = iFloatingItems[i].GetFloatingItemType();
       
   295         if ( iFloatingItems[i].IsFloatingItemValid() )
       
   296             {
       
   297             TInt drawnItemIndex = iFloatingItems[i].GetDrawnItemIndex();
       
   298             TSize size = iWidget->View()->ItemSize( drawnItemIndex );
       
   299             TRect rect( iFloatingItems[i].GetItemPosition(), iFloatingItems[i].GetItemPosition() + size);
       
   300             
       
   301             if (rect.Intersects(currentlyDrawnRect))
       
   302 				{
       
   303 				TInt tempZoomIconIndex = iZoomIconIndex;
       
   304 				TInt tempZoomRatio = iIconAnimationZoomRatio;
       
   305 
       
   306 				iZoomIconIndex = iFloatingItems[i].GetDrawnItemIndex();
       
   307 				iIconAnimationZoomRatio = iFloatingItems[i].GetCurrentZoomRatio();
       
   308 
       
   309 				if ( ItemHasFloatingType( drawnItemIndex, EDrag) ||
       
   310 						ItemHasFloatingType( drawnItemIndex, EDragTransition) )
       
   311 					{
       
   312 					ClearFlags( CListItemDrawer::EPressedDownState );
       
   313 					}
       
   314 				
       
   315 				DrawActualItem( drawnItemIndex, rect, ETrue, EFalse, EFalse, EFalse );
       
   316 				iIconAnimationZoomRatio = tempZoomRatio;
       
   317 				iZoomIconIndex = tempZoomIconIndex;
       
   318 				}
       
   319             }
       
   320         else
       
   321         	{
       
   322             iFloatingItems.Remove(i);
       
   323         	}
       
   324         }
       
   325     SetRedrawItemBackground( ETrue );
       
   326     }
       
   327 
       
   328 // -----------------------------------------------------------------------------
       
   329 //
       
   330 // -----------------------------------------------------------------------------
       
   331 //
       
   332 TInt CMmListBoxItemDrawer::GetValidFloatingItemCount(TMmFloatingItemType aType)
       
   333     {
       
   334     TInt count (0);
       
   335 
       
   336     for(TInt i(iFloatingItems.Count()-1); i >= 0; i--)
       
   337         {
       
   338         if (iFloatingItems[i].GetFloatingItemType() == aType
       
   339                 && iFloatingItems[i].IsFloatingItemValid() )
       
   340             count++;
       
   341         }
       
   342     return count;
       
   343     }
       
   344 // -----------------------------------------------------------------------------
       
   345 //
       
   346 // -----------------------------------------------------------------------------
       
   347 //
       
   348 void CMmListBoxItemDrawer::DrawItem(TInt aItemIndex, TPoint aItemRectPos,
       
   349         TBool aItemIsSelected, TBool aItemIsCurrent, TBool aViewIsEmphasized,
       
   350         TBool aViewIsDimmed) const
       
   351         {
       
   352         if ( !Widget()->View()->RedrawDisabled() )
       
   353             {
       
   354             DoDrawItem( aItemIndex, aItemRectPos, aItemIsSelected,
       
   355                     aItemIsCurrent, aViewIsEmphasized, aViewIsDimmed);
       
   356             }
       
   357         }
       
   358 // -----------------------------------------------------------------------------
       
   359 //
       
   360 // -----------------------------------------------------------------------------
       
   361 //
       
   362 void CMmListBoxItemDrawer::DoDrawItem(TInt aItemIndex, TPoint aItemRectPos,
       
   363         TBool aItemIsSelected, TBool aItemIsCurrent, TBool aViewIsEmphasized,
       
   364         TBool aViewIsDimmed) const
       
   365     {
       
   366     TSize itemCellSize = TSize( GetItemSize( aItemIndex, aItemIsCurrent ));
       
   367     TRect actualItemRect(aItemRectPos, itemCellSize);
       
   368 
       
   369 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   370 	MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( iGc );
       
   371 	if ( transApi )
       
   372 		{
       
   373 		transApi->StartDrawing( MAknListBoxTfxInternal::EListView );
       
   374 		transApi->StopDrawing();
       
   375 		transApi->BeginRedraw( MAknListBoxTfxInternal::EListItem,
       
   376 				actualItemRect, aItemIndex );
       
   377 		}
       
   378 #endif
       
   379 
       
   380     const_cast<CMmListBoxItemDrawer*>(this)->iLeftOverAreaUnderAnimatedItem = EFalse;
       
   381     for(TInt i(iFloatingItems.Count()-1); i >= 0; i--)
       
   382         {
       
   383         if ( iFloatingItems[i].GetDrawnItemIndex() == aItemIndex
       
   384         		&& iFloatingItems[i].IsFloatingItemValid() )
       
   385             {
       
   386             const_cast<CMmListBoxItemDrawer*>(this)->iLeftOverAreaUnderAnimatedItem = ETrue;
       
   387             break;
       
   388             }
       
   389         }
       
   390 
       
   391     DrawActualItem(aItemIndex, actualItemRect, aItemIsCurrent, aViewIsEmphasized,
       
   392     		aViewIsDimmed, aItemIsSelected);
       
   393     const_cast<CMmListBoxItemDrawer*>(this)->iLeftOverAreaUnderAnimatedItem = EFalse;
       
   394 
       
   395     const_cast<CMmListBoxItemDrawer*>(this)->DrawFloatingItems(actualItemRect);
       
   396 
       
   397     if (!AknLayoutUtils::PenEnabled() && IsEditMode())
       
   398         {
       
   399         const_cast<CMmListBoxItemDrawer*>(this)->DrawActualIndicatorItem(
       
   400         		aItemIndex, actualItemRect );
       
   401         }
       
   402 
       
   403 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   404 	if ( transApi )
       
   405 		{
       
   406 	    transApi->EndRedraw( MAknListBoxTfxInternal::EListItem, aItemIndex );
       
   407 		}
       
   408 #endif
       
   409 
       
   410 
       
   411 
       
   412     }
       
   413 // -----------------------------------------------------------------------------
       
   414 //
       
   415 // -----------------------------------------------------------------------------
       
   416 //
       
   417 void CMmListBoxItemDrawer::DrawItemText(TInt aItemIndex,
       
   418 		const TRect &aItemTextRect, TBool aItemIsCurrent,
       
   419 		TBool aViewIsEmphasized, TBool aItemIsSelected ) const
       
   420     {
       
   421     TRAP_IGNORE( DoDrawItemTextL( aItemIndex, aItemTextRect, aItemIsCurrent,
       
   422     		aViewIsEmphasized, aItemIsSelected ) );
       
   423     }
       
   424 
       
   425 // -----------------------------------------------------------------------------
       
   426 //
       
   427 // -----------------------------------------------------------------------------
       
   428 //
       
   429 void CMmListBoxItemDrawer::DoDrawItemTextL( TInt aItemIndex, const TRect
       
   430 		&aItemTextRect, TBool aItemIsCurrent, TBool aViewIsEmphasized,
       
   431 		TBool /* aItemIsSelected */) const
       
   432     {
       
   433     CMmCacheForItem* cache = iItemsDataCache->GetItemCacheL( aItemIndex );
       
   434     cache->InvalidateIfCacheMayNotBeUsed(
       
   435             aItemIsCurrent, iLastSubcellsSetupCode );
       
   436 
       
   437     if ( IsRedrawItemBackgroundEnabled() )
       
   438         {
       
   439         DrawBackgroundAndSeparatorLines( aItemTextRect );
       
   440         }
       
   441     
       
   442     if ( !iUseCache || !cache->IsValid() )
       
   443         {
       
   444         SetupSubCellsL( aItemIsCurrent, aItemIndex );
       
   445         }
       
   446     __ASSERT_DEBUG( cache->IsValid(), User::Invariant() );
       
   447     CArrayPtr<CGulIcon>* oldIconList = FormattedCellData()->IconArray();
       
   448     FormattedCellData()->SetIconArray( cache->GetIconListL() );
       
   449     delete oldIconList;
       
   450     oldIconList = NULL;
       
   451 
       
   452 
       
   453     TBool highlightShown = ETrue;
       
   454 	CFormattedCellListBoxData::TColors colors;
       
   455 
       
   456 	colors = SetupColors( IsFloating( aItemIndex ) );
       
   457 
       
   458 	CFormattedCellListBoxData* data = static_cast<CFormattedCellListBoxData*>(iData);
       
   459 	data->EnableMarqueeL( EFalse );
       
   460 	if (FormattedCellData()->RespectFocus() && !aViewIsEmphasized)
       
   461 		{
       
   462 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   463 		MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( iGc );
       
   464 		if ( transApi )
       
   465 			 {
       
   466 			 transApi->Remove( MAknListBoxTfxInternal::EListHighlight );
       
   467 			 }
       
   468 #endif
       
   469 		highlightShown = EFalse;
       
   470 		}
       
   471 	
       
   472     data->Draw( Properties(aItemIndex), *iGc, &( cache->GetItemText() ), aItemTextRect,
       
   473     		GetHighlightVisibility( aItemIndex, aItemIsCurrent, highlightShown ), colors );
       
   474 
       
   475 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   476 	MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( iGc );
       
   477 	if ( transApi )
       
   478 		{
       
   479 		transApi->StartDrawing( MAknListBoxTfxInternal::EListItem );
       
   480 		}
       
   481 #endif
       
   482 
       
   483 	if ( iMarqueeAdapter && aItemIsCurrent )
       
   484 		{
       
   485 		DEBUG(("CMmListBoxItemDrawer::DoDrawItemTextL - DrawMarquee"));
       
   486 		iMarqueeAdapter->DrawMarqueeL( *iGc );
       
   487 		}
       
   488 
       
   489 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   490 	if ( transApi )
       
   491 		{
       
   492 		transApi->StopDrawing();
       
   493 		}
       
   494 #endif
       
   495 
       
   496 	delete ColumnData()->IconArray();
       
   497 	ColumnData()->SetIconArray( NULL );
       
   498     }
       
   499 
       
   500 // -----------------------------------------------------------------------------
       
   501 //
       
   502 // -----------------------------------------------------------------------------
       
   503 //
       
   504 void CMmListBoxItemDrawer::SetRedrawItemBackground( TBool aRedraw )
       
   505     {
       
   506     iRedrawBackground = aRedraw;
       
   507     }
       
   508 
       
   509 // -----------------------------------------------------------------------------
       
   510 //
       
   511 // -----------------------------------------------------------------------------
       
   512 //
       
   513 TBool CMmListBoxItemDrawer::IsRedrawItemBackgroundEnabled() const
       
   514     {
       
   515     return iRedrawBackground;
       
   516     }
       
   517 
       
   518 void CMmListBoxItemDrawer::DrawBackgroundAndSeparatorLines( const TRect& aItemTextRect ) const
       
   519     {
       
   520     MAknsSkinInstance *skin = AknsUtils::SkinInstance();
       
   521     CCoeControl* control = FormattedCellData()->Control();
       
   522 
       
   523     if ( IsRedrawItemBackgroundEnabled() )
       
   524         {
       
   525 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   526   	    MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( iGc );
       
   527         if ( transApi )
       
   528             {
       
   529             transApi->StartDrawing( MAknListBoxTfxInternal::EListView );
       
   530             }
       
   531 #endif
       
   532         TBool bgDrawn( EFalse );
       
   533         if ( control )
       
   534             {
       
   535 	        if ( CAknEnv::Static()->TransparencyEnabled() )
       
   536                 {
       
   537                 bgDrawn = AknsDrawUtils::Background(
       
   538                     skin, iBgContext, control, *iGc, aItemTextRect,
       
   539                     KAknsDrawParamNoClearUnderImage );
       
   540                 }
       
   541             else
       
   542                 {
       
   543                 bgDrawn = AknsDrawUtils::Background(
       
   544                     skin, iBgContext, control, *iGc, aItemTextRect,
       
   545                     KAknsDrawParamNoClearUnderImage |
       
   546                     KAknsDrawParamBottomLevelRGBOnly );
       
   547                 }
       
   548             }
       
   549         if ( !bgDrawn )
       
   550             {
       
   551             iGc->Clear( aItemTextRect );
       
   552             }
       
   553 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   554         if ( transApi )
       
   555             {
       
   556             transApi->StopDrawing();
       
   557             }
       
   558 #endif
       
   559         }
       
   560     }
       
   561 
       
   562 // -----------------------------------------------------------------------------
       
   563 //
       
   564 // -----------------------------------------------------------------------------
       
   565 //
       
   566 void CMmListBoxItemDrawer::SetupSubNoCellL( TInt aIndex,
       
   567         TInt aItemIndex ) const
       
   568     {
       
   569     TTemplateChild child;
       
   570     child.iFontId = EAknLogicalFontSecondaryFont;
       
   571     child.iIsImage = EFalse;
       
   572     const_cast<CMmListBoxItemDrawer*>(this)->
       
   573         ReplaceSubCellText( KNullDesC() );
       
   574     SetupSubCellL( child, aIndex, aItemIndex );
       
   575     iLastSubcellsSetupCode.AddSubcellInfo( TMmSubcellsSetupCode::ENoSubcell );
       
   576     }
       
   577 
       
   578 // -----------------------------------------------------------------------------
       
   579 //
       
   580 // -----------------------------------------------------------------------------
       
   581 //
       
   582 void CMmListBoxItemDrawer::SetupSubIcondDragHighlightCellL(
       
   583         TTemplateChild aSubCellTemplate, TInt aIndex, TInt aItemIndex ) const
       
   584     {
       
   585     aSubCellTemplate.iRectAccordingToParent.iBr
       
   586 		= TPoint(ItemCellSize().iWidth * iIconAnimationZoomRatio,
       
   587 				ItemCellSize().iHeight * iIconAnimationZoomRatio);
       
   588 
       
   589     aSubCellTemplate.iRectAccordingToParent.iTl = TPoint(0, 0);
       
   590     SetupSubCellL( aSubCellTemplate, aIndex , aItemIndex);
       
   591     }
       
   592 
       
   593 // -----------------------------------------------------------------------------
       
   594 //
       
   595 // -----------------------------------------------------------------------------
       
   596 //
       
   597 void CMmListBoxItemDrawer::SetupSubCellL( TTemplateChild aSubCellTemplate,
       
   598         TInt aIndex, TInt aItemIndex  ) const
       
   599 	{
       
   600     CFormattedCellListBoxData* data = static_cast<CFormattedCellListBoxData*>(iData);
       
   601     TInt width = aSubCellTemplate.iRectAccordingToParent.iBr.iX - aSubCellTemplate.iRectAccordingToParent.iTl.iX;
       
   602     TInt height = aSubCellTemplate.iRectAccordingToParent.iBr.iY - aSubCellTemplate.iRectAccordingToParent.iTl.iY;
       
   603     data->SetTransparentSubCellL(aIndex, ETrue);
       
   604     data->SetSubCellSizeL( aIndex, TSize(width,height));
       
   605     data->SetSubCellIconSize( aIndex, TSize(width,height) );
       
   606 	data->SetSubCellPositionL( aIndex, aSubCellTemplate.iRectAccordingToParent.iTl);
       
   607 	data->SetGraphicsSubCellL( aIndex, aSubCellTemplate.iIsImage );
       
   608 	data->SetSubCellAlignmentL( aIndex, aSubCellTemplate.iTextAlign );
       
   609 	const CFont* font = AknLayoutUtils::FontFromId(aSubCellTemplate.iFontId);
       
   610 	data->SetSubCellFontL (aIndex, font);
       
   611 	data->SetSubCellBaselinePosL( aIndex,
       
   612 			CAknLayoutFont::AsCAknLayoutFontOrNull( font )->TextPaneTopToBaseline()
       
   613 			+ aSubCellTemplate.iRectAccordingToParent.iTl.iY );
       
   614 
       
   615 //	If some text is clipped then marquee will do the drawing right after the subcell is drawn by ListBoxData.
       
   616 //	Setting the subcell size to zero prevents ListBoxData from drawing the text.
       
   617 	if (!aSubCellTemplate.iIsImage
       
   618 			&& !iIsMarqueeBeingDrawn
       
   619 			&& ( aItemIndex == iWidget->View()->CurrentItemIndex() )
       
   620 			&& !IsEditMode()
       
   621 			&& iWidgetType == EListbox
       
   622 			&& iSubcellText
       
   623             && iMarqueeAdapter->IsMarqueeEnabled() )
       
   624 
       
   625 		{
       
   626 		if (iMarqueeAdapter && IsTextClippedL( aSubCellTemplate, *iSubcellText )
       
   627 			&& STATIC_CAST(CMmWidgetContainer*,Widget()->Parent())->IsTimerActive() )
       
   628 		    {
       
   629 		    data->SetSubCellSizeL( aIndex, TSize(0,0));
       
   630     		const_cast<CMmListBoxItemDrawer*>(this)->AddSubcellMarqueeElementL(
       
   631     				aSubCellTemplate, aIndex, aItemIndex);
       
   632 		    }
       
   633 		else if (iMarqueeAdapter)
       
   634             {
       
   635             iMarqueeAdapter->StopMarqueeDrawing(aIndex);
       
   636             }
       
   637 		}
       
   638 
       
   639 	if ( iMarqueeAdapter && iIsMarqueeBeingDrawn
       
   640     		&& iMarqueeAdapter->SubcellMarqueeElementExists( aIndex ) )
       
   641     	{
       
   642     	if (aItemIndex != iWidget->View()->CurrentItemIndex() )
       
   643             {
       
   644             iMarqueeAdapter->StopMarqueeDrawing(aIndex);
       
   645             }
       
   646     	else
       
   647     	    {
       
   648     	    data->SetSubCellSizeL(aIndex, TSize(0, 0));
       
   649     	    }
       
   650         }
       
   651 	}
       
   652 
       
   653 // -----------------------------------------------------------------------------
       
   654 //
       
   655 // -----------------------------------------------------------------------------
       
   656 //
       
   657 CFormattedCellListBoxData::TColors CMmListBoxItemDrawer::SetupColors(  TBool aDragged ) const
       
   658 	{
       
   659 	CFormattedCellListBoxData::TColors colors;
       
   660 	MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   661 
       
   662 	if ( !aDragged )
       
   663 	    {
       
   664         AknsUtils::GetCachedColor( skin, colors.iText, KAknsIIDQsnTextColors,
       
   665                 EAknsCIQsnTextColorsCG6 );
       
   666         AknsUtils::GetCachedColor( skin, colors.iBack , KAknsIIDQsnTextColors,
       
   667                 EAknsCIQsnOtherColorsCG9 );
       
   668         AknsUtils::GetCachedColor( skin, colors.iHighlightedText,
       
   669                 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG10 );
       
   670         AknsUtils::GetCachedColor( skin, colors.iHighlightedBack,
       
   671                 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 );
       
   672 	    }
       
   673 	else
       
   674 	    {
       
   675         AknsUtils::GetCachedColor( skin, colors.iText, KAknsIIDQsnTextColors,
       
   676                 EAknsCIQsnTextColorsCG10 );
       
   677         AknsUtils::GetCachedColor( skin, colors.iBack , KAknsIIDQsnTextColors,
       
   678                 EAknsCIQsnTextColorsCG6 );
       
   679         AknsUtils::GetCachedColor( skin, colors.iHighlightedText,
       
   680                 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG10 );
       
   681         AknsUtils::GetCachedColor( skin, colors.iHighlightedBack,
       
   682                 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 );
       
   683 	    }
       
   684 
       
   685 	return colors;
       
   686 	}
       
   687 
       
   688 // -----------------------------------------------------------------------------
       
   689 //
       
   690 // -----------------------------------------------------------------------------
       
   691 //
       
   692 TInt CMmListBoxItemDrawer::GetItemHeight( TInt aItemIndex, TBool aItemIsCurrent ) const
       
   693     {
       
   694     TSize ret(TInt(0),TInt(0));
       
   695     ret = GetItemSize(aItemIndex, aItemIsCurrent);
       
   696     return ret.iHeight;
       
   697     }
       
   698 
       
   699 // -----------------------------------------------------------------------------
       
   700 //
       
   701 // -----------------------------------------------------------------------------
       
   702 //
       
   703 TInt CMmListBoxItemDrawer::GetFloatingItemCount()
       
   704     {
       
   705 	for( TInt i=0; i< iFloatingItems.Count(); i++)
       
   706 		{
       
   707 		TMmFloatingItem& current = GetFloatingItemAtIndex(i);
       
   708 		if (current.GetDrawnItemIndex() == KErrNotFound)
       
   709 			{
       
   710 			RemoveFloatingItem(i);
       
   711 			}
       
   712 		}
       
   713 
       
   714     return iFloatingItems.Count();
       
   715     }
       
   716 
       
   717 // -----------------------------------------------------------------------------
       
   718 //
       
   719 // -----------------------------------------------------------------------------
       
   720 //
       
   721 TMmFloatingItem& CMmListBoxItemDrawer::GetFloatingItemAtIndex( TInt aIndex )
       
   722     {
       
   723     return iFloatingItems[ aIndex ];
       
   724     }
       
   725 
       
   726 // -----------------------------------------------------------------------------
       
   727 //
       
   728 // -----------------------------------------------------------------------------
       
   729 //
       
   730 void CMmListBoxItemDrawer::RemoveFloatingItem( TInt aPosition )
       
   731     {
       
   732     if (aPosition != KErrNotFound)
       
   733     	{
       
   734     	iFloatingItems.Remove( aPosition );
       
   735     	}
       
   736     }
       
   737 
       
   738 // -----------------------------------------------------------------------------
       
   739 //
       
   740 // -----------------------------------------------------------------------------
       
   741 //
       
   742 void CMmListBoxItemDrawer::RemoveFloatingItems()
       
   743     {
       
   744     iFloatingItems.Reset();
       
   745     }
       
   746 
       
   747 // -----------------------------------------------------------------------------
       
   748 //
       
   749 // -----------------------------------------------------------------------------
       
   750 //
       
   751 void CMmListBoxItemDrawer::AddFloatingItemL( TMmFloatingItem& aFloatingItem,
       
   752         TInt aPosition )
       
   753     {
       
   754     if (aPosition != KErrNotFound)
       
   755         {
       
   756         iFloatingItems.InsertL( aFloatingItem, aPosition );
       
   757         }
       
   758     else
       
   759         {
       
   760         iFloatingItems.AppendL( aFloatingItem );
       
   761         }
       
   762     }
       
   763 
       
   764 // -----------------------------------------------------------------------------
       
   765 //
       
   766 // -----------------------------------------------------------------------------
       
   767 //
       
   768 TSize CMmListBoxItemDrawer::GetItemSize( TInt aItemIndex, TBool aItemIsCurrent ) const
       
   769     {
       
   770     if ( aItemIndex < 0 )
       
   771         {
       
   772         return TSize( 1, 1 );
       
   773         }
       
   774     
       
   775 	TSize size;
       
   776 
       
   777 	CMmCacheForItem* cache = NULL;
       
   778 	TRAPD( cacheError, cache = iItemsDataCache->GetItemCacheL( aItemIndex ) );
       
   779 	if ( cacheError != KErrNone )
       
   780 	    {
       
   781 	    cache = NULL;
       
   782 	    }
       
   783 	
       
   784 	if ( cache )
       
   785 	    {
       
   786 	    cache->InvalidateIfCacheMayNotBeUsed(
       
   787 	            aItemIsCurrent, iLastSubcellsSetupCode );
       
   788 	    }
       
   789 	
       
   790     if ( !iUseCache || !cache || !cache->IsValid() )
       
   791         {
       
   792         const TDesC8& mm_template = iMmModel->GetAttributeAsText (aItemIndex,
       
   793                 KMmTemplate8);
       
   794         TRect viewRect = iWidget->View()->ViewRect();
       
   795         
       
   796         TBool landscapeOrientation = viewRect.Width() > viewRect.Height();
       
   797         // Layout_Meta_Data::IsLandscapeOrientation cannot be used here because it
       
   798         // might happen that GetSize (this method) gets called immediately after
       
   799         // layout change but before AppUi calls SetRect on the container of iWidget
       
   800         // (Layout_Meta_Data::IsLandscapeOrientation always reflects the current state,
       
   801         // whereas ViewRect might sometimes be out of date).
       
   802         // In such situation iTemplateLibrary->GetSize (called just below) would
       
   803         // cause the template library to fill the internal cache for landscape mode
       
   804         // with parameters calculated according to the outdated ViewRect.
       
   805 
       
   806         
       
   807         if ( iTemplateLibrary->GetSize( size, iWidgetType, mm_template,
       
   808                 landscapeOrientation, aItemIsCurrent, viewRect )
       
   809                 != KErrNone )
       
   810             {
       
   811             size = TSize( 1, 1 );
       
   812             }
       
   813         if ( cache )
       
   814             {
       
   815             cache->SetSize( size );
       
   816             }
       
   817         }
       
   818     else
       
   819         {
       
   820         size = cache->GetSize();
       
   821         }
       
   822     return size;
       
   823     }
       
   824 
       
   825 // -----------------------------------------------------------------------------
       
   826 //
       
   827 // -----------------------------------------------------------------------------
       
   828 //
       
   829 TRect CMmListBoxItemDrawer::GetIndicatorRect() const
       
   830     {
       
   831     TBool landscapeOrientation = Layout_Meta_Data::IsLandscapeOrientation();
       
   832     const TDesC8& mm_template = iMmModel->GetAttributeAsText(
       
   833             iWidget->View()->CurrentItemIndex(), KMmTemplate8 );
       
   834     TRect indicatorRect( iTemplateLibrary->GetMoveIndicatorRect(
       
   835             iWidgetType, mm_template, landscapeOrientation, ETrue ) );
       
   836     return indicatorRect;
       
   837     }
       
   838 
       
   839 // -----------------------------------------------------------------------------
       
   840 //
       
   841 // -----------------------------------------------------------------------------
       
   842 //
       
   843 void CMmListBoxItemDrawer::SetDraggableL( TBool aDraggable )
       
   844     {
       
   845 
       
   846 	iDraggable = aDraggable;
       
   847 
       
   848     if (!iDraggable)
       
   849         {
       
   850         for(int i=0; i< iFloatingItems.Count(); i++)
       
   851             {
       
   852             if (iFloatingItems[i].GetFloatingItemType() == EZoomTransition
       
   853                     && iFloatingItems[i].GetZoomingStatus() > 0)
       
   854                 {
       
   855                 AnimateItemZoomOutL( iFloatingItems[i].GetDrawnItemIndex() );
       
   856                 }
       
   857             else if (iFloatingItems[i].GetFloatingItemType() == EDrag
       
   858                     || iFloatingItems[i].IsManualDelete())
       
   859                 {
       
   860                 iFloatingItems[i].InvalidateFloatingItem();
       
   861                 }
       
   862             }
       
   863         }
       
   864     }
       
   865 
       
   866 // -----------------------------------------------------------------------------
       
   867 //
       
   868 // -----------------------------------------------------------------------------
       
   869 //
       
   870 void CMmListBoxItemDrawer::SetEditModeL( TBool aEditMode )
       
   871     {
       
   872     if ( aEditMode )
       
   873         {
       
   874         EnableCachedDataUse( EFalse );
       
   875         }
       
   876 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   877     MAknListBoxTfxInternal *trans = CAknListLoader::TfxApiInternal( iGc );
       
   878     if( trans )
       
   879         {
       
   880         trans->Remove( MAknListBoxTfxInternal::EListEverything );
       
   881         trans->Draw( iViewRect );
       
   882         }
       
   883 #endif
       
   884     iIsEditMode = aEditMode;
       
   885     }
       
   886 
       
   887 // -----------------------------------------------------------------------------
       
   888 //
       
   889 // -----------------------------------------------------------------------------
       
   890 //
       
   891 TBool CMmListBoxItemDrawer::IsEditMode() const
       
   892 	{
       
   893 	return iIsEditMode;
       
   894 	}
       
   895 
       
   896 // -----------------------------------------------------------------------------
       
   897 //
       
   898 // -----------------------------------------------------------------------------
       
   899 //
       
   900 CMmDrawerAnimator* CMmListBoxItemDrawer::GetAnimator()
       
   901     {
       
   902     return iAnimator;
       
   903     }
       
   904 
       
   905 // -----------------------------------------------------------------------------
       
   906 //
       
   907 // -----------------------------------------------------------------------------
       
   908 //
       
   909 void CMmListBoxItemDrawer::SetDraggedPointL( TPoint aPoint )
       
   910 	{
       
   911 	TInt dragFloatingItem = GetFloatingItemIndex(EDrag);
       
   912 	if (dragFloatingItem != KErrNotFound )
       
   913 		{
       
   914 		TMmFloatingItem & item = GetFloatingItemAtIndex( dragFloatingItem );
       
   915 		TMmFloatingItem floatingItem( item.GetDrawnItemIndex(),
       
   916 				aPoint,	EDrag, MmEffects::KNoAnimationFramesCount, NULL );
       
   917 		floatingItem.SetManualDelete( ETrue );
       
   918 
       
   919 		TMmFloatingItem postDragRefresh( item.GetDrawnItemIndex(),
       
   920 						item.GetItemPosition(),	EPostDragRefreshItem,
       
   921 						MmEffects::KNoAnimationFramesCount, iWidget->View() );
       
   922 
       
   923 		iFloatingItems.Remove(dragFloatingItem);
       
   924 
       
   925 		if (postDragRefresh.GetItemPosition() != floatingItem.GetItemPosition())
       
   926 			{
       
   927 			iFloatingItems.Append( postDragRefresh );
       
   928 			}
       
   929 		iFloatingItems.Insert( floatingItem, 0 );
       
   930 		}
       
   931 	}
       
   932 
       
   933 // -----------------------------------------------------------------------------
       
   934 //
       
   935 // -----------------------------------------------------------------------------
       
   936 //
       
   937 void CMmListBoxItemDrawer::SetDraggedIndexL(TInt aDraggedItemIndex,
       
   938 		TPoint aPoint)
       
   939     {
       
   940     TInt dragFloatingItem = KErrNotFound;
       
   941     do
       
   942     	{
       
   943 	    dragFloatingItem = GetFloatingItemIndex(EDrag);
       
   944 	    if (dragFloatingItem != KErrNotFound)
       
   945 	    	{
       
   946 	    	TMmFloatingItem & item = GetFloatingItemAtIndex( dragFloatingItem );
       
   947 
       
   948 	    	TMmFloatingItem postDragRefresh( item.GetDrawnItemIndex(),
       
   949 				item.GetItemPosition(),	EPostDragRefreshItem,
       
   950 				MmEffects::KNoAnimationFramesCount, iWidget->View() );
       
   951 
       
   952 	    	if (postDragRefresh.GetItemPosition() != aPoint)
       
   953 	    		{
       
   954 	    		iFloatingItems.Append( postDragRefresh );
       
   955 	    		}
       
   956 	    	}
       
   957 
       
   958 		RemoveFloatingItem( dragFloatingItem );
       
   959 
       
   960     	}
       
   961 	while ( dragFloatingItem != KErrNotFound );
       
   962 
       
   963     if ( aDraggedItemIndex != KErrNotFound )
       
   964     	{
       
   965 		TMmFloatingItem floatingItem( aDraggedItemIndex, aPoint, EDrag,
       
   966 				MmEffects::KNoAnimationFramesCount, iWidget->View() );
       
   967 		floatingItem.SetManualDelete( ETrue );
       
   968 		AddFloatingItemL(floatingItem, 0);
       
   969 		
       
   970 	    ClearFlags( CListItemDrawer::EPressedDownState );
       
   971     	}
       
   972 
       
   973     iAnimator->Trigger();
       
   974     }
       
   975 
       
   976 // -----------------------------------------------------------------------------
       
   977 //
       
   978 // -----------------------------------------------------------------------------
       
   979 //
       
   980 TBool CMmListBoxItemDrawer::IsDraggable() const
       
   981     {
       
   982     return iDraggable && iWidget->View();
       
   983     }
       
   984 
       
   985 // -----------------------------------------------------------------------------
       
   986 //
       
   987 // -----------------------------------------------------------------------------
       
   988 //
       
   989 void CMmListBoxItemDrawer::SetBgContext(
       
   990 		CAknsBasicBackgroundControlContext * aBgContext )
       
   991 	{
       
   992 	iBgContext = aBgContext;
       
   993 	}
       
   994 
       
   995 // -----------------------------------------------------------------------------
       
   996 //
       
   997 // -----------------------------------------------------------------------------
       
   998 //
       
   999 void CMmListBoxItemDrawer::SetScrollbarVisibilityL( TBool aIsScrollbarVisible )
       
  1000 	{
       
  1001 	iTemplateLibrary->SetScrollbarVisibilityL( aIsScrollbarVisible );
       
  1002 	}
       
  1003 
       
  1004 // -----------------------------------------------------------------------------
       
  1005 //
       
  1006 // -----------------------------------------------------------------------------
       
  1007 //
       
  1008 TRect CMmListBoxItemDrawer::AdjustItemRect( TInt aItemIndex ) const
       
  1009 	{
       
  1010 	TSize size = iWidget->View()->ItemSize (iWidget->View()->CurrentItemIndex () );
       
  1011 	TRect rect(iWidget->View()->ItemPos (iWidget->View()->CurrentItemIndex () ),
       
  1012 			iWidget->View()->ItemPos (iWidget->View()->CurrentItemIndex () ) + size);
       
  1013 	if ( !AknLayoutUtils::PenEnabled () && iIsIndicatorItem)
       
  1014 		{
       
  1015 		TBool landscapeOrientation =
       
  1016 				Layout_Meta_Data::IsLandscapeOrientation ();
       
  1017 		const TDesC8& mm_template = iMmModel->GetAttributeAsText (
       
  1018 				0, KMmTemplate8);
       
  1019 		TRect relativeToParentRect = TRect (TPoint (0, 0), TPoint (0, 0));
       
  1020 		relativeToParentRect = iTemplateLibrary->GetMoveIndicatorRect(
       
  1021 						iWidgetType, mm_template, landscapeOrientation,
       
  1022 						aItemIndex == iWidget->View()->CurrentItemIndex () );
       
  1023 		rect.Move (relativeToParentRect.iTl);
       
  1024 		rect.iBr.iX = rect.iBr.iX + relativeToParentRect.Width ();
       
  1025 		rect.iBr.iY = rect.iBr.iY + relativeToParentRect.Height ();
       
  1026 		}
       
  1027 	return rect;
       
  1028 	}
       
  1029 
       
  1030 // -----------------------------------------------------------------------------
       
  1031 //
       
  1032 // -----------------------------------------------------------------------------
       
  1033 //
       
  1034 void CMmListBoxItemDrawer::DrawActualIndicatorItem( TInt aItemIndex, TRect /*actualItemRect*/ )
       
  1035 	{
       
  1036 	if ( iDrawMoveIndicators )
       
  1037 		{
       
  1038 		iIsIndicatorItem = ETrue;
       
  1039 		SetRedrawItemBackground( EFalse );
       
  1040 		
       
  1041 		DrawActualItem( aItemIndex, AdjustItemRect( aItemIndex ) , EFalse, EFalse, EFalse, EFalse);
       
  1042 
       
  1043 		SetRedrawItemBackground( ETrue );
       
  1044 		iIsIndicatorItem = EFalse;
       
  1045 		}
       
  1046 	}
       
  1047 
       
  1048 // -----------------------------------------------------------------------------
       
  1049 //
       
  1050 // -----------------------------------------------------------------------------
       
  1051 //
       
  1052 void CMmListBoxItemDrawer::ReplaceSubCellText( const TDesC& aText )
       
  1053 	{
       
  1054 	delete iSubcellText;
       
  1055 	iSubcellText = NULL;
       
  1056 	if( aText.Compare( KNullDesC() ) )
       
  1057 		{
       
  1058 		iSubcellText = aText.Alloc();
       
  1059 		}
       
  1060 	}
       
  1061 
       
  1062 // -----------------------------------------------------------------------------
       
  1063 //
       
  1064 // -----------------------------------------------------------------------------
       
  1065 //
       
  1066 void CMmListBoxItemDrawer::AddSubcellMarqueeElementL( TTemplateChild aSubCellTemplate, TInt aIndex, TInt aItemIndex )
       
  1067 	{
       
  1068 	TRgb textColor;
       
  1069 	MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  1070 	AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG10 );
       
  1071 	iMarqueeAdapter->AddMarqueeElementL( aSubCellTemplate.iRectAccordingToParent, *iSubcellText,
       
  1072 			aSubCellTemplate.iFontId, textColor, aSubCellTemplate.iTextAlign, aIndex,
       
  1073 			aSubCellTemplate.iRectAccordingToParent.iTl.iY,
       
  1074 			aItemIndex);
       
  1075 	}
       
  1076 
       
  1077 // -----------------------------------------------------------------------------
       
  1078 //
       
  1079 // -----------------------------------------------------------------------------
       
  1080 //
       
  1081 void CMmListBoxItemDrawer::SetMarqueeAdapter( CMmMarqueeAdapter* aAdapter )
       
  1082 	{
       
  1083 	iMarqueeAdapter = aAdapter;
       
  1084 	}
       
  1085 
       
  1086 // -----------------------------------------------------------------------------
       
  1087 //
       
  1088 // -----------------------------------------------------------------------------
       
  1089 //
       
  1090 void CMmListBoxItemDrawer::SetMarqueeDrawing( TBool aIsMarqueeBeingDrawn )
       
  1091 	{
       
  1092 	iIsMarqueeBeingDrawn = aIsMarqueeBeingDrawn;
       
  1093 	}
       
  1094 
       
  1095 
       
  1096 // -----------------------------------------------------------------------------
       
  1097 //
       
  1098 // -----------------------------------------------------------------------------
       
  1099 //
       
  1100 TBool CMmListBoxItemDrawer::IsTextClippedL( TTemplateChild aTemplateChild,
       
  1101 		const TDesC& aText ) const
       
  1102 	{
       
  1103     TBuf< MmMarqueeConstants::KClippingBufLength > clipbuf
       
  1104 		= aText.Left( MmMarqueeConstants::KTextTrimmingThreshold);
       
  1105 	TInt maxClipWidth = aTemplateChild.iRectAccordingToParent.Width();
       
  1106 	const CFont* font = AknLayoutUtils::FontFromId(aTemplateChild.iFontId);
       
  1107     return AknBidiTextUtils::ConvertToVisualAndClipL( clipbuf, *font,
       
  1108     		aTemplateChild.iRectAccordingToParent.Width(), maxClipWidth );
       
  1109 	}
       
  1110 
       
  1111 // -----------------------------------------------------------------------------
       
  1112 //
       
  1113 // -----------------------------------------------------------------------------
       
  1114 //
       
  1115 void CMmListBoxItemDrawer::SetNumberOfColsInView(TInt aNumberOfColumns)
       
  1116 	{
       
  1117 	iNumberOfColsInWidget = aNumberOfColumns;
       
  1118 	}
       
  1119 
       
  1120 // -----------------------------------------------------------------------------
       
  1121 //
       
  1122 // -----------------------------------------------------------------------------
       
  1123 //
       
  1124 void CMmListBoxItemDrawer::SetupIconSubcellL(
       
  1125 		RArray<TTemplateChild>& aTemplateChildArray, TInt aChildIndex, TInt aItemIndex,
       
  1126 		RBuf& aItemText, TInt& aSubcellIncrement ) const
       
  1127 		{
       
  1128 		CGulIcon* icon = NULL;
       
  1129 		TTemplateChild child = aTemplateChildArray[aChildIndex];
       
  1130 		if ( !IsEditMode() &&
       
  1131 		        child.iImageVisualId == EImageVisualIdEditMode )
       
  1132 		    {
       
  1133 		    child.iIsImage = EFalse;
       
  1134 		    }
       
  1135 
       
  1136 		if ( IsDraggable() && aItemIndex == iZoomIconIndex )
       
  1137 			{
       
  1138 			const TReal KNormalZoomRatio = 1.0;
       
  1139 			TReal zoomDelta = ( iIconAnimationZoomRatio - KNormalZoomRatio ) / 2.0;
       
  1140 			TSize size = child.iRectAccordingToParent.Size();
       
  1141 			TSize sizeDelta( size.iWidth * zoomDelta, size.iHeight * zoomDelta );
       
  1142 			child.iRectAccordingToParent.Grow( sizeDelta );
       
  1143 			}
       
  1144 
       
  1145 		TSize targetSize = child.iRectAccordingToParent.Size();
       
  1146 
       
  1147 		CHnIconHolder* iconHolder = iMmModel->GetAttributeAsRefCountedGraphics(
       
  1148                 aItemIndex, child.iData, &targetSize );
       
  1149         icon = iconHolder ? iconHolder->GetGulIcon() : NULL;
       
  1150         if ( icon )
       
  1151             {
       
  1152             CFbsBitmap* bitmap = icon->Bitmap();
       
  1153             ASSERT( bitmap );
       
  1154             //resize the item if it is a move indicator
       
  1155             if( iIsIndicatorItem )
       
  1156                 {
       
  1157                 AknIconUtils::SetSize( bitmap, child.iRectAccordingToParent.Size(),
       
  1158                 		EAspectRatioNotPreserved );
       
  1159                 }
       
  1160             else
       
  1161                 {
       
  1162                 TSize bmpSize = bitmap->SizeInPixels();
       
  1163                 TBool setSizeRequired = bitmap->DisplayMode() == ENone;
       
  1164                 if ( targetSize.iWidth && targetSize.iHeight &&
       
  1165                         ( setSizeRequired || !BitmapFitsIntoTarget( bmpSize, targetSize ) ) )
       
  1166                     {
       
  1167                     CFbsBitmap* mask = icon->Mask();
       
  1168                     if ( mask )
       
  1169                         {
       
  1170                         __ASSERT_DEBUG( bmpSize == mask->SizeInPixels(), User::Invariant() );
       
  1171                         AknIconUtils::SetSize( mask, targetSize, EAspectRatioPreservedAndUnusedSpaceRemoved );
       
  1172                         }
       
  1173                     AknIconUtils::SetSize( bitmap, targetSize, EAspectRatioPreservedAndUnusedSpaceRemoved );
       
  1174                     }
       
  1175                 }
       
  1176 
       
  1177             TInt iconIndex = iItemsDataCache->GetItemCacheL( aItemIndex )->AppendIconL( iconHolder );
       
  1178 
       
  1179             HBufC8* number = HnConvUtils::NumToStr8LC( iconIndex );
       
  1180             const TInt newLength = aItemText.Length() + number->Length();
       
  1181             if( aItemText.MaxLength() < newLength )
       
  1182                 {
       
  1183                 aItemText.ReAllocL( newLength );
       
  1184                 }
       
  1185             CleanupStack::PopAndDestroy( number );
       
  1186             aItemText.AppendNum( iconIndex );
       
  1187 
       
  1188     	    SetupSubCellL( child, aSubcellIncrement, aItemIndex );
       
  1189 
       
  1190         	if ( aChildIndex < aTemplateChildArray.Count() - 1 )
       
  1191         	    {
       
  1192 	            const TInt newLength = aItemText.Length() + KTab().Length();
       
  1193                 if( aItemText.MaxLength() < newLength )
       
  1194                     {
       
  1195                     aItemText.ReAllocL( newLength );
       
  1196                     }
       
  1197         	    aItemText.Append( KTab );
       
  1198         	    }
       
  1199 
       
  1200         	aSubcellIncrement++;
       
  1201         	iLastSubcellsSetupCode.AddSubcellInfo( TMmSubcellsSetupCode::EGraphicsSubcell );
       
  1202         	}
       
  1203         else
       
  1204             {
       
  1205             // Even when there is no graphics in the model, it is
       
  1206             // necessary to set up an empty subcell in place of
       
  1207             // what would normally be an icon (graphics) subcell.
       
  1208             // This ensures that TMmSubcellsSetupCode will work
       
  1209             // properly.
       
  1210             SetupSubNoCellL( aSubcellIncrement, aItemIndex );
       
  1211             aSubcellIncrement++;
       
  1212             }
       
  1213 		}
       
  1214 
       
  1215 // -----------------------------------------------------------------------------
       
  1216 //
       
  1217 // -----------------------------------------------------------------------------
       
  1218 //
       
  1219 TBool CMmListBoxItemDrawer::BitmapFitsIntoTarget(
       
  1220         TSize aBmpSize, TSize aTargetSize ) const
       
  1221     {
       
  1222     TBool widthLessOrEqual = aBmpSize.iWidth <= aTargetSize.iWidth;
       
  1223     TBool heightLessOrEqual = aBmpSize.iHeight <= aTargetSize.iHeight;
       
  1224     TBool widthAlmostEqual = Abs( aBmpSize.iWidth - aTargetSize.iWidth ) < 2;
       
  1225     TBool heightAlmostEqual = Abs( aBmpSize.iHeight - aTargetSize.iHeight ) < 2;
       
  1226     return ( widthLessOrEqual && heightAlmostEqual ) ||
       
  1227            ( widthAlmostEqual && heightLessOrEqual );
       
  1228     }
       
  1229 
       
  1230 // -----------------------------------------------------------------------------
       
  1231 //
       
  1232 // -----------------------------------------------------------------------------
       
  1233 //
       
  1234 void CMmListBoxItemDrawer::SetupTextSubcellL(
       
  1235 		RArray<TTemplateChild>& aTemplateChildArray, TInt aChildIndex,
       
  1236 		TInt aItemIndex, RBuf& aItemText, TInt& aSubcellIncrement ) const
       
  1237 		{
       
  1238 		TTemplateChild child = aTemplateChildArray[aChildIndex];
       
  1239 		RBuf itemChildText;
       
  1240 		CleanupClosePushL( itemChildText );
       
  1241 		const TDesC8& mmTitleDes8 = iMmModel->GetAttributeAsText( aItemIndex,
       
  1242 				child.iData  );
       
  1243 		itemChildText.Assign( HnConvUtils::Str8ToStr( mmTitleDes8 ) );
       
  1244 
       
  1245 		AppendText( aItemText, itemChildText );
       
  1246 
       
  1247 		const_cast<CMmListBoxItemDrawer*>(this)->ReplaceSubCellText(
       
  1248 				itemChildText );
       
  1249 		CleanupStack::PopAndDestroy( &itemChildText );
       
  1250 
       
  1251 	    SetupSubCellL( child, aSubcellIncrement, aItemIndex );
       
  1252 
       
  1253     	if ( aChildIndex < aTemplateChildArray.Count() - 1 )
       
  1254     	    {
       
  1255     	    AppendText( aItemText, KTab );
       
  1256     	    }
       
  1257 
       
  1258     	aSubcellIncrement++;
       
  1259     	iLastSubcellsSetupCode.AddSubcellInfo( TMmSubcellsSetupCode::ETextSubcell );
       
  1260 		}
       
  1261 // -----------------------------------------------------------------------------
       
  1262 //
       
  1263 // -----------------------------------------------------------------------------
       
  1264 //
       
  1265 void CMmListBoxItemDrawer::AppendText( RBuf& aBuffer, const TDesC& aTextToAppend ) const
       
  1266 	{
       
  1267 		TInt newLength = aBuffer.Length() + aTextToAppend.Length();
       
  1268 		TInt error = KErrNone;
       
  1269 
       
  1270    		if( aBuffer.MaxLength() < newLength )
       
  1271    		    {
       
  1272    		    error = aBuffer.ReAlloc( newLength );
       
  1273    		    }
       
  1274    		if ( error == KErrNone )
       
  1275    			{
       
  1276    			aBuffer.Append( aTextToAppend );
       
  1277    			}
       
  1278 	}
       
  1279 // -----------------------------------------------------------------------------
       
  1280 //
       
  1281 // -----------------------------------------------------------------------------
       
  1282 //
       
  1283 void CMmListBoxItemDrawer::SetupBackdropSubcellL(
       
  1284 		RArray<TTemplateChild>& aTemplateChildArray, TInt aItemIndex,
       
  1285 		RBuf& aItemText, TInt& aSubcellIncrement ) const
       
  1286 	{
       
  1287     CGulIcon* icon = NULL;
       
  1288     for ( TInt i = 0; i < aTemplateChildArray.Count() /*&&
       
  1289             aItemIndex != iWidget->View()->CurrentItemIndex()*/; ++i )
       
  1290         {
       
  1291         TTemplateChild child = aTemplateChildArray[i];
       
  1292         if( child.iImageVisualId == EImageVisualIdEditMode  &&
       
  1293                 child.iIsImage )
       
  1294             {
       
  1295             TSize itemSize = GetItemSize( aItemIndex,
       
  1296             		aItemIndex == iWidget->View()->CurrentItemIndex() );
       
  1297             CHnIconHolder* iconHolder = iMmModel->GetAttributeAsRefCountedGraphics( aItemIndex, child.iData, &itemSize );
       
  1298             icon = iconHolder ? iconHolder->GetGulIcon() : NULL;
       
  1299             if ( icon )
       
  1300                 {
       
  1301                 CFbsBitmap* bitmap = icon->Bitmap();
       
  1302 				child.iRectAccordingToParent = TRect( TPoint( 0, 0 ),
       
  1303 						TPoint( itemSize.iWidth, itemSize.iHeight ) );
       
  1304 				AknIconUtils::SetSize( bitmap, itemSize,
       
  1305 						EAspectRatioNotPreserved );
       
  1306 				TInt iconIndex = iItemsDataCache->GetItemCacheL( aItemIndex )->AppendIconL( iconHolder );
       
  1307 
       
  1308                 HBufC8* number = HnConvUtils::NumToStr8LC( iconIndex );
       
  1309                 TInt newLength = aItemText.Length() + number->Length();
       
  1310                 if( aItemText.MaxLength() < newLength )
       
  1311                     {
       
  1312                     aItemText.ReAllocL( newLength );
       
  1313                     }
       
  1314                 CleanupStack::PopAndDestroy( number );
       
  1315                 aItemText.AppendNum( iconIndex );
       
  1316 
       
  1317                 newLength = aItemText.Length() + KTab().Length();
       
  1318                 if( aItemText.MaxLength() < newLength )
       
  1319                     {
       
  1320                     aItemText.ReAllocL( newLength );
       
  1321                     }
       
  1322                 aItemText.Append( KTab );
       
  1323                 SetupSubCellL( child, aSubcellIncrement, aItemIndex );
       
  1324                 aSubcellIncrement++;
       
  1325                 iLastSubcellsSetupCode.AddSubcellInfo( TMmSubcellsSetupCode::EBackdropSubcell );
       
  1326                 }
       
  1327             }
       
  1328         }
       
  1329 	}
       
  1330 
       
  1331 // -----------------------------------------------------------------------------
       
  1332 //
       
  1333 // -----------------------------------------------------------------------------
       
  1334 //
       
  1335 void CMmListBoxItemDrawer::SetupSubCellsL( TBool aItemIsCurrent,
       
  1336         TInt aItemIndex ) const
       
  1337     {
       
  1338     CMmCacheForItem* cache = iItemsDataCache->GetItemCacheL( aItemIndex );
       
  1339     cache->SetValid( EFalse );
       
  1340     
       
  1341     const TDesC8& mmTemplate = iMmModel->GetAttributeAsText( aItemIndex, KMmTemplate8 );
       
  1342     if ( !mmTemplate.Compare( KNullDesC8 ) || !mmTemplate.Compare( KEmpty8 ) )
       
  1343         {
       
  1344         User::Leave( KErrNotFound );
       
  1345         }
       
  1346     cache->SetTemplateL( mmTemplate );
       
  1347     
       
  1348     cache->ClearIconArray();
       
  1349     cache->SetCurrent( aItemIsCurrent );
       
  1350     
       
  1351     TBool landscapeOrientation = Layout_Meta_Data::IsLandscapeOrientation();
       
  1352     
       
  1353     RBuf& itemText = cache->GetItemTextForModifications();
       
  1354     itemText.Close();
       
  1355     itemText.CreateL( MmTemplateContants::KItemSubCellsText );
       
  1356 
       
  1357     RArray<TTemplateChild> templateChildArray;
       
  1358     CleanupClosePushL( templateChildArray );
       
  1359     if ( !iIsIndicatorItem )
       
  1360 		{
       
  1361 		iTemplateLibrary->GetChildrenL( iWidgetType, templateChildArray, mmTemplate,
       
  1362 				landscapeOrientation, aItemIsCurrent,	IsEditMode() );
       
  1363 		}
       
  1364     else if ( !AknLayoutUtils::PenEnabled() )
       
  1365 		{
       
  1366 		iTemplateLibrary->GetMoveIndicatorChildrenL( iWidgetType, templateChildArray,
       
  1367 	    		mmTemplate, landscapeOrientation, aItemIsCurrent );
       
  1368 		}
       
  1369     
       
  1370     iLastSubcellsSetupCode.Clear();
       
  1371     
       
  1372     //Backdrop icon as first element to draw
       
  1373     TInt subcellIncrement( 0 );
       
  1374     if ( GetBackdropVisibility( aItemIndex, aItemIsCurrent ) )
       
  1375         {
       
  1376         SetupBackdropSubcellL( templateChildArray, aItemIndex, itemText, subcellIncrement );
       
  1377         iItemHasBackdrop = ETrue;
       
  1378         }
       
  1379     else 
       
  1380     	{
       
  1381     	iItemHasBackdrop = EFalse;
       
  1382     	}
       
  1383 
       
  1384 	for ( TInt i( 0 ) ; i < templateChildArray.Count() && !iLeftOverAreaUnderAnimatedItem; i++ )
       
  1385 		{
       
  1386 		TTemplateChild child = templateChildArray[i];
       
  1387         if ( child.iImageVisualId == EImageVisualIdEditMode && child.iIsImage )
       
  1388             {
       
  1389             continue;
       
  1390             }
       
  1391         else if( !child.iIsImage )
       
  1392     		{
       
  1393     		SetupTextSubcellL( templateChildArray, i, aItemIndex, itemText, subcellIncrement );
       
  1394     		}
       
  1395     	else
       
  1396     		{
       
  1397     		SetupIconSubcellL( templateChildArray, i, aItemIndex, itemText, subcellIncrement );
       
  1398     		}
       
  1399 		}
       
  1400 
       
  1401 	for ( TInt i = subcellIncrement; i < MmTemplateContants::KSubCellsCount; i++ )
       
  1402 	    {
       
  1403 	    SetupSubNoCellL( i, aItemIndex );
       
  1404 	    }
       
  1405 	
       
  1406 	iLastSubcellsSetupCode.AddTemplateInfo(
       
  1407 	        iItemsDataCache->GetTemplateIdentifierL( mmTemplate ) );
       
  1408 	iLastSubcellsSetupCode.AddIsCurrentInfo( aItemIsCurrent );
       
  1409 
       
  1410 	CleanupStack::PopAndDestroy( &templateChildArray );
       
  1411 	
       
  1412 	cache->SetSubcellsSetupCode( iLastSubcellsSetupCode );
       
  1413 	// the line below is here only to make the cached information complete
       
  1414 	GetItemSize( aItemIndex, aItemIsCurrent );
       
  1415 	cache->SetValid( ETrue );
       
  1416 	}
       
  1417 
       
  1418 // -----------------------------------------------------------------------------
       
  1419 //
       
  1420 // -----------------------------------------------------------------------------
       
  1421 //
       
  1422 CMmTemplateLibrary* CMmListBoxItemDrawer::TemplateLibrary()
       
  1423     {
       
  1424     return iTemplateLibrary;
       
  1425     }
       
  1426 
       
  1427 // -----------------------------------------------------------------------------
       
  1428 //
       
  1429 // -----------------------------------------------------------------------------
       
  1430 //
       
  1431 void CMmListBoxItemDrawer::SetHighlightShown( TBool aDrawn )
       
  1432 	{
       
  1433 	iHighlightShown = aDrawn;
       
  1434 	iDrawMoveIndicators = aDrawn;
       
  1435 	}
       
  1436 
       
  1437 // -----------------------------------------------------------------------------
       
  1438 //
       
  1439 // -----------------------------------------------------------------------------
       
  1440 //
       
  1441 TBool CMmListBoxItemDrawer::IsFloating( TInt aItemIndex ) const
       
  1442     {
       
  1443     TBool isFloating( EFalse );
       
  1444 
       
  1445     TInt index = GetFloatingItemIndex( EDrag );
       
  1446     if (index == KErrNotFound)
       
  1447     	{
       
  1448     	index = GetFloatingItemIndex( EDragTransition );
       
  1449     	}
       
  1450 
       
  1451     if ( KErrNotFound != index )
       
  1452         {
       
  1453         TMmFloatingItem& current = const_cast<CMmListBoxItemDrawer*>(this)->GetFloatingItemAtIndex( index );
       
  1454         TInt drawnIndex = current.GetDrawnItemIndex();
       
  1455         if ( drawnIndex == aItemIndex )
       
  1456             {
       
  1457             isFloating = ETrue;
       
  1458             }
       
  1459         }
       
  1460     return isFloating;
       
  1461     }
       
  1462 
       
  1463 // -----------------------------------------------------------------------------
       
  1464 //
       
  1465 // -----------------------------------------------------------------------------
       
  1466 //
       
  1467 void CMmListBoxItemDrawer::DrawActualItem(TInt aItemIndex, 
       
  1468 		const TRect& aActualItemRect, TBool aItemIsCurrent, 
       
  1469 		TBool aViewIsEmphasized, TBool /*aViewIsDimmed*/,
       
  1470 		TBool aItemIsSelected) const
       
  1471 		{
       
  1472 		if (Properties(aItemIndex).IsSelectionHidden()) 
       
  1473 			{ 
       
  1474 			aItemIsSelected = EFalse; 
       
  1475 			}
       
  1476 		DrawItemText(aItemIndex,aActualItemRect,aItemIsCurrent,
       
  1477 				aViewIsEmphasized,aItemIsSelected);
       
  1478 		}
       
  1479 
       
  1480 // -----------------------------------------------------------------------------
       
  1481 //
       
  1482 // -----------------------------------------------------------------------------
       
  1483 //
       
  1484 TBool CMmListBoxItemDrawer::GetHighlightVisibility( TInt aItemIndex, 
       
  1485 		TBool aItemIsCurrent, TBool aAllowHighlightForNonDraggedItem ) const
       
  1486 	{
       
  1487 	TBool highlightVisibility(EFalse);
       
  1488 	if (!iItemHasBackdrop && !iLeftOverAreaUnderAnimatedItem ) //never draw highlight when item has backdrop or when left over area under animated item
       
  1489 		{
       
  1490 		TBool currentlyDraggedItem =
       
  1491 			ItemHasFloatingType( aItemIndex, EDrag ) ||
       
  1492 			ItemHasFloatingType( aItemIndex, EDragTransition );
       
  1493 		
       
  1494 		if ( ( STATIC_CAST(CMmWidgetContainer*,Widget()->Parent())->IsTimerActive()
       
  1495 				&& aItemIsCurrent && aAllowHighlightForNonDraggedItem )
       
  1496 				|| currentlyDraggedItem )
       
  1497 			{
       
  1498 			highlightVisibility = ETrue;
       
  1499 			}
       
  1500 		}
       
  1501 	return highlightVisibility;
       
  1502 	}
       
  1503 
       
  1504 // -----------------------------------------------------------------------------
       
  1505 //
       
  1506 // -----------------------------------------------------------------------------
       
  1507 //
       
  1508 TBool CMmListBoxItemDrawer::GetBackdropVisibility( TInt aItemIndex, 
       
  1509 		TBool aItemIsCurrent ) const
       
  1510 	{
       
  1511 	TBool currentlyDraggedItem =
       
  1512 		ItemHasFloatingType( aItemIndex, EDrag ) ||
       
  1513 		ItemHasFloatingType( aItemIndex, EDragTransition );
       
  1514 	
       
  1515     return 	IsEditMode() /* draw the backdrop only in edit mode */
       
  1516     		&& !currentlyDraggedItem /* backdrop is disabled for dragged items */
       
  1517     		&& !iIsIndicatorItem /* in non-touch backdrop is not drawn, just "move indicators" */
       
  1518     		&& !iLeftOverAreaUnderAnimatedItem /* is the currently drawn item the area left over behind dragged item*/
       
  1519     		&& !( STATIC_CAST( CMmWidgetContainer*,Widget()->Parent() )->IsTimerActive() 
       
  1520     				&& aItemIsCurrent );/*if the timer is active then we want to draw highlight (not backdrop) on the current index*/
       
  1521 	}
       
  1522 
       
  1523 // -----------------------------------------------------------------------------
       
  1524 //
       
  1525 // -----------------------------------------------------------------------------
       
  1526 //
       
  1527 TBool CMmListBoxItemDrawer::ItemHasFloatingType( TInt aItemIndex, 
       
  1528 		TMmFloatingItemType aFloatingType) const
       
  1529 	{
       
  1530 	TBool hasFloatingType( EFalse );
       
  1531 	for ( TInt i = iFloatingItems.Count() - 1 ; i >= 0; i-- )
       
  1532         {
       
  1533 		const TMmFloatingItem& item = iFloatingItems[i];
       
  1534         if ( item.GetFloatingItemType() == aFloatingType
       
  1535         		&& item.GetDrawnItemIndex() == aItemIndex )
       
  1536             {
       
  1537             hasFloatingType = ETrue;
       
  1538             break;
       
  1539             }
       
  1540         }
       
  1541 	return hasFloatingType;
       
  1542 	}
       
  1543 // End of file