1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _SV_ANIMATE_HXX 25 #define _SV_ANIMATE_HXX 26 27 #include <vcl/dllapi.h> 28 #include <vcl/timer.hxx> 29 #include <vcl/bitmapex.hxx> 30 31 // ----------- 32 // - Defines - 33 // ----------- 34 35 #define ANIMATION_TIMEOUT_ON_CLICK 2147483647L 36 37 // --------- 38 // - Enums - 39 // --------- 40 41 enum Disposal 42 { 43 DISPOSE_NOT, 44 DISPOSE_BACK, 45 DISPOSE_FULL, 46 DISPOSE_PREVIOUS 47 }; 48 49 enum CycleMode 50 { 51 CYCLE_NOT, 52 CYCLE_NORMAL, 53 CYCLE_FALLBACK, 54 CYCLE_REVERS, 55 CYCLE_REVERS_FALLBACK 56 }; 57 58 // ------------------- 59 // - AnimationBitmap - 60 // ------------------- 61 62 struct VCL_DLLPUBLIC AnimationBitmap 63 { 64 BitmapEx aBmpEx; 65 Point aPosPix; 66 Size aSizePix; 67 long nWait; 68 Disposal eDisposal; 69 sal_Bool bUserInput; 70 AnimationBitmapAnimationBitmap71 AnimationBitmap() {} AnimationBitmapAnimationBitmap72 AnimationBitmap( const BitmapEx& rBmpEx, const Point& rPosPix, 73 const Size& rSizePix, long _nWait = 0L, 74 Disposal _eDisposal = DISPOSE_NOT ) : 75 aBmpEx ( rBmpEx ), 76 aPosPix ( rPosPix ), 77 aSizePix ( rSizePix ), 78 nWait ( _nWait ), 79 eDisposal ( _eDisposal ), 80 bUserInput ( sal_False ) {} 81 operator ==AnimationBitmap82 sal_Bool operator==( const AnimationBitmap& rAnimBmp ) const 83 { 84 return( rAnimBmp.aBmpEx == aBmpEx && 85 rAnimBmp.aPosPix == aPosPix && 86 rAnimBmp.aSizePix == aSizePix && 87 rAnimBmp.nWait == nWait && 88 rAnimBmp.eDisposal == eDisposal && 89 rAnimBmp.bUserInput == bUserInput ); 90 } 91 operator !=AnimationBitmap92 sal_Bool operator!=( const AnimationBitmap& rAnimBmp ) const { return !( *this == rAnimBmp ); } 93 IsEqualAnimationBitmap94 sal_Bool IsEqual( const AnimationBitmap& rAnimBmp ) const 95 { 96 return( rAnimBmp.aPosPix == aPosPix && 97 rAnimBmp.aSizePix == aSizePix && 98 rAnimBmp.nWait == nWait && 99 rAnimBmp.eDisposal == eDisposal && 100 rAnimBmp.bUserInput == bUserInput && 101 rAnimBmp.aBmpEx.IsEqual( aBmpEx ) ); 102 } 103 104 sal_uLong GetChecksum() const; 105 }; 106 107 // ------------------- 108 // - AnimationBitmap - 109 // ------------------- 110 111 struct AInfo 112 { 113 Bitmap aLastSaveBitmap; 114 Bitmap aBackBitmap; 115 Rectangle aClipRect; 116 Size aLastSaveSize; 117 Point aLastSavePoint; 118 Point aStartOrg; 119 Size aStartSize; 120 OutputDevice* pOutDev; 121 void* pViewData; 122 long nExtraData; 123 sal_Bool bWithSize; 124 sal_Bool bPause; 125 AInfoAInfo126 AInfo() : pOutDev( NULL ), 127 pViewData( NULL ), 128 nExtraData( 0L ), 129 bWithSize( sal_False ), 130 bPause( sal_False ) {} 131 }; 132 133 // ------------------- 134 // - AnimationBitmap - 135 // ------------------- 136 137 class VCL_DLLPUBLIC Animation 138 { 139 SAL_DLLPRIVATE static sal_uLong mnAnimCount; 140 141 List maList; 142 List maAInfoList; 143 Link maNotifyLink; 144 BitmapEx maBitmapEx; 145 Timer maTimer; 146 Size maGlobalSize; 147 List* mpViewList; 148 void* mpExtraData; 149 long mnLoopCount; 150 long mnLoops; 151 long mnPos; 152 Disposal meLastDisposal; 153 CycleMode meCycleMode; 154 sal_Bool mbFirst; 155 sal_Bool mbIsInAnimation; 156 sal_Bool mbWithSize; 157 sal_Bool mbLoopTerminated; 158 sal_Bool mbIsWaiting; 159 160 //#if 0 // _SOLAR__PRIVATE 161 162 SAL_DLLPRIVATE void ImplRestartTimer( sal_uLong nTimeout ); 163 DECL_DLLPRIVATE_LINK( ImplTimeoutHdl, Timer* ); 164 165 public: 166 ImplIncAnimCount()167 SAL_DLLPRIVATE static void ImplIncAnimCount() { mnAnimCount++; } ImplDecAnimCount()168 SAL_DLLPRIVATE static void ImplDecAnimCount() { mnAnimCount--; } ImplGetCurPos() const169 SAL_DLLPRIVATE sal_uLong ImplGetCurPos() const { return mnPos; } 170 171 //#endif 172 173 public: 174 Animation(); 175 Animation( const Animation& rAnimation ); 176 ~Animation(); 177 178 Animation& operator=( const Animation& rAnimation ); 179 sal_Bool operator==( const Animation& rAnimation ) const; operator !=(const Animation & rAnimation) const180 sal_Bool operator!=( const Animation& rAnimation ) const { return !(*this==rAnimation); } 181 182 sal_Bool IsEqual( const Animation& rAnimation ) const; 183 184 sal_Bool IsEmpty() const; 185 void SetEmpty(); 186 187 void Clear(); 188 189 sal_Bool Start( OutputDevice* pOutDev, const Point& rDestPt, long nExtraData = 0, 190 OutputDevice* pFirstFrameOutDev = NULL ); 191 sal_Bool Start( OutputDevice* pOutDev, const Point& rDestPt, const Size& rDestSz, long nExtraData = 0, 192 OutputDevice* pFirstFrameOutDev = NULL ); 193 void Stop( OutputDevice* pOutDev = NULL, long nExtraData = 0 ); 194 195 void Draw( OutputDevice* pOutDev, const Point& rDestPt ) const; 196 void Draw( OutputDevice* pOutDev, const Point& rDestPt, const Size& rDestSz ) const; 197 IsInAnimation() const198 sal_Bool IsInAnimation() const { return mbIsInAnimation; } 199 sal_Bool IsTransparent() const; IsTerminated() const200 sal_Bool IsTerminated() const { return mbLoopTerminated; } 201 GetDisplaySizePixel() const202 const Size& GetDisplaySizePixel() const { return maGlobalSize; } SetDisplaySizePixel(const Size & rSize)203 void SetDisplaySizePixel( const Size& rSize ) { maGlobalSize = rSize; } 204 GetBitmapEx() const205 const BitmapEx& GetBitmapEx() const { return maBitmapEx; } SetBitmapEx(const BitmapEx & rBmpEx)206 void SetBitmapEx( const BitmapEx& rBmpEx ) { maBitmapEx = rBmpEx; } 207 GetLoopCount() const208 sal_uLong GetLoopCount() const { return mnLoopCount; } 209 void SetLoopCount( const sal_uLong nLoopCount ); 210 void ResetLoopCount(); 211 212 void SetCycleMode( CycleMode eMode ); GetCycleMode() const213 CycleMode GetCycleMode() const { return meCycleMode; } 214 SetNotifyHdl(const Link & rLink)215 void SetNotifyHdl( const Link& rLink ) { maNotifyLink = rLink; } GetNotifyHdl() const216 const Link& GetNotifyHdl() const { return maNotifyLink; } 217 Count() const218 sal_uInt16 Count() const { return (sal_uInt16) maList.Count(); } 219 sal_Bool Insert( const AnimationBitmap& rAnimationBitmap ); 220 const AnimationBitmap& Get( sal_uInt16 nAnimation ) const; 221 void Replace( const AnimationBitmap& rNewAnimationBmp, sal_uInt16 nAnimation ); 222 GetAInfoList()223 List* GetAInfoList() { return &maAInfoList; } 224 sal_uLong GetSizeBytes() const; 225 sal_uLong GetChecksum() const; 226 227 public: 228 229 sal_Bool Convert( BmpConversion eConversion ); 230 sal_Bool ReduceColors( sal_uInt16 nNewColorCount, 231 BmpReduce eReduce = BMP_REDUCE_SIMPLE ); 232 sal_Bool Invert(); 233 sal_Bool Mirror( sal_uLong nMirrorFlags ); 234 sal_Bool Dither( sal_uLong nDitherFlags = BMP_DITHER_MATRIX ); 235 sal_Bool Adjust( short nLuminancePercent = 0, 236 short nContrastPercent = 0, 237 short nChannelRPercent = 0, 238 short nChannelGPercent = 0, 239 short nChannelBPercent = 0, 240 double fGamma = 1.0, 241 sal_Bool bInvert = sal_False ); 242 sal_Bool Filter( BmpFilter eFilter, 243 const BmpFilterParam* pFilterParam = NULL, 244 const Link* pProgress = NULL ); 245 246 friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStream, Animation& rAnimation ); 247 friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStream, const Animation& rAnimation ); 248 }; 249 250 #endif // _SV_ANIMATE_HXX 251