classicui_plat/fonts_api/inc/AknLayoutFont.h
changeset 49 31c16e0c5e3e
equal deleted inserted replaced
40:7165f928e888 49:31c16e0c5e3e
       
     1 /*
       
     2 * Copyright (c) 2004 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 *   Interface for Series 60 font type, incorporating principles of series 60 layout
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20    
       
    21 #ifndef AKNLAYOUTFONT_H
       
    22 #define AKNLAYOUTFONT_H
       
    23 
       
    24 #include <gdi.h>
       
    25 #include <fbs.h>
       
    26 #include <AknFontSpecification.h>
       
    27 #include <AknTextDecorationMetrics.h>
       
    28 
       
    29 class CBitmapDevice;
       
    30 
       
    31 /**
       
    32 * This abstract class is a CFbsFont that can update itself (re-bind a font) and has standard
       
    33 * Series 60 layout API available.
       
    34 * 
       
    35 * Concrete classes derived from this implement constructors and Update methods that
       
    36 * supply the specification required for the initially, and newly bound font, respectively. 
       
    37 * Derived classes must also implement the CreateFont framework method in order to
       
    38 * implement the font binding itself.
       
    39 * 
       
    40 *  @lib avkon.dll
       
    41 *  @since 2.8
       
    42 *
       
    43 *  @internal
       
    44 */
       
    45 NONSHARABLE_CLASS(CAknLayoutFont) : public CFbsFont
       
    46     {
       
    47 
       
    48 public:
       
    49     /**
       
    50     * C++ Destructor.
       
    51     */
       
    52     virtual ~CAknLayoutFont();
       
    53 
       
    54 public: // New functions
       
    55     /**  
       
    56     * Update this object's binding to a CFbsFont, using the member data of the derived class.
       
    57     * This method only needs to be called if the client owns the CAknLayoutFont
       
    58     * object, and there has been a layout switch that may affect the font. 
       
    59     * 
       
    60     * It is functionally equivalent to deleting the CAknLayoutFont object, and 
       
    61     * reconstructing it with the same parameters.
       
    62     */
       
    63     IMPORT_C void Update();
       
    64 
       
    65     /**
       
    66     * Return the maximum extent of any pixel in the font upwards from the baseline
       
    67     * Measured up, so therefore it is a positive value.
       
    68     * 
       
    69     * @return maximum ascent of the font
       
    70     */ 
       
    71     IMPORT_C TInt MaxAscent() const;
       
    72 
       
    73     /**
       
    74     * Return the maximum extent of any pixel in the font down the baseline
       
    75     * Measured down, so therefore it is usually a positive value.
       
    76     * 
       
    77     * @return maximum descent of the font
       
    78     */ 
       
    79     IMPORT_C TInt MaxDescent() const;
       
    80 
       
    81     /*
       
    82     * Position of the baseline measured down from the Series 60 layout text pane top
       
    83     *
       
    84     * @return distance from text pane top to baseline
       
    85     */
       
    86     IMPORT_C TInt TextPaneTopToBaseline() const;
       
    87     
       
    88     /*
       
    89     * Position of the text pane bottom measured down from the baseline
       
    90     *
       
    91     * @return distance from text pane top to baseline
       
    92     */
       
    93     IMPORT_C TInt BaselineToTextPaneBottom() const;
       
    94 
       
    95     /*
       
    96     * Series 60 text pane height. 
       
    97     * Always equal to TextPaneTopToBaseline() + BaselineToTextPaneBottom()
       
    98     *
       
    99     * @return text pane height
       
   100     */
       
   101     IMPORT_C TInt TextPaneHeight() const;
       
   102 
       
   103     /**
       
   104     * This provides the baseline relative to the top of the combined font for a specific 
       
   105     * character code. This value does not include any TopShortfall.
       
   106     **/
       
   107     TInt AscentForCharacter( TChar aCharacter ) const; 
       
   108 
       
   109     /**
       
   110     * Returns if a font pointer cast to this type if the actual type conforms to this type. 
       
   111     * 
       
   112     * @returns NULL if the font does not conform to CAknLayoutFont.
       
   113     */
       
   114     IMPORT_C static const CAknLayoutFont* AsCAknLayoutFontOrNull( const CFont* aFont );
       
   115 
       
   116     /**
       
   117     * Returns an object describing how the text with this font is to be decorated
       
   118     * 
       
   119     * @return   text decoration metrics for the font
       
   120     */
       
   121     IMPORT_C TAknTextDecorationMetrics TextDecorationMetrics() const;
       
   122 
       
   123     /**
       
   124     * Returns the Avkon font category (EAknFontCategoryPrimary, EAknFontCategorySecondary...)
       
   125     * that was used to generate this font.
       
   126     * 
       
   127     * @return   font category
       
   128     */
       
   129     IMPORT_C TAknFontCategory FontCategory() const;
       
   130 
       
   131     /**
       
   132     * This API allows the font to provide the metrics under which the font was requested.
       
   133     * 
       
   134     * @return   the font specification for which the font has been supplied
       
   135     */
       
   136     IMPORT_C TAknFontSpecification FontSpecification() const;
       
   137     
       
   138 public: // Functions from CFont
       
   139      
       
   140 public:// Functions from CFbsFont
       
   141 
       
   142     TFontSpec DoFontSpecInTwips() const;
       
   143 
       
   144 protected:
       
   145     /**
       
   146     * C++ Constructor.
       
   147     */
       
   148     CAknLayoutFont( CBitmapDevice& aScreenDevice );
       
   149     CBitmapDevice& BitmapDevice() const;
       
   150 
       
   151 protected: // Internal methods
       
   152 
       
   153     void SetExcessAscent( TInt aExcessAscent );
       
   154     void SetExcessDescent( TInt aExcessDescent );
       
   155     void SetBottomShortfall( TInt aBottomShortfall );
       
   156     void SetTextPaneHeight( TInt aTextPaneHeight );
       
   157 
       
   158 private: // New Framework methods
       
   159     virtual CFbsFont* SupplyFont() = 0;
       
   160     virtual TInt DoAscentForCharacter( TChar aCharacter ) const;
       
   161     virtual TAknTextDecorationMetrics DoTextDecorationMetrics() const = 0;
       
   162     virtual TAknFontSpecification DoFontSpecification() const = 0;
       
   163     virtual void CAknLayoutFont_Reserved_1();
       
   164 
       
   165 private:
       
   166     void Register();
       
   167     void Deregister();
       
   168 
       
   169 private:
       
   170 
       
   171     CFbsFont* iNonDynamicFont;
       
   172     CBitmapDevice& iScreenDevice;
       
   173     TInt iExcessAscent;
       
   174     TInt iExcessDescent;
       
   175     TInt iBottomShortfall;
       
   176     TInt iTextPaneHeight;
       
   177     TInt iSpare;
       
   178     };
       
   179 
       
   180 
       
   181 #endif  //AKNLAYOUTFONT_H