|
Nokia N97 SDK Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : graphicsappview.h 00004 * Part of : graphics 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 __GRAPHICSAPPVIEW_H__ 00017 #define __GRAPHICSAPPVIEW_H__ 00018 00019 // INCLUDES 00020 #include <coecntrl.h> 00021 #include <eikenv.h> 00022 #include <AknIconUtils.h> 00023 00024 // FORWARD DECLARATIONS 00025 class CIconFileProvider; 00026 class CSprite; 00027 00028 namespace 00029 { 00030 const TInt KInitialXSpeed = 4; 00031 const TInt KInitialYSpeed = 4; 00032 _LIT ( KMultiBitmapFilename,"GraphicsAppImages.mbm" ); 00033 } 00034 00035 /** 00036 * CGraphicsAppView view class. 00037 * An instance of this class is the Application View object 00038 * for the Graphics example application 00039 */ 00040 class CGraphicsAppView : public CCoeControl 00041 { 00042 public: // Constructors and destructor 00043 /** 00044 * NewL. 00045 * Two-phased constructor. 00046 * Create a CGraphicsAppView object, which will draw itself to aRect. 00047 * @param aRect The rectangle this view will be drawn to. 00048 * @return a pointer to the created instance of CGraphicsAppView. 00049 */ 00050 static CGraphicsAppView* NewL( const TRect& aRect ); 00051 00052 /** 00053 * NewLC. 00054 * Two-phased constructor. 00055 * Create a CGraphicsAppView object, which will draw itself to aRect. 00056 * @param aRect Rectangle this view will be drawn to. 00057 * @return A pointer to the created instance of CGraphicsAppView. 00058 */ 00059 static CGraphicsAppView* NewLC( const TRect& aRect ); 00060 00061 /** 00062 * ~CGraphicsAppView 00063 * Virtual Destructor. 00064 */ 00065 virtual ~CGraphicsAppView(); 00066 00067 public: // New functions 00068 00069 /** 00070 * StartOffScreenDemo 00071 * Start demo using off-screen bitmap. 00072 */ 00073 void StartOffScreenDemo(); 00074 00075 /** 00076 * StartNoOffScreenDemo 00077 * Start demo without using off-screen bitmap. 00078 */ 00079 void StartNoOffScreenDemo(); 00080 00081 /** 00082 * StopDemo 00083 * Stop animation. 00084 */ 00085 void StopDemo(); 00086 00087 private: // Functions from base classes 00088 00089 /** 00090 * From CCoeControl, Draw 00091 * Draw this CGraphicsAppView to the screen. 00092 * @param aRect the rectangle of this view that needs updating 00093 */ 00094 void Draw( const TRect& aRect ) const; 00095 00096 void HandleResourceChange(TInt aType, const TRect& aRect); 00097 00098 private: // Constructors 00099 00100 /** 00101 * ConstructL 00102 * 2nd phase constructor. 00103 * Perform the second phase construction of a CGraphicsAppView object 00104 * @param aRect The rectangle this view will be drawn to. 00105 */ 00106 void ConstructL( const TRect& aRect ); 00107 00108 /** 00109 * CGraphicsAppView. 00110 * C++ default constructor. 00111 */ 00112 CGraphicsAppView(); 00113 00114 private: // New functions 00115 00116 /** 00117 * DoPeriodTask. 00118 * Called by period task static function. 00119 */ 00120 void DoPeriodTask(); 00121 00122 /** 00123 * Period. 00124 * Call back function for a periodic timer 00125 * @param aPtr a parameter passed to the timer when the timer is started. 00126 * @return Value TRUE indicates the callback should be done again. 00127 */ 00128 static TInt Period( TAny* aPtr ); 00129 00130 /** 00131 * UpdateDisplay. 00132 * Perfom the drawing, does not activate the GC. 00133 */ 00134 void UpdateDisplay() const; 00135 00136 /** 00137 * SetUpSpritesL. 00138 * Initialise the objects being drawn. 00139 */ 00140 void SetUpSpritesL(); 00141 00142 /** 00143 * StartTimer. 00144 * Start the timer. 00145 */ 00146 void StartTimer(); 00147 00148 /** 00149 * ScaleImages 00150 * Scales background and sprite according to current layout. 00151 */ 00152 void ScaleImages(); 00153 00154 private: // Data 00155 00156 /** 00157 * iBackgroundImage 00158 * The background bitmap 00159 * Owned by CGraphicsAppView object. 00160 */ 00161 CFbsBitmap* iBackgroundImage; 00162 00163 /** 00164 * iSpriteImage 00165 * The "sprite" bitmap image 00166 * Owned by CGraphicsAppView object. 00167 */ 00168 CFbsBitmap* iSpriteImage; 00169 00170 /** 00171 * iSpriteMask 00172 * The "sprite" bitblit mask 00173 * Owned by CGraphicsAppView object. 00174 */ 00175 CFbsBitmap* iSpriteMask; 00176 00177 /** 00178 * iSpriteImage 00179 * The "sprite" bitmap image 00180 * Owned by CGraphicsAppView object. 00181 */ 00182 CFbsBitmap* iSpriteImage2; 00183 00184 /** 00185 * iSpriteMask 00186 * The "sprite" bitblit mask 00187 * Owned by CGraphicsAppView object. 00188 */ 00189 CFbsBitmap* iSpriteMask2; 00190 00191 /** 00192 * iOffScreenBitmap 00193 * The off screen bitmap 00194 * Owned by CGraphicsAppView object. 00195 */ 00196 CFbsBitmap* iOffScreenBitmap; 00197 00198 /** 00199 * iOffScreenBitmapDevice 00200 * The off screen bitmap device 00201 * Owned by CGraphicsAppView object. 00202 */ 00203 CFbsBitmapDevice* iOffScreenBitmapDevice; 00204 00205 /** 00206 * iOffScreenBitmapGc 00207 * The off screen bitmap gc 00208 * Owned by CGraphicsAppView object. 00209 */ 00210 CFbsBitGc* iOffScreenBitmapGc; 00211 00212 /** 00213 * iPeriodicTimer 00214 * The periodic timer used to control the animation 00215 * Owned by CGraphicsAppView object. 00216 */ 00217 CPeriodic* iPeriodicTimer; 00218 00219 /** 00220 * iUsingOffScreenBitmap 00221 * The flag to keep track of whether or not the demo is 00222 * using an off screen bitmap 00223 */ 00224 TBool iUsingOffScreenBitmap; 00225 00226 /** 00227 * iSprites 00228 * The array of sprites to be drawn 00229 * Owned by CGraphicsAppView object. 00230 */ 00231 CArrayPtrFlat<CSprite>* iSprites; 00232 00233 RFs iFsSession; 00234 CIconFileProvider* iIconProvider; 00235 }; 00236 00237 #endif // __GRAPHICSAPPVIEW_H__ 00238 00239 // End of File
|
© Nokia 2009 |