1 // Copyright (c) 1995-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Header for writing animated DLL add ons
18 #if !defined(__W32ADLL_H__)
21 #if !defined(__W32STD_H__)
25 #if !defined(__BITSTD_H__)
33 const TUint KWservAnimDllUidValue8=268435858;
39 const TUid KWservAnimDllUid8={KWservAnimDllUidValue8};
45 const TUint KWservAnimDllUidValue16=268450594;
51 const TUid KWservAnimDllUid16={KWservAnimDllUidValue16};
57 const TUint KWservAnimDllUidValue=KWservAnimDllUidValue16;
63 const TUid KWservAnimDllUid={KWservAnimDllUidValue};
66 // Contains functions callable from animated DLLs
71 /** Animation window information.
73 Stores the window position and display mode for the animation.
74 During a redraw of the animation window, the redraw regions
75 can be retrieved by calling GetRedrawRegionAndRedrawShadowRegion().
79 @see TWindowInfo::GetRedrawRegionAndRedrawShadowRegion() */
82 /** The screen position. */
86 This is the minimum display mode that the screen has to be in to display this window. */
89 /** Constructs an animation window information object. */
90 inline TWindowInfo() : iRegionPair(NULL) {}
92 /** Stores a pair of region pointers. */
95 const TRegion* iRegion1;
96 const TRegion* iRegion2;
98 /** Returns the current redraw region and redraw shadow region.
99 This function must only be called from an override of CWindowAnim's pure virtual Redraw function.
100 The region pointers retrieved must not be used beyond the end of the Redraw override.
101 @param aRedrawRegion The redraw region in screen coordinates.
102 @param aRedrawShadowRegion The redraw shadow region in screen coordinates. */
103 inline void GetRedrawRegionAndRedrawShadowRegion(const TRegion*& aRedrawRegion, const TRegion*& aRedrawShadowRegion) const
107 aRedrawRegion=iRegionPair->iRegion1;
108 aRedrawShadowRegion=iRegionPair->iRegion2;
114 aRedrawShadowRegion=NULL;
118 mutable const TRegionPair* iRegionPair;
120 friend class CWsAnim;
125 /** Event handler interface.
127 The interface provides a function to handle raw events, e.g. key presses,
128 pen events, power buttons etc. Raw events are passed to the OfferRawEvent()
129 function when the MAnimGeneralFunctions::GetRawEvents() function has been
136 /** Handles raw events.
138 If the incoming event can be handled, the function should
139 process it and then return true. If it cannot be processed the function should
140 return false, and the event will be passed to other event handling code.
142 This function must be implemented in every animation DLL. If event
143 handling is not required, the function should simply return false.
145 @param aRawEvent The raw event to be processed
146 @return ETrue if the raw event is handled by this function, EFalse if the function
147 chooses not to process it. */
148 virtual TBool OfferRawEvent(const TRawEvent &aRawEvent)=0;
151 enum TAnimNotifications
152 /** Bit flags to be used by anims when registering for notifications */
154 /** Notify when direct screen access begins or ends.*/
155 EDirectScreenAccess = 0x0001,
156 /** Notify when the wserv heartbeat timer starts or stops. */
157 EHeartbeatTimer = 0x0002,
158 /** Notify when screen device changes.*/
159 EScreenDeviceChange = 0x0004
161 //Forward Declaration.
162 class MAnimGeneralFunctionsWindowExtension;
163 class MAnimGeneralFunctionsEventExtension ;
165 class MAnimGeneralFunctions
166 /** General animation utility functions interface.
168 The interface provides functions to set the animation timing,
169 event functions, and other general functions.
171 You do not have to create an object of this type. The class is implemented
172 by the window server and provides utility functions to all CAnim-derived
173 classes via the CAnim::iFunctions pointer.
175 It is not intended for user derivation.
181 /** Animation synchronisation flags.
183 The animation can be synchronised to any of these values;
184 the Animate() call will take place at the start of the new unit (day, hour, etc...). */
187 /** Not synchronised. Animate() is called after some number of flash cycles -
190 /** Animate() every flash tick. This occurs twice a second, on the second and after
191 7/12ths of a second, e.g. the function is called in a flash-on (7/12 seconds) -
192 flash-off (5/12 seconds) cycle. */
194 /** Animate() called as soon after every second as system activity allows. */
196 /** Animate() called as soon after every minute as system activity allows. */
198 /** Animate() called as soon after midnight every day as system activity allows. */
203 ENumberOfExtendedInterfaces=0,
204 EWindowExtensionInterface,
205 EEventExtentionInterface,
206 EInterfaceCount, // Always keep at the end.
209 /** Calls the DLL's Animate() function then deactivates the graphics context.
211 This allows users to do drawing from their own active object.
215 If the user calls the CAnim-derived classes' Animate() function directly,
216 or otherwise does drawing from their own active object, then this will not
217 deactivate the graphics context. This causes the window server to panic the
220 Alternatively, use CFreeTimerWindowAnim, which allows you to deactivate the
221 graphics context yourself.
223 @param aDateTime The parameter passed into the animation DLL's Animate()
225 virtual void Animate(TDateTime *aDateTime)=0;
226 /** Sets the synchronisation mode.
228 This determines the time intervals between calls to the Animate() function.
230 @param aSyncMode The synchronisation mode. */
231 virtual void SetSync(TAnimSync aSyncMode)=0;
232 /** Sets the repeat interval.
234 If the synchronisation mode is TAnimSync::ESyncNone, then the Animate() function
235 is called at intervals defined by some number of flash ticks. There are two
236 flash ticks a second, with a 7/12 second - 5/12 second cycle. If the function
237 is called when the synchronisation mode is not TAnimSync::ESyncNone, then
238 the window server panics the client.
240 If the new interval is greater than the current countdown, then the call does
241 not affect the current countdown. For example, if the countdown has 10 flash
242 ticks remaining, and the interval is set to 20, the new interval does not
243 apply until the current countdown is complete.
245 However if the new interval is less the current countdown, then the new interval
246 applies immediately i.e. the countdown is reset to the interval value.
248 If the interval is set to zero the countdown stops, and the Animate() function
251 @param aInterval The number of flash ticks between calls to the Animate()
253 virtual void SetInterval(TInt aInterval)=0;
254 /** Sets the next interval.
256 This function immediately resets the current countdown to the specified number
257 of flash ticks, irrespective of its current value. After the countdown expires,
258 the interval returns to its usual rate. Note that this may be zero (i.e.
261 To call this function, the synchronisation mode must be TAnimSync::ESyncNone,
262 otherwise the window server panics the client.
264 Note: there are two flash ticks a second, with a 7/12 second - 5/12 second cycle.
266 @param aInterval The interval to the next Animate(). If the value is less
267 than 1, it automatically gets set to 1.
268 @see SetInterval() */
269 virtual void SetNextInterval(TInt aInterval)=0;
270 /** Gets the system time as it was when Animate() was last called.
272 @return The system time when Animate() was last called. */
273 virtual TDateTime SystemTime() const=0;
274 /** Tests the flash cycle state.
276 The flash cycle has 2 states: on (7/12 second) or off (5/12 second).
278 @return ETrue if in the on part of the flash cycle, otherwise EFalse. */
279 virtual TBool FlashStateOn() const=0;
280 /** Gets the current synchronisation mode.
282 @return The current sync mode. */
283 virtual TAnimSync Sync() const=0;
284 //Other functions generally useful
285 /** Gets a pointer to the screen device.
287 For example, this might be used to gain access to twips to pixel conversion functions.
289 @return A pointer to the screen device. */
290 virtual const CFbsScreenDevice *ScreenDevice()=0;
291 /** Creates and duplicates a bitmap from a handle.
293 This function might be used to duplicate client side bitmaps on the server side.
295 @param aHandle A handle to the bitmap to be duplicated.
296 @return A pointer to the duplicate bitmap. */
297 virtual CFbsBitmap *DuplicateBitmapL(TInt aHandle)=0;
298 /** Creates and duplicates a font from a handle.
300 This function might be used to duplicate client side fonts on the server side.
302 @param aHandle A handle to the font to be duplicated.
303 @return A pointer to the duplicate font. */
304 virtual CFbsFont *DuplicateFontL(TInt aHandle)=0;
305 /** Closes a duplicate font.
307 @param Pointer to the duplicate font.
308 @see DuplicateFontL() */
309 virtual void CloseFont(CFbsFont *)=0;
310 /** Gets a reference to the calling client's thread.
312 @return A reference to the calling client's thread. */
313 virtual const RThread &Client()=0;
314 virtual void ReplyBuf(const TDesC8 &aDes)=0; // Reply a buffer to the client
315 virtual void ReplyBuf(const TDesC16 &aDes)=0; // Reply a buffer to the client
316 /** Panics the client.
318 This will result in the client thread being destroyed. */
319 virtual void Panic() const=0;
321 /** Switches animation raw event handling on and off.
323 If raw event handling is switched on, then raw events, e.g. pointer, key, or power events
324 are all offered to the animation event handling code's MEventHandler::OfferRawEvent().
326 @param aGetEvents If ETrue, raw events are passed to the animation
327 event handling code. If EFalse, events are not passed to the animation. */
328 virtual void GetRawEvents(TBool aGetEvents) const=0;
329 /** Posts a raw event, just as if it had come from the kernel.
331 @param aRawEvent The raw event */
332 virtual void PostRawEvent(const TRawEvent &aRawEvent) const=0;
333 /** Posts a key event.
335 The function is similar to PostRawEvent() but should be
336 used for posting key events.
338 @param aRawEvent The key event. */
339 virtual void PostKeyEvent(const TKeyEvent &aRawEvent) const=0;
340 /** Get the address of an object which can retrieve information from and send
341 information to the client-side.
343 @return A pointer to RMessagePtr2. Complete must be called on the returned object (or a
344 copy of it) if and only if Message is called from an override of CAnim's CommandReplyL which
345 has been caused by a client-side RAnim::AsyncCommandReply call. If Message is called outside
346 an override of CAnim's CommandReplyL or outside an override of CWindowAnim's ConstructL or
347 CSpriteAnim's ConstructL, the it returns NULL.
349 virtual const RMessagePtr2* Message()=0; // replaces Reserved1
350 /**Returns an extension interface, maybe extended further in the future.
351 @param aInterfaceId The ID of the interface to return.
352 @return A pointer to the extension interface.
353 When aInterface=0 (ENumberOfExtendedInterfaces), the number of interfaces is returned (currently 2).
354 When aInterface=1 (EWindowExtensionInterface), a pointer to the Window Extension interface is returned.
355 When aInterface=2 (EEventExtentionInterface), a pointer to the Event Extension interface is returned.
357 virtual TAny* ExtendedInterface(TInt aInterface)=0; // replaces Reserved2
359 /** Register to receive notifications.
360 @param aNotifications A bitset of TAnimNotifications values indicating which notifications are required
361 @return One of the system wide error codes
363 virtual TInt RegisterForNotifications(TUint32 aNotifications)=0;
365 Return number of ExtendedInterfaces. */
366 inline TInt NumberOfExtendedInterfaces()
368 return reinterpret_cast<TInt>(ExtendedInterface(ENumberOfExtendedInterfaces));
370 /** Gets access to Window Extension utility functions.
371 @return A pointer to a class containing functions for working with Window. */
372 inline MAnimGeneralFunctionsWindowExtension* WindowExtension()
374 return static_cast<MAnimGeneralFunctionsWindowExtension*>(ExtendedInterface(EWindowExtensionInterface));
376 /** Gets access to EventExtension utility functions.
377 @return A pointer to a class containing functions for working with Event. */
378 inline MAnimGeneralFunctionsEventExtension* EventExtension()
380 return static_cast<MAnimGeneralFunctionsEventExtension*>(ExtendedInterface(EEventExtentionInterface));
383 virtual void Reserved1() const;
384 virtual void Reserved2() const;
385 virtual void Reserved3() const;
388 /* Structure for passing window configuration information. Currently transparancey
389 related configuration information is supported, though this may be added to, as
398 /** Transparency flags.
400 Used to represent transparency configuration of the window. */
403 /** Transparency is enabled on the window. */
404 ETransparencyEnabled=0x0001,
405 /** Window transparency uses alpha blending channel. */
406 EAlphaBlendedTransparency=0x0002,
409 /** Indicate configuration of window, using enumerations defined within this class. */
417 class MAnimGeneralFunctionsWindowExtension
418 /** General Window utility functions interface.
420 The member functions define the interface for querying and manipulating
421 the window and screen attributes.
423 You obtain one by calling: iFunctions->ExtendedInterface(MAnimGeneralFunctions::EWindowExtensionInterface)
424 and casting the result.
426 It is not intended for user derivation.
432 /** Class contains the information pertaining to a window group: name, priority,
434 class TWindowGroupInfo
439 /** Window is focusable flag. */
443 /** Returns whether or not the window is focusable.
444 @return ETrue if focusable, else returns EFalse. */
445 inline TBool IsFocusable() const {return iFlags&EIsFocusable;}
447 /* Window group attributes. */
450 TInt iOrdinalPriority;
455 /** Returns the total number of screens.
456 @return The total number of screens. */
457 virtual TInt Screens() const=0;
459 /** Returns the number of the screen which is currently in focus.
460 @return The number of the screen which is currently in focus.*/
461 virtual TInt FocusScreens() const=0;
463 /** Changes the focused screen.
464 @param aScreenNo New screen number. */
465 virtual void SetFocusScreen(TInt aScreenNo)=0;
467 /** Returns the number of window groups available for the specified screen.
469 @param aScreen The screen number.
470 @return The number of window groups. */
471 virtual TInt WindowGroups(TInt aScreen) const=0;
473 /** Takes a screen number and an ordinal position and returns the complete window
474 group information of the specified window. If the window group does not exist, the
475 function returns EFalse.
477 Note: the ordinal position specified should be the total or full ordinal position
478 of all group windows of all priorities on that screen.
480 @param aInfo on return, complete window information.
481 @param aScreen Screen number.
482 @param aFullOrdinalPosition Ordinal position of the window.
483 @return ETrue if window group information exists, EFalse otherwise. */
484 virtual TBool WindowGroupInfo(TWindowGroupInfo& aInfo,TInt aScreen,TInt aFullOrdinalPosition) const=0;
486 /** Takes a screen number and an ordinal position and returns the window group name.
487 If the window group does not exist, the function returns false.
489 Note: the ordinal position specified should be the total or full ordinal position of
490 all group windows of all priorities on that screen.
492 Note: if the name does not fit into the descriptor provided then it will be truncated.
494 @param aWindowName On return, the window group name.
495 @param aScreen The screen number.
496 @param aFullOrdinalPosition The ordinal position of the window.
497 @return ETrue if the window group name exists, EFalse otherwise. */
498 virtual TBool WindowGroupName(TPtrC& aWindowName,TInt aScreen,TInt aFullOrdinalPosition) const=0;
500 /** Changes the ordinal position and priority of the window group with the specified ID.
502 @param aWindowGroupId The window group ID.
503 @param aPos The ordinal position to move the window to.
504 @param aOrdinalPriority The new ordinal priority of the window.
505 @return KErrNotFound if there is no window group with the specified ID, KErrNone otherwise. */
506 virtual TInt SetOrdinalPosition(TInt aWindowGroupId,TInt aPos,TInt aOrdinalPriority)=0;
508 /** Accessor for window configuration.
510 @param aWindowConfig Gets filled in with window configuration details. */
511 virtual void WindowConfig(TWindowConfig& aWindowConfig) const=0;
514 virtual void Reserved1() const;
515 virtual void Reserved2() const;
516 virtual void Reserved3() const;
519 class MAnimGeneralFunctionsEventExtension
520 /** Event utility functions interface.
522 The member functions define the interface for generate repeated key events .
524 It is not intended for user derivation.
528 /** Posts a key event.
530 The function is similar to PostKeyEvent() but should be
531 used for posting repeated key events.
533 @param aRawEvent The key event.
534 @param aRepeats value */
535 virtual void PostKeyEvent(const TKeyEvent& aRawEvent, TInt aRepeats) const=0;
538 virtual void Reserved1() const;
539 virtual void Reserved2() const;
542 class MAnimWindowFunctions
543 /** Window utility functions interface.
545 The member functions define the interface for querying and manipulating
546 the window in which the animation takes place.
548 You do not have to create an object of this type. The class is implemented
549 by the window server, and provides these utility functions to all CWindowAnim
550 and CFreeTimerWindowAnim derived classes via the iWindowFunctions pointer.
552 It is not intended for user derivation.
558 /** Activates the graphics context.
560 This function should be called to enable drawing in the CAnim-derived classes'
561 Command(), CommandReplyL(), Animate(), or FocusChanged() functions.
563 Note: this function is called automatically by the animation DLL framework in the
564 Redraw() function. */
565 virtual void ActivateGc()=0;
566 /** Sets the rectangle that this animation is to draw to.
568 This function must be called as part of the initialisation/construction of
569 the CAnim-derived object, i.e. in CAnim::ConstructL(). This is so that the
570 window server knows which area the animation is operating in.
572 @param aRect The rectangle to be drawn to. */
573 virtual void SetRect(const TRect &aRect)=0;
574 /** Gets the window size.
576 @return The window size, in pixels. */
577 virtual TSize WindowSize() const=0;
578 /** Tests whether to draw the animation.
580 If the window is completely hidden, there is normally no need to draw
581 the animation. However in some conditions the animation should be drawn even
582 if it is obscured. The window server is aware of these cases, and returns
583 ETrue if it is not safe to draw the animation.
585 @return True if the window is completely hidden and there is no requirement
586 to continue drawing the animation, otherwise false. */
587 virtual TBool IsHidden()=0;
588 /** Sets the visibility of the window the animation is drawing to.
590 This does the same as RWindowBase::SetVisible().
592 @param aState True for visible, false otherwise. */
593 virtual void SetVisible(TBool aState)=0;
594 /** Forces a redraw of a rectangular part of the window.
596 The function causes a redraw message on the part of the window specified,
597 which provides a non-immediate way to do drawing.
599 It can be used to redraw the whole of the window, not just the part used by
602 @param aRect The rectangle to be redrawn. These co-ordinates are relative
603 to the origin of the window. */
604 virtual void Invalidate(const TRect &aRect)=0;
605 /** Gets window information.
607 @param aData The window information. */
608 virtual void Parameters(TWindowInfo &aData)=0;
609 /** Gets the visible region.
611 This region is the area of the visible window which
612 is currently unshadowed. If there is not enough memory to calculate this region
613 then aRegion's error flag is set.
615 @param aRegion The visible region. */
616 virtual void VisibleRegion(TRegion& aRegion)=0;
617 //virtual void CopyScreen(CFbsBitGc *aBitmapGc,TRect aRect)=0;
619 virtual void Reserved() const;
620 virtual void Reserved1() const;
621 virtual void Reserved2() const;
622 virtual void Reserved3() const;
626 class MAnimFreeTimerWindowFunctions : public MAnimWindowFunctions
627 /** Free timer animation utility functions interface.
629 The class inherits functions from MAnimWindowFunctions, and defines the additional
630 interface required for window operations which support animations with their
633 You do NOT have to create an object of this type. The class is implemented
634 by the window server, and provides utility functions to all CFreeTimerWindowAnim
635 derived classes via the WindowFunctions() member.
637 It is not intended for user derivation.
643 /** Deactivates the graphics context.
645 This function is used in the context of a CFreeTimerWindowAnim derived class
646 when writing animation DLLs with their own timer. Within the timer's RunL(),
647 the ActivateGc() function should be called prior to drawing to the window.
648 DeactivateGc() should be called after drawing is finished. */
649 virtual void DeactivateGc()=0;
650 /** Forces the screen to update. */
651 virtual void Update()=0;
653 virtual void Reserved3() const;
656 class MAnimSpriteFunctions
657 /** Sprite animation utility functions interface.
659 The interface includes functions for querying and manipulating a sprite.
661 You do NOT have to create an object of this type. The class is implemented
662 by the window server, and provides utility functions to all CSpriteAnim derived
663 classes via the CSpriteAnim::iSpriteFunctions pointer.
665 It is not intended for user derivation.
671 /** Gets sprite member data.
673 Each member of the sprite is effectively a bitmap, which is displayed for a
674 different amount of time.
676 @param aMember The index of the sprite member for which information is required.
677 @return A pointer to the sprite member. */
678 virtual TSpriteMember *GetSpriteMember(TInt aMember) const=0;
679 /** Redraws part of a sprite.
683 The updates a sprite on the screen, possibly after the bitmap for a particular
684 sprite member has been changed.
686 Two types of redraw are possible. A full update takes the bitmap off the screen
687 and then re-draws it. This is 'safe' in that the screen always reflects
688 the contents of the sprite bitmap. However it can result in flicker. Use the
689 aRect parameter to specify the (small) part of the sprite which has been changed,
690 then any flicker will only occur in this rectangle.
692 A full update is required if you have removed pixels from the mask, i.e. made
693 pixels in the sprite transparent when they were not before. If drawing is
694 additive, e.g. you are using a mask or the draw mode is EDrawModePEN, a partial
695 update is possible. Otherwise the aFullUpdate argument is ignored and a full
696 update is always done.
698 Note: if the sprite member aMember is not visible then there is no need for a change
699 to the display, so the aRect and aFullUpdate parameters are ignored.
701 param aMember The index of the sprite member that is to be updated.
702 param aRect The part of the sprite member which has changed.
703 param aFullUpdate ETrue for a full update, EFalse otherwise.
707 Updates a sprite on the screen, possibly after the bitmap for a particular
708 sprite member has been changed.
710 Use the aRect parameter to specify the (small) part of the sprite which has been changed,
711 then any flicker will only occur in this rectangle.
713 A full update used to be required if you had removed pixels from the mask, i.e. made
714 pixels in the sprite transparent when they were not before. If drawing is
715 additive, e.g. you are using a mask or the draw mode is EDrawModePEN, a partial
716 update used to be possible. But newer versions of the window-server always do full back to front rendering.
718 Note: if the sprite member aMember is not visible then there is no need for a change
719 to the display, so the aRect and aFullUpdate parameters are ignored.
721 @param aMember The index of the sprite member that is to be updated.
722 @param aRect The part of the sprite member which has changed.
723 @param aFullUpdate Not used. Wserv now always do full back to front rendering. */
724 virtual void UpdateMember(TInt aMember,const TRect& aRect,TBool aFullUpdate)=0;
725 /** Turns a sprite on or off.
727 In effect this makes the sprite bitmap visible.
729 @param aActive ETrue to turn sprite on. EFalse to turn it off. */
730 virtual void Activate(TBool aActive)=0;
731 /** Finishes constructing the sprite.
733 It also sets the currently displayed sprite member to zero.
735 This function must be called after members change size. */
736 virtual void SizeChangedL()=0;
737 /** Set the sprite's position.
739 @param aPos The new position of the sprite. */
740 virtual void SetPosition(const TPoint &aPos)=0;
742 virtual void Reserved() const;
744 /** Returns the visibility of the sprite.
746 A sprite can be seen if it is neither obscured by another window nor hidden.
748 @return ETrue if the sprite can be seen, EFalse otherwise. */
749 virtual TBool SpriteCanBeSeen() const = 0;
751 virtual void Reserved2() const;
752 virtual void Reserved3() const;
753 virtual void Reserved4() const;
757 class CAnimGc : public CBitmapContext
758 /** Animation graphics context.
760 An object of this type is linked into CAnim by the window server, which allows
761 you to draw to the animation window. The object's functions allow you to set
762 and cancel the clipping region, and to draw to the visible window using
763 the inherited CBitmapContext functions.
769 /** Sets the clipping region.
771 Only the parts of the animation which are within the clipping region are drawn.
773 @param aRegion The clipping region. */
774 virtual TInt SetClippingRegion(const TRegion &aRegion)=0;
775 /** Cancels the clipping region.
777 @see SetClippingRegion() */
778 virtual void CancelClippingRegion()=0;
781 class CWsAnim; // Forward ref for friend declaration
784 class CAnim : public CBase , public MEventHandler
785 /** Server side animated object base interface.
787 Animations implement this interface, which is called by the window server
788 to pass commands from clients, perform a step in the animation, or to pass
789 window server events (if required) so that the animation can handle them
790 before the application.
792 The functions are all pure virtual, and must be implemented in
793 the derived class to provide server side behaviour. The functions will be
794 called by the window server with optional arguments passed in from the client
795 side animation class RAnim.
797 You should derive from CWindowAnim, CFreeTimerWindowAnim or CSpriteAnim,
798 depending on whether the animation is to draw to a sprite or a window,
799 rather than directly from this class.
801 The derived class is constructed in the DLL factory class CAnimDll::CreateInstanceL()
804 The operation to perform an animation step is called by the window server
805 on a timer. The timing properties are set through an MAnimGeneralFunctions
806 member, which also provides other utility functions.
812 /** Implements client-side initiated commands, returning a value.
814 The window server calls this function in response to application calls to
815 the client side command function RAnim::CommandReplyL(). The arguments passed
816 to the function by the window server are the same as were used on the client
819 This function returns values to the client side, and should be used to return
820 error codes for commands which might leave.
822 @param aOpcode Opcode understood by the class.
823 @param aArgs Arguments packaged on the client side, for example as a struct
824 of a type determined by the aOpcode argument. These mirror the aArgs argument
825 passed in to RAnim::CommandReply().
826 @return Value passed back to client side function when this function completes.
827 Typically this would be KErrNone or another of the system-wide error codes.
828 However any value may be returned to the client side.
830 virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs)=0;
831 /** Implements client-side initiated commands.
833 The window server calls this function in response to application calls to
834 the client side command function RAnim::Command(). The arguments passed to
835 the function by the window server are the same as were used on the client
838 Because this function does not return errors, it is not safe for commands
841 @param aOpcode Opcode understood by the class
842 @param aArgs Arguments packaged on the client side, for example as a struct
843 of a type determined by the aOpcode argument. These mirror the aArgs argument
844 passed in to RAnim::Command().
846 virtual void Command(TInt aOpcode, TAny *aArgs)=0;
847 /** Main animation function, called by the window server.
849 The drawing code which implements a given animation should be provided here.
851 This function is called at a frequency determined by the SetSync() helper
852 function. Note that if sync is not set, then this function will never be
853 called. This effect can be exploited to use the animation framework, with
854 its server side speed, for what are strictly not animations, e.g. for streaming
857 The aDateTime parameter will be null if the current time (as determined by
858 the window server) matches the time implied by the sync period, modulo normalisation,
859 otherwise it will contain a valid (non-normalised) time.
861 Normalisation is to some specified granularity, for example if one minute
862 is specified as the animation frequency, then in effect the window server
863 will decide whether the implied time is correct to the minute, but not to
866 Implied time is the time implied by the (normalised) actual time of the previous
867 animation call plus the sync interval. For example if the last call was at
868 time 't' and the sync interval is 1 second then if the time at this call
869 is t + 1 second, then actual time and implied time match and the value placed
870 into aDateTime will be NULL.
872 Cases in which the two may not match include, for example, system time having
873 been reset between animation calls (perhaps British Summer Time or other daylight
874 saving time has just come into effect). The intention is that when system
875 time changes, a mechanism is provided to alert the animation code and allow
876 it to reset itself. The assumption is that somewhere in its initialisation
877 code, the animation will have performed a CAnimFunctions utility call to set
878 a base time, which is then implicitly tracked by incrementing by a suitable
879 interval; when aDateTime is non-NULL after a call to Animate(), base time
882 @param aDateTime Null if the current time w.r.t. the window server matches
883 the time implied by the synch period. Otherwise a valid (non-normalised) time. */
884 virtual void Animate(TDateTime *aDateTime)=0;
885 virtual void HandleNotification(const TWsEvent& /*aEvent*/) {};
888 virtual void Reserved1() const {};
889 virtual void Reserved2() const {};
890 virtual void Reserved3() const {};
892 /** Pointer to a class containing functions implemented by the window server.
894 These are available to any CAnim derived class.
896 Note that this value is automatically set for you by the animation framework.
897 You do not need to assign a value to this pointer.
900 MAnimGeneralFunctions *iFunctions;
901 friend class CWsAnim;
902 friend class CWindowAnim;
903 friend class CSpriteAnim;
907 class CWindowAnim : public CAnim
908 /** Window animation interface.
910 This interface is provided to create animations other than sprites. A window
911 animation can be provided by deriving from this class.
913 The interface inherits from CAnim and has access to its functions. It additionally
914 can access an interface for querying and manipulating the window in which
915 the animation takes place, using its iWindowFunctions member.
917 The derived class is constructed in the DLL factory class CAnimDll::CreateInstanceL().
921 @see CFreeTimerWindowAnim
925 /** Server side construction and initialisation of an animation class.
927 Note: the aHasFocus argument allows the animation to start in a known focus state.
928 For example, an animation may or may not have focus, depending on how it was
929 started. Together with the FocusChanged() function, this allows an animation
930 to always know its focus state.
932 @param aArgs Packaged arguments which may be required during construction.
933 These are transferred from the aParams argument of the client side constructor's
935 @param aHasFocus Specifies whether or not the animation has window server focus. */
936 virtual void ConstructL(TAny *aArgs, TBool aHasFocus)=0;
937 /** Redraws the objects.
939 The function is called by the window server when it needs to redraw the object.
940 The object must provide all the low level drawing code. */
941 virtual void Redraw()=0;
942 /** Notifies change of focus.
944 The function is called by the window server to notify a change of focus,
945 allowing the animation code to track whether it does or does not have focus,
946 and to change its appearance accordingly.
948 @param aState Indicates whether the focus has or has not changed. */
949 virtual void FocusChanged(TBool aState)=0;
951 /** Protected constructor.
953 Prevents objects of this class being directly constructed. */
954 inline CWindowAnim() {}
956 virtual void ReservedW1() const {};
957 virtual void ReservedW2() const {};
959 /** Pointer to a class containing functions implemented by the window server.
961 These are available to any CWindowAnim-derived class.
963 Note that this and the iGc pointer are automatically set for you by the
964 animation framework - you do not need to assign a value to them.*/
965 MAnimWindowFunctions *iWindowFunctions;
966 /** Pointer to the graphics context. */
968 friend class CWsAnim;
972 class CFreeTimerWindowAnim : public CWindowAnim
973 /** Free timer animation interface.
975 This interface allows animations to have their own timers or other active
976 objects, and to draw to the window when the timer completes. The implication
977 of this is that animations derived from this class can have an extremely short
978 user-defined time between calls to the Animate() function, unlike the
979 other animation classes, which are tied to the (approximately) half second
982 The interface inherits from CWindowAnim and has access to its functions. It
983 additionally can access functions declared in the MAnimFreeTimerWindowFunctions
984 interface, using WindowFunctions().
986 In order to draw to the window inside the RunL() of your own timer, you will
987 need call the ActivateGc() function before doing any drawing, and the DeactivateGc()
988 function after finishing the drawing.
995 inline MAnimFreeTimerWindowFunctions* WindowFunctions()
996 /** Gets the free timer utility functions.
998 These functions include all the MAnimWindowFunctions,
999 and additional functions to deactivate the graphics context and to force the
1002 @return A pointer to the free timer utility functions. */
1003 {return STATIC_CAST(MAnimFreeTimerWindowFunctions*,iWindowFunctions);}
1005 virtual void ReservedF1() const {};
1009 class CSpriteAnim : public CAnim
1010 /** Sprite animation interface.
1012 Sprites are bitmaps that can overlay a window or the screen. A sprite animation
1013 can be provided by deriving from this class.
1015 The interface inherits from CAnim and has access to its functions. It additionally
1016 can access an interface for querying and manipulating a sprite, using its
1017 iSpriteFunctions member.
1019 The derived class is constructed in the DLL factory class CAnimDll::CreateInstanceL()
1024 @see CFreeTimerWindowAnim
1028 /** Server side construction and initialisation of an animation class.
1030 @param aArgs Packaged arguments which may be required during construction.
1031 These are transferred from the aParams argument of the client side constructor's
1032 RAnim::Construct(). */
1033 virtual void ConstructL(TAny *aArgs)=0;
1035 inline CSpriteAnim()
1036 /** Protected constructor.
1038 Ensures that only derived classes can be constructed. */
1041 virtual void ReservedS1() const {};
1042 virtual void ReservedS2() const {};
1044 /** Pointer to a class containing functions implemented by the window server.
1046 These are available to any CSpriteAnim-derived class.
1048 Note that this value is automatically set for you by the animation framework.
1049 You do not need to assign a value to this pointer. */
1050 MAnimSpriteFunctions *iSpriteFunctions;
1051 friend class CWsAnim;
1055 class CAnimDll : public CBase
1056 /** Animation DLL factory interface.
1058 An animation DLL class must be a derived class of CAnimDll, and can be thought
1059 of as a server side factory class. CAnimDll consists of a single pure virtual
1060 factory function, CreateInstanceL(TInt aType), which is used to create new
1061 instances of animation objects of type CAnim contained in the DLL. Animation
1062 DLL objects are created by the CreateCAnimDllL() function, which is called
1063 by the window server at the request of the client.
1065 For efficiency reasons, it makes sense to collect multiple animation classes
1066 into a single DLL, even if they are otherwise logically quite separate classes.
1072 /** Factory function for animation DLLs.
1074 It must be provided in the derived class.
1076 The parameter can be used to differentiate between multiple animation
1077 classes contained in the same animation DLL.
1079 @param aType Identifies an animation class to be constructed. This is the
1080 same value as the aType argument of the client side animation constructor
1081 RAnim::Construct(). It is passed from the client side by the animation framework.
1082 @return Pointer to a CAnim-derived animation class object. */
1083 virtual CAnim *CreateInstanceL(TInt aType)=0;