inc/alf/alflinevisualattributesetter.h
branchRCL_3
changeset 19 4ea6f81c838a
parent 17 514d98f21c43
child 20 0e9bb658ef58
equal deleted inserted replaced
17:514d98f21c43 19:4ea6f81c838a
     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:   Line visual attribute setter Header.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef ALFLINEVISUALATTRIBUTESETTER_H
       
    20 #define ALFLINEVISUALATTRIBUTESETTER_H
       
    21 
       
    22 #include <osn/osndefines.h>
       
    23 #include "alf/alfcommonvisualattributesetter.h"
       
    24 
       
    25 class CAlfCurvePath;
       
    26 class CAlfLineVisual;
       
    27 
       
    28 namespace Alf
       
    29     {
       
    30 
       
    31 class AlfLineVisualAttributeSetterImpl;
       
    32 
       
    33 /** @class AlfLineVisualAttributeSetter alflinevisualattributesetter.h 
       
    34  *  "alf/alflinevisualattributesetter.h"
       
    35  *  The implementation of the attribute setter.
       
    36  *
       
    37  *  @interfaces IAlfAttributeSetter
       
    38  *  @lib alfwidgetmodel.lib
       
    39  *  @since S60 ?S60_version
       
    40  *  @status Draft
       
    41  */
       
    42 class AlfLineVisualAttributeSetter : public AlfCommonVisualAttributeSetter
       
    43     {
       
    44 public:
       
    45 
       
    46     /**
       
    47      * Constructor.
       
    48      *
       
    49 	 * @exception std::bad_alloc     
       
    50      * @param aType Type of the attribute setter.
       
    51      */
       
    52     OSN_IMPORT AlfLineVisualAttributeSetter();
       
    53 
       
    54     /**
       
    55      * Destructor.
       
    56      */
       
    57     OSN_IMPORT virtual ~AlfLineVisualAttributeSetter();
       
    58 
       
    59     /**
       
    60      * Sets an attribute value in the target visual immediately without
       
    61      * a transition.
       
    62      *
       
    63      * @exception osncore::AlfVisualException Thrown with the error code 
       
    64      *     osncore::EInvalidVisual when supplied visual is not a line visual.
       
    65      *
       
    66      * @param aVisual The target visual. Doesn't take ownership
       
    67      * @param aContainer The container holding the new value of the attribute.
       
    68      *      Ownership of the object is not transferred.
       
    69      * @param aData Not used currently.
       
    70      */
       
    71     OSN_IMPORT virtual void setAttributeValue(
       
    72         CAlfVisual &aVisual,
       
    73         AlfAttributeContainer* aContainer,
       
    74         IAlfMap* aData);
       
    75 
       
    76     /**
       
    77      * Deprecated! Do not use!
       
    78      * Creates a command to change the value of an attribute in the target
       
    79      * visual gradually with a transition.
       
    80      *
       
    81      * @param aVisual The target visual. Doesn't take ownership
       
    82      * @param aContainer The container holding the new value of the
       
    83      *      attribute.Ownership of the object is not transferred.
       
    84      * @param aData Not used currently.
       
    85      * @param aTransitionTime Time used for the transition.
       
    86      * @param aRefVisual Optional reference visual. If not NULL, the target
       
    87      *       value of the attribute is defined by adding the value
       
    88      *       specific by aContainer to the corresponding attribute
       
    89      *      value in the reference visual.
       
    90      * @ret The command to gradually change the attribute in the target visual
       
    91      */
       
    92     OSN_IMPORT virtual TAlfCommand* createCommand(
       
    93         CAlfVisual& aVisual,
       
    94         AlfAttributeContainer* aContainer,
       
    95         IAlfMap* aData,
       
    96         int aTransitionTime = 0,
       
    97         CAlfVisual* aRefVisual = NULL );
       
    98 
       
    99     /**
       
   100      * Creates commands to change the given attribute values in the target
       
   101      * visual gradually with a transition.
       
   102      * Then sends the commands via the ALF environment.
       
   103      *
       
   104      * @param aVisual The target visual. Doesn't take ownership
       
   105      * @param aContainer The attribute container holding attribute value(s)
       
   106      *       used by the attribute setter. Ownership is not
       
   107      *       transferred. The container can hold new values for
       
   108      *       multiple different attributes, in which case several
       
   109      *       commands are executed.
       
   110      * @param aRefVisual Optional reference visual. If not NULL, the target
       
   111      *       value of the attribute is defined by adding the value specific by
       
   112      *       aContainer to the corresponding attribute value in the reference
       
   113      *       visual
       
   114      */
       
   115     OSN_IMPORT virtual void createAndSendCommands(
       
   116         CAlfVisual& aVisual,
       
   117         AlfAttributeContainer* aContainer,
       
   118         CAlfVisual* aRefVisual = NULL );
       
   119 
       
   120 protected:
       
   121     /**
       
   122      * Sets an dynamic attribute value in the target visual using transitions
       
   123      * defined in attributes
       
   124      *
       
   125      * @param aVisual The target visual. Doesn't take ownership
       
   126      * @param aAttr The attribute to process. Doesn't take ownership
       
   127      * @param aContainer The container holding attributes. Ownership of the
       
   128      *      object is not transferred.
       
   129      */
       
   130     virtual void handleDynamicAttribute (
       
   131         CAlfVisual &aVisual,
       
   132         AlfAttribute& aAttr,
       
   133         AlfAttributeContainer& aContainer);
       
   134 
       
   135     /**
       
   136      * Sets a value for static attribute in the target visual immediately 
       
   137      * without any transition using data in map.
       
   138      *
       
   139      * @exception osncore::AlfDataException Thrown with the error code 
       
   140      *     osncore::ECommonError when empty attribute for line visual 
       
   141      *     is supplied .
       
   142      * @exception osncore::AlfAttributeException Thrown with the error code 
       
   143      *     osncore::EInvalidAttribute when wrong attribute for line visual 
       
   144      *     is supplied .
       
   145      * @exception osncore::AlfAttributeException Thrown with the error code 
       
   146      *     osncore::EIncompleteAttributeValues when all values of an attribute
       
   147      *     for line visual are not supplied .
       
   148      * @param aVisual The target visual. Doesn't take ownership
       
   149      * @param aAttr The attribute to process. Doesn't take ownership
       
   150      * @param aContainer The container holding attributes. Ownership of the 
       
   151      *                   object is not transferred.
       
   152      * @param aData Contains data.Ownership of the object is not transferred.
       
   153      */
       
   154     virtual void handleStaticDataAttribute ( CAlfVisual &aVisual,
       
   155         AlfAttribute& aAttr,
       
   156         AlfAttributeContainer& aContainer,
       
   157         IAlfMap* aData );
       
   158 
       
   159     /**
       
   160      * Sets a value for dynamic attribute value in the target visual using 
       
   161      * transitions and data in map.
       
   162      *
       
   163      * @exception osncore::AlfDataException Thrown with the error code 
       
   164      *     osncore::ECommonError when empty attribute for line visual 
       
   165      *     is supplied .
       
   166      * @param aVisual The target visual. Doesn't take ownership
       
   167      * @param aAttr The attribute to process. Doesn't take ownership
       
   168      * @param aContainer The container holding attributes. Ownership of the
       
   169      *                   object is not transferred.
       
   170      * @param aData Contains data.Ownership of the object is not transferred.
       
   171      */
       
   172     virtual void handleDynamicDataAttribute (
       
   173         CAlfVisual &aVisual,
       
   174         AlfAttribute& aAttr,
       
   175         AlfAttributeContainer& aContainer,
       
   176         IAlfMap* aData );
       
   177 
       
   178     /**
       
   179      * Sets a value of a static attribute to target visual immediately without
       
   180      * any transition.
       
   181      *
       
   182      * @exception osncore::AlfAttributeException Thrown with the error code 
       
   183      *     osncore::EInvalidAttribute when wrong attribute data for line visual
       
   184      *     is supplied .
       
   185      * @param aVisual The target visual. Doesn't take ownership
       
   186      * @param aAttr The attribute to process. Doesn't take ownership
       
   187      * @param aContainer The container holding attributes. Ownership of the 
       
   188      *                   object is not transferred.
       
   189      */
       
   190     virtual void handleStaticAttribute (
       
   191         CAlfVisual &aVisual,
       
   192         AlfAttribute& aAttr,
       
   193         AlfAttributeContainer& aContainer);
       
   194 
       
   195 private:
       
   196 
       
   197     /**
       
   198      * Creates and returns a toolkit defined mappping function based on the
       
   199      * attribute content.
       
   200      * The int value-mapping function mapping is the following:
       
   201      * 0 - KConstMappingFunction
       
   202      * 1 - KLinearMappingFunction
       
   203      * 2 - KSineMappingFunction
       
   204      * 3 - KCosineMappingFunction
       
   205      * @param aAttribute Attribute containing the deciding int value and data
       
   206      *                   required for construction of the mapping function.
       
   207      * @param aEnv       Environment
       
   208      * @result The mapping function pointer
       
   209      */
       
   210     MAlfMappingFunction* getMappingFunction(
       
   211         AlfAttribute& aAttribute ,
       
   212         CAlfEnv& aEnv);
       
   213 
       
   214     /**
       
   215      * Creates and returns a toolkit defined mappping function based on the
       
   216      * container content.
       
   217      * The int value-mapping function mapping is the following:
       
   218      * 0 - KConstMappingFunction
       
   219      * 1 - KLinearMappingFunction
       
   220      * 2 - KSineMappingFunction
       
   221      * 3 - KCosineMappingFunction
       
   222      * @param aContainer Container containing the deciding int value and data
       
   223      *                   required for construction of the mapping function.
       
   224      * @param aEnv       Environment
       
   225      * @result The mapping function pointer
       
   226      */
       
   227     MAlfMappingFunction* getMappingFunctionFromContainer(
       
   228         IAlfContainer* aContainer,
       
   229         CAlfEnv& aEnv);
       
   230 
       
   231 
       
   232     /**
       
   233      * Gets the path from the line visual or creates it if does not exist
       
   234      * @param aLineVisual Line Visual
       
   235      * @result The curvepath
       
   236      */
       
   237     CAlfCurvePath* getCurvePath(CAlfLineVisual* aLineVisual);
       
   238 
       
   239     /**
       
   240      * Check if data in the attribute is int or float.
       
   241      * Return the value as a float value
       
   242      *
       
   243      * @param aAttr The attribute containing the value
       
   244      * @param aIndex The index of the value to be checked
       
   245      * return Content of the attribute
       
   246      */
       
   247     float floatOrInt(const AlfAttribute& aAttr, int aIndex);
       
   248 
       
   249     /**
       
   250      * Check if data in the variant type is int or float.
       
   251      * Return the value as a float value
       
   252      *
       
   253      * @param aData The variant type containing the value
       
   254      * return Content of the variant type
       
   255      */
       
   256     float floatOrIntFromData(IAlfVariantType* aData);
       
   257 
       
   258 
       
   259 
       
   260 private: // data
       
   261     auto_ptr<AlfLineVisualAttributeSetterImpl> mImpl;
       
   262     };
       
   263 
       
   264     } // namespace Alf
       
   265 
       
   266 #endif // ALFLINEVISUALATTRIBUTESETTER_H
       
   267