1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxAnimation* classes
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 Supported animation types.
14 wxANIMATION_TYPE_INVALID
,
16 /** represents an animated GIF file. */
19 /** represents an ANI file. */
22 /** autodetect the filetype. */
27 #define wxAC_NO_AUTORESIZE (0x0010)
28 #define wxAC_DEFAULT_STYLE (wxBORDER_NONE)
32 @class wxAnimationCtrl
34 This is a static control which displays an animation.
35 wxAnimationCtrl API is as simple as possible and won't give you full control
36 on the animation; if you need it then use wxMediaCtrl.
38 This control is useful to display a (small) animation while doing a long task
41 It is only available if @c wxUSE_ANIMATIONCTRL is set to 1 (the default).
44 @style{wxAC_DEFAULT_STYLE}
45 The default style: wxBORDER_NONE.
46 @style{wxAC_NO_AUTORESIZE}
47 By default, the control will adjust its size to exactly fit to the
48 size of the animation when SetAnimation is called. If this style
49 flag is given, the control will not change its size
55 @nativeimpl{wxgtk,wxmsw}
57 @appearance{animationctrl}
59 @see wxAnimation, @sample{animate}
61 class wxAnimationCtrl
: public wxControl
65 Initializes the object and calls Create() with
68 wxAnimationCtrl(wxWindow
* parent
, wxWindowID id
,
69 const wxAnimation
& anim
= wxNullAnimation
,
70 const wxPoint
& pos
= wxDefaultPosition
,
71 const wxSize
& size
= wxDefaultSize
,
72 long style
= wxAC_DEFAULT_STYLE
,
73 const wxString
& name
= wxAnimationCtrlNameStr
);
76 Creates the control with the given @a anim animation.
78 After control creation you must explicitly call Play() to start to play
79 the animation. Until that function won't be called, the first frame
80 of the animation is displayed.
83 Parent window, must be non-@NULL.
85 The identifier for the control.
87 The initial animation shown in the control.
93 The window style, see wxAC_* flags.
97 @return @true if the control was successfully created or @false if
100 bool Create(wxWindow
* parent
, wxWindowID id
,
101 const wxAnimation
& anim
= wxNullAnimation
,
102 const wxPoint
& pos
= wxDefaultPosition
,
103 const wxSize
& size
= wxDefaultSize
,
104 long style
= wxAC_DEFAULT_STYLE
,
105 const wxString
& name
= wxAnimationCtrlNameStr
);
108 Returns the animation associated with this control.
110 virtual wxAnimation
GetAnimation() const;
113 Returns the inactive bitmap shown in this control when the;
114 see SetInactiveBitmap() for more info.
116 wxBitmap
GetInactiveBitmap() const;
119 Returns @true if the animation is being played.
121 virtual bool IsPlaying() const;
124 Loads the animation from the given file and calls SetAnimation().
125 See wxAnimation::LoadFile for more info.
127 virtual bool LoadFile(const wxString
& file
,
128 wxAnimationType animType
= wxANIMATION_TYPE_ANY
);
131 Loads the animation from the given stream and calls SetAnimation().
132 See wxAnimation::Load() for more info.
134 virtual bool Load(wxInputStream
& file
,
135 wxAnimationType animType
= wxANIMATION_TYPE_ANY
);
138 Starts playing the animation.
140 The animation is always played in loop mode (unless the last frame of the
141 animation has an infinite delay time) and always start from the first frame
142 even if you @ref Stop "stopped" it while some other frame was displayed.
147 Sets the animation to play in this control.
149 If the previous animation is being played, it's @ref Stop() stopped.
150 Until Play() isn't called, a static image, the first frame of the given
151 animation or the background colour will be shown
152 (see SetInactiveBitmap() for more info).
154 virtual void SetAnimation(const wxAnimation
& anim
);
157 Sets the bitmap to show on the control when it's not playing an animation.
159 If you set as inactive bitmap ::wxNullBitmap (which is the default), then the
160 first frame of the animation is instead shown when the control is inactive;
161 in this case, if there's no valid animation associated with the control
162 (see SetAnimation()), then the background colour of the window is shown.
164 If the control is not playing the animation, the given bitmap will be
165 immediately shown, otherwise it will be shown as soon as Stop() is called.
167 Note that the inactive bitmap, if smaller than the control's size, will be
168 centered in the control; if bigger, it will be stretched to fit it.
170 virtual void SetInactiveBitmap(const wxBitmap
& bmp
);
173 Stops playing the animation.
174 The control will show the first frame of the animation, a custom static image or
175 the window's background colour as specified by the last SetInactiveBitmap() call.
185 This class encapsulates the concept of a platform-dependent animation.
186 An animation is a sequence of frames of the same size.
187 Sound is not supported by wxAnimation.
189 Note that on wxGTK wxAnimation is capable of loading the formats supported
190 by the internally-used @c gdk-pixbuf library (typically this means only
191 @c wxANIMATION_TYPE_GIF).
192 On other platforms wxAnimation is always capable of loading both GIF and ANI
193 formats (i.e. both @c wxANIMATION_TYPE_GIF and @c wxANIMATION_TYPE_ANI).
201 @see wxAnimationCtrl, @sample{animate}
203 class wxAnimation
: public wxGDIObject
214 wxAnimation(const wxAnimation
& anim
);
217 Loads an animation from a file.
220 The name of the file to load.
222 See LoadFile() for more info.
224 wxAnimation(const wxString
& name
,
225 wxAnimationType type
= wxANIMATION_TYPE_ANY
);
229 See @ref overview_refcount_destruct for more info.
231 virtual ~wxAnimation();
234 Returns the delay for the i-th frame in milliseconds.
235 If @c -1 is returned the frame is to be displayed forever.
237 virtual int GetDelay(unsigned int i
) const;
240 Returns the i-th frame as a wxImage.
242 This method is not implemented in the native wxGTK implementation of
243 this class and always returns an invalid image there.
245 virtual wxImage
GetFrame(unsigned int i
) const;
248 Returns the number of frames for this animation.
250 This method is not implemented in the native wxGTK implementation of
251 this class and always returns 0 there.
253 virtual unsigned int GetFrameCount() const;
256 Returns the size of the animation.
258 virtual wxSize
GetSize() const;
261 Returns @true if animation data is present.
263 virtual bool IsOk() const;
266 Loads an animation from the given stream.
269 The stream to use to load the animation.
270 Under wxGTK may be any kind of stream; under other platforms
271 this must be a seekable stream.
273 One of the ::wxAnimationType enumeration values.
275 @return @true if the operation succeeded, @false otherwise.
277 virtual bool Load(wxInputStream
& stream
,
278 wxAnimationType type
= wxANIMATION_TYPE_ANY
);
281 Loads an animation from a file.
286 One of the ::wxAnimationType values; wxANIMATION_TYPE_ANY
287 means that the function should try to autodetect the filetype.
289 @return @true if the operation succeeded, @false otherwise.
291 virtual bool LoadFile(const wxString
& name
,
292 wxAnimationType type
= wxANIMATION_TYPE_ANY
);
295 Assignment operator, using @ref overview_refcount "reference counting".
297 wxAnimation
& operator =(const wxAnimation
& brush
);
301 // ============================================================================
302 // Global functions/macros
303 // ============================================================================
306 An empty animation object.
308 wxAnimation wxNullAnimation
;