diff --git a/include/wx/animate.h b/include/wx/animate.h index 1c6b45b23b..7badb01fb7 100644 --- a/include/wx/animate.h +++ b/include/wx/animate.h @@ -184,13 +184,6 @@ private: : wxGenericAnimationCtrl(parent, id, anim, pos, size, style, name) {} - - static wxAnimationImpl* CreateAnimationImpl(wxAnimationImplType WXUNUSED(implType)) - { - // For the generic widget we always use the generic impl and ignore the given type - return new wxAnimationGenericImpl(); - } - private: wxDECLARE_DYNAMIC_CLASS(wxAnimationCtrl); }; diff --git a/include/wx/generic/animate.h b/include/wx/generic/animate.h index 597f1591e9..50f3143214 100644 --- a/include/wx/generic/animate.h +++ b/include/wx/generic/animate.h @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: wx/generic/animate.h -// Purpose: wxAnimationGenericImpl and wxGenericAnimationCtrl +// Purpose: wxGenericAnimationCtrl // Author: Julian Smart and Guillermo Rodriguez Garcia // Modified by: Francesco Montorsi // Created: 13/8/99 @@ -13,43 +13,6 @@ #include "wx/bitmap.h" -// ---------------------------------------------------------------------------- -// wxGenericAnimation -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxAnimationGenericImpl : public wxAnimationImpl -{ -public: - wxAnimationGenericImpl() {} - - virtual wxAnimationImplType GetImplType() wxOVERRIDE - { return wxANIMATION_IMPL_TYPE_GENERIC; } - - virtual bool IsOk() const wxOVERRIDE - { return m_refData != NULL; } - - virtual unsigned int GetFrameCount() const wxOVERRIDE; - virtual int GetDelay(unsigned int i) const wxOVERRIDE; - virtual wxImage GetFrame(unsigned int i) const wxOVERRIDE; - virtual wxSize GetSize() const wxOVERRIDE; - - virtual bool LoadFile(const wxString& filename, - wxAnimationType type = wxANIMATION_TYPE_ANY) wxOVERRIDE; - virtual bool Load(wxInputStream& stream, - wxAnimationType type = wxANIMATION_TYPE_ANY) wxOVERRIDE; - - // extended interface used only by the generic implementation of wxAnimationCtrl - virtual wxPoint GetFramePosition(unsigned int frame) const; - virtual wxSize GetFrameSize(unsigned int frame) const; - virtual wxAnimationDisposal GetDisposalMethod(unsigned int frame) const; - virtual wxColour GetTransparentColour(unsigned int frame) const; - virtual wxColour GetBackgroundColour() const; - -protected: - wxDECLARE_NO_COPY_CLASS(wxAnimationGenericImpl); - wxDECLARE_DYNAMIC_CLASS(wxAnimationGenericImpl); -}; - // ---------------------------------------------------------------------------- // wxGenericAnimationCtrl @@ -129,6 +92,8 @@ public: // extended API specific to this implementation of wxAnimateCtrl wxBitmap& GetBackingStore() { return m_backingStore; } + static wxAnimationImpl* CreateAnimationImpl(wxAnimationImplType implType); + protected: // internal utilities // resize this control to fit m_animation diff --git a/include/wx/generic/private/animate.h b/include/wx/generic/private/animate.h new file mode 100644 index 0000000000..d5b89e2ca2 --- /dev/null +++ b/include/wx/generic/private/animate.h @@ -0,0 +1,54 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/generic/private/animate.h +// Purpose: wxAnimationGenericImpl +// Author: Julian Smart and Guillermo Rodriguez Garcia +// Modified by: Francesco Montorsi +// Created: 13/8/99 +// Copyright: (c) Julian Smart and Guillermo Rodriguez Garcia +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_GENERIC_PRIVATE_ANIMATEH__ +#define _WX_GENERIC_PRIVATE_ANIMATEH__ + +#include "wx/bitmap.h" + +// ---------------------------------------------------------------------------- +// wxAnimationGenericImpl +// ---------------------------------------------------------------------------- + +class WXDLLIMPEXP_ADV wxAnimationGenericImpl : public wxAnimationImpl +{ +public: + wxAnimationGenericImpl() {} + + virtual wxAnimationImplType GetImplType() wxOVERRIDE + { return wxANIMATION_IMPL_TYPE_GENERIC; } + + virtual bool IsOk() const wxOVERRIDE + { return m_refData != NULL; } + + virtual unsigned int GetFrameCount() const wxOVERRIDE; + virtual int GetDelay(unsigned int i) const wxOVERRIDE; + virtual wxImage GetFrame(unsigned int i) const wxOVERRIDE; + virtual wxSize GetSize() const wxOVERRIDE; + + virtual bool LoadFile(const wxString& filename, + wxAnimationType type = wxANIMATION_TYPE_ANY) wxOVERRIDE; + virtual bool Load(wxInputStream& stream, + wxAnimationType type = wxANIMATION_TYPE_ANY) wxOVERRIDE; + + // extended interface used only by the generic implementation of wxAnimationCtrl + virtual wxPoint GetFramePosition(unsigned int frame) const; + virtual wxSize GetFrameSize(unsigned int frame) const; + virtual wxAnimationDisposal GetDisposalMethod(unsigned int frame) const; + virtual wxColour GetTransparentColour(unsigned int frame) const; + virtual wxColour GetBackgroundColour() const; + +protected: + wxDECLARE_NO_COPY_CLASS(wxAnimationGenericImpl); + wxDECLARE_DYNAMIC_CLASS(wxAnimationGenericImpl); +}; + + +#endif // _WX_GENERIC_PRIVATE_ANIMATEH__ diff --git a/include/wx/gtk/animate.h b/include/wx/gtk/animate.h index 16d5064fad..08afe23002 100644 --- a/include/wx/gtk/animate.h +++ b/include/wx/gtk/animate.h @@ -14,62 +14,6 @@ typedef struct _GdkPixbufAnimation GdkPixbufAnimation; typedef struct _GdkPixbufAnimationIter GdkPixbufAnimationIter; -// ---------------------------------------------------------------------------- -// wxAnimation -// Unlike the generic wxAnimation object (see generic\animate.cpp), we won't -// use directly wxAnimationHandlers as gdk-pixbuf already provides the -// concept of handler and will automatically use the available handlers. -// Like generic wxAnimation object, this implementation of wxAnimation is -// refcounted so that assignment is very fast -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxAnimationGTKImpl : public wxAnimationImpl -{ -public: - wxAnimationGTKImpl() - : m_pixbuf(NULL) {} - ~wxAnimationGTKImpl() { UnRef(); } - - - virtual wxAnimationImplType GetImplType() wxOVERRIDE - { return wxANIMATION_IMPL_TYPE_NATIVE; } - - virtual bool IsOk() const wxOVERRIDE - { return m_pixbuf != NULL; } - - - // unfortunately GdkPixbufAnimation does not expose these info: - - virtual unsigned int GetFrameCount() const wxOVERRIDE { return 0; } - virtual wxImage GetFrame(unsigned int frame) const wxOVERRIDE; - - // we can retrieve the delay for a frame only after building - // a GdkPixbufAnimationIter... - virtual int GetDelay(unsigned int WXUNUSED(frame)) const wxOVERRIDE { return 0; } - virtual wxSize GetSize() const wxOVERRIDE; - - virtual bool LoadFile(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY) wxOVERRIDE; - virtual bool Load(wxInputStream &stream, wxAnimationType type = wxANIMATION_TYPE_ANY) wxOVERRIDE; - - // Implementation -public: // used by GTK callbacks - - GdkPixbufAnimation *GetPixbuf() const - { return m_pixbuf; } - void SetPixbuf(GdkPixbufAnimation* p); - -protected: - GdkPixbufAnimation *m_pixbuf; - -private: - void UnRef(); - - typedef wxAnimationImpl base_type; - wxDECLARE_NO_COPY_CLASS(wxAnimationGTKImpl); - wxDECLARE_DYNAMIC_CLASS(wxAnimationGTKImpl); -}; - - // ---------------------------------------------------------------------------- // wxAnimationCtrl // ---------------------------------------------------------------------------- diff --git a/include/wx/gtk/private/animate.h b/include/wx/gtk/private/animate.h new file mode 100644 index 0000000000..6337547ce7 --- /dev/null +++ b/include/wx/gtk/private/animate.h @@ -0,0 +1,71 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/gtk/private/animate.h +// Purpose: Animation classes +// Author: Julian Smart and Guillermo Rodriguez Garcia +// Modified by: Francesco Montorsi +// Created: 13/8/99 +// Copyright: (c) Julian Smart and Guillermo Rodriguez Garcia +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_GTK_PRIVATE_ANIMATEH__ +#define _WX_GTK_PRIVATE_ANIMATEH__ + +typedef struct _GdkPixbufAnimation GdkPixbufAnimation; +typedef struct _GdkPixbufAnimationIter GdkPixbufAnimationIter; + +// ---------------------------------------------------------------------------- +// wxAnimationGTKImpl +// Unlike the generic wxAnimation object we won't use directly +// wxAnimationDecoders as gdk-pixbuf already provides the concept of decoder and +// will automatically use the available handlers. +// ---------------------------------------------------------------------------- + +class WXDLLIMPEXP_ADV wxAnimationGTKImpl : public wxAnimationImpl +{ +public: + wxAnimationGTKImpl() + : m_pixbuf(NULL) {} + ~wxAnimationGTKImpl() { UnRef(); } + + + virtual wxAnimationImplType GetImplType() wxOVERRIDE + { return wxANIMATION_IMPL_TYPE_NATIVE; } + + virtual bool IsOk() const wxOVERRIDE + { return m_pixbuf != NULL; } + + + // unfortunately GdkPixbufAnimation does not expose these info: + + virtual unsigned int GetFrameCount() const wxOVERRIDE { return 0; } + virtual wxImage GetFrame(unsigned int frame) const wxOVERRIDE; + + // we can retrieve the delay for a frame only after building + // a GdkPixbufAnimationIter... + virtual int GetDelay(unsigned int WXUNUSED(frame)) const wxOVERRIDE { return 0; } + virtual wxSize GetSize() const wxOVERRIDE; + + virtual bool LoadFile(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY) wxOVERRIDE; + virtual bool Load(wxInputStream &stream, wxAnimationType type = wxANIMATION_TYPE_ANY) wxOVERRIDE; + + // Implementation +public: // used by GTK callbacks + + GdkPixbufAnimation *GetPixbuf() const + { return m_pixbuf; } + void SetPixbuf(GdkPixbufAnimation* p); + +protected: + GdkPixbufAnimation *m_pixbuf; + +private: + void UnRef(); + + typedef wxAnimationImpl base_type; + wxDECLARE_NO_COPY_CLASS(wxAnimationGTKImpl); + wxDECLARE_DYNAMIC_CLASS(wxAnimationGTKImpl); +}; + + +#endif // _WX_GTK_PRIVATE_ANIMATEH__ diff --git a/src/generic/animateg.cpp b/src/generic/animateg.cpp index 7798e85bed..baff574048 100644 --- a/src/generic/animateg.cpp +++ b/src/generic/animateg.cpp @@ -16,6 +16,7 @@ #if wxUSE_ANIMATIONCTRL #include "wx/animate.h" +#include "wx/generic/private/animate.h" #ifndef WX_PRECOMP #include "wx/log.h" @@ -594,7 +595,18 @@ void wxGenericAnimationCtrl::OnSize(wxSizeEvent &WXUNUSED(event)) } } +// ---------------------------------------------------------------------------- + +//static +wxAnimationImpl* wxGenericAnimationCtrl::CreateAnimationImpl(wxAnimationImplType WXUNUSED(implType)) +{ + // For the generic widget we always use the generic impl and ignore the given type + return new wxAnimationGenericImpl(); +} + +// ---------------------------------------------------------------------------- // helpers to safely access wxAnimationGenericImpl methods +// ---------------------------------------------------------------------------- #define ANIMATION (static_cast(m_animation.GetImpl())) wxPoint wxGenericAnimationCtrl::AnimationImplGetFramePosition(unsigned int frame) const diff --git a/src/gtk/animate.cpp b/src/gtk/animate.cpp index 8a60886888..d5181c5ded 100644 --- a/src/gtk/animate.cpp +++ b/src/gtk/animate.cpp @@ -13,6 +13,7 @@ #if wxUSE_ANIMATIONCTRL #include "wx/animate.h" +#include "wx/gtk/private/animate.h" #ifndef WX_PRECOMP #include "wx/image.h"