emailuis/uicomponents/src/fstreeplainonelinenodevisualizer.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 nodes 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 "fstreeplainonelinenodevisualizer.h"
       
    25 #include "fstreeplainonelinenodedata.h"
       
    26 #include "fsgenericpanic.h"
       
    27 #include "fstreelist.h"
       
    28 #include "fslayoutmanager.h"
       
    29 #include "fsmarqueeclet.h"
       
    30 #include <touchlogicalfeedback.h>
       
    31 
       
    32 // <cmail> SF
       
    33 #include <alf/alfanchorlayout.h>
       
    34 #include <alf/alfimagevisual.h>
       
    35 #include <alf/alfviewportlayout.h>
       
    36 #include <alf/alftextvisual.h>
       
    37 #include <alf/alfimage.h>
       
    38 #include <alf/alfenv.h>
       
    39 
       
    40 #include <alf/alfevent.h>
       
    41 #include <alf/alfmappingfunctions.h>
       
    42 // </cmail>
       
    43 
       
    44 // ======== MEMBER FUNCTIONS ========
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // Two-phased constructor.
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 EXPORT_C CFsTreePlainOneLineNodeVisualizer*
       
    51     CFsTreePlainOneLineNodeVisualizer::NewL(
       
    52                                                   CAlfControl& aOwnerControl )
       
    53     {
       
    54     CFsTreePlainOneLineNodeVisualizer* self = new( ELeave )
       
    55                             CFsTreePlainOneLineNodeVisualizer( aOwnerControl);
       
    56     CleanupStack::PushL( self );
       
    57     self->ConstructL( );
       
    58     CleanupStack::Pop( self );
       
    59     return self;
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // C++ destructor.
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 CFsTreePlainOneLineNodeVisualizer::~CFsTreePlainOneLineNodeVisualizer()
       
    67     {
       
    68     FUNC_LOG;
       
    69     delete iTextMarquee;
       
    70     }
       
    71 
       
    72 
       
    73 // from base class MFsTreeItemVisualizer
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // From MFsTreeItemVisualizer.
       
    77 // Returns visualizer's type.
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 TFsTreeItemVisualizerType CFsTreePlainOneLineNodeVisualizer::Type() const
       
    81     {
       
    82     FUNC_LOG;
       
    83     return EFsTreePlainOneLineNodeVisualizer;
       
    84     }
       
    85 
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // From MFsTreeItemVisualizer.
       
    89 // Sets multiple flags for a node at one time.
       
    90 // KFsTreeListItemExtendable flag has no effect.
       
    91 // KFsTreeListItemExtended flag has no effect.
       
    92 // KFsTreeListItemAlwaysExtended  flag has no effect.
       
    93 // ---------------------------------------------------------------------------
       
    94 //
       
    95 void CFsTreePlainOneLineNodeVisualizer::SetFlags( TUint32 aFlags )
       
    96     {
       
    97     FUNC_LOG;
       
    98     iFlags = aFlags;
       
    99     iFlags &= ~KFsTreeListItemExtendable;
       
   100     iFlags &= ~KFsTreeListItemExtended;
       
   101     iFlags &= ~KFsTreeListItemAlwaysExtended;
       
   102     }
       
   103 
       
   104 void CFsTreePlainOneLineNodeVisualizer::SetExpanded( TBool aFlag, const MFsTreeItemData* aData )
       
   105     {
       
   106     CFsTreeNodeVisualizerBase::SetExpanded(aFlag, aData);
       
   107     if (aData)
       
   108         {
       
   109         const CFsTreePlainOneLineNodeData* data =
       
   110                                 static_cast<const CFsTreePlainOneLineNodeData*>(aData);
       
   111         if (iIconVisual)
       
   112             {
       
   113             if ( IsExpanded())
       
   114                 {
       
   115                 if (data->IsIconExpandedSet())
       
   116                     {
       
   117                     iIconVisual->SetImage(TAlfImage( data->IconExpanded ()));
       
   118                     }
       
   119                 }
       
   120             else
       
   121                 {
       
   122                 if (data->IsIconCollapsedSet())
       
   123                     {
       
   124                     iIconVisual->SetImage(TAlfImage( data->IconCollapsed()));
       
   125                     }
       
   126                 }
       
   127             }
       
   128         }
       
   129     }
       
   130 
       
   131 
       
   132 // ---------------------------------------------------------------------------
       
   133 // From MFsTreeItemVisualizer.
       
   134 // Sets item's visualization state to extended.
       
   135 // Node cannot be extended - the function has no effect.
       
   136 // ---------------------------------------------------------------------------
       
   137 //
       
   138 void CFsTreePlainOneLineNodeVisualizer::SetExtended( TBool /*aIsExtended*/ )
       
   139     {
       
   140     FUNC_LOG;
       
   141     iFlags &= ~KFsTreeListItemExtended;
       
   142     }
       
   143 
       
   144 
       
   145 // ---------------------------------------------------------------------------
       
   146 // From MFsTreeItemVisualizer.
       
   147 // Returns extended/not extended state of the item visualization.
       
   148 // Node cannot be extended - the function always returns EFalse.
       
   149 // ---------------------------------------------------------------------------
       
   150 //
       
   151 TBool CFsTreePlainOneLineNodeVisualizer::IsExtended() const
       
   152     {
       
   153     FUNC_LOG;
       
   154     return EFalse;
       
   155     }
       
   156 
       
   157 
       
   158 // ---------------------------------------------------------------------------
       
   159 // From MFsTreeItemVisualizer.
       
   160 // Sets if an item can be in expanded state or not.
       
   161 // Node is not extendable - the function has no effect.
       
   162 // ---------------------------------------------------------------------------
       
   163 //
       
   164 void CFsTreePlainOneLineNodeVisualizer::SetExtendable( TBool /*aIsExtendable*/ )
       
   165     {
       
   166     FUNC_LOG;
       
   167     iFlags &= ~KFsTreeListItemExtendable;
       
   168     }
       
   169 
       
   170 
       
   171 // ---------------------------------------------------------------------------
       
   172 // From MFsTreeItemVisualizer.
       
   173 // Returns an information if item can be in expanded state.
       
   174 // Node is not extendable - the function always returns EFalse.
       
   175 // ---------------------------------------------------------------------------
       
   176 //
       
   177 TBool CFsTreePlainOneLineNodeVisualizer::IsExtendable( )
       
   178     {
       
   179     FUNC_LOG;
       
   180     return EFalse;
       
   181     }
       
   182 
       
   183 
       
   184 // ---------------------------------------------------------------------------
       
   185 // From MFsTreeItemVisualizer.
       
   186 // This functions sets wether an item should always be in extended state.
       
   187 // Node cannot be made always extended. This function has no effect.
       
   188 // ---------------------------------------------------------------------------
       
   189 //
       
   190 void CFsTreePlainOneLineNodeVisualizer::SetAlwaysExtended( TBool /*aAlwaysExtended*/ )
       
   191     {
       
   192     FUNC_LOG;
       
   193     iFlags &= ~KFsTreeListItemAlwaysExtended;
       
   194     }
       
   195 
       
   196 
       
   197 // ---------------------------------------------------------------------------
       
   198 // From MFsTreeItemVisualizer.
       
   199 // This function returns wether an item is always in extended state.
       
   200 // Node cannot be made always extended. The function always returns EFalse.
       
   201 // ---------------------------------------------------------------------------
       
   202 //
       
   203 TBool CFsTreePlainOneLineNodeVisualizer::IsAlwaysExtended( ) const
       
   204     {
       
   205     FUNC_LOG;
       
   206     return EFalse;
       
   207     }
       
   208 
       
   209 // ---------------------------------------------------------------------------
       
   210 // From class MFsTreeItemVisualizer.
       
   211 // Sets the size of the item visualization when item is not in expanded
       
   212 // state. The value is taken from layout manager.
       
   213 // ---------------------------------------------------------------------------
       
   214 //
       
   215 void CFsTreePlainOneLineNodeVisualizer::UpdateLayout(
       
   216         const CFsTreePlainOneLineNodeData* aData,
       
   217         const TInt aIndentation,
       
   218         CAlfTexture*& /*aMarkIcon*/,
       
   219         CAlfTexture*& /*aMenuIcon*/
       
   220         )
       
   221     {
       
   222     FUNC_LOG;
       
   223     TRect rect;
       
   224 
       
   225     TAlfTimedPoint tpMainIconTl, tpMainIconBr;
       
   226     TAlfTimedPoint tpTextTl, tpTextBr;
       
   227     TAlfTimedPoint tpMarkIconTl, tpMarkIconBr;
       
   228     TAlfTimedPoint tpMenuIconTl, tpMenuIconBr;
       
   229 
       
   230     // <cmail> Platform layout change
       
   231     /*CFsLayoutManager::TFsLayoutMetrics
       
   232         mainIconMetrics = CFsLayoutManager::EFsLmListMediumLineG3G1,
       
   233         markIconMetrics = CFsLayoutManager::EFsLmListMediumLineG3G2,
       
   234         menuIconMetrics = CFsLayoutManager::EFsLmListMediumLineG3G3,
       
   235         textMetrics     = CFsLayoutManager::EFsLmListMediumLineG3T1,
       
   236         sizeMetrics     = CFsLayoutManager::EFsLmListSingleDycRowPane;*/
       
   237 
       
   238 
       
   239     CFsLayoutManager::TFsLayoutMetrics mainIconMetrics =
       
   240         CFsLayoutManager::EFsLmListSingleDycRowPaneG1;
       
   241     CFsLayoutManager::TFsLayoutMetrics markIconMetrics =
       
   242         CFsLayoutManager::EFsLmListSingleDycRowPaneG4;
       
   243     CFsLayoutManager::TFsLayoutMetrics menuIconMetrics =
       
   244         CFsLayoutManager::EFsLmListSingleDycRowPaneG3;
       
   245     CFsLayoutManager::TFsLayoutMetrics textMetrics =
       
   246         CFsLayoutManager::EFsLmListSingleDycRowTextPaneT1;
       
   247 
       
   248     TInt mainIconVariety( 0 );
       
   249     TInt markIconVariety( 0 );
       
   250     TInt menuIconVariety( 0 );
       
   251     TInt textPaneVariety( 0 );
       
   252     // </cmail> Platform layout change
       
   253 
       
   254     if (aData->IsIconCollapsedSet())
       
   255         {
       
   256         if (iFlags & KFsTreeListItemMarked)
       
   257             {
       
   258             if ((iFlags & KFsTreeListItemHasMenu)
       
   259                     && (iFlags & KFsTreeListItemFocused))
       
   260                 {
       
   261                 // <cmail> Platform layout change
       
   262                 //mainIcon + markIcon + menuIcon
       
   263                 //the metrics defined when declared
       
   264                 mainIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG1;
       
   265                 menuIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG3;
       
   266                 markIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG4;
       
   267                 mainIconVariety = 3;
       
   268                 textPaneVariety = 3;
       
   269                 menuIconVariety = 1;
       
   270                 markIconVariety = 2;
       
   271                 // </cmail> Platform layout change
       
   272                 }
       
   273             else
       
   274                 {
       
   275                 // <cmail> Platform layout change
       
   276                 //mainIcon + markIcon
       
   277                 /*
       
   278                 mainIconMetrics = CFsLayoutManager::EFsLmListMediumLineG2G1;
       
   279                 markIconMetrics = CFsLayoutManager::EFsLmListMediumLineG2G2;
       
   280                 textMetrics     = CFsLayoutManager::EFsLmListMediumLineG2T1;
       
   281                 */
       
   282                 mainIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG1;
       
   283                 markIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG4;
       
   284                 mainIconVariety = 4;
       
   285                 textPaneVariety = 4;
       
   286                 markIconVariety = 3;
       
   287                 // </cmail> Platform layout change
       
   288                 }
       
   289             }
       
   290         else
       
   291             {
       
   292             if ((iFlags & KFsTreeListItemHasMenu)
       
   293                     && (iFlags & KFsTreeListItemFocused))
       
   294                 {
       
   295                 // <cmail> Platform layout change
       
   296                 //mainIcon + menuIcon
       
   297                 /*mainIconMetrics = CFsLayoutManager::EFsLmListMediumLineG2G1;
       
   298                 menuIconMetrics = CFsLayoutManager::EFsLmListMediumLineG2G2;
       
   299                 textMetrics     = CFsLayoutManager::EFsLmListMediumLineG2T1;*/
       
   300                 mainIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG1;
       
   301                 menuIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG4;
       
   302                 mainIconVariety = 4;
       
   303                 textPaneVariety = 4;
       
   304                 menuIconVariety = 3;
       
   305                 // </cmail> Platform layout change
       
   306                 }
       
   307             else
       
   308                 {
       
   309                 if ( IsLayoutHintSet( EFolderLayout ) )
       
   310 	                {
       
   311 	                //mainIcon
       
   312 	                mainIconMetrics = CFsLayoutManager::EFsLmFolderListMediumLineG1;
       
   313 	                textMetrics     = CFsLayoutManager::EFsLmFolderListMediumLineT1;
       
   314 	                }
       
   315 	            else
       
   316 		            {
       
   317 		            // <cmail> Platform layout change
       
   318 	                //mainIcon
       
   319 		            /*
       
   320 	                mainIconMetrics = CFsLayoutManager::EFsLmListMediumLineG1;
       
   321 	                textMetrics     = CFsLayoutManager::EFsLmListMediumLineT1;*/
       
   322                     mainIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG1;
       
   323                     mainIconVariety = 5;
       
   324                     textPaneVariety = 5;
       
   325                     // </cmail> Platform layout change
       
   326 		            }
       
   327                 }
       
   328             }
       
   329         }
       
   330     else
       
   331         {
       
   332         if (iFlags & KFsTreeListItemMarked)
       
   333             {
       
   334             if ((iFlags & KFsTreeListItemHasMenu)
       
   335                     && (iFlags & KFsTreeListItemFocused))
       
   336                 {
       
   337                 // <cmail> Platform layout change
       
   338                 //markIcon + menuIcon
       
   339                 /*
       
   340                 markIconMetrics =
       
   341                     CFsLayoutManager::EFsLmListMediumLineRightIconx2G1;
       
   342                 menuIconMetrics =
       
   343                     CFsLayoutManager::EFsLmListMediumLineRightIconx2G2;
       
   344                 textMetrics     =
       
   345                     CFsLayoutManager::EFsLmListMediumLineRightIconx2T1;*/
       
   346                 menuIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG3;
       
   347                 markIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG4;
       
   348                 menuIconVariety = 2;
       
   349                 markIconVariety = 4;
       
   350                 textPaneVariety = 6;
       
   351                 // </cmail> Platform layout change
       
   352                 }
       
   353             else
       
   354                 {
       
   355                 // <cmail> Platform layout change
       
   356                 //markIcon
       
   357                 /*
       
   358                 markIconMetrics =
       
   359                     CFsLayoutManager::EFsLmListMediumLineRightIconG1;
       
   360                 textMetrics     =
       
   361                     CFsLayoutManager::EFsLmListMediumLineRightIconT1;*/
       
   362                 markIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG4;
       
   363                 markIconVariety = 5;
       
   364                 textPaneVariety = 7;
       
   365                 // </cmail> Platform layout change
       
   366                 }
       
   367             }
       
   368         else
       
   369             {
       
   370             if ((iFlags & KFsTreeListItemHasMenu)
       
   371                     && (iFlags & KFsTreeListItemFocused))
       
   372                 {
       
   373                 // <cmail> Platform layout change
       
   374                 //menuIcon
       
   375                 /*
       
   376                 menuIconMetrics =
       
   377                     CFsLayoutManager::EFsLmListMediumLineRightIconG1;
       
   378                 textMetrics     =
       
   379                     CFsLayoutManager::EFsLmListMediumLineRightIconT1;*/
       
   380                 menuIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG4;
       
   381                 menuIconVariety = 5;
       
   382                 textPaneVariety = 7;
       
   383                 // </cmail> Platform layout change
       
   384                 }
       
   385             else
       
   386                 {
       
   387                 // <cmail> Platform layout change
       
   388                 //plain item
       
   389                 /*textMetrics     =
       
   390                     CFsLayoutManager::EFsLmListMediumLinePlainT1;*/
       
   391                 textPaneVariety = 8;
       
   392                 // </cmail> Platform layout change
       
   393                 }
       
   394             }
       
   395         }
       
   396     //layout manager is queried for medium values - LM returnes rects based on phone's global text settings
       
   397 
       
   398     TRect parentLayoutRect = TRect(iParentLayout->Size().Target().AsSize());
       
   399     parentLayoutRect.Resize(-(iParentLayout->HorizontalPadding()*2), 0);
       
   400 
       
   401     if (iFlags & KFsTreeListItemManagedLayout)
       
   402         {
       
   403         // <cmail> Platform layout change
       
   404         /*CFsLayoutManager::LayoutMetricsSize(
       
   405                 parentLayoutRect,
       
   406                 sizeMetrics,
       
   407                 iSize );*/
       
   408         CFsLayoutManager::LayoutMetricsSize(
       
   409                 parentLayoutRect,
       
   410                 CFsLayoutManager::EFsLmListSingleDycRowPane,
       
   411                 iSize );
       
   412         // </cmail> Platform layout change
       
   413         }
       
   414 
       
   415     //one line node is not extendable
       
   416     TRect currentSize = iSize;
       
   417     if (CFsLayoutManager::IsMirrored())
       
   418         {
       
   419         currentSize.iBr = currentSize.iBr - TPoint(aIndentation, 0);
       
   420         }
       
   421     else
       
   422         {
       
   423         currentSize.iTl = currentSize.iTl + TPoint(aIndentation, 0);
       
   424         }
       
   425 
       
   426 
       
   427     // <cmail> Platform layout change
       
   428     /*CFsLayoutManager::LayoutMetricsRect(
       
   429             currentSize,
       
   430             mainIconMetrics,
       
   431             rect );*/
       
   432     CFsLayoutManager::LayoutMetricsRect(
       
   433                 currentSize,
       
   434                 mainIconMetrics,
       
   435                 rect,
       
   436                 mainIconVariety );
       
   437     // </cmail> Platform layout change
       
   438     tpMainIconTl.SetTarget(TAlfRealPoint(rect.iTl));
       
   439     tpMainIconBr.SetTarget(TAlfRealPoint(rect.iBr));
       
   440 
       
   441     // <cmail> Platform layout change
       
   442     /*CFsLayoutManager::LayoutMetricsRect(
       
   443             currentSize,
       
   444             markIconMetrics,
       
   445             rect );*/
       
   446     CFsLayoutManager::LayoutMetricsRect(
       
   447             currentSize,
       
   448             markIconMetrics,
       
   449             rect,
       
   450             markIconVariety );
       
   451     // </cmail> Platform layout change
       
   452     tpMarkIconTl.SetTarget(TAlfRealPoint(rect.iTl));
       
   453     tpMarkIconBr.SetTarget(TAlfRealPoint(rect.iBr));
       
   454 
       
   455     // <cmail> Platform layout change
       
   456     /*CFsLayoutManager::LayoutMetricsRect(
       
   457             currentSize,
       
   458             menuIconMetrics,
       
   459             rect );*/
       
   460     CFsLayoutManager::LayoutMetricsRect(
       
   461             currentSize,
       
   462             menuIconMetrics,
       
   463             rect,
       
   464             menuIconVariety );
       
   465     // </cmail> Platform layout change
       
   466     tpMenuIconTl.SetTarget(TAlfRealPoint(rect.iTl));
       
   467     tpMenuIconBr.SetTarget(TAlfRealPoint(rect.iBr));
       
   468 
       
   469     // <cmail> Platform layout change
       
   470     TRect textRect( currentSize );
       
   471     if (textMetrics == CFsLayoutManager::EFsLmListSingleDycRowTextPaneT1)
       
   472         {
       
   473         CFsLayoutManager::LayoutMetricsRect(
       
   474                     currentSize,
       
   475                     CFsLayoutManager::EFsLmListSingleDycRowTextPane,
       
   476                     textRect,
       
   477                     textPaneVariety );
       
   478         }
       
   479 
       
   480     CFsLayoutManager::TFsText textInfo;
       
   481     /*CFsLayoutManager::LayoutMetricsText(currentSize, textMetrics, textInfo,
       
   482             textVariety);*/
       
   483 
       
   484     CFsLayoutManager::LayoutMetricsText(textRect,
       
   485             textMetrics, textInfo, textPaneVariety);
       
   486     // </cmail> Platform layout change
       
   487 
       
   488     tpTextTl.SetTarget(TAlfRealPoint(textInfo.iTextRect.iTl));
       
   489     tpTextBr.SetTarget(TAlfRealPoint(textInfo.iTextRect.iBr));
       
   490 
       
   491     TInt visualIconIndex = iLayout->FindVisual(iIconVisual);
       
   492     if ( visualIconIndex != KErrNotFound )
       
   493         {
       
   494         iLayout->SetAnchor( EAlfAnchorTopLeft,
       
   495                 visualIconIndex,
       
   496                 EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
       
   497                 EAlfAnchorMetricAbsolute,
       
   498                 EAlfAnchorMetricAbsolute,
       
   499                 tpMainIconTl );
       
   500         iLayout->SetAnchor( EAlfAnchorBottomRight,
       
   501                 visualIconIndex,
       
   502                 EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
       
   503                 EAlfAnchorMetricAbsolute,
       
   504                 EAlfAnchorMetricAbsolute,
       
   505                 tpMainIconBr );
       
   506         }
       
   507 
       
   508     if ((iFlags & KFsTreeListItemHasMenu)
       
   509             && (iFlags & KFsTreeListItemFocused))
       
   510         {
       
   511         TInt iconMenuVisIndex = iLayout->FindVisual(iIconMenu);
       
   512         if ( iconMenuVisIndex != KErrNotFound )
       
   513             {
       
   514             iLayout->SetAnchor(EAlfAnchorTopLeft,
       
   515                     iconMenuVisIndex,
       
   516                     EAlfAnchorOriginLeft,EAlfAnchorOriginTop,
       
   517                     EAlfAnchorMetricAbsolute,EAlfAnchorMetricAbsolute,
       
   518                     tpMenuIconTl );
       
   519             iLayout->SetAnchor(EAlfAnchorBottomRight,
       
   520                     iconMenuVisIndex,
       
   521                     EAlfAnchorOriginLeft,EAlfAnchorOriginTop,
       
   522                     EAlfAnchorMetricAbsolute,EAlfAnchorMetricAbsolute,
       
   523                     tpMenuIconBr );
       
   524 
       
   525             TAlfTimedValue opacity;
       
   526             opacity.SetValueNow(1.0f);
       
   527             iIconMenu->SetOpacity(opacity);
       
   528             }
       
   529         }
       
   530     else
       
   531         {
       
   532         TAlfTimedValue opacity;
       
   533         opacity.SetValueNow(0.0f);
       
   534         iIconMenu->SetOpacity(opacity);
       
   535         }
       
   536 
       
   537     if (iViewportLayout)
       
   538         {
       
   539         TInt textVisIndex = iLayout->FindVisual(iViewportLayout);
       
   540         if ( textVisIndex != KErrNotFound )
       
   541             {
       
   542             iLayout->SetAnchor(EAlfAnchorTopLeft,
       
   543                     textVisIndex,
       
   544                     EAlfAnchorOriginLeft,EAlfAnchorOriginTop,
       
   545                     EAlfAnchorMetricAbsolute,
       
   546                     EAlfAnchorMetricAbsolute,
       
   547                     tpTextTl );
       
   548             iLayout->SetAnchor(EAlfAnchorBottomRight,
       
   549                     textVisIndex,
       
   550                     EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
       
   551                     EAlfAnchorMetricAbsolute,
       
   552                     EAlfAnchorMetricAbsolute,
       
   553                     tpTextBr );
       
   554             }
       
   555         }
       
   556 
       
   557     if ( iFlags & KFsTreeListItemMarked )
       
   558         {
       
   559         TInt iconMarkedVisIndex =
       
   560                             iLayout->FindVisual(iIconMarked);
       
   561         if ( iconMarkedVisIndex != KErrNotFound )
       
   562             {
       
   563             iLayout->SetAnchor(EAlfAnchorTopLeft,
       
   564                     iconMarkedVisIndex,
       
   565                     EAlfAnchorOriginLeft,EAlfAnchorOriginTop,
       
   566                     EAlfAnchorMetricAbsolute,
       
   567                     EAlfAnchorMetricAbsolute,
       
   568                     tpMarkIconTl );
       
   569             iLayout->SetAnchor(EAlfAnchorBottomRight,
       
   570                     iconMarkedVisIndex,
       
   571                     EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
       
   572                     EAlfAnchorMetricAbsolute,
       
   573                     EAlfAnchorMetricAbsolute,
       
   574                     tpMarkIconBr );
       
   575 
       
   576             TAlfTimedValue opacity;
       
   577             opacity.SetValueNow(1.0f);
       
   578             iIconMarked->SetOpacity(opacity);
       
   579             }
       
   580         }
       
   581     else
       
   582         {
       
   583         if (iIconMarked)
       
   584             {
       
   585             TAlfTimedValue opacity;
       
   586             opacity.SetValueNow(0.0f);
       
   587             iIconMarked->SetOpacity(opacity);
       
   588             }
       
   589         }
       
   590     iLayout->UpdateChildrenLayout();
       
   591 
       
   592     }
       
   593 
       
   594 // ---------------------------------------------------------------------------
       
   595 // From class MFsTreeItemVisualizer.
       
   596 // A call to this function means that the node is requested to draw itself
       
   597 // within specified parent layout.
       
   598 // ---------------------------------------------------------------------------
       
   599 //
       
   600 void CFsTreePlainOneLineNodeVisualizer::ShowL( CAlfLayout& aParentLayout,
       
   601                                         const TUint aTimeout )
       
   602     {
       
   603     FUNC_LOG;
       
   604 
       
   605 
       
   606     if (!iLayout)
       
   607         {
       
   608         iParentLayout = &aParentLayout;
       
   609 
       
   610         iLayout = CAlfAnchorLayout::AddNewL( iOwnerControl, iParentLayout );
       
   611         iLayout->SetTactileFeedbackL( ETouchEventStylusDown, ETouchFeedbackBasic );
       
   612         iLayout->EnableBrushesL();
       
   613         iLayout->SetClipping(ETrue);
       
   614 
       
   615         if (!iIconVisual)
       
   616             {
       
   617             iIconVisual = CAlfImageVisual::AddNewL(iOwnerControl,iLayout);
       
   618             iIconVisual->SetScaleMode( CAlfImageVisual::EScaleNormal );
       
   619             iIconVisual->SetFlag( EAlfVisualFlagIgnorePointer );
       
   620             }
       
   621 
       
   622         if (!iViewportLayout)
       
   623             {
       
   624             iViewportLayout =
       
   625                       CAlfViewportLayout::AddNewL(iOwnerControl, iLayout);
       
   626             iViewportLayout->SetFlag( EAlfVisualFlagIgnorePointer );
       
   627             }
       
   628 
       
   629         if (!iTextVisual)
       
   630             {
       
   631             iTextVisual = CAlfTextVisual::AddNewL(iOwnerControl, iViewportLayout);
       
   632             iTextVisual->SetStyle(EAlfTextStyleSmall, EAlfBackgroundTypeLight);
       
   633             iTextVisual->SetStyle(EAlfTextStyleSmall);
       
   634             iTextVisual->SetFlag( EAlfVisualFlagIgnorePointer );
       
   635             }
       
   636 
       
   637         if (!iIconMarked)
       
   638             {
       
   639             iIconMarked = CAlfImageVisual::AddNewL( iOwnerControl, iLayout );
       
   640             iIconMarked->SetScaleMode( CAlfImageVisual::EScaleNormal);
       
   641             iIconMarked->SetFlag( EAlfVisualFlagIgnorePointer );
       
   642             }
       
   643 
       
   644         if (!iIconMenu)
       
   645             {
       
   646             iIconMenu =
       
   647                         CAlfImageVisual::AddNewL(iOwnerControl, iLayout);
       
   648             iIconMenu->SetScaleMode( CAlfImageVisual::EScaleNormal);
       
   649             iIconMenu->SetFlag( EAlfVisualFlagIgnorePointer );
       
   650             }
       
   651 
       
   652         iTextMarquee = new (ELeave) TFsMarqueeClet(iOwnerControl, *iViewportLayout, TFsMarqueeClet::EScrollFromRight, TFsMarqueeClet::EScrollForth);
       
   653         }
       
   654     else
       
   655         {
       
   656         if (!iLayout->Layout())
       
   657             {
       
   658             aParentLayout.Append(iLayout, aTimeout);
       
   659             iParentLayout = &aParentLayout;
       
   660             }
       
   661         }
       
   662     }
       
   663 
       
   664 // ---------------------------------------------------------------------------
       
   665 // A call to this function means that the item is requested to update its
       
   666 // visual content.
       
   667 // ---------------------------------------------------------------------------
       
   668 //
       
   669 void CFsTreePlainOneLineNodeVisualizer::UpdateL( const MFsTreeItemData& aData,
       
   670                                           TBool aFocused,
       
   671                                           const TUint aLevel,
       
   672                                           CAlfTexture*& aMarkIcon,
       
   673                                           CAlfTexture*& aMenuIcon,
       
   674                                           const TUint /*aTimeout*/,
       
   675                                           TBool aUpdateData)
       
   676     {
       
   677     FUNC_LOG;
       
   678 
       
   679     if (iLayout)
       
   680         {
       
   681         iSize.iWidth = iParentLayout->Size().Target().iX;
       
   682         iExtendedSize.iWidth = iSize.iWidth;
       
   683         
       
   684         TSize layoutSize(iLayout->Size().Target().iX, iLayout->Size().Target().iY);
       
   685         layoutSize.iWidth = iSize.iWidth;
       
   686         iLayout->SetSize(layoutSize);
       
   687         
       
   688         if (aFocused)
       
   689             {
       
   690             if (IsFocusable())
       
   691                 {
       
   692                 iFlags |= KFsTreeListItemFocused;
       
   693                 }
       
   694             }
       
   695         else
       
   696             {
       
   697             iFlags &= ~KFsTreeListItemFocused;
       
   698             }
       
   699 
       
   700         if ( aData.Type() == KFsTreePlainOneLineNodeDataType )
       
   701             {
       
   702             const CFsTreePlainOneLineNodeData* data =
       
   703                         static_cast<const CFsTreePlainOneLineNodeData*>(&aData);
       
   704 
       
   705             //update the ancors for current item settings
       
   706             const TInt indent( iTextIndentation * ( aLevel - 1 ) );
       
   707             UpdateLayout(data, indent, aMarkIcon, aMenuIcon);
       
   708 
       
   709             if (iTextVisual && aUpdateData)
       
   710                 {
       
   711                 //get text color
       
   712                 TRgb textColor;
       
   713                 if ( aFocused )
       
   714                     {
       
   715                     if (!iIsCustomTextFocusedColor)
       
   716                         {//custom color not set, use color from skin - load it in case theme has changed
       
   717                         iFocusedTextColor = FocusedStateTextSkinColor();
       
   718                         }
       
   719                     textColor = iFocusedTextColor;
       
   720                     }
       
   721                 else
       
   722                     {
       
   723                     if (!iIsCustomTextNormalColor)
       
   724                         {//custom color not set, use color from skin - load it in case theme has changed
       
   725                         iNormalTextColor = NormalStateTextSkinColor( );
       
   726                         }
       
   727                     textColor = iNormalTextColor;
       
   728                     }
       
   729 
       
   730                 //get text style
       
   731                 TInt styleId = ModifiedStyleIdL( );
       
   732 
       
   733                 iTextVisual->Env().CancelCustomCommands(this);
       
   734 
       
   735                 TAlfTimedPoint tp(0,0);
       
   736                 tp.SetStyle(EAlfTimedValueStyleLinear);
       
   737                 iTextVisual->SetPos(tp);
       
   738                 iTextVisual->SetTextL(data->Data( ));
       
   739 
       
   740                 iTextVisual->EnableShadow(iFlags & KFsTreeListItemTextShadow);
       
   741                 iTextVisual->SetColor( textColor );
       
   742                 iTextVisual->SetTextStyle( styleId );
       
   743 
       
   744                 iTextVisual->SetWrapping(CAlfTextVisual::ELineWrapManual);
       
   745 
       
   746                 TAlfAlignHorizontal currTextAlign( EAlfAlignHLocale );
       
   747                 currTextAlign = CurrentTextAlignmentL( iTextAlign, &data->Data(), iTextVisual );
       
   748                 iTextVisual->SetAlign( currTextAlign, EAlfAlignVCenter );
       
   749 
       
   750                 iTextVisual->SetWrapping(CAlfTextVisual::ELineWrapTruncate);
       
   751 
       
   752                 if ( currTextAlign == EAlfAlignHRight )
       
   753                     {
       
   754                     iTextMarquee->SetScrollDirection( TFsMarqueeClet::EScrollFromLeft );
       
   755                     }
       
   756                 else
       
   757                     {
       
   758                     iTextMarquee->SetScrollDirection( TFsMarqueeClet::EScrollFromRight );
       
   759                     }
       
   760                 }
       
   761 
       
   762             if ( iIconVisual )
       
   763                 {
       
   764                 if ( IsExpanded())
       
   765                     {
       
   766                     if (data->IsIconExpandedSet())
       
   767                         {
       
   768                         iIconVisual->SetImage(TAlfImage( data->IconExpanded ()));
       
   769                         }
       
   770                     }
       
   771                 else
       
   772                     {
       
   773                     if (data->IsIconCollapsedSet())
       
   774                         {
       
   775                         iIconVisual->SetImage(TAlfImage( data->IconCollapsed()));
       
   776                         }
       
   777                     }
       
   778                 }
       
   779 
       
   780             if ( IsMarked() && iIconMarked && aMarkIcon )
       
   781                 {
       
   782                 iIconMarked->SetImage( *aMarkIcon );
       
   783                 }
       
   784 
       
   785             if ( (iFlags & KFsTreeListItemHasMenu) && iIconMenu && aMenuIcon )
       
   786                 {
       
   787                 iIconMenu->SetImage( *aMenuIcon );
       
   788                 }
       
   789 
       
   790             iTextMarquee->StopScrolling();
       
   791             iTextVisual->SetWrapping(CAlfTextVisual::ELineWrapTruncate);
       
   792             }
       
   793         }
       
   794     }
       
   795 
       
   796 // ---------------------------------------------------------------------------
       
   797 // From class MFsTreeItemVisualizer.
       
   798 // A call to this function means that the node goes out of the visible items
       
   799 // scope.
       
   800 // ---------------------------------------------------------------------------
       
   801 //
       
   802 void CFsTreePlainOneLineNodeVisualizer::Hide( const TInt aTimeout )
       
   803     {
       
   804     FUNC_LOG;
       
   805     if ( iLayout )
       
   806         {
       
   807         //if marquee command was sent
       
   808         iTextVisual->Env().CancelCustomCommands(this);
       
   809 
       
   810         delete iTextMarquee;
       
   811         iTextMarquee = NULL; //it has to be here
       
   812 
       
   813         iParentLayout->Remove(iLayout, aTimeout);
       
   814         iLayout->RemoveAndDestroyAllD();
       
   815         iLayout = NULL;
       
   816         iParentLayout = NULL;
       
   817         iIconVisual = NULL;
       
   818         iIconMarked = NULL;
       
   819         iIconMenu = NULL;
       
   820         iTextVisual = NULL;
       
   821         iViewportLayout = NULL;
       
   822         }
       
   823     }
       
   824 
       
   825 
       
   826 // ---------------------------------------------------------------------------
       
   827 // From MFsTreeItemVisualizer.
       
   828 //  Method to marquee the text when it's too long.
       
   829 // ---------------------------------------------------------------------------
       
   830 //
       
   831 void CFsTreePlainOneLineNodeVisualizer::MarqueeL(const TFsTextMarqueeType aMarqueeType,
       
   832                                                  const TUint aMarqueeSpeed,
       
   833                                                  const TInt aMarqueeStartDelay,
       
   834                                                  const TInt aMarqueeCycleStartDelay,
       
   835                                                  const TInt aMarqueeRepetitions)
       
   836     {
       
   837     FUNC_LOG;
       
   838     TInt marqueeSize(0), textWidth(0);
       
   839 
       
   840     if ( aMarqueeType == EFsTextMarqueeNone )
       
   841         {
       
   842         return;
       
   843         }
       
   844 
       
   845     iTextVisual->SetWrapping(CAlfTextVisual::ELineWrapManual);
       
   846 
       
   847     textWidth = iTextVisual->SubstringExtents(0, iTextVisual->Text().Length()).Width();
       
   848     marqueeSize = textWidth - iViewportLayout->Size().iX.Target();
       
   849 
       
   850     if (iTextVisual && (marqueeSize>0))
       
   851         {
       
   852         TSize size(textWidth,iViewportLayout->Size().iY.Target());
       
   853         if ( aMarqueeType == EFsTextMarqueeForth )
       
   854             {
       
   855             iTextMarquee->SetScrollType( TFsMarqueeClet::EScrollForth );
       
   856             }
       
   857         else if ( aMarqueeType == EFsTextMarqueeForthBack )
       
   858             {
       
   859             iTextMarquee->SetScrollType( TFsMarqueeClet::EScrollBounce );
       
   860             }
       
   861         else if ( aMarqueeType == EFsTextMarqueeLoop )
       
   862             {
       
   863             iTextMarquee->SetScrollType( TFsMarqueeClet::EScrollWrap );
       
   864             //duplicate text
       
   865             TBufC <1> separator(_L(" "));
       
   866             HBufC* textHeap = HBufC::NewLC( (iTextVisual->Text().Length()+1)*2+1);
       
   867             TPtr doubleString(textHeap->Des());
       
   868             doubleString = iTextVisual->Text();
       
   869             doubleString.Append(_L(" "));
       
   870             doubleString.Append(iTextVisual->Text());
       
   871             doubleString.Append(_L(" "));
       
   872             iTextVisual->SetTextL( doubleString );
       
   873             CleanupStack::PopAndDestroy(textHeap);
       
   874             size.iWidth = iTextVisual->SubstringExtents(0, iTextVisual->Text().Length()).Width();
       
   875             }
       
   876 
       
   877         iTextMarquee->SetScrollRepetitions( aMarqueeRepetitions );
       
   878         TInt time(0);
       
   879         if ( aMarqueeType == EFsTextMarqueeLoop )
       
   880             {
       
   881             time = textWidth * 1000 / aMarqueeSpeed;
       
   882             }
       
   883         else
       
   884             {
       
   885             time = marqueeSize * 1000 / aMarqueeSpeed;
       
   886             }
       
   887         iTextMarquee->SetScrollSpeed( time );
       
   888         iTextMarquee->SetScrollableArea( size );
       
   889         iTextMarquee->SetScrollCycleDelay( aMarqueeCycleStartDelay );
       
   890 
       
   891         iTextVisual->Env().CancelCustomCommands( this, aMarqueeType );
       
   892         TAlfCustomEventCommand cmd( aMarqueeType, this, 0 );
       
   893         iTextVisual->Env().Send(cmd, aMarqueeStartDelay );
       
   894         }
       
   895     }
       
   896 
       
   897 
       
   898 // ---------------------------------------------------------------------------
       
   899 //  Handles custom Alf event. Used with text marquee.
       
   900 // ---------------------------------------------------------------------------
       
   901 //
       
   902 TBool CFsTreePlainOneLineNodeVisualizer::OfferEventL(const TAlfEvent& aEvent)
       
   903     {
       
   904     FUNC_LOG;
       
   905     TBool ret( EFalse );
       
   906     if ( aEvent.IsCustomEvent() )
       
   907         {
       
   908         TInt param = aEvent.CustomParameter();
       
   909         if ( param == EFsTextMarqueeForth ||
       
   910              param == EFsTextMarqueeForthBack ||
       
   911              param == EFsTextMarqueeLoop )
       
   912             {
       
   913             ret = ETrue;
       
   914             iTextMarquee->StartScrolling( );
       
   915             }
       
   916         }
       
   917     return ret;
       
   918     }
       
   919 
       
   920 // ---------------------------------------------------------------------------
       
   921 //  C++ constructor.
       
   922 // ---------------------------------------------------------------------------
       
   923 //
       
   924 CFsTreePlainOneLineNodeVisualizer::CFsTreePlainOneLineNodeVisualizer
       
   925                                                 ( CAlfControl& aOwnerControl )
       
   926     : CFsTreeNodeVisualizerBase( aOwnerControl )
       
   927 
       
   928     {
       
   929     FUNC_LOG;
       
   930 
       
   931     }
       
   932 
       
   933 // ---------------------------------------------------------------------------
       
   934 //  Second phase constructor.
       
   935 // ---------------------------------------------------------------------------
       
   936 //
       
   937 void CFsTreePlainOneLineNodeVisualizer::ConstructL( )
       
   938     {
       
   939     FUNC_LOG;
       
   940     //get default skin values
       
   941     CFsTreeNodeVisualizerBase::ConstructL();
       
   942     }
       
   943