* Switch back to using an wxAnimationBase class
* Change the [GS]etAnimation methods to be non-virtual so they can use generic/native types of animation obj
This commit is contained in:
parent
08ac4dbad6
commit
a7f9d5e3c5
@ -20,9 +20,11 @@
|
||||
#include "wx/timer.h"
|
||||
#include "wx/bitmap.h"
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxAnimation;
|
||||
class WXDLLIMPEXP_FWD_CORE wxGenericAnimation;
|
||||
|
||||
extern WXDLLIMPEXP_DATA_CORE(wxGenericAnimation) wxNullAnimation;
|
||||
extern WXDLLIMPEXP_DATA_CORE(wxAnimation) wxNullAnimation;
|
||||
extern WXDLLIMPEXP_DATA_CORE(wxGenericAnimation) wxNullGenericAnimation;
|
||||
extern WXDLLIMPEXP_DATA_CORE(const char) wxAnimationCtrlNameStr[];
|
||||
|
||||
|
||||
@ -32,46 +34,38 @@ extern WXDLLIMPEXP_DATA_CORE(const char) wxAnimationCtrlNameStr[];
|
||||
|
||||
WX_DECLARE_LIST_WITH_DECL(wxAnimationDecoder, wxAnimationDecoderList, class WXDLLIMPEXP_ADV);
|
||||
|
||||
class WXDLLIMPEXP_ADV wxGenericAnimation : public wxObject
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxAnimationBase
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_CORE wxAnimationBase : public wxObject
|
||||
{
|
||||
public:
|
||||
wxGenericAnimation() {}
|
||||
wxGenericAnimation(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY)
|
||||
{ LoadFile(name, type); }
|
||||
wxAnimationBase() {}
|
||||
|
||||
virtual bool IsOk() const
|
||||
{ return m_refData != NULL; }
|
||||
virtual bool IsOk() const = 0;
|
||||
|
||||
virtual unsigned int GetFrameCount() const;
|
||||
virtual int GetDelay(unsigned int i) const;
|
||||
virtual wxImage GetFrame(unsigned int i) const;
|
||||
virtual wxSize GetSize() const;
|
||||
// can be -1
|
||||
virtual int GetDelay(unsigned int frame) const = 0;
|
||||
|
||||
virtual bool LoadFile(const wxString& filename,
|
||||
wxAnimationType type = wxANIMATION_TYPE_ANY);
|
||||
virtual unsigned int GetFrameCount() const = 0;
|
||||
virtual wxImage GetFrame(unsigned int frame) const = 0;
|
||||
virtual wxSize GetSize() const = 0;
|
||||
|
||||
virtual bool LoadFile(const wxString& name,
|
||||
wxAnimationType type = wxANIMATION_TYPE_ANY) = 0;
|
||||
virtual bool Load(wxInputStream& stream,
|
||||
wxAnimationType type = wxANIMATION_TYPE_ANY);
|
||||
wxAnimationType type = wxANIMATION_TYPE_ANY) = 0;
|
||||
|
||||
// extended interface used 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;
|
||||
// extended interface used only by the generic implementation of wxAnimationCtrl
|
||||
virtual wxPoint GetFramePosition(unsigned int frame) const = 0;
|
||||
virtual wxSize GetFrameSize(unsigned int frame) const = 0;
|
||||
virtual wxAnimationDisposal GetDisposalMethod(unsigned int frame) const = 0;
|
||||
virtual wxColour GetTransparentColour(unsigned int frame) const = 0;
|
||||
virtual wxColour GetBackgroundColour() const = 0;
|
||||
|
||||
protected:
|
||||
static wxAnimationDecoderList sm_handlers;
|
||||
|
||||
public:
|
||||
static inline wxAnimationDecoderList& GetHandlers() { return sm_handlers; }
|
||||
static void AddHandler(wxAnimationDecoder *handler);
|
||||
static void InsertHandler(wxAnimationDecoder *handler);
|
||||
static const wxAnimationDecoder *FindHandler( wxAnimationType animType );
|
||||
|
||||
static void CleanUpHandlers();
|
||||
static void InitStandardHandlers();
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS(wxGenericAnimation);
|
||||
wxDECLARE_ABSTRACT_CLASS(wxAnimationBase);
|
||||
};
|
||||
|
||||
|
||||
@ -98,9 +92,6 @@ public:
|
||||
virtual bool Load(wxInputStream& stream,
|
||||
wxAnimationType type = wxANIMATION_TYPE_ANY) = 0;
|
||||
|
||||
virtual void SetAnimation(const wxGenericAnimation &anim) = 0;
|
||||
virtual wxGenericAnimation GetAnimation() const = 0;
|
||||
|
||||
virtual bool Play() = 0;
|
||||
virtual void Stop() = 0;
|
||||
|
||||
@ -135,7 +126,8 @@ private:
|
||||
// include the platform-specific version of the wxAnimationCtrl class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
|
||||
#if defined(__WXGTK20__)
|
||||
#include "wx/generic/animate.h"
|
||||
#include "wx/gtk/animate.h"
|
||||
#else
|
||||
#include "wx/generic/animate.h"
|
||||
@ -147,6 +139,8 @@ private:
|
||||
: wxGenericAnimation() {}
|
||||
wxAnimation(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY)
|
||||
: wxGenericAnimation(name, type) {}
|
||||
wxAnimation(const wxGenericAnimation& other)
|
||||
: wxGenericAnimation(other) {}
|
||||
private:
|
||||
wxDECLARE_DYNAMIC_CLASS(wxAnimation);
|
||||
};
|
||||
@ -154,18 +148,22 @@ private:
|
||||
class WXDLLIMPEXP_ADV wxAnimationCtrl : public wxGenericAnimationCtrl
|
||||
{
|
||||
public:
|
||||
wxAnimationCtrl()
|
||||
wxAnimationCtrl()
|
||||
: wxGenericAnimationCtrl()
|
||||
{}
|
||||
wxAnimationCtrl(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxGenericAnimation& anim = wxNullAnimation,
|
||||
const wxAnimation& anim = wxNullAnimation,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxAC_DEFAULT_STYLE,
|
||||
const wxString& name = wxAnimationCtrlNameStr)
|
||||
: wxGenericAnimationCtrl(parent, id, anim, pos, size, style, name)
|
||||
{}
|
||||
|
||||
virtual wxAnimation GetAnimation() const
|
||||
{ return wxAnimation(m_animation) ; }
|
||||
|
||||
private:
|
||||
wxDECLARE_DYNAMIC_CLASS(wxAnimationCtrl);
|
||||
};
|
||||
|
@ -13,6 +13,53 @@
|
||||
|
||||
#include "wx/bitmap.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxGenericAnimation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxGenericAnimation : public wxAnimationBase
|
||||
{
|
||||
public:
|
||||
wxGenericAnimation() {}
|
||||
wxGenericAnimation(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY)
|
||||
{ LoadFile(name, type); }
|
||||
|
||||
virtual bool IsOk() const
|
||||
{ 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 wxOVERRIDE;
|
||||
virtual wxSize GetFrameSize(unsigned int frame) const wxOVERRIDE;
|
||||
virtual wxAnimationDisposal GetDisposalMethod(unsigned int frame) const wxOVERRIDE;
|
||||
virtual wxColour GetTransparentColour(unsigned int frame) const wxOVERRIDE;
|
||||
virtual wxColour GetBackgroundColour() const wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
static wxAnimationDecoderList sm_handlers;
|
||||
|
||||
public:
|
||||
static inline wxAnimationDecoderList& GetHandlers() { return sm_handlers; }
|
||||
static void AddHandler(wxAnimationDecoder *handler);
|
||||
static void InsertHandler(wxAnimationDecoder *handler);
|
||||
static const wxAnimationDecoder *FindHandler( wxAnimationType animType );
|
||||
|
||||
static void CleanUpHandlers();
|
||||
static void InitStandardHandlers();
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS(wxGenericAnimation);
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxGenericAnimationCtrl
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -23,7 +70,7 @@ public:
|
||||
wxGenericAnimationCtrl() { Init(); }
|
||||
wxGenericAnimationCtrl(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxGenericAnimation& anim = wxNullAnimation,
|
||||
const wxGenericAnimation& anim = wxNullGenericAnimation,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxAC_DEFAULT_STYLE,
|
||||
@ -37,7 +84,7 @@ public:
|
||||
void Init();
|
||||
|
||||
bool Create(wxWindow *parent, wxWindowID id,
|
||||
const wxGenericAnimation& anim = wxNullAnimation,
|
||||
const wxGenericAnimation& anim = wxNullGenericAnimation,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxAC_DEFAULT_STYLE,
|
||||
@ -45,6 +92,7 @@ public:
|
||||
|
||||
~wxGenericAnimationCtrl();
|
||||
|
||||
|
||||
public:
|
||||
virtual bool LoadFile(const wxString& filename, wxAnimationType type = wxANIMATION_TYPE_ANY) wxOVERRIDE;
|
||||
virtual bool Load(wxInputStream& stream, wxAnimationType type = wxANIMATION_TYPE_ANY) wxOVERRIDE;
|
||||
@ -55,8 +103,8 @@ public:
|
||||
virtual bool IsPlaying() const wxOVERRIDE
|
||||
{ return m_isPlaying; }
|
||||
|
||||
void SetAnimation(const wxGenericAnimation &animation) wxOVERRIDE;
|
||||
wxGenericAnimation GetAnimation() const wxOVERRIDE
|
||||
void SetAnimation(const wxGenericAnimation &animation);
|
||||
wxGenericAnimation GetAnimation() const
|
||||
{ return m_animation; }
|
||||
|
||||
virtual void SetInactiveBitmap(const wxBitmap &bmp) wxOVERRIDE;
|
||||
|
@ -38,20 +38,32 @@ public:
|
||||
{ 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;
|
||||
|
||||
// unfortunately GdkPixbufAnimation does not expose these info:
|
||||
|
||||
virtual unsigned int GetFrameCount() const wxOVERRIDE
|
||||
{ return 0; }
|
||||
virtual wxImage GetFrame(unsigned int WXUNUSED(frame)) const wxOVERRIDE
|
||||
{ return wxNullImage; }
|
||||
virtual wxPoint GetFramePosition(unsigned int WXUNUSED(frame)) const wxOVERRIDE
|
||||
{ return wxDefaultPosition; }
|
||||
virtual wxSize GetFrameSize(unsigned int WXUNUSED(frame)) const wxOVERRIDE
|
||||
{ return wxDefaultSize; }
|
||||
virtual wxAnimationDisposal GetDisposalMethod(unsigned int WXUNUSED(frame)) const wxOVERRIDE
|
||||
{ return wxANIM_UNSPECIFIED; }
|
||||
virtual wxColour GetTransparentColour(unsigned int WXUNUSED(frame)) const wxOVERRIDE
|
||||
{ return wxNullColour; }
|
||||
virtual wxColour GetBackgroundColour() const wxOVERRIDE
|
||||
{ return wxNullColour; }
|
||||
|
||||
|
||||
// Implementation
|
||||
public: // used by GTK callbacks
|
||||
|
||||
@ -112,9 +124,9 @@ public: // public API
|
||||
virtual bool LoadFile(const wxString& filename, wxAnimationType type = wxANIMATION_TYPE_ANY) wxOVERRIDE;
|
||||
virtual bool Load(wxInputStream& stream, wxAnimationType type = wxANIMATION_TYPE_ANY) wxOVERRIDE;
|
||||
|
||||
virtual void SetAnimation(const wxAnimation &anim) wxOVERRIDE;
|
||||
virtual wxAnimation GetAnimation() const wxOVERRIDE
|
||||
{ return wxAnimation(m_anim); }
|
||||
void SetAnimation(const wxAnimation &anim);
|
||||
wxAnimation GetAnimation() const
|
||||
{ return wxAnimation(m_anim) ; }
|
||||
|
||||
virtual bool Play() wxOVERRIDE;
|
||||
virtual void Stop() wxOVERRIDE;
|
||||
|
@ -30,14 +30,18 @@
|
||||
#include "wx/dcmemory.h"
|
||||
|
||||
const char wxAnimationCtrlNameStr[] = "animationctrl";
|
||||
wxGenericAnimation wxNullGenericAnimation;
|
||||
wxAnimation wxNullAnimation;
|
||||
|
||||
// global object
|
||||
wxGenericAnimation wxNullAnimation;
|
||||
|
||||
wxIMPLEMENT_DYNAMIC_CLASS(wxAnimation, wxGenericAnimation);
|
||||
wxIMPLEMENT_ABSTRACT_CLASS(wxAnimationBase, wxObject);
|
||||
wxIMPLEMENT_ABSTRACT_CLASS(wxAnimationCtrlBase, wxControl);
|
||||
wxIMPLEMENT_DYNAMIC_CLASS(wxAnimationCtrl, wxAnimationCtrlBase);
|
||||
wxIMPLEMENT_DYNAMIC_CLASS(wxAnimation, wxAnimationBase);
|
||||
wxIMPLEMENT_DYNAMIC_CLASS(wxGenericAnimation, wxAnimationBase);
|
||||
|
||||
#if !defined(__WXGTK20__)
|
||||
// In this case the "native" ctrl is the generic ctrl. See wx/animate.h
|
||||
wxIMPLEMENT_CLASS(wxAnimationCtrl, wxGenericAnimationCtrl);
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxAnimationCtrlBase
|
||||
|
@ -39,7 +39,6 @@ wxAnimationDecoderList wxGenericAnimation::sm_handlers;
|
||||
// wxAnimation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxIMPLEMENT_DYNAMIC_CLASS(wxGenericAnimation, wxObject);
|
||||
#define M_ANIMDATA static_cast<wxAnimationDecoder*>(m_refData)
|
||||
|
||||
wxSize wxGenericAnimation::GetSize() const
|
||||
@ -313,7 +312,7 @@ bool wxGenericAnimationCtrl::LoadFile(const wxString& filename, wxAnimationType
|
||||
|
||||
bool wxGenericAnimationCtrl::Load(wxInputStream& stream, wxAnimationType type)
|
||||
{
|
||||
wxAnimation anim;
|
||||
wxGenericAnimation anim;
|
||||
if ( !anim.Load(stream, type) || !anim.IsOk() )
|
||||
return false;
|
||||
|
||||
@ -554,7 +553,7 @@ void wxGenericAnimationCtrl::DisplayStaticImage()
|
||||
if (!m_animation.IsOk() ||
|
||||
!RebuildBackingStoreUpToFrame(0))
|
||||
{
|
||||
m_animation = wxNullAnimation;
|
||||
m_animation = wxNullGenericAnimation;
|
||||
DisposeToBackground();
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@
|
||||
#if wxUSE_ANIMATIONCTRL
|
||||
#include "wx/animate.h"
|
||||
|
||||
#if !wxUSE_GENERIC_ANIMATIONCTRL
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/image.h"
|
||||
@ -53,7 +52,6 @@ void gdk_pixbuf_area_updated(GdkPixbufLoader *loader,
|
||||
// wxAnimation
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
wxIMPLEMENT_DYNAMIC_CLASS(wxAnimation, wxAnimationBase);
|
||||
|
||||
wxAnimation::wxAnimation(const wxAnimation& that)
|
||||
: base_type(that)
|
||||
@ -177,11 +175,6 @@ bool wxAnimation::Load(wxInputStream &stream, wxAnimationType type)
|
||||
return data_written;
|
||||
}
|
||||
|
||||
wxImage wxAnimation::GetFrame(unsigned int WXUNUSED(frame)) const
|
||||
{
|
||||
return wxNullImage;
|
||||
}
|
||||
|
||||
wxSize wxAnimation::GetSize() const
|
||||
{
|
||||
return wxSize(gdk_pixbuf_animation_get_width(m_pixbuf),
|
||||
@ -467,5 +460,4 @@ void wxAnimationCtrl::OnTimer(wxTimerEvent& WXUNUSED(ev))
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !wxUSE_GENERIC_ANIMATIONCTRL
|
||||
#endif // wxUSE_ANIMATIONCTRL
|
||||
|
Loading…
Reference in New Issue
Block a user