2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: animate.h
|
2008-03-10 12:23:56 -04:00
|
|
|
// Purpose: interface of wxAnimation* classes
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-03-10 12:23:56 -04:00
|
|
|
/**
|
|
|
|
Supported animation types.
|
|
|
|
*/
|
|
|
|
enum wxAnimationType
|
|
|
|
{
|
|
|
|
wxANIMATION_TYPE_INVALID,
|
|
|
|
|
|
|
|
/** represents an animated GIF file. */
|
|
|
|
wxANIMATION_TYPE_GIF,
|
|
|
|
|
|
|
|
/** represents an ANI file. */
|
|
|
|
wxANIMATION_TYPE_ANI,
|
|
|
|
|
|
|
|
/** autodetect the filetype. */
|
|
|
|
wxANIMATION_TYPE_ANY
|
|
|
|
};
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxAnimationCtrl
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This is a static control which displays an animation.
|
2008-03-10 12:23:56 -04:00
|
|
|
wxAnimationCtrl API is as simple as possible and won't give you full control
|
|
|
|
on the animation; if you need it then use wxMediaCtrl.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This control is useful to display a (small) animation while doing a long task
|
|
|
|
(e.g. a "throbber").
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
It is only available if @c wxUSE_ANIMATIONCTRL is set to 1 (the default).
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@beginStyleTable
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxAC_DEFAULT_STYLE}
|
2008-03-08 08:52:38 -05:00
|
|
|
The default style: wxBORDER_NONE.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxAC_NO_AUTORESIZE}
|
2008-03-08 08:52:38 -05:00
|
|
|
By default, the control will adjust its size to exactly fit to the
|
|
|
|
size of the animation when SetAnimation is called. If this style
|
|
|
|
flag is given, the control will not change its size
|
|
|
|
@endStyleTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxadv}
|
|
|
|
@category{ctrl}
|
2008-03-10 12:23:56 -04:00
|
|
|
|
|
|
|
@nativeimpl{wxgtk,wxmsw}
|
|
|
|
|
2008-10-13 04:05:18 -04:00
|
|
|
@appearance{animationctrl.png}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-06-21 01:10:40 -04:00
|
|
|
@see wxAnimation, @sample{animate}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxAnimationCtrl : public wxControl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Initializes the object and calls Create() with
|
|
|
|
all the parameters.
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
wxAnimationCtrl(wxWindow* parent, wxWindowID id,
|
2008-03-20 18:32:46 -04:00
|
|
|
const wxAnimation& anim = wxNullAnimation,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxAC_DEFAULT_STYLE,
|
2008-03-27 16:54:47 -04:00
|
|
|
const wxString& name = wxAnimationCtrlNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-10 12:23:56 -04:00
|
|
|
Creates the control with the given @a anim animation.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2011-03-22 10:17:38 -04:00
|
|
|
After control creation you must explicitly call Play() to start to play
|
2008-03-10 12:23:56 -04:00
|
|
|
the animation. Until that function won't be called, the first frame
|
2008-03-08 08:52:38 -05:00
|
|
|
of the animation is displayed.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param parent
|
2008-03-09 08:33:59 -04:00
|
|
|
Parent window, must be non-@NULL.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param id
|
2008-03-09 08:33:59 -04:00
|
|
|
The identifier for the control.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param anim
|
2008-03-09 08:33:59 -04:00
|
|
|
The initial animation shown in the control.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pos
|
2008-03-09 08:33:59 -04:00
|
|
|
Initial position.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param size
|
2008-03-09 08:33:59 -04:00
|
|
|
Initial size.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param style
|
2008-03-09 08:33:59 -04:00
|
|
|
The window style, see wxAC_* flags.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
Control name.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if the control was successfully created or @false if
|
|
|
|
creation failed.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
bool Create(wxWindow* parent, wxWindowID id,
|
2008-03-20 18:32:46 -04:00
|
|
|
const wxAnimation& anim = wxNullAnimation,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxAC_DEFAULT_STYLE,
|
2008-03-23 21:02:55 -04:00
|
|
|
const wxString& name = wxAnimationCtrlNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the animation associated with this control.
|
|
|
|
*/
|
2008-03-24 14:17:11 -04:00
|
|
|
virtual wxAnimation GetAnimation() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the inactive bitmap shown in this control when the;
|
|
|
|
see SetInactiveBitmap() for more info.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxBitmap GetInactiveBitmap() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the animation is being played.
|
|
|
|
*/
|
2008-03-24 14:17:11 -04:00
|
|
|
virtual bool IsPlaying() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Loads the animation from the given file and calls SetAnimation().
|
|
|
|
See wxAnimation::LoadFile for more info.
|
|
|
|
*/
|
2008-03-24 14:17:11 -04:00
|
|
|
virtual bool LoadFile(const wxString& file,
|
|
|
|
wxAnimationType animType = wxANIMATION_TYPE_ANY);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2008-05-17 18:51:52 -04:00
|
|
|
/**
|
|
|
|
Loads the animation from the given stream and calls SetAnimation().
|
|
|
|
See wxAnimation::Load() for more info.
|
|
|
|
*/
|
|
|
|
virtual bool Load(wxInputStream& file,
|
|
|
|
wxAnimationType animType = wxANIMATION_TYPE_ANY);
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Starts playing the animation.
|
2008-03-10 12:23:56 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
The animation is always played in loop mode (unless the last frame of the
|
2008-03-10 12:23:56 -04:00
|
|
|
animation has an infinite delay time) and always start from the first frame
|
|
|
|
even if you @ref Stop "stopped" it while some other frame was displayed.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-24 14:17:11 -04:00
|
|
|
virtual bool Play();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the animation to play in this control.
|
2008-03-10 12:23:56 -04:00
|
|
|
|
|
|
|
If the previous animation is being played, it's @ref Stop() stopped.
|
|
|
|
Until Play() isn't called, a static image, the first frame of the given
|
|
|
|
animation or the background colour will be shown
|
2008-03-08 08:52:38 -05:00
|
|
|
(see SetInactiveBitmap() for more info).
|
|
|
|
*/
|
2008-03-24 14:17:11 -04:00
|
|
|
virtual void SetAnimation(const wxAnimation& anim);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the bitmap to show on the control when it's not playing an animation.
|
2008-03-10 12:23:56 -04:00
|
|
|
|
|
|
|
If you set as inactive bitmap ::wxNullBitmap (which is the default), then the
|
|
|
|
first frame of the animation is instead shown when the control is inactive;
|
|
|
|
in this case, if there's no valid animation associated with the control
|
|
|
|
(see SetAnimation()), then the background colour of the window is shown.
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
If the control is not playing the animation, the given bitmap will be
|
2008-03-10 12:23:56 -04:00
|
|
|
immediately shown, otherwise it will be shown as soon as Stop() is called.
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Note that the inactive bitmap, if smaller than the control's size, will be
|
2008-03-10 12:23:56 -04:00
|
|
|
centered in the control; if bigger, it will be stretched to fit it.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-23 21:02:55 -04:00
|
|
|
virtual void SetInactiveBitmap(const wxBitmap& bmp);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Stops playing the animation.
|
|
|
|
The control will show the first frame of the animation, a custom static image or
|
2008-03-10 12:23:56 -04:00
|
|
|
the window's background colour as specified by the last SetInactiveBitmap() call.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-24 14:17:11 -04:00
|
|
|
virtual void Stop();
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxAnimation
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This class encapsulates the concept of a platform-dependent animation.
|
|
|
|
An animation is a sequence of frames of the same size.
|
|
|
|
Sound is not supported by wxAnimation.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2009-01-13 14:39:48 -05:00
|
|
|
Note that on wxGTK wxAnimation is capable of loading the formats supported
|
|
|
|
by the internally-used @c gdk-pixbuf library (typically this means only
|
2010-08-22 18:16:05 -04:00
|
|
|
@c wxANIMATION_TYPE_GIF).
|
2009-01-13 14:39:48 -05:00
|
|
|
On other platforms wxAnimation is always capable of loading both GIF and ANI
|
|
|
|
formats (i.e. both @c wxANIMATION_TYPE_GIF and @c wxANIMATION_TYPE_ANI).
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxadv}
|
2008-03-10 12:23:56 -04:00
|
|
|
@category{gdi}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@stdobjects
|
2008-03-10 12:23:56 -04:00
|
|
|
::wxNullAnimation
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-06-21 01:10:40 -04:00
|
|
|
@see wxAnimationCtrl, @sample{animate}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxAnimation : public wxGDIObject
|
|
|
|
{
|
|
|
|
public:
|
2008-03-20 18:32:46 -04:00
|
|
|
/**
|
|
|
|
Copy ctor.
|
|
|
|
*/
|
2008-03-10 12:23:56 -04:00
|
|
|
wxAnimation(const wxAnimation& anim);
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Loads an animation from a file.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
The name of the file to load.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param type
|
2009-01-13 14:26:53 -05:00
|
|
|
See LoadFile() for more info.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
wxAnimation(const wxString& name,
|
|
|
|
wxAnimationType type = wxANIMATION_TYPE_ANY);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
2008-03-10 12:23:56 -04:00
|
|
|
See @ref overview_refcount_destruct for more info.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-23 21:02:55 -04:00
|
|
|
virtual ~wxAnimation();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the delay for the i-th frame in milliseconds.
|
|
|
|
If @c -1 is returned the frame is to be displayed forever.
|
|
|
|
*/
|
2008-03-24 14:17:11 -04:00
|
|
|
virtual int GetDelay(unsigned int i) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the i-th frame as a wxImage.
|
2011-07-26 17:37:20 -04:00
|
|
|
|
|
|
|
This method is not implemented in the native wxGTK implementation of
|
|
|
|
this class and always returns an invalid image there.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-24 14:17:11 -04:00
|
|
|
virtual wxImage GetFrame(unsigned int i) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the number of frames for this animation.
|
2011-07-26 17:37:20 -04:00
|
|
|
|
|
|
|
This method is not implemented in the native wxGTK implementation of
|
|
|
|
this class and always returns 0 there.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-24 14:17:11 -04:00
|
|
|
virtual unsigned int GetFrameCount() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the size of the animation.
|
|
|
|
*/
|
2008-03-24 14:17:11 -04:00
|
|
|
virtual wxSize GetSize() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if animation data is present.
|
|
|
|
*/
|
2008-03-24 14:17:11 -04:00
|
|
|
virtual bool IsOk() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Loads an animation from the given stream.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param stream
|
2008-03-09 08:33:59 -04:00
|
|
|
The stream to use to load the animation.
|
2009-01-13 14:26:53 -05:00
|
|
|
Under wxGTK may be any kind of stream; under other platforms
|
|
|
|
this must be a seekable stream.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param type
|
2009-01-13 14:26:53 -05:00
|
|
|
One of the ::wxAnimationType enumeration values.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if the operation succeeded, @false otherwise.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-24 14:17:11 -04:00
|
|
|
virtual bool Load(wxInputStream& stream,
|
|
|
|
wxAnimationType type = wxANIMATION_TYPE_ANY);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Loads an animation from a file.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
A filename.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param type
|
2009-01-13 14:26:53 -05:00
|
|
|
One of the ::wxAnimationType values; wxANIMATION_TYPE_ANY
|
2008-03-10 12:23:56 -04:00
|
|
|
means that the function should try to autodetect the filetype.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if the operation succeeded, @false otherwise.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-24 14:17:11 -04:00
|
|
|
virtual bool LoadFile(const wxString& name,
|
|
|
|
wxAnimationType type = wxANIMATION_TYPE_ANY);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-10 12:23:56 -04:00
|
|
|
Assignment operator, using @ref overview_refcount "reference counting".
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-20 18:32:46 -04:00
|
|
|
wxAnimation& operator =(const wxAnimation& brush);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-14 11:35:10 -04:00
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Global functions/macros
|
|
|
|
// ============================================================================
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
/**
|
2008-03-10 12:23:56 -04:00
|
|
|
An empty animation object.
|
2008-03-10 11:24:38 -04:00
|
|
|
*/
|
|
|
|
wxAnimation wxNullAnimation;
|
|
|
|
|