diff --git a/include/wx/animate.h b/include/wx/animate.h index 316c2a5ec9..6c076f3b85 100644 --- a/include/wx/animate.h +++ b/include/wx/animate.h @@ -115,12 +115,16 @@ public: { return m_bmpStatic; } wxAnimation CreateAnimation() const - { return wxAnimation(DoCreateAnimationImpl()); } + { return MakeAnimFromImpl(DoCreateAnimationImpl()); } protected: virtual wxAnimationImpl* DoCreateAnimationImpl() const = 0; - // This method allows derived classes access to wxAnimation::GetImpl(). + // These methods allow derived classes access to private wxAnimation ctor + // and wxAnimation::GetImpl(), respectively. + static wxAnimation MakeAnimFromImpl(wxAnimationImpl* impl) + { return wxAnimation(impl); } + wxAnimationImpl* GetAnimImpl() const { return m_animation.GetImpl(); } diff --git a/include/wx/generic/animate.h b/include/wx/generic/animate.h index 7de8ac8190..54487b21ee 100644 --- a/include/wx/generic/animate.h +++ b/include/wx/generic/animate.h @@ -64,6 +64,8 @@ public: // override base class method virtual bool SetBackgroundColour(const wxColour& col) wxOVERRIDE; + static wxAnimation CreateCompatibleAnimation(); + public: // event handlers void OnPaint(wxPaintEvent& event); diff --git a/include/wx/gtk/animate.h b/include/wx/gtk/animate.h index 8b9983c585..6b8ab3ac9b 100644 --- a/include/wx/gtk/animate.h +++ b/include/wx/gtk/animate.h @@ -65,6 +65,8 @@ public: // public API bool SetBackgroundColour( const wxColour &colour ) wxOVERRIDE; + static wxAnimation CreateCompatibleAnimation(); + protected: virtual wxAnimationImpl* DoCreateAnimationImpl() const wxOVERRIDE; diff --git a/interface/wx/animate.h b/interface/wx/animate.h index 2b0d4c7636..3233ae0099 100644 --- a/interface/wx/animate.h +++ b/interface/wx/animate.h @@ -113,10 +113,22 @@ public: A wxAnimation object created using this function is always compatible with controls of this type, see wxAnimation::IsCompatibleWith(). + @see CreateCompatibleAnimation() + @since 3.1.4 */ wxAnimation CreateAnimation() const; + /** + Create a new animation object compatible with this control. + + This method does the same thing as CreateAnimation() but is static, + i.e. can be called without creating any wxAnimationCtrl objects. + + @since 3.1.4 + */ + static wxAnimation CreateCompatibleAnimation(); + /** Returns the animation associated with this control. */ diff --git a/src/generic/animateg.cpp b/src/generic/animateg.cpp index 237cad4ef2..bfd826eb04 100644 --- a/src/generic/animateg.cpp +++ b/src/generic/animateg.cpp @@ -225,6 +225,11 @@ bool wxGenericAnimationCtrl::Load(wxInputStream& stream, wxAnimationType type) return true; } +wxAnimation wxGenericAnimationCtrl::CreateCompatibleAnimation() +{ + return MakeAnimFromImpl(new wxAnimationGenericImpl()); +} + wxAnimationImpl* wxGenericAnimationCtrl::DoCreateAnimationImpl() const { return new wxAnimationGenericImpl(); diff --git a/src/gtk/animate.cpp b/src/gtk/animate.cpp index d6e17a4f70..bb52a72a54 100644 --- a/src/gtk/animate.cpp +++ b/src/gtk/animate.cpp @@ -265,6 +265,11 @@ bool wxAnimationCtrl::Load(wxInputStream& stream, wxAnimationType type) return true; } +wxAnimation wxAnimationCtrl::CreateCompatibleAnimation() +{ + return MakeAnimFromImpl(new wxAnimationGTKImpl()); +} + wxAnimationImpl* wxAnimationCtrl::DoCreateAnimationImpl() const { return new wxAnimationGTKImpl();