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