uiacceltk/hitchcock/coretoolkit/src/HuiS60TextStyle.cpp
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     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 Text style encapsulates a unique text style 
       
    15 *                in Hitchcock UI Toolkit usage.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #include <AknUtils.h>
       
    22 #include <AknLayoutFont.h>
       
    23 #include <AknFontSpecification.h>
       
    24 
       
    25 #include "HuiS60TextStyle.h"
       
    26 
       
    27 
       
    28 EXPORT_C THuiS60TextStyle::THuiS60TextStyle(TInt aFontStyleId, TInt aParentId)
       
    29     : THuiTextStyle(aFontStyleId, aParentId)
       
    30     {
       
    31     Init();
       
    32     }
       
    33 
       
    34 void THuiS60TextStyle::Init()
       
    35     {
       
    36     if (!CCoeEnv::Static())
       
    37         {
       
    38         return;
       
    39         }
       
    40 		
       
    41     TFontSpec fs; 
       
    42     // note that we can use CAknLayoutFont::AsCAknLayoutFontOrNull to downcast
       
    43     const CAknLayoutFont* font = AknLayoutUtils::LayoutFontFromId(iFontStyleId, NULL);
       
    44     fs = font->FontSpecInTwips();
       
    45     
       
    46     // Define everything that is found from the TFontSpec
       
    47     iLocalDefinitionFlags |= KTextSizeDefined;
       
    48     iLocalDefinitionFlags |= KStrokeWeightDefined;
       
    49     iLocalDefinitionFlags |= KPostureDefined;
       
    50     iLocalDefinitionFlags |= KFontDefined;
       
    51 
       
    52     iFont.SetFontSpec(fs); 
       
    53     THuiFont huiFont(0, fs);
       
    54     
       
    55     // transfer the text pane height between the different font specs
       
    56     TAknFontSpecification aknFs = font->FontSpecification();
       
    57     huiFont.SetTextPaneHeight(aknFs.TextPaneHeight());
       
    58     
       
    59     SetFont(huiFont);
       
    60     }