uiaccelerator_plat/alf_tracing_api/inc/alf/alflayoutmetrics.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:   Layout metrics
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_ALFLAYOUTMETRICS_H
       
    21 #define C_ALFLAYOUTMETRICS_H
       
    22 
       
    23 #include <e32base.h>
       
    24 
       
    25 class CAlfTextVisual;
       
    26 class CAlfEnv;
       
    27 struct TMarkedVisualEntry;
       
    28 
       
    29 /**
       
    30  *  Layout metrics utility for measuring text visuals. Measuring is
       
    31  *  is done based on text style or font id. Mesuring texts that has been 
       
    32  *  defined using font specification are not yet supported.
       
    33  *  
       
    34  *
       
    35  *  Example of use:
       
    36  *  
       
    37  *  void CHelloWorldAppUi::ConstructL()
       
    38  *     {
       
    39  *     iEnv = CAlfEnv::NewL();
       
    40  *  #ifdef __DEBUG
       
    41  *     // Enable layout metrics utility visual automarking in debug builds.
       
    42  *     iEnv->LayoutMetricsUtility()->EnableAutoMarking(); 
       
    43  *  #endif
       
    44  *     ...
       
    45  *     ...
       
    46  *     // Create some textvisuals, these will be automatically included
       
    47  *     // into metrics reports. 
       
    48  *     iTextVisual = CAlfTextVisual::AddNewL(*this, iLayout);
       
    49  *     iTextVisual->SetText(KMyText);
       
    50  *     iTextVisual->SetStyle(EAlfTextStyleSmall);
       
    51  *     ...
       
    52  *     ...
       
    53  *     }
       
    54  *
       
    55  *   // handle any menu commands
       
    56  *  void CHelloWorldAppUi::HandleCommandL(TInt aCommand)
       
    57  *     {
       
    58  *     switch(aCommand)
       
    59  *         {
       
    60  *         case EHellowWorldCmdMeasureVisuals:
       
    61  *             {
       
    62  *             // Measure currently visible text visuals
       
    63  *             iEnv->LayoutMetricsUtility()->MeasureVisuals();
       
    64  *             // Write a metrics report into a file 
       
    65  *             iEnv->LayoutMetricsUtility()->WriteReport();
       
    66  *             break;
       
    67  *             }
       
    68  *          ...
       
    69  *          ...    
       
    70  *         }
       
    71  *     ...
       
    72  *     }        
       
    73  *
       
    74  *
       
    75  *  @lib alfclient.lib
       
    76  *  @since S60 v3.2
       
    77  */
       
    78 NONSHARABLE_CLASS( CAlfLayoutMetricsUtility ): public CBase
       
    79     {
       
    80 public:
       
    81 
       
    82     /**
       
    83      * Destructor.
       
    84      */
       
    85     virtual ~CAlfLayoutMetricsUtility();
       
    86     
       
    87     /**
       
    88      * 2-phase constructor.
       
    89      */
       
    90     static CAlfLayoutMetricsUtility* NewL(CAlfEnv& aEnv);
       
    91 
       
    92     /**
       
    93      * 2-phase constructor.
       
    94      */
       
    95     static CAlfLayoutMetricsUtility* NewLC(CAlfEnv& aEnv);
       
    96     
       
    97     /**
       
    98      * Marks visual to be included into layout metric reports.
       
    99      * @param aLogicalName Logical name for the visual, e.q. "title_pane_t1" or "qtn_title_text"...
       
   100      *                     If NULL is given, text visual text will be used as logical name
       
   101      *                     in the reports.
       
   102      * @param aVisual      The visual to be included into reports.
       
   103      */
       
   104     IMPORT_C void MarkVisual(TDesC* aLogicalName, CAlfTextVisual* aVisual);
       
   105     
       
   106     /**
       
   107      * Unmarks visual, it will not be included into layout metric reports.
       
   108      * @param aVisual      The visual to be excluded from reports.
       
   109      */
       
   110     IMPORT_C void UnmarkVisual(CAlfTextVisual* aVisual);
       
   111 
       
   112     /**
       
   113      * Measures all currently visible visuals.
       
   114      */
       
   115     IMPORT_C void MeasureVisuals();
       
   116 
       
   117     /**
       
   118      * Writes a layout metric report into a file, by default C: drive is used.
       
   119      * Report contains metrics data for each visual at the time of last call to the
       
   120      * MeasureVisuals()-method.
       
   121      *
       
   122      * Report is intended to be used when text strings lenghts are decided and localized to 
       
   123      * different language variants.
       
   124      *
       
   125      * Report contains data for each measured textvisual such as:
       
   126      *
       
   127      * - Component type ("Text" for text visual)
       
   128      * - Id (Generated id number)
       
   129      * - Variety (Generated variety id number)
       
   130      * - Logical name (Given with MarkVisual()-method) 
       
   131      * - Alias (Text that the text visual shows)
       
   132      * - Font type (qfn_primary, qfn_secondary...)
       
   133      * - Text width (Text width in pixels)
       
   134      * - Text height (Text height in pixels)
       
   135      * - Visual coordinates relative to parent layout left, right, top and bottom coordinates
       
   136      * - Remarks (Free text, if any)
       
   137      * - Layout parent id (Generated id for parent layout) 
       
   138      * - Layout parent variety id (Generated variety id for parent layout) 
       
   139      * - Wheter text visual is a multi row or not 
       
   140      * - Max number of text rows 
       
   141      * - Font style 1 (plain, bold -attributes)
       
   142      * - Font style 2 (regular, italic -attributes)
       
   143      * - Font style 3 (underline, strikethrough, outline, boxed or shadow)
       
   144      * - Concatenated rows or not
       
   145      *
       
   146      */
       
   147     IMPORT_C void WriteReport();
       
   148 
       
   149     /**
       
   150      * Enables (or disables) automarking of visuals. If enabled, when visuals are 
       
   151      * created they are automatical marked to be included into reports.
       
   152      */
       
   153     IMPORT_C void EnableAutoMarking(TBool aEnabled=ETrue);
       
   154 
       
   155     /**
       
   156      * Tells if automatic visual marking is enabled.
       
   157      * @retrun ETrue if automatic visual marking is enabled, otherwise EFalse.
       
   158      */     
       
   159     IMPORT_C TBool AutoMarking();
       
   160 
       
   161 private:
       
   162 
       
   163     CAlfLayoutMetricsUtility();
       
   164     
       
   165     void ConstructL(CAlfEnv& aEnv);
       
   166 
       
   167     void MarkVisualL(TDesC* aLogicalName, CAlfTextVisual* aVisual);
       
   168 
       
   169     void MeasureVisualsL();
       
   170 
       
   171     void PrintToFile( TDesC16& aBuf );
       
   172     
       
   173                            
       
   174 private:
       
   175 
       
   176     struct TMetricsPrivateData;
       
   177     TMetricsPrivateData* iMetricsData;
       
   178     };
       
   179 
       
   180 
       
   181 #endif // C_ALFLAYOUTMETRICS_H