From: Vadim Zeitlin Date: Sat, 17 May 2008 22:51:52 +0000 (+0000) Subject: allow loading wxAnimationCtrl contents from stream (patch 1962344) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/462167a9f7f9bace458054445806dd30c1ba2079?hp=7bf2b0881a6bf28138f258504e88b2643daa854e allow loading wxAnimationCtrl contents from stream (patch 1962344) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53629 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/animate.h b/include/wx/animate.h index 27f37a3b80..97321c5994 100644 --- a/include/wx/animate.h +++ b/include/wx/animate.h @@ -75,6 +75,8 @@ public: // public API virtual bool LoadFile(const wxString& filename, wxAnimationType type = wxANIMATION_TYPE_ANY) = 0; + virtual bool Load(wxInputStream& stream, + wxAnimationType type = wxANIMATION_TYPE_ANY) = 0; virtual void SetAnimation(const wxAnimation &anim) = 0; virtual wxAnimation GetAnimation() const = 0; diff --git a/include/wx/generic/animate.h b/include/wx/generic/animate.h index 883c8a5952..dee5f28364 100644 --- a/include/wx/generic/animate.h +++ b/include/wx/generic/animate.h @@ -97,6 +97,7 @@ public: public: virtual bool LoadFile(const wxString& filename, wxAnimationType type = wxANIMATION_TYPE_ANY); + virtual bool Load(wxInputStream& stream, wxAnimationType type = wxANIMATION_TYPE_ANY); virtual void Stop(); virtual bool Play() diff --git a/include/wx/gtk/animate.h b/include/wx/gtk/animate.h index 67a5f6d1b3..8a568a7057 100644 --- a/include/wx/gtk/animate.h +++ b/include/wx/gtk/animate.h @@ -113,6 +113,7 @@ public: // event handler public: // public API virtual bool LoadFile(const wxString& filename, wxAnimationType type = wxANIMATION_TYPE_ANY); + virtual bool Load(wxInputStream& stream, wxAnimationType type = wxANIMATION_TYPE_ANY); virtual void SetAnimation(const wxAnimation &anim); virtual wxAnimation GetAnimation() const diff --git a/interface/animate.h b/interface/animate.h index 7d7e3e3403..c2f4735b3c 100644 --- a/interface/animate.h +++ b/interface/animate.h @@ -123,6 +123,13 @@ public: virtual bool LoadFile(const wxString& file, wxAnimationType animType = wxANIMATION_TYPE_ANY); + /** + 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); + /** Starts playing the animation. diff --git a/src/generic/animateg.cpp b/src/generic/animateg.cpp index 17605f1af8..a2a50f94be 100644 --- a/src/generic/animateg.cpp +++ b/src/generic/animateg.cpp @@ -307,10 +307,15 @@ wxAnimationCtrl::~wxAnimationCtrl() } bool wxAnimationCtrl::LoadFile(const wxString& filename, wxAnimationType type) +{ + wxFileInputStream fis(filename); + 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); diff --git a/src/gtk/animate.cpp b/src/gtk/animate.cpp index f9190b6c05..4c0f3dde70 100644 --- a/src/gtk/animate.cpp +++ b/src/gtk/animate.cpp @@ -232,9 +232,15 @@ wxAnimationCtrl::~wxAnimationCtrl() } bool wxAnimationCtrl::LoadFile(const wxString &filename, wxAnimationType type) +{ + wxFileInputStream fis(filename); + return Load(fis, type); +} + +bool wxAnimationCtrl::Load(wxInputStream& stream, wxAnimationType type) { wxAnimation anim; - if (!anim.LoadFile(filename, type)) + if ( !anim.Load(stream, type) || !anim.IsOk() ) return false; SetAnimation(anim);