Branch libreoffice-5-0-4
[LibreOffice.git] / include / vcl / animate.hxx
blobdb62836225b9b6941766a4cca5788ec9368b11b7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_ANIMATE_HXX
21 #define INCLUDED_VCL_ANIMATE_HXX
23 #include <vcl/dllapi.h>
24 #include <vcl/timer.hxx>
25 #include <vcl/bitmapex.hxx>
26 #include <vcl/vclptr.hxx>
28 #define ANIMATION_TIMEOUT_ON_CLICK 2147483647L
30 enum Disposal
32 DISPOSE_NOT,
33 DISPOSE_BACK,
34 DISPOSE_FULL,
35 DISPOSE_PREVIOUS
38 enum CycleMode
40 CYCLE_NOT,
41 CYCLE_NORMAL,
42 CYCLE_FALLBACK,
43 CYCLE_REVERS,
44 CYCLE_REVERS_FALLBACK
47 struct VCL_DLLPUBLIC AnimationBitmap
49 BitmapEx aBmpEx;
50 Point aPosPix;
51 Size aSizePix;
52 long nWait;
53 Disposal eDisposal;
54 bool bUserInput;
56 AnimationBitmap()
57 : nWait(0)
58 , eDisposal(DISPOSE_NOT)
59 , bUserInput(false)
62 AnimationBitmap(
63 const BitmapEx& rBmpEx,
64 const Point& rPosPix,
65 const Size& rSizePix,
66 long _nWait = 0L,
67 Disposal _eDisposal = DISPOSE_NOT
68 ) :
69 aBmpEx ( rBmpEx ),
70 aPosPix ( rPosPix ),
71 aSizePix ( rSizePix ),
72 nWait ( _nWait ),
73 eDisposal ( _eDisposal ),
74 bUserInput ( false )
77 bool operator==( const AnimationBitmap& rAnimBmp ) const
79 return( rAnimBmp.aBmpEx == aBmpEx &&
80 rAnimBmp.aPosPix == aPosPix &&
81 rAnimBmp.aSizePix == aSizePix &&
82 rAnimBmp.nWait == nWait &&
83 rAnimBmp.eDisposal == eDisposal &&
84 rAnimBmp.bUserInput == bUserInput );
87 bool operator!=( const AnimationBitmap& rAnimBmp ) const
88 { return !( *this == rAnimBmp ); }
90 bool IsEqual( const AnimationBitmap& rAnimBmp ) const
92 return( rAnimBmp.aPosPix == aPosPix &&
93 rAnimBmp.aSizePix == aSizePix &&
94 rAnimBmp.nWait == nWait &&
95 rAnimBmp.eDisposal == eDisposal &&
96 rAnimBmp.bUserInput == bUserInput &&
97 rAnimBmp.aBmpEx.IsEqual( aBmpEx ) );
100 BitmapChecksum GetChecksum() const;
103 struct AInfo
105 Bitmap aLastSaveBitmap;
106 Bitmap aBackBitmap;
107 Rectangle aClipRect;
108 Size aLastSaveSize;
109 Point aLastSavePoint;
110 Point aStartOrg;
111 Size aStartSize;
112 VclPtr<OutputDevice> pOutDev;
113 void* pViewData;
114 long nExtraData;
115 bool bWithSize;
116 bool bPause;
118 AInfo();
121 class ImplAnimView;
123 class VCL_DLLPUBLIC Animation
125 public:
126 Animation();
127 Animation( const Animation& rAnimation );
128 ~Animation();
130 Animation& operator=( const Animation& rAnimation );
131 bool operator==( const Animation& rAnimation ) const;
132 bool operator!=( const Animation& rAnimation ) const
133 { return !(*this==rAnimation); }
135 void Clear();
137 bool Start(
138 OutputDevice* pOutDev,
139 const Point& rDestPt,
140 const Size& rDestSz,
141 long nExtraData = 0,
142 OutputDevice* pFirstFrameOutDev = NULL);
144 void Stop( OutputDevice* pOutDev = NULL, long nExtraData = 0 );
146 void Draw( OutputDevice* pOutDev, const Point& rDestPt ) const;
147 void Draw( OutputDevice* pOutDev, const Point& rDestPt, const Size& rDestSz ) const;
149 bool IsInAnimation() const { return mbIsInAnimation; }
150 bool IsTransparent() const;
151 bool IsTerminated() const { return mbLoopTerminated; }
153 const Size& GetDisplaySizePixel() const { return maGlobalSize; }
154 void SetDisplaySizePixel( const Size& rSize ) { maGlobalSize = rSize; }
156 const BitmapEx& GetBitmapEx() const { return maBitmapEx; }
157 void SetBitmapEx( const BitmapEx& rBmpEx ) { maBitmapEx = rBmpEx; }
159 sal_uLong GetLoopCount() const { return mnLoopCount; }
160 void SetLoopCount( const sal_uLong nLoopCount );
161 void ResetLoopCount();
163 void SetCycleMode( CycleMode eMode );
164 CycleMode GetCycleMode() const { return meCycleMode; }
166 void SetNotifyHdl( const Link<>& rLink ) { maNotifyLink = rLink; }
167 const Link<>& GetNotifyHdl() const { return maNotifyLink; }
169 size_t Count() const { return maList.size(); }
170 bool Insert( const AnimationBitmap& rAnimationBitmap );
171 const AnimationBitmap&
172 Get( sal_uInt16 nAnimation ) const;
173 void Replace( const AnimationBitmap& rNewAnimationBmp, sal_uInt16 nAnimation );
175 sal_uLong GetSizeBytes() const;
176 BitmapChecksum GetChecksum() const;
178 public:
180 bool Convert( BmpConversion eConversion );
181 bool ReduceColors(
182 sal_uInt16 nNewColorCount,
183 BmpReduce eReduce = BMP_REDUCE_SIMPLE );
185 bool Invert();
186 bool Mirror( BmpMirrorFlags nMirrorFlags );
187 bool Adjust(
188 short nLuminancePercent = 0,
189 short nContrastPercent = 0,
190 short nChannelRPercent = 0,
191 short nChannelGPercent = 0,
192 short nChannelBPercent = 0,
193 double fGamma = 1.0,
194 bool bInvert = false );
196 bool Filter(
197 BmpFilter eFilter,
198 const BmpFilterParam* pFilterParam = NULL,
199 const Link<>* pProgress = NULL );
201 friend VCL_DLLPUBLIC SvStream& ReadAnimation( SvStream& rIStream, Animation& rAnimation );
202 friend VCL_DLLPUBLIC SvStream& WriteAnimation( SvStream& rOStream, const Animation& rAnimation );
204 public:
206 SAL_DLLPRIVATE static void
207 ImplIncAnimCount() { mnAnimCount++; }
208 SAL_DLLPRIVATE static void
209 ImplDecAnimCount() { mnAnimCount--; }
210 SAL_DLLPRIVATE sal_uLong
211 ImplGetCurPos() const { return mnPos; }
213 private:
214 SAL_DLLPRIVATE static sal_uLong mnAnimCount;
216 std::vector< AnimationBitmap* > maList;
217 std::vector< ImplAnimView* > maViewList;
219 Link<> maNotifyLink;
220 BitmapEx maBitmapEx;
221 Timer maTimer;
222 Size maGlobalSize;
223 long mnLoopCount;
224 long mnLoops;
225 size_t mnPos;
226 CycleMode meCycleMode;
227 bool mbIsInAnimation;
228 bool mbLoopTerminated;
229 bool mbIsWaiting;
231 SAL_DLLPRIVATE void ImplRestartTimer( sal_uLong nTimeout );
232 DECL_DLLPRIVATE_LINK_TYPED( ImplTimeoutHdl, Timer*, void );
236 #endif // INCLUDED_VCL_ANIMATE_HXX
238 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */