phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlaunchercustomlistboxdata.cpp
changeset 0 e686773b3f54
child 3 04ab22b956c2
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2009 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  * ccappcommlaunchercustomlistboxdata.cpp
       
    19  *
       
    20  *  Created on: 2009-11-2
       
    21  *      Author: dev
       
    22  */
       
    23 /*
       
    24  * ============================================================================
       
    25  *  Name     : Eikfrlbd.cpp
       
    26  *  Part of  : Avkon
       
    27  *
       
    28  *  Description:
       
    29  *  Version:
       
    30  *
       
    31  *  Copyright � 2002-2009 Nokia Corporation.
       
    32  *  This material, including documentation and any related 
       
    33  *  computer programs, is protected by copyright controlled by 
       
    34  *  Nokia Corporation. All rights are reserved. Copying, 
       
    35  *  including reproducing, storing,  adapting or translating, any 
       
    36  *  or all of this material requires the prior written consent of 
       
    37  *  Nokia Corporation. This material also contains confidential 
       
    38  *  information which may not be disclosed to others without the 
       
    39  *  prior written consent of Nokia Corporation.
       
    40  * ============================================================================
       
    41  */
       
    42 
       
    43 #include <eikfrlbd.h>
       
    44 #include <aknlists.h>
       
    45 #include <AknMarqueeControl.h>
       
    46 #include <aknpictographinterface.h>
       
    47 #include <aknpictographdrawerinterface.h>
       
    48 #include <aknseffectanim.h>
       
    49 #include <aknslistboxbackgroundcontrolcontext.h>
       
    50 #include <aknsframebackgroundcontrolcontext.h>
       
    51 #include <aknpanic.h>
       
    52 #include <aknbiditextutils.h>
       
    53 #include <centralrepository.h>
       
    54 #include <avkoninternalcrkeys.h>
       
    55 #include <gulicon.h>
       
    56 #include <eikslbd.h>
       
    57 //#include <akndebug.h>
       
    58 #include <aknlayoutscalable_avkon.cdl.h>
       
    59 #include <layoutmetadata.cdl.h>
       
    60 #include <aknphysics.h>
       
    61 #include <AknUtils.h> 
       
    62 #include <AknFontId.h>
       
    63 #include <AknLayoutFont.h>
       
    64 
       
    65 #include "ccappcommlaunchercustomlistboxdata.h"
       
    66 
       
    67 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
    68 #include <aknlistloadertfx.h>
       
    69 #include <aknlistboxtfxinternal.h>
       
    70 #endif //RD_UI_TRANSITION_EFFECTS_LIST
       
    71 
       
    72 #ifdef RD_TACTILE_FEEDBACK
       
    73 #include <touchfeedback.h>
       
    74 #endif //RD_TACTILE_FEEDBACK
       
    75 // there are 17(!) subcells in qdial grid (0 ... 16)
       
    76 const TInt KMaxSubCellIndex = 16 + 1;
       
    77 
       
    78 // colored tick marks support
       
    79 const TInt KColorIconFlag = -1;
       
    80 const TInt KColorIconIdx = 0;
       
    81 
       
    82 /**
       
    83  * This class needs to be in .cpp file so that we do not accidentally make it
       
    84  * derivable; that would destroy all the binary compability advantages this
       
    85  * class has..
       
    86  *
       
    87  * About animation usage:
       
    88  * All animation usage is implemented in this class. Animation is eye candy and
       
    89  * low priority when it comes to resources -> on resource failures animation
       
    90  * fails fast to release resources for more critical functionality. Also, no
       
    91  * attempt to (re)construct failed animation is made.
       
    92  *
       
    93  * User inactivity is not being observed. Only one animation is used. Extension
       
    94  * is CActive to make it possible to postpone animation deletion on animation
       
    95  * failure.
       
    96  */
       
    97 NONSHARABLE_CLASS(CCCAppCommLauncherCustomListBoxDataExtension) : public CActive,
       
    98 		public MAknPictographAnimatorCallBack,
       
    99 		public MCoeForegroundObserver,
       
   100 		public MAknsEffectAnimObserver,
       
   101 		public MListBoxItemChangeObserver
       
   102 	{
       
   103 public:
       
   104 	enum TFlag
       
   105 		{
       
   106 		// Set if current item background should be copied to animation as
       
   107 		// input layer.
       
   108 		EFlagUpdateBg = 0,
       
   109 
       
   110 		// Set if animation has been resized at least once
       
   111 		EFlagHasLayers = 1,
       
   112 
       
   113 		// Set if foreground has been gained.
       
   114 		EFlagHasForeground = 2
       
   115 		};
       
   116 
       
   117 	enum TSubCellType
       
   118 		{
       
   119 		EAknSLGraphic, EAknSLText, EAknSLNumeric
       
   120 		};
       
   121 
       
   122 public:
       
   123 	CCCAppCommLauncherCustomListBoxDataExtension();
       
   124 	void ConstructL(CCCAppCommLauncherCustomListBoxData* aListBoxData,
       
   125 			const TAknsItemID& aAnimationIID);
       
   126 	~CCCAppCommLauncherCustomListBoxDataExtension();
       
   127 	void CreatePictographInterfaceL();
       
   128 	void CreateMarqueeControlL();
       
   129 	static TInt RedrawEvent(TAny* aControl); // Marquee draw callback
       
   130 	TBool IsMarqueeOn();
       
   131 	struct SRowAndSubCell
       
   132 		{
       
   133 		TInt iIndex; // 24 bits for row and 8 bits for subcell
       
   134 		const CFont* iFont;
       
   135 		//TBool iUnderline;
       
   136 		//TBool iStrikethrough;
       
   137 		};
       
   138 	struct SSLSubCell
       
   139 		{
       
   140 		TInt iSubCell; // Must be first entry
       
   141 		TAknTextLineLayout iTextLayout;
       
   142 		TAknWindowLineLayout iGraphicLayout;
       
   143 		TInt iSubCellType;
       
   144 		TInt iConditionValue; // used with conditional layouts for not always drawn subcells
       
   145 		};
       
   146 
       
   147 	SRowAndSubCell& At(TInt aArrayIndex);
       
   148 	const SRowAndSubCell& At(TInt aArrayIndex) const;
       
   149 	void AddRowAndSubCellL(TInt aRow, TInt aSubCell);
       
   150 	TInt
       
   151 			FindRowAndSubCellIndex(TInt& aArrayIndex, TInt aRow, TInt aSubCell) const;
       
   152 	void FindRowAndSubCellIndexOrAddL(TInt& aArrayIndex, TInt aRow,
       
   153 			TInt aSubCell);
       
   154 
       
   155 	SSLSubCell& AtSL(TInt aArrayIndex);
       
   156 	const SSLSubCell& AtSL(TInt aArrayIndex) const;
       
   157 	void AddSLSubCellL(TInt aSubCell);
       
   158 	TInt FindSLSubCellIndex(TInt& aArrayIndex, TInt aSubCell) const;
       
   159 	void FindSLSubCellIndexOrAddL(TInt& aArrayIndex, TInt aSubCell);
       
   160 	void ResetSLSubCellArray();
       
   161 
       
   162 	inline void NoAnimIfError(TInt aError);
       
   163 	void TryCreateAnimation();
       
   164 	TBool SyncAnim(const TSize& aSize);
       
   165 	TBool SyncAndDrawAnim(CBitmapContext& aGc, const TRect& aRect);
       
   166 	MAknsControlContext* SkinBackgroundContext() const;
       
   167 	void DeleteAnim();
       
   168 	void FocusGained();
       
   169 	void FocusLost();
       
   170 	void SkinChanged();
       
   171 	void SetControl(CCoeControl* aControl);
       
   172 
       
   173 	// Implementation of MCoeForegroundObserver
       
   174 	void HandleGainingForeground();
       
   175 	void HandleLosingForeground();
       
   176 
       
   177 	// Implementation of MAknsEffectAnimObserver
       
   178 	void AnimFrameReady(TInt aError, TInt);
       
   179 
       
   180 	// Implementation of MListBoxItemChangeObserver
       
   181 	void ListBoxItemsChanged(CEikListBox* aListBox);
       
   182 
       
   183 	// Overloads CActive::DoCancel
       
   184 	void DoCancel();
       
   185 	// Overloads CActive::RunL
       
   186 	void RunL();
       
   187 
       
   188 	void Play();
       
   189 
       
   190 	void CreateColorBitmapsL(TSize aSize);
       
   191 	void CreateColorBitmapsL();
       
   192 
       
   193 	TBool DrawPressedDownEffectL(MAknsSkinInstance* aSkin, CWindowGc& aGc,
       
   194 			const TRect& aOutRect, const TRect& aInnerRect) const;
       
   195 private:
       
   196 	// New internal methods
       
   197 	TBool DrawHighlightBackground(CFbsBitGc& aGc);
       
   198 	void PostDeleteAnimation();
       
   199 	void CreateAnimationL();
       
   200 	void DoResizeL(const TSize& aHighlightSize, TBool aAboutToStart);
       
   201 
       
   202 public:
       
   203 	struct TSubCellExt
       
   204 		{
       
   205 		TInt iSubCell; // Must be first entry 
       
   206 		TBool iLayoutAlign;
       
   207 		};
       
   208 
       
   209 	TInt AddSubCellExtL(TInt aSubCell);
       
   210 	void FindSubCellExtIndexOrAddL(TInt& aArrayIndex, TInt aSubCell);
       
   211 
       
   212 	void SetSubCellLayoutAlignmentL(TInt aSubCellIndex);
       
   213 
       
   214 	TInt FindSubCellExtIndex(TInt& aArrayIndex, TInt aSubCell) const;
       
   215 	TBool SubCellLayoutAlignment(TInt aSubCellIndex) const;
       
   216 
       
   217 private:
       
   218 	// From MAknPictographAnimatorCallBack
       
   219 	void DrawPictographArea();
       
   220 
       
   221 public:
       
   222 	CCoeControl *iControl; // not owned
       
   223 	CCCAppCommLauncherCustomListBoxData* iListBoxData; // Not owned
       
   224 	CAknsListBoxBackgroundControlContext* iSkinControlContext;
       
   225 	TBool iSkinEnabled;
       
   226 	const TAknsItemID *iSkinHighlightFrameId;
       
   227 	const TAknsItemID *iSkinHighlightFrameCenterId;
       
   228 	TBool iRespectFocus;
       
   229 	// not used ?    HBufC *iTempTextBuffer;
       
   230 	TRect iSkinPopupInnerRect;
       
   231 	TRect iSkinPopupOuterRect;
       
   232 	CAknsFrameBackgroundControlContext* iPopupFrame;
       
   233 	TBool iUseLogicalToVisualConversion;
       
   234 	TInt16 iFirstWordWrappedSubcellIndex;
       
   235 	TInt16 iSecondWordWrappedSubcellIndex;
       
   236 	CAknPictographInterface* iPictoInterface;
       
   237 	CAknMarqueeControl* iMarquee;
       
   238 	CAknMarqueeControl* i2ndLineMarquee;
       
   239 	TInt iCurrentItem; // Current list item index that marquee draws/has drawn.
       
   240 	TInt iCurrentRow; // Current list row being drawn.  // not true - cache of currentitemindex 
       
   241 	TInt iCurrentlyDrawnItemIndex;
       
   242 	CArrayFix<SRowAndSubCell>* iRowAndSubCellArray;
       
   243 	CArrayFix<SSLSubCell>* iSLSubCellArray;
       
   244 	TBool iDrawBackground; // Determines if background should be drawn (transparency)
       
   245 	TSize iSubCellIconSize[KMaxSubCellIndex]; // Store icon sizes for each subcell
       
   246 	TAknSeparatorLinePosition iSeparatorLinePosition;
       
   247 	CAknsEffectAnim* iAnimation;
       
   248 	TBitFlags32 iAnimFlags;
       
   249 	TRgb iHighlightedTextColor;
       
   250 	TRgb iTextColor;
       
   251 	TBool iDrawScrollbarBackground;
       
   252 	TBool iSimpleList;
       
   253 
       
   254 	TBool iUnderlineFlagSet; // underlining support for more than
       
   255 	TBitFlags32 iUnderlineFlags; // one text subcell
       
   256 	TBool iHideSecondRow;
       
   257 	TBool iSubCellsMightIntersect;
       
   258 	TBool iStretchingEnabled;
       
   259 	TAknsItemID iAnimIID;
       
   260 	MListBoxAnimBackgroundDrawer* iHighlightBgDrawer;
       
   261 	TSize iAnimSize; // TODO Deprecating old style anim API and removing this
       
   262 	// Drop shadows can be toggled on/off in
       
   263 	// "transparent" lists (eg. transparent camera setting page).
       
   264 	TBool iUseDropShadows;
       
   265 
       
   266 	// highlight color skinning for setstyle lists - to be deprecated once correct color skinning is available
       
   267 	TBool iUseHighligthIconSwapping;
       
   268 
       
   269 	// colorskin highlight icons
       
   270 	CFbsBitmap* iColorBmp;
       
   271 	CFbsBitmap* iHiliBmp;
       
   272 	TRgb iIconColor;
       
   273 	TRgb iHiliIconColor;
       
   274 
       
   275 	TInt iConditionalCells;
       
   276 
       
   277 	// which columns of highlighted item have clipped text ?
       
   278 	TUint32 iClippedSubcells;
       
   279 	TUint32 iClippedByWrap;
       
   280 	TBool iUseClippedByWrap;
       
   281 
       
   282 	CArrayFix<TSubCellExt>* iSubCellExtArray; //for subcell alignment
       
   283 
       
   284 	TRect iMarginRect;
       
   285 	TBool iKineticScrolling;
       
   286 	};
       
   287 
       
   288 /**
       
   289  * High priority is well argumented because running the active object will
       
   290  * result in animation deletion -> results in freeing resources.
       
   291  */
       
   292 CCCAppCommLauncherCustomListBoxDataExtension::CCCAppCommLauncherCustomListBoxDataExtension() :
       
   293 	CActive(EPriorityHigh)
       
   294 	{
       
   295 	}
       
   296 
       
   297 void CCCAppCommLauncherCustomListBoxDataExtension::ConstructL(
       
   298 		CCCAppCommLauncherCustomListBoxData* aListBoxData,
       
   299 		const TAknsItemID& aAnimationIID)
       
   300 	{
       
   301 	iListBoxData = aListBoxData;
       
   302 	iRowAndSubCellArray = new (ELeave) CArrayFixFlat<SRowAndSubCell> (4);
       
   303 	iSLSubCellArray = new (ELeave) CArrayFixFlat<SSLSubCell> (4);
       
   304 
       
   305 	iSubCellExtArray = new (ELeave) CArrayFixFlat<TSubCellExt> (4);
       
   306 
       
   307 	// bi-di algorithm support (NON_LEAVING_VERSION)
       
   308 	// not used ?    iTempTextBuffer = HBufC::NewL(256);
       
   309 	iUseLogicalToVisualConversion = ETrue;
       
   310 
       
   311 	iFirstWordWrappedSubcellIndex = -1;
       
   312 	iSecondWordWrappedSubcellIndex = -1;
       
   313 
       
   314 	iDrawBackground = ETrue;
       
   315 	iSeparatorLinePosition = ENoLine;
       
   316 
       
   317 	iAnimIID = aAnimationIID;
       
   318 	CActiveScheduler::Add(this);
       
   319 	TryCreateAnimation(); // Animations are created by default
       
   320 
       
   321 	iTextColor = NULL; // just in case
       
   322 	iHighlightedTextColor = NULL; // just in case
       
   323 	iDrawScrollbarBackground = ETrue;
       
   324 
       
   325 #ifdef RD_LIST_STRETCH
       
   326 	// check list stretching from cenrep
       
   327 	CRepository* cenRep = CRepository::NewL(KCRUidAvkon);
       
   328 	cenRep->Get(KAknAutomaticListStretching, iStretchingEnabled);
       
   329 	delete cenRep;
       
   330 #endif
       
   331 
       
   332 	iKineticScrolling = CAknPhysics::FeatureEnabled();
       
   333 	}
       
   334 
       
   335 CCCAppCommLauncherCustomListBoxDataExtension::~CCCAppCommLauncherCustomListBoxDataExtension()
       
   336 	{
       
   337 	Cancel();
       
   338 
       
   339 	// Stop receiving foreground events
       
   340 	CCoeEnv* env = CCoeEnv::Static();
       
   341 	env->RemoveForegroundObserver(*this);
       
   342 
       
   343 	delete iRowAndSubCellArray;
       
   344 	iRowAndSubCellArray = NULL;
       
   345 	delete iSLSubCellArray;
       
   346 	iSLSubCellArray = NULL;
       
   347 	delete iSubCellExtArray;
       
   348 	iSubCellExtArray = NULL;
       
   349 	delete iPopupFrame;
       
   350 	delete iSkinControlContext;
       
   351 	// not used ?    delete iTempTextBuffer;
       
   352 	delete iPictoInterface;
       
   353 	delete iMarquee;
       
   354 	delete i2ndLineMarquee;
       
   355 	delete iAnimation;
       
   356 	delete iColorBmp;
       
   357 	delete iHiliBmp;
       
   358 	}
       
   359 
       
   360 void CCCAppCommLauncherCustomListBoxDataExtension::AddRowAndSubCellL(TInt aRow,
       
   361 		TInt aSubCell)
       
   362 	{
       
   363 	SRowAndSubCell subcell;
       
   364 	subcell.iIndex = (aRow << 8) | (aSubCell & 0xff);
       
   365 	subcell.iFont = NULL;
       
   366 	TKeyArrayFix key(0, ECmpTInt32);
       
   367 	iRowAndSubCellArray->InsertIsqL(subcell, key);
       
   368 	}
       
   369 
       
   370 CCCAppCommLauncherCustomListBoxDataExtension::SRowAndSubCell&
       
   371 CCCAppCommLauncherCustomListBoxDataExtension::At(TInt aArrayIndex)
       
   372 	{
       
   373 	/*    SRowAndSubCell subcell;
       
   374 	 for (int a=0;a<iRowAndSubCellArray->Count();a++)
       
   375 	 subcell = iRowAndSubCellArray->At(a); */
       
   376 
       
   377 	//__ASSERT_DEBUG(aArrayIndex>=0 && aArrayIndex<iRowAndSubCellArray->Count(),Panic(EAknPanicOutOfRange));
       
   378 	return (iRowAndSubCellArray->At(aArrayIndex));
       
   379 	}
       
   380 
       
   381 const CCCAppCommLauncherCustomListBoxDataExtension::SRowAndSubCell&
       
   382 CCCAppCommLauncherCustomListBoxDataExtension::At(TInt aArrayIndex) const
       
   383 	{
       
   384 	//__ASSERT_DEBUG(aArrayIndex>=0 && aArrayIndex<iRowAndSubCellArray->Count(),Panic(EAknPanicOutOfRange));
       
   385 	return (iRowAndSubCellArray->At(aArrayIndex));
       
   386 	}
       
   387 
       
   388 TInt CCCAppCommLauncherCustomListBoxDataExtension::FindRowAndSubCellIndex(
       
   389 		TInt& aArrayIndex, TInt aRow, TInt aSubCell) const
       
   390 	{
       
   391 	if (iRowAndSubCellArray->Count() == 0)
       
   392 		return (KErrNotFound);
       
   393 	TKeyArrayFix key(0, ECmpTInt32);
       
   394 	SRowAndSubCell rowAndSubcell;
       
   395 	rowAndSubcell.iIndex = (aRow << 8) | (aSubCell & 0xff);
       
   396 	return (iRowAndSubCellArray->FindIsq(rowAndSubcell, key, aArrayIndex));
       
   397 	}
       
   398 
       
   399 void CCCAppCommLauncherCustomListBoxDataExtension::FindRowAndSubCellIndexOrAddL(
       
   400 		TInt& aArrayIndex, TInt aRow, TInt aSubCell)
       
   401 	{
       
   402 	if (FindRowAndSubCellIndex(aArrayIndex, aRow, aSubCell) != 0) //==KErrNotFound)
       
   403 		{
       
   404 		AddRowAndSubCellL(aRow, aSubCell);
       
   405 		FindRowAndSubCellIndex(aArrayIndex, aRow, aSubCell);
       
   406 		}
       
   407 	/*       SRowAndSubCell rowAndSubcell;
       
   408 	 rowAndSubcell = iRowAndSubCellArray->At(aArrayIndex); */
       
   409 	}
       
   410 
       
   411 void CCCAppCommLauncherCustomListBoxDataExtension::AddSLSubCellL(TInt aSubCell)
       
   412 	{
       
   413 	SSLSubCell subcell;
       
   414 	subcell.iSubCell = aSubCell;
       
   415 	subcell.iTextLayout = NULL;
       
   416 	subcell.iGraphicLayout = NULL;
       
   417 	subcell.iSubCellType = 0;
       
   418 	subcell.iConditionValue = -1;
       
   419 
       
   420 	TKeyArrayFix key(0, ECmpTInt32);
       
   421 	iSLSubCellArray->InsertIsqL(subcell, key);
       
   422 	}
       
   423 
       
   424 CCCAppCommLauncherCustomListBoxDataExtension::SSLSubCell&
       
   425 CCCAppCommLauncherCustomListBoxDataExtension::AtSL(TInt aArrayIndex)
       
   426 	{
       
   427 	//__ASSERT_DEBUG(aArrayIndex>=0 && aArrayIndex<iSLSubCellArray->Count(),Panic(EAknPanicOutOfRange));
       
   428 	return (iSLSubCellArray->At(aArrayIndex));
       
   429 	}
       
   430 
       
   431 const CCCAppCommLauncherCustomListBoxDataExtension::SSLSubCell&
       
   432 CCCAppCommLauncherCustomListBoxDataExtension::AtSL(TInt aArrayIndex) const
       
   433 	{
       
   434 	//__ASSERT_DEBUG(aArrayIndex>=0 && aArrayIndex<iSLSubCellArray->Count(),Panic(EAknPanicOutOfRange));
       
   435 	return (iSLSubCellArray->At(aArrayIndex));
       
   436 	}
       
   437 
       
   438 TInt CCCAppCommLauncherCustomListBoxDataExtension::FindSLSubCellIndex(
       
   439 		TInt& aArrayIndex, TInt aSubCell) const
       
   440 	{
       
   441 	if (iSLSubCellArray->Count() == 0)
       
   442 		return (KErrNotFound);
       
   443 	TKeyArrayFix key(0, ECmpTInt32);
       
   444 	SSLSubCell SLSubCell;
       
   445 	SLSubCell.iSubCell = aSubCell;
       
   446 	return (iSLSubCellArray->FindIsq(SLSubCell, key, aArrayIndex));
       
   447 	}
       
   448 
       
   449 void CCCAppCommLauncherCustomListBoxDataExtension::FindSLSubCellIndexOrAddL(
       
   450 		TInt& aArrayIndex, TInt aSubCell)
       
   451 	{
       
   452 	if (FindSLSubCellIndex(aArrayIndex, aSubCell) != 0) //==KErrNotFound)
       
   453 		{
       
   454 		AddSLSubCellL(aSubCell);
       
   455 		FindSLSubCellIndex(aArrayIndex, aSubCell);
       
   456 		}
       
   457 	}
       
   458 
       
   459 void CCCAppCommLauncherCustomListBoxDataExtension::ResetSLSubCellArray()
       
   460 	{
       
   461 	iSLSubCellArray->Reset();
       
   462 	iRowAndSubCellArray->Reset();
       
   463 	}
       
   464 
       
   465 void CCCAppCommLauncherCustomListBoxDataExtension::CreatePictographInterfaceL()
       
   466 	{
       
   467 	if (!iPictoInterface)
       
   468 		{
       
   469 		iPictoInterface = CAknPictographInterface::NewL(*iControl, *this);
       
   470 		}
       
   471 	}
       
   472 
       
   473 // -----------------------------------------------------------------------------
       
   474 // CCCAppCommLauncherCustomListBoxDataExtension::NoAnimIfError
       
   475 // -----------------------------------------------------------------------------
       
   476 //
       
   477 inline void CCCAppCommLauncherCustomListBoxDataExtension::NoAnimIfError(
       
   478 		TInt aError)
       
   479 	{
       
   480 	if (KErrNone != aError)
       
   481 		{
       
   482 		DeleteAnim();
       
   483 		}
       
   484 	}
       
   485 
       
   486 // -----------------------------------------------------------------------------
       
   487 // CCCAppCommLauncherCustomListBoxDataExtension::TryCreateAnimation
       
   488 // -----------------------------------------------------------------------------
       
   489 //
       
   490 void CCCAppCommLauncherCustomListBoxDataExtension::TryCreateAnimation()
       
   491 	{
       
   492 	if (!iControl)
       
   493 		{
       
   494 		return;
       
   495 		}
       
   496 
       
   497 #ifdef RD_UI_TRANSITION_EFFECTS_LIST  
       
   498 	CEikListBox* list = static_cast<CEikListBox*> (iControl);
       
   499 	CListBoxView* view = list->View();
       
   500 	if (!view || !view->ItemDrawer())
       
   501 		{
       
   502 		return;
       
   503 		}
       
   504 	CWindowGc* gc = view->ItemDrawer()->Gc();
       
   505 	MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal(gc);
       
   506 	if (transApi && transApi->VerifyKml() == KErrNone)
       
   507 		{
       
   508 		return;
       
   509 		}
       
   510 #endif //RD_UI_TRANSITION_EFFECTS_LIST      
       
   511 
       
   512 	// Ideally we should not create animation if the list has zero items.
       
   513 	// Unfortunately, this will cause problems elsewhere as setting item text
       
   514 	// array to list requires not calling HandleItemAddition (or similar
       
   515 	// method) -> in some situations animation would not be created at all as
       
   516 	// we don't receive item change event. Fortunately, creating animation to
       
   517 	// empty list doesn't carry much overhead as layer creation is delayed to
       
   518 	// first render.
       
   519 
       
   520 	if (!iAnimation)
       
   521 		{
       
   522 		// This must be the first call because animation does not exist.
       
   523 		// Animation layers are created when the animation is rendered for the
       
   524 		// first time.
       
   525 		TRAPD( err, CreateAnimationL() );
       
   526 		NoAnimIfError(err);
       
   527 		}
       
   528 	}
       
   529 
       
   530 // -----------------------------------------------------------------------------
       
   531 // CCCAppCommLauncherCustomListBoxDataExtension::SyncAnim
       
   532 // -----------------------------------------------------------------------------
       
   533 //
       
   534 TBool CCCAppCommLauncherCustomListBoxDataExtension::SyncAnim(const TSize& aSize)
       
   535 	{
       
   536 	if (!iAnimation || aSize.iWidth <= 0 || aSize.iHeight <= 0)
       
   537 		{
       
   538 		return EFalse;
       
   539 		}
       
   540 
       
   541 	if (iAnimation->Size() != aSize || iAnimation->NeedsInputLayer())
       
   542 		{
       
   543 		// Resizing will update animation background
       
   544 		iAnimFlags.Clear(EFlagUpdateBg);
       
   545 		// Animation exists but its size is out of sync or input layers have
       
   546 		// been released
       
   547 		TRAPD( err, DoResizeL( aSize, iAnimFlags.IsSet( EFlagHasForeground ) ) );
       
   548 
       
   549 		if (err)
       
   550 			{
       
   551 			DeleteAnim();
       
   552 			return EFalse;
       
   553 			}
       
   554 		iAnimFlags.Set(EFlagHasLayers);
       
   555 		}
       
   556 
       
   557 	// Highlight animation background needs update (current item has changed)
       
   558 	if (iAnimFlags.IsSet(EFlagUpdateBg))
       
   559 		{
       
   560 		iAnimFlags.Clear(EFlagUpdateBg);
       
   561 
       
   562 		if (iAnimation->InputRgbGc())
       
   563 			{
       
   564 			DrawHighlightBackground(*iAnimation->InputRgbGc());
       
   565 			// We need to update the output frame (otherwise the highlight
       
   566 			// would drawn with the old output before the next new animation
       
   567 			// frame).
       
   568 			NoAnimIfError(iAnimation->UpdateOutput());
       
   569 			if (!iAnimation)
       
   570 				{
       
   571 				return EFalse;
       
   572 				}
       
   573 			}
       
   574 		}
       
   575 
       
   576 	return ETrue;
       
   577 	}
       
   578 
       
   579 // -----------------------------------------------------------------------------
       
   580 // CCCAppCommLauncherCustomListBoxDataExtension::SyncAndDrawAnim
       
   581 // -----------------------------------------------------------------------------
       
   582 //
       
   583 TBool CCCAppCommLauncherCustomListBoxDataExtension::SyncAndDrawAnim(
       
   584 		CBitmapContext& aGc, const TRect& aRect)
       
   585 	{
       
   586 	if (iAnimation)
       
   587 		{
       
   588 		// When application loses foreground or has not yet gained foreground
       
   589 		// animation is in stopped state and input layers are not present. It
       
   590 		// is possible that list is repainted in this situation. Calling
       
   591 		// SyncAnim will create the non-present layers -> WSERV flush ->
       
   592 		// flicker. To prevent flickering we just render the existing frame.
       
   593 		// This can lead to incorrect draw if the current item index is changed
       
   594 		// when the app has no foreground (very unlikely). If EFlagHasLayers is
       
   595 		// not set we need to do SyncAnim because it is the first call to draw
       
   596 		// (and flicker is not an issue).
       
   597 		if (EAknsAnimStateStopped == iAnimation->State() && !iAnimFlags.IsSet(
       
   598 				EFlagHasForeground) && iAnimFlags.IsSet(EFlagHasLayers)
       
   599 				&& !iAnimFlags.IsSet(EFlagUpdateBg))
       
   600 			{
       
   601 			return iAnimation->Render(aGc, aRect);
       
   602 			}
       
   603 		}
       
   604 
       
   605 	if (SyncAnim(aRect.Size()))
       
   606 		{
       
   607 		return iAnimation->Render(aGc, aRect);
       
   608 		}
       
   609 
       
   610 	return EFalse;
       
   611 	}
       
   612 
       
   613 // -----------------------------------------------------------------------------
       
   614 // CCCAppCommLauncherCustomListBoxDataExtension::SkinBackgroundContext
       
   615 // -----------------------------------------------------------------------------
       
   616 //
       
   617 MAknsControlContext* CCCAppCommLauncherCustomListBoxDataExtension::SkinBackgroundContext() const
       
   618 	{
       
   619 	if (iSkinEnabled)
       
   620 		return iSkinControlContext;
       
   621 	else
       
   622 		return NULL;
       
   623 	}
       
   624 
       
   625 // -----------------------------------------------------------------------------
       
   626 // CCCAppCommLauncherCustomListBoxDataExtension::DeleteAnim
       
   627 // -----------------------------------------------------------------------------
       
   628 //
       
   629 void CCCAppCommLauncherCustomListBoxDataExtension::DeleteAnim()
       
   630 	{
       
   631 	// Stop receiving foreground events
       
   632 	CCoeEnv* env = CCoeEnv::Static();
       
   633 	env->RemoveForegroundObserver(*this);
       
   634 
       
   635 	delete iAnimation;
       
   636 	iAnimation = NULL;
       
   637 	}
       
   638 
       
   639 // -----------------------------------------------------------------------------
       
   640 // CCCAppCommLauncherCustomListBoxDataExtension::FocusGained
       
   641 // -----------------------------------------------------------------------------
       
   642 //
       
   643 void CCCAppCommLauncherCustomListBoxDataExtension::FocusGained()
       
   644 	{
       
   645 	Play();
       
   646 	}
       
   647 
       
   648 // -----------------------------------------------------------------------------
       
   649 // CCCAppCommLauncherCustomListBoxDataExtension::FocusLost
       
   650 // -----------------------------------------------------------------------------
       
   651 //
       
   652 void CCCAppCommLauncherCustomListBoxDataExtension::FocusLost()
       
   653 	{
       
   654 	if (iAnimation)
       
   655 		{
       
   656 		NoAnimIfError(iAnimation->Pause());
       
   657 		}
       
   658 	}
       
   659 
       
   660 // -----------------------------------------------------------------------------
       
   661 // CCCAppCommLauncherCustomListBoxDataExtension::SkinChanged
       
   662 // -----------------------------------------------------------------------------
       
   663 //
       
   664 void CCCAppCommLauncherCustomListBoxDataExtension::SkinChanged()
       
   665 	{
       
   666 	DeleteAnim();
       
   667 	TryCreateAnimation();
       
   668 	TRAP_IGNORE( CreateColorBitmapsL() );
       
   669 	}
       
   670 
       
   671 // -----------------------------------------------------------------------------
       
   672 // CCCAppCommLauncherCustomListBoxDataExtension::SetControl
       
   673 // -----------------------------------------------------------------------------
       
   674 //
       
   675 void CCCAppCommLauncherCustomListBoxDataExtension::SetControl(
       
   676 		CCoeControl* aControl)
       
   677 	{
       
   678 	if (iControl)
       
   679 		{
       
   680 		CEikListBox* list = (CEikListBox*) iControl;
       
   681 		list->RemoveItemChangeObserver(this);
       
   682 		}
       
   683 
       
   684 	iControl = aControl;
       
   685 
       
   686 	if (iControl)
       
   687 		{
       
   688 		CEikListBox* list = (CEikListBox*) iControl;
       
   689 			TRAP_IGNORE( list->AddItemChangeObserverL(this) );
       
   690 
       
   691 		if (!iAnimation)
       
   692 			{
       
   693 			TryCreateAnimation();
       
   694 			}
       
   695 
       
   696 		if (iAnimation)
       
   697 			{
       
   698 			Play();
       
   699 			}
       
   700 		}
       
   701 	else
       
   702 		{
       
   703 		DeleteAnim();
       
   704 		}
       
   705 	}
       
   706 
       
   707 // -----------------------------------------------------------------------------
       
   708 // CCCAppCommLauncherCustomListBoxDataExtension::HandleGainingForeground
       
   709 // -----------------------------------------------------------------------------
       
   710 //
       
   711 void CCCAppCommLauncherCustomListBoxDataExtension::HandleGainingForeground()
       
   712 	{
       
   713 	// Most of the time focus focus events happen between foreground events.
       
   714 	// Unfortunately, there are embedded app related cases where this does not
       
   715 	// always hold (it is possible to focus in non-foreground application or
       
   716 	// gain foreground without getting a focus gained). Therefore animations
       
   717 	// must be started here. This causes potential problem case: foreground
       
   718 	// events are broadcasted to all animations, if there are multiple lists
       
   719 	// that have focus the result will be multiple animations running at the
       
   720 	// same time.
       
   721 	iAnimFlags.Set(EFlagHasForeground);
       
   722 
       
   723 	if (iAnimation)
       
   724 		{
       
   725 		// Because we are gaining foreground we must restore input layers
       
   726 		// (which are released when animation stops to reduce memory usage).
       
   727 		SyncAnim(iAnimation->Size());
       
   728 		}
       
   729 
       
   730 	if (iControl)
       
   731 		{
       
   732 		if (iControl->IsFocused())
       
   733 			{
       
   734 			Play();
       
   735 			}
       
   736 		}
       
   737 	}
       
   738 
       
   739 // -----------------------------------------------------------------------------
       
   740 // CCCAppCommLauncherCustomListBoxDataExtension::HandleLosingForeground
       
   741 // -----------------------------------------------------------------------------
       
   742 //
       
   743 void CCCAppCommLauncherCustomListBoxDataExtension::HandleLosingForeground()
       
   744 	{
       
   745 	iAnimFlags.Clear(EFlagHasForeground);
       
   746 	if (iAnimation)
       
   747 		{
       
   748 		NoAnimIfError(iAnimation->Stop());
       
   749 		}
       
   750 	}
       
   751 
       
   752 // -----------------------------------------------------------------------------
       
   753 // CCCAppCommLauncherCustomListBoxDataExtension::AnimFrameReady
       
   754 // -----------------------------------------------------------------------------
       
   755 //
       
   756 void CCCAppCommLauncherCustomListBoxDataExtension::AnimFrameReady(TInt aError,
       
   757 		TInt)
       
   758 	{
       
   759 	if (KErrNone != aError)
       
   760 		{
       
   761 		// Animation has failed to run -> schedule the animation for
       
   762 		// deletion to fall back to normal rendering.
       
   763 		PostDeleteAnimation();
       
   764 		return;
       
   765 		}
       
   766 
       
   767 	// This situation should never happen because we start/stop animation when
       
   768 	// the extension's control is set.
       
   769 	if (!iControl)
       
   770 		return;
       
   771 
       
   772 	// From now on, we have a valid control pointer
       
   773 	CEikListBox* list = static_cast<CEikListBox*> (iControl);
       
   774 	CListBoxView* view = list->View();
       
   775 
       
   776 	if (!view)
       
   777 		return;
       
   778 
       
   779 	// We should not run animation when control is in certain states. When
       
   780 	// control is in these states we idle the animation until the control state
       
   781 	// becomes valid again.
       
   782 	TBool invalid = !iControl->IsVisible() || iControl->IsDimmed()
       
   783 			|| (view->ItemDrawer()->Flags()
       
   784 					& CListItemDrawer::EDisableHighlight);
       
   785 
       
   786 	// Check for idling
       
   787 	if (iAnimation->IsIdling())
       
   788 		{
       
   789 		if (invalid)
       
   790 			{
       
   791 			// We are idling and the control is still invalid -> keep on
       
   792 			// idling.
       
   793 			return;
       
   794 			}
       
   795 		else
       
   796 			{
       
   797 			// Control is in valid state, animation should be continued
       
   798 			TInt err = iAnimation->Continue();
       
   799 			if (err)
       
   800 				PostDeleteAnimation();
       
   801 			return;
       
   802 			}
       
   803 		}
       
   804 	else if (invalid) // Not idling and invalid control -> start idling
       
   805 		{
       
   806 		iAnimation->SetIdling(KAknsEffectAnimDefaultIdleInterval);
       
   807 		// If the highlight has been disabled, render once to clear the
       
   808 		// highlight (not returning in that case).
       
   809 		if (!(view->ItemDrawer()->Flags() & CListItemDrawer::EDisableHighlight))
       
   810 			return;
       
   811 		}
       
   812 
       
   813 	// From now on, we have a valid control pointer and control has enabled
       
   814 	// highlight, is visible and is not dimmed.
       
   815 
       
   816 	// No items, no drawing
       
   817 	if (list->Model()->NumberOfItems() == 0)
       
   818 		return;
       
   819 
       
   820 	if (iListBoxData->LastSubCell() < 0)
       
   821 		return;
       
   822 
       
   823 	TBool customGcInUse = list->GetGc() != &CEikonEnv::Static()->SystemGc();
       
   824 
       
   825 	// if remoteGc is in use (CCoeControl has custom gc set)
       
   826 	// then draw the whole control as the transition system 
       
   827 	// expects the draw to be initiated from CONE control
       
   828 
       
   829 	if (!customGcInUse)
       
   830 		{
       
   831 		// Repaint the highlighted cell only
       
   832 		list->RedrawItem(view->CurrentItemIndex());
       
   833 		}
       
   834 	else
       
   835 		{
       
   836 		CCoeControl* ctrl = (CCoeControl*) list;
       
   837 		ctrl->DrawNow();
       
   838 		}
       
   839 
       
   840 	}
       
   841 
       
   842 // -----------------------------------------------------------------------------
       
   843 // CCCAppCommLauncherCustomListBoxDataExtension::ListBoxItemsChanged
       
   844 //
       
   845 // this is called from from:
       
   846 // - CEikListBox::Reset()
       
   847 // - CEikListBox::HandleItemRemoval{WithoutSelections}L()
       
   848 // - CEikListBox::HandleItemAdditionL()
       
   849 // - CEikListBox::FireItemChange()
       
   850 // In all cases:
       
   851 // - feedback areas might be invalid
       
   852 // - application is responsible for redrawing the listbox.
       
   853 //
       
   854 // since re-drawing listbox fixes feedback areas, those can be reset here.
       
   855 // -----------------------------------------------------------------------------
       
   856 //
       
   857 void CCCAppCommLauncherCustomListBoxDataExtension::ListBoxItemsChanged(
       
   858 		CEikListBox* aListBox)
       
   859 	{
       
   860 
       
   861 	TInt items = aListBox->Model()->NumberOfItems();
       
   862 
       
   863 	if (iAnimation)
       
   864 		{
       
   865 		if (0 == items)
       
   866 			{
       
   867 			DeleteAnim();
       
   868 			}
       
   869 		else
       
   870 			{
       
   871 			Play();
       
   872 			}
       
   873 		}
       
   874 	else if (!iAnimation)
       
   875 		{
       
   876 		// Animation doesn't exist and we have > 0 items
       
   877 		TryCreateAnimation();
       
   878 		}
       
   879 	}
       
   880 
       
   881 // -----------------------------------------------------------------------------
       
   882 // CCCAppCommLauncherCustomListBoxDataExtension::DoCancel
       
   883 // -----------------------------------------------------------------------------
       
   884 //
       
   885 void CCCAppCommLauncherCustomListBoxDataExtension::DoCancel()
       
   886 	{
       
   887 	// Required method, but not needed
       
   888 	}
       
   889 
       
   890 // -----------------------------------------------------------------------------
       
   891 // CCCAppCommLauncherCustomListBoxDataExtension::RunL
       
   892 // Postponed animation deletion is done here.
       
   893 // -----------------------------------------------------------------------------
       
   894 //
       
   895 void CCCAppCommLauncherCustomListBoxDataExtension::RunL()
       
   896 	{
       
   897 	DeleteAnim();
       
   898 	}
       
   899 
       
   900 // -----------------------------------------------------------------------------
       
   901 // CCCAppCommLauncherCustomListBoxDataExtension::Play
       
   902 // -----------------------------------------------------------------------------
       
   903 //
       
   904 void CCCAppCommLauncherCustomListBoxDataExtension::Play()
       
   905 	{
       
   906 	if (!iAnimation)
       
   907 		{
       
   908 		return;
       
   909 		}
       
   910 
       
   911 	// No need to start running/finished animation
       
   912 	if (EAknsAnimStateRunning == iAnimation->State() || EAknsAnimStateFinished
       
   913 			== iAnimation->State())
       
   914 		{
       
   915 		return;
       
   916 		}
       
   917 
       
   918 	// Check that application is on foreground because there are cases where
       
   919 	// focus changes are done after foreground is lost -> potentially leads to
       
   920 	// multiple running animations.
       
   921 	if (!iAnimFlags.IsSet(EFlagHasForeground))
       
   922 		{
       
   923 		return;
       
   924 		}
       
   925 
       
   926 	// Animation cannot run if we don't have control (nowhere to draw)
       
   927 	if (!iControl)
       
   928 		{
       
   929 		return;
       
   930 		}
       
   931 
       
   932 	// The control must also have the focus
       
   933 	if (!iControl->IsFocused())
       
   934 		{
       
   935 		return;
       
   936 		}
       
   937 
       
   938 	// Don't animate empty list
       
   939 	CEikListBox* list = static_cast<CEikListBox*> (iControl);
       
   940 	if (list->Model()->NumberOfItems() == 0)
       
   941 		{
       
   942 		return;
       
   943 		}
       
   944 
       
   945 	// All preconditions are met: we have animation, foreground, focus, more
       
   946 	// than zero items and animation is either paused or stopped. Invisibility,
       
   947 	// dimming and disabled highlight are handled by idling the animation (see
       
   948 	// AnimFrameReady).
       
   949 
       
   950 	if (EAknsAnimStatePaused == iAnimation->State())
       
   951 		{
       
   952 		NoAnimIfError(iAnimation->Continue());
       
   953 		}
       
   954 	else if (EAknsAnimStateStopped == iAnimation->State())
       
   955 		{
       
   956 		NoAnimIfError(iAnimation->Start());
       
   957 		}
       
   958 	}
       
   959 
       
   960 // -----------------------------------------------------------------------------
       
   961 // CCCAppCommLauncherCustomListBoxDataExtension::DrawHighlightBackground
       
   962 // -----------------------------------------------------------------------------
       
   963 //
       
   964 TBool CCCAppCommLauncherCustomListBoxDataExtension::DrawHighlightBackground(
       
   965 		CFbsBitGc& aGc)
       
   966 	{
       
   967 	if (iHighlightBgDrawer) // Bg drawing is done externally (in derived class)
       
   968 		{
       
   969 		return iHighlightBgDrawer->DrawHighlightAnimBackground(aGc);
       
   970 		}
       
   971 
       
   972 	// Draw the background under the current highlight. This is simplified
       
   973 	// drawing, we only grab a piece from the list background bitmap.
       
   974 	CEikListBox* list = static_cast<CEikListBox*> (iControl);
       
   975 	CListBoxView* view = list->View();
       
   976 	TRect itemRect;
       
   977 	TInt index = view->CurrentItemIndex();
       
   978 
       
   979 	// It is possible that the animation is constructed when the list is
       
   980 	// empty. In this case draw the first element background (drawing works ok
       
   981 	// even if the list has no items).
       
   982 	if (list->Model()->NumberOfItems() == 0)
       
   983 		{
       
   984 		index = 0;
       
   985 		}
       
   986 	itemRect.SetRect(view->ItemPos(index), iAnimation->Size());
       
   987 
       
   988 	MAknsControlContext* cc = AknsDrawUtils::ControlContext(iControl);
       
   989 
       
   990 	if (!cc)
       
   991 		{
       
   992 		cc = SkinBackgroundContext();
       
   993 		}
       
   994 
       
   995 	return AknsDrawUtils::DrawBackground(AknsUtils::SkinInstance(), cc,
       
   996 			iControl, aGc, TPoint(0, 0), itemRect,
       
   997 			KAknsDrawParamBottomLevelRGBOnly);
       
   998 	}
       
   999 
       
  1000 // -----------------------------------------------------------------------------
       
  1001 // CCCAppCommLauncherCustomListBoxDataExtension::PostDeleteAnimation
       
  1002 // Schedules the animation for deletion by activating the extension itself.
       
  1003 // Deletion is postponed because in many error/failure occasions the caller has
       
  1004 // been animation and direct deletion is possibly not safe (because function
       
  1005 // stack would return through the deleted object).
       
  1006 // -----------------------------------------------------------------------------
       
  1007 //
       
  1008 void CCCAppCommLauncherCustomListBoxDataExtension::PostDeleteAnimation()
       
  1009 	{
       
  1010 	TRequestStatus* status = &iStatus;
       
  1011 	User::RequestComplete(status, KErrNone);
       
  1012 	SetActive();
       
  1013 	}
       
  1014 
       
  1015 // -----------------------------------------------------------------------------
       
  1016 // CCCAppCommLauncherCustomListBoxDataExtension::CreateAnimationL
       
  1017 // -----------------------------------------------------------------------------
       
  1018 //
       
  1019 void CCCAppCommLauncherCustomListBoxDataExtension::CreateAnimationL()
       
  1020 	{
       
  1021 	DeleteAnim();
       
  1022 
       
  1023 	// Check if derived class wants to disable highlight animation. Also, no
       
  1024 	// highlight animation on lists that don't have background
       
  1025 	if ((KAknsIIDNone == iAnimIID)
       
  1026 			|| !iListBoxData->IsBackgroundDrawingEnabled())
       
  1027 		{
       
  1028 		return;
       
  1029 		}
       
  1030 
       
  1031 	// Create animation
       
  1032 	CCoeEnv* env = CCoeEnv::Static();
       
  1033 	env->AddForegroundObserverL(*this);
       
  1034 
       
  1035 	iAnimation = CAknsEffectAnim::NewL(this);
       
  1036 	TBool ok = iAnimation->ConstructFromSkinL(iAnimIID);
       
  1037 
       
  1038 	if (!ok) // Animation for the ID was not found from the skin
       
  1039 		{
       
  1040 		User::Leave(KErrNotFound);
       
  1041 		}
       
  1042 
       
  1043 	// Sync the local foreground flag state. Foreground state is stored locally
       
  1044 	// because calling AppUi::IsForeground causes WSERV flush (shocking) and
       
  1045 	// therefore it cannot be used in draw routines.
       
  1046 	CAknAppUi* aui = static_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi());
       
  1047 	iAnimFlags.Assign(EFlagHasForeground, aui->IsForeground());
       
  1048 
       
  1049 	Play();
       
  1050 	}
       
  1051 
       
  1052 // -----------------------------------------------------------------------------
       
  1053 // CCCAppCommLauncherCustomListBoxDataExtension::DoResizeL
       
  1054 // -----------------------------------------------------------------------------
       
  1055 //
       
  1056 void CCCAppCommLauncherCustomListBoxDataExtension::DoResizeL(
       
  1057 		const TSize& aHighlightSize, TBool aAboutToStart)
       
  1058 	{
       
  1059 	iAnimation->BeginConfigInputLayersL(aHighlightSize, aAboutToStart);
       
  1060 
       
  1061 	if (iAnimation->InputRgbGc())
       
  1062 		{
       
  1063 		DrawHighlightBackground(*iAnimation->InputRgbGc());
       
  1064 		}
       
  1065 
       
  1066 	iAnimation->EndConfigInputLayersL();
       
  1067 	}
       
  1068 
       
  1069 ///////////handling TSubCellExt,start
       
  1070 
       
  1071 TInt CCCAppCommLauncherCustomListBoxDataExtension::AddSubCellExtL(TInt aSubCell)
       
  1072 	{
       
  1073 	TSubCellExt subcell;
       
  1074 	subcell.iSubCell = aSubCell;
       
  1075 	subcell.iLayoutAlign = ETrue;
       
  1076 
       
  1077 	TKeyArrayFix key(0, ECmpTInt);
       
  1078 	return iSubCellExtArray->InsertIsqL(subcell, key);
       
  1079 
       
  1080 	}
       
  1081 
       
  1082 void CCCAppCommLauncherCustomListBoxDataExtension::FindSubCellExtIndexOrAddL(
       
  1083 		TInt& aArrayIndex, TInt aSubCell)
       
  1084 	{
       
  1085 	if (FindSubCellExtIndex(aArrayIndex, aSubCell) == KErrNotFound)
       
  1086 		{
       
  1087 		aArrayIndex = AddSubCellExtL(aSubCell);
       
  1088 		//FindSubCellExtIndex(aArrayIndex,aSubCell);
       
  1089 		}
       
  1090 	}
       
  1091 
       
  1092 void CCCAppCommLauncherCustomListBoxDataExtension::SetSubCellLayoutAlignmentL(
       
  1093 		TInt aSubCellIndex)
       
  1094 	{
       
  1095 	TInt index = 0;
       
  1096 	FindSubCellExtIndexOrAddL(index, aSubCellIndex);
       
  1097 	iSubCellExtArray->At(index).iLayoutAlign = EFalse;
       
  1098 	}
       
  1099 
       
  1100 TInt CCCAppCommLauncherCustomListBoxDataExtension::FindSubCellExtIndex(
       
  1101 		TInt& aArrayIndex, TInt aSubCell) const
       
  1102 	{
       
  1103 	if (aSubCell < 0 || iSubCellExtArray->Count() == 0)
       
  1104 		return (KErrNotFound);
       
  1105 	TKeyArrayFix key(0, ECmpTInt);
       
  1106 	TSubCellExt subcell;
       
  1107 	subcell.iSubCell = aSubCell;
       
  1108 	TInt retVal = iSubCellExtArray->FindIsq(subcell, key, aArrayIndex);
       
  1109 	if (retVal != 0)
       
  1110 		{
       
  1111 		return KErrNotFound;
       
  1112 		}
       
  1113 
       
  1114 	return retVal;
       
  1115 	}
       
  1116 
       
  1117 TBool CCCAppCommLauncherCustomListBoxDataExtension::SubCellLayoutAlignment(
       
  1118 		TInt aSubCellIndex) const
       
  1119 	{
       
  1120 	TInt index = 0;
       
  1121 	if (FindSubCellExtIndex(index, aSubCellIndex) == KErrNotFound)
       
  1122 		return (ETrue);
       
  1123 	return (iSubCellExtArray->At(index).iLayoutAlign);
       
  1124 	}
       
  1125 
       
  1126 ///////////handling TSubCellExt,end
       
  1127 
       
  1128 void CCCAppCommLauncherCustomListBoxDataExtension::DrawPictographArea()
       
  1129 	{
       
  1130 	// This callback is never invoked, if iControl is NULL.
       
  1131 	iControl->DrawNow();
       
  1132 	}
       
  1133 
       
  1134 void CCCAppCommLauncherCustomListBoxDataExtension::CreateMarqueeControlL()
       
  1135 	{
       
  1136 	if (!iMarquee)
       
  1137 		{
       
  1138 		iMarquee = CAknMarqueeControl::NewL();
       
  1139 		}
       
  1140 
       
  1141 	if (!i2ndLineMarquee)
       
  1142 		{
       
  1143 		i2ndLineMarquee = CAknMarqueeControl::NewL();
       
  1144 		}
       
  1145 	}
       
  1146 
       
  1147 TInt CCCAppCommLauncherCustomListBoxDataExtension::RedrawEvent(TAny* aControl)
       
  1148 	{
       
  1149 	if (!((CCoeControl*) aControl)->IsVisible())
       
  1150 		{
       
  1151 		return EFalse;
       
  1152 		}
       
  1153 	CEikFormattedCellListBox* listBox = (CEikFormattedCellListBox*) aControl;
       
  1154 	if (listBox->CurrentItemIndex() >= 0)
       
  1155 		{
       
  1156 		listBox->RedrawItem(listBox->CurrentItemIndex());
       
  1157 		}
       
  1158 	return ETrue;
       
  1159 	}
       
  1160 
       
  1161 TBool CCCAppCommLauncherCustomListBoxDataExtension::IsMarqueeOn()
       
  1162 	{
       
  1163 	TBool isOn = EFalse;
       
  1164 	if (iMarquee)
       
  1165 		isOn = iMarquee->IsMarqueeOn();
       
  1166 	return isOn;
       
  1167 	}
       
  1168 
       
  1169 TBool CCCAppCommLauncherCustomListBoxDataExtension::DrawPressedDownEffectL(
       
  1170 		MAknsSkinInstance* aInstance, CWindowGc& aGc, const TRect& aOutRect,
       
  1171 		const TRect& aInnerRect) const
       
  1172 	{
       
  1173 	return AknsDrawUtils::DrawFrame(aInstance, aGc, aOutRect, aInnerRect,
       
  1174 			KAknsIIDQsnFrListPressed, KAknsIIDQsnFrListCenterPressed);
       
  1175 	}
       
  1176 
       
  1177  CCoeControl *CCCAppCommLauncherCustomListBoxData::Control() const
       
  1178 	{
       
  1179 	return iExtension->iControl;
       
  1180 	}
       
  1181 
       
  1182  void CCCAppCommLauncherCustomListBoxData::SetSeparatorLinePosition(
       
  1183 		TAknSeparatorLinePosition aPosition)
       
  1184 	{
       
  1185 	if (iExtension)
       
  1186 		iExtension->iSeparatorLinePosition = aPosition;
       
  1187 	}
       
  1188  TAknSeparatorLinePosition CCCAppCommLauncherCustomListBoxData::SeparatorLinePosition() const
       
  1189 	{
       
  1190 	if (iExtension)
       
  1191 		return iExtension->iSeparatorLinePosition;
       
  1192 	else
       
  1193 		return ENoLine;
       
  1194 	}
       
  1195  CAknLayoutData *CCCAppCommLauncherCustomListBoxData::LayoutData() const
       
  1196 	{
       
  1197 	return NULL;
       
  1198 	}
       
  1199 
       
  1200  TBool CCCAppCommLauncherCustomListBoxData::LayoutInit() const
       
  1201 	{
       
  1202 	return EFalse;
       
  1203 	}
       
  1204  void CCCAppCommLauncherCustomListBoxData::SetLayoutInit(TBool /*aValue*/)
       
  1205 	{
       
  1206 	}
       
  1207 
       
  1208 CCCAppCommLauncherCustomListBoxDataExtension *CCCAppCommLauncherCustomListBoxData::Extension()
       
  1209 	{
       
  1210 	return iExtension;
       
  1211 	}
       
  1212 CCCAppCommLauncherCustomListBoxDataExtension *CCCAppCommLauncherCustomListBoxData::Extension() const
       
  1213 	{
       
  1214 	return iExtension;
       
  1215 	}
       
  1216 
       
  1217  void CCCAppCommLauncherCustomListBoxData::SetControl(
       
  1218 		CCoeControl *aControl)
       
  1219 	{
       
  1220 	iExtension->SetControl(aControl);
       
  1221 	}
       
  1222 
       
  1223  MAknsControlContext* CCCAppCommLauncherCustomListBoxData::SkinBackgroundContext() const
       
  1224 	{
       
  1225 	if (iExtension->iSkinEnabled)
       
  1226 		{
       
  1227 		if (iExtension->iPopupFrame)
       
  1228 			{
       
  1229 			return iExtension->iPopupFrame;
       
  1230 			}
       
  1231 		else
       
  1232 			{
       
  1233 			return iExtension->iSkinControlContext;
       
  1234 			}
       
  1235 		}
       
  1236 	else
       
  1237 		{
       
  1238 		return NULL;
       
  1239 		}
       
  1240 	}
       
  1241 
       
  1242  void CCCAppCommLauncherCustomListBoxData::SetSkinEnabledL(
       
  1243 		TBool aEnabled)
       
  1244 	{
       
  1245 	CListBoxData::SetSkinEnabledL(aEnabled);
       
  1246 	iExtension->iSkinEnabled = aEnabled;
       
  1247 	}
       
  1248 
       
  1249  TBool CCCAppCommLauncherCustomListBoxData::SkinEnabled() const
       
  1250 	{
       
  1251 	return iExtension->iSkinEnabled;
       
  1252 	}
       
  1253 
       
  1254  void CCCAppCommLauncherCustomListBoxData::SetSkinStyle(
       
  1255 		const TAknsItemID *id, const TRect &aTileRect)
       
  1256 	{
       
  1257 
       
  1258 	if (iExtension->iSkinControlContext)
       
  1259 		{
       
  1260 		iExtension->iSkinControlContext->SetTiledBitmap(*id);
       
  1261 		iExtension->iSkinControlContext->SetTiledRect(aTileRect);
       
  1262 		}
       
  1263 	}
       
  1264  void CCCAppCommLauncherCustomListBoxData::SetSkinParentPos(
       
  1265 		const TPoint &aPos)
       
  1266 	{
       
  1267 	if (iExtension->iSkinControlContext)
       
  1268 		{
       
  1269 		iExtension->iSkinControlContext->SetParentPos(aPos);
       
  1270 		}
       
  1271 	}
       
  1272  void CCCAppCommLauncherCustomListBoxData::SetBackgroundSkinStyle(
       
  1273 		const TAknsItemID *aId, const TRect &aRect)
       
  1274 	{
       
  1275 	if (iExtension->iSkinControlContext)
       
  1276 		{
       
  1277 		iExtension->iSkinControlContext->SetBitmap(*aId);
       
  1278 		iExtension->iSkinControlContext->SetRect(aRect);
       
  1279 		}
       
  1280 	}
       
  1281  void CCCAppCommLauncherCustomListBoxData::SetListEndSkinStyle(
       
  1282 		const TAknsItemID *aListEndId, const TRect &aRect)
       
  1283 	{
       
  1284 	if (iExtension->iSkinControlContext)
       
  1285 		{
       
  1286 		iExtension->iSkinControlContext->SetBottomBitmap(*aListEndId);
       
  1287 		iExtension->iSkinControlContext->SetBottomRect(aRect);
       
  1288 		}
       
  1289 	}
       
  1290 
       
  1291  void CCCAppCommLauncherCustomListBoxData::SetSkinHighlightFrame(
       
  1292 		const TAknsItemID *aFrameId, const TAknsItemID *aFrameCenterId)
       
  1293 	{
       
  1294 	iExtension->iSkinHighlightFrameId = aFrameId;
       
  1295 	iExtension->iSkinHighlightFrameCenterId = aFrameCenterId;
       
  1296 	}
       
  1297 
       
  1298  void CCCAppCommLauncherCustomListBoxData::SetSkinPopupFrame(
       
  1299 		const TAknsItemID *aFrameId, const TAknsItemID *aFrameCenterId)
       
  1300 	{
       
  1301 	if (iExtension && iExtension->iPopupFrame)
       
  1302 		{
       
  1303 		iExtension->iPopupFrame->SetFrame(*aFrameId);
       
  1304 		iExtension->iPopupFrame->SetCenter(*aFrameCenterId);
       
  1305 		}
       
  1306 	else
       
  1307 		{
       
  1308 		TRAPD(err, iExtension->iPopupFrame = CAknsFrameBackgroundControlContext::NewL(
       
  1309 						KAknsIIDNone,
       
  1310 						TRect(0,0,1,1), // these must be set by using SetSkinPopupFramePosition
       
  1311 						TRect(0,0,1,1),
       
  1312 						EFalse ) );
       
  1313 		if (!err)
       
  1314 			{
       
  1315 			iExtension->iPopupFrame->SetFrame(*aFrameId);
       
  1316 			iExtension->iPopupFrame->SetCenter(*aFrameCenterId);
       
  1317 			}
       
  1318 		}
       
  1319 	}
       
  1320 
       
  1321  void CCCAppCommLauncherCustomListBoxData::SetSkinPopupFramePosition(
       
  1322 		const TRect &aOuterRect, const TRect &aInnerRect)
       
  1323 	{
       
  1324 	if (iExtension && iExtension->iPopupFrame)
       
  1325 		iExtension->iPopupFrame->SetFrameRects(aOuterRect, aInnerRect);
       
  1326 	}
       
  1327 
       
  1328  void CCCAppCommLauncherCustomListBoxData::UseLogicalToVisualConversion(
       
  1329 		TBool aUseConversion)
       
  1330 	{
       
  1331 	if (iExtension)
       
  1332 		iExtension->iUseLogicalToVisualConversion = aUseConversion;
       
  1333 	}
       
  1334 
       
  1335 void CCCAppCommLauncherCustomListBoxData::CreatePictographInterfaceL()
       
  1336 	{
       
  1337 	iExtension->CreatePictographInterfaceL();
       
  1338 	}
       
  1339 
       
  1340 void CCCAppCommLauncherCustomListBoxData::CreateMarqueeControlL()
       
  1341 	{
       
  1342 	TCallBack callBack(
       
  1343 			CCCAppCommLauncherCustomListBoxDataExtension::RedrawEvent,
       
  1344 			iExtension->iControl);
       
  1345 	//iExtension->iMarquee = CAknMarqueeControl::NewL();
       
  1346 	iExtension->CreateMarqueeControlL();
       
  1347 	iExtension->iMarquee->SetRedrawCallBack(callBack);
       
  1348 	iExtension->i2ndLineMarquee->SetRedrawCallBack(callBack);
       
  1349 	}
       
  1350 
       
  1351 const TInt KSubCellListBoxGranularity = 4;
       
  1352 const TInt KNoActualSubCellFont = -1;
       
  1353 
       
  1354 
       
  1355 CCCAppCommLauncherCustomListBoxData* CCCAppCommLauncherCustomListBoxData::NewL()
       
  1356 	{
       
  1357 	CCCAppCommLauncherCustomListBoxData* self =
       
  1358 			new (ELeave) CCCAppCommLauncherCustomListBoxData;
       
  1359 	self->ConstructLD(KAknsIIDQsnAnimList);
       
  1360 	return (self);
       
  1361 	}
       
  1362 
       
  1363  CCCAppCommLauncherCustomListBoxData::~CCCAppCommLauncherCustomListBoxData()
       
  1364 	{
       
  1365 	delete iExtension;
       
  1366 	delete iSubCellArray;
       
  1367 	if (iIconArray)
       
  1368 		{
       
  1369 		iIconArray->ResetAndDestroy();
       
  1370 		delete iIconArray;
       
  1371 		}
       
  1372 	}
       
  1373 
       
  1374  TSize CCCAppCommLauncherCustomListBoxData::SubCellSize(
       
  1375 		TInt aSubCellIndex) const
       
  1376 	{
       
  1377 	TInt index = 0;
       
  1378 	if (FindSubCellIndex(index, aSubCellIndex) == KErrNotFound)
       
  1379 		return TSize(0, 0);
       
  1380 	return (iSubCellArray->At(index).iSize);
       
  1381 	}
       
  1382 
       
  1383  void CCCAppCommLauncherCustomListBoxData::SetSubCellSizeL(
       
  1384 		TInt aSubCellIndex, TSize aSize)
       
  1385 	{
       
  1386 	TInt index = 0;
       
  1387 	FindSubCellIndexOrAddL(index, aSubCellIndex);
       
  1388 	At(index).iSize = aSize;
       
  1389 	// if someone uses this api directly, revert to old draw
       
  1390 	// new api will turn this to ETrue again.
       
  1391 	UseScalableLayoutData(EFalse);
       
  1392 	}
       
  1393 
       
  1394  TInt CCCAppCommLauncherCustomListBoxData::SubCellBaselinePos(
       
  1395 		TInt aSubCellIndex) const
       
  1396 	{
       
  1397 	TInt index = 0;
       
  1398 	if (FindSubCellIndex(index, aSubCellIndex) == KErrNotFound)
       
  1399 		return TInt(0);
       
  1400 	return (iSubCellArray->At(index).iBaseline);
       
  1401 	}
       
  1402 
       
  1403  void CCCAppCommLauncherCustomListBoxData::SetSubCellBaselinePosL(
       
  1404 		TInt aSubCellIndex, TInt aPos)
       
  1405 	{
       
  1406 	TInt index = 0;
       
  1407 	FindSubCellIndexOrAddL(index, aSubCellIndex);
       
  1408 	At(index).iBaseline = aPos;
       
  1409 	}
       
  1410 
       
  1411  TInt CCCAppCommLauncherCustomListBoxData::SubCellTextClipGap(
       
  1412 		TInt aSubCellIndex) const
       
  1413 	{
       
  1414 	TInt index;
       
  1415 	if (FindSubCellIndex(index, aSubCellIndex) == KErrNotFound)
       
  1416 		return TInt(0);
       
  1417 	return (iSubCellArray->At(index).iTextClipGap);
       
  1418 	}
       
  1419 
       
  1420  void CCCAppCommLauncherCustomListBoxData::SetSubCellTextClipGapL(
       
  1421 		TInt aSubCellIndex, TInt aGap)
       
  1422 	{
       
  1423 	TInt index;
       
  1424 	FindSubCellIndexOrAddL(index, aSubCellIndex);
       
  1425 	At(index).iTextClipGap = aGap;
       
  1426 	}
       
  1427 
       
  1428 TSize CCCAppCommLauncherCustomListBoxData::SubCellRealSize(TInt aSubCellIndex) const
       
  1429 	{
       
  1430 	TInt index = 0;
       
  1431 	if (FindSubCellIndex(index, aSubCellIndex) == KErrNotFound)
       
  1432 		return TSize(0, 0);
       
  1433 	return (iSubCellArray->At(index).iRealSize);
       
  1434 	}
       
  1435 
       
  1436 void CCCAppCommLauncherCustomListBoxData::SetSubCellRealSize(
       
  1437 		TInt aSubCellIndex, TSize aRealSize) const
       
  1438 	{
       
  1439 	TInt index = 0;
       
  1440 	if (!(FindSubCellIndex(index, aSubCellIndex) == KErrNotFound))
       
  1441 		{
       
  1442 		MUTABLE_CAST(TSize&,At(index).iRealSize) = aRealSize;
       
  1443 		}
       
  1444 	}
       
  1445 
       
  1446 TSize CCCAppCommLauncherCustomListBoxData::SubCellRealTextSize(
       
  1447 		TInt aSubCellIndex) const
       
  1448 	{
       
  1449 	TInt index = 0;
       
  1450 	if (FindSubCellIndex(index, aSubCellIndex) == KErrNotFound)
       
  1451 		return TSize(0, 0);
       
  1452 	return (iSubCellArray->At(index).iRealTextSize);
       
  1453 	}
       
  1454 
       
  1455 void CCCAppCommLauncherCustomListBoxData::SetSubCellRealTextSize(
       
  1456 		TInt aSubCellIndex, TSize aRealTextSize) const
       
  1457 	{
       
  1458 	TInt index = 0;
       
  1459 	if (!(FindSubCellIndex(index, aSubCellIndex) == KErrNotFound))
       
  1460 		{
       
  1461 		MUTABLE_CAST(TSize&,At(index).iRealTextSize) = aRealTextSize;
       
  1462 		}
       
  1463 	}
       
  1464 
       
  1465  TPoint CCCAppCommLauncherCustomListBoxData::SubCellPosition(
       
  1466 		TInt aSubCellIndex) const
       
  1467 	{
       
  1468 	TInt index = 0;
       
  1469 	if (FindSubCellIndex(index, aSubCellIndex) == KErrNotFound)
       
  1470 		return TPoint(0, 0);
       
  1471 	return (iSubCellArray->At(index).iPosition);
       
  1472 	}
       
  1473 
       
  1474  void CCCAppCommLauncherCustomListBoxData::SetSubCellPositionL(
       
  1475 		TInt aSubCellIndex, TPoint aPosition)
       
  1476 	{
       
  1477 	TInt index = 0;
       
  1478 	FindSubCellIndexOrAddL(index, aSubCellIndex);
       
  1479 	At(index).iPosition = aPosition;
       
  1480 	// if someone uses this api directly, revert to old draw
       
  1481 	// new api will turn this to ETrue again.
       
  1482 	UseScalableLayoutData(EFalse);
       
  1483 	}
       
  1484 
       
  1485  TMargins CCCAppCommLauncherCustomListBoxData::SubCellMargins(
       
  1486 		TInt aSubCellIndex) const
       
  1487 	{
       
  1488 	TInt index = 0;
       
  1489 	if (FindSubCellIndex(index, aSubCellIndex) == KErrNotFound)
       
  1490 		{
       
  1491 		TMargins tm =
       
  1492 			{
       
  1493 			0, 0, 0, 0
       
  1494 			};
       
  1495 		return tm;
       
  1496 		}
       
  1497 	return (iSubCellArray->At(index).iMargin);
       
  1498 	}
       
  1499 
       
  1500  void CCCAppCommLauncherCustomListBoxData::SetSubCellMarginsL(
       
  1501 		TInt aSubCellIndex, TMargins aMargins)
       
  1502 	{
       
  1503 	TInt index = 0;
       
  1504 	FindSubCellIndexOrAddL(index, aSubCellIndex);
       
  1505 	At(index).iMargin = aMargins;
       
  1506 	}
       
  1507 
       
  1508  const CFont*
       
  1509 CCCAppCommLauncherCustomListBoxData::SubCellFont(TInt aSubCellIndex) const
       
  1510 	{
       
  1511 	TInt index = 0;
       
  1512 	if (FindSubCellIndex(index, aSubCellIndex) == KErrNotFound)
       
  1513 		return 0;
       
  1514 	return (iSubCellArray->At(index).iBaseFont);
       
  1515 	}
       
  1516 
       
  1517  void CCCAppCommLauncherCustomListBoxData::SetSubCellFontL(
       
  1518 		TInt aSubCellIndex, const CFont* aFont)
       
  1519 	{
       
  1520 #if 0
       
  1521 	TInt subcells=iSubCellArray->Count();
       
  1522 #endif
       
  1523 	TInt index = 0;
       
  1524 	FindSubCellIndexOrAddL(index, aSubCellIndex);
       
  1525 	if (At(index).iBaseFont != aFont)
       
  1526 		{
       
  1527 #if 0
       
  1528 		TInt actualFontIndex=0;
       
  1529 		TRAPD(err, actualFontIndex=AddActualFontL(aFont));
       
  1530 		if (err)
       
  1531 			{
       
  1532 			if (subcells!=iSubCellArray->Count())
       
  1533 				{
       
  1534 				iSubCellArray->Delete(index);
       
  1535 				}
       
  1536 			User::Leave(err);
       
  1537 			}
       
  1538 		At(index).iActualFontIndex=actualFontIndex;
       
  1539 #endif
       
  1540 		At(index).iBaseFont = aFont;
       
  1541 		}
       
  1542 	}
       
  1543 
       
  1544  CGraphicsContext::TTextAlign CCCAppCommLauncherCustomListBoxData::SubCellAlignment(
       
  1545 		TInt aSubCellIndex) const
       
  1546 	{
       
  1547 	TInt index = 0;
       
  1548 	if (FindSubCellIndex(index, aSubCellIndex) == KErrNotFound)
       
  1549 		return CGraphicsContext::ELeft;
       
  1550 	return (iSubCellArray->At(index).iAlign);
       
  1551 	}
       
  1552 
       
  1553  void CCCAppCommLauncherCustomListBoxData::SetSubCellAlignmentL(
       
  1554 		TInt aSubCellIndex, CGraphicsContext::TTextAlign aAlign)
       
  1555 	{
       
  1556 	TInt index = 0;
       
  1557 	FindSubCellIndexOrAddL(index, aSubCellIndex);
       
  1558 	At(index).iAlign = aAlign;
       
  1559 
       
  1560 	iExtension->SetSubCellLayoutAlignmentL(aSubCellIndex);
       
  1561 	}
       
  1562 
       
  1563  const CCCAppCommLauncherCustomListBoxData::TColors &
       
  1564 CCCAppCommLauncherCustomListBoxData::SubCellColors(TInt aSubCellIndex) const
       
  1565 	{
       
  1566 	TInt index = 0;
       
  1567 	if (FindSubCellIndex(index, aSubCellIndex) == KErrNotFound)
       
  1568 		return defaultcolors;
       
  1569 	return (iSubCellArray->At(index).iColors);
       
  1570 	}
       
  1571 
       
  1572  void CCCAppCommLauncherCustomListBoxData::SetSubCellColorsL(
       
  1573 		TInt aSubCellIndex, const TColors & aColors)
       
  1574 	{
       
  1575 	TInt index = 0;
       
  1576 	FindSubCellIndexOrAddL(index, aSubCellIndex);
       
  1577 	At(index).iColors = aColors;
       
  1578 	At(index).iUseSubCellColors = ETrue;
       
  1579 	}
       
  1580 
       
  1581  TBool CCCAppCommLauncherCustomListBoxData::UseSubCellColors(
       
  1582 		TInt aSubCell) const
       
  1583 	{
       
  1584 	TInt index = 0;
       
  1585 	if (FindSubCellIndex(index, aSubCell) == KErrNotFound)
       
  1586 		return EFalse;
       
  1587 	return At(index).iUseSubCellColors;
       
  1588 	}
       
  1589 
       
  1590  CGraphicsContext::TPenStyle CCCAppCommLauncherCustomListBoxData::SubCellRightSeparatorStyle(
       
  1591 		TInt aSubCellIndex) const
       
  1592 	{
       
  1593 	TInt index = 0;
       
  1594 	if (FindSubCellIndex(index, aSubCellIndex) == KErrNotFound)
       
  1595 		return CGraphicsContext::ENullPen;
       
  1596 	return (iSubCellArray->At(index).iRightSeparatorStyle);
       
  1597 	}
       
  1598 
       
  1599  void CCCAppCommLauncherCustomListBoxData::SetSubCellRightSeparatorStyleL(
       
  1600 		TInt aSubCellIndex, CGraphicsContext::TPenStyle aStyle)
       
  1601 	{
       
  1602 	TInt index = 0;
       
  1603 	FindSubCellIndexOrAddL(index, aSubCellIndex);
       
  1604 	At(index).iRightSeparatorStyle = aStyle;
       
  1605 	}
       
  1606 
       
  1607  TBool CCCAppCommLauncherCustomListBoxData::SubCellIsGraphics(
       
  1608 		TInt aSubCellIndex) const
       
  1609 	{
       
  1610 	TInt index = 0;
       
  1611 	if (FindSubCellIndex(index, aSubCellIndex) == KErrNotFound)
       
  1612 		return EFalse;
       
  1613 	return (iSubCellArray->At(index).iGraphics);
       
  1614 	}
       
  1615 
       
  1616  void CCCAppCommLauncherCustomListBoxData::SetGraphicsSubCellL(
       
  1617 		TInt aSubCellIndex, TBool aIsGraphics)
       
  1618 	{
       
  1619 	TInt index = 0;
       
  1620 	FindSubCellIndexOrAddL(index, aSubCellIndex);
       
  1621 	At(index).iGraphics = aIsGraphics;
       
  1622 	// if someone uses this api directly, revert to old draw
       
  1623 	// new api will turn this to ETrue again.
       
  1624 	UseScalableLayoutData(EFalse);
       
  1625 	}
       
  1626 
       
  1627  TBool CCCAppCommLauncherCustomListBoxData::SubCellIsNumberCell(
       
  1628 		TInt aSubCellIndex) const
       
  1629 	{
       
  1630 	TInt index = 0;
       
  1631 	if (FindSubCellIndex(index, aSubCellIndex) == KErrNotFound)
       
  1632 		return EFalse;
       
  1633 	return (iSubCellArray->At(index).iNumberCell);
       
  1634 	}
       
  1635 
       
  1636  void CCCAppCommLauncherCustomListBoxData::SetNumberCellL(
       
  1637 		TInt aSubCellIndex, TBool aIsNumberCell)
       
  1638 	{
       
  1639 	TInt index = 0;
       
  1640 	FindSubCellIndexOrAddL(index, aSubCellIndex);
       
  1641 	At(index).iNumberCell = aIsNumberCell;
       
  1642 	}
       
  1643 
       
  1644  TBool CCCAppCommLauncherCustomListBoxData::SubCellIsTransparent(
       
  1645 		TInt aSubCellIndex) const
       
  1646 	{
       
  1647 	TInt index = 0;
       
  1648 	if (FindSubCellIndex(index, aSubCellIndex) == KErrNotFound)
       
  1649 		return EFalse;
       
  1650 	return (iSubCellArray->At(index).iTransparent);
       
  1651 	}
       
  1652 
       
  1653  void CCCAppCommLauncherCustomListBoxData::SetTransparentSubCellL(
       
  1654 		TInt aSubCellIndex, TBool aIsTransparent)
       
  1655 	{
       
  1656 	TInt index = 0;
       
  1657 	FindSubCellIndexOrAddL(index, aSubCellIndex);
       
  1658 	At(index).iTransparent = aIsTransparent;
       
  1659 	}
       
  1660 
       
  1661  TBool CCCAppCommLauncherCustomListBoxData::SubCellIsNotAlwaysDrawn(
       
  1662 		TInt aSubCellIndex) const
       
  1663 	{
       
  1664 	TInt index = 0;
       
  1665 	if (FindSubCellIndex(index, aSubCellIndex) == KErrNotFound)
       
  1666 		return EFalse;
       
  1667 	return (iSubCellArray->At(index).iNotAlwaysDrawn);
       
  1668 	}
       
  1669 
       
  1670  void CCCAppCommLauncherCustomListBoxData::SetNotAlwaysDrawnSubCellL(
       
  1671 		TInt aSubCellIndex, TBool aIsNotAlwaysDrawn)
       
  1672 	{
       
  1673 	TInt index = 0;
       
  1674 	FindSubCellIndexOrAddL(index, aSubCellIndex);
       
  1675 	At(index).iNotAlwaysDrawn = aIsNotAlwaysDrawn;
       
  1676 	}
       
  1677 
       
  1678  CArrayPtr<CGulIcon>*
       
  1679 CCCAppCommLauncherCustomListBoxData::IconArray() const
       
  1680 	{
       
  1681 	return iIconArray;
       
  1682 	}
       
  1683 
       
  1684  void CCCAppCommLauncherCustomListBoxData::SetIconArrayL(CArrayPtr<
       
  1685 		CGulIcon>* aArray)
       
  1686 	{
       
  1687 	iIconArray = aArray;
       
  1688 	}
       
  1689 
       
  1690  void CCCAppCommLauncherCustomListBoxData::SetIconArray(CArrayPtr<
       
  1691 		CGulIcon>* aArray)
       
  1692 	{
       
  1693 	iIconArray = aArray;
       
  1694 	}
       
  1695 
       
  1696  TBool CCCAppCommLauncherCustomListBoxData::RespectFocus() const
       
  1697 	{
       
  1698 	if (iExtension)
       
  1699 		return iExtension->iRespectFocus;
       
  1700 	return EFalse;
       
  1701 	}
       
  1702 
       
  1703  void CCCAppCommLauncherCustomListBoxData::SetRespectFocus(TBool aBool)
       
  1704 	{
       
  1705 	if (iExtension)
       
  1706 		iExtension->iRespectFocus = aBool;
       
  1707 	}
       
  1708 
       
  1709  CFont*
       
  1710 CCCAppCommLauncherCustomListBoxData::Font(
       
  1711 		const TListItemProperties& /*aItemProperties*/, TInt aSubCellIndex) const
       
  1712 	{
       
  1713 	return const_cast<CFont*> (SubCellFont(aSubCellIndex));
       
  1714 #if 0
       
  1715 	TInt index = 0;
       
  1716 	if (FindSubCellIndex(index,aSubCellIndex)!=0/*KErrNotFound*/)
       
  1717 	return(NULL);
       
  1718 	TInt actualFontIndex=iSubCellArray->At(index).iActualFontIndex;
       
  1719 	if (actualFontIndex==KNoActualSubCellFont)
       
  1720 	return(NULL);
       
  1721 	if ((aItemProperties.IsBold()) && (aItemProperties.IsItalics()))
       
  1722 		{
       
  1723 		return iBoldItalicFont.iFonts->At(actualFontIndex);
       
  1724 		}
       
  1725 	else if (aItemProperties.IsBold())
       
  1726 		{
       
  1727 		return iBoldFont.iFonts->At(actualFontIndex);
       
  1728 		}
       
  1729 	else if (aItemProperties.IsItalics())
       
  1730 		{
       
  1731 		return iItalicFont.iFonts->At(actualFontIndex);
       
  1732 		}
       
  1733 	else return iNormalFont.iFonts->At(actualFontIndex);
       
  1734 #endif
       
  1735 	}
       
  1736 
       
  1737  void CCCAppCommLauncherCustomListBoxData::Draw(
       
  1738 		TListItemProperties aProperties, CWindowGc& aGc, const TDesC* aText,
       
  1739 		const TRect& aRect, TBool aHighlight, const TColors& aColors) const
       
  1740 	{
       
  1741 	DrawDefaultHighlight(aGc, aRect, aHighlight);
       
  1742 
       
  1743 	// Draw the actual items.
       
  1744 	DrawFormatted(aProperties, aGc, aText, aRect, aHighlight, aColors);
       
  1745 	}
       
  1746 
       
  1747  void CCCAppCommLauncherCustomListBoxData::DrawFormatted(
       
  1748 		TListItemProperties aProperties, CWindowGc& aGc, const TDesC* aText,
       
  1749 		const TRect& aItemRect, TBool aHighlight, const TColors& aColors) const
       
  1750 	{
       
  1751 	if (aHighlight)
       
  1752 		{
       
  1753 		iExtension->iClippedSubcells = 0;
       
  1754 		}
       
  1755 
       
  1756 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  1757 	MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal(&aGc);
       
  1758 	TBool effectsDisabled = ETrue;
       
  1759 
       
  1760 	if (transApi)
       
  1761 		{
       
  1762 		transApi->StartDrawing(MAknListBoxTfxInternal::EListItem);
       
  1763 		effectsDisabled = transApi->EffectsDisabled();
       
  1764 
       
  1765 		if (effectsDisabled)
       
  1766 			{
       
  1767 			CListBoxView* view =
       
  1768 					static_cast<CEikListBox*> (iExtension->iControl)->View();
       
  1769 			aGc.SetClippingRect(view->ViewRect());
       
  1770 			}
       
  1771 		}
       
  1772 #else
       
  1773 	CListBoxView* view = static_cast<CEikListBox*>( iExtension->iControl )->View();
       
  1774 	aGc.SetClippingRect( view->ViewRect() );
       
  1775 #endif //RD_UI_TRANSITION_EFFECTS_LIST
       
  1776 	if (UsesScalableLayoutData())
       
  1777 		{
       
  1778 		/* this is a AvKon list or list is created using methods in aknlists.cpp
       
  1779 		 * which is _the_ way to set up a list
       
  1780 		 */
       
  1781 		DrawFormattedSimple(aProperties, aGc, aText, aItemRect, aHighlight,
       
  1782 				aColors);
       
  1783 		}
       
  1784 	else
       
  1785 		{
       
  1786 		/* someone used directly the (unfortunately) exported methods
       
  1787 		 * from this file. These should be fixed in such way, that
       
  1788 		 * DrawFormattedOld could be removed.
       
  1789 		 */
       
  1790 		DrawFormattedOld(aProperties, aGc, aText, aItemRect, aHighlight,
       
  1791 				aColors);
       
  1792 		}
       
  1793 
       
  1794 #ifdef RD_UI_TRANSITION_EFFECTS_LIST  
       
  1795 	if (transApi)
       
  1796 		{
       
  1797 		if (effectsDisabled)
       
  1798 			{
       
  1799 			aGc.CancelClippingRect();
       
  1800 			}
       
  1801 
       
  1802 		transApi->StopDrawing();
       
  1803 		}
       
  1804 #else
       
  1805 	aGc.CancelClippingRect();
       
  1806 #endif //RD_UI_TRANSITION_EFFECTS_LIST 
       
  1807 	}
       
  1808 
       
  1809 void CCCAppCommLauncherCustomListBoxData::BitBltColored(CWindowGc& aGc,
       
  1810 		TBool aHighlight, const CGulIcon* aIcon, TInt aSubcell,
       
  1811 		TBool aColorIcon, const TRect& aGraphicRect) const
       
  1812 	{
       
  1813 	// se also eikclbd.cpp ( sigh ).
       
  1814 	CFbsBitmap* bitmap(aIcon->Bitmap());
       
  1815 	CFbsBitmap* mask(aIcon->Mask());
       
  1816 
       
  1817 	// possibly colorskinnable icon. Check must be after SetSize()
       
  1818 	TBool bw(bitmap->DisplayMode() == EGray2);
       
  1819 
       
  1820 	// center graphics
       
  1821 	TSize size = bitmap->SizeInPixels();
       
  1822 	TInt yDiff = (aGraphicRect.Height() - size.iHeight) / 2;
       
  1823 	TInt xDiff = (aGraphicRect.Width() - size.iWidth) / 2;
       
  1824 	TPoint posInBitmap(0, 0);
       
  1825 
       
  1826 	if (xDiff < 0) // icon's width bigger than subcell's width
       
  1827 		{ // possible, if icon is not a aknicon
       
  1828 		posInBitmap.iX = -xDiff;
       
  1829 		xDiff = 0;
       
  1830 		}
       
  1831 
       
  1832 	if (yDiff < 0) // icon's height bigger than subcell's height
       
  1833 		{
       
  1834 		posInBitmap.iY = -yDiff;
       
  1835 		yDiff = 0;
       
  1836 		}
       
  1837 
       
  1838 	TPoint bmpPos(aGraphicRect.iTl + TPoint(xDiff, yDiff));
       
  1839 	TRect sourcerect(posInBitmap, aGraphicRect.Size());
       
  1840 
       
  1841 	if (mask)
       
  1842 		{
       
  1843 		TInt i(0x01);
       
  1844 		i = i << aSubcell;
       
  1845 		if (((i & iExtension->iConditionalCells) && bw) || aColorIcon)
       
  1846 			{
       
  1847 			aGc.BitBltMasked(bmpPos, aHighlight ? iExtension->iHiliBmp
       
  1848 					: iExtension->iColorBmp, TRect(posInBitmap, size), mask,
       
  1849 					ETrue);
       
  1850 			}
       
  1851 		else
       
  1852 			{
       
  1853 			aGc.BitBltMasked(bmpPos, bitmap, sourcerect, mask, ETrue);
       
  1854 			}
       
  1855 		}
       
  1856 	else
       
  1857 		{
       
  1858 		aGc.BitBlt(bmpPos, bitmap, sourcerect);
       
  1859 		}
       
  1860 	}
       
  1861 
       
  1862 void CCCAppCommLauncherCustomListBoxData::DrawFormattedSimple(
       
  1863 		TListItemProperties& aProperties, CWindowGc& aGc, const TDesC* aText,
       
  1864 		const TRect& aItemRect, TBool aHighlight, const TColors& aColors) const
       
  1865 	{
       
  1866 	TRect textRect(aItemRect);
       
  1867 	const TColors *subcellColors = &aColors;
       
  1868 
       
  1869 	TInt lastSubCell = Min(LastSubCell(), KMaxSubCellIndex);
       
  1870 
       
  1871 	TInt subcell = 0;
       
  1872 	TPtrC text;
       
  1873 	TPtrC tempText;
       
  1874 	TRect textShadowRect; // For transparent list
       
  1875 	TRgb textShadowColour = AKN_LAF_COLOR_STATIC(215); // Black shadow for item text.
       
  1876 	MAknsControlContext *cc = AknsDrawUtils::ControlContext(Control());
       
  1877 	TBool skinEnabled = AknsUtils::AvkonSkinEnabled();
       
  1878 
       
  1879 	if (!cc)
       
  1880 		{
       
  1881 		cc = SkinBackgroundContext();
       
  1882 		}
       
  1883 
       
  1884 	TAknTextLineLayout textLines[KMaxSubCellIndex];
       
  1885 	TBool rectClipped[KMaxSubCellIndex];
       
  1886 
       
  1887 	Mem::FillZ(&rectClipped[0], KMaxSubCellIndex * sizeof(TBool));
       
  1888 
       
  1889 	if (iExtension->iSubCellsMightIntersect)
       
  1890 		{
       
  1891 		CheckIfSubCellsIntersect(&textLines[0], &rectClipped[0], *aText,
       
  1892 				aItemRect);
       
  1893 		}
       
  1894 
       
  1895 	TInt SCindex = 0;
       
  1896 
       
  1897 	// This loop does the drawing.    
       
  1898 	aGc.SetPenStyle(CGraphicsContext::ENullPen);
       
  1899 	subcell = 0;
       
  1900 	FOREVER{
       
  1901 	if (subcell>lastSubCell)
       
  1902 		{
       
  1903 		break;
       
  1904 		}
       
  1905 
       
  1906 	TextUtils::ColumnText(text,subcell, aText);
       
  1907 	if (text == KNullDesC)
       
  1908 		{
       
  1909 		// empty subcell, continue to draw next subcell
       
  1910 		++ subcell;
       
  1911 		continue;
       
  1912 		}
       
  1913 	if (!iExtension) break;
       
  1914 	if (iExtension->FindSLSubCellIndex(SCindex,subcell)!=0) break;
       
  1915 
       
  1916 	if (UseSubCellColors(subcell))
       
  1917 		{
       
  1918 		subcellColors = &SubCellColors(subcell);
       
  1919 		}
       
  1920 	else
       
  1921 		{
       
  1922 		subcellColors = &aColors;
       
  1923 		}
       
  1924 
       
  1925 	TRgb color;
       
  1926 
       
  1927 	if (aHighlight)
       
  1928 		{
       
  1929 		color = subcellColors->iHighlightedText;
       
  1930 		aGc.SetBrushColor(subcellColors->iHighlightedBack);
       
  1931 		if ( skinEnabled )
       
  1932 			{
       
  1933 			if ( iExtension->iHighlightedTextColor != NULL )
       
  1934 				{
       
  1935 				color = iExtension->iHighlightedTextColor;
       
  1936 				}
       
  1937 			}
       
  1938 		}
       
  1939 	else
       
  1940 		{
       
  1941 		color = subcellColors->iText;
       
  1942 		aGc.SetBrushColor(subcellColors->iBack);
       
  1943 		if ( skinEnabled )
       
  1944 			{
       
  1945 			if ( iExtension->iTextColor != NULL )
       
  1946 				{
       
  1947 				color = iExtension->iTextColor;
       
  1948 				}
       
  1949 			}
       
  1950 		}
       
  1951 
       
  1952 	// graphics or text column
       
  1953 	if (iExtension->AtSL(SCindex).iSubCellType == CCCAppCommLauncherCustomListBoxDataExtension::EAknSLText)
       
  1954 		{
       
  1955 		const CFont* rowAndCellFont=RowAndSubCellFont(iExtension->iCurrentlyDrawnItemIndex,subcell);
       
  1956 		const CFont* cellFont=Font(aProperties, subcell);
       
  1957 		const CFont* tempFont=(cellFont) ? cellFont : NULL;
       
  1958 		const CFont* usedFont=(rowAndCellFont) ? rowAndCellFont : tempFont;
       
  1959 
       
  1960 		TAknTextLineLayout textLineLayout = NULL;
       
  1961 
       
  1962 		if ( rectClipped[subcell] )
       
  1963 			{
       
  1964 			textLineLayout = textLines[subcell];
       
  1965 			}
       
  1966 		else
       
  1967 			{
       
  1968 			// check if there are icons affecting this text layout
       
  1969 			TInt gSC = iExtension->AtSL(SCindex).iConditionValue; // graphical subcell which might affect this text subcell
       
  1970 
       
  1971 			if (gSC> -1)
       
  1972 				{
       
  1973 				TInt tempIndex;
       
  1974 				while (gSC> -1) // when gSC == -1, we have found our graphical subcell
       
  1975 
       
  1976 					{
       
  1977 					if (iExtension->FindSLSubCellIndex(tempIndex,gSC)!=0) break;
       
  1978 					TextUtils::ColumnText(tempText,gSC, aText);
       
  1979 					if (tempText != KNullDesC)
       
  1980 						{
       
  1981 						textLineLayout = iExtension->AtSL(tempIndex).iTextLayout;
       
  1982 						break;
       
  1983 						}
       
  1984 					gSC = iExtension->AtSL(tempIndex).iConditionValue;
       
  1985 					}
       
  1986 				}
       
  1987 
       
  1988 			if (gSC == -1) // no affecting icons -> use default layout
       
  1989 
       
  1990 				{
       
  1991 				textLineLayout = iExtension->AtSL(SCindex).iTextLayout;
       
  1992 				}
       
  1993 			}
       
  1994 
       
  1995 		CGraphicsContext::TTextAlign align=SubCellAlignment(subcell); //gumq
       
  1996 		TBool isLayoutAlignment = iExtension->SubCellLayoutAlignment(subcell); //gumq  
       
  1997 		if( !isLayoutAlignment )
       
  1998 			{
       
  1999 			switch(align)
       
  2000 				{
       
  2001 				case CGraphicsContext::ELeft :
       
  2002 					{
       
  2003 					textLineLayout.iJ = ELayoutAlignLeft;
       
  2004 					}
       
  2005 				break;
       
  2006 				case CGraphicsContext::ECenter:
       
  2007 					{
       
  2008 					textLineLayout.iJ = ELayoutAlignCenter;
       
  2009 					}
       
  2010 				break;
       
  2011 				case CGraphicsContext::ERight:
       
  2012 					{
       
  2013 					textLineLayout.iJ = ELayoutAlignRight;
       
  2014 					}
       
  2015 				break;
       
  2016 				default: break;
       
  2017 				};
       
  2018 			}
       
  2019 
       
  2020 		TAknLayoutText textLayout;
       
  2021 		textLayout.LayoutText(textRect, textLineLayout, usedFont);
       
  2022 
       
  2023 		SetUnderlineStyle( aProperties, aGc, subcell );
       
  2024 
       
  2025 		// * 2 == leave some room for marquee
       
  2026 		const TInt maxlen( KMaxColumnDataLength * 2 );
       
  2027 		TBuf<maxlen> convBuf = text.Left(maxlen);
       
  2028 
       
  2029 		// Note that this potentially modifies the text so its lenght in pixels
       
  2030 		// might increase. Therefore, this should always be done before
       
  2031 		// wrapping/clipping text. In some cases, WordWrapListItem is called
       
  2032 		// before coming here. Is it certain that it is not done for number subcells?
       
  2033 
       
  2034 		// Do number conversion if required.
       
  2035 		if (SubCellIsNumberCell(subcell))
       
  2036 			{
       
  2037 			AknTextUtils::LanguageSpecificNumberConversion(convBuf);
       
  2038 			}
       
  2039 
       
  2040 		// Check whether logical to visual conversion should be done here or not.
       
  2041 		TBool bidiConv =
       
  2042 		iExtension->iUseLogicalToVisualConversion &&
       
  2043 		subcell != iExtension->iFirstWordWrappedSubcellIndex &&
       
  2044 		subcell != iExtension->iSecondWordWrappedSubcellIndex;
       
  2045 
       
  2046 		TBool doesNotFit( EFalse );
       
  2047 		if ( aHighlight )
       
  2048 			{
       
  2049 			doesNotFit = usedFont->TextWidthInPixels( convBuf )> textLayout.TextRect().Width();
       
  2050 
       
  2051 			if ( doesNotFit )
       
  2052 				{
       
  2053 				iExtension->iClippedSubcells |= ( 1 << subcell );
       
  2054 				}
       
  2055 			else
       
  2056 				{
       
  2057 				iExtension->iClippedSubcells &= ~( 1 << subcell );
       
  2058 				}
       
  2059 
       
  2060 			if ( iExtension->iUseClippedByWrap ) // override if already clipped
       
  2061 
       
  2062 				{
       
  2063 				iExtension->iClippedSubcells = iExtension->iClippedByWrap;
       
  2064 				}
       
  2065 			}
       
  2066 
       
  2067 		// marquee
       
  2068 		CAknMarqueeControl* marquee =
       
  2069 		subcell == 1 || subcell == 3 ? iExtension->iMarquee :
       
  2070 		iExtension->i2ndLineMarquee;
       
  2071 		TBool marqueeDisabled =
       
  2072 		static_cast<CEikListBox*>(
       
  2073 				Control() )->View()->ItemDrawer()->Flags() & CListItemDrawer::EDisableMarquee;
       
  2074 
       
  2075 		if ( aHighlight && iExtension->IsMarqueeOn() && doesNotFit && !marqueeDisabled )
       
  2076 			{
       
  2077 			iExtension->iMarquee->UseLogicalToVisualConversion( bidiConv );
       
  2078 
       
  2079 			if ( marquee->DrawText( aGc, textRect, textLineLayout, convBuf, usedFont, color ) )
       
  2080 				{
       
  2081 				// all the loops have been executed
       
  2082 				textLayout.DrawText( aGc, convBuf, bidiConv, color );
       
  2083 				}
       
  2084 			}
       
  2085 		else
       
  2086 			{
       
  2087 			if ( marquee && marqueeDisabled )
       
  2088 				{
       
  2089 				marquee->Stop();
       
  2090 				}
       
  2091 
       
  2092 			textLayout.DrawText( aGc, convBuf, bidiConv, color );
       
  2093 			}
       
  2094 
       
  2095 		if ( iExtension->iPictoInterface )
       
  2096 			{
       
  2097 
       
  2098 			TRect pictoRect = textLayout.TextRect();
       
  2099 			pictoRect.Normalize();
       
  2100 			if ( convBuf.Length() && bidiConv )
       
  2101 				{
       
  2102 				TInt maxWidth = pictoRect.Size().iWidth;
       
  2103 				TInt charsCanBeDisplayed = textLayout.Font()->TextCount(
       
  2104 						convBuf, maxWidth );
       
  2105 				if ( charsCanBeDisplayed < convBuf.Length() )
       
  2106 					{
       
  2107 					TInt clipCharWidth = textLayout.Font()->CharWidthInPixels(
       
  2108 							KEllipsis /*aClipChar*/);
       
  2109 					// Check how many characters fit in given space with truncation char. 
       
  2110 					charsCanBeDisplayed = textLayout.Font()->TextCount(
       
  2111 							convBuf, maxWidth - clipCharWidth );
       
  2112 
       
  2113 					// This is "avkon rule": should not insert ellipsis right after a space.
       
  2114 					if ( charsCanBeDisplayed> 1 &&
       
  2115 							convBuf[charsCanBeDisplayed - 1] == ' ' &&
       
  2116 							convBuf[charsCanBeDisplayed - 2] != ' ' )
       
  2117 						{
       
  2118 						charsCanBeDisplayed--;
       
  2119 						}
       
  2120 
       
  2121 					TInt pictoRectWidth = textLayout.Font()->TextWidthInPixels(
       
  2122 							convBuf.Left( charsCanBeDisplayed ) );
       
  2123 					pictoRect.SetWidth( pictoRectWidth );
       
  2124 					}
       
  2125 				}
       
  2126 
       
  2127 			/*iExtension->iPictoInterface->Interface()->DrawPictographsInText(
       
  2128 					aGc, *usedFont, convBuf,
       
  2129 					pictoRect,
       
  2130 					textLayout.BaselineOffset(),
       
  2131 					textLayout.Align(),
       
  2132 					0 );*/ //qiang
       
  2133 			}
       
  2134 
       
  2135 		aGc.SetUnderlineStyle( EUnderlineOff );
       
  2136 		}
       
  2137 	else // Graphics subcell
       
  2138 
       
  2139 		{
       
  2140 		TLex lex(text);
       
  2141 		TInt index;
       
  2142 		TInt indexValue;
       
  2143 
       
  2144 		indexValue=lex.Val(index);
       
  2145 
       
  2146 		if (indexValue!=KErrNone)
       
  2147 			{
       
  2148 			// wrong icon index
       
  2149 			++ subcell;
       
  2150 			continue;
       
  2151 			}
       
  2152 
       
  2153 		//__ASSERT_DEBUG(indexValue==KErrNone, Panic(EAknPanicFormattedCellListInvalidBitmapIndex));
       
  2154 
       
  2155 		TBool colorIcon( EFalse );
       
  2156 		if ( index == KColorIconFlag )
       
  2157 			{
       
  2158 			if ( iExtension->iColorBmp && iExtension->iHiliBmp )
       
  2159 				{
       
  2160 				colorIcon = ETrue;
       
  2161 				}
       
  2162 			index = KColorIconIdx;
       
  2163 			}
       
  2164 
       
  2165 		if( !iIconArray )
       
  2166 			{
       
  2167 			continue;
       
  2168 			}
       
  2169 
       
  2170 		if (aHighlight && (index> 0xffff))
       
  2171 			{
       
  2172 			index = index >> 16; // we have different icon for highlight
       
  2173 			}
       
  2174 
       
  2175 		index = index & 0xffff; // mask off possible highlight icon
       
  2176 		//__ASSERT_DEBUG((index>=0 && index<iIconArray->Count()),Panic(EAknPanicFormattedCellListInvalidBitmapIndex));
       
  2177 
       
  2178 		TAknWindowLineLayout graphicLayout = iExtension->AtSL(SCindex).iGraphicLayout;
       
  2179 		TAknLayoutRect graphicRect;
       
  2180 
       
  2181 		graphicRect.LayoutRect(textRect,graphicLayout);
       
  2182 		TSize graphicSize( graphicRect.Rect().Size() );
       
  2183 
       
  2184 		if (index>=0 && iIconArray)
       
  2185 			{
       
  2186 			CGulIcon* icon=(*iIconArray)[index];
       
  2187 			CFbsBitmap* bitmap=icon->Bitmap();
       
  2188 			// Sometimes we get fake bitmap...
       
  2189 			if ( bitmap )
       
  2190 				{
       
  2191 				TSize size( bitmap->SizeInPixels() ); // set size if not already
       
  2192 				if ( size.iWidth != graphicSize.iWidth && size.iHeight != graphicSize.iHeight )
       
  2193 					{
       
  2194 					AknIconUtils::SetSize( bitmap,
       
  2195 							graphicSize,
       
  2196 							EAspectRatioPreservedAndUnusedSpaceRemoved);
       
  2197 					}
       
  2198 				BitBltColored( aGc, aHighlight, icon, subcell, colorIcon, graphicRect.Rect() );
       
  2199 				aGc.SetPenStyle(CGraphicsContext::ESolidPen);
       
  2200 				}
       
  2201 			}
       
  2202 		}
       
  2203 	++subcell;
       
  2204 	}
       
  2205 
       
  2206 // Clear information of wordwrapped and bidi-reordered subcells.
       
  2207 const_cast<CCCAppCommLauncherCustomListBoxData*>( this )->
       
  2208 SetWordWrappedSubcellIndices( -1, -1 );
       
  2209 }
       
  2210 
       
  2211  CCCAppCommLauncherCustomListBoxData::CCCAppCommLauncherCustomListBoxData() :
       
  2212 	CListBoxData()
       
  2213 	{
       
  2214 	}
       
  2215 
       
  2216  void CCCAppCommLauncherCustomListBoxData::ConstructLD()
       
  2217 	{
       
  2218 	TRAPD( err, DoConstructL( KAknsIIDQsnAnimList ) );
       
  2219 	if (err)
       
  2220 		{
       
  2221 		delete (this);
       
  2222 		User::Leave(err);
       
  2223 		}
       
  2224 	}
       
  2225 
       
  2226  void CCCAppCommLauncherCustomListBoxData::ConstructLD(
       
  2227 		const TAknsItemID& aAnimationIID)
       
  2228 	{
       
  2229 	TRAPD( err, DoConstructL( aAnimationIID ) );
       
  2230 	if (err)
       
  2231 		{
       
  2232 		delete (this);
       
  2233 		User::Leave(err);
       
  2234 		}
       
  2235 	}
       
  2236 
       
  2237 void CCCAppCommLauncherCustomListBoxData::DoConstructL(
       
  2238 		const TAknsItemID& aAnimationIID)
       
  2239 	{
       
  2240 	iSubCellArray = new (ELeave) CArrayFixFlat<SSubCell> (
       
  2241 			KSubCellListBoxGranularity);
       
  2242 	iExtension = new (ELeave) CCCAppCommLauncherCustomListBoxDataExtension;
       
  2243 
       
  2244 	iExtension->iSkinEnabled = AknsUtils::AvkonSkinEnabled();
       
  2245 	SetupSkinContextL();
       
  2246 
       
  2247 	// Preallocate so that SizeChanged() methods do not leave so often.
       
  2248 	CListBoxData::ConstructL(NULL);
       
  2249 	iExtension->ConstructL(this, aAnimationIID);
       
  2250 	CListBoxData::SetSkinBackgroundControlContextL(
       
  2251 			iExtension->iSkinControlContext);
       
  2252 	AddSubCellL(0);
       
  2253 	AddSubCellL(1);
       
  2254 	AddSubCellL(2);
       
  2255 	AddSubCellL(3);
       
  2256 	AddSubCellL(4);
       
  2257 	}
       
  2258 
       
  2259 TInt CCCAppCommLauncherCustomListBoxData::LastSubCell() const
       
  2260 	{
       
  2261 	TInt count = iSubCellArray->Count();
       
  2262 	if (!count)
       
  2263 		return (KErrNotFound);
       
  2264 	return (At(count - 1).iSubCell);
       
  2265 	}
       
  2266 
       
  2267 void CCCAppCommLauncherCustomListBoxData::AddSubCellL(TInt aSubCell)
       
  2268 	{
       
  2269 	SSubCell subcell;
       
  2270 	TMargins m =
       
  2271 		{
       
  2272 		0, 0, 0, 0
       
  2273 		};
       
  2274 	subcell.iSubCell = aSubCell;
       
  2275 	subcell.iWidth = 0;
       
  2276 	subcell.iMargin = m;
       
  2277 	subcell.iBaseFont = NULL;
       
  2278 	subcell.iActualFontIndex = KNoActualSubCellFont;
       
  2279 	subcell.iGraphics = EFalse;
       
  2280 	subcell.iTransparent = EFalse;
       
  2281 	subcell.iNotAlwaysDrawn = EFalse;
       
  2282 	subcell.iRightSeparatorStyle = CGraphicsContext::ENullPen;
       
  2283 	subcell.iAlign = CGraphicsContext::ELeft;
       
  2284 	subcell.iPosition = TPoint(0, 0);
       
  2285 	subcell.iBaseline = 0;
       
  2286 	subcell.iSize = TSize(0, 0);
       
  2287 	subcell.iUseSubCellColors = EFalse;
       
  2288 	subcell.iTextClipGap = 0;
       
  2289 	subcell.iNumberCell = 0;
       
  2290 	TKeyArrayFix key(0, ECmpTInt);
       
  2291 	iSubCellArray->InsertIsqL(subcell, key);
       
  2292 	}
       
  2293 
       
  2294 CCCAppCommLauncherCustomListBoxData::SSubCell&
       
  2295 CCCAppCommLauncherCustomListBoxData::At(TInt aArrayIndex)
       
  2296 	{
       
  2297 	//__ASSERT_DEBUG(aArrayIndex>=0 && aArrayIndex<iSubCellArray->Count(),Panic(EAknPanicOutOfRange));
       
  2298 	return (iSubCellArray->At(aArrayIndex));
       
  2299 	}
       
  2300 
       
  2301 const CCCAppCommLauncherCustomListBoxData::SSubCell&
       
  2302 CCCAppCommLauncherCustomListBoxData::At(TInt aArrayIndex) const
       
  2303 	{
       
  2304 	//__ASSERT_DEBUG(aArrayIndex>=0 && aArrayIndex<iSubCellArray->Count(),Panic(EAknPanicOutOfRange));
       
  2305 	return (iSubCellArray->At(aArrayIndex));
       
  2306 	}
       
  2307 
       
  2308 TInt CCCAppCommLauncherCustomListBoxData::FindSubCellIndex(TInt& aArrayIndex,
       
  2309 		TInt aSubCell) const
       
  2310 	{
       
  2311 	if (aSubCell < 0 || iSubCellArray->Count() == 0)
       
  2312 		return (KErrNotFound);
       
  2313 	TKeyArrayFix key(0, ECmpTInt);
       
  2314 	SSubCell subcell;
       
  2315 	subcell.iSubCell = aSubCell;
       
  2316 	TInt retVal = iSubCellArray->FindIsq(subcell, key, aArrayIndex);
       
  2317 	if (retVal != 0)
       
  2318 		{
       
  2319 		return KErrNotFound;
       
  2320 		}
       
  2321 
       
  2322 	return retVal;
       
  2323 	}
       
  2324 
       
  2325 void CCCAppCommLauncherCustomListBoxData::FindSubCellIndexOrAddL(
       
  2326 		TInt& aArrayIndex, TInt aSubCell)
       
  2327 	{
       
  2328 	if (FindSubCellIndex(aArrayIndex, aSubCell) == KErrNotFound)
       
  2329 		{
       
  2330 		AddSubCellL(aSubCell);
       
  2331 		FindSubCellIndex(aArrayIndex, aSubCell);
       
  2332 		}
       
  2333 	}
       
  2334 
       
  2335  CCCAppCommLauncherCustomListBoxData::TColors::TColors() :
       
  2336 			iText(KRgbBlack), iBack(KRgbWhite), iHighlightedText(KRgbWhite), iHighlightedBack(
       
  2337 					KRgbBlack),
       
  2338 			iRightSeparatorColor(AKN_LAF_COLOR_STATIC(215))
       
  2339 	{
       
  2340 	}
       
  2341 
       
  2342 TInt CCCAppCommLauncherCustomListBoxData::AddActualFontL(const CFont* aBaseFont)
       
  2343 	{
       
  2344 	if (!iNormalFont.iFonts)
       
  2345 		{
       
  2346 		iNormalFont.iFonts = new (ELeave) CArrayPtrFlat<CFont> (1);
       
  2347 		iBoldFont.iFonts = new (ELeave) CArrayPtrFlat<CFont> (1);
       
  2348 		iItalicFont.iFonts = new (ELeave) CArrayPtrFlat<CFont> (1);
       
  2349 		iBoldItalicFont.iFonts = new (ELeave) CArrayPtrFlat<CFont> (1);
       
  2350 		}
       
  2351 
       
  2352 	// Reserves extra space for each font array.
       
  2353 	TInt fontCount = iNormalFont.iFonts->Count() + 1;
       
  2354 	iNormalFont.iFonts->SetReserveL(fontCount);
       
  2355 	iBoldFont.iFonts->SetReserveL(fontCount);
       
  2356 	iItalicFont.iFonts->SetReserveL(fontCount);
       
  2357 	iBoldItalicFont.iFonts->SetReserveL(fontCount);
       
  2358 
       
  2359 	// Add Fonts.
       
  2360 	ConstructFontL(aBaseFont, TFontStyle(EPostureUpright, EStrokeWeightNormal,
       
  2361 			EPrintPosNormal), iNormalFont);
       
  2362 	ConstructFontL(aBaseFont, TFontStyle(EPostureUpright, EStrokeWeightBold,
       
  2363 			EPrintPosNormal), iBoldFont);
       
  2364 	ConstructFontL(aBaseFont, TFontStyle(EPostureItalic, EStrokeWeightNormal,
       
  2365 			EPrintPosNormal), iItalicFont);
       
  2366 	ConstructFontL(aBaseFont, TFontStyle(EPostureItalic, EStrokeWeightBold,
       
  2367 			EPrintPosNormal), iBoldItalicFont);
       
  2368 
       
  2369 	return fontCount - 1;
       
  2370 	}
       
  2371 
       
  2372 void CCCAppCommLauncherCustomListBoxData::DrawDefaultHighlight(CWindowGc &aGc,
       
  2373 		const TRect &aItemRect, TBool aHighlight) const
       
  2374 	{
       
  2375 	// When this flag set, draw pressed down state and don't use animation.
       
  2376 	// There are several derived CListboxData in this file. All of them do  
       
  2377 	// this same thing.
       
  2378 	CListBoxView* view =
       
  2379 			static_cast<CEikListBox*> (iExtension->iControl)->View();
       
  2380 	TBool pressedDown = view->ItemDrawer()->Flags()
       
  2381 			& CListItemDrawer::EPressedDownState;
       
  2382 
       
  2383 	if (aHighlight)
       
  2384 		{
       
  2385 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  2386 		MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal(&aGc);
       
  2387 		if (transApi)
       
  2388 			{
       
  2389 			transApi->Invalidate(MAknListBoxTfxInternal::EListHighlight);
       
  2390 			if (!transApi->BeginRedraw(MAknListBoxTfxInternal::EListHighlight,
       
  2391 					aItemRect))
       
  2392 				{
       
  2393 				// No need to execute drawing if no drawing will occur
       
  2394 				transApi->EndRedraw(MAknListBoxTfxInternal::EListHighlight);
       
  2395 				return;
       
  2396 				}
       
  2397 			transApi->StartDrawing(MAknListBoxTfxInternal::EListHighlight);
       
  2398 
       
  2399 			}
       
  2400 #endif //RD_UI_TRANSITION_EFFECTS_LIST
       
  2401 		TBool highlightDrawn = EFalse;
       
  2402 
       
  2403 		TAknLayoutRect outerRect;
       
  2404 		TAknLayoutRect innerRect;
       
  2405 		outerRect.LayoutRect(
       
  2406 				aItemRect,
       
  2407 				TAknWindowComponentLayout::Compose(
       
  2408 						AknLayoutScalable_Avkon::list_highlight_pane_cp1(),
       
  2409 						AknLayoutScalable_Avkon::list_highlight_pane_g10_cp1()).LayoutLine());
       
  2410 		innerRect.LayoutRect(
       
  2411 				aItemRect,
       
  2412 				TAknWindowComponentLayout::Compose(
       
  2413 						AknLayoutScalable_Avkon::list_highlight_pane_cp1(),
       
  2414 						AknLayoutScalable_Avkon::list_highlight_pane_g1_cp1()).LayoutLine());
       
  2415 
       
  2416 		if (iExtension->iAnimation) // animated highlight
       
  2417 			{
       
  2418 			aGc.SetPenStyle(CGraphicsContext::ENullPen);
       
  2419 			highlightDrawn = iExtension->SyncAndDrawAnim(aGc, outerRect.Rect());
       
  2420 			}
       
  2421 
       
  2422 		if (!highlightDrawn) // normal skinned highlight
       
  2423 			{
       
  2424 			if (pressedDown)
       
  2425 				{
       
  2426 				TRAP_IGNORE( highlightDrawn = iExtension->DrawPressedDownEffectL(
       
  2427 						AknsUtils::SkinInstance(), aGc, outerRect.Rect(),
       
  2428 						innerRect.Rect()) );
       
  2429 				}
       
  2430 			else
       
  2431 				{
       
  2432 				MAknsControlContext *cc = AknsDrawUtils::ControlContext(
       
  2433 						Control());
       
  2434 
       
  2435 				if (!cc)
       
  2436 					{
       
  2437 					cc = SkinBackgroundContext();
       
  2438 					}
       
  2439 
       
  2440 				if (cc)
       
  2441 					{
       
  2442 
       
  2443 					aGc.SetPenStyle(CGraphicsContext::ENullPen);
       
  2444 
       
  2445 					highlightDrawn = AknsDrawUtils::DrawFrame(
       
  2446 							AknsUtils::SkinInstance(), aGc, outerRect.Rect(),
       
  2447 							innerRect.Rect(),
       
  2448 							*iExtension->iSkinHighlightFrameId,
       
  2449 							*iExtension->iSkinHighlightFrameCenterId);
       
  2450 					}
       
  2451 				}
       
  2452 			}
       
  2453 
       
  2454 		if (!highlightDrawn) // legacy fallback
       
  2455 			{
       
  2456 			TRgb color(AKN_LAF_COLOR( 244 ));
       
  2457 			aGc.SetPenColor(color);
       
  2458 			aGc.SetBrushColor(color);
       
  2459 			aGc.SetPenStyle(CGraphicsContext::ESolidPen);
       
  2460 			aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  2461 			aGc.DrawRect(aItemRect);
       
  2462 			}
       
  2463 #ifdef RD_UI_TRANSITION_EFFECTS_LIST  
       
  2464 		if (transApi)
       
  2465 			{
       
  2466 			transApi->StopDrawing();
       
  2467 			transApi->EndRedraw(MAknListBoxTfxInternal::EListHighlight);
       
  2468 			}
       
  2469 #endif
       
  2470 		}
       
  2471 	}
       
  2472 
       
  2473 void CCCAppCommLauncherCustomListBoxData::DrawSettingHighlight(CWindowGc &aGc,
       
  2474 		const TRect &aItemRect, TBool aHighlight) const
       
  2475 	{
       
  2476 	DrawDefaultHighlight(aGc, aItemRect, aHighlight);
       
  2477 	}
       
  2478 
       
  2479 void CCCAppCommLauncherCustomListBoxData::DrawPopupHighlight(CWindowGc &aGc,
       
  2480 		const TRect &aItemRect, TBool aHighlight) const
       
  2481 	{
       
  2482 	DrawDefaultHighlight(aGc, aItemRect, aHighlight);
       
  2483 	}
       
  2484 
       
  2485 void CCCAppCommLauncherCustomListBoxData::DrawPopupFrame(CWindowGc &aGc) const
       
  2486 	{
       
  2487 	CCoeControl* control = Control();
       
  2488 
       
  2489 	if (control)
       
  2490 		{
       
  2491 		aGc.SetPenStyle(CGraphicsContext::ENullPen);
       
  2492 
       
  2493 		TBool done = AknsDrawUtils::Background(AknsUtils::SkinInstance(),
       
  2494 				iExtension->iPopupFrame, control, aGc, control->Rect());
       
  2495 
       
  2496 		if (!done)
       
  2497 			{
       
  2498 			aGc.Clear(control->Rect());
       
  2499 			}
       
  2500 		}
       
  2501 	}
       
  2502 
       
  2503 void CCCAppCommLauncherCustomListBoxData::SetWordWrappedSubcellIndices(
       
  2504 		TInt aFirstIndex, TInt aSecondIndex)
       
  2505 	{
       
  2506 	iExtension->iFirstWordWrappedSubcellIndex = (TInt16) aFirstIndex;
       
  2507 	iExtension->iSecondWordWrappedSubcellIndex = (TInt16) aSecondIndex;
       
  2508 	}
       
  2509 
       
  2510  void CCCAppCommLauncherCustomListBoxData::EnableMarqueeL(TBool aEnable)
       
  2511 	{
       
  2512 	// CreateMarqueeControlL does nothing if marquee already exists,
       
  2513 	// so let's just call it just in case.
       
  2514 	CreateMarqueeControlL();
       
  2515 	iExtension->iMarquee->EnableMarquee(aEnable);
       
  2516 	iExtension->i2ndLineMarquee->EnableMarquee(aEnable);
       
  2517 	}
       
  2518 
       
  2519 // Two versions to eliminate compiler warnings.
       
  2520 #ifdef __WINS__
       
  2521  const TBool CCCAppCommLauncherCustomListBoxData::IsMarqueeOn()
       
  2522 	{
       
  2523 	return iExtension->IsMarqueeOn();
       
  2524 	}
       
  2525 #else
       
  2526  TBool CCCAppCommLauncherCustomListBoxData::IsMarqueeOn()
       
  2527 	{
       
  2528 	return iExtension->IsMarqueeOn();
       
  2529 	}
       
  2530 #endif // __WINS__
       
  2531 
       
  2532 void CCCAppCommLauncherCustomListBoxData::FocusGained()
       
  2533 	{
       
  2534 	iExtension->FocusGained();
       
  2535 	}
       
  2536 
       
  2537 void CCCAppCommLauncherCustomListBoxData::FocusLost()
       
  2538 	{
       
  2539 	iExtension->FocusLost();
       
  2540 	}
       
  2541 
       
  2542 void CCCAppCommLauncherCustomListBoxData::HandleResourceChange(TInt aType)
       
  2543 	{
       
  2544 	// Animation is skin dependent, whenever skin changes animation changes
       
  2545 	// too.
       
  2546 	if (KAknsMessageSkinChange == aType)
       
  2547 		{
       
  2548 		iExtension->SkinChanged();
       
  2549 		}
       
  2550 	else if (aType == KEikDynamicLayoutVariantSwitch)
       
  2551 		{
       
  2552 		// What is under highlight may have changed -> we need to update
       
  2553 		// highlight background to animation.
       
  2554 		iExtension->iAnimFlags.Set(
       
  2555 				CCCAppCommLauncherCustomListBoxDataExtension::EFlagUpdateBg);
       
  2556 		}
       
  2557 	}
       
  2558 
       
  2559 // -----------------------------------------------------------------------------
       
  2560 // CCCAppCommLauncherCustomListBoxData::HighlightAnim
       
  2561 // -----------------------------------------------------------------------------
       
  2562 //
       
  2563  const CAknsEffectAnim* CCCAppCommLauncherCustomListBoxData::HighlightAnim() const
       
  2564 	{
       
  2565 	if (iExtension)
       
  2566 		return iExtension->iAnimation;
       
  2567 	return NULL;
       
  2568 	}
       
  2569 
       
  2570 // -----------------------------------------------------------------------------
       
  2571 // CCCAppCommLauncherCustomListBoxData::AboutToDrawHighlightAnim
       
  2572 // -----------------------------------------------------------------------------
       
  2573 //
       
  2574  void CCCAppCommLauncherCustomListBoxData::AboutToDrawHighlightAnim() const
       
  2575 	{
       
  2576 	if (!iExtension)
       
  2577 		{
       
  2578 		return;
       
  2579 		}
       
  2580 	if (!iExtension->iAnimation || !iExtension->iControl)
       
  2581 		{
       
  2582 		return;
       
  2583 		}
       
  2584 
       
  2585 	CEikListBox* list = static_cast<CEikListBox*> (iExtension->iControl);
       
  2586 	CListBoxView* view = list->View();
       
  2587 	if (!view)
       
  2588 		{
       
  2589 		return;
       
  2590 		}
       
  2591 
       
  2592 	if (view->CurrentItemIndex() != iExtension->iCurrentRow)
       
  2593 		{
       
  2594 		iExtension->iAnimFlags.Set(
       
  2595 				CCCAppCommLauncherCustomListBoxDataExtension::EFlagUpdateBg);
       
  2596 		iExtension->iCurrentRow = view->CurrentItemIndex();
       
  2597 		}
       
  2598 
       
  2599 	iExtension->SyncAnim(iExtension->iAnimSize);
       
  2600 	}
       
  2601 
       
  2602 // -----------------------------------------------------------------------------
       
  2603 // CCCAppCommLauncherCustomListBoxData::SetHighlightAnimBackgroundDrawer
       
  2604 // -----------------------------------------------------------------------------
       
  2605 //
       
  2606  void CCCAppCommLauncherCustomListBoxData::SetHighlightAnimBackgroundDrawer(
       
  2607 		MListBoxAnimBackgroundDrawer* aDrawer)
       
  2608 	{
       
  2609 	if (iExtension)
       
  2610 		{
       
  2611 		iExtension->iHighlightBgDrawer = aDrawer;
       
  2612 		}
       
  2613 	}
       
  2614 
       
  2615 // -----------------------------------------------------------------------------
       
  2616 // CCCAppCommLauncherCustomListBoxData::SetItemCellSize
       
  2617 // -----------------------------------------------------------------------------
       
  2618 //
       
  2619  void CCCAppCommLauncherCustomListBoxData::SetItemCellSize(
       
  2620 		const TSize& aSize)
       
  2621 	{
       
  2622 	if (iExtension)
       
  2623 		{
       
  2624 		if (iExtension->iAnimSize != aSize)
       
  2625 			{
       
  2626 			iExtension->Play();
       
  2627 			}
       
  2628 		iExtension->iAnimSize = aSize;
       
  2629 		}
       
  2630 	}
       
  2631 
       
  2632 // -----------------------------------------------------------------------------
       
  2633 // CCCAppCommLauncherCustomListBoxData::HasHighlightAnim
       
  2634 // -----------------------------------------------------------------------------
       
  2635 //
       
  2636  TBool CCCAppCommLauncherCustomListBoxData::HasHighlightAnim() const
       
  2637 	{
       
  2638 	if (!iExtension)
       
  2639 		return EFalse;
       
  2640 	if (!iExtension->iAnimation)
       
  2641 		return EFalse;
       
  2642 	return ETrue;
       
  2643 	}
       
  2644 
       
  2645 // -----------------------------------------------------------------------------
       
  2646 // CCCAppCommLauncherCustomListBoxData::DrawHighlightAnim
       
  2647 // -----------------------------------------------------------------------------
       
  2648 //
       
  2649  TBool CCCAppCommLauncherCustomListBoxData::DrawHighlightAnim(
       
  2650 		CBitmapContext& aGc, const TRect& aRect) const
       
  2651 	{
       
  2652 	if (!iExtension)
       
  2653 		return EFalse;
       
  2654 
       
  2655 	if (!iExtension->iAnimation)
       
  2656 		return EFalse;
       
  2657 
       
  2658 	return iExtension->SyncAndDrawAnim(aGc, aRect);
       
  2659 	}
       
  2660 
       
  2661 void CCCAppCommLauncherCustomListBoxData::ResetMarquee()
       
  2662 	{
       
  2663 	if (iExtension->iMarquee)
       
  2664 		{
       
  2665 		iExtension->iMarquee->Reset();
       
  2666 		}
       
  2667 	if (iExtension->i2ndLineMarquee)
       
  2668 		{
       
  2669 		iExtension->i2ndLineMarquee->Reset();
       
  2670 		}
       
  2671 	}
       
  2672 
       
  2673 TInt CCCAppCommLauncherCustomListBoxData::CurrentMarqueeItemIndex()
       
  2674 	{
       
  2675 	return iExtension->iCurrentItem;
       
  2676 	}
       
  2677 
       
  2678 void CCCAppCommLauncherCustomListBoxData::SetCurrentMarqueeItemIndex(
       
  2679 		TInt aIndex)
       
  2680 	{
       
  2681 	iExtension->iCurrentItem = aIndex;
       
  2682 	}
       
  2683 
       
  2684 void CCCAppCommLauncherCustomListBoxData::SetCurrentItemIndex(TInt aIndex)
       
  2685 	{
       
  2686 	if (iExtension->iCurrentRow != aIndex)
       
  2687 		{
       
  2688 		iExtension->iAnimFlags.Set(
       
  2689 				CCCAppCommLauncherCustomListBoxDataExtension::EFlagUpdateBg);
       
  2690 		}
       
  2691 	iExtension->iCurrentRow = aIndex;
       
  2692 	}
       
  2693 
       
  2694 void CCCAppCommLauncherCustomListBoxData::SetCurrentlyDrawnItemIndex(
       
  2695 		TInt aIndex)
       
  2696 	{
       
  2697 	if (iExtension)
       
  2698 		{
       
  2699 		iExtension->iCurrentlyDrawnItemIndex = aIndex;
       
  2700 		}
       
  2701 	}
       
  2702 
       
  2703  const CFont*
       
  2704 CCCAppCommLauncherCustomListBoxData::RowAndSubCellFont(TInt aRow,
       
  2705 		TInt aSubCellIndex) const
       
  2706 	{
       
  2707 	if (!iExtension)
       
  2708 		return 0;
       
  2709 	TInt index = 0;
       
  2710 	if (iExtension->FindRowAndSubCellIndex(index, aRow, aSubCellIndex) != 0)
       
  2711 		return 0;
       
  2712 	return (iExtension->At(index).iFont);
       
  2713 	}
       
  2714 
       
  2715  void CCCAppCommLauncherCustomListBoxData::SetSubCellFontForRowL(
       
  2716 		TInt aRowIndex, TInt aSubCellIndex, const CFont* aFont)
       
  2717 	{
       
  2718 	if (!iExtension)
       
  2719 		return;
       
  2720 	TInt index = 0;
       
  2721 	iExtension->FindRowAndSubCellIndexOrAddL(index, aRowIndex, aSubCellIndex);
       
  2722 	iExtension->At(index).iFont = aFont;
       
  2723 	}
       
  2724 
       
  2725 /**
       
  2726  * Enables / disables transparency effect, ie. does the listbox draw it's own background or not.
       
  2727  * @param aDrawBackground  EFalse enables transparency
       
  2728  */
       
  2729  void CCCAppCommLauncherCustomListBoxData::SetDrawBackground(
       
  2730 		const TBool aDrawBackground)
       
  2731 	{
       
  2732 	iExtension->iDrawBackground = aDrawBackground;
       
  2733 	if (!aDrawBackground)
       
  2734 		{
       
  2735 		iExtension->DeleteAnim();
       
  2736 		}
       
  2737 	}
       
  2738 
       
  2739 /**
       
  2740  * Is the listbox drawing the background itself or not (= "transparency")
       
  2741  */
       
  2742 TBool CCCAppCommLauncherCustomListBoxData::IsBackgroundDrawingEnabled() const
       
  2743 	{
       
  2744 	return iExtension->iDrawBackground;
       
  2745 	}
       
  2746 
       
  2747 /**
       
  2748  * Enables / disables drawing background after scrollbar
       
  2749  * @param aDrawBackground  default ETrue
       
  2750  */
       
  2751 void CCCAppCommLauncherCustomListBoxData::SetDrawScrollbarBackground(
       
  2752 		const TBool aDrawBackground)
       
  2753 	{
       
  2754 	iExtension->iDrawScrollbarBackground = aDrawBackground;
       
  2755 	}
       
  2756 
       
  2757 /**
       
  2758  * Is the listbox drawing the background after scrollbar or not
       
  2759  */
       
  2760 TBool CCCAppCommLauncherCustomListBoxData::IsScrollbarBackgroundDrawingEnabled() const
       
  2761 	{
       
  2762 	return iExtension->iDrawScrollbarBackground;
       
  2763 	}
       
  2764 
       
  2765  void CCCAppCommLauncherCustomListBoxData::SetMarqueeParams(
       
  2766 		const TInt aLoops, const TInt aScrollAmount, const TInt aScrollDelay,
       
  2767 		const TInt aInterval)
       
  2768 	{
       
  2769 	if (iExtension->iMarquee)
       
  2770 		{
       
  2771 		iExtension->iMarquee->SetLoops(aLoops);
       
  2772 		iExtension->iMarquee->SetSpeedInPixels(aScrollAmount);
       
  2773 		iExtension->iMarquee->SetDelay(aScrollDelay);
       
  2774 		iExtension->iMarquee->SetInterval(aInterval);
       
  2775 		}
       
  2776 	if (iExtension->i2ndLineMarquee)
       
  2777 		{
       
  2778 		iExtension->i2ndLineMarquee->SetLoops(aLoops);
       
  2779 		iExtension->i2ndLineMarquee->SetSpeedInPixels(aScrollAmount);
       
  2780 		iExtension->i2ndLineMarquee->SetDelay(aScrollDelay);
       
  2781 		iExtension->i2ndLineMarquee->SetInterval(aInterval);
       
  2782 		}
       
  2783 	}
       
  2784 
       
  2785  void CCCAppCommLauncherCustomListBoxData::SetSubCellIconSize(
       
  2786 		TInt aIndex, TSize aSize)
       
  2787 	{
       
  2788 	if (iExtension && aIndex <= KMaxSubCellIndex && aIndex >= 0)
       
  2789 		{
       
  2790 		iExtension->iSubCellIconSize[aIndex] = aSize;
       
  2791 		}
       
  2792 	}
       
  2793 
       
  2794 TSize CCCAppCommLauncherCustomListBoxData::GetSubCellIconSize(TInt aIndex)
       
  2795 	{
       
  2796 	if (iExtension && aIndex <= KMaxSubCellIndex && aIndex >= 0)
       
  2797 		{
       
  2798 		return iExtension->iSubCellIconSize[aIndex];
       
  2799 		}
       
  2800 	return TSize(0, 0);
       
  2801 	}
       
  2802 
       
  2803 void CCCAppCommLauncherCustomListBoxData::SetupSkinContextL()
       
  2804 	{
       
  2805 	//__ASSERT_DEBUG( iExtension, Panic( EAknPanicNullPointer ));
       
  2806 
       
  2807 	// list's own rect cannot be used since it might be unknown at this point
       
  2808 	TRect mainPane;
       
  2809 	AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPane);
       
  2810 
       
  2811 	TRect mainPaneRect(mainPane.Size());
       
  2812 
       
  2813 	if (!iExtension->iSkinControlContext)
       
  2814 		{
       
  2815 		iExtension->iSkinControlContext
       
  2816 				= CAknsListBoxBackgroundControlContext::NewL(
       
  2817 						KAknsIIDQsnBgAreaMainListGene, mainPaneRect, EFalse, // Changed to EFalse: See TSW defect avao-6eelpv
       
  2818 						KAknsIIDNone, mainPaneRect);
       
  2819 		}
       
  2820 	else
       
  2821 		{
       
  2822 		iExtension->iSkinControlContext->SetRect(mainPaneRect);
       
  2823 		}
       
  2824 
       
  2825 	if (iExtension->iPopupFrame)
       
  2826 		{
       
  2827 		iExtension->iPopupFrame->SetRect(mainPaneRect);
       
  2828 		}
       
  2829 
       
  2830 	iExtension->iSkinHighlightFrameId = &KAknsIIDQsnFrList;
       
  2831 	iExtension->iSkinHighlightFrameCenterId = &KAknsIIDQsnFrListCenter;
       
  2832 	}
       
  2833 
       
  2834 // extended skin support
       
  2835 void CCCAppCommLauncherCustomListBoxData::SetESSTextColor(
       
  2836 		TAknsQsnTextColorsIndex aIndex)
       
  2837 	{
       
  2838 	TRgb color;
       
  2839 
       
  2840 	TInt error = AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), color,
       
  2841 			KAknsIIDQsnTextColors, aIndex);
       
  2842 	if (!error && iExtension)
       
  2843 		{
       
  2844 		iExtension->iTextColor = color;
       
  2845 		}
       
  2846 	}
       
  2847 
       
  2848 // extended skin support
       
  2849 void CCCAppCommLauncherCustomListBoxData::SetESSHighlightedTextColor(
       
  2850 		TAknsQsnTextColorsIndex aIndex)
       
  2851 	{
       
  2852 	TRgb color;
       
  2853 
       
  2854 	TInt error = AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), color,
       
  2855 			KAknsIIDQsnTextColors, aIndex);
       
  2856 	if (!error)
       
  2857 		{
       
  2858 		iExtension->iHighlightedTextColor = color;
       
  2859 		}
       
  2860 	}
       
  2861 
       
  2862 void CCCAppCommLauncherCustomListBoxData::SetGraphicSubCellL(TInt aSubCell,
       
  2863 		const TAknWindowLineLayout &aGraphicLayout)
       
  2864 	{
       
  2865 	if (!iExtension)
       
  2866 		return;
       
  2867 	CEikFormattedCellListBox* list =
       
  2868 			static_cast<CEikFormattedCellListBox*> (iExtension->iControl);
       
  2869 	// this does happen with caknsetstyle, caknform(wide)style lists.
       
  2870 	// eventually they'll get here again with list!=0, so this check is enough
       
  2871 	if (!list)
       
  2872 		return;
       
  2873 
       
  2874 	TInt index = 0;
       
  2875 	iExtension->FindSLSubCellIndexOrAddL(index, aSubCell);
       
  2876 	iExtension->AtSL(index).iTextLayout = NULL;
       
  2877 	iExtension->AtSL(index).iGraphicLayout = aGraphicLayout;
       
  2878 	iExtension->AtSL(index).iSubCellType
       
  2879 			= CCCAppCommLauncherCustomListBoxDataExtension::EAknSLGraphic;
       
  2880 
       
  2881 	// For compabitility - needed at least for text wrapping.
       
  2882 	// Beware - some of these WILL be overriden if you got here trough
       
  2883 	// old layout methods like AknListBoxLayouts::SetupFormTextCell()
       
  2884 	// & friends.
       
  2885 	TAknLayoutRect r;
       
  2886 
       
  2887 	r.LayoutRect(list->View()->ItemDrawer()->ItemCellSize(), aGraphicLayout);
       
  2888 	SetSubCellSizeL(aSubCell, r.Rect().Size());
       
  2889 	SetSubCellPositionL(aSubCell, r.Rect().iTl);
       
  2890 	SetSubCellAlignmentL(aSubCell, CGraphicsContext::ECenter);
       
  2891 	SetGraphicsSubCellL(aSubCell, ETrue);
       
  2892 	UseScalableLayoutData(ETrue);
       
  2893 	if (iExtension->iMarginRect == TRect::EUninitialized)
       
  2894 		{
       
  2895 		iExtension->iMarginRect = r.Rect();
       
  2896 		}
       
  2897 	else
       
  2898 		{
       
  2899 		iExtension->iMarginRect.BoundingRect(r.Rect());
       
  2900 		}
       
  2901 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  2902 	MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal(
       
  2903 			list->View()->ItemDrawer()->Gc());
       
  2904 	if (transApi)
       
  2905 		{
       
  2906 		transApi->SetPosition(MAknListBoxTfxInternal::EListTLMargin,
       
  2907 				iExtension->iMarginRect.iTl);
       
  2908 		TSize size = list->View()->ItemDrawer()->ItemCellSize();
       
  2909 		TPoint br(size.AsPoint() - iExtension->iMarginRect.iBr);
       
  2910 		transApi->SetPosition(MAknListBoxTfxInternal::EListBRMargin, br);
       
  2911 		}
       
  2912 #endif
       
  2913 	}
       
  2914 
       
  2915 void CCCAppCommLauncherCustomListBoxData::SetTextSubCellL(TInt aSubCell,
       
  2916 		const TAknTextLineLayout &aTextLayout)
       
  2917 	{
       
  2918 	if (!iExtension)
       
  2919 		return;
       
  2920 	CEikFormattedCellListBox* list =
       
  2921 			static_cast<CEikFormattedCellListBox*> (iExtension->iControl);
       
  2922 	// this does happen with caknsetstyle, caknform(wide)style lists.
       
  2923 	// eventually they'll get here again with list!=0, so this check is enough
       
  2924 	if (!list)
       
  2925 		return;
       
  2926 
       
  2927 	TInt index = 0;
       
  2928 	iExtension->FindSLSubCellIndexOrAddL(index, aSubCell);
       
  2929 	iExtension->AtSL(index).iTextLayout = aTextLayout;
       
  2930 	iExtension->AtSL(index).iGraphicLayout = NULL;
       
  2931 	iExtension->AtSL(index).iSubCellType
       
  2932 			= CCCAppCommLauncherCustomListBoxDataExtension::EAknSLText;
       
  2933 
       
  2934 	// For compabitility - needed at least for text wrapping.
       
  2935 	// Beware - some of these WILL be overriden if you got here trough
       
  2936 	// old layout methods like AknListBoxLayouts::SetupFormTextCell()
       
  2937 	// & friends.
       
  2938 	TAknLayoutText t;
       
  2939 	t.LayoutText(list->View()->ItemDrawer()->ItemCellSize(), aTextLayout);
       
  2940 	SetSubCellSizeL(aSubCell, t.TextRect().Size());
       
  2941 	SetSubCellPositionL(aSubCell, t.TextRect().iTl);
       
  2942 	SetSubCellFontL(aSubCell, t.Font());
       
  2943 	SetSubCellAlignmentL(aSubCell, AknLayoutUtils::TextAlignFromId(
       
  2944 			aTextLayout.iJ));
       
  2945 	TInt B = CorrectBaseline(
       
  2946 			list->View()->ItemDrawer()->ItemCellSize().iHeight, aTextLayout.iB,
       
  2947 			aTextLayout.FontId());
       
  2948 	SetSubCellBaselinePosL(aSubCell, B);
       
  2949 	UseScalableLayoutData(ETrue);
       
  2950 	if (iExtension->iMarginRect == TRect::EUninitialized)
       
  2951 		{
       
  2952 		iExtension->iMarginRect = t.TextRect();
       
  2953 		}
       
  2954 	else
       
  2955 		{
       
  2956 		iExtension->iMarginRect.BoundingRect(t.TextRect());
       
  2957 		}
       
  2958 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  2959 	MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal(
       
  2960 			list->View()->ItemDrawer()->Gc());
       
  2961 	if (transApi)
       
  2962 		{
       
  2963 		transApi->SetPosition(MAknListBoxTfxInternal::EListTLMargin,
       
  2964 				iExtension->iMarginRect.iTl);
       
  2965 		TSize size = list->View()->ItemDrawer()->ItemCellSize();
       
  2966 		TPoint br(size.AsPoint() - iExtension->iMarginRect.iBr);
       
  2967 		transApi->SetPosition(MAknListBoxTfxInternal::EListBRMargin, br);
       
  2968 		}
       
  2969 #endif
       
  2970 
       
  2971 	}
       
  2972 
       
  2973 
       
  2974 TInt CCCAppCommLauncherCustomListBoxData::CorrectBaseline(TInt aParentHeight, TInt aBaseline, TInt aFontId)
       
  2975     {
       
  2976     TInt B = aBaseline;
       
  2977 
       
  2978     if( /*TAknFontId::IsEncodedFont(aFontId) &&*/ aFontId != ELayoutEmpty ) // This tells us that the font id has come from scalable layout API
       
  2979         {
       
  2980         TInt b = aBaseline;
       
  2981         if (IsParentRelative(b)) { b = aParentHeight - ELayoutP + b; }
       
  2982 
       
  2983         const CAknLayoutFont *font = AknLayoutUtils::LayoutFontFromId(aFontId);
       
  2984         TInt descent = font->BaselineToTextPaneBottom();
       
  2985 
       
  2986         // calculate distance down from top of parent to bottom of maximal glyph
       
  2987         TInt top2bog = aParentHeight - b;
       
  2988 
       
  2989         // distance down to baseline is distance down to bottom of glyph minus descent
       
  2990         // A further 1 is subtracted to account for the definition of baseline in the
       
  2991         // Series 60 pre-2.8 layout specifications.
       
  2992         B = top2bog - descent - 1;
       
  2993         }
       
  2994 
       
  2995     return B;
       
  2996     }
       
  2997 TBool CCCAppCommLauncherCustomListBoxData::IsParentRelative(TInt aVal)
       
  2998     {
       
  2999     return aVal > ELayoutP-ELayoutPRange && aVal <= ELayoutP;
       
  3000     }
       
  3001 
       
  3002 void CCCAppCommLauncherCustomListBoxData::SetConditionalSubCellL(TInt aSubCell,
       
  3003 		const TAknTextLineLayout &aTextLayout, TInt aAffectedSubCell)
       
  3004 	{
       
  3005 	// iConditionValue of affected subcell (=text subcell, which has different layouts)
       
  3006 	// contains index of graphical subcell, which existence should be checked first.
       
  3007 	// This graphical subcell has in iConditionValue index of graphical subcell,
       
  3008 	// which existence should be checked second etc. Each graphical subcell can
       
  3009 	// affect only to 1 text subcell (or none).
       
  3010 
       
  3011 	// for compabitility - needed at least for text wrapping
       
  3012 	SetNotAlwaysDrawnSubCellL(aSubCell, ETrue);
       
  3013 
       
  3014 	if (!iExtension)
       
  3015 		return;
       
  3016 
       
  3017 	TInt i = 0x01;
       
  3018 	i = i << aSubCell;
       
  3019 	iExtension->iConditionalCells = iExtension->iConditionalCells | i;
       
  3020 
       
  3021 	TInt graphicalIndex = 0;
       
  3022 	if (iExtension->FindSLSubCellIndex(graphicalIndex, aSubCell) != 0)
       
  3023 		return; // subcell not found
       
  3024 	// conditional layoutline can be only added to graphical subcells
       
  3025 	if (iExtension->AtSL(graphicalIndex).iSubCellType
       
  3026 			!= CCCAppCommLauncherCustomListBoxDataExtension::EAknSLGraphic)
       
  3027 		return;
       
  3028 
       
  3029 	TInt textIndex = 0; // index of affected subcell
       
  3030 	if (iExtension->FindSLSubCellIndex(textIndex, aAffectedSubCell) != 0)
       
  3031 		return; // subcell not found
       
  3032 	// affected subcell can only be text subcell
       
  3033 	if (iExtension->AtSL(textIndex).iSubCellType
       
  3034 			== CCCAppCommLauncherCustomListBoxDataExtension::EAknSLGraphic)
       
  3035 		return;
       
  3036 
       
  3037 	TInt gSC = iExtension->AtSL(textIndex).iConditionValue; // text subcell to be added in priority chain
       
  3038 
       
  3039 	while (gSC > -1)
       
  3040 		{
       
  3041 		if (iExtension->FindSLSubCellIndex(textIndex, gSC) != 0)
       
  3042 			return; // subcell not found
       
  3043 		gSC = iExtension->AtSL(textIndex).iConditionValue;
       
  3044 		}
       
  3045 	iExtension->AtSL(textIndex).iConditionValue = aSubCell; // add next subcell to chain
       
  3046 	iExtension->AtSL(graphicalIndex).iTextLayout = aTextLayout;
       
  3047 
       
  3048 	iExtension->CreateColorBitmapsL(SubCellSize(aSubCell));
       
  3049 
       
  3050 	TRect r(SubCellPosition(aSubCell), SubCellSize(aSubCell));
       
  3051 	if (iExtension->iMarginRect == TRect::EUninitialized)
       
  3052 		{
       
  3053 		iExtension->iMarginRect = r;
       
  3054 		}
       
  3055 	else
       
  3056 		{
       
  3057 		iExtension->iMarginRect.BoundingRect(r);
       
  3058 		}
       
  3059 	CEikFormattedCellListBox* list =
       
  3060 			static_cast<CEikFormattedCellListBox*> (iExtension->iControl);
       
  3061 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  3062 	MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal(
       
  3063 			list->View()->ItemDrawer()->Gc());
       
  3064 	if (transApi)
       
  3065 		{
       
  3066 		transApi->SetPosition(MAknListBoxTfxInternal::EListTLMargin,
       
  3067 				iExtension->iMarginRect.iTl);
       
  3068 		TSize size = list->View()->ItemDrawer()->ItemCellSize();
       
  3069 		TPoint br(size.AsPoint() - iExtension->iMarginRect.iBr);
       
  3070 		transApi->SetPosition(MAknListBoxTfxInternal::EListBRMargin, br);
       
  3071 		}
       
  3072 #endif
       
  3073 	}
       
  3074 
       
  3075 // -----------------------------------------------------------------------------
       
  3076 // CCCAppCommLauncherCustomListBoxData::UsesScalableLayoutData
       
  3077 // -----------------------------------------------------------------------------
       
  3078 //
       
  3079 TBool CCCAppCommLauncherCustomListBoxData::UsesScalableLayoutData() const
       
  3080 	{
       
  3081 	if (iExtension)
       
  3082 		return iExtension->iSimpleList;
       
  3083 
       
  3084 	return EFalse;
       
  3085 	}
       
  3086 void CCCAppCommLauncherCustomListBoxData::UseScalableLayoutData(TBool aUse)
       
  3087 	{
       
  3088 	if (iExtension)
       
  3089 		{
       
  3090 		if (!aUse && iExtension->iSimpleList)
       
  3091 			{
       
  3092 			CEikFormattedCellListBox
       
  3093 					* list =
       
  3094 							static_cast<CEikFormattedCellListBox*> (iExtension->iControl);
       
  3095 			MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal(
       
  3096 					list->View()->ItemDrawer()->Gc());
       
  3097 			if (transApi)
       
  3098 				{
       
  3099 				transApi->SetPosition(MAknListBoxTfxInternal::EListTLMargin,
       
  3100 						TPoint(0, 0));
       
  3101 				transApi->SetPosition(MAknListBoxTfxInternal::EListBRMargin,
       
  3102 						TPoint(0, 0));
       
  3103 				}
       
  3104 			}
       
  3105 		iExtension->iSimpleList = aUse;
       
  3106 		}
       
  3107 	}
       
  3108 
       
  3109  void CCCAppCommLauncherCustomListBoxData::SetSubcellUnderlined(
       
  3110 		TBitFlags32 aUnderlinedCells)
       
  3111 	{
       
  3112 	if (iExtension)
       
  3113 		{
       
  3114 		iExtension->iUnderlineFlagSet = ETrue;
       
  3115 		iExtension->iUnderlineFlags = aUnderlinedCells;
       
  3116 		}
       
  3117 	}
       
  3118 
       
  3119 void CCCAppCommLauncherCustomListBoxData::SetUnderlineStyle(
       
  3120 		TListItemProperties aProperties, CWindowGc& aGc, TInt aSubCell) const
       
  3121 	{
       
  3122 	if (!iExtension)
       
  3123 		{
       
  3124 		return;
       
  3125 		}
       
  3126 
       
  3127 	if (!iExtension->iUnderlineFlagSet)
       
  3128 		{
       
  3129 		// underlining is already either on or off and
       
  3130 		// hardcoded off turning will ensure old style
       
  3131 		// behaviour
       
  3132 		return;
       
  3133 		}
       
  3134 
       
  3135 	if (aProperties.IsUnderlined() && iExtension->iUnderlineFlagSet
       
  3136 			&& iExtension->iUnderlineFlags.IsSet(aSubCell))
       
  3137 		{
       
  3138 		aGc.SetUnderlineStyle(EUnderlineOn);
       
  3139 		}
       
  3140 	else
       
  3141 		{
       
  3142 		aGc.SetUnderlineStyle(EUnderlineOff);
       
  3143 		}
       
  3144 	}
       
  3145 
       
  3146 void CCCAppCommLauncherCustomListBoxData::UseHighlightIconSwapping(TBool aUse)
       
  3147 	{
       
  3148 	if (iExtension)
       
  3149 		{
       
  3150 		iExtension->iUseHighligthIconSwapping = aUse;
       
  3151 		}
       
  3152 	}
       
  3153 
       
  3154 TBool CCCAppCommLauncherCustomListBoxData::UseHighlightIconSwapping() const
       
  3155 	{
       
  3156 	if (iExtension)
       
  3157 		{
       
  3158 		return iExtension->iUseHighligthIconSwapping;
       
  3159 		}
       
  3160 	return EFalse;
       
  3161 	}
       
  3162 
       
  3163 // -----------------------------------------------------------------------------
       
  3164 // CCCAppCommLauncherCustomListBoxData::SetStretchableGraphicSubCellL
       
  3165 // -----------------------------------------------------------------------------
       
  3166 //
       
  3167 void CCCAppCommLauncherCustomListBoxData::SetStretchableGraphicSubCellL(
       
  3168 		TInt aSubCell, const TAknWindowComponentLayout& aNormalLayout,
       
  3169 		const TAknWindowComponentLayout& aStretchedLayout)
       
  3170 	{
       
  3171 	if (Layout_Meta_Data::IsLandscapeOrientation()
       
  3172 			&& Layout_Meta_Data::IsListStretchingEnabled()
       
  3173 			&& StretchingEnabled())
       
  3174 		{
       
  3175 		SetGraphicSubCellL(aSubCell, aStretchedLayout.LayoutLine());
       
  3176 		}
       
  3177 	else
       
  3178 		{
       
  3179 		SetGraphicSubCellL(aSubCell, aNormalLayout.LayoutLine());
       
  3180 		}
       
  3181 	}
       
  3182 
       
  3183 // -----------------------------------------------------------------------------
       
  3184 // CCCAppCommLauncherCustomListBoxData::SetStretchableTextSubCellL
       
  3185 // -----------------------------------------------------------------------------
       
  3186 //
       
  3187 void CCCAppCommLauncherCustomListBoxData::SetStretchableTextSubCellL(
       
  3188 		TInt aSubCell, const TAknTextComponentLayout& aNormalLayout,
       
  3189 		const TAknTextComponentLayout& aStretchedLayout)
       
  3190 	{
       
  3191 	if (Layout_Meta_Data::IsLandscapeOrientation()
       
  3192 			&& Layout_Meta_Data::IsListStretchingEnabled()
       
  3193 			&& StretchingEnabled())
       
  3194 		{
       
  3195 		SetTextSubCellL(aSubCell, aStretchedLayout.LayoutLine());
       
  3196 		}
       
  3197 	else
       
  3198 		{
       
  3199 		SetTextSubCellL(aSubCell, aNormalLayout.LayoutLine());
       
  3200 		}
       
  3201 	}
       
  3202 
       
  3203 // -----------------------------------------------------------------------------
       
  3204 // CCCAppCommLauncherCustomListBoxData::SetStretchableConditionalSubCellL
       
  3205 // -----------------------------------------------------------------------------
       
  3206 //
       
  3207 void CCCAppCommLauncherCustomListBoxData::SetStretchableConditionalSubCellL(
       
  3208 		TInt aSubCell, const TAknTextComponentLayout& aNormalLayout,
       
  3209 		const TAknTextComponentLayout& aStretchedLayout, TInt aNormalSubCell,
       
  3210 		TInt aStretchedSubCell)
       
  3211 	{
       
  3212 	if (Layout_Meta_Data::IsLandscapeOrientation()
       
  3213 			&& Layout_Meta_Data::IsListStretchingEnabled()
       
  3214 			&& StretchingEnabled())
       
  3215 		{
       
  3216 		SetConditionalSubCellL(aSubCell, aStretchedLayout.LayoutLine(),
       
  3217 				aStretchedSubCell);
       
  3218 		}
       
  3219 	else
       
  3220 		{
       
  3221 		SetConditionalSubCellL(aSubCell, aNormalLayout.LayoutLine(),
       
  3222 				aNormalSubCell);
       
  3223 		}
       
  3224 	}
       
  3225 
       
  3226 // -----------------------------------------------------------------------------
       
  3227 // CCCAppCommLauncherCustomListBoxData::ResetSLSubCellArray
       
  3228 // -----------------------------------------------------------------------------
       
  3229 //
       
  3230 void CCCAppCommLauncherCustomListBoxData::ResetSLSubCellArray()
       
  3231 	{
       
  3232 	if (!iExtension)
       
  3233 		{
       
  3234 		return;
       
  3235 		}
       
  3236 
       
  3237 	iExtension->iMarginRect = TRect::EUninitialized;
       
  3238 
       
  3239 	UseScalableLayoutData(EFalse);
       
  3240 	iExtension->ResetSLSubCellArray();
       
  3241 		// This function gets called always when size changes, so here is called
       
  3242 		// SetupSkinContextL to update the layout rect of the background skin 
       
  3243 		// context (mainpane rect can change for example if toolbar is hidden.
       
  3244 		TRAP_IGNORE( SetupSkinContextL() );
       
  3245 	}
       
  3246 
       
  3247 // -----------------------------------------------------------------------------
       
  3248 // CCCAppCommLauncherCustomListBoxData::StretchingEnabled
       
  3249 // -----------------------------------------------------------------------------
       
  3250 //
       
  3251 TBool CCCAppCommLauncherCustomListBoxData::StretchingEnabled() const
       
  3252 	{
       
  3253 #ifdef RD_LIST_STRETCH    
       
  3254 	if (!iExtension)
       
  3255 		{
       
  3256 		return EFalse;
       
  3257 		}
       
  3258 
       
  3259 	return iExtension->iStretchingEnabled;
       
  3260 #else
       
  3261 	return EFalse;
       
  3262 #endif // #ifdef RD_LIST_STRETCH        
       
  3263 	}
       
  3264 
       
  3265 #ifdef RD_LIST_STRETCH    
       
  3266 // -----------------------------------------------------------------------------
       
  3267 // CCCAppCommLauncherCustomListBoxData::EnableStretching
       
  3268 // -----------------------------------------------------------------------------
       
  3269 //
       
  3270 void CCCAppCommLauncherCustomListBoxData::EnableStretching(const TBool aEnabled)
       
  3271 	{
       
  3272 	if (!iExtension)
       
  3273 		{
       
  3274 		return;
       
  3275 		}
       
  3276 
       
  3277 	iExtension->iStretchingEnabled = aEnabled;
       
  3278 	}
       
  3279 
       
  3280 // -----------------------------------------------------------------------------
       
  3281 // CCCAppCommLauncherCustomListBoxData::HideSecondRow
       
  3282 // -----------------------------------------------------------------------------
       
  3283 //
       
  3284 void CCCAppCommLauncherCustomListBoxData::HideSecondRow(const TBool aHide)
       
  3285 	{
       
  3286 	if (!iExtension)
       
  3287 		{
       
  3288 		return;
       
  3289 		}
       
  3290 
       
  3291 	iExtension->iHideSecondRow = aHide;
       
  3292 	}
       
  3293 #endif // RD_LIST_STRETCH
       
  3294 // -----------------------------------------------------------------------------
       
  3295 // CCCAppCommLauncherCustomListBoxData::SecondRowHidden
       
  3296 // -----------------------------------------------------------------------------
       
  3297 //
       
  3298 TBool CCCAppCommLauncherCustomListBoxData::SecondRowHidden() const
       
  3299 	{
       
  3300 	if (!iExtension)
       
  3301 		{
       
  3302 		return EFalse;
       
  3303 		}
       
  3304 
       
  3305 	return iExtension->iHideSecondRow;
       
  3306 	}
       
  3307 
       
  3308 // -----------------------------------------------------------------------------
       
  3309 // CCCAppCommLauncherCustomListBoxData::ToggleDropShadows
       
  3310 // -----------------------------------------------------------------------------
       
  3311 //
       
  3312 void CCCAppCommLauncherCustomListBoxData::ToggleDropShadows(const TBool aEnable)
       
  3313 	{
       
  3314 	if (!iExtension)
       
  3315 		{
       
  3316 		return;
       
  3317 		}
       
  3318 	iExtension->iUseDropShadows = aEnable;
       
  3319 	}
       
  3320 
       
  3321 // -----------------------------------------------------------------------------
       
  3322 // CCCAppCommLauncherCustomListBoxData::CheckIfSubCellsIntersect
       
  3323 // -----------------------------------------------------------------------------
       
  3324 //
       
  3325 void CCCAppCommLauncherCustomListBoxData::CheckIfSubCellsIntersect(
       
  3326 		TAknTextLineLayout* aLayouts, TBool* aResults, const TDesC& aText,
       
  3327 		const TRect& aItemRect) const
       
  3328 	{
       
  3329 	TInt subCell = 0;
       
  3330 	TInt subCell2;
       
  3331 	TInt subCellIndex;
       
  3332 	TInt subCellIndex2;
       
  3333 	TInt lastSubCell = Min(KMaxSubCellIndex, LastSubCell());
       
  3334 	TPtrC text;
       
  3335 	TBool isEmpty[KMaxSubCellIndex];
       
  3336 	TBool layoutMirrored = AknLayoutUtils::LayoutMirrored();
       
  3337 
       
  3338 	// cache the empty text states
       
  3339 	while (ETrue)
       
  3340 		{
       
  3341 		if (subCell > lastSubCell)
       
  3342 			{
       
  3343 			break;
       
  3344 			}
       
  3345 
       
  3346 		TextUtils::ColumnText(text, subCell, &aText);
       
  3347 
       
  3348 		if (text == KNullDesC && SubCellIsNotAlwaysDrawn(subCell))
       
  3349 			{
       
  3350 			isEmpty[subCell] = ETrue;
       
  3351 			}
       
  3352 		else
       
  3353 			{
       
  3354 			isEmpty[subCell] = EFalse;
       
  3355 			}
       
  3356 
       
  3357 		++subCell;
       
  3358 		}
       
  3359 
       
  3360 	subCell = 0;
       
  3361 
       
  3362 	while (ETrue)
       
  3363 		{
       
  3364 		if (subCell > lastSubCell)
       
  3365 			{
       
  3366 			break;
       
  3367 			}
       
  3368 
       
  3369 		if (iExtension->FindSLSubCellIndex(subCellIndex, subCell) != 0)
       
  3370 			{
       
  3371 			break;
       
  3372 			}
       
  3373 
       
  3374 		if (isEmpty[subCell])
       
  3375 			{
       
  3376 			++subCell;
       
  3377 			continue;
       
  3378 			}
       
  3379 
       
  3380 		TRect bRect(SubCellPosition(subCell), SubCellSize(subCell));
       
  3381 
       
  3382 		for (subCell2 = subCell + 1; subCell2 <= lastSubCell; ++subCell2)
       
  3383 			{
       
  3384 			if (isEmpty[subCell2])
       
  3385 				{
       
  3386 				continue;
       
  3387 				}
       
  3388 
       
  3389 			if (iExtension->FindSLSubCellIndex(subCellIndex2, subCell2) != 0)
       
  3390 				{
       
  3391 				break;
       
  3392 				}
       
  3393 
       
  3394 			TRect bRect2(SubCellPosition(subCell2), SubCellSize(subCell2));
       
  3395 
       
  3396 			if (bRect.Intersects(bRect2) && !SubCellIsTransparent(subCell)
       
  3397 					&& !SubCellIsTransparent(subCell2))
       
  3398 				{
       
  3399 				aResults[subCell] = ETrue;
       
  3400 
       
  3401 				if (!layoutMirrored)
       
  3402 					{
       
  3403 					bRect.iBr.iX = bRect2.iTl.iX;
       
  3404 					}
       
  3405 				else
       
  3406 					{
       
  3407 					bRect.iTl.iX = bRect2.iBr.iX;
       
  3408 					}
       
  3409 				}
       
  3410 			}
       
  3411 
       
  3412 		if (aResults[subCell])
       
  3413 			{
       
  3414 			if (iExtension->AtSL(subCellIndex).iSubCellType
       
  3415 					== CCCAppCommLauncherCustomListBoxDataExtension::EAknSLText)
       
  3416 				{
       
  3417 				TAknTextLineLayout textLine =
       
  3418 						iExtension->AtSL(subCellIndex).iTextLayout;
       
  3419 
       
  3420 				textLine.iW = bRect.Width();
       
  3421 
       
  3422 				if (!layoutMirrored)
       
  3423 					{
       
  3424 					textLine.ir = aItemRect.iBr.iX - bRect.iBr.iX;
       
  3425 					}
       
  3426 				else
       
  3427 					{
       
  3428 					textLine.il = bRect.iTl.iX - aItemRect.iTl.iX;
       
  3429 					}
       
  3430 
       
  3431 				aLayouts[subCell] = textLine;
       
  3432 				}
       
  3433 			}
       
  3434 
       
  3435 		++subCell;
       
  3436 		}
       
  3437 	}
       
  3438 
       
  3439 // -----------------------------------------------------------------------------
       
  3440 // CCCAppCommLauncherCustomListBoxData::SubCellsMightIntersect
       
  3441 // -----------------------------------------------------------------------------
       
  3442 //
       
  3443 void CCCAppCommLauncherCustomListBoxData::SubCellsMightIntersect(
       
  3444 		const TBool aMightIntersect)
       
  3445 	{
       
  3446 	iExtension->iSubCellsMightIntersect = aMightIntersect;
       
  3447 	}
       
  3448 
       
  3449 void CCCAppCommLauncherCustomListBoxDataExtension::CreateColorBitmapsL()
       
  3450 	{
       
  3451 	if (iColorBmp)
       
  3452 		{
       
  3453 		CreateColorBitmapsL(iColorBmp->SizeInPixels());
       
  3454 		}
       
  3455 	}
       
  3456 
       
  3457 void CCCAppCommLauncherCustomListBoxDataExtension::CreateColorBitmapsL(
       
  3458 		TSize aSize)
       
  3459 	{
       
  3460 	TRgb color, hiliColor;
       
  3461 	TInt error;
       
  3462 	// icon #13	main area	additional list icons	#215
       
  3463 	// icon #16	list highlight	additional list iconsform checkbox, radio button	#215
       
  3464 
       
  3465 	error = AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), color,
       
  3466 			KAknsIIDQsnIconColors, EAknsCIQsnIconColorsCG13);
       
  3467 	if (error)
       
  3468 		return;
       
  3469 
       
  3470 	error = AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), hiliColor,
       
  3471 			KAknsIIDQsnIconColors, EAknsCIQsnIconColorsCG16);
       
  3472 	if (error)
       
  3473 		return;
       
  3474 
       
  3475 	if (iColorBmp && iColorBmp->SizeInPixels() == aSize && color == iIconColor
       
  3476 			&& hiliColor == iHiliIconColor)
       
  3477 		{
       
  3478 		return;
       
  3479 		}
       
  3480 
       
  3481 	iIconColor = color;
       
  3482 	iHiliIconColor = hiliColor;
       
  3483 
       
  3484 	if (!iColorBmp)
       
  3485 		{
       
  3486 		iColorBmp = new (ELeave) CFbsBitmap();
       
  3487 		iColorBmp->Create(aSize,
       
  3488 				CCoeEnv::Static()->ScreenDevice()->DisplayMode());
       
  3489 		}
       
  3490 	else if (iColorBmp->SizeInPixels() != aSize)
       
  3491 		{
       
  3492 		iColorBmp->Resize(aSize);
       
  3493 		}
       
  3494 	if (!iHiliBmp)
       
  3495 		{
       
  3496 		iHiliBmp = new (ELeave) CFbsBitmap();
       
  3497 		iHiliBmp->Create(aSize,
       
  3498 				CCoeEnv::Static()->ScreenDevice()->DisplayMode());
       
  3499 		}
       
  3500 	else if (iHiliBmp->SizeInPixels() != aSize)
       
  3501 		{
       
  3502 		iHiliBmp->Resize(aSize);
       
  3503 		}
       
  3504 
       
  3505 	CFbsBitGc* fbsBitGc = CFbsBitGc::NewL();
       
  3506 	CleanupStack::PushL(fbsBitGc);
       
  3507 
       
  3508 	CFbsBitmapDevice* bmpDevice = CFbsBitmapDevice::NewL(iColorBmp);
       
  3509 	CleanupStack::PushL(bmpDevice);
       
  3510 	fbsBitGc->Activate(bmpDevice);
       
  3511 	fbsBitGc->SetPenStyle(CGraphicsContext::ENullPen);
       
  3512 	fbsBitGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  3513 	fbsBitGc->SetBrushColor(color);
       
  3514 	fbsBitGc->Clear();
       
  3515 	CleanupStack::PopAndDestroy(bmpDevice);
       
  3516 	bmpDevice = NULL;
       
  3517 
       
  3518 	bmpDevice = CFbsBitmapDevice::NewL(iHiliBmp);
       
  3519 	CleanupStack::PushL(bmpDevice);
       
  3520 	fbsBitGc->Activate(bmpDevice);
       
  3521 	fbsBitGc->SetPenStyle(CGraphicsContext::ENullPen);
       
  3522 	fbsBitGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  3523 	fbsBitGc->SetBrushColor(hiliColor);
       
  3524 	fbsBitGc->Clear();
       
  3525 	CleanupStack::PopAndDestroy(bmpDevice);
       
  3526 	bmpDevice = NULL;
       
  3527 
       
  3528 	CleanupStack::PopAndDestroy(fbsBitGc);
       
  3529 	}
       
  3530 
       
  3531 void CCCAppCommLauncherCustomListBoxData::DrawFormattedOld(
       
  3532 		TListItemProperties& aProperties, CWindowGc& aGc, const TDesC* aText,
       
  3533 		const TRect& aItemRect, TBool aHighlight, const TColors& aColors) const
       
  3534 	{
       
  3535 	TRect aRect(aItemRect);
       
  3536 	const TColors *subcellColors = &aColors;
       
  3537 
       
  3538 	TInt lastSubCell = LastSubCell();
       
  3539 	if (lastSubCell == KErrNotFound)
       
  3540 		{
       
  3541 		aGc.UseFont(CEikonEnv::Static()->NormalFont());
       
  3542 		aGc.DrawText(TPtrC(), aRect, 0); // use draw text so that don't need to change pen color/style
       
  3543 		aGc.DiscardFont(); // Release the font cache
       
  3544 		return;
       
  3545 		}
       
  3546 	const CFont* font = SubCellFont(0);
       
  3547 	if (font == NULL)
       
  3548 		{
       
  3549 		font = CEikonEnv::Static()->NormalFont();
       
  3550 		}
       
  3551 
       
  3552 	TInt extraVerticalSpace = (aRect.Height() - font->HeightInPixels());
       
  3553 	TInt baseLineOffset = extraVerticalSpace / 2 + font->AscentInPixels();
       
  3554 	TRect textRect = aRect;
       
  3555 	textRect.iBr.iX = aRect.iTl.iX;
       
  3556 	TInt subcell = 0;
       
  3557 	TInt subcell2 = 0;
       
  3558 	TPtrC text;
       
  3559 	TBool textNull[30];
       
  3560 	TRgb bmpBackColor, bmpForeColor;
       
  3561 	TRect textShadowRect; // For transparent list
       
  3562 	TRgb textShadowColour = AKN_LAF_COLOR_STATIC(215); // Black shadow for item text.
       
  3563 	MAknsControlContext *cc = AknsDrawUtils::ControlContext(Control());
       
  3564 	TBool layoutMirrored = AknLayoutUtils::LayoutMirrored();
       
  3565 	TBool skinEnabled = AknsUtils::AvkonSkinEnabled();
       
  3566 
       
  3567 	if (!cc)
       
  3568 		{
       
  3569 		cc = SkinBackgroundContext();
       
  3570 		}
       
  3571 	TBool linesShown = AknListBoxUtils::ListBoxLinesShown(
       
  3572 			AknsUtils::SkinInstance(), cc);
       
  3573 
       
  3574 	Mem::FillZ(textNull, sizeof(textNull));
       
  3575 
       
  3576 	// cache the text states.
       
  3577 	subcell = 0;
       
  3578 	for (;;)
       
  3579 		{
       
  3580 		if (subcell > lastSubCell)
       
  3581 			{
       
  3582 			break;
       
  3583 			}
       
  3584 
       
  3585 		TextUtils::ColumnText(text, subcell, aText);
       
  3586 		if (text == KNullDesC && SubCellIsNotAlwaysDrawn(subcell))
       
  3587 			{
       
  3588 			textNull[subcell] = ETrue;
       
  3589 			}
       
  3590 
       
  3591 		subcell++;
       
  3592 		}
       
  3593 
       
  3594 	// this loop handles rectangles that are clipped because of other subcells.
       
  3595 	subcell = 0;
       
  3596 
       
  3597 	for (;;)
       
  3598 		{
       
  3599 		if (subcell > lastSubCell)
       
  3600 			{
       
  3601 			break;
       
  3602 			}
       
  3603 
       
  3604 		if (textNull[subcell])
       
  3605 			{
       
  3606 			++subcell;
       
  3607 			continue;
       
  3608 			}
       
  3609 
       
  3610 		TRect bRect(SubCellPosition(subcell), SubCellSize(subcell));
       
  3611 		TMargins m(SubCellMargins(subcell));
       
  3612 		TRect cRect(bRect.iTl + TSize(m.iLeft, m.iTop), bRect.Size() - TSize(
       
  3613 				m.iRight + m.iLeft, m.iBottom + m.iTop));
       
  3614 
       
  3615 		for (subcell2 = subcell + 1; subcell2 <= lastSubCell; subcell2++)
       
  3616 			{
       
  3617 			if (textNull[subcell2])
       
  3618 				{
       
  3619 				continue;
       
  3620 				}
       
  3621 
       
  3622 			// This is called O(N^2) times - Do not put anything extra to it, it'll slow down drawing!
       
  3623 			TRect bRect2(SubCellPosition(subcell2), SubCellSize(subcell2));
       
  3624 			if (cRect.Intersects(bRect2) && bRect.Intersects(bRect2)
       
  3625 					&& !SubCellIsTransparent(subcell) && !SubCellIsTransparent(
       
  3626 					subcell2))
       
  3627 				{
       
  3628 				if (!layoutMirrored)
       
  3629 					{
       
  3630 					cRect.iBr.iX = bRect2.iTl.iX;
       
  3631 					bRect.iBr.iX = bRect2.iTl.iX;
       
  3632 					}
       
  3633 				else
       
  3634 					{
       
  3635 					cRect.iTl.iX = bRect2.iBr.iX;
       
  3636 					bRect.iTl.iX = bRect2.iBr.iX;
       
  3637 					}
       
  3638 				}
       
  3639 			}
       
  3640 		SetSubCellRealTextSize(subcell, cRect.Size());
       
  3641 		SetSubCellRealSize(subcell, bRect.Size());
       
  3642 		subcell++;
       
  3643 		}
       
  3644 
       
  3645 	// This loop does the drawing.    
       
  3646 	aGc.SetPenStyle(CGraphicsContext::ENullPen);
       
  3647 	subcell = 0;
       
  3648 	for (;;)
       
  3649 		{
       
  3650 		if (subcell > lastSubCell)
       
  3651 			{
       
  3652 			break;
       
  3653 			}
       
  3654 
       
  3655 		if (textNull[subcell])
       
  3656 			{
       
  3657 			++subcell;
       
  3658 			continue;
       
  3659 			}
       
  3660 
       
  3661 		// SetPosition, SetSize and margins support
       
  3662 		TRect bRect(SubCellPosition(subcell), SubCellRealSize(subcell));
       
  3663 		TMargins m(SubCellMargins(subcell));
       
  3664 		TRect cRect(bRect.iTl + TSize(m.iLeft, m.iTop), SubCellRealTextSize(
       
  3665 				subcell));
       
  3666 
       
  3667 		if (bRect.iBr.iX == 0)
       
  3668 			{
       
  3669 			++subcell;
       
  3670 			continue;
       
  3671 			}
       
  3672 
       
  3673 		if (layoutMirrored)
       
  3674 			{
       
  3675 			TRect bRect(SubCellPosition(subcell), SubCellSize(subcell));
       
  3676 			TRect cRect2(bRect.iTl + TSize(m.iLeft, m.iTop), bRect.Size()
       
  3677 					- TSize(m.iRight + m.iLeft, m.iBottom + m.iTop));
       
  3678 
       
  3679 			TInt shift = (cRect2.Size() - SubCellRealTextSize(subcell)).iWidth;
       
  3680 			cRect.iTl.iX += shift;
       
  3681 			cRect.iBr.iX += shift;
       
  3682 			}
       
  3683 
       
  3684 		textRect.SetRect(aItemRect.iTl + cRect.iTl, cRect.Size());
       
  3685 
       
  3686 		if (UseSubCellColors(subcell))
       
  3687 			{
       
  3688 			subcellColors = &SubCellColors(subcell);
       
  3689 			}
       
  3690 		else
       
  3691 			{
       
  3692 			subcellColors = &aColors;
       
  3693 			}
       
  3694 
       
  3695 		if (aHighlight)
       
  3696 			{
       
  3697 			aGc.SetPenColor(subcellColors->iHighlightedText);
       
  3698 			aGc.SetBrushColor(subcellColors->iHighlightedBack);
       
  3699 			bmpBackColor = subcellColors->iHighlightedBack;
       
  3700 			bmpForeColor = subcellColors->iHighlightedText;
       
  3701 			if (skinEnabled && iExtension)
       
  3702 				{
       
  3703 				if (iExtension->iHighlightedTextColor != NULL)
       
  3704 					{
       
  3705 					aGc.SetPenColor(iExtension->iHighlightedTextColor);
       
  3706 					bmpForeColor = iExtension->iHighlightedTextColor;
       
  3707 					}
       
  3708 				}
       
  3709 			}
       
  3710 		else
       
  3711 			{
       
  3712 			aGc.SetPenColor(subcellColors->iText);
       
  3713 			aGc.SetBrushColor(subcellColors->iBack);
       
  3714 			bmpBackColor = subcellColors->iBack;
       
  3715 			bmpForeColor = subcellColors->iText;
       
  3716 
       
  3717 			if (skinEnabled && iExtension)
       
  3718 				{
       
  3719 				if (iExtension->iTextColor != NULL)
       
  3720 					{
       
  3721 					aGc.SetPenColor(iExtension->iTextColor);
       
  3722 					bmpForeColor = iExtension->iTextColor;
       
  3723 					}
       
  3724 				}
       
  3725 			}
       
  3726 
       
  3727 		aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
       
  3728 
       
  3729 		// The following draws subcells to textRect
       
  3730 		if (textRect.iBr.iX != textRect.iTl.iX)
       
  3731 			{
       
  3732 			TextUtils::ColumnText(text, subcell, aText);
       
  3733 
       
  3734 			// graphics or text column
       
  3735 			CGraphicsContext::TTextAlign align = SubCellAlignment(subcell);
       
  3736 			if (!SubCellIsGraphics(subcell))
       
  3737 				{
       
  3738 				const CFont* rowAndCellFont = RowAndSubCellFont(
       
  3739 						iExtension->iCurrentlyDrawnItemIndex, subcell);
       
  3740 				const CFont* cellFont = Font(aProperties, subcell);
       
  3741 				const CFont* tempFont = (cellFont) ? cellFont : font;
       
  3742 				const CFont* usedFont = (rowAndCellFont) ? rowAndCellFont
       
  3743 						: tempFont;
       
  3744 				aGc.UseFont(usedFont);
       
  3745 				SetUnderlineStyle(aProperties, aGc, subcell);
       
  3746 
       
  3747 				// baseline calc needed for each cell.
       
  3748 				baseLineOffset = SubCellBaselinePos(subcell);
       
  3749 				baseLineOffset -= cRect.iTl.iY;
       
  3750 				if (!baseLineOffset)
       
  3751 					{
       
  3752 					baseLineOffset = (cRect.Size().iHeight
       
  3753 							- usedFont->HeightInPixels()) / 2
       
  3754 							+ usedFont->AscentInPixels();
       
  3755 					}
       
  3756 
       
  3757 				TBuf<KMaxColumnDataLength + KAknBidiExtraSpacePerLine> clipbuf =
       
  3758 						text.Left(KMaxColumnDataLength);
       
  3759 
       
  3760 				// Note that this potentially modifies the text so its lenght in pixels
       
  3761 				// might increase. Therefore, this should always be done before
       
  3762 				// wrapping/clipping text. In some cases, WordWrapListItem is called
       
  3763 				// before coming here. Is it certain that it is not done for number subcells?
       
  3764 				if (SubCellIsNumberCell(subcell))
       
  3765 					{
       
  3766 					AknTextUtils::LanguageSpecificNumberConversion(clipbuf);
       
  3767 					}
       
  3768 
       
  3769 				TBool clipped(EFalse);
       
  3770 				TInt clipgap = SubCellTextClipGap(subcell);
       
  3771 
       
  3772 				if (iExtension->iUseLogicalToVisualConversion && subcell
       
  3773 						!= iExtension->iFirstWordWrappedSubcellIndex && subcell
       
  3774 						!= iExtension->iSecondWordWrappedSubcellIndex)
       
  3775 					{
       
  3776 					TInt maxClipWidth = textRect.Size().iWidth + clipgap;
       
  3777 
       
  3778 					clipped = AknBidiTextUtils::ConvertToVisualAndClip(
       
  3779 							text.Left(KMaxColumnDataLength), clipbuf,
       
  3780 							*usedFont, textRect.Size().iWidth, maxClipWidth);
       
  3781 					}
       
  3782 
       
  3783 				if (clipped)
       
  3784 					{
       
  3785 					if (!layoutMirrored)
       
  3786 						{
       
  3787 						textRect.iBr.iX += clipgap;
       
  3788 						}
       
  3789 					else
       
  3790 						{
       
  3791 						textRect.iTl.iX -= clipgap;
       
  3792 						}
       
  3793 					}
       
  3794 
       
  3795 				if (aHighlight)
       
  3796 					{
       
  3797 					if (clipped)
       
  3798 						{
       
  3799 						iExtension->iClippedSubcells |= (1 << subcell);
       
  3800 						}
       
  3801 					else
       
  3802 						{
       
  3803 						iExtension->iClippedSubcells &= ~(1 << subcell);
       
  3804 						}
       
  3805 
       
  3806 					if (iExtension->iUseClippedByWrap) // override if already clipped
       
  3807 						{
       
  3808 						iExtension->iClippedSubcells
       
  3809 								= iExtension->iClippedByWrap;
       
  3810 						}
       
  3811 					}
       
  3812 
       
  3813 				CAknMarqueeControl* marquee =
       
  3814 						subcell == 1 ? iExtension->iMarquee
       
  3815 								: iExtension->i2ndLineMarquee;
       
  3816 
       
  3817 				TBool
       
  3818 						marqueeDisabled =
       
  3819 								static_cast<CEikListBox*> (Control())->View()->ItemDrawer()->Flags()
       
  3820 										& CListItemDrawer::EDisableMarquee;
       
  3821 
       
  3822 				if (aHighlight && iExtension->IsMarqueeOn() && clipped
       
  3823 						&& !marqueeDisabled)
       
  3824 					{
       
  3825 					// Let marquee know if it needs to do bidi conversion.
       
  3826 					marquee->UseLogicalToVisualConversion(clipped);
       
  3827 
       
  3828 					if (marquee->DrawText(aGc, textRect, text, baseLineOffset,
       
  3829 							align, *usedFont))
       
  3830 						{
       
  3831 						// All the loops have been executed -> the text needs to be truncated.
       
  3832 						aGc.DrawText(clipbuf, textRect, baseLineOffset, align,
       
  3833 								0);
       
  3834 						}
       
  3835 					}
       
  3836 				else
       
  3837 					{
       
  3838 					if (marquee && marqueeDisabled)
       
  3839 						{
       
  3840 						marquee->Stop();
       
  3841 						}
       
  3842 
       
  3843 					if (IsBackgroundDrawingEnabled())
       
  3844 						{
       
  3845 						aGc.DrawText(clipbuf, textRect, baseLineOffset, align,
       
  3846 								0);
       
  3847 						}
       
  3848 					else // "Transparent" list, draw text shadow first, then the actual text.
       
  3849 						{
       
  3850 						textShadowRect = textRect;
       
  3851 						textShadowRect.Move(1, 1);
       
  3852 						aGc.SetPenColor(textShadowColour);
       
  3853 						aGc.DrawText(clipbuf, textShadowRect, baseLineOffset,
       
  3854 								align, 0);
       
  3855 						if (aHighlight)
       
  3856 							{
       
  3857 							aGc.SetPenColor(subcellColors->iHighlightedText);
       
  3858 							}
       
  3859 						else
       
  3860 							{
       
  3861 							aGc.SetPenColor(subcellColors->iText);
       
  3862 							}
       
  3863 						aGc.DrawText(clipbuf, textRect, baseLineOffset, align,
       
  3864 								0);
       
  3865 						}
       
  3866 					}
       
  3867 
       
  3868 				if (iExtension->iPictoInterface)
       
  3869 					{
       
  3870 					iExtension->iPictoInterface->Interface()->DrawPictographsInText(
       
  3871 							aGc, *usedFont, clipbuf, textRect, baseLineOffset,
       
  3872 							align, 0);
       
  3873 					}
       
  3874 				// disable underline after first text.
       
  3875 				// at least phonebook uses this. See SetSubcellUnderlined to override
       
  3876 				aGc.SetUnderlineStyle(EUnderlineOff);
       
  3877 				aGc.DiscardFont(); // Release the font cache
       
  3878 				}
       
  3879 			else // Graphics subcell
       
  3880 				{
       
  3881 				TLex lex(text);
       
  3882 				TInt index;
       
  3883 				//__ASSERT_ALWAYS(lex.Val(index)==KErrNone,Panic(EAknPanicFormattedCellListInvalidBitmapIndex));
       
  3884 				//__ASSERT_DEBUG(iIconArray, Panic(EAknPanicOutOfRange));
       
  3885 				if (index == KColorIconFlag)
       
  3886 					index = KColorIconIdx;
       
  3887 				//__ASSERT_DEBUG((index>=0 && index<iIconArray->Count()),Panic(EAknPanicFormattedCellListInvalidBitmapIndex));
       
  3888 				TRect bmpRect;
       
  3889 				bmpRect.iTl = textRect.iTl;
       
  3890 
       
  3891 				if (index >= 0 && iIconArray)
       
  3892 					{
       
  3893 					CGulIcon* icon = (*iIconArray)[index];
       
  3894 					CFbsBitmap* bitmap = icon->Bitmap();
       
  3895 
       
  3896 					if (iExtension)
       
  3897 						{
       
  3898 						TInt w, h;
       
  3899 						TSize sz = bitmap->SizeInPixels();
       
  3900 
       
  3901 						w = iExtension->iSubCellIconSize[subcell].iWidth;
       
  3902 						h = iExtension->iSubCellIconSize[subcell].iHeight;
       
  3903 
       
  3904 						if (h != 0 && w != 0 && !(sz.iWidth == w || sz.iHeight
       
  3905 								== h))
       
  3906 							{
       
  3907 							AknIconUtils::SetSize(bitmap,
       
  3908 									iExtension->iSubCellIconSize[subcell],
       
  3909 									EAspectRatioPreservedAndUnusedSpaceRemoved);
       
  3910 							}
       
  3911 						else if (sz.iWidth == 0 || sz.iHeight == 0) // check if size is set at all
       
  3912 							{
       
  3913 							// just in case fallback
       
  3914 							AknIconUtils::SetSize(bitmap, textRect.Size(),
       
  3915 									EAspectRatioPreservedAndUnusedSpaceRemoved);
       
  3916 							}
       
  3917 						}
       
  3918 
       
  3919 					TSize size = bitmap->SizeInPixels();
       
  3920 
       
  3921 					if (size.iWidth > textRect.Size().iWidth)
       
  3922 						{
       
  3923 						size.iWidth = textRect.Size().iWidth;
       
  3924 						}
       
  3925 
       
  3926 					if (size.iHeight > textRect.Size().iHeight)
       
  3927 						{
       
  3928 						size.iHeight = textRect.Size().iHeight;
       
  3929 						}
       
  3930 
       
  3931 					TPoint bmpPos = textRect.iTl;
       
  3932 					bmpPos.iY += (textRect.Height() - size.iHeight) >> 1;
       
  3933 					switch (align)
       
  3934 						{
       
  3935 						case ELeft:
       
  3936 							break;
       
  3937 						case ECenter:
       
  3938 							bmpPos.iX += (textRect.Width() - size.iWidth) >> 1;
       
  3939 							break;
       
  3940 						case ERight:
       
  3941 							bmpPos.iX = textRect.iBr.iX - size.iWidth;
       
  3942 							break;
       
  3943 						}
       
  3944 					bmpRect = TRect(bmpPos, size);
       
  3945 					TPoint posInBitmap = TPoint(0, 0) + bitmap->SizeInPixels()
       
  3946 							- textRect.Size();
       
  3947 					posInBitmap.iX >> 1;
       
  3948 					posInBitmap.iY >> 1;
       
  3949 					if (posInBitmap.iX < 0)
       
  3950 						{
       
  3951 						posInBitmap.iX = 0;
       
  3952 						}
       
  3953 					if (posInBitmap.iY < 0)
       
  3954 						{
       
  3955 						posInBitmap.iY = 0;
       
  3956 						}
       
  3957 					TRect rect(posInBitmap, textRect.Size());
       
  3958 
       
  3959 					if (icon->Mask())
       
  3960 						{
       
  3961 						aGc.BitBltMasked(bmpPos, bitmap, rect, icon->Mask(),
       
  3962 								ETrue);
       
  3963 						}
       
  3964 					else
       
  3965 						{
       
  3966 						aGc.BitBlt(bmpPos, bitmap, rect);
       
  3967 						}
       
  3968 					}
       
  3969 				aGc.SetPenStyle(CGraphicsContext::ESolidPen);
       
  3970 				}
       
  3971 			}
       
  3972 		aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  3973 		++subcell;
       
  3974 		}
       
  3975 
       
  3976 	// Clear information of wordwrapped and bidi-reordered subcells.
       
  3977 	const_cast<CCCAppCommLauncherCustomListBoxData*> (this)-> SetWordWrappedSubcellIndices(
       
  3978 			-1, -1);
       
  3979 	}
       
  3980 
       
  3981 void CCCAppCommLauncherCustomListBoxData::SetClippedByWrap(
       
  3982 		TUint32 aClippedCells, TBool aUseClippedByWrap)
       
  3983 	{
       
  3984 	if (iExtension)
       
  3985 		{
       
  3986 		iExtension->iClippedByWrap = aClippedCells;
       
  3987 		iExtension->iUseClippedByWrap = aUseClippedByWrap;
       
  3988 		}
       
  3989 	}
       
  3990 
       
  3991  TUint32 CCCAppCommLauncherCustomListBoxData::CurrentItemTextWasClipped() const
       
  3992 	{
       
  3993 	return iExtension ? iExtension->iClippedSubcells : 0;
       
  3994 	}
       
  3995 
       
  3996 TBool CCCAppCommLauncherCustomListBoxData::KineticScrollingEnabled() const
       
  3997 	{
       
  3998 	if (iExtension)
       
  3999 		{
       
  4000 		return iExtension->iKineticScrolling;
       
  4001 		}
       
  4002 	return EFalse;
       
  4003 	}
       
  4004 
       
  4005 CEikListBox* CCCAppCommLauncherCustomListBoxData::ListBox() const
       
  4006 	{
       
  4007 	if (iExtension && iExtension->iControl)
       
  4008 		{
       
  4009 		return static_cast<CEikListBox*> (iExtension->iControl);
       
  4010 		}
       
  4011 	return NULL;
       
  4012 	}
       
  4013 
       
  4014 // End of File
       
  4015