1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxAnimationCtrl
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxAnimationCtrl
13 This is a static control which displays an animation.
14 wxAnimationCtrl API is simple as possible and won't give you full control on the
15 animation; if you need it then use wxMediaCtrl.
17 This control is useful to display a (small) animation while doing a long task
20 It is only available if @c wxUSE_ANIMATIONCTRL is set to 1 (the default).
23 @style{wxAC_DEFAULT_STYLE}:
24 The default style: wxBORDER_NONE.
25 @style{wxAC_NO_AUTORESIZE}:
26 By default, the control will adjust its size to exactly fit to the
27 size of the animation when SetAnimation is called. If this style
28 flag is given, the control will not change its size
33 @appearance{animationctrl.png}
37 class wxAnimationCtrl
: public wxControl
41 Initializes the object and calls Create() with
44 wxAnimationCtrl(wxWindow
* parent
, wxWindowID id
,
45 const wxAnimation
& anim
,
46 const wxPoint
& pos
= wxDefaultPosition
,
47 const wxSize
& size
= wxDefaultSize
,
48 long style
= wxAC_DEFAULT_STYLE
,
49 const wxString
& name
= "animationctrl");
52 After control creation you must explicitely call Play()
53 to start to play the animation. Until that function won't be called, the first
55 of the animation is displayed.
58 Parent window, must be non-@NULL.
60 The identifier for the control.
62 The initial animation shown in the control.
68 The window style, see wxAC_* flags.
72 @returns @true if the control was successfully created or @false if
75 bool Create(wxWindow
* parent
, wxWindowID id
,
76 const wxAnimation
& anim
,
77 const wxPoint
& pos
= wxDefaultPosition
,
78 const wxSize
& size
= wxDefaultSize
,
79 long style
= wxAC_DEFAULT_STYLE
,
80 const wxString
& name
= "animationctrl");
83 Returns the animation associated with this control.
85 wxAnimation
GetAnimation() const;
88 Returns the inactive bitmap shown in this control when the;
89 see SetInactiveBitmap() for more info.
91 wxBitmap
GetInactiveBitmap() const;
94 Returns @true if the animation is being played.
96 bool IsPlaying() const;
99 Loads the animation from the given file and calls SetAnimation().
100 See wxAnimation::LoadFile for more info.
102 bool LoadFile(const wxString
& file
,
103 wxAnimationType animType
= wxANIMATION_TYPE_ANY
);
106 Starts playing the animation.
107 The animation is always played in loop mode (unless the last frame of the
109 has an infinite delay time) and always start from the first frame
110 (even if you @ref stop() stopped it while some other frame was
116 Sets the animation to play in this control.
117 If the previous animation is being played, it's @ref stop() Stopped.
118 Until Play() isn't called, a static image, the first
119 frame of the given animation or the background colour will be shown
120 (see SetInactiveBitmap() for more info).
122 void SetAnimation(const wxAnimation
& anim
);
125 Sets the bitmap to show on the control when it's not playing an animation.
126 If you set as inactive bitmap @c wxNullBitmap (which is the default), then the
127 first frame of the animation is instead shown when the control is inactive; in
129 if there's no valid animation associated with the control (see
130 wxAnimationCtrl::SetAnimation),
131 then the background colour of the window is shown.
132 If the control is not playing the animation, the given bitmap will be
134 shown, otherwise it will be shown as soon as Stop()
136 Note that the inactive bitmap, if smaller than the control's size, will be
138 the control; if bigger, it will be stretched to fit it.
140 void SetInactiveBitmap(const wxBitmap
& bmp
);
143 Stops playing the animation.
144 The control will show the first frame of the animation, a custom static image or
145 the window's background colour as specified by the
146 last SetInactiveBitmap() call.
157 This class encapsulates the concept of a platform-dependent animation.
158 An animation is a sequence of frames of the same size.
159 Sound is not supported by wxAnimation.
165 ::Objects:, ::wxNullAnimation,
169 class wxAnimation
: public wxGDIObject
174 Loads an animation from a file.
177 The name of the file to load.
179 See LoadFile for more info.
182 wxAnimation(const wxAnimation
& anim
);
183 wxAnimation(const wxString
& name
,
184 wxAnimationType type
= wxANIMATION_TYPE_ANY
);
189 See @ref overview_refcountdestruct "reference-counted object destruction" for
195 Returns the delay for the i-th frame in milliseconds.
196 If @c -1 is returned the frame is to be displayed forever.
198 int GetDelay(unsigned int i
) const;
201 Returns the i-th frame as a wxImage.
203 wxImage
GetFrame(unsigned int i
) const;
206 Returns the number of frames for this animation.
208 unsigned int GetFrameCount() const;
211 Returns the size of the animation.
213 wxSize
GetSize() const;
216 Returns @true if animation data is present.
221 Loads an animation from the given stream.
224 The stream to use to load the animation.
226 One of the following values:
239 Load an animated GIF file.
261 Try to autodetect the filetype.
263 @returns @true if the operation succeeded, @false otherwise.
265 bool Load(wxInputStream
& stream
,
266 wxAnimationType type
= wxANIMATION_TYPE_ANY
);
269 Loads an animation from a file.
274 One of the following values:
287 Load an animated GIF file.
309 Try to autodetect the filetype.
311 @returns @true if the operation succeeded, @false otherwise.
313 bool LoadFile(const wxString
& name
,
314 wxAnimationType type
= wxANIMATION_TYPE_ANY
);
317 Assignment operator, using @ref overview_trefcount "reference counting".
319 wxAnimation
operator =(const wxAnimation
& brush
);
332 wxAnimation wxNullAnimation
;