]> git.saurik.com Git - wxWidgets.git/blame - interface/animate.h
Minor doc corrections for [q-r] in ticket #9581 (most of the patch was applied alread...
[wxWidgets.git] / interface / animate.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: animate.h
f59be7c6 3// Purpose: interface of wxAnimation* classes
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
f59be7c6
FM
9/**
10 Supported animation types.
11*/
12enum wxAnimationType
13{
14 wxANIMATION_TYPE_INVALID,
15
16 /** represents an animated GIF file. */
17 wxANIMATION_TYPE_GIF,
18
19 /** represents an ANI file. */
20 wxANIMATION_TYPE_ANI,
21
22 /** autodetect the filetype. */
23 wxANIMATION_TYPE_ANY
24};
25
23324ae1
FM
26/**
27 @class wxAnimationCtrl
28 @wxheader{animate.h}
7c913512 29
23324ae1 30 This is a static control which displays an animation.
f59be7c6
FM
31 wxAnimationCtrl API is as simple as possible and won't give you full control
32 on the animation; if you need it then use wxMediaCtrl.
7c913512 33
23324ae1
FM
34 This control is useful to display a (small) animation while doing a long task
35 (e.g. a "throbber").
7c913512 36
23324ae1 37 It is only available if @c wxUSE_ANIMATIONCTRL is set to 1 (the default).
7c913512 38
23324ae1 39 @beginStyleTable
8c6791e4 40 @style{wxAC_DEFAULT_STYLE}
23324ae1 41 The default style: wxBORDER_NONE.
8c6791e4 42 @style{wxAC_NO_AUTORESIZE}
23324ae1
FM
43 By default, the control will adjust its size to exactly fit to the
44 size of the animation when SetAnimation is called. If this style
45 flag is given, the control will not change its size
46 @endStyleTable
7c913512 47
23324ae1
FM
48 @library{wxadv}
49 @category{ctrl}
f59be7c6
FM
50
51 @nativeimpl{wxgtk,wxmsw}
52
0c7fe6f2 53 <!-- @appearance{animationctrl.png} -->
7c913512 54
5d4cca7f 55 @see wxAnimation, @sample{animate}
23324ae1
FM
56*/
57class wxAnimationCtrl : public wxControl
58{
59public:
60 /**
61 Initializes the object and calls Create() with
62 all the parameters.
63 */
4cc4bfaf 64 wxAnimationCtrl(wxWindow* parent, wxWindowID id,
3d8662ab 65 const wxAnimation& anim = wxNullAnimation,
23324ae1
FM
66 const wxPoint& pos = wxDefaultPosition,
67 const wxSize& size = wxDefaultSize,
68 long style = wxAC_DEFAULT_STYLE,
d9faa1fe 69 const wxString& name = wxAnimationCtrlNameStr);
23324ae1
FM
70
71 /**
f59be7c6 72 Creates the control with the given @a anim animation.
3c4f71cc 73
f59be7c6
FM
74 After control creation you must explicitely call Play() to start to play
75 the animation. Until that function won't be called, the first frame
23324ae1 76 of the animation is displayed.
3c4f71cc 77
7c913512 78 @param parent
4cc4bfaf 79 Parent window, must be non-@NULL.
7c913512 80 @param id
4cc4bfaf 81 The identifier for the control.
7c913512 82 @param anim
4cc4bfaf 83 The initial animation shown in the control.
7c913512 84 @param pos
4cc4bfaf 85 Initial position.
7c913512 86 @param size
4cc4bfaf 87 Initial size.
7c913512 88 @param style
4cc4bfaf 89 The window style, see wxAC_* flags.
7c913512 90 @param name
4cc4bfaf 91 Control name.
3c4f71cc 92
d29a9a8a
BP
93 @return @true if the control was successfully created or @false if
94 creation failed.
23324ae1 95 */
4cc4bfaf 96 bool Create(wxWindow* parent, wxWindowID id,
3d8662ab 97 const wxAnimation& anim = wxNullAnimation,
23324ae1
FM
98 const wxPoint& pos = wxDefaultPosition,
99 const wxSize& size = wxDefaultSize,
100 long style = wxAC_DEFAULT_STYLE,
8d483c9b 101 const wxString& name = wxAnimationCtrlNameStr);
23324ae1
FM
102
103 /**
104 Returns the animation associated with this control.
105 */
e4f1d811 106 virtual wxAnimation GetAnimation() const;
23324ae1
FM
107
108 /**
109 Returns the inactive bitmap shown in this control when the;
110 see SetInactiveBitmap() for more info.
111 */
328f5751 112 wxBitmap GetInactiveBitmap() const;
23324ae1
FM
113
114 /**
115 Returns @true if the animation is being played.
116 */
e4f1d811 117 virtual bool IsPlaying() const;
23324ae1
FM
118
119 /**
120 Loads the animation from the given file and calls SetAnimation().
121 See wxAnimation::LoadFile for more info.
122 */
e4f1d811
FM
123 virtual bool LoadFile(const wxString& file,
124 wxAnimationType animType = wxANIMATION_TYPE_ANY);
23324ae1 125
462167a9
VZ
126 /**
127 Loads the animation from the given stream and calls SetAnimation().
128 See wxAnimation::Load() for more info.
129 */
130 virtual bool Load(wxInputStream& file,
131 wxAnimationType animType = wxANIMATION_TYPE_ANY);
132
23324ae1
FM
133 /**
134 Starts playing the animation.
f59be7c6 135
23324ae1 136 The animation is always played in loop mode (unless the last frame of the
f59be7c6
FM
137 animation has an infinite delay time) and always start from the first frame
138 even if you @ref Stop "stopped" it while some other frame was displayed.
23324ae1 139 */
e4f1d811 140 virtual bool Play();
23324ae1
FM
141
142 /**
143 Sets the animation to play in this control.
f59be7c6
FM
144
145 If the previous animation is being played, it's @ref Stop() stopped.
146 Until Play() isn't called, a static image, the first frame of the given
147 animation or the background colour will be shown
23324ae1
FM
148 (see SetInactiveBitmap() for more info).
149 */
e4f1d811 150 virtual void SetAnimation(const wxAnimation& anim);
23324ae1
FM
151
152 /**
153 Sets the bitmap to show on the control when it's not playing an animation.
f59be7c6
FM
154
155 If you set as inactive bitmap ::wxNullBitmap (which is the default), then the
156 first frame of the animation is instead shown when the control is inactive;
157 in this case, if there's no valid animation associated with the control
158 (see SetAnimation()), then the background colour of the window is shown.
159
23324ae1 160 If the control is not playing the animation, the given bitmap will be
f59be7c6
FM
161 immediately shown, otherwise it will be shown as soon as Stop() is called.
162
23324ae1 163 Note that the inactive bitmap, if smaller than the control's size, will be
f59be7c6 164 centered in the control; if bigger, it will be stretched to fit it.
23324ae1 165 */
8d483c9b 166 virtual void SetInactiveBitmap(const wxBitmap& bmp);
23324ae1
FM
167
168 /**
169 Stops playing the animation.
170 The control will show the first frame of the animation, a custom static image or
f59be7c6 171 the window's background colour as specified by the last SetInactiveBitmap() call.
23324ae1 172 */
e4f1d811 173 virtual void Stop();
23324ae1
FM
174};
175
176
e54c96f1 177
23324ae1
FM
178/**
179 @class wxAnimation
180 @wxheader{animate.h}
7c913512 181
23324ae1
FM
182 This class encapsulates the concept of a platform-dependent animation.
183 An animation is a sequence of frames of the same size.
184 Sound is not supported by wxAnimation.
7c913512 185
23324ae1 186 @library{wxadv}
f59be7c6 187 @category{gdi}
7c913512 188
23324ae1 189 @stdobjects
f59be7c6 190 ::wxNullAnimation
7c913512 191
5d4cca7f 192 @see wxAnimationCtrl, @sample{animate}
23324ae1
FM
193*/
194class wxAnimation : public wxGDIObject
195{
196public:
3d8662ab
FM
197 /**
198 Copy ctor.
199 */
f59be7c6
FM
200 wxAnimation(const wxAnimation& anim);
201
23324ae1
FM
202 /**
203 Loads an animation from a file.
3c4f71cc 204
7c913512 205 @param name
4cc4bfaf 206 The name of the file to load.
7c913512 207 @param type
4cc4bfaf 208 See LoadFile for more info.
23324ae1 209 */
7c913512
FM
210 wxAnimation(const wxString& name,
211 wxAnimationType type = wxANIMATION_TYPE_ANY);
23324ae1
FM
212
213 /**
214 Destructor.
f59be7c6 215 See @ref overview_refcount_destruct for more info.
23324ae1 216 */
8d483c9b 217 virtual ~wxAnimation();
23324ae1
FM
218
219 /**
220 Returns the delay for the i-th frame in milliseconds.
221 If @c -1 is returned the frame is to be displayed forever.
222 */
e4f1d811 223 virtual int GetDelay(unsigned int i) const;
23324ae1
FM
224
225 /**
226 Returns the i-th frame as a wxImage.
227 */
e4f1d811 228 virtual wxImage GetFrame(unsigned int i) const;
23324ae1
FM
229
230 /**
231 Returns the number of frames for this animation.
232 */
e4f1d811 233 virtual unsigned int GetFrameCount() const;
23324ae1
FM
234
235 /**
236 Returns the size of the animation.
237 */
e4f1d811 238 virtual wxSize GetSize() const;
23324ae1
FM
239
240 /**
241 Returns @true if animation data is present.
242 */
e4f1d811 243 virtual bool IsOk() const;
23324ae1
FM
244
245 /**
246 Loads an animation from the given stream.
3c4f71cc 247
7c913512 248 @param stream
4cc4bfaf 249 The stream to use to load the animation.
7c913512 250 @param type
4cc4bfaf 251 One of the following values:
f59be7c6
FM
252 @li wxANIMATION_TYPE_GIF: loads an animated GIF file;
253 @li wxANIMATION_TYPE_ANI: load an ANI file;
254 @li wxANIMATION_TYPE_ANY: tries to autodetect the filetype.
3c4f71cc 255
d29a9a8a 256 @return @true if the operation succeeded, @false otherwise.
23324ae1 257 */
e4f1d811
FM
258 virtual bool Load(wxInputStream& stream,
259 wxAnimationType type = wxANIMATION_TYPE_ANY);
23324ae1
FM
260
261 /**
262 Loads an animation from a file.
3c4f71cc 263
7c913512 264 @param name
4cc4bfaf 265 A filename.
7c913512 266 @param type
f59be7c6
FM
267 One of the wxAnimationType values; wxANIMATION_TYPE_ANY
268 means that the function should try to autodetect the filetype.
3c4f71cc 269
d29a9a8a 270 @return @true if the operation succeeded, @false otherwise.
23324ae1 271 */
e4f1d811
FM
272 virtual bool LoadFile(const wxString& name,
273 wxAnimationType type = wxANIMATION_TYPE_ANY);
23324ae1
FM
274
275 /**
f59be7c6 276 Assignment operator, using @ref overview_refcount "reference counting".
23324ae1 277 */
3d8662ab 278 wxAnimation& operator =(const wxAnimation& brush);
23324ae1 279};
e54c96f1 280
39fb8056
FM
281
282// ============================================================================
283// Global functions/macros
284// ============================================================================
285
e54c96f1 286/**
f59be7c6 287 An empty animation object.
e54c96f1
FM
288*/
289wxAnimation wxNullAnimation;
290