Merge branch 'disable-native-animation'
Allow the generic animation classes to be used on all platforms. See https://github.com/wxWidgets/wxWidgets/pull/1768
This commit is contained in:
@@ -53,11 +53,12 @@ public:
|
||||
wxAnimationType GetType() const wxOVERRIDE
|
||||
{ return wxANIMATION_TYPE_ANI; }
|
||||
|
||||
private:
|
||||
protected:
|
||||
// wxAnimationDecoder pure virtual:
|
||||
virtual bool DoCanRead( wxInputStream& stream ) const wxOVERRIDE;
|
||||
// modifies current stream position (see wxAnimationDecoder::CanRead)
|
||||
|
||||
private:
|
||||
// frames stored as wxImage(s): ANI files are meant to be used mostly for animated
|
||||
// cursors and thus they do not use any optimization to encode differences between
|
||||
// two frames: they are just a list of images to display sequentially.
|
||||
|
@@ -21,38 +21,61 @@
|
||||
#include "wx/bitmap.h"
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxAnimation;
|
||||
class wxAnimationImpl;
|
||||
|
||||
extern WXDLLIMPEXP_DATA_CORE(wxAnimation) wxNullAnimation;
|
||||
extern WXDLLIMPEXP_DATA_CORE(const char) wxAnimationCtrlNameStr[];
|
||||
|
||||
WX_DECLARE_LIST_WITH_DECL(wxAnimationDecoder, wxAnimationDecoderList, class WXDLLIMPEXP_CORE);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxAnimationBase
|
||||
// wxAnimation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_CORE wxAnimationBase : public wxObject
|
||||
class WXDLLIMPEXP_CORE wxAnimation : public wxObject
|
||||
{
|
||||
public:
|
||||
wxAnimationBase() {}
|
||||
wxAnimation();
|
||||
explicit wxAnimation(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY);
|
||||
wxAnimation(const wxAnimation& other);
|
||||
|
||||
virtual bool IsOk() const = 0;
|
||||
wxAnimation& operator=(const wxAnimation& other);
|
||||
|
||||
// can be -1
|
||||
virtual int GetDelay(unsigned int frame) const = 0;
|
||||
bool IsOk() const;
|
||||
bool IsCompatibleWith(wxClassInfo* ci) const;
|
||||
|
||||
virtual unsigned int GetFrameCount() const = 0;
|
||||
virtual wxImage GetFrame(unsigned int frame) const = 0;
|
||||
virtual wxSize GetSize() const = 0;
|
||||
int GetDelay(unsigned int frame) const;
|
||||
unsigned int GetFrameCount() const;
|
||||
wxImage GetFrame(unsigned int frame);
|
||||
wxSize GetSize() const;
|
||||
|
||||
virtual bool LoadFile(const wxString& name,
|
||||
wxAnimationType type = wxANIMATION_TYPE_ANY) = 0;
|
||||
virtual bool Load(wxInputStream& stream,
|
||||
wxAnimationType type = wxANIMATION_TYPE_ANY) = 0;
|
||||
bool LoadFile(const wxString& name, wxAnimationType type = wxANIMATION_TYPE_ANY);
|
||||
bool Load(wxInputStream& stream, wxAnimationType type = wxANIMATION_TYPE_ANY);
|
||||
|
||||
// Methods for managing the list of decoders
|
||||
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();
|
||||
|
||||
protected:
|
||||
wxDECLARE_ABSTRACT_CLASS(wxAnimationBase);
|
||||
};
|
||||
wxAnimationImpl* GetImpl() const;
|
||||
|
||||
private:
|
||||
static wxAnimationDecoderList sm_handlers;
|
||||
|
||||
// Ctor used by wxAnimationCtrl::CreateAnimation() only.
|
||||
explicit wxAnimation(wxAnimationImpl* impl);
|
||||
|
||||
// Give it permission to create objects of this class using specific impl
|
||||
// and access our GetImpl().
|
||||
friend class wxAnimationCtrlBase;
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS(wxAnimation);
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -78,7 +101,7 @@ public:
|
||||
wxAnimationType type = wxANIMATION_TYPE_ANY) = 0;
|
||||
|
||||
virtual void SetAnimation(const wxAnimation &anim) = 0;
|
||||
virtual wxAnimation GetAnimation() const = 0;
|
||||
wxAnimation GetAnimation() const { return m_animation; }
|
||||
|
||||
virtual bool Play() = 0;
|
||||
virtual void Stop() = 0;
|
||||
@@ -91,7 +114,23 @@ public:
|
||||
wxBitmap GetInactiveBitmap() const
|
||||
{ return m_bmpStatic; }
|
||||
|
||||
wxAnimation CreateAnimation() const
|
||||
{ return MakeAnimFromImpl(DoCreateAnimationImpl()); }
|
||||
|
||||
protected:
|
||||
virtual wxAnimationImpl* DoCreateAnimationImpl() const = 0;
|
||||
|
||||
// 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(); }
|
||||
|
||||
// The associated animation, possibly invalid/empty.
|
||||
wxAnimation m_animation;
|
||||
|
||||
// the inactive bitmap as it was set by the user
|
||||
wxBitmap m_bmpStatic;
|
||||
|
||||
@@ -104,9 +143,6 @@ protected:
|
||||
|
||||
// called by SetInactiveBitmap
|
||||
virtual void DisplayStaticImage() = 0;
|
||||
|
||||
private:
|
||||
wxDECLARE_ABSTRACT_CLASS(wxAnimationCtrlBase);
|
||||
};
|
||||
|
||||
|
||||
@@ -116,9 +152,31 @@ private:
|
||||
|
||||
#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
|
||||
#include "wx/gtk/animate.h"
|
||||
|
||||
#define wxHAS_NATIVE_ANIMATIONCTRL
|
||||
#else
|
||||
#include "wx/generic/animate.h"
|
||||
#endif
|
||||
|
||||
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 // defined(__WXGTK20__)
|
||||
|
||||
#endif // wxUSE_ANIMATIONCTRL
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/generic/animate.h
|
||||
// Purpose: wxAnimation and wxAnimationCtrl
|
||||
// Purpose: wxGenericAnimationCtrl
|
||||
// Author: Julian Smart and Guillermo Rodriguez Garcia
|
||||
// Modified by: Francesco Montorsi
|
||||
// Created: 13/8/99
|
||||
@@ -13,70 +13,22 @@
|
||||
|
||||
#include "wx/bitmap.h"
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxAnimation
|
||||
// wxGenericAnimationCtrl
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
WX_DECLARE_LIST_WITH_DECL(wxAnimationDecoder, wxAnimationDecoderList, class WXDLLIMPEXP_ADV);
|
||||
|
||||
class WXDLLIMPEXP_ADV wxAnimation : public wxAnimationBase
|
||||
class WXDLLIMPEXP_ADV wxGenericAnimationCtrl: public wxAnimationCtrlBase
|
||||
{
|
||||
public:
|
||||
wxAnimation() {}
|
||||
wxAnimation(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY)
|
||||
{ LoadFile(name, type); }
|
||||
|
||||
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 by the generic implementation of wxAnimationCtrl
|
||||
wxPoint GetFramePosition(unsigned int frame) const;
|
||||
wxSize GetFrameSize(unsigned int frame) const;
|
||||
wxAnimationDisposal GetDisposalMethod(unsigned int frame) const;
|
||||
wxColour GetTransparentColour(unsigned int frame) const;
|
||||
wxColour GetBackgroundColour() const;
|
||||
|
||||
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(wxAnimation);
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxAnimationCtrl
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxAnimationCtrl: public wxAnimationCtrlBase
|
||||
{
|
||||
public:
|
||||
wxAnimationCtrl() { Init(); }
|
||||
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() { Init(); }
|
||||
wxGenericAnimationCtrl(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)
|
||||
{
|
||||
Init();
|
||||
|
||||
@@ -92,7 +44,8 @@ public:
|
||||
long style = wxAC_DEFAULT_STYLE,
|
||||
const wxString& name = wxAnimationCtrlNameStr);
|
||||
|
||||
~wxAnimationCtrl();
|
||||
~wxGenericAnimationCtrl();
|
||||
|
||||
|
||||
public:
|
||||
virtual bool LoadFile(const wxString& filename, wxAnimationType type = wxANIMATION_TYPE_ANY) wxOVERRIDE;
|
||||
@@ -105,14 +58,14 @@ public:
|
||||
{ return m_isPlaying; }
|
||||
|
||||
void SetAnimation(const wxAnimation &animation) wxOVERRIDE;
|
||||
wxAnimation GetAnimation() const wxOVERRIDE
|
||||
{ return m_animation; }
|
||||
|
||||
virtual void SetInactiveBitmap(const wxBitmap &bmp) wxOVERRIDE;
|
||||
|
||||
// override base class method
|
||||
virtual bool SetBackgroundColour(const wxColour& col) wxOVERRIDE;
|
||||
|
||||
static wxAnimation CreateCompatibleAnimation();
|
||||
|
||||
public: // event handlers
|
||||
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
@@ -140,6 +93,7 @@ public: // extended API specific to this implementation of wxAnimateCtrl
|
||||
{ return m_backingStore; }
|
||||
|
||||
protected: // internal utilities
|
||||
virtual wxAnimationImpl* DoCreateAnimationImpl() const wxOVERRIDE;
|
||||
|
||||
// resize this control to fit m_animation
|
||||
void FitToAnimation();
|
||||
@@ -156,11 +110,19 @@ protected: // internal utilities
|
||||
virtual void DisplayStaticImage() wxOVERRIDE;
|
||||
virtual wxSize DoGetBestSize() const wxOVERRIDE;
|
||||
|
||||
// Helpers to safely access methods in the wxAnimationGenericImpl that are
|
||||
// specific to the generic implementation
|
||||
wxPoint AnimationImplGetFramePosition(unsigned int frame) const;
|
||||
wxSize AnimationImplGetFrameSize(unsigned int frame) const;
|
||||
wxAnimationDisposal AnimationImplGetDisposalMethod(unsigned int frame) const;
|
||||
wxColour AnimationImplGetTransparentColour(unsigned int frame) const;
|
||||
wxColour AnimationImplGetBackgroundColour() const;
|
||||
|
||||
|
||||
protected:
|
||||
unsigned int m_currentFrame; // Current frame
|
||||
bool m_looped; // Looped, or not
|
||||
wxTimer m_timer; // The timer
|
||||
wxAnimation m_animation; // The animation
|
||||
|
||||
bool m_isPlaying; // Is the animation playing?
|
||||
bool m_useWinBackgroundColour; // Use animation bg colour or window bg colour?
|
||||
@@ -170,7 +132,7 @@ protected:
|
||||
|
||||
private:
|
||||
typedef wxAnimationCtrlBase base_type;
|
||||
wxDECLARE_DYNAMIC_CLASS(wxAnimationCtrl);
|
||||
wxDECLARE_DYNAMIC_CLASS(wxGenericAnimationCtrl);
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
|
56
include/wx/generic/private/animate.h
Normal file
56
include/wx/generic/private/animate.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 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/private/animate.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxAnimationGenericImpl
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxAnimationGenericImpl : public wxAnimationImpl
|
||||
{
|
||||
public:
|
||||
wxAnimationGenericImpl() : m_decoder(NULL) {}
|
||||
virtual ~wxAnimationGenericImpl() { UnRef(); }
|
||||
|
||||
virtual bool IsOk() const wxOVERRIDE
|
||||
{ return m_decoder != NULL; }
|
||||
virtual bool IsCompatibleWith(wxClassInfo* ci) const wxOVERRIDE;
|
||||
|
||||
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;
|
||||
|
||||
private:
|
||||
void UnRef();
|
||||
|
||||
wxAnimationDecoder* m_decoder;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxAnimationGenericImpl);
|
||||
};
|
||||
|
||||
|
||||
#endif // _WX_GENERIC_PRIVATE_ANIMATEH__
|
@@ -85,11 +85,12 @@ public:
|
||||
wxAnimationType GetType() const wxOVERRIDE
|
||||
{ return wxANIMATION_TYPE_GIF; }
|
||||
|
||||
private:
|
||||
protected:
|
||||
// wxAnimationDecoder pure virtual
|
||||
virtual bool DoCanRead( wxInputStream& stream ) const wxOVERRIDE;
|
||||
// modifies current stream position (see wxAnimationDecoder::CanRead)
|
||||
|
||||
private:
|
||||
int getcode(wxInputStream& stream, int bits, int abfin);
|
||||
wxGIFErrorCode dgif(wxInputStream& stream,
|
||||
GIFImage *img, int interl, int bits);
|
||||
|
@@ -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 wxAnimation : public wxAnimationBase
|
||||
{
|
||||
public:
|
||||
wxAnimation(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY)
|
||||
: m_pixbuf(NULL) { LoadFile(name, type); }
|
||||
wxAnimation(GdkPixbufAnimation *p = NULL);
|
||||
wxAnimation(const wxAnimation&);
|
||||
~wxAnimation() { UnRef(); }
|
||||
|
||||
wxAnimation& operator= (const wxAnimation&);
|
||||
|
||||
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 wxAnimationBase base_type;
|
||||
wxDECLARE_DYNAMIC_CLASS(wxAnimation);
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxAnimationCtrl
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -112,9 +56,7 @@ 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) wxOVERRIDE;
|
||||
|
||||
virtual bool Play() wxOVERRIDE;
|
||||
virtual void Stop() wxOVERRIDE;
|
||||
@@ -123,7 +65,10 @@ public: // public API
|
||||
|
||||
bool SetBackgroundColour( const wxColour &colour ) wxOVERRIDE;
|
||||
|
||||
static wxAnimation CreateCompatibleAnimation();
|
||||
|
||||
protected:
|
||||
virtual wxAnimationImpl* DoCreateAnimationImpl() const wxOVERRIDE;
|
||||
|
||||
virtual void DisplayStaticImage() wxOVERRIDE;
|
||||
virtual wxSize DoGetBestSize() const wxOVERRIDE;
|
||||
@@ -133,6 +78,11 @@ protected:
|
||||
void ResetAnim();
|
||||
void ResetIter();
|
||||
|
||||
// Helpers to safely access methods in the wxAnimationGTKImpl that are
|
||||
// specific to the gtk implementation
|
||||
GdkPixbufAnimation *AnimationImplGetPixbuf() const;
|
||||
void AnimationImplSetPixbuf(GdkPixbufAnimation* p);
|
||||
|
||||
protected: // internal vars
|
||||
|
||||
GdkPixbufAnimation *m_anim;
|
||||
|
69
include/wx/gtk/private/animate.h
Normal file
69
include/wx/gtk/private/animate.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 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__
|
||||
|
||||
#include "wx/private/animate.h"
|
||||
|
||||
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 bool IsOk() const wxOVERRIDE
|
||||
{ return m_pixbuf != NULL; }
|
||||
virtual bool IsCompatibleWith(wxClassInfo* ci) const wxOVERRIDE;
|
||||
|
||||
|
||||
// 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);
|
||||
};
|
||||
|
||||
|
||||
#endif // _WX_GTK_PRIVATE_ANIMATEH__
|
44
include/wx/private/animate.h
Normal file
44
include/wx/private/animate.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/animate.h
|
||||
// Purpose: wxAnimationImpl declaration
|
||||
// Author: Robin Dunn, Vadim Zeitlin
|
||||
// Created: 2020-04-06
|
||||
// Copyright: (c) 2020 wxWidgets development team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PRIVATE_ANIMATEH__
|
||||
#define _WX_PRIVATE_ANIMATEH__
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxAnimationImpl
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_CORE wxAnimationImpl : public wxRefCounter
|
||||
{
|
||||
public:
|
||||
wxAnimationImpl() {}
|
||||
virtual ~wxAnimationImpl() {}
|
||||
|
||||
virtual bool IsOk() const = 0;
|
||||
virtual bool IsCompatibleWith(wxClassInfo* ci) const = 0;
|
||||
|
||||
// can be -1
|
||||
virtual int GetDelay(unsigned int frame) const = 0;
|
||||
|
||||
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) = 0;
|
||||
|
||||
// This function creates the default implementation for this platform:
|
||||
// currently it's wxAnimationGTKImpl under wxGTK and wxAnimationGenericImpl
|
||||
// under all the other platforms.
|
||||
static wxAnimationImpl *CreateDefault();
|
||||
};
|
||||
|
||||
#endif // _WX_PRIVATE_ANIMATEH__
|
Reference in New Issue
Block a user