uifw/AvKon/inc/AknLayoutUtilsHelpers.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *  Internal implementations of Avkon Layout Utilities
       
    16 * 
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef __AKNLAYOUTUTILSHELPERS_H__
       
    22 #define __AKNLAYOUTUTILSHELPERS_H__
       
    23 
       
    24 #include <e32std.h>
       
    25 #include <AknsConstants.h> // For TAknsQsnTextColorsIndex
       
    26 
       
    27 class CEikEdwin;
       
    28 class TAknTextLineLayout;
       
    29 class CAknLayoutFont;
       
    30 class TAknTextDecorationMetrics;
       
    31 class CFont;
       
    32 
       
    33 /**
       
    34 * This class contains non-exported internal implementations of some of the functionality within
       
    35 * AknLayoutUtils.
       
    36 *
       
    37 */
       
    38 class AknLayoutUtilsHelpers 
       
    39     {
       
    40 public:               
       
    41 
       
    42 /**
       
    43 * This layout routine performs the core of the edwin layout.  All layout structures and fonts
       
    44 * are to be processed to basic parameters by this point.  A font is passed in, and not font id.
       
    45 * Baselines are defined in terms of the distance from the parent to the baseline of the font, 
       
    46 * where both a parent boundary and baseline are inifinitely thin lines. (This differs from the 
       
    47 * baseline definition used elsewhere in the layout system where a value smaller by 1 pixel is used.)*
       
    48 *
       
    49 * This routine may be used within Avkon by those writing editor layout routines
       
    50 * 
       
    51 * @param aEdwin                 a constructed edwin pointer 
       
    52 * @param aEdwinParent           rectangle in which to position editor
       
    53 * @param aFont                  constructed layout font pointer
       
    54 * @param aColor                 color index
       
    55 * @param aLeftMargin            space between editor and parent on the left       
       
    56 * @param aRightMargin           space between editor and parent on the right
       
    57 * @param aFirstBaseline         distance from parent top to 1st baseline. 
       
    58 * @param aWidth                 Width of the text pane (For debug checking only)
       
    59 * @param aJustification         text justification
       
    60 * @param aNumberOfLinesShown    number of lines of editor to format
       
    61 * @param aSecondLineBaseline    distance from parent top to 2nd baseline. 0 if not required
       
    62 * @param aOverrideColor         a Skins color index if required
       
    63 * @param decorationMetrics      Metrics for the highlights and cursor
       
    64 * @param aEnsureEditorIsContainedByParent   Boolean to say whether the editor is allowed to
       
    65 *                                           extend below the parent's bottom.
       
    66 * @param aNumberOfVisibleLines  Outputs the number of lines formatted in the editor
       
    67 */
       
    68 static void LayoutEdwinScalableWithCorrectedParametersAndDecorationMetrics(
       
    69                                  CEikEdwin *aEdwin, 
       
    70                                  const TRect &aEdwinParent, 
       
    71                                  const CAknLayoutFont *aFont, 
       
    72                                  TInt aColor, 
       
    73                                  TInt aLeftMargin, 
       
    74                                  TInt aRightMargin, 
       
    75                                  TInt aFirstBaseline, // naturally defined
       
    76                                  TInt aWidth,
       
    77                                  TInt aJustification, 
       
    78                                  TInt aNumberOfLinesShown, 
       
    79                                  TInt aSecondLineBaseline, //naturally defined
       
    80                                  TAknsQsnTextColorsIndex aOverrideColor,
       
    81                                  TAknTextDecorationMetrics& decorationMetrics,
       
    82                                  TBool aEnsureEditorIsContainedByParent,
       
    83                                  TInt& aNumberOfVisibleLines);
       
    84 /**
       
    85 * Layout helper routine used by majority of LayoutEdwin implementations
       
    86 *  
       
    87 * @param aEdwin                 a constructed edwin pointer 
       
    88 * @param aEdwinParent           rectangle in which to position editor
       
    89 * @param aFontId                An Avkon font id
       
    90 * @param aColor                 color index
       
    91 * @param aLeftMargin            space between editor and parent on the left       
       
    92 * @param aRightMargin           space between editor and parent on the right
       
    93 * @param aBaseline              distance from parent top to the top of the pixel row sitting on the baseline 
       
    94 *                               of the glyphs. 
       
    95 * @param aWidth                 width of editor
       
    96 * @param aJustification         text justification
       
    97 * @param aNumberOfLinesShown    number of lines of editor to format
       
    98 * @param aSecondLineBaseline    distance from parent top to the top of the pixel row sitting on the baseline 
       
    99 *                               of the glyphs in the 2nd line. 
       
   100 * @param aOverrideColor         a Skins color index if required
       
   101 * @param aCustomFont            font to be used if the layout has a font id = EFontCustom
       
   102 * @param aMinimizeEdwinView     Editor view size is to be minimised (not used)
       
   103 */
       
   104 static void LayoutEdwinScalable(CEikEdwin *aEdwin, 
       
   105                                  const TRect &aEdwinParent, 
       
   106                                  TInt aFontId, 
       
   107                                  TInt aColor, 
       
   108                                  TInt aLeftMargin, 
       
   109                                  TInt aRightMargin, 
       
   110                                  TInt aBaseline, 
       
   111                                  TInt aWidth, 
       
   112                                  TInt aJustification, 
       
   113                                  TInt aNumberOfLinesShown, 
       
   114                                  TInt aSecondLineBaseline, 
       
   115                                  TAknsQsnTextColorsIndex aOverrideColor,
       
   116                                  const CAknLayoutFont *aCustomFont, 
       
   117                                  TBool aMinimizeEdwinView);
       
   118                                    
       
   119 /**
       
   120 * Routine to determine the height required for an editor.  The position of the editor
       
   121 * relative to parent is also returned via the parameter aVerticalPositionOfEdwin.
       
   122 * This gap between parent and editor is not included in the returned height.
       
   123 */
       
   124 
       
   125 static TInt EdwinHeightFromLines(
       
   126         TInt aParentHeight,
       
   127         const TAknTextLineLayout& aLayout,
       
   128         TInt aBaselineSeparationOverRide,
       
   129         TInt aNumberOfLinesToShowOverRide,
       
   130         TInt& aVerticalPositionOfEdwin
       
   131         );
       
   132         
       
   133 /**
       
   134 * Routine to tell how many lines of laid out editor can fit into an edwin of a given 
       
   135 * height.
       
   136 */
       
   137 static TInt EdwinLinesWithinHeight (
       
   138         const TAknTextLineLayout& aLayout,
       
   139         TInt aBaselineSeparationOverRide,
       
   140         TInt aMaxHeight,
       
   141         TInt& aUsedHeight
       
   142         );
       
   143 
       
   144 
       
   145 private:
       
   146 /**
       
   147 * Corrects the baseline back to pre-aknlayout2 conventions. 
       
   148 *
       
   149 * If the font is encoded, then the legacy baseline value definition is returned
       
   150 * If not, then the passed-in value is returned.
       
   151 */
       
   152 static TInt CorrectBaseline( TInt aParentHeight, TInt aBaseline, TInt aFontId);
       
   153         
       
   154 /** 
       
   155 * This routine emulates what the Symbian Form/Tagma component is doing 
       
   156 * internally to get font height and depth.
       
   157 */
       
   158 static void GetFontMaxHeightAndDepth( 
       
   159         const CFont* aFont, TInt& aMaxHeight, TInt& aMaxDepth); 
       
   160 
       
   161 static TInt EdwinHeightFromLines (
       
   162         TInt aTextPaneHeight,
       
   163         TAknTextDecorationMetrics& aDecorationMetrics,
       
   164         TInt aBaselineSeparation,
       
   165         TInt aNumberOfLinesToShow
       
   166         );
       
   167 
       
   168  static TInt EdwinLinesWithinHeight (
       
   169         TInt aTextPaneHeight,
       
   170         TAknTextDecorationMetrics& aDecorationMetrics,
       
   171         TInt aBaselineSeparation,
       
   172         TInt aMaxHeight,
       
   173         TInt& aUsedHeight
       
   174         );
       
   175 /**
       
   176 * Routine to obtain the position of an editor's top relative to the parent.
       
   177 * Because of the way baseline is specified in scalable layout, parent height is 
       
   178 * required.
       
   179 */ 
       
   180 static void GetEditorVerticalPositionWithinParent(
       
   181     TInt aParentHeight, 
       
   182     const TAknTextLineLayout& aLayout, 
       
   183     TInt& aRelativeVerticalPositionOfEditor );
       
   184         
       
   185 static TInt EditorVerticalPositionWithinParent(
       
   186     const CAknLayoutFont* aLayoutFont,
       
   187     TInt aFirstBaseline,
       
   188     TInt aTopMargin );
       
   189 
       
   190     };
       
   191     
       
   192 #endif //  __AKNLAYOUTUTILSHELPERS_H__
       
   193 
       
   194 // End of file
       
   195 
       
   196 
       
   197 
       
   198 
       
   199 
       
   200 
       
   201 
       
   202 
       
   203