]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/animate.h
Fix wrong return value in the changes of r73365.
[wxWidgets.git] / interface / wx / 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$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
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
d72927c1
RD
26
27#define wxAC_NO_AUTORESIZE (0x0010)
28#define wxAC_DEFAULT_STYLE (wxBORDER_NONE)
29
30
23324ae1
FM
31/**
32 @class wxAnimationCtrl
7c913512 33
23324ae1 34 This is a static control which displays an animation.
f59be7c6
FM
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.
7c913512 37
23324ae1
FM
38 This control is useful to display a (small) animation while doing a long task
39 (e.g. a "throbber").
7c913512 40
23324ae1 41 It is only available if @c wxUSE_ANIMATIONCTRL is set to 1 (the default).
7c913512 42
23324ae1 43 @beginStyleTable
8c6791e4 44 @style{wxAC_DEFAULT_STYLE}
23324ae1 45 The default style: wxBORDER_NONE.
8c6791e4 46 @style{wxAC_NO_AUTORESIZE}
23324ae1
FM
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
50 @endStyleTable
7c913512 51
23324ae1
FM
52 @library{wxadv}
53 @category{ctrl}
f59be7c6
FM
54
55 @nativeimpl{wxgtk,wxmsw}
56
ce154616 57 @appearance{animationctrl}
7c913512 58
5d4cca7f 59 @see wxAnimation, @sample{animate}
23324ae1
FM
60*/
61class wxAnimationCtrl : public wxControl
62{
63public:
64 /**
65 Initializes the object and calls Create() with
66 all the parameters.
67 */
4cc4bfaf 68 wxAnimationCtrl(wxWindow* parent, wxWindowID id,
3d8662ab 69 const wxAnimation& anim = wxNullAnimation,
23324ae1
FM
70 const wxPoint& pos = wxDefaultPosition,
71 const wxSize& size = wxDefaultSize,
72 long style = wxAC_DEFAULT_STYLE,
d9faa1fe 73 const wxString& name = wxAnimationCtrlNameStr);
23324ae1
FM
74
75 /**
f59be7c6 76 Creates the control with the given @a anim animation.
3c4f71cc 77
4c51a665 78 After control creation you must explicitly call Play() to start to play
f59be7c6 79 the animation. Until that function won't be called, the first frame
23324ae1 80 of the animation is displayed.
3c4f71cc 81
7c913512 82 @param parent
4cc4bfaf 83 Parent window, must be non-@NULL.
7c913512 84 @param id
4cc4bfaf 85 The identifier for the control.
7c913512 86 @param anim
4cc4bfaf 87 The initial animation shown in the control.
7c913512 88 @param pos
4cc4bfaf 89 Initial position.
7c913512 90 @param size
4cc4bfaf 91 Initial size.
7c913512 92 @param style
4cc4bfaf 93 The window style, see wxAC_* flags.
7c913512 94 @param name
4cc4bfaf 95 Control name.
3c4f71cc 96
d29a9a8a
BP
97 @return @true if the control was successfully created or @false if
98 creation failed.
23324ae1 99 */
4cc4bfaf 100 bool Create(wxWindow* parent, wxWindowID id,
3d8662ab 101 const wxAnimation& anim = wxNullAnimation,
23324ae1
FM
102 const wxPoint& pos = wxDefaultPosition,
103 const wxSize& size = wxDefaultSize,
104 long style = wxAC_DEFAULT_STYLE,
8d483c9b 105 const wxString& name = wxAnimationCtrlNameStr);
23324ae1
FM
106
107 /**
108 Returns the animation associated with this control.
109 */
e4f1d811 110 virtual wxAnimation GetAnimation() const;
23324ae1
FM
111
112 /**
113 Returns the inactive bitmap shown in this control when the;
114 see SetInactiveBitmap() for more info.
115 */
328f5751 116 wxBitmap GetInactiveBitmap() const;
23324ae1
FM
117
118 /**
119 Returns @true if the animation is being played.
120 */
e4f1d811 121 virtual bool IsPlaying() const;
23324ae1
FM
122
123 /**
124 Loads the animation from the given file and calls SetAnimation().
125 See wxAnimation::LoadFile for more info.
126 */
e4f1d811
FM
127 virtual bool LoadFile(const wxString& file,
128 wxAnimationType animType = wxANIMATION_TYPE_ANY);
23324ae1 129
462167a9
VZ
130 /**
131 Loads the animation from the given stream and calls SetAnimation().
132 See wxAnimation::Load() for more info.
133 */
134 virtual bool Load(wxInputStream& file,
135 wxAnimationType animType = wxANIMATION_TYPE_ANY);
136
23324ae1
FM
137 /**
138 Starts playing the animation.
f59be7c6 139
23324ae1 140 The animation is always played in loop mode (unless the last frame of the
f59be7c6
FM
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.
23324ae1 143 */
e4f1d811 144 virtual bool Play();
23324ae1
FM
145
146 /**
147 Sets the animation to play in this control.
f59be7c6
FM
148
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
23324ae1
FM
152 (see SetInactiveBitmap() for more info).
153 */
e4f1d811 154 virtual void SetAnimation(const wxAnimation& anim);
23324ae1
FM
155
156 /**
157 Sets the bitmap to show on the control when it's not playing an animation.
f59be7c6
FM
158
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.
163
23324ae1 164 If the control is not playing the animation, the given bitmap will be
f59be7c6
FM
165 immediately shown, otherwise it will be shown as soon as Stop() is called.
166
23324ae1 167 Note that the inactive bitmap, if smaller than the control's size, will be
f59be7c6 168 centered in the control; if bigger, it will be stretched to fit it.
23324ae1 169 */
8d483c9b 170 virtual void SetInactiveBitmap(const wxBitmap& bmp);
23324ae1
FM
171
172 /**
173 Stops playing the animation.
174 The control will show the first frame of the animation, a custom static image or
f59be7c6 175 the window's background colour as specified by the last SetInactiveBitmap() call.
23324ae1 176 */
e4f1d811 177 virtual void Stop();
23324ae1
FM
178};
179
180
e54c96f1 181
23324ae1
FM
182/**
183 @class wxAnimation
7c913512 184
23324ae1
FM
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.
7c913512 188
ab8b305b
FM
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
232fdc63 191 @c wxANIMATION_TYPE_GIF).
ab8b305b
FM
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).
194
23324ae1 195 @library{wxadv}
f59be7c6 196 @category{gdi}
7c913512 197
23324ae1 198 @stdobjects
f59be7c6 199 ::wxNullAnimation
7c913512 200
5d4cca7f 201 @see wxAnimationCtrl, @sample{animate}
23324ae1 202*/
c1bd5a6d 203class wxAnimation : public wxObject
23324ae1
FM
204{
205public:
d72927c1
RD
206 /**
207 Default ctor.
208 */
209 wxAnimation();
210
3d8662ab
FM
211 /**
212 Copy ctor.
213 */
f59be7c6
FM
214 wxAnimation(const wxAnimation& anim);
215
23324ae1
FM
216 /**
217 Loads an animation from a file.
3c4f71cc 218
7c913512 219 @param name
4cc4bfaf 220 The name of the file to load.
7c913512 221 @param type
d72f7a9d 222 See LoadFile() for more info.
23324ae1 223 */
7c913512
FM
224 wxAnimation(const wxString& name,
225 wxAnimationType type = wxANIMATION_TYPE_ANY);
23324ae1
FM
226
227 /**
228 Destructor.
f59be7c6 229 See @ref overview_refcount_destruct for more info.
23324ae1 230 */
8d483c9b 231 virtual ~wxAnimation();
23324ae1
FM
232
233 /**
234 Returns the delay for the i-th frame in milliseconds.
235 If @c -1 is returned the frame is to be displayed forever.
236 */
e4f1d811 237 virtual int GetDelay(unsigned int i) const;
23324ae1
FM
238
239 /**
240 Returns the i-th frame as a wxImage.
d298f18f
VZ
241
242 This method is not implemented in the native wxGTK implementation of
243 this class and always returns an invalid image there.
23324ae1 244 */
e4f1d811 245 virtual wxImage GetFrame(unsigned int i) const;
23324ae1
FM
246
247 /**
248 Returns the number of frames for this animation.
d298f18f
VZ
249
250 This method is not implemented in the native wxGTK implementation of
251 this class and always returns 0 there.
23324ae1 252 */
e4f1d811 253 virtual unsigned int GetFrameCount() const;
23324ae1
FM
254
255 /**
256 Returns the size of the animation.
257 */
e4f1d811 258 virtual wxSize GetSize() const;
23324ae1
FM
259
260 /**
261 Returns @true if animation data is present.
262 */
e4f1d811 263 virtual bool IsOk() const;
23324ae1
FM
264
265 /**
266 Loads an animation from the given stream.
3c4f71cc 267
7c913512 268 @param stream
4cc4bfaf 269 The stream to use to load the animation.
d72f7a9d
FM
270 Under wxGTK may be any kind of stream; under other platforms
271 this must be a seekable stream.
7c913512 272 @param type
d72f7a9d 273 One of the ::wxAnimationType enumeration values.
3c4f71cc 274
d29a9a8a 275 @return @true if the operation succeeded, @false otherwise.
23324ae1 276 */
e4f1d811
FM
277 virtual bool Load(wxInputStream& stream,
278 wxAnimationType type = wxANIMATION_TYPE_ANY);
23324ae1
FM
279
280 /**
281 Loads an animation from a file.
3c4f71cc 282
7c913512 283 @param name
4cc4bfaf 284 A filename.
7c913512 285 @param type
d72f7a9d 286 One of the ::wxAnimationType values; wxANIMATION_TYPE_ANY
f59be7c6 287 means that the function should try to autodetect the filetype.
3c4f71cc 288
d29a9a8a 289 @return @true if the operation succeeded, @false otherwise.
23324ae1 290 */
e4f1d811
FM
291 virtual bool LoadFile(const wxString& name,
292 wxAnimationType type = wxANIMATION_TYPE_ANY);
23324ae1
FM
293
294 /**
f59be7c6 295 Assignment operator, using @ref overview_refcount "reference counting".
23324ae1 296 */
3d8662ab 297 wxAnimation& operator =(const wxAnimation& brush);
23324ae1 298};
e54c96f1 299
39fb8056
FM
300
301// ============================================================================
302// Global functions/macros
303// ============================================================================
304
e54c96f1 305/**
f59be7c6 306 An empty animation object.
e54c96f1
FM
307*/
308wxAnimation wxNullAnimation;
309