idlehomescreen/xmluirendering/renderingplugins/xnnewstickerfactory/inc/xnnewstickeradapter.h
changeset 0 f72a12da539e
child 2 08c6ee43b396
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2002-2006 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:  Wrapper class for Newsticker text label.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef _XNNEWSTICKERADAPTER_H
       
    20 #define _XNNEWSTICKERADAPTER_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include "xncontroladapter.h"
       
    24 #include "xnnewsticker.h"
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class CXnNodePluginIf;
       
    28 class CXnNewstickerControl;
       
    29 class CXnNewstickerSvgControl;
       
    30 
       
    31 // CONSTANTS
       
    32 // The default values for the newsticker control
       
    33 const TInt KXnNewstickerDelay = 1000000;   // start scrolling after a delay of 1 second
       
    34 const TInt KXnNewstickerInterval = 100000; // scroll 10 times in a second
       
    35 const TInt KXnNewstickerScrollAmount = 6;  // scroll 6 pixels at time
       
    36 const TInt KXnNewstickerLoops = 1;         // loop amount
       
    37 const TInt KNoDelay = 0;                   //  No delay to start the animation
       
    38 const TInt KAnimationTime = 6000000;       //  The animation lasts 6 seconds
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /**
       
    43 * @ingroup group_xnnewstickerfactory
       
    44 * 
       
    45 *  Newsticker adapter class implementation.
       
    46 *
       
    47 *  @lib xnnewstickerfactory.dll
       
    48 *  @since Series 60 3.2
       
    49 */
       
    50 class CXnNewstickerAdapter : public CXnControlAdapter,
       
    51             XnNewstickerInterface::MXnNewstickerCallbackInterface
       
    52     {
       
    53     public:
       
    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
       
    68             {
       
    69             EScroll,
       
    70             ESlide,
       
    71             EAlternate,
       
    72             EScrollAlternate
       
    73             };            
       
    74             
       
    75     public:
       
    76 
       
    77     	/**
       
    78     	* 2 phase construction.
       
    79         * @param aParent Parent control
       
    80         * @param aNode UI node
       
    81     	*/
       
    82     	static CXnNewstickerAdapter* NewL(CXnControlAdapter* aParent, CXnNodePluginIf& aNode);
       
    83 
       
    84     	/**
       
    85     	* Destructor.
       
    86     	*/
       
    87     	virtual ~CXnNewstickerAdapter();
       
    88 
       
    89     public: // New functions
       
    90 
       
    91         /**
       
    92          * Append new title to the end of the title list.
       
    93          * @param aTitle The new title to add.
       
    94          */
       
    95         void AppendTitleL(const TDesC& aTitle);
       
    96 
       
    97         /**
       
    98          * Insert new title to the end of the title list.
       
    99          * @param aTitle The new title to add.
       
   100          * @param aIndex The place to add the title.
       
   101          */
       
   102         void InsertTitleL(const TDesC& aTitle, TInt aIndex);
       
   103 
       
   104         /**
       
   105          * Update title text.
       
   106          * @param aTitle The new title to add.
       
   107          * @param aIndex The place to update the title.
       
   108          */
       
   109         void UpdateTitleL(const TDesC& aTitle, TInt aIndex);
       
   110 
       
   111         /**
       
   112          * Delete the title.
       
   113          * @param aIndex The title index to delete.
       
   114          */
       
   115         void DeleteTitleL(TInt aIndex);
       
   116 
       
   117     	/**
       
   118     	 * Returns index of the currently selected title.
       
   119     	 * @return The index of the current title.
       
   120     	 */
       
   121         TInt CurrentTitleIndex();
       
   122 
       
   123     	/**
       
   124     	 * Return the title of the given index.
       
   125     	 * @param aIndex The index to return the title.
       
   126     	 * @return The title of the given index.
       
   127     	 */
       
   128         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 
       
   137         /**
       
   138          * Delete all titles.
       
   139          */
       
   140         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 
       
   154         /**
       
   155          * Set callback interface.
       
   156          * @param aCallback The callback interface pointer.
       
   157          */
       
   158         void SetCallbackInterfaceL(
       
   159             XnNewstickerInterface::MXnNewstickerCallbackInterface* aCallback);
       
   160 
       
   161         /**
       
   162          * Start showing the titles.
       
   163          */
       
   164         void StartL();
       
   165 
       
   166         /**
       
   167          * Stop showing the titles.
       
   168          */
       
   169         void StopL();
       
   170 
       
   171         /**
       
   172          * Show SVG next.
       
   173          */
       
   174         void ShowSvgL();
       
   175 
       
   176         /**
       
   177          * Callback which will be called by the CPeriodic.
       
   178          * @param aPtr User defined pointer.
       
   179          * @return ETrue if the method should be called again.
       
   180          */
       
   181         static TInt PeriodicEventL(TAny * aPtr);
       
   182 
       
   183         /**
       
   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         
       
   226     public: // from base classes
       
   227 
       
   228         //  From MXnNewstickerCallbackInterface
       
   229         /**
       
   230          * Called when the title has been shown and is now offscreen.
       
   231          * @param aTitleIndex The title that has been completely shown.
       
   232          */
       
   233         void TitleScrolled(TInt aTitleIndex);
       
   234 
       
   235         /**
       
   236         * See CCoeControl documentation
       
   237         */    	
       
   238         void SizeChanged();
       
   239 
       
   240         /**
       
   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
       
   258         */    	
       
   259     	void Draw(const TRect& aRect) const;
       
   260 
       
   261         /**
       
   262         * 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.
       
   264         */ 
       
   265         void DoEnterPowerSaveModeL(TModeEvent aEvent);
       
   266 
       
   267 	   	/**
       
   268         * 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.
       
   270         */ 
       
   271         void DoExitPowerSaveModeL(TModeEvent aEvent);
       
   272 
       
   273         /**
       
   274         * From CXnControlAdapter Handles the property changes.
       
   275         * @since Series 60 3.1
       
   276         * @return void.
       
   277         */ 
       
   278         void DoHandlePropertyChangeL(CXnProperty* aProperty = NULL);
       
   279 
       
   280 	    /**
       
   281         * Skin change notification.
       
   282         * See CXnControlAdapter documentation
       
   283         */        
       
   284         void SkinChanged();
       
   285         
       
   286         void ReportNewstickerEventL(const TDesC8& aEventName);
       
   287         
       
   288         /**
       
   289         * See CCoeControl documentation
       
   290         */
       
   291         void DrawNow() const;
       
   292         
       
   293         /**
       
   294         * If newsticker is not focusable, finds and draws focusable parent
       
   295         */
       
   296         TBool DrawFocusableParentL() const;
       
   297 
       
   298     private:
       
   299 
       
   300     	CXnNewstickerAdapter(CXnControlAdapter* aParent, CXnNodePluginIf& aNode);
       
   301 
       
   302     	void ConstructL();
       
   303     	
       
   304     	/**
       
   305     	* Sets text properties, such as color, font, etc.
       
   306     	*/
       
   307     	void SetTextPropertiesL();	
       
   308 
       
   309     	/**
       
   310     	* Sets newsticker timing properties.
       
   311     	*/
       
   312         void SetNewstickerPropertiesL();
       
   313 
       
   314     	/**
       
   315     	* Creates a new doublebuffer for newsticker.
       
   316     	*/        
       
   317         void UpdateDoubleBufferL();
       
   318 
       
   319     	/**
       
   320     	* Draws a reconstructed background for newsticker.
       
   321     	*/
       
   322         void UpdateBackgroundL() const;
       
   323 
       
   324     	/**
       
   325     	* Same as SizeChanged(), but this is an L function.
       
   326     	*/
       
   327         void SizeChangedL();
       
   328 
       
   329     	/**
       
   330     	* Checks if feed can be started
       
   331     	*/       
       
   332         TBool CheckDisplayL( CXnNodePluginIf& aNode );
       
   333 
       
   334         void RestartL();
       
   335     private:
       
   336 
       
   337         /**
       
   338         * The state of the newsticker control.
       
   339         */
       
   340         TState                      iState;
       
   341 
       
   342         /**
       
   343         * The timer to use for scrolling events.
       
   344         * Own.
       
   345         */
       
   346 	    CPeriodic*                  iPeriodicTimer;
       
   347 
       
   348         /**
       
   349         * The callback interface which is used when a title has been shown.
       
   350         * Not own.
       
   351         */
       
   352         XnNewstickerInterface::MXnNewstickerCallbackInterface*  iCallback;
       
   353 
       
   354         /**
       
   355         * The control handling the text title showing
       
   356         * Own.
       
   357         */
       
   358         CXnNewstickerControl*       iControl;
       
   359         
       
   360         /**
       
   361         * The control handling the svg title showing
       
   362         * Own.
       
   363         */
       
   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         
       
   376         /**
       
   377          * The alternate interval between ticks.
       
   378          */	    
       
   379 	    TInt                        iAlternateInterval;
       
   380 
       
   381         /**
       
   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
       
   398         * Not own.
       
   399         */
       
   400         CXnNodePluginIf&            iNode;
       
   401 
       
   402         /**
       
   403         * Font for control.
       
   404         * Own.
       
   405         */        
       
   406         CFont*                      iFont;
       
   407         
       
   408         /**
       
   409         * Whether the font needs to be released or not.
       
   410         */        
       
   411         TBool                       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 
       
   442         /**
       
   443         * For keeping track of the current powersave mode state
       
   444         */       
       
   445         TBool                       iPowerSaveMode;
       
   446 
       
   447         /**
       
   448         * Current scroll behaviour
       
   449         */               
       
   450         TInt                        iScrollBehaviour;
       
   451         
       
   452         /**
       
   453          * Restart animation after title has been updated
       
   454          */
       
   455         TBool                       iRestartAfterUpdate;
       
   456     };
       
   457 
       
   458 #endif // XNNEWSTICKERADAPTER_H
       
   459             
       
   460 // End of File