uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiTextStyleManager.h
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:   Text style manager allows creation and management of
       
    15 *                platform text styles in Hitchcock UI Toolkit usage.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 #ifndef __HUITEXTSTYLEMANAGER_H__
       
    23 #define __HUITEXTSTYLEMANAGER_H__
       
    24 
       
    25 #include <e32base.h>
       
    26 #include <uiacceltk/huitextstyle.h>
       
    27 
       
    28 /** 
       
    29  * Preconfigured text styles.
       
    30  * Matching text styles always exist in the text style manager.
       
    31  * It is possible to retrieve the associated text style object through
       
    32  * CHuiTextStyleManager::TextStyle() - interface.
       
    33  */
       
    34 enum THuiPreconfiguredTextStyle
       
    35     {
       
    36     EHuiTextStyleNormal = 0,
       
    37     EHuiTextStyleNormalItalic,
       
    38     EHuiTextStyleMenuItem,
       
    39     EHuiTextStyleSmall,
       
    40     EHuiTextStyleMenuSmall,
       
    41     EHuiTextStyleMenuTitle,
       
    42     EHuiTextStyleLarge,
       
    43     EHuiTextStyleSoftkey,
       
    44     EHuiTextStyleSupplement,
       
    45     EHuiTextStyleTitle
       
    46     };
       
    47 
       
    48 /**
       
    49  * CHuiTextStyleManager allows user to create text styles supported by the platform
       
    50  * that can be used in Hitchcock UI Toolkit user interfaces. Text styles are referred  
       
    51  * to by Hithcock UI Toolkit session specific unique IDs. Collection of preconfigured
       
    52  * text styles are constructed by default. @see THuiPreconfiguredTextStyle. 
       
    53  */
       
    54 NONSHARABLE_CLASS(CHuiTextStyleManager): public CBase
       
    55 {
       
    56 public:
       
    57 
       
    58     /* Constructors and destructor. */
       
    59 
       
    60     /**
       
    61      * Constructor.
       
    62      */
       
    63     static CHuiTextStyleManager* NewL();
       
    64 
       
    65     /**
       
    66      * Constructor.
       
    67      */
       
    68     static CHuiTextStyleManager* NewLC();
       
    69 
       
    70     /**
       
    71      * Destructor.
       
    72      */    
       
    73      ~CHuiTextStyleManager();
       
    74      
       
    75     /**
       
    76      * Creates a new text style object based on the S60 font style id passed into this method. 
       
    77      * Text style font and size are set according to the given S60 id. Ids are defined in
       
    78      * avkon.hrh in TAknLogicalFontId enumeration.
       
    79      * A unique toolkit specific ID is constructed and returned. This text style can be
       
    80      * accessed anytime through the TextStyle - method based on the unique ID. The default 
       
    81      * text style has always ID 0.
       
    82      * Text styles cascade properties from their parent styles. By default all text styles
       
    83      * are descended from EHuiTextStyleNormal text style.
       
    84      * If an invalid parent id is given the created text style will use EHuiTextStyleNormal
       
    85      * as its parent.
       
    86      * @see TextStyle()
       
    87      *
       
    88      * Created text styles must be deleted with DeleteTextStyle.
       
    89      * @see DeleteTextStyle()
       
    90      * 
       
    91      * @param aFontStyleId The S60 font style id based on which the text style object will be created.
       
    92      * @param aParentId Toolkit specific ID of the parent text style. The text styles are cascaded.
       
    93      *                          The parent of the created text style is EHuiTextStyleNormal by default.
       
    94      * @return Unique toolkit specific ID for the created text style.
       
    95      */
       
    96      IMPORT_C TInt CreatePlatformTextStyleL(TInt aFontStyleId, TInt aParentId = EHuiTextStyleNormal);
       
    97      
       
    98     /**
       
    99      * Returns a text style object based on the text style id passed into this method.
       
   100      * If no matching text style is found from the system the method returns the EHuiTextStyleNormal
       
   101      * text style. There is a collection of preconfigured text styles available. They can
       
   102      * be queried using the id enumerations from THuiPreconfiguredTextStyle.
       
   103      * @see CreatePlatformTextStyleL()
       
   104      * 
       
   105      * @param aId A text style id identifying the requested text style in the text style manager.
       
   106      * @return A pointer to a requested text style. Various attributes of the text style 
       
   107      * can be changed using the returned pointer.
       
   108      */
       
   109      IMPORT_C THuiTextStyle* TextStyle(TInt aId);
       
   110      
       
   111     /**
       
   112      * Creates a new text style object that is identical with the given source text style.
       
   113      * All the properties of the source text style are copied. The only difference is the 
       
   114      * text style ID. Each text style has a unique toolkit specific ID.
       
   115      *
       
   116      * Created text styles must be deleted with DeleteTextStyle.
       
   117      * @see DeleteTextStyle()
       
   118      *
       
   119      * @param aSourceId A toolkit specific ID of the text style to be cloned.
       
   120      * @return Unique toolkit specific ID for the created text style.
       
   121      */
       
   122      IMPORT_C TInt CopyTextStyleL(TInt aSourceId);
       
   123      
       
   124      /**
       
   125       * Deletes the given text style.
       
   126       *
       
   127       * @param aId Text style ID to delete.
       
   128       *
       
   129       * @return Error code. KErrNone if text style was deleted
       
   130       *                     KErrArgument if there is no style defined with given ID
       
   131       *                     KErrAccessDenied if the ID refers to pre-defined styles.
       
   132      */ 
       
   133      IMPORT_C TInt DeleteTextStyle(TInt aId);
       
   134 
       
   135     /**
       
   136      * Constructs the collection of built-in preconfigured text styles.
       
   137      * @see THuiPreconfiguredTextStyle
       
   138      */
       
   139      void ConstructBuiltInStylesL();
       
   140 
       
   141      /**
       
   142       * 
       
   143       */
       
   144      void SetSoftkeyTextStyle(TInt aTextStyleId);
       
   145      
       
   146      void NotifyDisplaySizeChangedL();
       
   147      
       
   148 protected:
       
   149 
       
   150     /* Constructors. */
       
   151 
       
   152     /**
       
   153      * Default constructor.
       
   154      */
       
   155     CHuiTextStyleManager();
       
   156 
       
   157     /**
       
   158      * Second-phase constructor.
       
   159      */
       
   160     void ConstructL();
       
   161     
       
   162     void InsertIntoArrayAndSetIdL(THuiTextStyle& style);
       
   163 
       
   164 private:
       
   165     
       
   166     /** Registry of all text styles within this manager. These text styles are  
       
   167      *  accessed by text style id. 
       
   168      */
       
   169     RPointerArray<THuiTextStyle> iTextStyles;
       
   170     
       
   171     /**
       
   172      * Last id of built in styles.
       
   173      */
       
   174     TInt iLastBuiltInStyleId;
       
   175 };
       
   176 
       
   177 #endif  //__HUITEXTSTYLEMANAGER_H__