Nokia N97 SDK
Example Applications Guide

HsWidgetExample.h

00001 /*
00002  ============================================================================
00003  Name           : HsWidgetExample.h
00004  Author   : 
00005  Version         : 1.0
00006  Copyright   : Copyright (c) 2006 Nokia Corporation.
00007  Description : CHsWidgetExample declaration
00008  ============================================================================
00009  */
00010 
00011 #ifndef __HSWIDGETEXAMPLE_H__
00012 #define __HSWIDGETEXAMPLE_H__
00013 
00014 // INCLUDES
00015 #include <e32std.h>
00016 #include <e32base.h>
00017 #include <string>
00018 #include <hsdataobserver.h>
00019 
00020 
00021 // CLASS DECLARATION
00022 namespace Hs 
00023     {
00024     class HsWidgetPublisher;
00025     }
00026 
00027 /**
00028  *  CHsWidgetExample
00029  * 
00030  */
00031 class CHsWidgetExample : 
00032         public CBase,
00033         public Hs::IHsDataObserver
00034         {
00035 public:
00036 
00037         /**
00038          * Intended to handle an event that occured on a widget.
00039          * This would include EActivate, EDeactivate, ESuspend, EReusume.
00040          *
00041          * @param aWidgetName Name of the widget that event is envoked for.
00042          * @param aEvent Event type that has taken place.
00043          */
00044         virtual void handleEvent( std::string aWidgetName, 
00045                         IHsDataObserver::EEvent aEvent);
00046         
00047         /**
00048          * Intended to handle an event that occured on a widget's item.
00049          * This would include ESelection.
00050          *
00051          * @param aWidgetName Name of the widget that event is envoked for.
00052          * @param aWidgetItemName Name of the item that event is envoked for.
00053          * @param aEvent Event type that has taken place
00054          */    
00055         virtual void handleItemEvent( std::string aWidgetName,
00056                         std::string aWidgetItemName,
00057                         IHsDataObserver::EItemEvent aEvent);
00058             
00059 public:
00060         // Constructors and destructor
00061 
00062         /**
00063          * Destructor.
00064          */
00065         ~CHsWidgetExample();
00066 
00067         /**
00068          * Two-phased constructor.
00069          */
00070         static CHsWidgetExample* NewL();
00071 
00072         /**
00073          * Two-phased constructor.
00074          */
00075         static CHsWidgetExample* NewLC();
00076 
00077         /**
00078          * Register widget to HS so it can be added as content.
00079          * New template is created and is keept by HSApi.
00080          */     
00081         void RegisterWidget();
00082         
00083         /**
00084          * Publish widget with actual seted items' values to HS.
00085          */     
00086         void PublishWidget();
00087         
00088         /**
00089          * Change items' values.
00090          */
00091         void ChangeWidgetValuesL();
00092         
00093         /**
00094          * Remove widget's template from HSApi.
00095          * It is now not avaliable for HS and it doesn't support events. 
00096          */
00097         void RemoveWidget();
00098 
00099 private:
00100 
00101         /**
00102          * Constructor for performing 1st stage construction
00103          */
00104         CHsWidgetExample();
00105 
00106         /**
00107          * EPOC default constructor for performing 2nd stage construction
00108          */
00109         void ConstructL();
00110         
00111         /**
00112          * Conversion method. 
00113          * @param aText string to convert
00114          * @return converted string
00115          */
00116         std::string ToString(const TDesC& aText);
00117 
00118 private:
00119         Hs::HsWidgetPublisher* iHsWidgetPublisher;
00120         
00121         std::string templateType;
00122         std::string widgetName;
00123         std::string widgetId;
00124         
00125         TInt iCounter;
00126         };
00127 
00128 #endif // __HSWIDGETEXAMPLE_H__

© Nokia 2009

Back to top