]> git.saurik.com Git - wxWidgets.git/blame - interface/animate.h
fixes to Freeze/Thawn when the window is shown or hidden in between Freeze and Thaw
[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
FM
39 @beginStyleTable
40 @style{wxAC_DEFAULT_STYLE}:
41 The default style: wxBORDER_NONE.
42 @style{wxAC_NO_AUTORESIZE}:
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
23324ae1 53 @appearance{animationctrl.png}
7c913512 54
e54c96f1 55 @see wxAnimation
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,
69 const wxString& name = "animationctrl");
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
23324ae1 93 @returns @true if the control was successfully created or @false if
4cc4bfaf 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,
101 const wxString& name = "animationctrl");
102
103 /**
104 Returns the animation associated with this control.
105 */
328f5751 106 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 */
328f5751 117 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 */
4cc4bfaf 123 bool LoadFile(const wxString& file,
23324ae1
FM
124 wxAnimationType animType = wxANIMATION_TYPE_ANY);
125
126 /**
127 Starts playing the animation.
f59be7c6 128
23324ae1 129 The animation is always played in loop mode (unless the last frame of the
f59be7c6
FM
130 animation has an infinite delay time) and always start from the first frame
131 even if you @ref Stop "stopped" it while some other frame was displayed.
23324ae1
FM
132 */
133 bool Play();
134
135 /**
136 Sets the animation to play in this control.
f59be7c6
FM
137
138 If the previous animation is being played, it's @ref Stop() stopped.
139 Until Play() isn't called, a static image, the first frame of the given
140 animation or the background colour will be shown
23324ae1
FM
141 (see SetInactiveBitmap() for more info).
142 */
4cc4bfaf 143 void SetAnimation(const wxAnimation& anim);
23324ae1
FM
144
145 /**
146 Sets the bitmap to show on the control when it's not playing an animation.
f59be7c6
FM
147
148 If you set as inactive bitmap ::wxNullBitmap (which is the default), then the
149 first frame of the animation is instead shown when the control is inactive;
150 in this case, if there's no valid animation associated with the control
151 (see SetAnimation()), then the background colour of the window is shown.
152
23324ae1 153 If the control is not playing the animation, the given bitmap will be
f59be7c6
FM
154 immediately shown, otherwise it will be shown as soon as Stop() is called.
155
23324ae1 156 Note that the inactive bitmap, if smaller than the control's size, will be
f59be7c6 157 centered in the control; if bigger, it will be stretched to fit it.
23324ae1
FM
158 */
159 void SetInactiveBitmap(const wxBitmap& bmp);
160
161 /**
162 Stops playing the animation.
163 The control will show the first frame of the animation, a custom static image or
f59be7c6 164 the window's background colour as specified by the last SetInactiveBitmap() call.
23324ae1
FM
165 */
166 void Stop();
167};
168
169
e54c96f1 170
23324ae1
FM
171/**
172 @class wxAnimation
173 @wxheader{animate.h}
7c913512 174
23324ae1
FM
175 This class encapsulates the concept of a platform-dependent animation.
176 An animation is a sequence of frames of the same size.
177 Sound is not supported by wxAnimation.
7c913512 178
23324ae1 179 @library{wxadv}
f59be7c6 180 @category{gdi}
7c913512 181
23324ae1 182 @stdobjects
f59be7c6 183 ::wxNullAnimation
7c913512 184
e54c96f1 185 @see wxAnimationCtrl
23324ae1
FM
186*/
187class wxAnimation : public wxGDIObject
188{
189public:
3d8662ab
FM
190 /**
191 Copy ctor.
192 */
f59be7c6
FM
193 wxAnimation(const wxAnimation& anim);
194
23324ae1
FM
195 /**
196 Loads an animation from a file.
3c4f71cc 197
7c913512 198 @param name
4cc4bfaf 199 The name of the file to load.
7c913512 200 @param type
4cc4bfaf 201 See LoadFile for more info.
23324ae1 202 */
7c913512
FM
203 wxAnimation(const wxString& name,
204 wxAnimationType type = wxANIMATION_TYPE_ANY);
23324ae1
FM
205
206 /**
207 Destructor.
f59be7c6 208 See @ref overview_refcount_destruct for more info.
23324ae1
FM
209 */
210 ~wxAnimation();
211
212 /**
213 Returns the delay for the i-th frame in milliseconds.
214 If @c -1 is returned the frame is to be displayed forever.
215 */
328f5751 216 int GetDelay(unsigned int i) const;
23324ae1
FM
217
218 /**
219 Returns the i-th frame as a wxImage.
220 */
328f5751 221 wxImage GetFrame(unsigned int i) const;
23324ae1
FM
222
223 /**
224 Returns the number of frames for this animation.
225 */
328f5751 226 unsigned int GetFrameCount() const;
23324ae1
FM
227
228 /**
229 Returns the size of the animation.
230 */
328f5751 231 wxSize GetSize() const;
23324ae1
FM
232
233 /**
234 Returns @true if animation data is present.
235 */
328f5751 236 bool IsOk() const;
23324ae1
FM
237
238 /**
239 Loads an animation from the given stream.
3c4f71cc 240
7c913512 241 @param stream
4cc4bfaf 242 The stream to use to load the animation.
7c913512 243 @param type
4cc4bfaf 244 One of the following values:
f59be7c6
FM
245 @li wxANIMATION_TYPE_GIF: loads an animated GIF file;
246 @li wxANIMATION_TYPE_ANI: load an ANI file;
247 @li wxANIMATION_TYPE_ANY: tries to autodetect the filetype.
3c4f71cc 248
23324ae1
FM
249 @returns @true if the operation succeeded, @false otherwise.
250 */
251 bool Load(wxInputStream& stream,
252 wxAnimationType type = wxANIMATION_TYPE_ANY);
253
254 /**
255 Loads an animation from a file.
3c4f71cc 256
7c913512 257 @param name
4cc4bfaf 258 A filename.
7c913512 259 @param type
f59be7c6
FM
260 One of the wxAnimationType values; wxANIMATION_TYPE_ANY
261 means that the function should try to autodetect the filetype.
3c4f71cc 262
23324ae1
FM
263 @returns @true if the operation succeeded, @false otherwise.
264 */
265 bool LoadFile(const wxString& name,
266 wxAnimationType type = wxANIMATION_TYPE_ANY);
267
268 /**
f59be7c6 269 Assignment operator, using @ref overview_refcount "reference counting".
23324ae1 270 */
3d8662ab 271 wxAnimation& operator =(const wxAnimation& brush);
23324ae1 272};
e54c96f1 273
39fb8056
FM
274
275// ============================================================================
276// Global functions/macros
277// ============================================================================
278
e54c96f1 279/**
f59be7c6 280 An empty animation object.
e54c96f1
FM
281*/
282wxAnimation wxNullAnimation;
283