epoc32/include/hswidget.h
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/hswidget.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,178 @@
     1.4 +/*
     1.5 +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:  Updates applications and icons in Operator Tile.
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#ifndef __HSWIDGET_H__
    1.23 +#define __HSWIDGET_H__
    1.24 +
    1.25 +//  Include Files
    1.26 +#include <cctype>
    1.27 +#include <string>
    1.28 +#include <memory>
    1.29 +#include <vector>
    1.30 +
    1.31 +namespace Hs {
    1.32 +
    1.33 +class HsWidgetItem;
    1.34 +
    1.35 +/**
    1.36 + * Class defining a Homescreen Widget. A widget is identified by
    1.37 + * its templateName, widgetName, uniqueIdentifier.
    1.38 + * 
    1.39 + * @code
    1.40 + * @code
    1.41 + * class ObserverClass : public IHsDataObserver
    1.42 + * {
    1.43 + *      void handleEvent( std::string aWidgetName, 
    1.44 + *			IHsDataObserver::EEvent aEvent)
    1.45 + *      {
    1.46 + *      }
    1.47 + * 
    1.48 + *      void handleItemEvent( std::string aWidgetName,
    1.49 + *        	std::string aWidgetItemName,
    1.50 + *       	IHsDataObserver::EItemEvent aEvent)
    1.51 + *      {
    1.52 + *      }
    1.53 + * }
    1.54 + * 
    1.55 + * ObserverClass* dataObserver = new ObserverClass();
    1.56 + * HsWidgetPublisher* hsPublisher = new HsWidgetPublisher( dataObserver );
    1.57 + * HsWidget& widget =  hsPublisher->createHsWidget( 
    1.58 + *     "templateName", "widgetName", "uniqueIdentifier" );
    1.59 + * hsPublisher->publishHsWidget( widget ); 
    1.60 + * @endcode
    1.61 + */
    1.62 +class HsWidget
    1.63 +    {
    1.64 +public:
    1.65 +    /**
    1.66 +     * Adds a new widget item to the widget if it wasn't created 
    1.67 +     * previously or set a new value to the existing one.
    1.68 +     * Widget item is identified by the name with the value provided. 
    1.69 +     * The value is a string.
    1.70 +     *
    1.71 +     * @code
    1.72 +     * HsWidgetPublisher* hsPublisher = new HsWidgetPublisher( dataObserver );
    1.73 +     * HsWidget& widget =  hsPublisher->createHsWidget( 
    1.74 +     *     "templateName", "widgetName", "uniqueIdentifier" );
    1.75 +     * // assuming count and values[] are defined
    1.76 +     * while ( count )
    1.77 +     * {
    1.78 +     *    widget->setItem("image", values[count] );
    1.79 +     *    count--;
    1.80 +     * }
    1.81 +     * @endcode
    1.82 +     * @param aItemName, Name of the widget item.
    1.83 +     * @param aValue Integer value of the widget item.
    1.84 +     * @exception HsException
    1.85 +     */
    1.86 +    IMPORT_C void setItem( std::string aItemName, std::string aValue);
    1.87 +    
    1.88 +    /**
    1.89 +     * Adds a new widget item to the widget if it wasn't created previously 
    1.90 +     * or set a new value to the existing one. Widget item is identified by 
    1.91 +     * the name with the value provided. The value is a int.
    1.92 +     *
    1.93 +     * @code
    1.94 +     * HsWidgetPublisher* hsPublisher = new HsWidgetPublisher( dataObserver );
    1.95 +     * HsWidget& widget =  hsPublisher->createHsWidget( 
    1.96 +     *     "templateName", "widgetName", "uniqueIdentifier" );
    1.97 +     * // assuming count and values[] are defined
    1.98 +     * while ( count )
    1.99 +     * {
   1.100 +     *    widget->setItem("image", values[count] );
   1.101 +     *    count--;
   1.102 +     * }
   1.103 +     * @endcode
   1.104 +     * @param aItemName, Name of the widget item.
   1.105 +     * @param aValue Integer value of the widget item.
   1.106 +     * @exception HsException
   1.107 +     */
   1.108 +    IMPORT_C void setItem( std::string aItemName, int aValue );
   1.109 +    
   1.110 +    /**
   1.111 +     * Method removes widget's item.
   1.112 +     * An attempt to remove not existing item causes exception with 
   1.113 +     * KErrNotFound reason;
   1.114 +     *
   1.115 +     * @code
   1.116 +     * HsWidgetPublisher* hsPublisher = new HsWidgetPublisher( dataObserver );
   1.117 +     * HsWidget& widget =  hsPublisher->createHsWidget( 
   1.118 +     *     "templateName", "widgetName", "uniqueIdentifier" );
   1.119 +     * widget.setItem( "myItem", "value" );
   1.120 +     * widget.removeItem( "myItem" );
   1.121 +     * hsPublisher->removeHsWidget(
   1.122 +     *     "templateName", "widgetName", "uniqueIdentifier" );
   1.123 +     * @endcode
   1.124 +     * @param aItemName Name of the Item.
   1.125 +     * @param aWidgetName Name of the Widget
   1.126 +     * @param aIdentifier Unique identification of the content.
   1.127 +     * @exception HsException
   1.128 +     */
   1.129 +    IMPORT_C void removeItem( std::string aItemName );
   1.130 +    
   1.131 +public: 
   1.132 +    
   1.133 +    /**
   1.134 +     */
   1.135 +	HsWidget( std::string& aTemplateName, 
   1.136 +        std::string& aWidgetName,
   1.137 +        std::string& aIdentifier );
   1.138 +
   1.139 +    /**
   1.140 +     */
   1.141 +    virtual ~HsWidget();
   1.142 +    
   1.143 +    /**
   1.144 +     */
   1.145 +    HsWidgetItem* getWidgetItem( std::string& aItemName );
   1.146 +
   1.147 +    /**
   1.148 +     */
   1.149 +    const std::string& getWidgetName();
   1.150 +    
   1.151 +    /**
   1.152 +     */
   1.153 +    const std::string& getTemplateName();
   1.154 +    
   1.155 +    /**
   1.156 +     */
   1.157 +    const std::string& getIdentifier();
   1.158 +    
   1.159 +    /**
   1.160 +     */
   1.161 +    int itemsCount();
   1.162 +    
   1.163 +    /**
   1.164 +     */
   1.165 +    HsWidgetItem* getWidgetItem( int aIndex );
   1.166 +    
   1.167 +    /**
   1.168 +     */
   1.169 +    bool checkIfWidgetItemExist( std::string& aItemName );
   1.170 +    
   1.171 +private:
   1.172 +    std::string mWidgetName;
   1.173 +    std::string mTemplateName;
   1.174 +    std::string mIdentifier;
   1.175 +    std::vector<HsWidgetItem*> mItems;
   1.176 +    };
   1.177 +
   1.178 +}
   1.179 +
   1.180 +
   1.181 +#endif /*__HSWIDGET_H__*/