idlehomescreen/inc/xndompropertyvalue.h
changeset 0 f72a12da539e
child 2 08c6ee43b396
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2005,2006 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:  Property's value encapsulation. 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef XN_DOM_PROPERTY_VALUE_H
       
    21 #define XN_DOM_PROPERTY_VALUE_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <s32strm.h>
       
    26 #include "mxndomlistitem.h"
       
    27 
       
    28 
       
    29 //CLASS FORWARD
       
    30 class CXnDomStringPool;
       
    31 class TRgb;
       
    32 // CLASS DECLARATION
       
    33 
       
    34 /**
       
    35 *  @ingroup group_domdocument
       
    36 *  Serializable class to hold property's value.
       
    37 *
       
    38 *  @lib XnDomDocument.lib
       
    39 *  @since Series 60 3.1
       
    40 */
       
    41 class CXnDomPropertyValue : public CBase, public MXnDomListItem
       
    42     {
       
    43     public:  //Enumerations
       
    44         
       
    45         /**
       
    46         * CSS Primitive value type
       
    47         */
       
    48         enum TPrimitiveValueType
       
    49             {
       
    50             EUnknown = 0,
       
    51             ENumber,
       
    52             EPercentage,
       
    53             EEms,
       
    54             EExs,
       
    55             EPx,
       
    56             ECm,
       
    57             EMm,
       
    58             EIn,
       
    59             EPt,
       
    60             EPc,
       
    61             EDeg,
       
    62             ERad,
       
    63             EGrad,
       
    64             EMs,
       
    65             ES,
       
    66             EHz,
       
    67             EKHz,
       
    68             EDimension,
       
    69             EString,
       
    70             EUri,
       
    71             EIdent,
       
    72             EAttr,
       
    73             ECounter,
       
    74             ERect,
       
    75             ERgbColor,
       
    76             ERgbaColor,
       
    77             EFunction,
       
    78             EUnitValue
       
    79             };
       
    80         
       
    81         /**
       
    82         * Ident type
       
    83         */
       
    84         enum TIdentType
       
    85             {
       
    86             ENotSet = 0,
       
    87             EAuto,
       
    88             ENone,
       
    89             EInherit
       
    90             };
       
    91                 
       
    92     public:  // Constructors and destructor
       
    93         
       
    94         /**
       
    95         * Two-phased constructor.
       
    96         */
       
    97         IMPORT_C static CXnDomPropertyValue* NewL( CXnDomStringPool& aStringPool );
       
    98         
       
    99         /**
       
   100         * Two-phased stream constructor.
       
   101         */
       
   102         static CXnDomPropertyValue* NewL( 
       
   103             RReadStream& aStream, 
       
   104             CXnDomStringPool& aStringPool );
       
   105         
       
   106         /**
       
   107         * Destructor.
       
   108         */
       
   109         IMPORT_C virtual ~CXnDomPropertyValue();
       
   110 
       
   111     public: // New functions
       
   112         /**
       
   113         * Clone property value.
       
   114         * @since Series 60 3.1
       
   115         * @return Pointer to a property value. Ownership is transferred to a caller 
       
   116         */
       
   117         IMPORT_C CXnDomPropertyValue* CloneL();
       
   118        
       
   119         /**
       
   120         * Clone property value.
       
   121         * @since Series 60 3.1
       
   122         * @param aStringPool StringPool clone which holds actual strings.
       
   123         * @return Pointer to a property value. Ownership is transferred to a caller 
       
   124         */
       
   125         CXnDomPropertyValue* CloneL( CXnDomStringPool& aStringPool );
       
   126         
       
   127         /**
       
   128         * Release object's data.
       
   129         * @since Series 60 3.1 
       
   130         */
       
   131         IMPORT_C void ReleaseData();        
       
   132         
       
   133         /**
       
   134         * Get the property's value. If value type is not recognized,
       
   135         * function will leave with KErrNotSupported. 
       
   136         * @since Series 60 3.1
       
   137         * @return Property's value
       
   138         */
       
   139         IMPORT_C TReal FloatValueL() const;
       
   140 
       
   141         /**
       
   142         * Set the property's value based on a given type. If type is not recognized,
       
   143         * function will leave with KErrNotSupported. 
       
   144         * @since Series 60 3.1
       
   145         * @param aValueType Type of a value.
       
   146         * @param aFloatValue Property's value.
       
   147         */
       
   148         IMPORT_C void SetFloatValueL( TPrimitiveValueType aValueType, TReal aFloatValue );
       
   149 
       
   150         /**
       
   151         * Get the property's string value. If value is not a string type,
       
   152         * function will leave with KErrNotSupported.
       
   153         * @since Series 60 3.1
       
   154         * @return Pointer to the property's string value.
       
   155         */
       
   156         IMPORT_C const TDesC8& StringValueL() ;
       
   157         
       
   158         /**
       
   159         * Get the property's string value. If value is not a string type,
       
   160         * function will return KNullDesC8.
       
   161         * @since Series 60 5.0
       
   162         * @return Reference to string.
       
   163         */
       
   164         IMPORT_C const TDesC8& StringValue() ;
       
   165 
       
   166         /**
       
   167         * Set the property's string value based on a given type. If type is not recognized,
       
   168         * function will leave with KErrNotSupported. 
       
   169         * @since Series 60 3.1
       
   170         * @param aValueType Type of a value.
       
   171         * @param aStringValue Property's string value.
       
   172         */
       
   173         IMPORT_C void SetStringValueL(
       
   174             TPrimitiveValueType aValueType,
       
   175             const TDesC8& aStringValue );
       
   176         
       
   177         /**
       
   178         * Get the property's color value.
       
   179         * @since Series 60 3.1
       
   180         * @return Property's color value (TRgb). 
       
   181         */
       
   182         IMPORT_C const TRgb& RgbColorValueL() const;
       
   183         
       
   184         /**
       
   185         * Sets the RGB Color value
       
   186         * @since Series 60 3.1
       
   187         * @param aRgb Instance of TRgb.
       
   188         */
       
   189         IMPORT_C void SetRgbColorL( const TRgb& aRgb );
       
   190         
       
   191         /**
       
   192         * Returns the primitive value type
       
   193         * @since Series 60 3.1
       
   194         * @return Primitive value type
       
   195         */
       
   196         IMPORT_C TPrimitiveValueType PrimitiveValueType() const;
       
   197         
       
   198         /**
       
   199         * Checks if string value is "inherit" 
       
   200         * @since Series 60 3.1
       
   201         * @return ETrue if TPrimitiveValueType::EIdent and string value is "inherit".
       
   202         */
       
   203         IMPORT_C TBool IsInheritIdent();
       
   204         
       
   205         /**
       
   206         * Checks if string value is "auto" 
       
   207         * @since Series 60 3.1
       
   208         * @return ETrue if TPrimitiveValueType::EIdent and string value is "auto".
       
   209         */
       
   210         IMPORT_C TBool IsAutoIdent();
       
   211         
       
   212         /**
       
   213         * Checks if string value is "none" 
       
   214         * @since Series 60 3.1
       
   215         * @return ETrue if TPrimitiveValueType::EIdent and string value is "none".
       
   216         */
       
   217         IMPORT_C TBool IsNoneIdent();
       
   218         
       
   219         /**
       
   220         * Set the property's string pool index
       
   221         * @since Series 60 3.1
       
   222         * @param aValueType Type of a value.
       
   223         * @param aStringPoolIndex String pool index.
       
   224         */
       
   225         IMPORT_C void SetStringPoolIndexL( 
       
   226             TPrimitiveValueType aValueType,
       
   227             TInt16 aStringPoolIndex );
       
   228         /**
       
   229         * Get the property's string pool index. If type is not string,
       
   230         * function will leave with KErrNotSupported. 
       
   231         * @since Series 60 3.1
       
   232         * @return String pool index.
       
   233         */
       
   234         IMPORT_C TInt16 StringPoolIndexL()const; 
       
   235     
       
   236     public: //From MXnDomListItem    
       
   237         /**
       
   238         * Documented in MXnDomListItem::Size
       
   239         */
       
   240         TInt Size()const;
       
   241         
       
   242         /**
       
   243         * Documented in MXnDomListItem::ExternalizeL
       
   244         */
       
   245         void ExternalizeL( RWriteStream& aStream ) const;
       
   246        
       
   247         /**
       
   248         * Documented in MXnDomListItem::InternalizeL
       
   249         */
       
   250         void InternalizeL( RReadStream& aStream );
       
   251         
       
   252         
       
   253         /**
       
   254         * Documented in MXnDomListItem::Name
       
   255         */
       
   256         const TDesC8& Name(){ return KNullDesC8; }   
       
   257 
       
   258     private:
       
   259 
       
   260         /**
       
   261         * C++ default constructor.
       
   262         */
       
   263         CXnDomPropertyValue( CXnDomStringPool& aStringPool );
       
   264 
       
   265         /**
       
   266         * By default Symbian 2nd phase constructor is private.
       
   267         */
       
   268         void ConstructL();
       
   269         
       
   270                 
       
   271     private:    // Data
       
   272         
       
   273         // union containing the primitive value data, 
       
   274         // this is an union for memory consumption optimization reasons
       
   275         union
       
   276             {
       
   277             // rgba color
       
   278             TRgb*   iRgbColor;
       
   279 
       
   280             // Real value
       
   281             TReal*  iRealValue;
       
   282 
       
   283             // String reference
       
   284             TInt16  iStringRef;
       
   285            
       
   286             // Constant string value
       
   287             TPtrC*  iUnknownValue;
       
   288             
       
   289             } iData;    
       
   290        
       
   291        //String pool
       
   292        CXnDomStringPool&    iStringPool;
       
   293        
       
   294        // primitive value type
       
   295        TPrimitiveValueType  iPrimitiveValueType;
       
   296        
       
   297        //Flag to identify ident
       
   298        TIdentType           iIdent;
       
   299        
       
   300     };
       
   301 
       
   302 #endif      // XN_DOM_PROPERTY_VALUE_H  
       
   303             
       
   304 // End of File