|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "bmpansrv.h" // for the structures definition used for the packaging |
|
17 #include "bmpanpan.h" // for panics |
|
18 |
|
19 |
|
20 const TInt KFrameDataArrayGranularity = 5; |
|
21 const TInt KDefaultFrameIntervalInMilliSeconds = 0; |
|
22 |
|
23 |
|
24 /** |
|
25 class CBitmapFrameData |
|
26 */ |
|
27 |
|
28 CBitmapFrameData::CBitmapFrameData() |
|
29 : iBitmapsOwnedExternally(EFalse) |
|
30 { |
|
31 } |
|
32 |
|
33 |
|
34 /** |
|
35 Destructor. |
|
36 |
|
37 It deletes the bitmap and mask objects owned by the frame unless the "owned |
|
38 externally" (SetBitmapsOwnedExternally()) flag is set. |
|
39 */ |
|
40 EXPORT_C CBitmapFrameData::~CBitmapFrameData() |
|
41 |
|
42 { |
|
43 if(!iBitmapsOwnedExternally) |
|
44 { |
|
45 if(iMaskBitmap != iBitmap) |
|
46 { |
|
47 delete iMaskBitmap; |
|
48 } |
|
49 |
|
50 delete iBitmap; |
|
51 } |
|
52 } |
|
53 |
|
54 |
|
55 |
|
56 /** |
|
57 Creates a new empty frame object. |
|
58 |
|
59 @return New CBitmapFrameData object |
|
60 */ |
|
61 EXPORT_C CBitmapFrameData* CBitmapFrameData::NewL() |
|
62 { |
|
63 CBitmapFrameData* self = new (ELeave) CBitmapFrameData(); |
|
64 return self; |
|
65 } |
|
66 |
|
67 |
|
68 |
|
69 /** |
|
70 Creates a new frame object with a specified bitmap and (optionally) a mask. |
|
71 |
|
72 The object takes ownership of the specified bitmap and mask. |
|
73 |
|
74 @param aBitmap A pointer to the bitmap to use in the new frame |
|
75 @param aMask If non-NULL, a pointer to the mask to use in the new frame |
|
76 @return New CBitmapFrameData object |
|
77 */ |
|
78 EXPORT_C CBitmapFrameData* CBitmapFrameData::NewL(CFbsBitmap* aBitmap,CFbsBitmap* aMask) |
|
79 { |
|
80 __ASSERT_DEBUG(aBitmap, Panic(EAnimationClientPanicNullPointer)); |
|
81 |
|
82 CBitmapFrameData* self = NewL(); |
|
83 CleanupStack::PushL(self); // |
|
84 self->SetBitmap(aBitmap); |
|
85 self->SetMask(aMask); |
|
86 CleanupStack::Pop(); // self |
|
87 |
|
88 return self; |
|
89 } |
|
90 |
|
91 |
|
92 |
|
93 /** |
|
94 Creates a new frame object. |
|
95 |
|
96 It takes ownership of the specified bitmap and mask (if specified), and |
|
97 is assigned the frame duration and position. |
|
98 |
|
99 @param aBitmap A pointer to the bitmap to use in the frame. |
|
100 @param aMask If non-NULL, a pointer to the mask to use in the frame. |
|
101 @param aIntervalInMilliSeconds The frame's duration in milliseconds. |
|
102 @param aPosition The frame's position relative to the animation window. |
|
103 @return New CBitmapFrameData object |
|
104 */ |
|
105 EXPORT_C CBitmapFrameData* CBitmapFrameData::NewL(CFbsBitmap* aBitmap,CFbsBitmap* aMask, TInt aIntervalInMilliSeconds, TPoint aPosition) |
|
106 { |
|
107 __ASSERT_DEBUG(aBitmap, Panic(EAnimationClientPanicNullPointer)); |
|
108 |
|
109 CBitmapFrameData* self = NewL(); |
|
110 CleanupStack::PushL(self); // |
|
111 self->SetBitmap(aBitmap); |
|
112 self->SetMask(aMask); |
|
113 self->SetPosition(aPosition); |
|
114 self->SetInterval(aIntervalInMilliSeconds); |
|
115 CleanupStack::Pop(); // self |
|
116 |
|
117 return self; |
|
118 } |
|
119 |
|
120 |
|
121 /** |
|
122 Sets the frame bitmap. |
|
123 |
|
124 Unless the "owned externally" (SetBitmapsOwnedExternally()) flag is set, it |
|
125 deletes any existing frame bitmap and takes ownership of the new bitmap. |
|
126 |
|
127 @param aBitmap The frame bitmap |
|
128 */ |
|
129 EXPORT_C void CBitmapFrameData::SetBitmap(CFbsBitmap* aBitmap) |
|
130 { |
|
131 __ASSERT_DEBUG(aBitmap, Panic(EAnimationClientPanicNullPointer)); |
|
132 |
|
133 if(!iBitmapsOwnedExternally && iBitmap != iMaskBitmap) |
|
134 { |
|
135 delete iBitmap; |
|
136 } |
|
137 |
|
138 iBitmap = aBitmap; |
|
139 } |
|
140 |
|
141 |
|
142 |
|
143 /** |
|
144 Gets the frame's bitmap. |
|
145 |
|
146 This does not affect ownership of the bitmap. |
|
147 |
|
148 @return The frame's bitmap |
|
149 */ |
|
150 EXPORT_C CFbsBitmap* CBitmapFrameData::Bitmap() const |
|
151 { |
|
152 return iBitmap; |
|
153 } |
|
154 |
|
155 |
|
156 |
|
157 /** |
|
158 Sets the frame mask. |
|
159 |
|
160 Unless the "owned externally" (SetBitmapsOwnedExternally()) flag is set, it |
|
161 deletes any existing mask bitmap and takes ownership of the new bitmap. |
|
162 |
|
163 @param aMask Mask to use in the frame |
|
164 */ |
|
165 EXPORT_C void CBitmapFrameData::SetMask(CFbsBitmap* aMask) |
|
166 { |
|
167 if(!iBitmapsOwnedExternally && iBitmap != iMaskBitmap) |
|
168 { |
|
169 delete iMaskBitmap; |
|
170 } |
|
171 |
|
172 iMaskBitmap = aMask; |
|
173 } |
|
174 |
|
175 |
|
176 |
|
177 /** |
|
178 Gets the frame's mask. |
|
179 |
|
180 This does not affect ownership of the bitmap. |
|
181 |
|
182 @return The frame's mask |
|
183 */ |
|
184 EXPORT_C CFbsBitmap* CBitmapFrameData::Mask() const |
|
185 { |
|
186 return iMaskBitmap; |
|
187 } |
|
188 |
|
189 |
|
190 |
|
191 /** |
|
192 Sets the frame's duration in milliseconds. |
|
193 |
|
194 You can alternatively set the interval for a complete animation using CBitmapAnimClientData::SetFrameInterval(). |
|
195 However, an interval set for an individual frame overrides any interval set |
|
196 at the animation level. |
|
197 |
|
198 @param aIntervalInMilliSeconds The number of milliseconds to display the frame |
|
199 */ |
|
200 EXPORT_C void CBitmapFrameData::SetInterval(TInt aIntervalInMilliSeconds) |
|
201 { |
|
202 iIntervalInMilliSeconds = aIntervalInMilliSeconds; |
|
203 } |
|
204 |
|
205 |
|
206 |
|
207 /** |
|
208 Gets the frame's duration in milliseconds. |
|
209 |
|
210 @return The number of milliseconds for which the frame is displayed |
|
211 */ |
|
212 EXPORT_C TInt CBitmapFrameData::IntervalInMilliSeconds() const |
|
213 { |
|
214 return iIntervalInMilliSeconds; |
|
215 } |
|
216 |
|
217 |
|
218 |
|
219 /** |
|
220 Sets the frame's position relative to the animation window. |
|
221 |
|
222 @param aPosition The frame's position relative to the animation window |
|
223 */ |
|
224 EXPORT_C void CBitmapFrameData::SetPosition(TPoint aPosition) |
|
225 { |
|
226 iPosition = aPosition; |
|
227 } |
|
228 |
|
229 |
|
230 |
|
231 /** |
|
232 Gets the frame's position, relative to the animation window. |
|
233 |
|
234 @return The frame's position, relative to the animation window. |
|
235 */ |
|
236 EXPORT_C TPoint CBitmapFrameData::Position() const |
|
237 { |
|
238 return iPosition; |
|
239 } |
|
240 |
|
241 |
|
242 |
|
243 /** |
|
244 Sets whether the bitmap and mask are owned by the frame. |
|
245 |
|
246 @param aOwnedExternally If ETrue, the bitmap and mask are specified as being |
|
247 owned externally and the CBitmapFrameData destructor is NOT responsible for destroying the bitmap. |
|
248 If EFalse, the CBitmapFrameData destructor is responsible for destroying the bitmap. |
|
249 */ |
|
250 EXPORT_C void CBitmapFrameData::SetBitmapsOwnedExternally(TBool aOwnedExternally) |
|
251 { |
|
252 iBitmapsOwnedExternally = aOwnedExternally ? ETrue : EFalse; |
|
253 } |
|
254 |
|
255 |
|
256 |
|
257 /** |
|
258 Tests whether the frame owns the bitmap and mask. |
|
259 |
|
260 @return ETrue if the bitmap is owned externally, EFalse otherwise. |
|
261 */ |
|
262 EXPORT_C TBool CBitmapFrameData::BitmapsOwnedExternally() const |
|
263 { |
|
264 return iBitmapsOwnedExternally; |
|
265 } |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 /** |
|
271 class CBitmapAnimClientData |
|
272 */ |
|
273 CBitmapAnimClientData::CBitmapAnimClientData() : |
|
274 iFlash(EFalse), |
|
275 iPlayMode(EPlay), |
|
276 iFrameIntervalInMilliSeconds(KDefaultFrameIntervalInMilliSeconds), |
|
277 iFrameArray(KFrameDataArrayGranularity) |
|
278 { |
|
279 } |
|
280 |
|
281 |
|
282 |
|
283 /** |
|
284 Destructor. |
|
285 |
|
286 It deletes the background frame and destroys the contents of the frame array. |
|
287 */ |
|
288 EXPORT_C CBitmapAnimClientData::~CBitmapAnimClientData() |
|
289 { |
|
290 delete iBackgroundFrame; |
|
291 iFrameArray.ResetAndDestroy(); |
|
292 } |
|
293 |
|
294 |
|
295 |
|
296 /** |
|
297 Allocates and constructs a new CBitmapAnimClientData object. |
|
298 |
|
299 @return New CBitmapAnimClientData object |
|
300 */ |
|
301 EXPORT_C CBitmapAnimClientData* CBitmapAnimClientData::NewL() |
|
302 { |
|
303 CBitmapAnimClientData* self = new (ELeave) CBitmapAnimClientData; |
|
304 return self; |
|
305 } |
|
306 |
|
307 |
|
308 |
|
309 /** |
|
310 Appends a new frame to the array of frames. |
|
311 |
|
312 The array takes ownership of the new frame. |
|
313 |
|
314 @param aFrame A pointer to the frame to add to the array of frames |
|
315 */ |
|
316 EXPORT_C void CBitmapAnimClientData::AppendFrameL(CBitmapFrameData* aFrame) |
|
317 { |
|
318 iFrameArray.AppendL(aFrame); |
|
319 } |
|
320 |
|
321 |
|
322 |
|
323 /** |
|
324 Gets the animation frame array. |
|
325 |
|
326 @return Animation frame array |
|
327 */ |
|
328 EXPORT_C const CArrayPtrFlat<CBitmapFrameData>& CBitmapAnimClientData::FrameArray() const |
|
329 { |
|
330 |
|
331 return iFrameArray; |
|
332 } |
|
333 |
|
334 |
|
335 |
|
336 /** |
|
337 Resets and destroys the frame array's contents. |
|
338 */ |
|
339 EXPORT_C void CBitmapAnimClientData::ResetFrameArray() |
|
340 { |
|
341 iFrameArray.ResetAndDestroy(); |
|
342 } |
|
343 |
|
344 |
|
345 |
|
346 /** |
|
347 Sets the background frame and takes ownership of it. |
|
348 |
|
349 Any previous background frame, and mask if one is included, is deleted from |
|
350 memory. The frame is redrawn in the animation window in order to clear the |
|
351 current frame before drawing the next one. |
|
352 |
|
353 @param aBackgroundFrame The bitmap to use as the background frame |
|
354 */ |
|
355 EXPORT_C void CBitmapAnimClientData::SetBackgroundFrame(CBitmapFrameData* aBackgroundFrame) |
|
356 { |
|
357 |
|
358 if(iBackgroundFrame) |
|
359 { |
|
360 delete iBackgroundFrame; |
|
361 } |
|
362 |
|
363 iBackgroundFrame = aBackgroundFrame; |
|
364 } |
|
365 |
|
366 |
|
367 |
|
368 /** |
|
369 Gets the background frame bitmap. |
|
370 |
|
371 @return Background frame bitmap |
|
372 */ |
|
373 EXPORT_C CBitmapFrameData* CBitmapAnimClientData::BackgroundFrame() const |
|
374 { |
|
375 return iBackgroundFrame; |
|
376 } |
|
377 |
|
378 |
|
379 |
|
380 /** |
|
381 Sets or unsets the animation's flash state. |
|
382 |
|
383 @param aFlash ETrue for the animation to flash, otherwise EFalse |
|
384 */ |
|
385 EXPORT_C void CBitmapAnimClientData::SetFlash(TBool aFlash) |
|
386 { |
|
387 iFlash = aFlash; |
|
388 } |
|
389 |
|
390 |
|
391 |
|
392 /** |
|
393 Gets the animation's flash setting. |
|
394 |
|
395 @return ETrue if the animation is flashing, otherwise EFalse |
|
396 */ |
|
397 EXPORT_C TBool CBitmapAnimClientData::Flash() const |
|
398 { |
|
399 return iFlash; |
|
400 } |
|
401 |
|
402 |
|
403 |
|
404 /** |
|
405 Specifies for how many milliseconds each frame in the animation is displayed. |
|
406 |
|
407 This is not used for any frames in the animation that specify their own interval. |
|
408 |
|
409 @param aFrameIntervalInMilliSeconds The number of milliseconds for which each |
|
410 frame in the animation is displayed |
|
411 */ |
|
412 EXPORT_C void CBitmapAnimClientData::SetFrameInterval(TInt aFrameIntervalInMilliSeconds) |
|
413 { |
|
414 __ASSERT_DEBUG(aFrameIntervalInMilliSeconds >= 0, Panic(EAnimationClientPanicFrameIntervalNegative)); |
|
415 iFrameIntervalInMilliSeconds = aFrameIntervalInMilliSeconds; |
|
416 } |
|
417 |
|
418 |
|
419 |
|
420 /** |
|
421 Gets the default animation frame interval in milliseconds. |
|
422 |
|
423 @return Default animation frame interval in milliseconds |
|
424 */ |
|
425 EXPORT_C TInt CBitmapAnimClientData::FrameIntervalInMilliSeconds() const |
|
426 { |
|
427 return iFrameIntervalInMilliSeconds; |
|
428 } |
|
429 |
|
430 |
|
431 |
|
432 /** |
|
433 Sets the play mode so that the animation plays once or continuously. |
|
434 |
|
435 @param aPlayMode The animation play mode |
|
436 */ |
|
437 EXPORT_C void CBitmapAnimClientData::SetPlayMode(TPlayMode aPlayMode) |
|
438 { |
|
439 iPlayMode = aPlayMode; |
|
440 } |
|
441 |
|
442 |
|
443 |
|
444 /** |
|
445 Gets the animation's play mode. |
|
446 |
|
447 @return Animation's play mode |
|
448 */ |
|
449 EXPORT_C CBitmapAnimClientData::TPlayMode CBitmapAnimClientData::PlayMode() const |
|
450 { |
|
451 return iPlayMode; |
|
452 } |
|
453 |
|
454 |
|
455 |
|
456 /** |
|
457 Gets the display size required to show the entire animation. |
|
458 |
|
459 @return Display size |
|
460 */ |
|
461 EXPORT_C TSize CBitmapAnimClientData::Size() const |
|
462 { |
|
463 TSize size; |
|
464 TSize frameSize; |
|
465 const TInt count = iFrameArray.Count(); |
|
466 CBitmapFrameData* frame; |
|
467 CFbsBitmap* bitmap; |
|
468 |
|
469 TInt index = 0; |
|
470 |
|
471 for (index=0; index < count; index++) |
|
472 { |
|
473 frame = iFrameArray.At(index); |
|
474 bitmap = frame->Bitmap(); |
|
475 if (bitmap) |
|
476 { |
|
477 frameSize = frame->Bitmap()->SizeInPixels() + frame->Position().AsSize(); |
|
478 } |
|
479 |
|
480 size.iHeight = Max(size.iHeight, frameSize.iHeight); |
|
481 size.iWidth = Max(size.iWidth, frameSize.iWidth); |
|
482 } |
|
483 // for the background frame |
|
484 if (iBackgroundFrame && iBackgroundFrame->Bitmap()) |
|
485 { |
|
486 frameSize = iBackgroundFrame->Bitmap()->SizeInPixels() + iBackgroundFrame->Position().AsSize(); |
|
487 size.iHeight = Max(size.iHeight, frameSize.iHeight); |
|
488 size.iWidth = Max(size.iWidth, frameSize.iWidth); |
|
489 } |
|
490 |
|
491 return size; |
|
492 } |
|
493 |
|
494 |
|
495 |
|
496 |
|
497 /** |
|
498 Gets the time required to display the entire sequence of frames that comprise |
|
499 the animation. |
|
500 |
|
501 This time is expressed in milliseconds. |
|
502 |
|
503 @return Animation duration |
|
504 */ |
|
505 EXPORT_C TInt CBitmapAnimClientData::DurationInMilliSeconds() const |
|
506 { |
|
507 TInt time = 0; |
|
508 TInt frameInterval; |
|
509 const TInt count = iFrameArray.Count(); |
|
510 |
|
511 TInt index = 0; |
|
512 |
|
513 for (index = 0; index < count; index++) |
|
514 { |
|
515 frameInterval = iFrameArray.At(index)->IntervalInMilliSeconds(); |
|
516 |
|
517 if (frameInterval < 0) |
|
518 { |
|
519 frameInterval = ((iFrameIntervalInMilliSeconds > 0) ? iFrameIntervalInMilliSeconds : KDefaultFrameIntervalInMilliSeconds); |
|
520 } |
|
521 |
|
522 time += frameInterval; |
|
523 } |
|
524 |
|
525 return time; |
|
526 } |
|
527 |
|
528 |
|
529 |
|
530 /** |
|
531 class RBitmapAnim |
|
532 */ |
|
533 |
|
534 /** |
|
535 Constructor. |
|
536 |
|
537 @param aAnimDll A reference to the DLL that runs the animation |
|
538 */ |
|
539 EXPORT_C RBitmapAnim::RBitmapAnim(RAnimDll& aAnimDll) |
|
540 :RAnim(aAnimDll) |
|
541 { |
|
542 } |
|
543 |
|
544 |
|
545 |
|
546 /** |
|
547 Completes construction of an animation object. |
|
548 |
|
549 This must be done after calling RBitmapAnim(), and before an application attempts |
|
550 any other communication with the server. |
|
551 |
|
552 @param aWindow A reference to the container control window that will hold |
|
553 the animation. |
|
554 */ |
|
555 EXPORT_C void RBitmapAnim::ConstructL(const RWindowBase& aDevice) |
|
556 { |
|
557 TPtrC8 des(NULL,0); |
|
558 User::LeaveIfError(RAnim::Construct(aDevice, 0, des)); |
|
559 } |
|
560 |
|
561 |
|
562 |
|
563 /** |
|
564 Sets the animation frame to display. |
|
565 |
|
566 How it appears depends on whether the animation is already running. If the |
|
567 animation is running, the animation jumps to the specified frame, then |
|
568 continues playing. If the animation is not running, the animation is played, |
|
569 starting with the specified frame |
|
570 |
|
571 @param aIndex The frame to display. |
|
572 */ |
|
573 EXPORT_C void RBitmapAnim::DisplayFrameL(TInt aIndex) |
|
574 { |
|
575 TPckgBuf<SBitmapAnimIndexFrame> bitmapAnimIndexFrame; |
|
576 bitmapAnimIndexFrame().iIndex = aIndex; |
|
577 User::LeaveIfError(CommandReply(EBitmapAnimCommandSetFrameIndex, bitmapAnimIndexFrame)); |
|
578 } |
|
579 |
|
580 |
|
581 |
|
582 |
|
583 /** |
|
584 Specifies the animation object to play and sends it to the animation server. |
|
585 |
|
586 To start the animation, you must subsequently call StartL(). |
|
587 Calling this method while an animation is running will stop the animation. |
|
588 |
|
589 @param aBitmapAnimData The animation object to play |
|
590 */ |
|
591 EXPORT_C void RBitmapAnim::SetBitmapAnimDataL(const CBitmapAnimClientData& aBitmapAnimData) |
|
592 { |
|
593 SetAttributesL(aBitmapAnimData); |
|
594 |
|
595 const CArrayPtrFlat<CBitmapFrameData>& frameArray = aBitmapAnimData.FrameArray(); |
|
596 SetFrameArrayL(frameArray); |
|
597 |
|
598 CBitmapFrameData* frameData = aBitmapAnimData.BackgroundFrame(); |
|
599 |
|
600 if (frameData) |
|
601 { |
|
602 SetBackgroundFrameL(*frameData); |
|
603 } |
|
604 } |
|
605 |
|
606 |
|
607 |
|
608 /** |
|
609 Sets or unsets the animation to be drawn flashing. |
|
610 |
|
611 @param aFlash ETrue to draw the animation flashing, otherwise EFalse. |
|
612 */ |
|
613 EXPORT_C void RBitmapAnim::SetFlashL(TBool aFlash) |
|
614 { |
|
615 TPckgBuf<TBmpAnimAttributes> bitmapAnimFlash; |
|
616 bitmapAnimFlash().iFlash = aFlash; |
|
617 User::LeaveIfError(CommandReply(EBitmapAnimCommandSetFlash, bitmapAnimFlash)); |
|
618 } |
|
619 |
|
620 |
|
621 |
|
622 /** |
|
623 Specifies the number of milliseconds for which each frame in the animation |
|
624 is displayed. |
|
625 |
|
626 This is not used for any frames in the animation that specify their own interval. |
|
627 |
|
628 @param aFrameIntervalInMilliSeconds The number of milliseconds for which each |
|
629 frame in the animation is displayed |
|
630 */ |
|
631 EXPORT_C void RBitmapAnim::SetFrameIntervalL(TInt aFrameIntervalInMilliSeconds) |
|
632 { |
|
633 __ASSERT_DEBUG(aFrameIntervalInMilliSeconds >= 0, Panic(EAnimationClientPanicFrameIntervalNegative)); |
|
634 TPckgBuf<TBmpAnimAttributes> bitmapAnimFrameInterval; |
|
635 bitmapAnimFrameInterval().iFrameIntervalInMilliSeconds = aFrameIntervalInMilliSeconds; |
|
636 User::LeaveIfError(CommandReply(EBitmapAnimCommandSetFrameInterval, bitmapAnimFrameInterval)); |
|
637 } |
|
638 |
|
639 |
|
640 |
|
641 /** |
|
642 Sets how many times the animation is played. |
|
643 |
|
644 If the play mode is CBitmapAnimClientData::EBounce, the number of cycles must |
|
645 be at least two to ensure a complete animation routine is played. |
|
646 |
|
647 @param aNumberOfCycles The number of times to play the animation. |
|
648 */ |
|
649 EXPORT_C void RBitmapAnim::SetNumberOfCyclesL(TInt aNumberOfCycles) |
|
650 { |
|
651 TPckgBuf<SBitmapAnimNumberOfCycles> bitmapAnimNumberOfCycles; |
|
652 bitmapAnimNumberOfCycles().iCycles = aNumberOfCycles; |
|
653 User::LeaveIfError(CommandReply(EBitmapAnimCommandSetNumberOfCycles, bitmapAnimNumberOfCycles)); |
|
654 } |
|
655 |
|
656 |
|
657 |
|
658 /** |
|
659 Sets the current animation's play mode. |
|
660 |
|
661 @param aPlayMode The animation's play mode. |
|
662 */ |
|
663 EXPORT_C void RBitmapAnim::SetPlayModeL(CBitmapAnimClientData::TPlayMode aPlayMode) |
|
664 { |
|
665 TPckgBuf<TBmpAnimAttributes> bitmapAnimPlayMode; |
|
666 bitmapAnimPlayMode().iPlayMode = aPlayMode; |
|
667 User::LeaveIfError(CommandReply(EBitmapAnimCommandSetPlayMode, bitmapAnimPlayMode)); |
|
668 } |
|
669 |
|
670 |
|
671 |
|
672 /** |
|
673 Sets the animation's position relative to the animation window. |
|
674 |
|
675 @param aPosition The animation's position relative to the animation window |
|
676 */ |
|
677 EXPORT_C void RBitmapAnim::SetPositionL(const TPoint aPosition) |
|
678 { |
|
679 TPckgBuf<SBitmapAnimNewPosition> bitmapAnimNewPosition; |
|
680 bitmapAnimNewPosition().iPosition = aPosition; |
|
681 User::LeaveIfError(CommandReply(EBitmapAnimCommandSetPosition, bitmapAnimNewPosition)); |
|
682 } |
|
683 |
|
684 |
|
685 |
|
686 /** |
|
687 Starts the animation. |
|
688 |
|
689 You must first specify an animation with SetBitmapAnimDataL(). |
|
690 |
|
691 If you have specified CBitmapAnimClientData::ECycle or CBitmapAnimClientData::EBounce |
|
692 as the animation's play mode, but have not specified the number of cycles |
|
693 using SetNumberOfCyclesL(), you must call StopL() to stop the animation. |
|
694 */ |
|
695 EXPORT_C void RBitmapAnim::StartL() |
|
696 { |
|
697 User::LeaveIfError(CommandReply(EBitmapAnimCommandStartAnimation)); |
|
698 } |
|
699 |
|
700 |
|
701 |
|
702 /** |
|
703 Stops the animation. |
|
704 */ |
|
705 EXPORT_C void RBitmapAnim::StopL() |
|
706 { |
|
707 User::LeaveIfError(CommandReply(EBitmapAnimCommandStopAnimation)); |
|
708 } |
|
709 |
|
710 |
|
711 |
|
712 /** |
|
713 Sets the general attributes of the animation. |
|
714 */ |
|
715 void RBitmapAnim::SetAttributesL(const CBitmapAnimClientData& aBitmapAnimData) |
|
716 { |
|
717 SetFlashL(aBitmapAnimData.Flash()); |
|
718 SetFrameIntervalL(aBitmapAnimData.FrameIntervalInMilliSeconds()); |
|
719 SetPlayModeL(aBitmapAnimData.PlayMode()); |
|
720 } |
|
721 |
|
722 |
|
723 /** |
|
724 Sets the animation frames to the player. |
|
725 */ |
|
726 void RBitmapAnim::SetFrameArrayL(const CArrayPtrFlat<CBitmapFrameData>& aFrameArray) |
|
727 { |
|
728 const TInt count = aFrameArray.Count(); |
|
729 |
|
730 if (count > 0) |
|
731 { |
|
732 User::LeaveIfError(CommandReply(EBitmapAnimCommandResetFrameArray)); |
|
733 CBitmapFrameData* frameData; |
|
734 User::LeaveIfError(CommandReply(EBitmapAnimCommandClearDataFrames)); |
|
735 |
|
736 TInt index = 0; |
|
737 |
|
738 for (index = 0; index < count; index++) |
|
739 { |
|
740 frameData = aFrameArray.At(index); |
|
741 SetFrameL(*frameData, EBitmapAnimCommandSetDataFrame); |
|
742 } |
|
743 } |
|
744 } |
|
745 |
|
746 |
|
747 |
|
748 /** |
|
749 Sets the background frame, aFrameData, to the player. |
|
750 */ |
|
751 void RBitmapAnim::SetBackgroundFrameL(const CBitmapFrameData& aFrameData) |
|
752 { |
|
753 SetFrameL(aFrameData, EBitmapAnimCommandSetBackgroundFrame); |
|
754 } |
|
755 |
|
756 |
|
757 /** |
|
758 Extracts data from aFrameData, packs them and then it sends this package to the player |
|
759 */ |
|
760 void RBitmapAnim::SetFrameL(const CBitmapFrameData& aFrameData, TInt aOpCode) |
|
761 { |
|
762 TPckgBuf<TFrameData> dataFrameArg; |
|
763 CFbsBitmap* bitmap = aFrameData.Bitmap(); |
|
764 dataFrameArg().iBitmapHandle=( (bitmap) ? bitmap->Handle() : 0 ); |
|
765 CFbsBitmap* mask = aFrameData.Mask(); |
|
766 dataFrameArg().iMaskBitmapHandle=( (mask) ? mask->Handle() : 0 ); |
|
767 dataFrameArg().iIntervalInMilliSeconds=aFrameData.IntervalInMilliSeconds(); |
|
768 dataFrameArg().iPosition=aFrameData.Position(); |
|
769 User::LeaveIfError(CommandReply(aOpCode, dataFrameArg)); |
|
770 } |