contents up previous next

wxanimationctrl

this is a static control which displays an animation. wxanimationctrl api is simple as possible and won't give you full control on the animation; if you need it then use wxmediactrl.

this control is useful to display a (small) animation while doing a long task (e.g. a "throbber").

it is only available if wxuse_animationctrl is set to 1 (the default).

derived from

wxcontrol
wxwindow
wxevthandler
wxobject

include files

<wx/animate.h>

window styles

wxac_default_style the default style: wxno_border.
wxac_no_autoresize 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

see also

wxanimation

members

wxanimationctrl::wxanimationctrl
wxanimationctrl::create
wxanimationctrl::getanimation
wxanimationctrl::getinactivebitmap
wxanimationctrl::isplaying
wxanimationctrl::loadfile
wxanimationctrl::play
wxanimationctrl::setanimation
wxanimationctrl::setinactivebitmap
wxanimationctrl::stop


wxanimationctrl::wxanimationctrl

wxanimationctrl(wxwindow *parent, wxwindowid id, const wxanimation& anim, const wxpoint& pos = wxdefaultposition, const wxsize& size = wxdefaultsize, long style = wxac_default_style, const wxstring& name = "animationctrl")

initializes the object and calls create with all the parameters.


wxanimationctrl::create

bool create(wxwindow *parent, wxwindowid id, const wxanimation& anim, const wxpoint& pos = wxdefaultposition, const wxsize& size = wxdefaultsize, long style = wxac_default_style, const wxstring& name = "animationctrl")

parameters

parent

id

anim

pos

size

style

name

after control creation you must explicitely call play to start to play the animation. until that function won't be called, the first frame of the animation is displayed.

return value

true if the control was successfully created or false if creation failed.


wxanimationctrl::getanimation

wxanimation getanimation() const

returns the animation associated with this control.


wxanimationctrl::getinactivebitmap

wxbitmap getinactivebitmap() const

returns the inactive bitmap shown in this control when the; see setinactivebitmap for more info.


wxanimationctrl::isplaying

bool isplaying() const

returns true if the animation is being played.


wxanimationctrl::loadfile

bool loadfile(const wxstring & file, wxanimationtype animtype = wxanimation_type_any)

loads the animation from the given file and calls setanimation. see wxanimation::loadfile for more info.


wxanimationctrl::play

bool play()

starts playing the animation. the animation is always played in loop mode (unless the last frame of the animation has an infinite delay time) and always start from the first frame (even if you stopped it while some other frame was displayed).


wxanimationctrl::setanimation

void setanimation(const wxanimation & anim)

sets the animation to play in this control. if the previous animation is being played, it's stopped.

until play isn't called, a static image, the first frame of the given animation or the background colour will be shown (see setinactivebitmap for more info).


wxanimationctrl::setinactivebitmap

void setinactivebitmap(const wxbitmap& bmp)

sets the bitmap to show on the control when it's not playing an animation. 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.

if the control is not playing the animation, the given bitmap will be immediately shown, otherwise it will be shown as soon as stop is called.

note that the inactive bitmap, if smaller than the control's size, will be centered in the control; if bigger, it will be stretched to fit it.


wxanimationctrl::stop

void stop()

stops playing the animation. the control will show the first frame of the animation, a custom static image or the window's background colour as specified by the last setinactivebitmap call.