emailuis/uicomponents/src/fstreeplainonelineitemvisualizer.cpp
changeset 0 8466d47a6819
child 1 12c456ceeff2
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  A visualizer for data items with plain text.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //<cmail> removed __FS_ALFRED_SUPPORT flag
       
    20 //#include <fsconfig.h>
       
    21 //</cmail> removed __FS_ALFRED_SUPPORT flag
       
    22 
       
    23 #include "emailtrace.h"
       
    24 #include "fstreeplainonelineitemvisualizer.h"
       
    25 #include "fstreeplainonelineitemdata.h"
       
    26 #include "fstreelist.h"
       
    27 #include "fslayoutmanager.h"
       
    28 #include "fstextstylemanager.h"
       
    29 #include "fsalftextstylemanager.h"
       
    30 #include "fsmarqueeclet.h"
       
    31 #include <touchlogicalfeedback.h>
       
    32 
       
    33 // <cmail> SF
       
    34 #include <alf/alfanchorlayout.h>
       
    35 #include <alf/alfimagevisual.h>
       
    36 #include <alf/alfviewportlayout.h>
       
    37 #include <alf/alftextvisual.h>
       
    38 #include <alf/alfimage.h>
       
    39 #include <alf/alfenv.h>
       
    40 #include <alf/alftextstyle.h>
       
    41 
       
    42 #include <alf/alfevent.h>
       
    43 #include <alf/alfmappingfunctions.h>
       
    44 // </cmail>
       
    45 
       
    46 // ======== MEMBER FUNCTIONS ========
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // Two-phased constructor.
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 EXPORT_C CFsTreePlainOneLineItemVisualizer*
       
    53     CFsTreePlainOneLineItemVisualizer::NewL( CAlfControl& aOwnerControl )
       
    54     {
       
    55     CFsTreePlainOneLineItemVisualizer* self =
       
    56         new( ELeave ) CFsTreePlainOneLineItemVisualizer( aOwnerControl );
       
    57     CleanupStack::PushL( self );
       
    58     self->ConstructL( );
       
    59     CleanupStack::Pop( self );
       
    60     return self;
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // C++ destructor.
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 CFsTreePlainOneLineItemVisualizer::~CFsTreePlainOneLineItemVisualizer()
       
    68     {
       
    69     FUNC_LOG;
       
    70     delete iTextMarquee;
       
    71     }
       
    72 
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // Returns visualizer's type.
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 TFsTreeItemVisualizerType CFsTreePlainOneLineItemVisualizer::Type() const
       
    79     {
       
    80     FUNC_LOG;
       
    81     return EFsTreePlainOneLineItemVisualizer;
       
    82     }
       
    83 
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // From class MFsTreeItemVisualizer.
       
    87 // Sets the size of the item visualization when item is not in expanded
       
    88 // state. The value is taken from layout manager.
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 void CFsTreePlainOneLineItemVisualizer::UpdateLayout(
       
    92         const CFsTreePlainOneLineItemData* aData,
       
    93         const TInt aIndentation )
       
    94     {
       
    95     FUNC_LOG;
       
    96     TRect rect;
       
    97 
       
    98     TAlfTimedPoint tpMainIconTl, tpMainIconBr;
       
    99     TAlfTimedPoint tpTextTl, tpTextBr;
       
   100     TAlfTimedPoint tpMarkIconTl, tpMarkIconBr;
       
   101     TAlfTimedPoint tpMenuIconTl, tpMenuIconBr;
       
   102 
       
   103     CFsLayoutManager::TFsLayoutMetrics mainIconMetrics =
       
   104         CFsLayoutManager::EFsLmListSingleDycRowPaneG1;
       
   105     CFsLayoutManager::TFsLayoutMetrics markIconMetrics =
       
   106         CFsLayoutManager::EFsLmListSingleDycRowPaneG4;
       
   107     CFsLayoutManager::TFsLayoutMetrics menuIconMetrics =
       
   108         CFsLayoutManager::EFsLmListSingleDycRowPaneG3;
       
   109     CFsLayoutManager::TFsLayoutMetrics textMetrics =
       
   110         CFsLayoutManager::EFsLmListSingleDycRowTextPaneT1;
       
   111 
       
   112     TInt mainIconVariety( 0 );
       
   113     TInt markIconVariety( 0 );
       
   114     TInt menuIconVariety( 0 );
       
   115     TInt textPaneVariety( 0 );
       
   116 
       
   117     if (aData->IsIconSet() || IsLayoutHintSet( CFsTreeItemVisualizerBase::EPopupLayout ))
       
   118         {
       
   119         if (iFlags & KFsTreeListItemMarked)
       
   120             {
       
   121             if (iMenu && (iFlags & KFsTreeListItemFocused))
       
   122                 {
       
   123                 //mainIcon + markIcon + menuIcon
       
   124                 //the metrics defined when declared
       
   125                 mainIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG1;
       
   126                 menuIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG3;
       
   127                 markIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG4;
       
   128                 mainIconVariety = 3;
       
   129                 textPaneVariety = 3;
       
   130                 menuIconVariety = 1;
       
   131                 markIconVariety = 2;
       
   132                 }
       
   133             else
       
   134                 {
       
   135                 //mainIcon + markIcon
       
   136                 mainIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG1;
       
   137                 markIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG4;
       
   138                 mainIconVariety = 4;
       
   139                 textPaneVariety = 4;
       
   140                 markIconVariety = 3;
       
   141                 }
       
   142             }
       
   143         else
       
   144             {
       
   145             if ((iFlags & KFsTreeListItemHasMenu)
       
   146                     && (iFlags & KFsTreeListItemFocused))
       
   147                 {
       
   148                 //mainIcon + menuIcon
       
   149                 mainIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG1;
       
   150                 menuIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG4;
       
   151                 mainIconVariety = 4;
       
   152                 textPaneVariety = 4;
       
   153                 menuIconVariety = 3;
       
   154                 }
       
   155             else
       
   156                 {
       
   157                 if ( IsLayoutHintSet( EFolderLayout ) )
       
   158 	                {
       
   159 	                //mainIcon
       
   160 	                mainIconMetrics = CFsLayoutManager::EFsLmFolderListMediumLineG1;
       
   161 	                textMetrics     = CFsLayoutManager::EFsLmFolderListMediumLineT1;
       
   162                     }
       
   163 	            else
       
   164 		            {
       
   165 	                //mainIcon
       
   166                     textMetrics     = CFsLayoutManager::EFsLmMainSpFsCtrlbarDdmenuPaneT1;
       
   167                     mainIconMetrics = CFsLayoutManager::EFsLmMainSpFsCtrlbarDdmenuPaneG2;
       
   168                     mainIconVariety = 0;
       
   169                     textPaneVariety = 2;
       
   170                     }
       
   171                 }
       
   172             }
       
   173         }
       
   174     else // !aData->IsIconSet()
       
   175         {
       
   176         if (iFlags & KFsTreeListItemMarked)
       
   177             {
       
   178             if (iMenu && (iFlags & KFsTreeListItemFocused))
       
   179                 {
       
   180                 //markIcon + menuIcon
       
   181                 menuIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG3;
       
   182                 markIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG4;
       
   183                 menuIconVariety = 2;
       
   184                 markIconVariety = 4;
       
   185                 textPaneVariety = 6;
       
   186                 }
       
   187             else
       
   188                 {
       
   189                 //markIcon
       
   190                 markIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG4;
       
   191                 markIconVariety = 5;
       
   192                 textPaneVariety = 7;
       
   193                 }
       
   194             }
       
   195         else
       
   196             {
       
   197             if ((iFlags & KFsTreeListItemHasMenu)
       
   198                     && (iFlags & KFsTreeListItemFocused))
       
   199                 {
       
   200                 //menuIcon
       
   201                 menuIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG4;
       
   202                 menuIconVariety = 5;
       
   203                 textPaneVariety = 7;
       
   204                 }
       
   205             else
       
   206                 {
       
   207                 //plain item
       
   208                 textPaneVariety = 8;
       
   209                 }
       
   210             }
       
   211         }
       
   212     //layout manager is queried for medium values - LM returnes rects based on phone's global text settings
       
   213 
       
   214     TRect parentLayoutRect = TRect(iParentLayout->Size().Target().AsSize());
       
   215     parentLayoutRect.Resize(-(iParentLayout->HorizontalPadding()*2), 0);
       
   216 
       
   217     if (iFlags & KFsTreeListItemManagedLayout)
       
   218         {
       
   219         CFsLayoutManager::LayoutMetricsSize(
       
   220                 parentLayoutRect,
       
   221                 CFsLayoutManager::EFsLmListSingleDycRowPane,
       
   222                 iSize );
       
   223         }
       
   224 
       
   225     TRect currentSize = iSize;
       
   226     if (CFsLayoutManager::IsMirrored())
       
   227         {
       
   228         currentSize.iBr = currentSize.iBr - TPoint(aIndentation, 0);
       
   229         }
       
   230     else
       
   231         {
       
   232         currentSize.iTl = currentSize.iTl + TPoint(aIndentation, 0);
       
   233         }
       
   234 
       
   235     CFsLayoutManager::LayoutMetricsRect(
       
   236                 currentSize,
       
   237                 mainIconMetrics,
       
   238                 rect,
       
   239                 mainIconVariety );
       
   240     tpMainIconTl.SetTarget(TAlfRealPoint(rect.iTl));
       
   241     tpMainIconBr.SetTarget(TAlfRealPoint(rect.iBr));
       
   242 
       
   243     CFsLayoutManager::LayoutMetricsRect(
       
   244             currentSize,
       
   245             markIconMetrics,
       
   246             rect,
       
   247             markIconVariety );
       
   248     tpMarkIconTl.SetTarget(TAlfRealPoint(rect.iTl));
       
   249     tpMarkIconBr.SetTarget(TAlfRealPoint(rect.iBr));
       
   250 
       
   251     CFsLayoutManager::LayoutMetricsRect(
       
   252             currentSize,
       
   253             menuIconMetrics,
       
   254             rect,
       
   255             menuIconVariety );
       
   256     tpMenuIconTl.SetTarget(TAlfRealPoint(rect.iTl));
       
   257     tpMenuIconBr.SetTarget(TAlfRealPoint(rect.iBr));
       
   258 
       
   259     TRect textRect( currentSize );
       
   260     if (textMetrics == CFsLayoutManager::EFsLmListSingleDycRowTextPaneT1)
       
   261         {
       
   262         CFsLayoutManager::LayoutMetricsRect(
       
   263                     currentSize,
       
   264                     CFsLayoutManager::EFsLmListSingleDycRowTextPane,
       
   265                     textRect,
       
   266                     textPaneVariety );
       
   267         }
       
   268     CFsLayoutManager::TFsText textInfo;
       
   269     /*CFsLayoutManager::LayoutMetricsText(currentSize, textMetrics, textInfo);*/
       
   270 
       
   271     CFsLayoutManager::LayoutMetricsText(textRect,
       
   272             textMetrics,
       
   273             textInfo, textPaneVariety);
       
   274     tpTextTl.SetTarget(TAlfRealPoint(textInfo.iTextRect.iTl));
       
   275     tpTextBr.SetTarget(TAlfRealPoint(textInfo.iTextRect.iBr));
       
   276 
       
   277     TInt visualIconIndex = iLayout->FindVisual(iIconVisual);
       
   278     if ( visualIconIndex != KErrNotFound )
       
   279         {
       
   280         iLayout->SetAnchor( EAlfAnchorTopLeft,
       
   281                 visualIconIndex,
       
   282                 EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
       
   283                 EAlfAnchorMetricAbsolute,
       
   284                 EAlfAnchorMetricAbsolute,
       
   285                 tpMainIconTl );
       
   286         iLayout->SetAnchor( EAlfAnchorBottomRight,
       
   287                 visualIconIndex,
       
   288                 EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
       
   289                 EAlfAnchorMetricAbsolute,
       
   290                 EAlfAnchorMetricAbsolute,
       
   291                 tpMainIconBr );
       
   292         }
       
   293 
       
   294     if ((iFlags & KFsTreeListItemHasMenu)
       
   295             && (iFlags & KFsTreeListItemFocused))
       
   296         {
       
   297         TInt iconMenuVisIndex = iLayout->FindVisual(iIconMenu);
       
   298         if ( iconMenuVisIndex != KErrNotFound )
       
   299             {
       
   300             iLayout->SetAnchor(EAlfAnchorTopLeft,
       
   301                     iconMenuVisIndex,
       
   302                     EAlfAnchorOriginLeft,EAlfAnchorOriginTop,
       
   303                     EAlfAnchorMetricAbsolute,EAlfAnchorMetricAbsolute,
       
   304                     tpMenuIconTl );
       
   305             iLayout->SetAnchor(EAlfAnchorBottomRight,
       
   306                     iconMenuVisIndex,
       
   307                     EAlfAnchorOriginLeft,EAlfAnchorOriginTop,
       
   308                     EAlfAnchorMetricAbsolute,EAlfAnchorMetricAbsolute,
       
   309                     tpMenuIconBr );
       
   310 
       
   311             TAlfTimedValue opacity;
       
   312             opacity.SetValueNow(1.0f);
       
   313             iIconMenu->SetOpacity(opacity);
       
   314             }
       
   315         }
       
   316     else
       
   317         {
       
   318         TAlfTimedValue opacity;
       
   319         opacity.SetValueNow(0.0f);
       
   320         iIconMenu->SetOpacity(opacity);
       
   321         }
       
   322 
       
   323     if (iViewportLayout)
       
   324         {
       
   325         TInt textVisIndex = iLayout->FindVisual(iViewportLayout);
       
   326         if ( textVisIndex != KErrNotFound )
       
   327             {
       
   328             iLayout->SetAnchor(EAlfAnchorTopLeft,
       
   329                     textVisIndex,
       
   330                     EAlfAnchorOriginLeft,EAlfAnchorOriginTop,
       
   331                     EAlfAnchorMetricAbsolute,
       
   332                     EAlfAnchorMetricAbsolute,
       
   333                     tpTextTl );
       
   334             iLayout->SetAnchor(EAlfAnchorBottomRight,
       
   335                     textVisIndex,
       
   336                     EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
       
   337                     EAlfAnchorMetricAbsolute,
       
   338                     EAlfAnchorMetricAbsolute,
       
   339                     tpTextBr );
       
   340             }
       
   341         }
       
   342 
       
   343     if ( iFlags & KFsTreeListItemMarked )
       
   344         {
       
   345         TInt iconMarkedVisIndex =
       
   346                             iLayout->FindVisual(iIconMarked);
       
   347         if ( iconMarkedVisIndex != KErrNotFound )
       
   348             {
       
   349             iLayout->SetAnchor(EAlfAnchorTopLeft,
       
   350                     iconMarkedVisIndex,
       
   351                     EAlfAnchorOriginLeft,EAlfAnchorOriginTop,
       
   352                     EAlfAnchorMetricAbsolute,
       
   353                     EAlfAnchorMetricAbsolute,
       
   354                     tpMarkIconTl );
       
   355             iLayout->SetAnchor(EAlfAnchorBottomRight,
       
   356                     iconMarkedVisIndex,
       
   357                     EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
       
   358                     EAlfAnchorMetricAbsolute,
       
   359                     EAlfAnchorMetricAbsolute,
       
   360                     tpMarkIconBr );
       
   361 
       
   362             TAlfTimedValue opacity;
       
   363             opacity.SetValueNow(1.0f);
       
   364             iIconMarked->SetOpacity(opacity);
       
   365             }
       
   366         }
       
   367     else
       
   368         {
       
   369         if (iIconMarked)
       
   370             {
       
   371             TAlfTimedValue opacity;
       
   372             opacity.SetValueNow(0.0f);
       
   373             iIconMarked->SetOpacity(opacity);
       
   374             }
       
   375         }
       
   376     iLayout->UpdateChildrenLayout();
       
   377 
       
   378     }
       
   379 
       
   380 
       
   381 
       
   382 
       
   383 
       
   384 // ---------------------------------------------------------------------------
       
   385 // From class MFsTreeItemVisualizer.
       
   386 // A call to this function means that the item is requested to draw itself
       
   387 // within specified parent layout.
       
   388 // ---------------------------------------------------------------------------
       
   389 //
       
   390 void CFsTreePlainOneLineItemVisualizer::ShowL( CAlfLayout& aParentLayout,
       
   391                                         const TUint aTimeout )
       
   392     {
       
   393     FUNC_LOG;
       
   394     if (!iLayout)
       
   395         {
       
   396         iParentLayout = &aParentLayout;
       
   397         iLayout = CAlfAnchorLayout::AddNewL(iOwnerControl,iParentLayout);
       
   398         iLayout->SetTactileFeedbackL( ETouchEventStylusDown, ETouchFeedbackBasic );
       
   399         iLayout->EnableBrushesL();
       
   400         iLayout->SetClipping(ETrue);
       
   401 
       
   402         if (!iIconVisual)
       
   403             {
       
   404             iIconVisual =
       
   405                         CAlfImageVisual::AddNewL(iOwnerControl, iLayout);
       
   406             // <cmail> aspect ratio preserved
       
   407             iIconVisual->SetScaleMode( CAlfImageVisual::EScaleFitInside);
       
   408             iIconVisual->SetFlag( EAlfVisualFlagIgnorePointer );
       
   409             }
       
   410 
       
   411         if (!iViewportLayout) 
       
   412             {
       
   413             iViewportLayout =
       
   414                       CAlfViewportLayout::AddNewL(iOwnerControl, iLayout);
       
   415             iViewportLayout->SetFlag( EAlfVisualFlagIgnorePointer );
       
   416             }
       
   417 
       
   418         if (!iTextVisual)
       
   419             {
       
   420             iTextVisual =
       
   421                       CAlfTextVisual::AddNewL(iOwnerControl, iViewportLayout);
       
   422             iTextVisual->SetFlag( EAlfVisualFlagIgnorePointer );
       
   423             }
       
   424 
       
   425         if (!iIconMarked)
       
   426             {
       
   427             iIconMarked = CAlfImageVisual::AddNewL(iOwnerControl, iLayout);
       
   428             iIconMarked->SetScaleMode( CAlfImageVisual::EScaleFitInside);
       
   429             iIconMarked->SetFlag( EAlfVisualFlagIgnorePointer );
       
   430             }
       
   431 
       
   432         if (!iIconMenu)
       
   433             {
       
   434             iIconMenu = CAlfImageVisual::AddNewL(iOwnerControl, iLayout);
       
   435             iIconMenu->SetScaleMode(CAlfImageVisual::EScaleFitInside);
       
   436             iIconMenu->SetFlag( EAlfVisualFlagIgnorePointer );
       
   437             }
       
   438 
       
   439         iTextMarquee = new (ELeave) TFsMarqueeClet(iOwnerControl, *iViewportLayout, TFsMarqueeClet::EScrollFromRight, TFsMarqueeClet::EScrollForth);
       
   440         }
       
   441     else
       
   442         {
       
   443         //visuals are already created but not attached to the list layout
       
   444         if (!iLayout->Layout())
       
   445             {
       
   446             aParentLayout.Append(iLayout, aTimeout);
       
   447             iParentLayout = &aParentLayout;
       
   448             }
       
   449         }
       
   450     }
       
   451 
       
   452 // ---------------------------------------------------------------------------
       
   453 // A call to this function means that the item is requested to update its
       
   454 // visual content.
       
   455 // ---------------------------------------------------------------------------
       
   456 //
       
   457 void CFsTreePlainOneLineItemVisualizer::UpdateL( const MFsTreeItemData& aData,
       
   458                                           TBool aFocused,
       
   459                                           const TUint aLevel,
       
   460                                           CAlfTexture*& aMarkIcon,
       
   461                                           CAlfTexture*& aMenuIcon,
       
   462                                           const TUint /*aTimeout*/,
       
   463                                           TBool aUpdateData)
       
   464     {
       
   465     FUNC_LOG;
       
   466     if (iLayout)
       
   467         {
       
   468         iSize.iWidth = iParentLayout->Size().Target().iX;
       
   469         iExtendedSize.iWidth = iSize.iWidth;
       
   470         
       
   471         TSize layoutSize(iLayout->Size().Target().iX, iLayout->Size().Target().iY);
       
   472         layoutSize.iWidth = iSize.iWidth;
       
   473         iLayout->SetSize(layoutSize);
       
   474 
       
   475         if (aFocused)
       
   476             {
       
   477             if (IsFocusable())
       
   478                 {
       
   479                 iFlags |= KFsTreeListItemFocused;
       
   480                 }
       
   481             }
       
   482         else
       
   483             {
       
   484             iFlags &= ~KFsTreeListItemFocused;
       
   485             }
       
   486 
       
   487         if ( aData.Type() == KFsTreePlainOneLineItemDataType )
       
   488             {
       
   489             const CFsTreePlainOneLineItemData* data =
       
   490                       static_cast<const CFsTreePlainOneLineItemData*>(&aData);
       
   491 
       
   492             //update the ancors for current item settings
       
   493             const TInt indent( iTextIndentation * ( aLevel - 1 ) );
       
   494             UpdateLayout(data, indent);
       
   495 
       
   496             if (iIconVisual && data->IsIconSet())
       
   497                 {
       
   498                 // <cmail> aspect ratio preserved
       
   499                 iIconVisual->SetScaleMode( CAlfImageVisual::EScaleFitInside );
       
   500                 // </cmail>
       
   501                 iIconVisual->SetImage( TAlfImage( data->Icon() ) );
       
   502                 }
       
   503 
       
   504             if ( iTextVisual && aUpdateData )
       
   505                 {
       
   506                 //get text color
       
   507                 TRgb textColor;
       
   508                 if ( aFocused )
       
   509                     {
       
   510                     if (!iIsCustomTextFocusedColor)
       
   511                         {//custom color not set, use color from skin - load it in case theme has changed
       
   512                         iFocusedTextColor = FocusedStateTextSkinColor();
       
   513                         }
       
   514                     textColor = iFocusedTextColor;
       
   515                     iFlags |= KFsTreeListItemFocused;
       
   516                     }
       
   517                 else
       
   518                     {
       
   519                     if (!iIsCustomTextNormalColor)
       
   520                         {//custom color not set, use color from skin - load it in case theme has changed
       
   521                         iNormalTextColor = NormalStateTextSkinColor( );
       
   522                         }
       
   523                     textColor = iNormalTextColor;
       
   524                     iFlags &= ~KFsTreeListItemFocused;
       
   525                     }
       
   526                 //get text style
       
   527                 TInt styleId = ModifiedStyleIdL( );
       
   528                 iTextVisual->Env().CancelCustomCommands(this);
       
   529 
       
   530                 TAlfTimedPoint tp(0,0);
       
   531                 tp.SetStyle(EAlfTimedValueStyleLinear);
       
   532                 iTextVisual->SetPos(tp);
       
   533                 iTextVisual->SetTextL(data->Data( ));
       
   534 
       
   535                 iTextVisual->EnableShadow(iFlags & KFsTreeListItemTextShadow);
       
   536                 iTextVisual->SetColor( textColor );
       
   537                 iTextVisual->SetTextStyle( styleId );
       
   538 
       
   539                 iTextVisual->SetWrapping(CAlfTextVisual::ELineWrapManual);
       
   540 
       
   541                 TAlfAlignHorizontal currTextAlign( EAlfAlignHLocale );
       
   542                 currTextAlign = CurrentTextAlignmentL( iTextAlign, &data->Data(), iTextVisual );
       
   543                 iTextVisual->SetAlign( currTextAlign, EAlfAlignVCenter );
       
   544 
       
   545                 iTextVisual->SetWrapping(CAlfTextVisual::ELineWrapTruncate);
       
   546 
       
   547                 if ( currTextAlign == EAlfAlignHRight )
       
   548                     {
       
   549                     iTextMarquee->SetScrollDirection( TFsMarqueeClet::EScrollFromLeft );
       
   550                     }
       
   551                 else
       
   552                     {
       
   553                     iTextMarquee->SetScrollDirection( TFsMarqueeClet::EScrollFromRight );
       
   554                     }
       
   555                 }
       
   556 
       
   557             if ( IsMarked() )
       
   558                 {
       
   559                 // <cmail> aspect ratio preserved
       
   560                 iIconMarked->SetScaleMode( CAlfImageVisual::EScaleFitInside);
       
   561                 // </cmail>
       
   562                 iIconMarked->SetImage( *aMarkIcon );
       
   563                 }
       
   564 
       
   565             if ((iFlags & KFsTreeListItemHasMenu)
       
   566                     && (iFlags & KFsTreeListItemFocused))
       
   567                 {
       
   568                 if ( iIconMenu && aMenuIcon )
       
   569                     {
       
   570                 iIconMenu->SetScaleMode( CAlfImageVisual::EScaleFit );
       
   571                 iIconMenu->SetImage( *aMenuIcon );
       
   572                 }
       
   573                 }
       
   574 
       
   575             iTextMarquee->StopScrolling();           
       
   576             iTextVisual->SetWrapping(CAlfTextVisual::ELineWrapTruncate);
       
   577             }
       
   578         }
       
   579     }
       
   580 
       
   581 // ---------------------------------------------------------------------------
       
   582 // From class MFsTreeItemVisualizer.
       
   583 // A call to this function means that the item goes out of the visible items
       
   584 // scope.
       
   585 // ---------------------------------------------------------------------------
       
   586 //
       
   587 void CFsTreePlainOneLineItemVisualizer::Hide( const TInt aTimeout )
       
   588     {
       
   589     FUNC_LOG;
       
   590     if ( iLayout )
       
   591         {
       
   592         //if marquee command was sent
       
   593         iTextVisual->Env().CancelCustomCommands(this);
       
   594 
       
   595         delete iTextMarquee;
       
   596         iTextMarquee = NULL; //it has to be here
       
   597 
       
   598         iParentLayout->Remove(iLayout, aTimeout);
       
   599         iLayout->RemoveAndDestroyAllD();
       
   600         iLayout = NULL;
       
   601         iTextVisual = NULL;
       
   602         iIconVisual = NULL;
       
   603         iIconMarked = NULL;
       
   604         iIconMenu = NULL;
       
   605         iParentLayout = NULL;
       
   606         iViewportLayout = NULL;
       
   607         }
       
   608     }
       
   609 
       
   610 // ---------------------------------------------------------------------------
       
   611 //  From MFsTreeItemVisualizer.
       
   612 //  Method to marquee the text when it's too long.
       
   613 // ---------------------------------------------------------------------------
       
   614 //
       
   615 void CFsTreePlainOneLineItemVisualizer::MarqueeL(const TFsTextMarqueeType aMarqueeType,
       
   616                                                  const TUint aMarqueeSpeed,
       
   617                                                  const TInt aMarqueeStartDelay,
       
   618                                                  const TInt aMarqueeCycleStartDelay,
       
   619                                                  const TInt aMarqueeRepetitions)
       
   620     {
       
   621     FUNC_LOG;
       
   622     TInt marqueeSize(0), textWidth(0);
       
   623 
       
   624     if ( aMarqueeType == EFsTextMarqueeNone )
       
   625         {
       
   626         return;
       
   627         }
       
   628 
       
   629 
       
   630     iTextVisual->SetWrapping(CAlfTextVisual::ELineWrapManual);
       
   631 
       
   632     textWidth = iTextVisual->SubstringExtents(0, iTextVisual->Text().Length()).Width();
       
   633     marqueeSize = textWidth - iViewportLayout->Size().iX.Target();
       
   634 
       
   635     if ( iTextVisual && ( marqueeSize>0 ) )
       
   636         {
       
   637         TSize size(textWidth,iViewportLayout->Size().iY.Target());
       
   638         if ( aMarqueeType == EFsTextMarqueeForth )
       
   639             {
       
   640             iTextMarquee->SetScrollType( TFsMarqueeClet::EScrollForth );
       
   641             }
       
   642         else if ( aMarqueeType == EFsTextMarqueeForthBack )
       
   643             {
       
   644             iTextMarquee->SetScrollType( TFsMarqueeClet::EScrollBounce );
       
   645             }
       
   646         else if ( aMarqueeType == EFsTextMarqueeLoop )
       
   647             {
       
   648             iTextMarquee->SetScrollType( TFsMarqueeClet::EScrollWrap );
       
   649             //duplicate text
       
   650             TBufC <1> separator(_L(" "));
       
   651             HBufC* textHeap = HBufC::NewLC( (iTextVisual->Text().Length()+1)*2+1);
       
   652             TPtr doubleString(textHeap->Des());
       
   653             doubleString = iTextVisual->Text();
       
   654             doubleString.Append(_L(" "));
       
   655             doubleString.Append(iTextVisual->Text());
       
   656             doubleString.Append(_L(" "));
       
   657             iTextVisual->SetTextL( doubleString );
       
   658             CleanupStack::PopAndDestroy(textHeap);
       
   659             size.iWidth = iTextVisual->SubstringExtents(0, iTextVisual->Text().Length()).Width();
       
   660             }
       
   661 
       
   662         iTextMarquee->SetScrollRepetitions( aMarqueeRepetitions );
       
   663         TInt time(0);
       
   664         if ( aMarqueeType == EFsTextMarqueeLoop )
       
   665             {
       
   666             time = textWidth * 1000 / aMarqueeSpeed;
       
   667             }
       
   668         else
       
   669             {
       
   670             time = marqueeSize * 1000 / aMarqueeSpeed;
       
   671             }
       
   672         iTextMarquee->SetScrollSpeed( time );
       
   673         iTextMarquee->SetScrollableArea( size );
       
   674         iTextMarquee->SetScrollCycleDelay( aMarqueeCycleStartDelay );
       
   675 
       
   676         TAlfCustomEventCommand cmd( aMarqueeType, this, 0 );
       
   677         iTextVisual->Env().CancelCustomCommands( this, aMarqueeType );
       
   678         iTextVisual->Env().Send( cmd, aMarqueeStartDelay );
       
   679         }
       
   680     }
       
   681 
       
   682 
       
   683 // ---------------------------------------------------------------------------
       
   684 //  Handles custom Alf event. Used with text marquee.
       
   685 // ---------------------------------------------------------------------------
       
   686 //
       
   687 TBool CFsTreePlainOneLineItemVisualizer::OfferEventL(const TAlfEvent& aEvent)
       
   688     {
       
   689     FUNC_LOG;
       
   690     TBool ret( EFalse );
       
   691     if ( aEvent.IsCustomEvent() )
       
   692         {
       
   693         TInt param = aEvent.CustomParameter();
       
   694         if ( param == EFsTextMarqueeForth ||
       
   695              param == EFsTextMarqueeForthBack ||
       
   696              param == EFsTextMarqueeLoop )
       
   697             {
       
   698             ret = ETrue;
       
   699             iTextMarquee->StartScrolling( );
       
   700             }
       
   701         }
       
   702     return ret;
       
   703     }
       
   704 
       
   705 // ---------------------------------------------------------------------------
       
   706 //  C++ constructor.
       
   707 // ---------------------------------------------------------------------------
       
   708 //
       
   709 CFsTreePlainOneLineItemVisualizer::CFsTreePlainOneLineItemVisualizer
       
   710                                                 ( CAlfControl& aOwnerControl )
       
   711     : CFsTreeItemVisualizerBase( aOwnerControl )
       
   712     {
       
   713     FUNC_LOG;
       
   714 
       
   715     }
       
   716 
       
   717 
       
   718 // ---------------------------------------------------------------------------
       
   719 //  Second phase constructor.
       
   720 // ---------------------------------------------------------------------------
       
   721 //
       
   722 void CFsTreePlainOneLineItemVisualizer::ConstructL( )
       
   723     {
       
   724     FUNC_LOG;
       
   725     CFsTreeItemVisualizerBase::ConstructL();
       
   726 
       
   727     //get default skin values
       
   728     iNormalTextColor = NormalStateTextSkinColor();
       
   729     iFocusedTextColor = FocusedStateTextSkinColor();
       
   730     }
       
   731