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