uifw/ganes/inc/HgMarquee.h
changeset 47 2f0c06423c72
parent 46 0e1e0022bd03
child 53 3c67ea82fafc
equal deleted inserted replaced
46:0e1e0022bd03 47:2f0c06423c72
     1 /*
       
     2 * Copyright (c) 2004 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:       Text scrolling functionality.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __HGMARQUEE_H__
       
    20 #define __HGMARQUEE_H__
       
    21 
       
    22 #include <coecntrl.h>
       
    23 #include <coemain.h>
       
    24 #include <babitflags.h>
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class TAknTextComponentLayout;
       
    28 class TAknLayoutText;
       
    29 
       
    30 
       
    31 /**
       
    32 * Marquee control for AVKON
       
    33 *
       
    34 */
       
    35 NONSHARABLE_CLASS(CHgMarquee) : public CBase
       
    36     {
       
    37     public:
       
    38 	
       
    39         /**
       
    40         * Two-phased constructor.
       
    41         * @param aLoops Max number of loops to be executed
       
    42         * @param aScrollAmount The amount of pixels scrolled per iteration
       
    43         * @param aScrollDelay The interval between iterations
       
    44         */
       
    45         static CHgMarquee* NewL(const TInt aLoops = 1, 
       
    46                         const TInt aScrollAmount = 6, const TInt aScrollDelay = 1000000);
       
    47 
       
    48         /**
       
    49         * Two-phased constructor.
       
    50         * @param aLoops Max number of loops to be executed
       
    51         * @param aScrollAmount The amount of pixels scrolled per iteration
       
    52         * @param aScrollDelay The interval between iterations
       
    53         */
       
    54         static CHgMarquee* NewLC(const TInt aLoops = 1, 
       
    55                         const TInt aScrollAmount = 6, const TInt aScrollDelay = 1000000);
       
    56         
       
    57         /** 
       
    58         * set redraw event callback
       
    59         *
       
    60         */
       
    61         void SetRedrawCallBack( TCallBack& aRedrawEventCallback );
       
    62 
       
    63         /** 
       
    64         * Draws text in the current position. 
       
    65         * After the marquee object is created calling this should be enough.
       
    66         * @since S60 3.1
       
    67         * @param aGc Graphics context.
       
    68         * @param aRect Parent rectangle for the text layout.
       
    69         * @param aTextLayout Text layout that is used to draw the text.
       
    70         * @param aText Text to marquee.
       
    71         * @param aFont Font used in drawing. If this is NULL then the font is
       
    72         * taken from the aTextLayout.
       
    73         * @param aColor Color of the text        
       
    74         * @return ETrue = All the loops have been executed, EFalse = There are loops to be executed.
       
    75         */
       
    76         TBool DrawText( CWindowGc& aGc,
       
    77                                  const TRect& aRect,
       
    78                                  const TAknTextComponentLayout& aTextLayout,
       
    79                                  const TDesC& aText,
       
    80                                  const TRgb& aColor );
       
    81 
       
    82     	/**
       
    83     	* Enable or disable logical to visual reordering in text drawing.
       
    84         * By default, it is enabled. This has any effect only when bidirectional text
       
    85         * is rendered.
       
    86         *
       
    87         * If the text is converted to visual order prior to passing it to DrawText methods
       
    88         * of this class, then the conversion should be disabled by calling this method.
       
    89         *
       
    90     	* @since 3.1
       
    91     	* @param aUseConversion Enable or disable conversion.
       
    92     	*/
       
    93 	    void UseLogicalToVisualConversion( TBool aUseConversion );
       
    94        
       
    95         /** 
       
    96         * Starts scrolling the text.
       
    97         *
       
    98         */
       
    99         void Start();
       
   100 
       
   101         /** 
       
   102         * Stops scrolling the text.
       
   103         *
       
   104         */
       
   105         void Stop();
       
   106 
       
   107         /** 
       
   108         * Resets the animation data.
       
   109         * 
       
   110         */
       
   111         void Reset();
       
   112 	
       
   113 	    /** 
       
   114         * Is marquee on?
       
   115         *
       
   116         */
       
   117     #ifdef __WINS__
       
   118         const TBool IsMarqueeOn();
       
   119     #else
       
   120     	TBool IsMarqueeOn();
       
   121     #endif // __WINS__
       
   122         
       
   123         /** 
       
   124         * Sets the amount of pixels the text moves per animation loop
       
   125         *
       
   126         */
       
   127 	    void SetSpeedInPixels(TInt aSpeed);
       
   128 	    
       
   129         /** 
       
   130         * Sets the delay between loops.
       
   131         *
       
   132         */
       
   133         void SetDelay(TInt aDelay); 
       
   134         
       
   135         /** 
       
   136         * Sets the animation interval (=frames/second)
       
   137         *
       
   138         */
       
   139 	    void SetInterval(TInt aInterval);
       
   140         
       
   141         /** 
       
   142         * Sets the maximum number of loops to be executed.
       
   143         *
       
   144         */
       
   145         void SetLoops(TInt aLoops);    
       
   146         
       
   147         /** 
       
   148         * Enables / disables marquee feature but does NOT start it yet.
       
   149         * 
       
   150         */
       
   151         void EnableMarquee(TBool aEnable); // ETrue = ON, EFalse = OFF
       
   152 
       
   153         /** 
       
   154         * Destructor
       
   155         *
       
   156         */
       
   157         virtual ~CHgMarquee();
       
   158 
       
   159 
       
   160         // from CCoeControl
       
   161     protected:
       
   162 
       
   163     private:
       
   164     
       
   165     enum TMarqueeFlags
       
   166         {
       
   167         // Is marquee enabled or not
       
   168         EFlagIsOn,
       
   169         // RTL when the first directional character is LTR character
       
   170         EFlagIsWestern,
       
   171         // If true, there needs to be a delay before the scrolling starts
       
   172         EFlagIsBeginningOfLoop,
       
   173         // Is conversion needed
       
   174         EFlagUseVisualToLogicalConversion,
       
   175         // In case of two-lined lists etc, this flag is turned on
       
   176         // when the text has been scrolled all the way to the left/right.
       
   177         EFlagIsWaitingForCallBack
       
   178         };
       
   179         
       
   180         /** 
       
   181         * Default constructor
       
   182         *
       
   183         */
       
   184         CHgMarquee(const TInt aLoops, const TInt aScrollAmount, const TInt aScrollDelay);
       
   185 
       
   186         /**
       
   187         * By default Symbian 2nd phase constructor is private.
       
   188         */
       
   189         void ConstructL();
       
   190 
       
   191 	    /**
       
   192         * advance text and issue a callback to parent
       
   193         */
       
   194         void DoScroll();
       
   195 
       
   196 	    /**
       
   197         * static callback for periodic timer
       
   198         */
       
   199         static TInt ScrollEvent(TAny * aPtr);
       
   200 
       
   201         void DrawWestern( CWindowGc& aGc,
       
   202                                  const TRect& aRect,
       
   203                                  const TRect& aMarqueeRect,
       
   204                                  const TAknTextComponentLayout& aTextLayout,
       
   205                                  TAknLayoutText aLayout,
       
   206                                  const TDesC& aText,
       
   207                                  TInt aTextWidth,
       
   208                                  const TRgb& aColor );
       
   209 
       
   210         void DrawNonWestern( CWindowGc& aGc,
       
   211                                  const TRect& aRect,
       
   212                                  const TRect& aMarqueeRect,
       
   213                                  const TAknTextComponentLayout& aTextLayout,
       
   214                                  TAknLayoutText aLayout,
       
   215                                  const TDesC& aText,
       
   216                                  TInt aTextWidth,
       
   217                                  const TRgb& aColor );
       
   218 
       
   219 
       
   220 private:    // Data
       
   221     
       
   222     CPeriodic* iPeriodicTimer;        // creates scrolling events
       
   223     TInt       iDelta;                // The difference between the old and new position in pixels
       
   224     TInt       iDelay;                // Delay between loops in microseconds
       
   225     TInt       iSpeed;                // Amount of pixels the text moves in a frame
       
   226     TInt       iInterval;             // The interval between frame updates (= "frames/second")
       
   227     TCallBack  iCallBack;             // Callback to parent
       
   228     TInt       iLoops;                // Amount of loops executed
       
   229     TInt       iMaxLoops;             // Amount of loops *to be executed*
       
   230     TBitFlags  iFlags;
       
   231     TBool      iLastCharacter;        // It is ETrue if last character has appeared, otherwise.
       
   232     };
       
   233 
       
   234 #endif // __HGMARQUEE_H__