Nokia N97 SDK
Example Applications Guide

serverimage.h

00001 /*
00002 * ==============================================================================
00003 *  Name        : serverimage.h
00004 *  Part of     : Animation example
00005 *  Interface   :
00006 *  Description :
00007 *  Version     :
00008 *
00009 *  Copyright (c) 2004 - 2006 Nokia Corporation.
00010 *  This material, including documentation and any related
00011 *  computer programs, is protected by copyright controlled by
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 #ifndef __SERVERIMAGE_H__
00017 #define __SERVERIMAGE_H__
00018 
00019 // INCLUDES
00020 #include <w32adll.h>
00021 #include "servertimeoutnotify.h"
00022 
00023 // CONSTANTS
00024 
00025 // Pixels the animation moves each timer event
00026 static const TInt KStepSize = 1;
00027 
00028 // Request a reset of the bouncing square
00029 static const TInt KAnimationReset  = 1;
00030 static const TInt KResolutionChange = 2;
00031 
00032 // The timer timeout resolution is different in the WINS and MARM platforms.
00033 // Under wins it is 1/10s, under marm it is 1/64s, also on both platforms it
00034 // takes a different time to draw the object.
00035 #ifdef __WINS__
00036 static const TInt KTimerPeriod = 10000;
00037 #else
00038 static const TInt KTimerPeriod = 150000;
00039 #endif
00040 
00041 
00042 // FORWARD DECLARATIONS
00043 class CTimeOutTimer;
00044 
00045 // CLASS DECLARATION
00046 
00047 /**
00048 * CImage.
00049 * An instance of class CImage encapsulates the functionality
00050 * of the bouncing square on the screen.
00051 */
00052 class CImage : public CWindowAnim, public MTimeoutNotify
00053     {
00054 
00055     public:  // Constructors and destructors
00056 
00057         /**
00058         * CImage()
00059         * Construct the object, forced to be public.
00060         */
00061         CImage();
00062 
00063         /**
00064         * ~CImage()
00065         * Virtual destructor.
00066         */
00067         virtual ~CImage();
00068 
00069     public:  // From CWindowAnim
00070 
00071         /**
00072         * ConstructL()
00073         * Complete animation server object construction
00074         * (called by windows server).
00075         * @param aArgs any arguments required during construction
00076         * (passed from client through window server)
00077         * @param aHasFocus true if the animation has window server focus.
00078         */
00079         void ConstructL( TAny* aArgs, TBool aHasFocus );
00080 
00081         /**
00082         * CommandReplyL()
00083         * Perform aCommand with optional additional arguments aArgs and
00084         * return a reply (called by windows server).
00085         * Note! This method can return an error, so any actions that can leave
00086         * should use this method and not Command ().
00087         * This command is not buffered and so requests from the client side are
00088         * performed immediately.  For these reason these functions should
00089         * not take a long time.
00090         * @param aCommand the command to perform
00091         * @param aArgs any additional arguments required.
00092         */
00093         TInt CommandReplyL( TInt aCommand, TAny* aArgs );
00094 
00095         /**
00096         * Command()
00097         * Perform aCommand with optional additional arguments aArgs.
00098         * Note! Because there is no way to return an error from this method, it
00099         * is important that these commands should not be able to fail or leave.
00100         * This command is buffered and so may have been requested by the client
00101         * side an unknown period ago.
00102         * @param aCommand the command to perform
00103         * @param aArgs any additional arguments required
00104         */
00105         void Command( TInt aCommand, TAny* aArgs );
00106 
00107         /**
00108         * Redraw()
00109         * Redraw the animation object, called by the Windows Server.
00110         */
00111         void Redraw();
00112 
00113         /**
00114         * Animate()
00115         * Animate the object, normally called by the Windows Server
00116         * at a fixed period
00117         */
00118         void Animate( TDateTime* aDateTime );
00119 
00120         /**
00121         * FocusChanged()
00122         * Handle the event when the focus changes.
00123         * @param aState TRUE if the Animation Server has focus
00124         */
00125         void FocusChanged( TBool aState );
00126 
00127         /**
00128         * OfferRawEvent()
00129         * For handling raw events. Not used in this example so return false.
00130         */
00131         TBool OfferRawEvent( const TRawEvent &aRawEvent );
00132 
00133     public: // From MTimeoutNotify
00134 
00135         /**
00136         * TimedOut()
00137         * Handle timer time out
00138         */
00139         void TimedOut();
00140 
00141     private: // Data
00142 
00143         /**
00144         * iServerTimer
00145         * Animation timer object
00146         * Owned by CImage object.
00147         */
00148         CTimeOutTimer* iServerTimer;
00149 
00150         /**
00151         * iNewPoint
00152         * The square's current position
00153         */
00154         TPoint iNewPoint;
00155 
00156         /**
00157         * iLastPoint
00158         * The square's last position
00159         */
00160         TPoint iLastPoint;
00161 
00162         /**
00163         * iSize
00164         * The square's size
00165         */
00166         TSize iSize;
00167 
00168         /**
00169         * iScreenSize
00170         * The screen size
00171         */
00172         TRect iScreenSize;
00173 
00174         /**
00175         * iAnimationReset
00176         * Should the animation be reset back to the beginning
00177         */
00178         TBool iAnimationReset;
00179 
00180         /**
00181         * iDrawn
00182         * Has the animation been drawn
00183         */
00184         TBool iDrawn;
00185 
00186         /**
00187         * iDeltaX
00188         * x coordinate step
00189         */
00190         TBool iDeltaX;
00191 
00192         /**
00193         * iDeltaY
00194         * y coordinate step
00195         */
00196         TBool iDeltaY;
00197     };
00198 
00199 #endif // __SERVERIMAGE_H__
00200 
00201 // End of File

© Nokia 2009

Back to top