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