X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/870cf35c4596571462c5e2d1395428b135196b98..9b49405777342458dc1666001865eef7309b6c30:/src/generic/animateg.cpp diff --git a/src/generic/animateg.cpp b/src/generic/animateg.cpp index c957313fad..fe6ee204da 100644 --- a/src/generic/animateg.cpp +++ b/src/generic/animateg.cpp @@ -15,7 +15,7 @@ #pragma hdrstop #endif //__BORLANDC__ -#if wxUSE_ANIMATIONCTRL && (!defined(__WXGTK20__) || defined(__WXUNIVERSAL__)) +#if wxUSE_ANIMATIONCTRL #include "wx/animate.h" @@ -42,7 +42,7 @@ wxAnimationDecoderList wxAnimation::sm_handlers; // ---------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxAnimation, wxAnimationBase) -#define M_ANIMDATA wx_static_cast(wxAnimationDecoder*, m_refData) +#define M_ANIMDATA static_cast(m_refData) wxSize wxAnimation::GetSize() const { @@ -138,7 +138,6 @@ bool wxAnimation::Load(wxInputStream &stream, wxAnimationType type) m_refData = handler->Clone(); return M_ANIMDATA->Load(stream); } - } wxLogWarning( _("No handler found for animation type.") ); @@ -147,10 +146,6 @@ bool wxAnimation::Load(wxInputStream &stream, wxAnimationType type) handler = FindHandler(type); - // do a copy of the handler from the static list which we will own - // as our reference data - m_refData = handler->Clone(); - if (handler == NULL) { wxLogWarning( _("No animation handler for type %ld defined."), type ); @@ -158,6 +153,11 @@ bool wxAnimation::Load(wxInputStream &stream, wxAnimationType type) return false; } + + // do a copy of the handler from the static list which we will own + // as our reference data + m_refData = handler->Clone(); + if (stream.IsSeekable() && !M_ANIMDATA->CanRead(stream)) { wxLogError(_("Animation file is not of type %ld."), type); @@ -254,8 +254,8 @@ class wxAnimationModule: public wxModule DECLARE_DYNAMIC_CLASS(wxAnimationModule) public: wxAnimationModule() {} - bool OnInit() { wxAnimation::InitStandardHandlers(); return true; }; - void OnExit() { wxAnimation::CleanUpHandlers(); }; + bool OnInit() { wxAnimation::InitStandardHandlers(); return true; } + void OnExit() { wxAnimation::CleanUpHandlers(); } }; IMPLEMENT_DYNAMIC_CLASS(wxAnimationModule, wxModule) @@ -306,10 +306,17 @@ wxAnimationCtrl::~wxAnimationCtrl() } bool wxAnimationCtrl::LoadFile(const wxString& filename, wxAnimationType type) +{ + wxFileInputStream fis(filename); + if (!fis.Ok()) + return false; + return Load(fis, type); +} + +bool wxAnimationCtrl::Load(wxInputStream& stream, wxAnimationType type) { wxAnimation anim; - if (!anim.LoadFile(filename, type) || - !anim.IsOk()) + if ( !anim.Load(stream, type) || !anim.IsOk() ) return false; SetAnimation(anim); @@ -417,7 +424,7 @@ bool wxAnimationCtrl::Play(bool looped) int delay = m_animation.GetDelay(0); if (delay == 0) delay = 1; // 0 is invalid timeout for wxTimer. - m_timer.Start(delay); + m_timer.Start(delay, true); return true; } @@ -662,7 +669,7 @@ void wxAnimationCtrl::OnTimer(wxTimerEvent &WXUNUSED(event)) int delay = m_animation.GetDelay(m_currentFrame); if (delay == 0) delay = 1; // 0 is invalid timeout for wxTimer. - m_timer.Start(delay); + m_timer.Start(delay, true); } void wxAnimationCtrl::OnSize(wxSizeEvent &WXUNUSED(event)) @@ -686,5 +693,5 @@ void wxAnimationCtrl::OnSize(wxSizeEvent &WXUNUSED(event)) } } -#endif // wxUSE_ANIMATIONCTRL +#endif // wxUSE_ANIMATIONCTRL