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$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
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
|
|
|
|
@wxheader{animate.h}
|
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-03-08 08:52:38 -05:00
|
|
|
@appearance{animationctrl.png}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxAnimation
|
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
|
|
|
|
2008-03-10 12:23:56 -04:00
|
|
|
After control creation you must explicitely call Play() to start to play
|
|
|
|
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-03-08 08:52:38 -05:00
|
|
|
@returns @true if the control was successfully created or @false if
|
2008-03-09 08:33:59 -04:00
|
|
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
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
|
|
|
|
@wxheader{animate.h}
|
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
|
|
|
|
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-03-10 11:24:38 -04:00
|
|
|
@see wxAnimationCtrl
|
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
|
2008-03-09 08:33:59 -04: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.
|
|
|
|
*/
|
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.
|
|
|
|
*/
|
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.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param type
|
2008-03-09 08:33:59 -04:00
|
|
|
One of the following values:
|
2008-03-10 12:23:56 -04:00
|
|
|
@li wxANIMATION_TYPE_GIF: loads an animated GIF file;
|
|
|
|
@li wxANIMATION_TYPE_ANI: load an ANI file;
|
|
|
|
@li wxANIMATION_TYPE_ANY: tries to autodetect the filetype.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@returns @true if the operation succeeded, @false otherwise.
|
|
|
|
*/
|
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
|
2008-03-10 12:23:56 -04:00
|
|
|
One of the wxAnimationType values; wxANIMATION_TYPE_ANY
|
|
|
|
means that the function should try to autodetect the filetype.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@returns @true if the operation succeeded, @false otherwise.
|
|
|
|
*/
|
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;
|
|
|
|
|