imstutils/imconversationview/imcvuiapp/src/cimcvnewmsgfadecontrol.h
changeset 15 81eeb8c83ce5
parent 0 5e5d6b214f4f
equal deleted inserted replaced
0:5e5d6b214f4f 15:81eeb8c83ce5
     1 /*
       
     2 * Copyright (c) 2008-2009 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:  This class encapsulates logic that is needed for text fading
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CIMCVNewMsgFadeControl_H
       
    21 #define CIMCVNewMsgFadeControl_H
       
    22 
       
    23 
       
    24 //  INCLUDES
       
    25 #include <aknview.h>
       
    26 #include <AknUtils.h>
       
    27 
       
    28 // CONSTANTS
       
    29 
       
    30 // MACROS
       
    31 
       
    32 // DATA TYPES
       
    33 
       
    34 // FUNCTION PROTOTYPES
       
    35 
       
    36 // FORWARD DECLARATIONS
       
    37 class MAknsControlContext;
       
    38 class MIMCVAppLayoutInfo;
       
    39 class MIMCVNewMsgFadeControlObserver;
       
    40 
       
    41 // CLASS DECLARATION
       
    42 
       
    43 /**
       
    44 *  This class declares text fader component
       
    45 *
       
    46 *  @lib imcvuiapp.exe
       
    47 *  @since 5.0
       
    48 */
       
    49 class CIMCVNewMsgFadeControl : public CCoeControl,
       
    50 					   public MCoeControlObserver
       
    51 	{
       
    52 	public:
       
    53 		
       
    54 		/*
       
    55 		*	Used to control fading timer
       
    56 		*/
       
    57 		enum TTimerStates
       
    58 			{
       
    59 			ETimerStopped = 0,
       
    60 			ETimerActivated
       
    61 			};
       
    62 
       
    63     public: // Constructors and destructor
       
    64         
       
    65         /**
       
    66         * Two-phased constructor.
       
    67 		* @param aRect TRect
       
    68 		* @return instance of class
       
    69         */
       
    70         static CIMCVNewMsgFadeControl* NewL( const TRect& aRect );
       
    71 
       
    72 		/**
       
    73 		 * Two-phased costructor. Leaves object into stack
       
    74 		 * @param aRect TRect
       
    75 		 * @return instance of class
       
    76 		 */
       
    77 		static CIMCVNewMsgFadeControl* NewLC( const TRect& aRect );
       
    78         
       
    79 
       
    80         /**
       
    81         * Destructor.
       
    82         */
       
    83         ~CIMCVNewMsgFadeControl();
       
    84 	
       
    85 	public: //New Functions
       
    86 
       
    87 		/**
       
    88 		 * Starts fading text
       
    89 		 * @since 5.0
       
    90 		 */
       
    91 		void Start();
       
    92 
       
    93 		/**
       
    94 		 * Stops fading
       
    95 		 * @since 5.0
       
    96 		 */
       
    97 		void Stop();
       
    98 
       
    99 		/**
       
   100 		 * Registers observer
       
   101 		 * @since 5.0
       
   102 		 * @param aObserver Observer instance
       
   103 		 */
       
   104 		void AddObserver( MIMCVNewMsgFadeControlObserver* aObserver );
       
   105 
       
   106 		/**
       
   107 		 * Sets the fade message
       
   108 		 * @since 5.0
       
   109 		 * @param aMsg Descriptor containing message
       
   110 		 */
       
   111 		void SetMessage( TDesC& aMsg );
       
   112 
       
   113 		/**
       
   114 		 * Returns message
       
   115 		 * @since 5.0
       
   116 		 * @return descriptor that contains message
       
   117 		 */
       
   118 		TPtrC Message() const;
       
   119 
       
   120 		/**
       
   121 		 * Tells if fading is active
       
   122 		 * @since 5.0
       
   123 		 * @return ETrue if active else EFalse
       
   124 		 */
       
   125 		TBool IsActive();
       
   126 
       
   127 		/**
       
   128 		 * Resets the faded string
       
   129 		 * @since 5.0
       
   130 		 */
       
   131 		void Reset();
       
   132 		
       
   133 		/**
       
   134 		 * Does the actual changing of text color
       
   135 		 * @since 5.0
       
   136 		 * @param aAnyPtr pointer of this object
       
   137 		 * @return ETrue if this should be called again
       
   138 		 */
       
   139 		static TInt FadeText( TAny* aAnyPtr );
       
   140 
       
   141 		/**
       
   142 		 * Starts the timer
       
   143 		 * @param aDelayInternal delay
       
   144 		 * @since 5.0
       
   145 		 */
       
   146 		void StartTicker( const TTimeIntervalMicroSeconds32 aDelayInternal );
       
   147 
       
   148 		/**
       
   149 		 * Stops the timer
       
   150 		 * @since 5.0
       
   151 		 */
       
   152 		void StopTicker();
       
   153 		
       
   154 		/**
       
   155 		 * Reports that this CoeControl has changed
       
   156 		 * @since 5.0
       
   157 		 */
       
   158 		void ReportChange();
       
   159 
       
   160     private: // Functions from base classes
       
   161 
       
   162 	   /**
       
   163         * From CCoeControl
       
   164 		* @see CCoeControl
       
   165         */
       
   166         void SizeChanged();
       
   167 
       
   168        /**
       
   169         * From CCoeControl
       
   170 		* @see CCoeControl
       
   171         */
       
   172         TInt CountComponentControls() const;
       
   173 
       
   174        /**
       
   175         * From CCoeControl
       
   176 		* @see CCoeControl
       
   177         */
       
   178         CCoeControl* ComponentControl(TInt aIndex) const;
       
   179 
       
   180        /**
       
   181         * From CCoeControl
       
   182 		* @see CCoeControl
       
   183         */
       
   184         void Draw(const TRect& aRect) const;
       
   185 
       
   186        /**
       
   187         * From CCoeControl
       
   188 		* @see CCoeControl
       
   189         */
       
   190         void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
       
   191 
       
   192 	
       
   193 	private:
       
   194 
       
   195         /**
       
   196         * C++ default constructor.
       
   197         */
       
   198         CIMCVNewMsgFadeControl();
       
   199 
       
   200         /**
       
   201         * By default Symbian 2nd phase constructor is private.
       
   202         * @param aRect the rect of this component
       
   203         */
       
   204         void ConstructL( const TRect& aRect );
       
   205 
       
   206 		/*
       
   207 		* Error handling method
       
   208 		* @param aError Error id
       
   209 		*/
       
   210 		void HandleError( TInt aError );
       
   211 
       
   212         /**
       
   213         * Updates clipped text so that it fits to the current
       
   214         * the navi pane
       
   215         * @return None
       
   216         */
       
   217         void UpdateClippedMessage();
       
   218 
       
   219 
       
   220     private: //data
       
   221         
       
   222 		/*
       
   223 		*	Periodic timer is used to drive fade control. Owns
       
   224 		*/
       
   225        	CPeriodic* iTimer;
       
   226 
       
   227 		/*
       
   228 		*	Index to color array.
       
   229 		*/
       
   230 		TInt iColorIndex;
       
   231 		
       
   232 		/*
       
   233 		*	Timer interval.
       
   234 		*/
       
   235 		TInt iTimerTick;
       
   236 
       
   237 		/*
       
   238 		*	Font that is used
       
   239 		*/
       
   240 		const CFont* iFadeFont;
       
   241 		//View rectangle
       
   242 		TRect iViewRect;
       
   243 		 
       
   244 		//Observer array
       
   245 		CArrayPtrSeg<MIMCVNewMsgFadeControlObserver>* iObserverArray;
       
   246 		//Layouts for texts
       
   247 		RArray<TAknLayoutText> iTextLayouts;
       
   248 
       
   249 		TAknLayoutRect iNavipaneRect;
       
   250 
       
   251 		MAknsControlContext* iBgContext;
       
   252 
       
   253 		/*
       
   254 		*	Message to fade
       
   255 		*/
       
   256 		HBufC* iIMessage;
       
   257 
       
   258 		/*
       
   259 		*	Owned. Message which will fit the screen.
       
   260 		*/
       
   261 		HBufC* iClippedMessage;
       
   262 
       
   263 		/*
       
   264 		*	State of timer
       
   265 		*/
       
   266 		TTimerStates iTimerState;
       
   267 
       
   268 		//does not own
       
   269 		MIMCVAppLayoutInfo* iLayoutInfo;
       
   270 	};
       
   271 
       
   272 #endif  // CIMCVNewMsgFadeControl_H