lafagnosticuifoundation/cone/src/COEFONT.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 #include <coefont.h>
       
    18 
       
    19 // 
       
    20 // class TCoeFont 
       
    21 // 
       
    22 
       
    23 
       
    24 /** constructor
       
    25 
       
    26 @publishedAll
       
    27 @released
       
    28 */
       
    29 EXPORT_C TCoeFont::TCoeFont(TLogicalSize aSize, TInt aStyle, TInt aFlags) : 
       
    30                 iLogicalSize(aSize), iHeightInPixels(0), iStyle(aStyle), iFlags(aFlags) 
       
    31         { 
       
    32         ASSERT(!(iStyle&ESuper && iStyle&ESub));        // Super and sub not allowed at once!         
       
    33         } 
       
    34         
       
    35 
       
    36 /** constructor
       
    37 
       
    38 @publishedAll
       
    39 @released
       
    40 */
       
    41 EXPORT_C TCoeFont::TCoeFont(TInt aHeightInPixels, TInt aStyle, TInt aFlags) : 
       
    42                 iLogicalSize(EUndefinedSize), iHeightInPixels(aHeightInPixels), iStyle(aStyle), iFlags(aFlags) 
       
    43         {
       
    44         ASSERT(!(iStyle&ESuper && iStyle&ESub));        // Super and sub not allowed at once!
       
    45         }         
       
    46 
       
    47 /** Copy constructor
       
    48 
       
    49 @publishedAll
       
    50 @released
       
    51 */
       
    52 EXPORT_C TCoeFont::TCoeFont(const TCoeFont& aFont) 
       
    53     { 
       
    54     iLogicalSize = aFont.iLogicalSize; 
       
    55     iHeightInPixels = aFont.iHeightInPixels; 
       
    56     iStyle = aFont.iStyle; 
       
    57     iFlags = aFont.iFlags; 
       
    58     iTypeface = aFont.iTypeface;         
       
    59     iSpare = aFont.iSpare; 
       
    60     } 
       
    61 
       
    62 EXPORT_C TCoeFont::TCoeFont() 
       
    63 		: iLogicalSize(EUndefinedSize)
       
    64 		{
       
    65 		}
       
    66 
       
    67 /** Return a default "normal" font
       
    68 
       
    69 @publishedAll
       
    70 @released
       
    71 */
       
    72 EXPORT_C TCoeFont TCoeFont::NormalFont(TInt aFlags) 
       
    73         { 
       
    74         return TCoeFont(EMedium, EPlain, aFlags);
       
    75         } 
       
    76         
       
    77 /** Return a default "legend" font
       
    78 
       
    79 @publishedAll
       
    80 @released
       
    81 */
       
    82 EXPORT_C TCoeFont TCoeFont::LegendFont(TInt aFlags) 
       
    83         { 
       
    84         return TCoeFont(EMedium, EBold, aFlags);
       
    85         } 
       
    86         
       
    87 /** Return a default "annotation" font
       
    88 
       
    89 @publishedAll
       
    90 @released
       
    91 */
       
    92 EXPORT_C TCoeFont TCoeFont::AnnotationFont(TInt aFlags) 
       
    93         { 
       
    94         return TCoeFont(ESmall, EPlain, aFlags);
       
    95         } 
       
    96         
       
    97 /** Return a default "title" font
       
    98 
       
    99 @publishedAll
       
   100 @released
       
   101 */
       
   102 EXPORT_C TCoeFont TCoeFont::TitleFont(TInt aFlags) 
       
   103         { 
       
   104         return TCoeFont(ELarge, EBold, aFlags);
       
   105         } 
       
   106 
       
   107 /** Return this font's logical size
       
   108 */
       
   109 EXPORT_C TCoeFont::TLogicalSize TCoeFont::LogicalSize() const 
       
   110         { 
       
   111         return iLogicalSize; 
       
   112         } 
       
   113 
       
   114 /** Return this font's height in pixels
       
   115 
       
   116 @publishedAll
       
   117 @released
       
   118 */
       
   119 EXPORT_C TInt TCoeFont::HeightInPixels() const 
       
   120         { 
       
   121         return iHeightInPixels;         
       
   122         } 
       
   123         
       
   124 /** Return this font's style
       
   125 
       
   126 @publishedAll
       
   127 @released
       
   128 */
       
   129 EXPORT_C TFontStyle TCoeFont::Style() const 
       
   130         { 
       
   131         return TFontStyle((iStyle&EItalic ? EPostureItalic : EPostureUpright), 
       
   132                                                 (iStyle&EBold ? EStrokeWeightBold : EStrokeWeightNormal), 
       
   133                                                 (iStyle&ESuper ? EPrintPosSuperscript : (iStyle&ESub ? EPrintPosSubscript : EPrintPosNormal))); 
       
   134         } 
       
   135 
       
   136 /** Says whether this font can be zoomed or not
       
   137 
       
   138 @publishedAll
       
   139 @released
       
   140 */
       
   141 EXPORT_C TBool TCoeFont::IsNonZooming() const 
       
   142         { 
       
   143         return (iFlags & ENonZooming); 
       
   144         } 
       
   145 
       
   146 /** Compare two TCoeFont objects
       
   147 */
       
   148 TInt TCoeFont::Compare(const TCoeFont& aFirst, const TCoeFont& aSecond) 
       
   149     { 
       
   150     if(aFirst.iStyle - aSecond.iStyle) 
       
   151     	return (aFirst.iStyle - aSecond.iStyle); 
       
   152         
       
   153     if(aFirst.iLogicalSize - aSecond.iLogicalSize) 
       
   154         return (aFirst.iLogicalSize - aSecond.iLogicalSize); 
       
   155         
       
   156     if(aFirst.iHeightInPixels - aSecond.iHeightInPixels) 
       
   157         return (aFirst.iHeightInPixels - aSecond.iHeightInPixels); 
       
   158                         
       
   159     return (aFirst.iFlags - aSecond.iFlags); 
       
   160     } 
       
   161 	
       
   162