idlehomescreen/xmluicontroller/inc/aixmluiutils.h
changeset 0 f72a12da539e
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2005-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:  Collection of common utility functions
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef AIXMLUIUTILS_H
       
    20 #define AIXMLUIUTILS_H
       
    21 
       
    22 #include <e32std.h>
       
    23 
       
    24 class CXnNodeAppIf;
       
    25 class CGulIcon;
       
    26 class TAiPolicyElement;
       
    27 class RPropertyHashMap;
       
    28 
       
    29 namespace AiXmlUiController
       
    30     {
       
    31     class CCssPropertyMap;
       
    32   
       
    33   
       
    34 /**
       
    35  * Finds a property element identified by the specified class.
       
    36  *
       
    37  * @param aUiElement the UI element associated with the property.
       
    38  * @param aPropertyClass the class of the property.
       
    39  * @return pointer array to the property elements. Ownership of the array
       
    40  *         is transferred. Ownership of the elements is not transferred.
       
    41  */
       
    42 RPointerArray< CXnNodeAppIf > FindPropertyElementL( CXnNodeAppIf& aUiElement,
       
    43                                                     const TDesC8& aPropertyClass );
       
    44 
       
    45 /**
       
    46  * Finds a property element identified by the specified class.
       
    47  *
       
    48  * @param aArray The Array where to append the nodes. 
       
    49  * @param aUiElement the UI element associated with the property.
       
    50  * @param aPropertyClass the class of the property.
       
    51  * @return pointer array to the property elements. Ownership of the array
       
    52  *         is transferred. Ownership of the elements is not transferred.
       
    53  */
       
    54 void FindPropertyElementL( RPointerArray< CXnNodeAppIf >& aArray, CXnNodeAppIf& aUiElement, const TDesC8& aPropertyClass );
       
    55 
       
    56 /**
       
    57  * Gets a property value from an UI element. The ownership of value is
       
    58  * transferred to caller.
       
    59  *
       
    60  * @param aUiElement the UI element to fecth the value from
       
    61  * @param aPropertyName the name of the property to fetch.
       
    62  * @return the value or NULL.
       
    63  */
       
    64 HBufC* PropertyValueL( const CXnNodeAppIf& aUiElement,
       
    65                        const TDesC8& aPropertyName );
       
    66 
       
    67 /**
       
    68  * Gets a property value from an UI element.
       
    69  *
       
    70  * @param aUiElement the UI element to fecth the value from
       
    71  * @param aPropertyName the name of the property to fetch.
       
    72  * @return the value or NULL.
       
    73  */
       
    74 const TDesC8* PropertyValue( const CXnNodeAppIf& aUiElement,
       
    75                              const TDesC8& aPropertyName );
       
    76 
       
    77 /**
       
    78  * Sets a property value into an UI element
       
    79  *
       
    80  * @param aUiElement the UI element to set the value into.
       
    81  * @param aPropertyName the name of the property to set.
       
    82  * @param aPropertyValue the new value.
       
    83  * @param aPropertyMap map of the original property values
       
    84  */
       
    85 void SetPropertyL( CXnNodeAppIf& aUiElement,
       
    86                    const TDesC8& aPropertyName,
       
    87                    const TDesC8& aPropertyValue,
       
    88                    CCssPropertyMap& aPropertyMap );
       
    89 
       
    90 /**
       
    91  * Sets a property values into hash map
       
    92  *
       
    93  * @param aArray the element array.
       
    94  * @param aPropertyMap map of the original property values
       
    95  * @param aPropertyHashMap hash map of the new property value arrays
       
    96  */
       
    97 void SetPropertiesToHashMapL( RArray<TAiPolicyElement>& aArray,
       
    98                               CCssPropertyMap& aPropertyMap,
       
    99                               RPropertyHashMap& aPropertyHashMap );
       
   100 
       
   101 /**
       
   102  * Sets all property values into an UI element(s)
       
   103  *
       
   104  * @param aPropertyMap map of the property arrays
       
   105  */
       
   106 void SetPropertyArraysL( RPropertyHashMap& aPropertyHashMap );
       
   107 
       
   108 /**
       
   109  * Sets a property value directly into an UI element
       
   110  *
       
   111  * @param aUiElement the UI element to set the value into.
       
   112  * @param aPropertyName the name of the property to set.
       
   113  * @param aPropertyValue the new value.
       
   114  */
       
   115 void SetPropertyToNodeL( 
       
   116     CXnNodeAppIf& aNode, 
       
   117     const TDesC8& aPropertyName, 
       
   118     const TDesC8& aNewValueString );
       
   119 
       
   120 /**
       
   121  * Leaves with specific error if given pointer is null.
       
   122  *
       
   123  * @param aPtr pointer to test.
       
   124  * @param aError error for leave.
       
   125  * @return aPtr if it is not NULL.
       
   126  */
       
   127 template< class PtrT > inline
       
   128 PtrT* LeaveIfNull( PtrT* aPtr, TInt aError );
       
   129 
       
   130 /**
       
   131  * Loads a resource icon from the skin or from a mif-file 
       
   132  * and puts it into cleanup stack.
       
   133  *
       
   134  * Leavecodes: 
       
   135  * - KErrNotSupported: Filetype is not supported
       
   136  * - KErrNotFound: Syntax is incorrect or icon not found 
       
   137  *
       
   138  * Syntaxes:
       
   139  * - Skin: SKIN(<majorid> <minorid>)
       
   140  * - Mif: file_name.mif#<index_in_mif>
       
   141  *
       
   142  * @param aResource resource node.
       
   143  * @return icon.
       
   144  */
       
   145 CGulIcon* LoadIconLC( CXnNodeAppIf& aResource );
       
   146 
       
   147     }
       
   148 
       
   149 #include "aixmluiutils.inl"
       
   150 
       
   151 #endif // AIXMLUIUTILS_H