widgetmodel/alfwidgetmodel/inc/alfwidgetattributeownerimpl.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 AlfWidget.
       
    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 CAlfWidgetControl;   
       
    30 
       
    31 /**
       
    32  * Implementation of the IAlfAttributeOwner interface for AlfWidget.
       
    33  */    
       
    34 class AlfWidgetAttributeOwnerImpl : public IAlfAttributeOwner
       
    35     {
       
    36 public:
       
    37 
       
    38     /**
       
    39      * Constructor.
       
    40      *
       
    41      * @param aWidget Reference to owner widget.
       
    42      */
       
    43     AlfWidgetAttributeOwnerImpl(CAlfWidgetControl* aControl);
       
    44 
       
    45     /**
       
    46      * Destructor.
       
    47      */
       
    48     virtual ~AlfWidgetAttributeOwnerImpl();
       
    49     
       
    50 // from base class IAlfInterfaceBase
       
    51 
       
    52     /**
       
    53      * Getter for interfaces provided by the widget classes.
       
    54      * Derived classes should always call the base class method
       
    55      * from the overridden MakeInterface.
       
    56      *
       
    57      * @since S60 ?S60_version
       
    58      * @param aType A descriptor to identify the type of the queried interface.
       
    59      * @return The queried interface, or NULL if the interface is not
       
    60      *         supported or available.
       
    61      */
       
    62     virtual IAlfInterfaceBase* makeInterface(const IfId& aType);       
       
    63             
       
    64 // from base class IAlfAttributeOwner
       
    65 
       
    66 	/**
       
    67      * Get the number of available attributes.
       
    68      *
       
    69      * @return The number of attributes.
       
    70      */
       
    71     virtual int attributeCount() const;
       
    72 
       
    73     /**
       
    74      * Gets the attribute with the given name.
       
    75      * The returned attribute instance is owned by the widget and
       
    76      * should not be deleted.
       
    77      * Also the returned attribute instance should not be modified.
       
    78      * Use SetAttribute for that.
       
    79      *
       
    80      * @param aAttribName The name of the attribute.
       
    81      * @return The attribute, or 0 if the attribute was not found.
       
    82      */
       
    83     virtual const AlfAttribute* getAttribute(const UString& aAttribName) const;
       
    84 
       
    85     /**
       
    86      * Set a value of an attribute.
       
    87      *
       
    88      * @param aAttribute Reference attribute, the data is copied from it.
       
    89      * The ownership is not transferred.
       
    90      * @return True if the attribute was supported, false if not.
       
    91      */
       
    92     virtual bool setAttribute(const AlfAttribute& aAttribute); 
       
    93 
       
    94     /**
       
    95      * Set a value of an attribute.
       
    96      * This SetAttribute variant is for simple non animated attributes 
       
    97      * that only have name and value.
       
    98      *
       
    99      * @param aAttribName Name of the attribute.
       
   100      * @param aValue Value of the attribute. Ownership is transferred
       
   101      * @return True if the attribute was supported, false if not.
       
   102      */    
       
   103     virtual bool setAttribute(const UString& aAttribName, 
       
   104         AlfAttributeValueType* aValue);         
       
   105         
       
   106     /**
       
   107      * Sets a value of an attribute to a specific target. 
       
   108      * The target is identified by using aTargetId parameter.
       
   109      *
       
   110      * @param aTargetId  Name of the target widget part, e.g element class tag.
       
   111      * @param aAttribute Reference attribute, the data is copied from it.
       
   112      *                   The ownership is not transferred.
       
   113      * @return True if the attribute was supported, false if not.
       
   114      */    
       
   115     virtual bool setAttribute( const UString& aTargetId , 
       
   116                                AlfAttribute& aAttribute ); 
       
   117 
       
   118 
       
   119    /**
       
   120      * Sets values of each attribute in given container to a specific target. 
       
   121      * The target is identified by using aTargetId parameter.
       
   122      *
       
   123      * @param aTargetId  Name of the target widget part, e.g element class tag.
       
   124      * @param aAttributeContainer Reference attributeContainer, All attributes
       
   125      *        in the container are handled. The ownership is not transferred.
       
   126      * @return True if some attributes were supported, false if not.
       
   127      */    
       
   128     virtual bool setAttributeContainer( const UString& aTargetId , 
       
   129                                AlfAttributeContainer& aAttributeContainer ); 
       
   130 
       
   131   /**
       
   132      * Sets a value of an static attribute.
       
   133      * This SetAttribute variant is for simple non animated attributes 
       
   134      * that only have name and value.
       
   135      *
       
   136      * @param aTargetId   The name of the target widget part, e.g. element class
       
   137      * @param aAttribName Name of the attribute.
       
   138      * @param aValue      Value of the attribute. Ownership is transferred
       
   139      * @return True if the attribute was supported, false if not.
       
   140      */
       
   141     virtual bool setAttribute( const UString& aTargetId, 
       
   142                                const UString& aAttribName, 
       
   143                                AlfAttributeValueType* aValue );
       
   144     
       
   145        /**
       
   146      * Sets values of each attribute in given container
       
   147      *
       
   148      * @param aAttributeContainer Reference attributeContainer, All attributes
       
   149      *        in the container are handled. The ownership is not transferred.
       
   150      *                            
       
   151      * @return True if some attributes were supported, false if not.
       
   152      */    
       
   153     virtual bool setAttributeContainer( AlfAttributeContainer& aAttributeContainer ); 
       
   154     
       
   155  		/**
       
   156      * Gets the attribute with the given name from specific target.
       
   157      * The returned attribute instance is owned by the widget and
       
   158      * should not be deleted.
       
   159      * Also the returned attribute instance should not be modified.
       
   160      * Use SetAttribute for that.
       
   161      *
       
   162      * @param aTargetId   The name of the target widget part, e.g. element class
       
   163      * @param aAttribName The name of the attribute.
       
   164      * @return A pointer to the attribute, or 0 if the attribute was not found.
       
   165      */
       
   166     virtual const AlfAttribute* getAttribute( const UString& aTargetId ,
       
   167                                               const UString& aAttribName ) const;
       
   168 private:
       
   169 
       
   170     /**
       
   171      * Lets elements to try handle attribute.
       
   172      *
       
   173      * @param aAttribute Reference attribute, the data is copied from it.
       
   174      * The ownership is not transferred.
       
   175      * @return True if the attribute was supported, false if not.
       
   176      */
       
   177     bool handleElementAttribute(const AlfAttribute& aAttribute);
       
   178 
       
   179     /**
       
   180      * Handles the attribute, sets proper values.
       
   181      *
       
   182      * @param aAttribute Reference attribute, the data is copied from it.
       
   183      * The ownership is not transferred.
       
   184      */
       
   185     void handleAttribute(const AlfAttribute& aAttribute);      
       
   186     
       
   187     /**
       
   188      * Can attribute be handled with this widget.
       
   189      *
       
   190      * @param aAttributeName Name of the attribute.
       
   191      * @return True if attribute is supported, false elsewhere.
       
   192      */
       
   193     bool canHandleAttribute(const char* aAttributeName);
       
   194 
       
   195 private:
       
   196 
       
   197     /**
       
   198      * The control. Not own.
       
   199      */
       
   200     CAlfWidgetControl* mControl;
       
   201 
       
   202     /*
       
   203      * Array of attributes set through IAlfAttributeOwner interface. Own.
       
   204      */
       
   205     AlfPtrVector<AlfAttribute> mAttributeList;        
       
   206     };
       
   207     
       
   208     }   // namespace Alf
       
   209     
       
   210 #endif // __ALFELEMENTATTRIBUTEOWNERIMPL_H__