widgetmodel/alfwidgetmodel/inc/alfelementattributeownerimpl.h
branchRCL_3
changeset 26 0e9bb658ef58
parent 0 e83bab7cf002
equal deleted inserted replaced
25:4ea6f81c838a 26:0e9bb658ef58
       
     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:  Implementation of the IAlfAttributeOwner interface 
       
    15 *                for AlfElement.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __ALFELEMENTATTRIBUTEOWNERIMPL_H__
       
    21 #define __ALFELEMENTATTRIBUTEOWNERIMPL_H__
       
    22 
       
    23 #include "alf/ialfattributeowner.h"
       
    24 #include <osn/alfptrvector.h>
       
    25 
       
    26 namespace Alf
       
    27     {
       
    28     
       
    29 class AlfElement;   
       
    30 
       
    31 /**
       
    32  * Implementation of the IAlfAttributeOwner interface for AlfElement.
       
    33  */    
       
    34 class AlfElementAttributeOwnerImpl : public IAlfAttributeOwner
       
    35     {
       
    36 public:
       
    37 
       
    38     /**
       
    39      * Constructor.
       
    40      *
       
    41      * @param aElement Reference to owner element.
       
    42      * @param aControl Reference to control
       
    43      */
       
    44     AlfElementAttributeOwnerImpl(AlfElement& aElement,
       
    45         CAlfWidgetControl& aControl);
       
    46 
       
    47     /**
       
    48      * Destructor.
       
    49      */
       
    50     virtual ~AlfElementAttributeOwnerImpl();
       
    51     
       
    52 // from base class IAlfInterfaceBase
       
    53 
       
    54     /**
       
    55      * Getter for interfaces provided by the element classes.
       
    56      * Derived classes should always call the base class method
       
    57      * from the overridden MakeInterface.
       
    58      *
       
    59      * @since S60 ?S60_version
       
    60      * @param aType A descriptor to identify the type of the queried interface.
       
    61      * @return The queried interface, or NULL if the interface is not
       
    62      *         supported or available.
       
    63      */
       
    64     virtual IAlfInterfaceBase* makeInterface(const IfId& aType);       
       
    65             
       
    66 // from base class IAlfAttributeOwner
       
    67 
       
    68 	/**
       
    69      * Get the number of available attributes.
       
    70      *
       
    71      * @return The number of attributes.
       
    72      */
       
    73     virtual int attributeCount() const;
       
    74 
       
    75     /**
       
    76      * Gets the attribute with the given name.
       
    77      * The returned attribute instance is owned by the widget and
       
    78      * should not be deleted.
       
    79      * Also the returned attribute instance should not be modified.
       
    80      * Use SetAttribute for that.
       
    81      *
       
    82      * @param aAttribName The name of the attribute.
       
    83      * @return The attribute, or 0 if the attribute was not found.
       
    84      */
       
    85     virtual const AlfAttribute* getAttribute(const UString& aAttribName) const;
       
    86 
       
    87     /**
       
    88      * Gets the attribute with the given name from specific target.
       
    89      * The returned attribute instance is owned by the widget and
       
    90      * should not be deleted.
       
    91      * Also the returned attribute instance should not be modified.
       
    92      * Use SetAttribute for that.
       
    93      *
       
    94      * @param aTargetId   The name of the target widget part, e.g. element class
       
    95      * @param aAttribName The name of the attribute.
       
    96      * @return A pointer to the attribute, or 0 if the attribute was not found.
       
    97      */
       
    98     virtual const AlfAttribute* getAttribute( const UString& aTargetId ,
       
    99                                               const UString& aAttribName ) const; 
       
   100     /**
       
   101      * Set a value of an attribute.
       
   102      *
       
   103      * @param aAttribute Reference attribute, the data is copied from it.
       
   104      * The ownership is not transferred.
       
   105      * @return True if the attribute was supported, false if not.
       
   106      */
       
   107     virtual bool setAttribute(const AlfAttribute& aAttribute); 
       
   108 
       
   109     /**
       
   110      * Sets a value of an attribute to a specific target. 
       
   111      * The target is identified by using aTargetId parameter.
       
   112      *
       
   113      * @param aTargetId  Name of the target widget part, e.g element class tag.
       
   114      * @param aAttribute Reference attribute, the data is copied from it.
       
   115      *                   The ownership is not transferred.
       
   116      * @return True if the attribute was supported, false if not.
       
   117      */    
       
   118     virtual bool setAttribute( const UString& aTargetId , 
       
   119                                AlfAttribute& aAttribute ); 
       
   120     /**
       
   121      * Set a value of an attribute.
       
   122      * This SetAttribute variant is for simple non animated attributes 
       
   123      * that only have name and value.
       
   124      *
       
   125      * @param aAttribName Name of the attribute.
       
   126      * @param aValue Value of the attribute. Ownership is transferred
       
   127      * @return True if the attribute was supported, false if not.
       
   128      */    
       
   129     virtual bool setAttribute(const UString& aAttribName, 
       
   130         AlfAttributeValueType* aValue);         
       
   131         
       
   132     /**
       
   133      * Sets a value of an static attribute.
       
   134      * This SetAttribute variant is for simple non animated attributes 
       
   135      * that only have name and value.
       
   136      *
       
   137      * @param aTargetId   The name of the target widget part, e.g. element class
       
   138      * @param aAttribName Name of the attribute.
       
   139      * @param aValue      Value of the attribute. Ownership is transferred
       
   140      * @return True if the attribute was supported, false if not.
       
   141      */
       
   142     virtual bool setAttribute( const UString& aTargetId, 
       
   143                                const UString& aAttribName, 
       
   144                                AlfAttributeValueType* aValue );
       
   145     
       
   146     /**
       
   147      * Sets values of each attribute in given container to a specific target. 
       
   148      * The target is identified by using aTargetId parameter.
       
   149      * 
       
   150      * When the target attributeowner instance cannot handle an attribute in the container,
       
   151      * an AlfAttributeException-exception is thrown with EInvalidAttribute parameter.
       
   152      *
       
   153      * @param aTargetId  Name of the target widget part, e.g element class tag.
       
   154      * @param aAttributeContainer Reference attributeContainer, All attributes
       
   155      *        in the container are handled. The ownership is not transferred.
       
   156      * @return True if all attributes were supported, false if not.
       
   157      */    
       
   158     virtual bool setAttributeContainer( const UString& aTargetId , 
       
   159                                AlfAttributeContainer& aAttributeContainer ); 
       
   160 
       
   161     /**
       
   162      * Sets values of each attribute in given container
       
   163      *
       
   164      * When an attributeowner-instance (which can handle some of the attributes in the container) 
       
   165      * cannot handle an attribute in the container,
       
   166      * an AlfAttributeException-exception is thrown with EInvalidAttribute parameter.
       
   167      *
       
   168      * @param aAttributeContainer Reference attributeContainer, All attributes
       
   169      *        in the container are handled. The ownership is not transferred.
       
   170      *                            
       
   171      * @return True if all attributes were supported, false if not.
       
   172      */    
       
   173     virtual bool setAttributeContainer( AlfAttributeContainer& aAttributeContainer );
       
   174     
       
   175      
       
   176 private:
       
   177 
       
   178     /**
       
   179      * Handles the attribute, sets proper values.
       
   180      *
       
   181      * @param aAttribute Reference attribute, the data is copied from it.
       
   182      * The ownership is not transferred.
       
   183      */
       
   184     void handleAttribute(AlfAttribute& aAttribute);      
       
   185     
       
   186     /**
       
   187      * Can attribute be handled with this widget.
       
   188      *
       
   189      * @param aAttributeName Name of the attribute.
       
   190      * @return True if attribute is supported, false elsewhere.
       
   191      */
       
   192     bool canHandleAttribute(const char* aAttributeName);    
       
   193     
       
   194     /**
       
   195      * Handles the Opacity Attribute.
       
   196      *
       
   197      * @param aAttribute the attribute to be handled.
       
   198      */
       
   199     void handleOpacityAttribute(AlfAttribute& aAttribute);
       
   200     
       
   201     /**
       
   202      * Handles the Position Attribute.
       
   203      *
       
   204      * @param aAttribute the attribute to be handled.
       
   205      */
       
   206     void handlePositionAttribute(AlfAttribute& aAttribute);
       
   207 
       
   208     /**
       
   209      * Handles the Tactile Attribute.
       
   210      *
       
   211      * @param aAttribute the attribute to be handled.
       
   212      */
       
   213 	void handleTactileAttribute(AlfAttribute& aAttributeEvent,AlfAttribute& aAttributeFeedback);
       
   214 
       
   215     /**
       
   216      * Handles the Size Attribute.
       
   217      *
       
   218      * @param aAttribute the attribute to be handled.
       
   219      */
       
   220     void handleSizeAttribute(AlfAttribute& aAttribute);
       
   221     
       
   222     /**
       
   223      * Handles the Max Size Attribute.
       
   224      *
       
   225      * @param aAttribute the attribute to be handled.
       
   226      */
       
   227     void handleMaxSizeAttribute(AlfAttribute& aAttribute);
       
   228     
       
   229     /**
       
   230      * Handles the Min Size Attribute.
       
   231      *
       
   232      * @param aAttribute the attribute to be handled.
       
   233      */
       
   234     void handleMinSizeAttribute(AlfAttribute& aAttribute);
       
   235     
       
   236     /**
       
   237      * Handles setting of paired attributes: width & height, xpos & ypos etc.
       
   238      *
       
   239      * @param aAttribute the attribute to be handled.
       
   240      * @param aAttributeNamePair name for the pair attribute of aAttribute.
       
   241      */
       
   242     bool handleAttributePairs(AlfAttribute& aAttribute, 
       
   243         const char* aAttributeNamePair);
       
   244 
       
   245 private:
       
   246 
       
   247     /*
       
   248      * Reference to owner element. Not own.
       
   249      */
       
   250     AlfElement& mElement;
       
   251     
       
   252     /*
       
   253      * Reference to control.
       
   254      */
       
   255     CAlfWidgetControl& mControl;
       
   256 
       
   257     /*
       
   258      * Array of attributes set through IAlfAttributeOwner interface. Own.
       
   259      */
       
   260     AlfPtrVector<AlfAttribute> mAttributeList;        
       
   261     };
       
   262     
       
   263     }   // namespace Alf
       
   264     
       
   265 #endif // __ALFELEMENTATTRIBUTEOWNERIMPL_H__