uifw/eikctl/src/EIKCLB.CPP
changeset 0 2f259fa3e83a
child 7 08e69e956a8c
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 1997-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 <barsread.h>
       
    20 #include <gdi.h>
       
    21 #include <gulicon.h>
       
    22 #include <gulutil.h>
       
    23 
       
    24 #include <eikenv.h>
       
    25 #include <eikclbd.h>
       
    26 #include <eikclb.h>
       
    27 #include <eiklbi.h>
       
    28 #include <eiktxlbm.h>
       
    29 #include <eikedwin.h>
       
    30 #include <eiklbv.h>
       
    31 #include <AknUtils.h>
       
    32 #include <eiksfont.h>
       
    33 #include <AknsDrawUtils.h>
       
    34 #include <AknsControlContext.h>
       
    35 #include <aknlists.h>
       
    36 #include <eikpanic.h>
       
    37 #include <eikcoctlpanic.h>
       
    38 #include <aknlayoutscalable_avkon.cdl.h>
       
    39 
       
    40 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
    41 #include <aknlistloadertfx.h>
       
    42 #include <aknlistboxtfxinternal.h>
       
    43 #endif //RD_UI_TRANSITION_EFFECTS_LIST
       
    44 
       
    45 
       
    46 #include <AknTasHook.h>
       
    47 
       
    48 #include "akntrace.h"
       
    49 //
       
    50 // Class CEikColumnListBox
       
    51 //
       
    52 
       
    53 EXPORT_C CEikColumnListBox::CEikColumnListBox()
       
    54 //
       
    55 //    C'tor
       
    56 //
       
    57     {
       
    58     __DECLARE_NAME(_S("CEikColumnListBox"));
       
    59     AKNTASHOOK_ADD( this, "CEikColumnListBox" );
       
    60     }
       
    61 
       
    62 EXPORT_C void CEikColumnListBox::CreateModelL()
       
    63     {
       
    64     _AKNTRACE_FUNC_ENTER;
       
    65     CTextListBoxModel *model = new(ELeave) CTextListBoxModel;
       
    66     iModel = model;
       
    67     _AKNTRACE_FUNC_EXIT;
       
    68     }
       
    69 
       
    70 EXPORT_C void CEikColumnListBox::ConstructL(const CCoeControl* aParent,TInt aFlags)
       
    71 //
       
    72 //    Defered constructor
       
    73 //
       
    74     {
       
    75     _AKNTRACE_FUNC_ENTER;
       
    76     CreateModelL();
       
    77     ((CTextListBoxModel*)iModel)->ConstructL();
       
    78 
       
    79     //CTextListBoxModel* model=new(ELeave) CTextListBoxModel;
       
    80     //iModel=model;
       
    81     CreateItemDrawerL();
       
    82     iItemDrawer->SetDrawMark(EFalse);
       
    83 
       
    84     EnableExtendedDrawingL();
       
    85 
       
    86     CEikListBox::ConstructL(aParent,aFlags);
       
    87 
       
    88     _AKNTRACE_FUNC_EXIT;
       
    89     }
       
    90 
       
    91 
       
    92 EXPORT_C TTypeUid::Ptr CEikColumnListBox::MopSupplyObject(TTypeUid aId)
       
    93     {
       
    94     if (aId.iUid == MAknsControlContext::ETypeId)
       
    95         {
       
    96         return MAknsControlContext::SupplyMopObject( aId, ItemDrawer()->ColumnData()->SkinBackgroundContext() );
       
    97         }
       
    98     return CEikTextListBox::MopSupplyObject(aId);
       
    99     }
       
   100 
       
   101 EXPORT_C void CEikColumnListBox::ConstructFromResourceL(TResourceReader& aReader)
       
   102 //
       
   103 //    Override base classes resource contructor to provide column model and viewer
       
   104 //
       
   105     {
       
   106     _AKNTRACE_FUNC_ENTER;
       
   107 
       
   108     RestoreCommonListBoxPropertiesL(aReader);
       
   109     iRequiredCellCharWidth=aReader.ReadInt16();
       
   110     //iModel=new(ELeave) CColumnListBoxModel;
       
   111     CreateModelL();
       
   112     //   iModel=new(ELeave) CTextListBoxModel;
       
   113     TInt array_id=aReader.ReadInt32();
       
   114     if (!array_id)
       
   115         {
       
   116         //((CColumnListBoxModel*)iModel)->ConstructL();
       
   117         ((CTextListBoxModel*)iModel)->ConstructL();
       
   118         }
       
   119     else
       
   120         {
       
   121         CDesCArray* desArray=iCoeEnv->ReadDesCArrayResourceL(array_id);
       
   122         CleanupStack::PushL(desArray);
       
   123         //((CColumnListBoxModel*)iModel)->ConstructL(desArray);
       
   124         ((CTextListBoxModel*)iModel)->ConstructL(desArray);
       
   125         CleanupStack::Pop();
       
   126         }
       
   127     // iItemDrawer=new(ELeave) CColumnListBoxItemDrawer((CColumnListBoxModel*)iModel,iEikonEnv->NormalFont());
       
   128     CreateItemDrawerL();
       
   129     iItemDrawer->SetDrawMark(EFalse);
       
   130 
       
   131     EnableExtendedDrawingL();
       
   132 
       
   133     ((CColumnListBoxItemDrawer*)iItemDrawer)->SetCellWidthInChars(iRequiredCellCharWidth);
       
   134     CreateViewL();
       
   135 
       
   136     _AKNTRACE_FUNC_EXIT;
       
   137     }
       
   138 
       
   139 /**
       
   140 * Note that it must be possible to call this method multiple times.
       
   141 */
       
   142 EXPORT_C void CEikColumnListBox::EnableExtendedDrawingL()
       
   143     {
       
   144     _AKNTRACE_FUNC_ENTER;
       
   145     // Assert that the item drawer has been created before calling this method.
       
   146     __ASSERT_DEBUG( ItemDrawer() && ItemDrawer()->ColumnData(),
       
   147                     User::Panic( _L("EIKCTL"), EEikPanicListBoxItemDrawerNotCreated ) );
       
   148 
       
   149     CColumnListBoxData* data = ItemDrawer()->ColumnData();
       
   150 
       
   151     data->SetControl( this );
       
   152     // Can be created only after the control has been set.
       
   153     data->CreatePictographInterfaceL();
       
   154     // Can be created only after the control has been set.
       
   155     data->CreateMarqueeControlL();
       
   156 
       
   157     _AKNTRACE_FUNC_EXIT;
       
   158     }
       
   159 
       
   160 EXPORT_C void CEikColumnListBox::CreateItemDrawerL()
       
   161     {
       
   162     _AKNTRACE_FUNC_ENTER;
       
   163 
       
   164     CColumnListBoxData* columnData=CColumnListBoxData::NewL(/*CCoeEnv::Static()->ScreenDevice(), this*/);
       
   165     CleanupStack::PushL( columnData );
       
   166     iItemDrawer=new(ELeave) CColumnListBoxItemDrawer(Model(), iEikonEnv->NormalFont(), columnData);
       
   167     CleanupStack::Pop();
       
   168 
       
   169     _AKNTRACE_FUNC_EXIT;
       
   170     }
       
   171 
       
   172 EXPORT_C CTextListBoxModel* CEikColumnListBox::Model() const
       
   173     {
       
   174     //return(CColumnListBoxModel*)iModel;
       
   175     return(CTextListBoxModel*)iModel;
       
   176     }
       
   177 
       
   178 EXPORT_C CColumnListBoxItemDrawer* CEikColumnListBox::ItemDrawer() const
       
   179     {
       
   180     return (CColumnListBoxItemDrawer*) iItemDrawer;
       
   181     }
       
   182 
       
   183 /**
       
   184 * Creates an item editor in column aColumn, if one does not already exist, and
       
   185 * starts editing the current item up to a maximum length of aMaxLength characters.
       
   186 *
       
   187 * @since ER5U
       
   188 */
       
   189 EXPORT_C void CEikColumnListBox::EditItemL(TInt aColumn, TInt aMaxLength)
       
   190     // Start editing given column listbox item
       
   191     {
       
   192     _AKNTRACE_FUNC_ENTER;
       
   193 
       
   194     // if not a bitmap column and the extension exists
       
   195     if (!STATIC_CAST(CColumnListBoxItemDrawer*,iItemDrawer)->ColumnData()->ColumnIsGraphics(aColumn))
       
   196         {
       
   197         MEikListBoxEditor* editor=ItemEditor();
       
   198         if (!editor)
       
   199             {
       
   200             SetItemEditor(new (ELeave) CEikColumnListBoxEditor(Model()));
       
   201             const TInt index=View()->CurrentItemIndex();
       
   202             TRect rect(View()->ItemPos(index),View()->ItemSize());
       
   203             if (STATIC_CAST(CColumnListBoxItemDrawer*,iItemDrawer)->ColumnData()->MakeColumnRect(aColumn,rect))
       
   204                 {
       
   205                 SetReasonForFocusLostL(EFocusLostToInternalEditor);
       
   206                 STATIC_CAST(CEikColumnListBoxEditor*,ItemEditor())->ConstructL(aColumn);
       
   207                 ItemEditor()->StartEditingL(*this,rect,index,aMaxLength );
       
   208                 SetReasonForFocusLostL(EFocusLostToExternalControl);
       
   209                 }
       
   210             }
       
   211         }
       
   212 
       
   213     _AKNTRACE_FUNC_EXIT;
       
   214     }
       
   215 
       
   216 /**
       
   217 * Gets the list of logical colors employed in the drawing of the control,
       
   218 * paired with an explanation of how they are used. Appends the list to aColorUseList.
       
   219 *
       
   220 * @since ER5U
       
   221 */
       
   222 EXPORT_C void CEikColumnListBox::GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const
       
   223     {
       
   224     CEikTextListBox::GetColorUseListL(aColorUseList);
       
   225     }
       
   226 
       
   227 /**
       
   228 * Handles a change to the control's resources of type aType
       
   229 * which are shared across the environment, e.g. colors or fonts.
       
   230 *
       
   231 * @since ER5U
       
   232 */
       
   233 EXPORT_C void CEikColumnListBox::HandleResourceChange(TInt aType)
       
   234     {
       
   235     _AKNTRACE( "[%s][%s] aType = %d", "CEikColumnListBox", __FUNCTION__, aType );
       
   236     // first update ESS text colors
       
   237     if( aType == KAknsMessageSkinChange || aType == KEikDynamicLayoutVariantSwitch)
       
   238         {
       
   239         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   240         TRgb color;
       
   241 
       
   242         // set ESS text color
       
   243         TInt error = AknsUtils::GetCachedColor( skin,
       
   244                                                 color,
       
   245                                                 KAknsIIDQsnTextColors,
       
   246                                                 EAknsCIQsnTextColorsCG6 );
       
   247         if ( !error )
       
   248             {
       
   249             ItemDrawer()->ColumnData()->SetESSTextColor( color );
       
   250             }
       
   251 
       
   252         // set ESS highlighted text color
       
   253         error = AknsUtils::GetCachedColor( skin,
       
   254                                            color,
       
   255                                            KAknsIIDQsnTextColors,
       
   256                                            EAknsCIQsnTextColorsCG10 );
       
   257         if ( !error )
       
   258             {
       
   259             ItemDrawer()->ColumnData()->SetESSHighlightedTextColor( color );
       
   260             }
       
   261         }
       
   262 
       
   263     if ( aType == KEikDynamicLayoutVariantSwitch )
       
   264         {
       
   265         TRAP_IGNORE( ItemDrawer()->ColumnData()->SetupSkinContextL() );
       
   266         }
       
   267 
       
   268     CEikTextListBox::HandleResourceChange(aType);
       
   269     if ( aType == KEikDynamicLayoutVariantSwitch )
       
   270         {
       
   271         SizeChanged();  // is this really needed here ?
       
   272         }
       
   273 
       
   274     ItemDrawer()->ColumnData()->HandleResourceChange( aType );
       
   275     }
       
   276 
       
   277 EXPORT_C void CEikColumnListBox::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
   278     {
       
   279     CEikTextListBox::HandlePointerEventL(aPointerEvent);
       
   280     }
       
   281 
       
   282 EXPORT_C void* CEikColumnListBox::ExtensionInterface( TUid /*aInterface*/ )
       
   283     {
       
   284     return NULL;
       
   285     }
       
   286 
       
   287 EXPORT_C void CEikColumnListBox::CEikListBox_Reserved()
       
   288     {
       
   289     }
       
   290 
       
   291 EXPORT_C CListBoxView* CEikColumnListBox::MakeViewClassInstanceL()
       
   292     {
       
   293     return (new(ELeave) CColumnListBoxView);
       
   294     }
       
   295 
       
   296 
       
   297 // This helper function sets icon sizes for visible list items.
       
   298 void CEikColumnListBox::SetIconSizes()
       
   299     {
       
   300     // No icon size setting when kinetic scrolling enabled
       
   301     if ( ItemDrawer()->ColumnData()->KineticScrollingEnabled() )
       
   302         {
       
   303         return;
       
   304         }
       
   305 
       
   306     // if you modify this, check eikfrlb.cpp also
       
   307     if (!IsReadyToDraw())
       
   308         {
       
   309         return; // can't access listdata yet
       
   310         }
       
   311 
       
   312     TInt numOfItems = Model()->NumberOfItems();
       
   313     // we have a filtered list, and it's item count might not be correct
       
   314     // since this is called when filtered model and text list box model
       
   315     // have yet not synced their item count
       
   316     if ( Model()->MatchableTextArray() )  // read as: if ( HaveFilter() )
       
   317         {
       
   318         // so we need to use this ugly hack
       
   319         TInt n = Model()->MatchableTextArray()->MdcaCount();
       
   320         numOfItems = n > numOfItems ? numOfItems : n;
       
   321         }
       
   322 
       
   323     if (numOfItems == 0) // no need to parse anything
       
   324         return;
       
   325 
       
   326     CArrayPtr<CGulIcon>* icons = ItemDrawer()->ColumnData()->IconArray();
       
   327 
       
   328     if (!icons || icons->Count() == 0) // no icons set yet
       
   329         {
       
   330         return;
       
   331         }
       
   332 
       
   333     TPtrC iconText;
       
   334     TInt iconIndex;
       
   335     TSize iconSize(0,0);
       
   336 
       
   337     for (TInt row=View()->TopItemIndex(); row <= View()->BottomItemIndex(); row++)
       
   338         {
       
   339         if (row >= numOfItems)
       
   340             {
       
   341             continue; // grid may have bottomitemindex bigger than item count
       
   342             }
       
   343         const TDesC &txt = Model()->ItemText(row);
       
   344 
       
   345         TBool textValid(ETrue);
       
   346         for (TInt subCell=0; subCell<6; subCell++)
       
   347             {
       
   348             iconSize = ItemDrawer()->ColumnData()->GetSubCellIconSize(subCell);
       
   349 
       
   350             // only those subcells that have icons, have also icon size set
       
   351             if (iconSize.iWidth == 0 || iconSize.iHeight == 0)
       
   352                 {
       
   353                 continue; // no need to set icon size
       
   354                 }
       
   355             TextUtils::ColumnText(iconText, subCell, &txt); // get icon index(text)
       
   356             /*
       
   357             * it is possible, that we get something like  24037K/24M
       
   358             * as iconText. iconLex will happily then return 24037 as value
       
   359             * and code crashes when trying to access icon 24037 in
       
   360             * icon array
       
   361             */
       
   362 
       
   363             textValid = ETrue;
       
   364             for ( TInt i = 0; i < iconText.Length(); i++ )
       
   365                 {
       
   366                 TChar c(iconText[i]);
       
   367                 if (! c.IsDigit())
       
   368                     {
       
   369                     textValid = EFalse;
       
   370                     break;
       
   371                     }
       
   372                 }
       
   373             if ( !textValid )
       
   374                 {
       
   375                 continue;
       
   376                 }
       
   377 
       
   378             TLex iconLex(iconText);
       
   379 
       
   380             if (iconLex.Val(iconIndex) != KErrNone)
       
   381                 {
       
   382                 iconIndex = -1;
       
   383                 }
       
   384 
       
   385             CGulIcon *icon;
       
   386             CFbsBitmap *bitmap;
       
   387             TInt realIndex;
       
   388 
       
   389             while(iconIndex >= 0)
       
   390                 {
       
   391                 if (iconIndex > 0xffff)
       
   392                     {
       
   393                     realIndex = iconIndex >> 16; // first set highlight icon
       
   394                     iconIndex = iconIndex & 0xffff;
       
   395                     }
       
   396                 else
       
   397                     {
       
   398                     realIndex = iconIndex;
       
   399                     iconIndex = -1;
       
   400                     }
       
   401 
       
   402                 if ( realIndex > icons->Count() -1 )
       
   403                     {
       
   404                     break;
       
   405                     }
       
   406 
       
   407                 icon = (*icons)[realIndex];
       
   408                 if (!icon)
       
   409                     {
       
   410                     break;
       
   411                     }
       
   412                 bitmap = icon->Bitmap();
       
   413                 if (!bitmap)
       
   414                     {
       
   415                     break;
       
   416                     }
       
   417                 /* note, that SetSize() must be called with
       
   418                 *  EAspectRatioPreservedAndUnusedSpaceRemoved,
       
   419                 *  otherwise centering/aligning code in CColumnListBoxData::Draw()
       
   420                 *  will not work. Default EAspectRatioPreserved parameter
       
   421                 *  will fill icon with blank extra space, and icon will then
       
   422                 *  be exactly same size as space reserved for it. Extra blank
       
   423                 *  space would be added to right side of the icon.
       
   424                 */
       
   425                 AknIconUtils::SetSize( bitmap,
       
   426                                        iconSize,
       
   427                                        EAspectRatioPreservedAndUnusedSpaceRemoved );
       
   428                 }
       
   429 
       
   430             /*switch(1)
       
   431                 {
       
   432                 case 1:
       
   433                 default:
       
   434                     if ( iconIndex <0 || iconIndex > icons->Count() -1 )
       
   435                         {
       
   436                         break;
       
   437                         }
       
   438 
       
   439                     icon = (*icons)[iconIndex];
       
   440                     if (!icon)
       
   441                         {
       
   442                         break;
       
   443                         }
       
   444                     bitmap = icon->Bitmap();
       
   445                     if (!bitmap)
       
   446                         {
       
   447                         break;
       
   448                         }*/
       
   449                     /* note, that SetSize() must be called with
       
   450                     *  EAspectRatioPreservedAndUnusedSpaceRemoved,
       
   451                     *  otherwise centering/aligning code in CColumnListBoxData::Draw()
       
   452                     *  will not work. Default EAspectRatioPreserved parameter
       
   453                     *  will fill icon with blank extra space, and icon will then
       
   454                     *  be exactly same size as space reserved for it. Extra blank
       
   455                     *  space would be added to right side of the icon.
       
   456                     */
       
   457                     //AknIconUtils::SetSize( bitmap,
       
   458                     //                       iconSize,
       
   459                     //                       EAspectRatioPreservedAndUnusedSpaceRemoved );
       
   460                 //}
       
   461             } // end subCell for
       
   462         } // end row for
       
   463     }
       
   464 
       
   465 EXPORT_C void CEikColumnListBox::FocusChanged( TDrawNow aDrawNow )
       
   466     {
       
   467     _AKNTRACE( "[%s][%s][%d].", "CEikColumnListBox", __FUNCTION__, __LINE__ );
       
   468     CEikTextListBox::FocusChanged( aDrawNow );
       
   469 
       
   470     // Data needs focus change information to control animations.
       
   471     if( IsFocused() )
       
   472         {
       
   473         ItemDrawer()->ColumnData()->FocusGained();
       
   474         }
       
   475     else
       
   476         {
       
   477         ItemDrawer()->ColumnData()->FocusLost();
       
   478         }
       
   479     }
       
   480 
       
   481 #ifdef RD_LIST_STRETCH
       
   482 EXPORT_C void CEikColumnListBox::EnableStretching( const TBool aEnabled )
       
   483     {
       
   484     if ( ItemDrawer()->ColumnData()->StretchingEnabled() != aEnabled )
       
   485         {
       
   486         ItemDrawer()->ColumnData()->EnableStretching( aEnabled );
       
   487         SizeChanged();
       
   488         }
       
   489     }
       
   490 #else
       
   491 EXPORT_C void CEikColumnListBox::EnableStretching( const TBool /*aEnabled*/ )
       
   492     {
       
   493     }
       
   494 #endif // RD_LIST_STRETCH
       
   495 
       
   496 //
       
   497 //    Class CColumnListBoxItemDrawer
       
   498 //
       
   499 
       
   500 EXPORT_C CColumnListBoxItemDrawer::CColumnListBoxItemDrawer() {}
       
   501 EXPORT_C CColumnListBoxItemDrawer::CColumnListBoxItemDrawer(MTextListBoxModel* aTextListBoxModel,
       
   502                                                             const CFont* aFont,
       
   503                                                             CColumnListBoxData* aColumnData)
       
   504     : CTextListItemDrawer(aTextListBoxModel, aFont)
       
   505     {
       
   506     __DECLARE_NAME(_S("CColumnListBoxItemDrawer"));
       
   507     SetData(aColumnData);
       
   508     }
       
   509 
       
   510 EXPORT_C CColumnListBoxItemDrawer::~CColumnListBoxItemDrawer()
       
   511     {
       
   512     delete iPropertyArray;
       
   513     }
       
   514 
       
   515 EXPORT_C TSize CColumnListBoxItemDrawer::MinimumCellSize() const
       
   516     {
       
   517     _AKNTRACE_FUNC_ENTER;
       
   518     CColumnListBoxData* data=ColumnData();
       
   519     const TInt columns=data->LastColumn();
       
   520     if (columns==-1)
       
   521         {
       
   522         _AKNTRACE( "[%s][%s][%d] return.", "CColumnListBoxItemDrawer", __FUNCTION__, __LINE__ );
       
   523         return CTextListItemDrawer::MinimumCellSize();
       
   524         }
       
   525     TInt width=0;
       
   526     TInt height=0;
       
   527     TBool graphicsColumn=EFalse;
       
   528     for (TInt ii=0;ii<=columns;ii++)
       
   529         {
       
   530         width+=data->ColumnWidthPixel(ii);
       
   531         if (data->ColumnIsGraphics(ii))
       
   532             {
       
   533             graphicsColumn=ETrue;
       
   534             }
       
   535         else
       
   536             {
       
   537             const CFont* font=data->ColumnFont(ii);
       
   538             if(font)
       
   539                 {
       
   540                 height=Max(height,font->HeightInPixels());
       
   541                 }
       
   542             else
       
   543                 {
       
   544                 height=Max(height, iFont->HeightInPixels());
       
   545                 }
       
   546             }
       
   547         }
       
   548     if (graphicsColumn)
       
   549         {
       
   550         CArrayPtr<CGulIcon>* iconArray=data->IconArray();
       
   551         if (iconArray)
       
   552             {
       
   553             const TInt count=iconArray->Count();
       
   554             for (TInt jj=0;jj<count;jj++)
       
   555                 height=Max(height,(*iconArray)[jj]->Bitmap()->SizeInPixels().iHeight);
       
   556             }
       
   557         }
       
   558     height = Max (iData->FontBoundValues().iHeightInPixels, height);
       
   559     height+=VerticalInterItemGap();
       
   560     _AKNTRACE_FUNC_EXIT;
       
   561     return TSize(width,height);
       
   562     }
       
   563 
       
   564 EXPORT_C TInt CColumnListBoxItemDrawer::ItemWidthInPixels(TInt /*aItemIndex*/) const
       
   565     {
       
   566     CColumnListBoxData* data=ColumnData();
       
   567     const TInt columns=data->LastColumn();
       
   568     TInt itemWidth = 0;
       
   569     if (iDrawMark)
       
   570         {
       
   571         itemWidth += (iMarkColumnWidth + iMarkGutter);
       
   572         }
       
   573     for (TInt ii=0;ii<=columns;ii++)
       
   574         {
       
   575         if (!ColumnData()->ColumnIsOptional(ii))
       
   576             {
       
   577             itemWidth+=data->ColumnWidthPixel(ii);
       
   578             }
       
   579         }
       
   580     _AKNTRACE( "[%s][%s] itemWidth = %d", "CColumnListBoxItemDrawer", __FUNCTION__, itemWidth );
       
   581     return itemWidth;
       
   582     }
       
   583 
       
   584 EXPORT_C void CColumnListBoxItemDrawer::SetItemCellSize(
       
   585     const TSize& aSizeInPixels)
       
   586     {
       
   587     _AKNTRACE( "[%s][%s] aSizeInPixels(w = %d, h = %d).", "CColumnListBoxItemDrawer", \
       
   588             __FUNCTION__, aSizeInPixels.iWidth, aSizeInPixels.iHeight );
       
   589     CTextListItemDrawer::SetItemCellSize( aSizeInPixels );
       
   590 
       
   591     // Data needs the cell size to create/reconfigure highlight animations
       
   592     CColumnListBoxData* data = ColumnData();
       
   593     data->SetItemCellSize( iItemCellSize );
       
   594     }
       
   595 
       
   596 void CColumnListBoxItemDrawer::DrawCurrentItemRect(const TRect& aRect) const
       
   597 //
       
   598 //    Draw the item background
       
   599 //
       
   600     {
       
   601     iGc->SetClippingRect(iViewRect);
       
   602     iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   603     iGc->SetPenColor(iHighlightedBackColor);    // KDefaultLbxHighlightRectColor
       
   604     iGc->DrawRect(aRect);
       
   605     iGc->CancelClippingRect();
       
   606     }
       
   607 
       
   608 /**
       
   609 * Returns a pointer to the column data. Does not imply transfer of ownership.
       
   610 *
       
   611 * @since ER5U
       
   612 */
       
   613 EXPORT_C CColumnListBoxData* CColumnListBoxItemDrawer::ColumnData() const
       
   614     {
       
   615     return STATIC_CAST(CColumnListBoxData*,iData);
       
   616     }
       
   617 
       
   618 EXPORT_C void CColumnListBoxItemDrawer::DrawItemMark(TBool /*aItemIsSelected*/, TBool /*aViewIsDimmed*/, const TPoint& /*aMarkPos*/) const
       
   619     {
       
   620     // not used in S60
       
   621     }
       
   622 
       
   623 EXPORT_C
       
   624 void CColumnListBoxItemDrawer::DrawItemText( TInt aItemIndex,
       
   625                                              const TRect& aItemTextRect,
       
   626                                              TBool aItemIsCurrent,
       
   627                                              TBool /*aViewIsEmphasized*/,
       
   628                                              TBool aItemIsSelected ) const
       
   629 //
       
   630 //    Draw the items text
       
   631 //
       
   632     {
       
   633 
       
   634 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   635     MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( iGc );
       
   636     if ( transApi )
       
   637         {
       
   638         transApi->StartDrawing( MAknListBoxTfxInternal::EListNotSpecified );
       
   639         }
       
   640 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
   641     iGc->SetPenColor(iTextColor);
       
   642     iGc->SetBrushColor(iBackColor);
       
   643     TPtrC temp=iModel->ItemText(aItemIndex);
       
   644     SetupGc(aItemIndex);
       
   645 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   646     if ( transApi )
       
   647         {
       
   648         transApi->StopDrawing();
       
   649         }
       
   650 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
   651 
       
   652     TBufC<256> target(KNullDesC);
       
   653     // SERIES60 ITEM MARKS! SAPLAF (the same code is in eikfrlb.cpp and eikclb.cpp)
       
   654     TPtrC repl;
       
   655     TInt pos = -1;
       
   656 
       
   657     TBool removeicon = (!aItemIsSelected && !ItemMarkReverse()) || (aItemIsSelected && ItemMarkReverse());
       
   658     if ( Flags() & EDrawMarkSelection && ItemMarkPosition() != -1 && removeicon)
       
   659         {
       
   660         repl.Set( ItemMarkReplacement() );
       
   661         pos = ItemMarkPosition();
       
   662         }
       
   663 
       
   664     // Try to allocate buffer dynamically. If out of memory, use the fixed size stack buffer.
       
   665     // (+1 is for the last column separator)
       
   666     TInt size = temp.Length() + repl.Length() + 1;
       
   667     if ( pos >= 0 )
       
   668         {
       
   669         size += pos; // space for other column separators
       
   670         }
       
   671 
       
   672     HBufC* buffer = NULL;
       
   673     if ( size > 256 )
       
   674         {
       
   675         buffer = HBufC::New( size );
       
   676         }
       
   677 
       
   678     TPtr des = ( buffer ? buffer->Des() : target.Des() );
       
   679     // Note that ReplaceColumn does not update correct length in variable 'des',
       
   680     // because it is not a reference parameter :(
       
   681     AknLAFUtils::ReplaceColumn(des, &temp, &repl, '\t', pos);
       
   682     des.Set( buffer ? buffer->Des() : target.Des() );
       
   683 
       
   684     // END OF ITEM MARKS! SAPLAF
       
   685 
       
   686     CColumnListBoxData::TColors colors;
       
   687     colors.iText=iTextColor;
       
   688     colors.iBack=iBackColor;
       
   689     colors.iHighlightedText=iHighlightedTextColor;
       
   690     colors.iHighlightedBack=iHighlightedBackColor;
       
   691 
       
   692     if (ColumnData()->CurrentMarqueeItemIndex() != aItemIndex && aItemIsCurrent)
       
   693         {
       
   694         ColumnData()->ResetMarquee();
       
   695         ColumnData()->SetCurrentMarqueeItemIndex(aItemIndex);
       
   696         }
       
   697     ColumnData()->SetCurrentItemIndex(aItemIndex);
       
   698     ColumnData()->Draw(Properties(aItemIndex), *iGc,&des,aItemTextRect,(aItemIsCurrent /*|| aViewIsEmphasized*/),colors);
       
   699 
       
   700 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   701     if ( transApi )
       
   702         {
       
   703         transApi->StartDrawing( MAknListBoxTfxInternal::EListNotSpecified );
       
   704         }
       
   705 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
   706     iGc->DiscardFont();
       
   707 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   708     if ( transApi )
       
   709         {
       
   710         transApi->StopDrawing();
       
   711         }
       
   712 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
   713     // end of SERIES60 LAF code.
       
   714 
       
   715     delete buffer;
       
   716     }
       
   717 
       
   718 EXPORT_C TAny* CColumnListBoxItemDrawer::Reserved_1()
       
   719     {
       
   720     return NULL;
       
   721     }
       
   722 
       
   723 //
       
   724 // Class CEikColumnListBoxEditor
       
   725 //
       
   726 
       
   727 EXPORT_C CEikColumnListBoxEditor::CEikColumnListBoxEditor(MListBoxModel* aModel)
       
   728     : CEikListBoxTextEditor( aModel )
       
   729     {
       
   730     AKNTASHOOK_ADD( this, "CEikColumnListBoxEditor" );
       
   731     }
       
   732 
       
   733 EXPORT_C CEikColumnListBoxEditor::~CEikColumnListBoxEditor()
       
   734     {
       
   735     AKNTASHOOK_REMOVE();
       
   736     }
       
   737 
       
   738 EXPORT_C void CEikColumnListBoxEditor::ConstructL(TInt aColumn)
       
   739     {
       
   740     iColumnIndex = aColumn;
       
   741     }
       
   742 
       
   743 EXPORT_C TPtrC CEikColumnListBoxEditor::ItemText()
       
   744     {
       
   745     TPtrC desColumn = static_cast<MTextListBoxModel*>(ListBoxModel())->ItemText(ItemIndex());
       
   746     TPtrC des;
       
   747     TextUtils::ColumnText(des, iColumnIndex, &desColumn);
       
   748     return des;
       
   749     }
       
   750 
       
   751 EXPORT_C TBool CEikColumnListBoxEditor::UpdateModelL()
       
   752     {
       
   753     _AKNTRACE( "[%s][%s][%d].", "CEikColumnListBoxEditor", __FUNCTION__, __LINE__ );
       
   754 
       
   755     if (!Editor())
       
   756         {
       
   757         return EFalse; // quit if editing is not currently on
       
   758         }
       
   759     const MDesCArray* matchableTextArray = STATIC_CAST(CTextListBoxModel*,ListBoxModel())->MatchableTextArray();
       
   760     CDesCArray* textArray = (CDesCArray*)matchableTextArray; // !!! why bother with this cast
       
   761     TPtrC oldItem=textArray->MdcaPoint(ItemIndex());
       
   762     TBuf<128> newItem; // !!! magic number
       
   763     TPtrC column;
       
   764     HBufC* newText = Editor()->GetTextInHBufL();
       
   765     if (!newText)
       
   766         {
       
   767         return ETrue;     // if user tries to insert an empty text...
       
   768         }
       
   769     CleanupStack::PushL(newText);
       
   770     TInt i=0;
       
   771     while ( !TextUtils::ColumnText( column, i, &oldItem ) )
       
   772         {
       
   773         if ( i!=iColumnIndex )
       
   774             {
       
   775             newItem.Append( column );
       
   776             }
       
   777         else
       
   778             {
       
   779             newItem.Append( *newText );
       
   780             }
       
   781 
       
   782         newItem.Append( TChar( KColumnListSeparator ) );
       
   783         i++;
       
   784         }
       
   785     textArray->InsertL(ItemIndex(), newItem);
       
   786     textArray->Delete(ItemIndex()+1);
       
   787     CleanupStack::PopAndDestroy(); // newText
       
   788     return ETrue;
       
   789     }
       
   790 
       
   791 EXPORT_C TInt CEikColumnListBoxEditor::Column() const
       
   792     {
       
   793     return iColumnIndex;
       
   794     }
       
   795 
       
   796 EXPORT_C void CEikColumnListBoxEditor::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
   797     {
       
   798     CEikListBoxTextEditor::HandlePointerEventL(aPointerEvent);
       
   799     }
       
   800 
       
   801 EXPORT_C void* CEikColumnListBoxEditor::ExtensionInterface( TUid /*aInterface*/ )
       
   802     {
       
   803     return NULL;
       
   804     }
       
   805 
       
   806 #define ITEM_EXISTS_BEGIN TInt no_of_items__ = iModel->NumberOfItems()
       
   807 #define ITEM_EXISTS(x) (((x) > -1) && ((x) < no_of_items__))
       
   808 
       
   809 #define ITEM_EXISTS_ONCE(x) (((x) > -1) && ((x) < iModel->NumberOfItems()))
       
   810 
       
   811 EXPORT_C void
       
   812 CColumnListBoxView::Draw( const TRect* aRect ) const
       
   813     {
       
   814 
       
   815     if (RedrawDisabled() || !IsVisible())
       
   816         {
       
   817         return;
       
   818         }
       
   819 
       
   820     TInt i=0;
       
   821 
       
   822     CColumnListBoxItemDrawer* lbi = (CColumnListBoxItemDrawer*)ItemDrawer();
       
   823     CEikListBox* listbox = static_cast<CEikListBox*>( lbi->ColumnData()->Control() );
       
   824     MAknsSkinInstance *skin = AknsUtils::SkinInstance();
       
   825     MAknsControlContext *cc = AknsDrawUtils::ControlContext( listbox );
       
   826 
       
   827     if ( !cc )
       
   828         {
       
   829         cc = lbi->ColumnData()->SkinBackgroundContext();
       
   830         }
       
   831 
       
   832     // draw the whole background at once, this is faster than drawing it in separate items
       
   833     if ( listbox && listbox->BackgroundDrawingSuppressed() )
       
   834         {
       
   835 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   836             MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( iGc );
       
   837             if ( transApi )
       
   838                 {
       
   839                 transApi->StartDrawing( MAknListBoxTfxInternal::EListView );
       
   840                 }
       
   841 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
   842 
       
   843         AknsDrawUtils::Background( skin, cc, listbox, *iGc, *aRect );
       
   844 
       
   845 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   846         if ( transApi )
       
   847             {
       
   848             transApi->StopDrawing();
       
   849             }
       
   850 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
   851         }
       
   852     else if ( !listbox )
       
   853         {
       
   854         iGc->Clear();
       
   855         }
       
   856 
       
   857     TInt firstPotentialItemIndex = iTopItemIndex;
       
   858     TInt lastPotentialItemIndex = iTopItemIndex + NumberOfItemsThatFitInRect(iViewRect) - 1;
       
   859 
       
   860     if (iModel->NumberOfItems() == 0)
       
   861         {
       
   862         // Empty
       
   863         }
       
   864     else
       
   865         {
       
   866         if ( lastPotentialItemIndex > iBottomItemIndex )
       
   867             {
       
   868             // Fix for EAAA-797CKC
       
   869             lastPotentialItemIndex = iBottomItemIndex;
       
   870             }
       
   871         ITEM_EXISTS_BEGIN;
       
   872         for (i = firstPotentialItemIndex; i <= lastPotentialItemIndex; i++)
       
   873             {
       
   874             if (ITEM_EXISTS(i))
       
   875                 {
       
   876                 DrawItem(i);
       
   877                 }
       
   878             else
       
   879                 {
       
   880                 break;
       
   881                 }
       
   882             }
       
   883         }
       
   884 
       
   885     if ( listbox && !listbox->BackgroundDrawingSuppressed() )
       
   886         {
       
   887         // clear the unused portion of the viewing area (this handles drawing the vertical line too :)
       
   888 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   889         MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( iGc );
       
   890 
       
   891         if ( transApi )
       
   892             {
       
   893             transApi->StartDrawing( MAknListBoxTfxInternal::EListView );
       
   894             }
       
   895 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
   896 
       
   897         TRect usedPortionOfViewRect( iViewRect.iTl + TSize( 0, iVerticalOffset ), TSize( iViewRect.Width(), ( i - iTopItemIndex ) * iItemHeight ) );
       
   898 
       
   899         // also clear area behind scroll bar.
       
   900         // this is a terrible hack, which is unfortunately needed since layouts
       
   901         // leave 2 pixel (in double res) wide margins to both sides of the
       
   902         // scroll bar, and there is no other way to do this. This hack is
       
   903         // only really valid for main pane lists, but it does not seem to
       
   904         // break popup lists, popup field lists or setting page radiobutton
       
   905         // lists.
       
   906         TRect sbbg( iViewRect );   // whole area behind scroll bar
       
   907         TRect margin( iViewRect ); // it gets even worse in mirrored layouts
       
   908 
       
   909         if ( AknLayoutUtils::LayoutMirrored() )
       
   910             {
       
   911             sbbg.iBr.iX = iViewRect.iBr.iX - lbi->LafItemSize().iWidth;
       
   912 
       
   913             // in mirrored layouts we also need to draw a margin slice in right
       
   914             TRect mainPane;
       
   915             AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
       
   916                                                mainPane );
       
   917             TAknLayoutRect listscrollAppPane;
       
   918             listscrollAppPane.LayoutRect( mainPane,
       
   919                                           AknLayoutScalable_Avkon::listscroll_app_pane( 0 ) );
       
   920 
       
   921             TInt rMargin = mainPane.iBr.iX - listscrollAppPane.Rect().iBr.iX;
       
   922             margin.iTl.iX = margin.iBr.iX - rMargin;
       
   923             }
       
   924         else
       
   925             {
       
   926             sbbg.iTl.iX = iViewRect.iTl.iX + lbi->LafItemSize().iWidth;
       
   927             }
       
   928 
       
   929         // Unused portion will be cleared only if listbox background is drawn.
       
   930         if ( listbox )
       
   931             {
       
   932             AknsDrawUtils::BackgroundBetweenRects( skin,
       
   933                                                    cc,
       
   934                                                    listbox,
       
   935                                                    *iGc,
       
   936                                                    iViewRect,
       
   937                                                    usedPortionOfViewRect );
       
   938 
       
   939             AknsDrawUtils::Background( skin, cc, listbox, *iGc, sbbg );
       
   940 
       
   941             if ( AknLayoutUtils::LayoutMirrored() )
       
   942                 {
       
   943                 AknsDrawUtils::Background( skin, cc, listbox, *iGc, margin );
       
   944                 }
       
   945             }
       
   946         else
       
   947             {
       
   948             iGc->SetBrushColor( BackColor() );
       
   949             DrawUtils::ClearBetweenRects( *iGc, iViewRect, usedPortionOfViewRect );
       
   950             iGc->Clear( sbbg );
       
   951 
       
   952             if ( AknLayoutUtils::LayoutMirrored() )
       
   953                 {
       
   954                 iGc->Clear( margin );
       
   955                 }
       
   956             }
       
   957 
       
   958 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   959         if ( transApi )
       
   960             {
       
   961             transApi->StopDrawing();
       
   962             }
       
   963 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
   964         }
       
   965     }
       
   966 
       
   967 EXPORT_C void CColumnListBoxView::CalcBottomItemIndex()
       
   968     {
       
   969     CListBoxView::CalcBottomItemIndex();
       
   970     }
       
   971 
       
   972 
       
   973 EXPORT_C TAny* CColumnListBoxView::Reserved_1()
       
   974     {
       
   975     return NULL;
       
   976     }
       
   977 
       
   978 EXPORT_C void CColumnListBoxItemDrawer::ClearAllPropertiesL()
       
   979     {
       
   980     delete iPropertyArray;
       
   981     iPropertyArray = NULL;
       
   982     iPropertyArray = new (ELeave) CArrayFixFlat<SListProperties>(2);
       
   983     }
       
   984 
       
   985 EXPORT_C void CColumnListBoxItemDrawer::SetPropertiesL(TInt aItemIndex, TListItemProperties aProperty)
       
   986     {
       
   987     _AKNTRACE( "[%s][%s][%d].", "CColumnListBoxItemDrawer", __FUNCTION__, __LINE__ );
       
   988     if (!iPropertyArray) ClearAllPropertiesL();
       
   989     TInt index;
       
   990     TKeyArrayFix key(0,ECmpTInt);
       
   991     SListProperties prop;
       
   992     prop.iItem = aItemIndex;
       
   993 
       
   994     if (iPropertyArray->FindIsq(prop, key, index))
       
   995         {
       
   996         iPropertyArray->InsertIsqL(prop, key);
       
   997         iPropertyArray->FindIsq(prop, key, index);
       
   998         }
       
   999     iPropertyArray->At(index).iProperties = aProperty;
       
  1000     }
       
  1001 
       
  1002 EXPORT_C
       
  1003 TListItemProperties CColumnListBoxItemDrawer::Properties(TInt aItemIndex) const
       
  1004     {
       
  1005     if (!iPropertyArray) return CTextListItemDrawer::Properties(aItemIndex);
       
  1006     CAknListBoxFilterItems *filter = STATIC_CAST(CAknFilteredTextListBoxModel*,iModel)->Filter();
       
  1007     if (filter)
       
  1008         {
       
  1009         aItemIndex = filter->FilteredItemIndex(aItemIndex);
       
  1010         }
       
  1011     TKeyArrayFix key(0,ECmpTInt);
       
  1012     SListProperties prop;
       
  1013     prop.iItem = aItemIndex;
       
  1014     TInt index;
       
  1015     if (iPropertyArray->FindIsq(prop, key, index)) return CTextListItemDrawer::Properties(aItemIndex);
       
  1016     return iPropertyArray->At(index).iProperties;
       
  1017     }
       
  1018 
       
  1019 EXPORT_C void CColumnListBoxItemDrawer::CColumnListBoxItemDrawer_Reserved()
       
  1020     {
       
  1021     }
       
  1022 
       
  1023 // End of File