* Rename the generic version as wxGenericAnimationCtrl

* Add a simple shim class for the generic wxAnimationCtrl
* Use the generic wxAnimation as the base class (this will probably change...)
This commit is contained in:
Robin Dunn
2020-03-25 16:29:34 -07:00
parent f501177857
commit fae15d39a6
4 changed files with 99 additions and 113 deletions

View File

@@ -27,30 +27,51 @@ extern WXDLLIMPEXP_DATA_CORE(const char) wxAnimationCtrlNameStr[];
// ----------------------------------------------------------------------------
// wxAnimationBase
// wxAnimation
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxAnimationBase : public wxObject
WX_DECLARE_LIST_WITH_DECL(wxAnimationDecoder, wxAnimationDecoderList, class WXDLLIMPEXP_ADV);
class WXDLLIMPEXP_ADV wxAnimation : public wxObject
{
public:
wxAnimationBase() {}
wxAnimation() {}
wxAnimation(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY)
{ LoadFile(name, type); }
virtual bool IsOk() const = 0;
virtual bool IsOk() const
{ return m_refData != NULL; }
// can be -1
virtual int GetDelay(unsigned int frame) 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;
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 LoadFile(const wxString& filename,
wxAnimationType type = wxANIMATION_TYPE_ANY);
virtual bool Load(wxInputStream& stream,
wxAnimationType type = wxANIMATION_TYPE_ANY) = 0;
wxAnimationType type = wxANIMATION_TYPE_ANY);
// 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;
protected:
wxDECLARE_ABSTRACT_CLASS(wxAnimationBase);
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(wxAnimation);
};
@@ -114,12 +135,29 @@ private:
// include the platform-specific version of the wxAnimationCtrl class
// ----------------------------------------------------------------------------
#if wxUSE_NATIVE_ANIMATIONCTRL && defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
#define wxUSE_GENERIC_ANIMATIONCTRL 0
#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
#include "wx/gtk/animate.h"
#else
#define wxUSE_GENERIC_ANIMATIONCTRL 1
#else
#include "wx/generic/animate.h"
class WXDLLIMPEXP_ADV wxAnimationCtrl : public wxGenericAnimationCtrl
{
public:
wxAnimationCtrl()
: wxGenericAnimationCtrl()
{}
wxAnimationCtrl(wxWindow *parent,
wxWindowID id,
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)
{}
private:
wxDECLARE_DYNAMIC_CLASS(wxAnimationCtrl);
};
#endif
#endif // wxUSE_ANIMATIONCTRL