Nokia N97 SDK
Example Applications Guide

HsWidgetExample.h

00001 /*
00002  ============================================================================
00003  Name           : HsWidgetExample.h
00004  Author   : 
00005  Version         : 1.1
00006  Copyright   : This material, including documentation and any related computer
00007           programs, is protected by copyright controlled by Nokia Corporation.
00008  Description : CHsWidgetExample declaration
00009  ============================================================================
00010  */
00011 
00012 #ifndef __HSWIDGETEXAMPLE_H__
00013 #define __HSWIDGETEXAMPLE_H__
00014 
00015 // INCLUDES
00016 #include <e32std.h>
00017 #include <e32base.h>
00018 #include <string>
00019 #include <hsdataobserver.h>
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          * Template is being published when the received event is EActivate or EResume
00041          *       
00042          * @param aWidgetName Name of the widget that event is envoked for.
00043          * @param aEvent Event type that has taken place.
00044          */
00045         virtual void handleEvent( std::string aWidgetName, 
00046                         IHsDataObserver::EEvent aEvent);
00047         
00048         /**
00049          * If the ESelect event was triggerred by the image item it will trigger the
00050          * content of the widget items to be changed. If the event is triggeted by the
00051          * text item the publisher application will he sent to foreground.
00052          * To be noted that if the publisher application is not running the Homescreen
00053          * application will start the publisher. The subsequent events will be sent to
00054          * the now running publisher application.
00055          *
00056          * @param aWidgetName Name of the widget that event is envoked for.
00057          * @param aWidgetItemName Name of the item that event is envoked for.
00058          * @param aEvent Event type that has taken place
00059          */    
00060         virtual void handleItemEvent( std::string aWidgetName,
00061                         std::string aWidgetItemName,
00062                         IHsDataObserver::EItemEvent aEvent);
00063             
00064 public:
00065         // Constructors and destructor
00066 
00067         /**
00068          * C++ destructor.
00069          */
00070         virtual ~CHsWidgetExample();
00071 
00072         /**
00073          * Two-phased constructor.
00074          */
00075         static CHsWidgetExample* NewL();
00076 
00077         /**
00078          * Two-phased constructor. Leaves constructed object on the cleanup stack
00079          */
00080         static CHsWidgetExample* NewLC();
00081 
00082         /**
00083          * Register widget to the home screen so it can be added as content.
00084          * New template is created and is kept by the Home Screen Publishing API.
00085          */     
00086         void RegisterWidgetL();
00087         
00088         /**
00089          * Publish widget with actual seted items' values to the home screen.
00090          */     
00091         void PublishWidgetL();
00092         
00093         /**
00094          * Change items' values. They will only be commited (and updated on the
00095          * home screen) once you call PublishWidgetL
00096          */
00097         void ChangeWidgetValuesL();
00098         
00099         /**
00100          * Remove widget's template from the Homescreen Publishing API.
00101          * It is now not available for the home screen and it doesn't report events. 
00102          */
00103         void RemoveWidgetL();
00104         
00105 private:
00106 
00107         /**
00108          * C++ constructor for performing the 1st stage construction
00109          */
00110         CHsWidgetExample();
00111 
00112         /**
00113          * EPOC default constructor for performing the 2nd stage construction
00114          */
00115         void ConstructL();
00116         
00117         /**
00118          * Conversion method. 
00119          * @param aText string to convert
00120          * @return converted string
00121          */
00122         std::string ToStringL(const TDesC& aText);
00123         
00124 private:
00125         /**
00126          * The Home Screen Publisher API's main class
00127          */
00128         Hs::HsWidgetPublisher* iHsWidgetPublisher;
00129         
00130         /**
00131          * String indicating which template will be used for this widget.
00132          */
00133         std::string templateType;
00134         
00135         /**
00136          * Widget's name. Will be shown to the user when he/she selects a
00137          * widget to be added to the home screen.
00138          */
00139         std::string widgetName;
00140         
00141         /**
00142          * Unique UID identifiying a widget.
00143          */
00144         std::string widgetId;
00145         
00146         /**
00147          * A counter, used to display different content on its widget depending
00148          * on its odd/even value
00149          */
00150         TInt iCounter;
00151         };
00152 
00153 #endif // __HSWIDGETEXAMPLE_H__

© Nokia 2009

Back to top