idlehomescreen/xmluirendering/renderingplugins/xnnewstickerfactory/inc/xnnewstickeradapter.h
changeset 2 08c6ee43b396
parent 0 f72a12da539e
child 26 1b758917cafc
equal deleted inserted replaced
1:5315654608de 2:08c6ee43b396
    24 #include "xnnewsticker.h"
    24 #include "xnnewsticker.h"
    25 
    25 
    26 // FORWARD DECLARATIONS
    26 // FORWARD DECLARATIONS
    27 class CXnNodePluginIf;
    27 class CXnNodePluginIf;
    28 class CXnNewstickerControl;
    28 class CXnNewstickerControl;
    29 class CXnNewstickerSvgControl;
    29 class CAknMarqueeControl;
    30 
    30 
    31 // CONSTANTS
    31 // CONSTANTS
    32 // The default values for the newsticker control
    32 // The default values for the newsticker control
    33 const TInt KXnNewstickerDelay = 1000000;   // start scrolling after a delay of 1 second
    33 const TInt KXnNewstickerDelay = 1000000;   // start scrolling after a delay of 1 second
    34 const TInt KXnNewstickerInterval = 100000; // scroll 10 times in a second
    34 const TInt KXnNewstickerInterval = 100000; // scroll 10 times in a second
    49 */
    49 */
    50 class CXnNewstickerAdapter : public CXnControlAdapter,
    50 class CXnNewstickerAdapter : public CXnControlAdapter,
    51             XnNewstickerInterface::MXnNewstickerCallbackInterface
    51             XnNewstickerInterface::MXnNewstickerCallbackInterface
    52     {
    52     {
    53     public:
    53     public:
    54 
    54           
    55         /**
       
    56         * State of the whole control.
       
    57         */
       
    58         enum TState
       
    59             {
       
    60             ENotStarted = 1,            //  No scrolling has been done
       
    61             EPaused,                //  Text is shown, but not scrolled
       
    62             EText,                  //  Text is shown and scrolled continuously
       
    63             EAnimation,             //  SVG animation is shown
       
    64             EScrollEnded            //  Looping is false and scrolling has ended
       
    65             };
       
    66             
       
    67         enum TScrollBehaviour
    55         enum TScrollBehaviour
    68             {
    56             {
    69             EScroll,
    57             EScroll,
    70             ESlide,
       
    71             EAlternate,
    58             EAlternate,
    72             EScrollAlternate
    59             EScrollAlternate,
    73             };            
    60             };            
    74             
    61             
    75     public:
    62     public:
    76 
    63 
    77     	/**
    64     	/**
    90 
    77 
    91         /**
    78         /**
    92          * Append new title to the end of the title list.
    79          * Append new title to the end of the title list.
    93          * @param aTitle The new title to add.
    80          * @param aTitle The new title to add.
    94          */
    81          */
    95         void AppendTitleL(const TDesC& aTitle);
    82         void AppendTitleL( const TDesC& aTitle );
    96 
    83 
    97         /**
    84         /**
    98          * Insert new title to the end of the title list.
    85          * Insert new title to the end of the title list.
    99          * @param aTitle The new title to add.
    86          * @param aTitle The new title to add.
   100          * @param aIndex The place to add the title.
    87          * @param aIndex The place to add the title.
   101          */
    88          */
   102         void InsertTitleL(const TDesC& aTitle, TInt aIndex);
    89         void InsertTitleL( const TDesC& aTitle, TInt aIndex );
   103 
    90 
   104         /**
    91         /**
   105          * Update title text.
    92          * Update title text.
   106          * @param aTitle The new title to add.
    93          * @param aTitle The new title to add.
   107          * @param aIndex The place to update the title.
    94          * @param aIndex The place to update the title.
   108          */
    95          */
   109         void UpdateTitleL(const TDesC& aTitle, TInt aIndex);
    96         void UpdateTitleL( const TDesC& aTitle, TInt aIndex );
   110 
    97 
   111         /**
    98         /**
   112          * Delete the title.
    99          * Delete the title.
   113          * @param aIndex The title index to delete.
   100          * @param aIndex The title index to delete.
   114          */
   101          */
   115         void DeleteTitleL(TInt aIndex);
   102         void DeleteTitleL( TInt aIndex );
   116 
   103 
   117     	/**
   104     	/**
   118     	 * Returns index of the currently selected title.
   105     	 * Returns index of the currently selected title.
   119     	 * @return The index of the current title.
   106     	 * @return The index of the current title.
   120     	 */
   107     	 */
   123     	/**
   110     	/**
   124     	 * Return the title of the given index.
   111     	 * Return the title of the given index.
   125     	 * @param aIndex The index to return the title.
   112     	 * @param aIndex The index to return the title.
   126     	 * @return The title of the given index.
   113     	 * @return The title of the given index.
   127     	 */
   114     	 */
   128         const TDesC& Title(TInt aIndex);
   115         const TDesC& Title( TInt aIndex );
   129 
       
   130     	/**
       
   131     	 * Set the separator image for all titles.
       
   132     	 * @param aIcon The separator image. This must be mif icon.
       
   133     	 * @return KErrNone if successful, KErrArgument if the icon is not mif.
       
   134     	 */
       
   135         TInt SetSeparatorImageL(CGulIcon* aIcon);
       
   136 
   116 
   137         /**
   117         /**
   138          * Delete all titles.
   118          * Delete all titles.
   139          */
   119          */
   140         void ClearTitles();
   120         void ClearTitles();
   141 
       
   142         /**
       
   143          * Append the SVG title to be shown.
       
   144          * @param aByteData The SVG data.
       
   145          */
       
   146         void AppendSvgTitleL(const TDesC8& aByteData);
       
   147 
       
   148         /**
       
   149          * Insert the SVG title to be shown.
       
   150          * @param aByteData The SVG data.
       
   151          */
       
   152         void InsertSvgTitleL(const TDesC8& aByteData, TInt aIndex);
       
   153 
   121 
   154         /**
   122         /**
   155          * Set callback interface.
   123          * Set callback interface.
   156          * @param aCallback The callback interface pointer.
   124          * @param aCallback The callback interface pointer.
   157          */
   125          */
   158         void SetCallbackInterfaceL(
   126         void SetCallbackInterfaceL(
   159             XnNewstickerInterface::MXnNewstickerCallbackInterface* aCallback);
   127             XnNewstickerInterface::MXnNewstickerCallbackInterface* aCallback );
   160 
   128 
   161         /**
   129         /**
   162          * Start showing the titles.
   130          * Start showing the titles.
   163          */
   131          */
   164         void StartL();
   132         void Start();
   165 
   133 
   166         /**
   134         /**
   167          * Stop showing the titles.
   135          * Stop showing the titles.
   168          */
   136          */
   169         void StopL();
   137         void Stop();
   170 
   138         
   171         /**
   139         /**
   172          * Show SVG next.
   140          * Stops alternate counter.
   173          */
   141          */
   174         void ShowSvgL();
   142         void StopAlternateCounter();
       
   143         
       
   144         /**
       
   145          * Resets and unenables narquee control.
       
   146          */
       
   147         void StopMarquee();
       
   148         
       
   149         /**
       
   150          * Starts alternate counter.
       
   151          */
       
   152         void StartAlternateCounter();
   175 
   153 
   176         /**
   154         /**
   177          * Callback which will be called by the CPeriodic.
   155          * Callback which will be called by the CPeriodic.
   178          * @param aPtr User defined pointer.
   156          * @param aPtr User defined pointer.
   179          * @return ETrue if the method should be called again.
   157          * @return ETrue if the method should be called again.
   180          */
   158          */
   181         static TInt PeriodicEventL(TAny * aPtr);
   159         static TInt PeriodicEventL( TAny * aPtr );
   182 
   160      
   183         /**
   161         void MakeVisible( TBool aVisible );
   184          * Draw background for the newsticker control area.
       
   185          * @param aRect The visivle area of newsticker component.
       
   186          * @param aGc Window graphics context.
       
   187          */
       
   188         void DrawBackgroundL(const TRect& aRect, CWindowGc& aGc) const;
       
   189 
       
   190         
       
   191         /**
       
   192         * Returns the bitmap context.
       
   193         * @return Bitmap context.
       
   194         */
       
   195         inline CBitmapContext* BufferGc() const { return iBufferGc; };
       
   196         
       
   197         
       
   198         /**
       
   199         * Returns the background bitmap
       
   200         * @return Background bitmap
       
   201         */
       
   202         inline const CFbsBitmap* BackgroundBitmap() const { return iBackgroundBitmap; };
       
   203 
       
   204         /**
       
   205         * Returns the state of the newsticker control.
       
   206         * @return Current state.
       
   207         */
       
   208         inline TState CurrentState() const { return iState; };
       
   209 
       
   210         /**
       
   211         * Returns the current scroll behaviour
       
   212         * @return current scroll behaviour
       
   213         */        
       
   214         inline TInt ScrollBehaviour() const { return iScrollBehaviour; };        
       
   215         
       
   216         /**
       
   217         * Reset periodic timer to set display time.
       
   218         */
       
   219         void SetTimerToDisplaytime();
       
   220         
       
   221         /**
       
   222         * Reset periodic timer to set scroll delay time.
       
   223         */
       
   224         void SetTimerToScrolltime();
       
   225         
   162         
   226     public: // from base classes
   163     public: // from base classes
   227 
   164 
   228         //  From MXnNewstickerCallbackInterface
   165         //  From MXnNewstickerCallbackInterface
   229         /**
   166         /**
   230          * Called when the title has been shown and is now offscreen.
   167          * Called when the title has been shown and is now offscreen.
   231          * @param aTitleIndex The title that has been completely shown.
   168          * @param aTitleIndex The title that has been completely shown.
   232          */
   169          */
   233         void TitleScrolled(TInt aTitleIndex);
   170         void TitleScrolled( TInt aTitleIndex );
   234 
   171 
   235         /**
   172         /**
   236         * See CCoeControl documentation
   173         * See CCoeControl documentation
   237         */    	
   174         */    	
   238         void SizeChanged();
   175         void SizeChanged();
   239 
   176 
   240         /**
   177         /**
   241         * See CCoeControl documentation
       
   242         */    	
       
   243         void HandlePointerEventL(const TPointerEvent& aPointerEvent);
       
   244 
       
   245         /**
       
   246         * See CCoeControl documentation
       
   247         */    	    	
       
   248         void FocusChanged(TDrawNow aDrawNow);
       
   249 
       
   250         /**
       
   251         * See CCoeControl documentation
       
   252         */
       
   253         TKeyResponse OfferKeyEventL(
       
   254                 const TKeyEvent& aKeyEvent, TEventCode aType);
       
   255 
       
   256         /**
       
   257         * See CXnControlAdapter documentation
   178         * See CXnControlAdapter documentation
   258         */    	
   179         */    	
   259     	void Draw(const TRect& aRect) const;
   180     	void Draw( const TRect& aRect ) const;
   260 
   181 
   261         /**
   182         /**
   262         * Enter power save mode. This is done when application goes to background or lights go off. 
   183         * Enter power save mode. This is done when application goes to background or lights go off. 
   263         * Derived classes should override this function and stop animations, timers etc. when the function is called.
   184         * Derived classes should override this function and stop animations, timers etc. when the function is called.
   264         */ 
   185         */ 
   265         void DoEnterPowerSaveModeL(TModeEvent aEvent);
   186         void DoEnterPowerSaveModeL( TModeEvent aEvent );
   266 
   187 
   267 	   	/**
   188 	   	/**
   268         * Exit power save mode. This is done when application comes to foreground or lights go on. 
   189         * Exit power save mode. This is done when application comes to foreground or lights go on. 
   269         * Derived classes should override this function and restart animations, timers etc. when the function is called.
   190         * Derived classes should override this function and restart animations, timers etc. when the function is called.
   270         */ 
   191         */ 
   271         void DoExitPowerSaveModeL(TModeEvent aEvent);
   192         void DoExitPowerSaveModeL( TModeEvent aEvent );
   272 
   193 
   273         /**
   194         /**
   274         * From CXnControlAdapter Handles the property changes.
   195         * From CXnControlAdapter Handles the property changes.
   275         * @since Series 60 3.1
   196         * @since Series 60 3.1
   276         * @return void.
   197         * @return void.
   277         */ 
   198         */ 
   278         void DoHandlePropertyChangeL(CXnProperty* aProperty = NULL);
   199         void DoHandlePropertyChangeL( CXnProperty* aProperty = NULL );
   279 
   200 
   280 	    /**
   201 	    /**
   281         * Skin change notification.
   202         * Skin change notification.
   282         * See CXnControlAdapter documentation
   203         * See CXnControlAdapter documentation
   283         */        
   204         */        
   284         void SkinChanged();
   205         void SkinChanged();
   285         
   206         
   286         void ReportNewstickerEventL(const TDesC8& aEventName);
   207         /**
   287         
   208         * Reports newsticker event
   288         /**
   209         * 
   289         * See CCoeControl documentation
   210         */   
   290         */
   211         void ReportNewstickerEvent( const TDesC8& aEventName );
   291         void DrawNow() const;
   212         
   292         
   213         /**
   293         /**
   214         * Draws text
   294         * If newsticker is not focusable, finds and draws focusable parent
   215         * Text drawing function is selected by scrolling behaviour
   295         */
   216         */
   296         TBool DrawFocusableParentL() const;
   217         void DrawText( const TDesC& aText, const TRect& aRect  );
       
   218         
       
   219         /**
       
   220         * ETrue if marquee control redrawing is needed. EFalse if truncated text is needed
       
   221         */
       
   222         TBool Redraw() { return iRedraw; }
       
   223 
   297 
   224 
   298     private:
   225     private:
   299 
   226 
   300     	CXnNewstickerAdapter(CXnControlAdapter* aParent, CXnNodePluginIf& aNode);
   227     	CXnNewstickerAdapter( CXnControlAdapter* aParent, CXnNodePluginIf& aNode );
   301 
   228 
   302     	void ConstructL();
   229     	void ConstructL( CXnControlAdapter* aParent );
   303     	
   230     	
   304     	/**
   231     	/**
   305     	* Sets text properties, such as color, font, etc.
   232     	* Sets text properties, such as color, font, etc.
   306     	*/
   233     	*/
   307     	void SetTextPropertiesL();	
   234     	void SetTextPropertiesL();	
   308 
   235 
   309     	/**
   236     	/**
   310     	* Sets newsticker timing properties.
   237     	* Sets newsticker timing properties.
   311     	*/
   238     	*/
   312         void SetNewstickerPropertiesL();
   239         void SetNewstickerPropertiesL();
   313 
   240         
   314     	/**
   241         /**
   315     	* Creates a new doublebuffer for newsticker.
   242          * From CoeControl,CountComponentControls.
   316     	*/        
   243          */
   317         void UpdateDoubleBufferL();
   244          TInt CountComponentControls() const;
   318 
   245 
   319     	/**
   246         /**
   320     	* Draws a reconstructed background for newsticker.
   247          * From CCoeControl,ComponentControl.
   321     	*/
   248          */
   322         void UpdateBackgroundL() const;
   249          CCoeControl* ComponentControl( TInt aIndex ) const;
   323 
   250         
   324     	/**
   251         /**
   325     	* Same as SizeChanged(), but this is an L function.
   252         * Callback function for marquee control
   326     	*/
   253         */    
   327         void SizeChangedL();
   254         static TInt RedrawCallback( TAny* aPtr );
   328 
   255         
   329     	/**
   256         /**
   330     	* Checks if feed can be started
   257         *  FScrolls alternative text. Function is called by periodic timer
   331     	*/       
   258         */    
   332         TBool CheckDisplayL( CXnNodePluginIf& aNode );
   259         void DoScroll();
   333 
   260         
   334         void RestartL();
   261         /**
       
   262         *  Draws text directly to screen if scrollins is not needed
       
   263         */  
       
   264         void DrawStaticText( CWindowGc& aGc, const TDesC& aText ) const;
       
   265         
       
   266         /**
       
   267         *  Draws scrolling text to screen via marquee control
       
   268         */ 
       
   269         TBool DrawMarqueeText( CWindowGc& aGc, const TDesC& aText ) const;               
       
   270         
   335     private:
   271     private:
   336 
       
   337         /**
       
   338         * The state of the newsticker control.
       
   339         */
       
   340         TState                      iState;
       
   341 
   272 
   342         /**
   273         /**
   343         * The timer to use for scrolling events.
   274         * The timer to use for scrolling events.
   344         * Own.
   275         * Own.
   345         */
   276         */
   354         /**
   285         /**
   355         * The control handling the text title showing
   286         * The control handling the text title showing
   356         * Own.
   287         * Own.
   357         */
   288         */
   358         CXnNewstickerControl*       iControl;
   289         CXnNewstickerControl*       iControl;
   359         
   290 	    
   360         /**
   291         /**
   361         * The control handling the svg title showing
   292          * The delay before first event
   362         * Own.
   293          */  
   363         */
   294 	    TInt                        iAlternateDelay;
   364         CXnNewstickerSvgControl*    iSvgControl;
       
   365 
       
   366         /**
       
   367          * Delay between loops in microseconds.
       
   368          */
       
   369 	    TInt                        iDelay;
       
   370 
       
   371         /**
       
   372          * The interval between ticks.
       
   373          */	    
       
   374 	    TInt                        iInterval;
       
   375         
   295         
   376         /**
   296         /**
   377          * The alternate interval between ticks.
   297          * The alternate interval between ticks.
   378          */	    
   298          */	    
   379 	    TInt                        iAlternateInterval;
   299 	    TInt                        iAlternateInterval;
   380 
   300 
   381         /**
   301         /**
   382          * The current interval between ticks.
       
   383          */	    
       
   384 	    TInt                        iCurrentInterval;
       
   385 
       
   386         /**
       
   387          * Amount of loops executed
       
   388          */	    
       
   389         TInt                        iLoops;
       
   390 
       
   391         /**
       
   392         * The animation time in microseconds.
       
   393         */
       
   394         TInt                        iAnimationTime;
       
   395 
       
   396         /**
       
   397         * UI node
   302         * UI node
   398         * Not own.
   303         * Not own.
   399         */
   304         */
   400         CXnNodePluginIf&            iNode;
   305         CXnNodePluginIf&            iNode;
   401 
   306 
   402         /**
   307         /**
   403         * Font for control.
   308         * Font for control.
   404         * Own.
   309         * Not own.
   405         */        
   310         */        
   406         CFont*                      iFont;
   311         CFont*                      iFont;
   407         
   312         
   408         /**
   313         /**
   409         * Whether the font needs to be released or not.
   314         * Whether the font needs to be released or not.
   410         */        
   315         */        
   411         TBool                       iReleaseFont;
   316         TInt                       iReleaseFont;
   412                 
       
   413         /**
       
   414         * Bitmap device. Used to draw on the drawing buffer
       
   415         * Own.
       
   416         */
       
   417     	CFbsBitmapDevice*           iBufferDevice;
       
   418 	
       
   419         /**
       
   420         * Drawing buffer
       
   421         * Own.
       
   422         */
       
   423     	CFbsBitmap*                 iDrawingBuffer;
       
   424     	
       
   425         /**
       
   426         * Bitmap Graphic Context. Used to draw on the drawing buffer
       
   427         * Own.
       
   428         */
       
   429         CBitmapContext*             iBufferGc;
       
   430         
       
   431         /**
       
   432         * Pointer to background bitmap.
       
   433         * Own.
       
   434         */
       
   435         mutable CFbsBitmap*         iBackgroundBitmap;
       
   436 
       
   437         /**
       
   438         * For the display property (content is either shown or not)
       
   439         */
       
   440         TBool                       iDisplay;
       
   441 
   317 
   442         /**
   318         /**
   443         * For keeping track of the current powersave mode state
   319         * For keeping track of the current powersave mode state
   444         */       
   320         */       
   445         TBool                       iPowerSaveMode;
   321         TBool                       iPowerSaveMode;
   446 
   322 
   447         /**
   323         /**
   448         * Current scroll behaviour
   324         * Current scroll behaviour
   449         */               
   325         */               
   450         TInt                        iScrollBehaviour;
   326         TScrollBehaviour            iScrollBehaviour;
   451         
   327         
   452         /**
   328         /**
   453          * Restart animation after title has been updated
   329          * Restart animation after title has been updated
   454          */
   330          */
   455         TBool                       iRestartAfterUpdate;
   331         TBool                       iRestartAfterUpdate;
       
   332         
       
   333         /**
       
   334         * marquee control for scrolling
       
   335 		* own
       
   336         */ 
       
   337        CAknMarqueeControl*         iMarqueeControl;
       
   338        
       
   339        /**
       
   340        * Current text color
       
   341        */ 
       
   342        TRgb                        iTextColor;
       
   343        
       
   344        /**
       
   345        * Current text alignment
       
   346        */ 
       
   347        TInt                        iTextAlignment;   
       
   348        
       
   349        /**
       
   350        * Current baseline
       
   351        */ 
       
   352        TInt                        iTextBaseline;
       
   353        
       
   354        /**
       
   355        * Current underlining behaviour
       
   356        */ 
       
   357        TFontUnderline              iUnderlining;       
       
   358        
       
   359        /**
       
   360        * Current strikethrough behaviour
       
   361        */ 
       
   362        TFontStrikethrough          iStrikethrough;
       
   363        
       
   364        /**
       
   365        * is scroll looping activated
       
   366        */ 
       
   367        TBool                    iScrollLooping;
       
   368        
       
   369        /**
       
   370        * is marquee control redraw needed
       
   371        */ 
       
   372        TBool                    iRedraw;
       
   373         
       
   374         
       
   375         
   456     };
   376     };
   457 
   377 
   458 #endif // XNNEWSTICKERADAPTER_H
   378 #endif // XNNEWSTICKERADAPTER_H
   459             
   379             
   460 // End of File
   380 // End of File