Name the base animation class wxGenericAnimation with a wxAnimation shim class

This commit is contained in:
Robin Dunn
2020-03-27 15:53:03 -07:00
parent 488084c2f5
commit 08ac4dbad6
5 changed files with 65 additions and 30 deletions

View File

@@ -20,10 +20,9 @@
#include "wx/timer.h"
#include "wx/bitmap.h"
class WXDLLIMPEXP_FWD_CORE wxAnimation;
//class WXDLLIMPEXP_FWD_CORE wxAnimationGeneric;
class WXDLLIMPEXP_FWD_CORE wxGenericAnimation;
extern WXDLLIMPEXP_DATA_CORE(wxAnimation) wxNullAnimation;
extern WXDLLIMPEXP_DATA_CORE(wxGenericAnimation) wxNullAnimation;
extern WXDLLIMPEXP_DATA_CORE(const char) wxAnimationCtrlNameStr[];
@@ -99,8 +98,8 @@ public:
virtual bool Load(wxInputStream& stream,
wxAnimationType type = wxANIMATION_TYPE_ANY) = 0;
virtual void SetAnimation(const wxAnimation &anim) = 0;
virtual wxAnimation GetAnimation() const = 0;
virtual void SetAnimation(const wxGenericAnimation &anim) = 0;
virtual wxGenericAnimation GetAnimation() const = 0;
virtual bool Play() = 0;
virtual void Stop() = 0;
@@ -139,6 +138,7 @@ private:
#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
#include "wx/gtk/animate.h"
#else
#include "wx/generic/animate.h"
class WXDLLIMPEXP_ADV wxAnimation : public wxGenericAnimation
{
@@ -151,8 +151,6 @@ private:
wxDECLARE_DYNAMIC_CLASS(wxAnimation);
};
#include "wx/generic/animate.h"
class WXDLLIMPEXP_ADV wxAnimationCtrl : public wxGenericAnimationCtrl
{
public:
@@ -161,7 +159,7 @@ private:
{}
wxAnimationCtrl(wxWindow *parent,
wxWindowID id,
const wxAnimation& anim = wxNullAnimation,
const wxGenericAnimation& anim = wxNullAnimation,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxAC_DEFAULT_STYLE,

View File

@@ -23,7 +23,7 @@ public:
wxGenericAnimationCtrl() { Init(); }
wxGenericAnimationCtrl(wxWindow *parent,
wxWindowID id,
const wxAnimation& anim = wxNullAnimation,
const wxGenericAnimation& anim = wxNullAnimation,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxAC_DEFAULT_STYLE,
@@ -37,7 +37,7 @@ public:
void Init();
bool Create(wxWindow *parent, wxWindowID id,
const wxAnimation& anim = wxNullAnimation,
const wxGenericAnimation& anim = wxNullAnimation,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxAC_DEFAULT_STYLE,
@@ -55,8 +55,8 @@ public:
virtual bool IsPlaying() const wxOVERRIDE
{ return m_isPlaying; }
void SetAnimation(const wxAnimation &animation) wxOVERRIDE;
wxAnimation GetAnimation() const wxOVERRIDE
void SetAnimation(const wxGenericAnimation &animation) wxOVERRIDE;
wxGenericAnimation GetAnimation() const wxOVERRIDE
{ return m_animation; }
virtual void SetInactiveBitmap(const wxBitmap &bmp) wxOVERRIDE;
@@ -111,7 +111,7 @@ protected:
unsigned int m_currentFrame; // Current frame
bool m_looped; // Looped, or not
wxTimer m_timer; // The timer
wxAnimation m_animation; // The animation
wxGenericAnimation m_animation; // The animation
bool m_isPlaying; // Is the animation playing?
bool m_useWinBackgroundColour; // Use animation bg colour or window bg colour?

View File

@@ -28,7 +28,7 @@ enum wxAnimationType
/**
@class wxAnimationCtrl
@class wxGenericAnimationCtrl
This is a static control which displays an animation.
wxAnimationCtrl API is as simple as possible and won't give you full control
@@ -57,15 +57,15 @@ enum wxAnimationType
@see wxAnimation, @sample{animate}
*/
class wxAnimationCtrl : public wxControl
class wxGenericAnimationCtrl : public wxControl
{
public:
/**
Initializes the object and calls Create() with
all the parameters.
*/
wxAnimationCtrl(wxWindow* parent, wxWindowID id,
const wxAnimation& anim = wxNullAnimation,
wxGenericAnimationCtrl(wxWindow* parent, wxWindowID id,
const wxGenericAnimation& anim = wxNullAnimation,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxAC_DEFAULT_STYLE,
@@ -97,7 +97,7 @@ public:
creation failed.
*/
bool Create(wxWindow* parent, wxWindowID id,
const wxAnimation& anim = wxNullAnimation,
const wxGenericAnimation& anim = wxNullAnimation,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxAC_DEFAULT_STYLE,
@@ -106,7 +106,7 @@ public:
/**
Returns the animation associated with this control.
*/
virtual wxAnimation GetAnimation() const;
virtual wxGenericAnimation GetAnimation() const;
/**
Returns the inactive bitmap shown in this control when the;
@@ -150,7 +150,7 @@ public:
animation or the background colour will be shown
(see SetInactiveBitmap() for more info).
*/
virtual void SetAnimation(const wxAnimation& anim);
virtual void SetAnimation(const wxGenericAnimation& anim);
/**
Sets the bitmap to show on the control when it's not playing an animation.
@@ -221,9 +221,31 @@ public:
};
/**
@class wxAnimationCtrl
If the platform supports a native animation control (currently just wxGTK)
then this class implements the control via the native widget.
Otherwise it is virtually the same as @c wxGenericAnimationCtrl.
*/
class wxAnimationCtrl : public wxGenericAnimationCtrl
{
public:
wxAnimationCtrl();
wxAnimationCtrl(wxWindow *parent,
wxWindowID id,
const wxGenericAnimation& anim = wxNullAnimation,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxAC_DEFAULT_STYLE,
const wxString& name = wxAnimationCtrlNameStr);
};
/**
@class wxAnimation
@class wxGenericAnimation
This class encapsulates the concept of a platform-dependent animation.
An animation is a sequence of frames of the same size.
@@ -246,18 +268,18 @@ public:
@see wxAnimationCtrl, @sample{animate}
*/
class wxAnimation : public wxObject
class wxGenericAnimation : public wxObject
{
public:
/**
Default ctor.
*/
wxAnimation();
wxGenericAnimation();
/**
Copy ctor.
*/
wxAnimation(const wxAnimation& anim);
// wxAnimation(const wxAnimation& anim);
/**
Loads an animation from a file.
@@ -267,14 +289,14 @@ public:
@param type
See LoadFile() for more info.
*/
wxAnimation(const wxString& name,
wxGenericAnimation(const wxString& name,
wxAnimationType type = wxANIMATION_TYPE_ANY);
/**
Destructor.
See @ref overview_refcount_destruct for more info.
*/
virtual ~wxAnimation();
virtual ~wxGenericAnimation();
/**
Returns the delay for the i-th frame in milliseconds.
@@ -395,6 +417,21 @@ public:
};
/**
@class wxAnimation
If the platform supports a native animation control (currently just wxGTK)
then this is the animation class that should be used with @c wxAnimationCtrl.
Otherwise it is virtually the same as @c wxGenericAnimation.
*/
class wxAnimation : public wxGenericAnimation
{
public:
wxAnimation();
wxAnimation(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY);
};
// ============================================================================
// Global functions/macros
// ============================================================================
@@ -402,5 +439,5 @@ public:
/**
An empty animation object.
*/
wxAnimation wxNullAnimation;
wxGenericAnimation wxNullAnimation;

View File

@@ -32,7 +32,7 @@
const char wxAnimationCtrlNameStr[] = "animationctrl";
// global object
wxAnimation wxNullAnimation;
wxGenericAnimation wxNullAnimation;
wxIMPLEMENT_DYNAMIC_CLASS(wxAnimation, wxGenericAnimation);
wxIMPLEMENT_ABSTRACT_CLASS(wxAnimationCtrlBase, wxControl);

View File

@@ -282,7 +282,7 @@ void wxGenericAnimationCtrl::Init()
}
bool wxGenericAnimationCtrl::Create(wxWindow *parent, wxWindowID id,
const wxAnimation& animation, const wxPoint& pos,
const wxGenericAnimation& animation, const wxPoint& pos,
const wxSize& size, long style, const wxString& name)
{
m_timer.SetOwner(this);
@@ -329,7 +329,7 @@ wxSize wxGenericAnimationCtrl::DoGetBestSize() const
return FromDIP(wxSize(100, 100));
}
void wxGenericAnimationCtrl::SetAnimation(const wxAnimation& animation)
void wxGenericAnimationCtrl::SetAnimation(const wxGenericAnimation& animation)
{
if (IsPlaying())
Stop();