emailuis/uicomponents/src/fstextviewerselect.cpp
changeset 0 8466d47a6819
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:  Base class for selectables (hotspots and expand areas)
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //<cmail> removed __FS_ALFRED_SUPPORT flag
       
    20 //#include <fsconfig.h>
       
    21 //</cmail> removed __FS_ALFRED_SUPPORT flag
       
    22 // <cmail> SF
       
    23 #include "emailtrace.h"
       
    24 #include <alf/alfvisual.h>
       
    25 #include <alf/alftextvisual.h>
       
    26 // </cmail>
       
    27 #include "fstextviewerselect.h"
       
    28 
       
    29 #include "fstextviewervisualizer.h"
       
    30 #include "fstextviewervisualizerdata.h"
       
    31 #include "fstextviewerselectsmanager.h"
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // ~CFsTextViewerSelect
       
    35 // ---------------------------------------------------------------------------
       
    36 CFsTextViewerSelect::~CFsTextViewerSelect()
       
    37     {
       
    38     FUNC_LOG;
       
    39     iVisuals.Close();
       
    40     }
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // SetType
       
    44 // ---------------------------------------------------------------------------
       
    45 void CFsTextViewerSelect::SetType( TFsTextViewerSelectType aType )
       
    46     {
       
    47     FUNC_LOG;
       
    48     iType = aType;
       
    49     }
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // GetType
       
    53 // ---------------------------------------------------------------------------
       
    54 CFsTextViewerSelect::TFsTextViewerSelectType CFsTextViewerSelect::GetType()
       
    55     {
       
    56     FUNC_LOG;
       
    57     return iType;
       
    58     }
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // SetId
       
    62 // ---------------------------------------------------------------------------
       
    63 void CFsTextViewerSelect::SetId( TInt aId )
       
    64     {
       
    65     FUNC_LOG;
       
    66     iId = aId;
       
    67     }
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // GetId
       
    71 // ---------------------------------------------------------------------------
       
    72 TInt CFsTextViewerSelect::GetId() const
       
    73     {
       
    74     FUNC_LOG;
       
    75     return iId;
       
    76     }
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // AppendVisualL
       
    80 // ---------------------------------------------------------------------------
       
    81 void CFsTextViewerSelect::AppendVisualL( TFsRangedVisual* aVisual )
       
    82     {
       
    83     FUNC_LOG;
       
    84     for ( TInt i = 0; i < iVisuals.Count(); ++i )
       
    85         {
       
    86         if ( aVisual == iVisuals[i] )
       
    87             {
       
    88             return;
       
    89             }
       
    90         }
       
    91     if ( iVisuals.Count() > 0 )
       
    92         {
       
    93         iRect.iBr = aVisual->iRect.iBr;
       
    94         }
       
    95     else
       
    96         {
       
    97         iRect = aVisual->iRect;
       
    98         }
       
    99     iEndChar = aVisual->iEnd;
       
   100     iVisuals.AppendL( aVisual );
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // RemoveVisual
       
   105 // ---------------------------------------------------------------------------
       
   106 void CFsTextViewerSelect::RemoveVisual( TFsRangedVisual* aVisual )
       
   107     {
       
   108     FUNC_LOG;
       
   109     for ( TInt i = 0; i < iVisuals.Count(); ++i )
       
   110         {
       
   111         if ( iVisuals[i] == aVisual )
       
   112             {
       
   113             iVisuals.Remove( i );
       
   114             }
       
   115         }
       
   116     }
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // GetStartHeight
       
   120 // ---------------------------------------------------------------------------
       
   121 TInt CFsTextViewerSelect::GetStartHeight()
       
   122     {
       
   123     FUNC_LOG;
       
   124     TInt retVal = -1;
       
   125     for ( TInt i = 0; i < iVisuals.Count(); ++i )
       
   126         {
       
   127         if ( iVisuals[i]->iVisual->DisplayRectTarget().iTl.iY > retVal )
       
   128             {
       
   129             retVal = iVisuals[i]->iRect.iTl.iY;
       
   130             }
       
   131         }
       
   132     return retVal;
       
   133     }
       
   134 
       
   135 // ---------------------------------------------------------------------------
       
   136 // GetStartLine
       
   137 // ---------------------------------------------------------------------------
       
   138 TInt CFsTextViewerSelect::GetStartLine()
       
   139     {
       
   140     FUNC_LOG;
       
   141     TInt retVal = -1;
       
   142     CFsTextViewerVisualizerData* navigator = 
       
   143         iManager->Visualizer()->Navigator();
       
   144     for ( TInt i = 0; i < iVisuals.Count(); ++i )
       
   145         {
       
   146         if ( iVisuals[i]->iLineNumber < retVal 
       
   147               || retVal < 0 ) 
       
   148             {
       
   149             retVal = iVisuals[i]->iLineNumber;
       
   150             }
       
   151         }
       
   152     return retVal;
       
   153     }
       
   154 
       
   155 // ---------------------------------------------------------------------------
       
   156 // IsVisible
       
   157 // ---------------------------------------------------------------------------
       
   158 TBool CFsTextViewerSelect::IsVisible()
       
   159     {
       
   160     FUNC_LOG;
       
   161     TBool retVal = EFalse;
       
   162     TInt minY = -1;
       
   163     TInt maxY = -1;
       
   164     
       
   165     
       
   166     if ( iVisuals.Count() > 0 )
       
   167         {
       
   168         if ( !iVisuals[0]->iVisual )
       
   169             {
       
   170             retVal = EFalse;
       
   171             }
       
   172         else 
       
   173             {
       
   174             minY = iVisuals[0]->iVisual->DisplayRectTarget().iTl.iY;
       
   175             }
       
   176         }
       
   177 
       
   178     for ( TInt i = 0; i < iVisuals.Count(); ++i )
       
   179         {
       
   180         if ( !iVisuals[i]->iVisual )
       
   181             {
       
   182             retVal = EFalse;
       
   183             }
       
   184         else
       
   185             {
       
   186             if ( minY > iVisuals[i]->iVisual->DisplayRectTarget().iTl.iY )
       
   187                 {
       
   188                 minY = iVisuals[i]->iVisual->DisplayRectTarget().iTl.iY;
       
   189                 }
       
   190             if ( maxY < iVisuals[i]->iVisual->DisplayRectTarget().iBr.iY )
       
   191                 {
       
   192                 maxY = iVisuals[i]->iVisual->DisplayRectTarget().iBr.iY;
       
   193                 }
       
   194             }
       
   195         }
       
   196     TInt screenHeight = iManager->Visualizer()->iDisplaySize.iHeight;
       
   197     if ( minY >= 0 && maxY <= screenHeight )
       
   198         {
       
   199         retVal = ETrue;
       
   200         }
       
   201     
       
   202     return retVal;
       
   203     }
       
   204 
       
   205 // ---------------------------------------------------------------------------
       
   206 // ContructL
       
   207 // ---------------------------------------------------------------------------
       
   208 void CFsTextViewerSelect::ConstructL()
       
   209     {
       
   210     FUNC_LOG;
       
   211     }
       
   212