47 * @param aScrollAmount The amount of pixels scrolled per iteration |
46 * @param aScrollAmount The amount of pixels scrolled per iteration |
48 * @param aScrollDelay The interval between iterations |
47 * @param aScrollDelay The interval between iterations |
49 * @param aStartDelay The delay before the animation starts |
48 * @param aStartDelay The delay before the animation starts |
50 * @return Pointer to this. |
49 * @return Pointer to this. |
51 */ |
50 */ |
52 static CXnNewstickerControl* NewL(CXnNewstickerAdapter* aAdapter); |
51 static CXnNewstickerControl* NewL( CXnNewstickerAdapter* aAdapter ); |
53 |
|
54 /** |
|
55 * Sets newsticker scroll amount. |
|
56 * @param aScrollAmount A scroll amount. |
|
57 * @return void |
|
58 */ |
|
59 void SetScrollAmount(TInt aScrollAmount); |
|
60 |
|
61 /** |
|
62 * Sets the rect of the visible area. |
|
63 * @param aContentRect The visible rect. |
|
64 * @return void |
|
65 */ |
|
66 void SetNewstickerRect(TRect& aContentRect); |
|
67 |
|
68 /** |
|
69 * Checks whether a western layout is used. |
|
70 * @return Returns true if wesern layout is in use. |
|
71 */ |
|
72 TBool IsWestern(); |
|
73 |
52 |
74 // Routed from MXnNewstickerInterface. |
53 // Routed from MXnNewstickerInterface. |
75 |
54 |
76 /** |
55 /** |
77 * Append new title to the end of the title list. |
56 * Append new title to the end of the title list. |
78 * @param aTitle The new title to add. |
57 * @param aTitle The new title to add. |
79 */ |
58 */ |
80 void AppendTitleL(const TDesC& aTitle); |
59 void AppendTitleL( const TDesC& aTitle ); |
81 |
60 |
82 /** |
61 /** |
83 * Insert new title to the end of the title list. |
62 * Insert new title to the end of the title list. |
84 * @param aTitle The new title to add. |
63 * @param aTitle The new title to add. |
85 * @param aIndex The place to add the title. |
64 * @param aIndex The place to add the title. |
86 */ |
65 */ |
87 void InsertTitleL(const TDesC& aTitle, TInt aIndex); |
66 void InsertTitleL( const TDesC& aTitle, TInt aIndex ); |
88 |
67 |
89 /** |
68 /** |
90 * Update title in the title list. |
69 * Update title in the title list. |
91 * @param aTitle The new title to add. |
70 * @param aTitle The new title to add. |
92 * @param aIndex The place to add the title. |
71 * @param aIndex The place to add the title. |
93 */ |
72 */ |
94 void UpdateTitleL(const TDesC& aTitle, TInt aIndex); |
73 void UpdateTitleL( const TDesC& aTitle, TInt aIndex ); |
95 |
74 |
96 /** |
75 /** |
97 * Delete the title. |
76 * Delete the title. |
98 * @param aIndex The title index to delete. |
77 * @param aIndex The title index to delete. |
99 */ |
78 */ |
100 void DeleteTitleL(TInt aIndex); |
79 void DeleteTitleL( TInt aIndex ); |
101 |
80 |
102 /** |
81 /** |
103 * Returns index of the currently selected title. |
82 * Returns index of the currently selected title. |
104 * @return The index of the current title. |
83 * @return The index of the current title. |
105 */ |
84 */ |
106 TInt CurrentTitleIndex(); |
85 TInt CurrentTitleIndex() const; |
107 |
86 |
108 /** |
87 /** |
109 * Return the title of the given index. |
88 * Return the title of the given index. |
110 * @param aIndex The index to return the title. |
89 * @param aIndex The index to return the title. |
111 * @return The title of the given index. |
90 * @return The title of the given index. |
112 */ |
91 */ |
113 const TDesC& Title(TInt aIndex); |
92 const TDesC& Title(TInt aIndex) const; |
114 |
|
115 /** |
|
116 * Set the separator image for all titles. |
|
117 * @param aIcon The separator image. This must be mif icon. |
|
118 * @return KErrNone if successful, KErrArgument if the icon is not mif. |
|
119 */ |
|
120 TInt SetSeparatorImageL(CGulIcon* aIcon); |
|
121 |
93 |
122 /** |
94 /** |
123 * Delete all titles. |
95 * Delete all titles. |
124 */ |
96 */ |
125 void ClearTitles(); |
97 void ClearTitles(); |
126 |
98 |
127 /** |
99 /** |
128 * Append the SVG title to be shown. |
|
129 * @param aByteData The SVG data. |
|
130 */ |
|
131 void AppendSvgTitleL(const TDesC8& aByteData); |
|
132 |
|
133 /** |
|
134 * Insert the SVG title to be shown. |
|
135 * @param aByteData The SVG data. |
|
136 */ |
|
137 void InsertSvgTitleL(const TDesC8& aByteData, TInt aIndex); |
|
138 |
|
139 /** |
|
140 * Return the current svg title. |
|
141 * @return The current svg title. |
|
142 */ |
|
143 const TDesC8& CurrentSvgTitle(); |
|
144 |
|
145 /** |
|
146 * Return the number of titles in the list. |
100 * Return the number of titles in the list. |
147 * @return The number of titles in the list. |
101 * @return The number of titles in the list. |
148 */ |
102 */ |
149 TInt TitleCount() const; |
103 TInt TitleCount() const; |
150 |
|
151 /** |
|
152 * Move to the next title. |
|
153 */ |
|
154 void MoveToNextL(); |
|
155 |
|
156 /** |
|
157 * Move to the previous title. |
|
158 */ |
|
159 void MoveToPrevL(); |
|
160 |
|
161 /** |
|
162 * Move to first title |
|
163 */ |
|
164 void MoveToFirstL(); |
|
165 |
|
166 /** |
|
167 * Move to last title |
|
168 */ |
|
169 void MoveToLastL(); |
|
170 |
|
171 /** |
|
172 * Move to the previous title. |
|
173 */ |
|
174 void MoveToCurrent(); |
|
175 |
|
176 /** |
|
177 * Sets font for bitmap graphic context. |
|
178 * @param aFont Font family. |
|
179 */ |
|
180 void SetFont(CFont* aFont); |
|
181 |
|
182 /** |
|
183 * Sets text color for bitmap graphic context. |
|
184 * @param aColor Color in RGB format. |
|
185 */ |
|
186 void SetTextColor(TRgb aColor); |
|
187 |
|
188 /** |
|
189 * Sets the underline style for all subsequently drawn text. |
|
190 * @param aStyle Underline style, which can be either on of off. |
|
191 */ |
|
192 void SetTextUnderlineStyle(TFontUnderline aStyle); |
|
193 |
|
194 /** |
|
195 * Sets the strikethrough style for all subsequently drawn text. |
|
196 * @param aStyle Strikethrough style, which can be either on of off. |
|
197 */ |
|
198 void SetTextStrikethroughStyle(TFontStrikethrough aStyle); |
|
199 |
104 |
200 /** |
105 /** |
201 * Destructor |
106 * Destructor |
202 */ |
107 */ |
203 virtual ~CXnNewstickerControl(); |
108 virtual ~CXnNewstickerControl(); |
204 |
109 |
205 /** |
|
206 * Creates background bitmap |
|
207 */ |
|
208 void CreateBufferBitmapL(); |
|
209 |
|
210 /** |
110 /** |
211 * Advance text and issue a callback to parent |
111 * Selects title to be shown |
212 */ |
112 */ |
213 void DoScrollL(); |
113 const TDesC& SelectTitle(); |
214 |
|
215 /** |
|
216 * Blit visible stuff to d-buffer. Drawing direction is left-to-right. |
|
217 */ |
|
218 void PrepareToDrawLtrL(); |
|
219 |
|
220 /** |
|
221 * Blit visible stuff to d-buffer. Drawing direction is right-to-left. |
|
222 */ |
|
223 void PrepareToDrawRtlL(); |
|
224 |
|
225 /** |
|
226 * Blit double buffer to gc. |
|
227 */ |
|
228 void Draw(); |
|
229 |
114 |
230 /** |
115 /** |
231 * Blit double buffer to gc. Draws only the last title truncated. |
116 * Sets the current title to default ( last one ) or move to next one |
232 */ |
117 */ |
233 void DrawStatic(); |
118 TBool SetCurrentTitle( TBool aSetDefault = EFalse ); |
234 |
119 |
235 /** |
|
236 * Sets iFirstdrawingOffset as a start position. |
|
237 */ |
|
238 void SetBeginningState(); |
|
239 |
|
240 /** |
|
241 * Return the font |
|
242 * @return font |
|
243 */ |
|
244 inline const CFont* Font() { return iFont; }; |
|
245 |
|
246 /** |
|
247 * Return the text color. |
|
248 * @return Text color. |
|
249 */ |
|
250 inline const TRgb TextColor() { return iTextColor; }; |
|
251 |
|
252 /** |
|
253 * Return font underline flag. |
|
254 * @return Font underline flag. |
|
255 */ |
|
256 inline const TFontUnderline TextUnderlineStyle() { return iUnderlining; }; |
|
257 |
|
258 /** |
|
259 * Return the font strikethrough flag. |
|
260 * @return Font strikethrough flag. |
|
261 */ |
|
262 inline const TFontStrikethrough TextStrikethroughStyle() { return iStrikethrough; }; |
|
263 |
|
264 /** |
|
265 * Set scroll looping property |
|
266 */ |
|
267 void SetScrollLooping( TBool aLoop ); |
|
268 |
|
269 /** |
|
270 * Return scroll looping property |
|
271 * @return TBool |
|
272 */ |
|
273 TBool ScrollLooping(); |
|
274 |
|
275 /** |
|
276 * @return ETrue if all the text fits on the drawing rect. In that case no scrolling and |
|
277 * text alignment should be used |
|
278 */ |
|
279 TBool TextFitInNewstickerRect(); |
|
280 |
|
281 /** |
|
282 * @param aAlignment ( ELayoutAlignCenter, ELayoutAlignLeft or ELayoutAlignRight ) |
|
283 * ELayoutAlignLeft default in western, ELayoutAlignRight in AH. |
|
284 */ |
|
285 void SetTextAlignment(TInt aAlignment); |
|
286 |
|
287 /** |
|
288 * @return ETrue if the current text fits on |
|
289 * the drawing rect (when scrolling behaviour is scroll-alternate) |
|
290 * EFalse otherwise. |
|
291 * If this is ETrue then no scrolling and text alignment should be used |
|
292 */ |
|
293 TBool CalculateCurrentTextFitInNewstickerRect(); |
|
294 |
120 |
295 private: |
121 private: |
296 |
122 |
297 CXnNewstickerControl(CXnNewstickerAdapter* aAdapter); |
123 CXnNewstickerControl(CXnNewstickerAdapter* aAdapter); |
298 |
124 |
299 void ConstructL(); |
125 void ConstructL(); |
300 |
|
301 /** |
|
302 * Calculate the indexes and offset after new title has been inserted. |
|
303 * @param aIndex The inserted index. |
|
304 */ |
|
305 void CountIndexAfterInsertL(TInt aIndex); |
|
306 |
126 |
307 /** |
|
308 * @return ETrue if all the text fits on the drawing rect (when scrolling behaviour is slide) |
|
309 * EFalse otherwise. |
|
310 * If this is ETrue then no scrolling and text alignment should be used |
|
311 */ |
|
312 TBool CalculateTextFitInNewstickerRect(); |
|
313 |
|
314 /** |
|
315 * @return text alignment from properties if text fits to the rect or scroll behaviour is alternate. |
|
316 * otherwise returns default alignment value (left in western, right in AH). |
|
317 */ |
|
318 CGraphicsContext::TTextAlign TextAlignment(); |
|
319 /** |
127 /** |
320 * Get the index of the next title that has content |
128 * Get the index of the next title that has content |
321 * |
129 * |
322 * @param aStartSearch The index where to start search |
130 * @param aStartSearch The index where to start search |
323 * @param aBackwards Search backwards |
131 * @param aBackwards Search backwards |
324 * |
132 * |
325 * @return The next index that has content or -1 if nothing was found |
133 * @return The next index that has content or -1 if nothing was found |
326 */ |
134 */ |
327 TInt GetNextTitleWithContent( TInt aStartSearch, TBool aBackwards = EFalse ); |
135 TInt GetNextTitleWithContent( TInt aStartSearch, TBool aBackwards = EFalse ) const; |
328 |
136 |
329 TBool IsVisibleTitles(); |
137 /** |
|
138 * Checks is there any visible titles in array |
|
139 */ |
|
140 TBool IsVisibleTitles() const; |
330 |
141 |
331 private: // Data |
142 private: // Data |
332 |
143 |
333 /** |
144 /** |
334 * Helper class containing the title text and its length in pixels. |
145 * The array for title texts |
335 * |
146 * owned |
336 * @lib xnnewstickerfactory.dll |
|
337 * @since Series 60 3.2 |
|
338 */ |
147 */ |
339 class CTitleData : public CBase |
148 RPointerArray<HBufC> iTitleTexts; |
340 { |
|
341 public: |
|
342 |
|
343 /** |
|
344 * Destructor |
|
345 */ |
|
346 virtual ~CTitleData(); |
|
347 |
|
348 /** |
|
349 * Two-phased constructor. |
|
350 * @param aTitle The title text. |
|
351 * @param aLenghtInPixels The lenght of title text in pixels. |
|
352 * @return Pointer to this. |
|
353 */ |
|
354 static CTitleData* NewL(const TDesC& aTitle, TInt aLenghtInPixels); |
|
355 |
|
356 /** |
|
357 * Two-phased constructor. |
|
358 * @param aTitle The title text. |
|
359 * @param aLenghtInPixels The lenght of title text in pixels. |
|
360 * @return Pointer to this. |
|
361 */ |
|
362 static CTitleData* NewLC(const TDesC& aTitle, TInt aLenghtInPixels); |
|
363 |
|
364 /** |
|
365 * Two-phased constructor. |
|
366 * @param aByteData The SVG title. |
|
367 * @param aLenghtInPixels The lenght of title text in pixels. |
|
368 * @return Pointer to this. |
|
369 */ |
|
370 static CTitleData* NewL(const TDesC8& aByteData); |
|
371 |
|
372 /** |
|
373 * Two-phased constructor. |
|
374 * @param aByteData The SVG title. |
|
375 * @param aLenghtInPixels The lenght of title text in pixels. |
|
376 * @return Pointer to this. |
|
377 */ |
|
378 static CTitleData* NewLC(const TDesC8& aByteData); |
|
379 |
|
380 /** |
|
381 * Return the title text. |
|
382 * @return The title text. |
|
383 */ |
|
384 const TDesC& TitleText(); |
|
385 |
|
386 /** |
|
387 * Set new title text |
|
388 */ |
|
389 void SetTitleTextL(const TDesC& aTitle); |
|
390 |
|
391 /** |
|
392 * Return the title text lenght in pixels. |
|
393 * @return The title text lenght in pixels. |
|
394 */ |
|
395 TInt TitleTextLengthInPixels(); |
|
396 |
|
397 /** |
|
398 * Return the title text lenght in pixels. |
|
399 * @param aLenghtInPixels The lenght of title text in pixels. |
|
400 */ |
|
401 void SetTitleTextLengthInPixels(TInt aLenghtInPixels); |
|
402 |
|
403 /** |
|
404 * ETrue if the title is svg, EFalse if it is text. |
|
405 * @return ETrue if the title is svg, EFalse if it is text. |
|
406 */ |
|
407 TBool IsSvgTitle(); |
|
408 |
|
409 /** |
|
410 * Return the svg title data. |
|
411 * @return The svg title data. |
|
412 */ |
|
413 const TDesC8& SvgTitleData(); |
|
414 |
|
415 private: |
|
416 |
|
417 CTitleData(TInt aLenghtInPixels = 0); |
|
418 |
|
419 void ConstructL(const TDesC& aTitle); |
|
420 |
|
421 void ConstructL(const TDesC8& aByteData); |
|
422 |
|
423 private: // Data |
|
424 |
|
425 /** |
|
426 * ETrue if the title is SVG, EFalse if it is text. |
|
427 */ |
|
428 TBool iTitleIsSvg; |
|
429 |
|
430 /** |
|
431 * The title text. Owned. |
|
432 */ |
|
433 HBufC* iText; |
|
434 |
|
435 /** |
|
436 * The svg title. Owned. |
|
437 */ |
|
438 HBufC8* iData; |
|
439 |
|
440 /** |
|
441 * The title text length in pixels. |
|
442 */ |
|
443 TInt iTextLenghtInPixels; |
|
444 }; |
|
445 |
|
446 /** |
|
447 * List of titles to show. |
|
448 */ |
|
449 RPointerArray<CTitleData> iTitles; |
|
450 |
|
451 /** |
|
452 * The index of the title which is drawn first. |
|
453 */ |
|
454 TInt iFirstDrawingTitleIndex; |
|
455 |
|
456 /** |
|
457 * The number of pixels of the first title and separator image which |
|
458 * have already been shown. In other words, the number of the pixels |
|
459 * that are not visible in the screen. The iFirstDrawingTitleIndex |
|
460 * is updated when: |
|
461 * iFirstDrawingOffset > iTextLenghtInPixels + iSeparatorImageWidth |
|
462 */ |
|
463 TInt iFirstDrawingOffset; |
|
464 |
|
465 /** |
|
466 * The width of the.separator image. |
|
467 */ |
|
468 TInt iImageWidthInPixels; |
|
469 |
149 |
470 /** |
150 /** |
471 * The index of the title which is selected if user activates the |
151 * The index of the title which is selected if user activates the |
472 * control. |
152 * control. |
473 */ |
153 */ |
474 TInt iCurrentTitleIndex; |
154 TInt iCurrentTitleIndex; |
475 |
|
476 /** |
|
477 * The separator image. |
|
478 * Owned. |
|
479 */ |
|
480 CGulIcon* iSeparatorimage; |
|
481 |
|
482 /** |
|
483 * The separator image including the gap between image and text. |
|
484 * Owned. |
|
485 */ |
|
486 TInt iSeparatorImageWidth; |
|
487 |
|
488 /** |
|
489 * Font |
|
490 * Not own. |
|
491 */ |
|
492 CFont* iFont; |
|
493 |
|
494 /** |
|
495 * Baseline for the text. |
|
496 */ |
|
497 TInt iTextBaseline; |
|
498 |
|
499 /** |
|
500 * Color for the text |
|
501 */ |
|
502 TRgb iTextColor; |
|
503 |
|
504 /** |
|
505 * Whether to use underlining for the text |
|
506 */ |
|
507 TFontUnderline iUnderlining; |
|
508 |
|
509 /** |
|
510 * Whether to use strikethrough for the text |
|
511 */ |
|
512 TFontStrikethrough iStrikethrough; |
|
513 |
|
514 /** |
|
515 * A rect in which the scrolling text is shown. |
|
516 */ |
|
517 TRect iContentRect; |
|
518 |
|
519 /** |
|
520 * Amount of pixels the text moves in a tick. |
|
521 */ |
|
522 TInt iSpeed; |
|
523 |
|
524 /** |
|
525 * Whether the scrolling texts will loop or not. |
|
526 * If false, the scrolling will end at the last index. |
|
527 */ |
|
528 TBool iScrollLooping; |
|
529 |
|
530 /** |
|
531 * Whether the text direction is LTR or RTL. |
|
532 */ |
|
533 TBool iIsWestern; |
|
534 |
155 |
535 /** |
156 /** |
536 * Parent control adapter |
157 * Parent control adapter |
537 * Not own. |
158 * Not own. |
538 */ |
159 */ |
539 CXnNewstickerAdapter* iAdapter; |
160 CXnNewstickerAdapter* iAdapter; |
540 |
161 |
541 /** |
162 |
542 * ETrue if there is only one title, it fits in the rect and |
163 |
543 * scroll behaviour is slide |
164 |
544 */ |
|
545 TBool iTextFitInNewstickerRect; |
|
546 /** |
|
547 * Text alignment from the properties |
|
548 */ |
|
549 TInt iTextAlignment; |
|
550 }; |
165 }; |
551 |
166 |
552 #endif // XNNEWSTICKERCONTROL_H |
167 #endif // XNNEWSTICKERCONTROL_H |
553 |
168 |
554 // End of File |
169 // End of File |