00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _SV_ANIMATE_HXX
00029 #define _SV_ANIMATE_HXX
00030
00031 #include <vcl/dllapi.h>
00032 #include <vcl/timer.hxx>
00033 #include <vcl/bitmapex.hxx>
00034
00035
00036
00037
00038
00039 #define ANIMATION_TIMEOUT_ON_CLICK 2147483647L
00040
00041
00042
00043
00044
00045 enum Disposal
00046 {
00047 DISPOSE_NOT,
00048 DISPOSE_BACK,
00049 DISPOSE_FULL,
00050 DISPOSE_PREVIOUS
00051 };
00052
00053 enum CycleMode
00054 {
00055 CYCLE_NOT,
00056 CYCLE_NORMAL,
00057 CYCLE_FALLBACK,
00058 CYCLE_REVERS,
00059 CYCLE_REVERS_FALLBACK
00060 };
00061
00062
00063
00064
00065
00066 struct VCL_DLLPUBLIC AnimationBitmap
00067 {
00068 BitmapEx aBmpEx;
00069 Point aPosPix;
00070 Size aSizePix;
00071 long nWait;
00072 Disposal eDisposal;
00073 BOOL bUserInput;
00074
00075 AnimationBitmap() {}
00076 AnimationBitmap( const BitmapEx& rBmpEx, const Point& rPosPix,
00077 const Size& rSizePix, long _nWait = 0L,
00078 Disposal _eDisposal = DISPOSE_NOT ) :
00079 aBmpEx ( rBmpEx ),
00080 aPosPix ( rPosPix ),
00081 aSizePix ( rSizePix ),
00082 nWait ( _nWait ),
00083 eDisposal ( _eDisposal ),
00084 bUserInput ( FALSE ) {}
00085
00086 BOOL operator==( const AnimationBitmap& rAnimBmp ) const
00087 {
00088 return( rAnimBmp.aBmpEx == aBmpEx &&
00089 rAnimBmp.aPosPix == aPosPix &&
00090 rAnimBmp.aSizePix == aSizePix &&
00091 rAnimBmp.nWait == nWait &&
00092 rAnimBmp.eDisposal == eDisposal &&
00093 rAnimBmp.bUserInput == bUserInput );
00094 }
00095
00096 BOOL operator!=( const AnimationBitmap& rAnimBmp ) const { return !( *this == rAnimBmp ); }
00097
00098 BOOL IsEqual( const AnimationBitmap& rAnimBmp ) const
00099 {
00100 return( rAnimBmp.aPosPix == aPosPix &&
00101 rAnimBmp.aSizePix == aSizePix &&
00102 rAnimBmp.nWait == nWait &&
00103 rAnimBmp.eDisposal == eDisposal &&
00104 rAnimBmp.bUserInput == bUserInput &&
00105 rAnimBmp.aBmpEx.IsEqual( aBmpEx ) );
00106 }
00107
00108 ULONG GetChecksum() const;
00109 };
00110
00111
00112
00113
00114
00115 struct AInfo
00116 {
00117 Bitmap aLastSaveBitmap;
00118 Bitmap aBackBitmap;
00119 Rectangle aClipRect;
00120 Size aLastSaveSize;
00121 Point aLastSavePoint;
00122 Point aStartOrg;
00123 Size aStartSize;
00124 OutputDevice* pOutDev;
00125 void* pViewData;
00126 long nExtraData;
00127 BOOL bWithSize;
00128 BOOL bPause;
00129
00130 AInfo() : pOutDev( NULL ),
00131 pViewData( NULL ),
00132 nExtraData( 0L ),
00133 bWithSize( FALSE ),
00134 bPause( FALSE ) {}
00135 };
00136
00137
00138
00139
00140
00141 class VCL_DLLPUBLIC Animation
00142 {
00143 SAL_DLLPRIVATE static ULONG mnAnimCount;
00144
00145 List maList;
00146 List maAInfoList;
00147 Link maNotifyLink;
00148 BitmapEx maBitmapEx;
00149 Timer maTimer;
00150 Size maGlobalSize;
00151 List* mpViewList;
00152 void* mpExtraData;
00153 long mnLoopCount;
00154 long mnLoops;
00155 long mnPos;
00156 Disposal meLastDisposal;
00157 CycleMode meCycleMode;
00158 BOOL mbFirst;
00159 BOOL mbIsInAnimation;
00160 BOOL mbWithSize;
00161 BOOL mbLoopTerminated;
00162 BOOL mbIsWaiting;
00163
00164
00165
00166 SAL_DLLPRIVATE void ImplRestartTimer( ULONG nTimeout );
00167 DECL_DLLPRIVATE_LINK( ImplTimeoutHdl, Timer* );
00168
00169 public:
00170
00171 SAL_DLLPRIVATE static void ImplIncAnimCount() { mnAnimCount++; }
00172 SAL_DLLPRIVATE static void ImplDecAnimCount() { mnAnimCount--; }
00173 SAL_DLLPRIVATE ULONG ImplGetCurPos() const { return mnPos; }
00174
00175
00176
00177 public:
00178 Animation();
00179 Animation( const Animation& rAnimation );
00180 ~Animation();
00181
00182 Animation& operator=( const Animation& rAnimation );
00183 BOOL operator==( const Animation& rAnimation ) const;
00184 BOOL operator!=( const Animation& rAnimation ) const { return !(*this==rAnimation); }
00185
00186 BOOL IsEqual( const Animation& rAnimation ) const;
00187
00188 BOOL IsEmpty() const;
00189 void SetEmpty();
00190
00191 void Clear();
00192
00193 BOOL Start( OutputDevice* pOutDev, const Point& rDestPt, long nExtraData = 0,
00194 OutputDevice* pFirstFrameOutDev = NULL );
00195 BOOL Start( OutputDevice* pOutDev, const Point& rDestPt, const Size& rDestSz, long nExtraData = 0,
00196 OutputDevice* pFirstFrameOutDev = NULL );
00197 void Stop( OutputDevice* pOutDev = NULL, long nExtraData = 0 );
00198
00199 void Draw( OutputDevice* pOutDev, const Point& rDestPt ) const;
00200 void Draw( OutputDevice* pOutDev, const Point& rDestPt, const Size& rDestSz ) const;
00201
00202 BOOL IsInAnimation() const { return mbIsInAnimation; }
00203 BOOL IsTransparent() const;
00204 BOOL IsTerminated() const { return mbLoopTerminated; }
00205
00206 const Size& GetDisplaySizePixel() const { return maGlobalSize; }
00207 void SetDisplaySizePixel( const Size& rSize ) { maGlobalSize = rSize; }
00208
00209 const BitmapEx& GetBitmapEx() const { return maBitmapEx; }
00210 void SetBitmapEx( const BitmapEx& rBmpEx ) { maBitmapEx = rBmpEx; }
00211
00212 ULONG GetLoopCount() const { return mnLoopCount; }
00213 void SetLoopCount( const ULONG nLoopCount );
00214 void ResetLoopCount();
00215
00216 void SetCycleMode( CycleMode eMode );
00217 CycleMode GetCycleMode() const { return meCycleMode; }
00218
00219 void SetNotifyHdl( const Link& rLink ) { maNotifyLink = rLink; }
00220 const Link& GetNotifyHdl() const { return maNotifyLink; }
00221
00222 USHORT Count() const { return (USHORT) maList.Count(); }
00223 BOOL Insert( const AnimationBitmap& rAnimationBitmap );
00224 const AnimationBitmap& Get( USHORT nAnimation ) const;
00225 void Replace( const AnimationBitmap& rNewAnimationBmp, USHORT nAnimation );
00226
00227 List* GetAInfoList() { return &maAInfoList; }
00228 ULONG GetSizeBytes() const;
00229 ULONG GetChecksum() const;
00230
00231 public:
00232
00233 BOOL Convert( BmpConversion eConversion );
00234 BOOL ReduceColors( USHORT nNewColorCount,
00235 BmpReduce eReduce = BMP_REDUCE_SIMPLE );
00236 BOOL Invert();
00237 BOOL Mirror( ULONG nMirrorFlags );
00238 BOOL Dither( ULONG nDitherFlags = BMP_DITHER_MATRIX );
00239 BOOL Adjust( short nLuminancePercent = 0,
00240 short nContrastPercent = 0,
00241 short nChannelRPercent = 0,
00242 short nChannelGPercent = 0,
00243 short nChannelBPercent = 0,
00244 double fGamma = 1.0,
00245 BOOL bInvert = FALSE );
00246 BOOL Filter( BmpFilter eFilter,
00247 const BmpFilterParam* pFilterParam = NULL,
00248 const Link* pProgress = NULL );
00249
00250 friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStream, Animation& rAnimation );
00251 friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStream, const Animation& rAnimation );
00252 };
00253
00254 #endif // _SV_ANIMATE_HXX