\twocolwidtha{5cm}%
\begin{twocollist}\itemsep=0pt
-\twocolitem{\windowstyle{wxAC\_DEFAULT\_STYLE}}{The default style: wxNO_BORDER.}
-\twocolitem{\windowstyle{wxAC\_NO_AUTORESIZE}}{By default, the control will adjust
+\twocolitem{\windowstyle{wxAC\_DEFAULT\_STYLE}}{The default style: wxNO\_BORDER.}
+\twocolitem{\windowstyle{wxAC\_NO\_AUTORESIZE}}{By default, the control will adjust
its size to exactly fit to the size of the animation when \helpref{SetAnimation}{wxanimationctrlsetanimation}
is called. If this style flag is given, the control will not change its size}
\end{twocollist}
\membersection{wxAnimation::GetDelay}\label{wxanimationgetdelay}
-\constfunc{int}{GetDelay}{\param{size_t }{i}}
+\constfunc{int}{GetDelay}{\param{size\_t }{i}}
Returns the delay for the i-th frame in milliseconds.
If {\tt -1} is returned the frame is to be displayed forever.
\membersection{wxAnimation::GetFrameCount}\label{wxanimationgetframecount}
-\constfunc{size_t}{GetFrameCount}{\void}
+\constfunc{size\_t}{GetFrameCount}{\void}
Returns the number of frames for this animation.
\membersection{wxAnimation::GetFrame}\label{wxanimationgetframe}
-\constfunc{wxImage}{GetFrame}{\param{size_t }{i}}
+\constfunc{wxImage}{GetFrame}{\param{size\_t }{i}}
Returns the i-th frame as a \helpref{wxImage}{wximage}.
#if wxUSE_ANIMATIONCTRL
-#include <wx/defs.h>
-#include <wx/string.h>
-#include <wx/gdicmn.h>
-#include <wx/list.h>
-#include <wx/timer.h>
-#include <wx/bitmap.h>
-#include <wx/colour.h>
-#include <wx/control.h>
-#include <wx/animdecod.h>
+#include "wx/animdecod.h"
+#include "wx/control.h"
+#include "wx/timer.h"
class WXDLLIMPEXP_ADV wxAnimation;
#if wxUSE_STREAMS && wxUSE_GIF
-#include "wx/stream.h"
-#include "wx/image.h"
#include "wx/colour.h"
+#include "wx/gdicmn.h"
+
+class WXDLLIMPEXP_BASE wxInputStream;
+class WXDLLIMPEXP_CORE wxImage;
/*
#ifndef _WX_GENERIC_ANIMATEH__
#define _WX_GENERIC_ANIMATEH__
-#include <wx/defs.h>
-#include <wx/string.h>
-#include <wx/gdicmn.h>
-#include <wx/list.h>
-#include <wx/timer.h>
-#include <wx/bitmap.h>
-#include <wx/colour.h>
-#include <wx/control.h>
-#include <wx/animdecod.h>
-
-class WXDLLIMPEXP_ADV wxAnimationBase;
-class WXDLLIMPEXP_ADV wxAnimationPlayer;
-class WXDLLEXPORT wxImage;
-class WXDLLEXPORT wxGIFDecoder;
-class WXDLLIMPEXP_ADV wxAnimation;
-
-
// ----------------------------------------------------------------------------
// wxAnimation
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxAnimation : public wxAnimationBase
{
public:
- wxAnimation(const wxAnimation &tocopy)
- { Ref(tocopy); }
- wxAnimation() {}
- ~wxAnimation() { UnRef(); }
-
- wxAnimation &operator= (const wxAnimation &tocopy)
- {
- Ref(tocopy);
- return *this;
- }
-
bool operator == (const wxAnimation& anim) const
{ return m_refData == anim.m_refData; }
bool operator != (const wxAnimation& anim) const
static void CleanUpHandlers();
static void InitStandardHandlers();
-protected:
DECLARE_DYNAMIC_CLASS(wxAnimation)
};
class WXDLLIMPEXP_ADV wxAnimationCtrl: public wxAnimationCtrlBase
{
public:
- wxAnimationCtrl() {}
+ wxAnimationCtrl();
wxAnimationCtrl(wxWindow *parent,
wxWindowID id,
const wxAnimation& anim = wxNullAnimation,
// on the screen
private:
+ typedef wxAnimationCtrlBase base_type;
DECLARE_DYNAMIC_CLASS(wxAnimationCtrl)
DECLARE_EVENT_TABLE()
};
#ifndef _WX_GTKANIMATEH__
#define _WX_GTKANIMATEH__
-#include "wx/defs.h"
-#include <gdk-pixbuf/gdk-pixbuf.h>
+typedef struct _GdkPixbufAnimation GdkPixbufAnimation;
+typedef struct _GdkPixbufAnimationIter GdkPixbufAnimationIter;
// ----------------------------------------------------------------------------
// wxAnimation
class WXDLLEXPORT wxAnimation : public wxAnimationBase
{
public:
- wxAnimation(const wxAnimation &tocopy)
- { m_pixbuf=tocopy.m_pixbuf; if (m_pixbuf) g_object_ref(m_pixbuf); }
- wxAnimation(GdkPixbufAnimation *p = NULL)
- { m_pixbuf=p; }
- ~wxAnimation()
- { UnRef(); }
-
- wxAnimation &operator= (const wxAnimation &tocopy)
- {
- m_pixbuf=tocopy.m_pixbuf;
- if (m_pixbuf) g_object_ref(m_pixbuf);
- return *this;
- }
+ wxAnimation(GdkPixbufAnimation *p = NULL) { m_pixbuf = p; }
+ wxAnimation(const wxAnimation&);
+ ~wxAnimation() { UnRef(); }
+
+ wxAnimation& operator= (const wxAnimation&);
bool operator == (const wxAnimation& anim) const
{ return m_pixbuf == anim.m_pixbuf; }
virtual size_t GetFrameCount() const
{ return 0; }
- virtual wxImage GetFrame(size_t i) const
- { return wxNullImage; }
+ virtual wxImage GetFrame(size_t i) const;
// we can retrieve the delay for a frame only after building
// a GdkPixbufAnimationIter...
virtual int GetDelay(size_t i) const
{ return 0; }
- virtual wxSize GetSize() const
- { return wxSize(gdk_pixbuf_animation_get_width(m_pixbuf),
- gdk_pixbuf_animation_get_height(m_pixbuf)); }
+ virtual wxSize GetSize() const;
virtual bool LoadFile(const wxString &name, wxAnimationType type = wxANIMATION_TYPE_ANY);
virtual bool Load(wxInputStream &stream, wxAnimationType type = wxANIMATION_TYPE_ANY);
- void UnRef()
- {
- if (m_pixbuf)
- g_object_unref(m_pixbuf);
- m_pixbuf = NULL;
- }
-
+ // Implementation
public: // used by GTK callbacks
GdkPixbufAnimation *GetPixbuf() const
{ return m_pixbuf; }
- void SetPixbuf(GdkPixbufAnimation *p)
- { m_pixbuf=p; if (m_pixbuf) g_object_ref(m_pixbuf); }
+ void SetPixbuf(GdkPixbufAnimation* p);
protected:
GdkPixbufAnimation *m_pixbuf;
// used temporary by Load()
//bool m_bLoadComplete;
-protected:
+private:
+ void UnRef();
+
+ typedef wxAnimationBase base_type;
DECLARE_DYNAMIC_CLASS(wxAnimation)
};
-
// ----------------------------------------------------------------------------
// wxAnimationCtrl
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxAnimationCtrl: public wxAnimationCtrlBase
{
public:
- wxAnimationCtrl() {}
+ wxAnimationCtrl();
wxAnimationCtrl(wxWindow *parent,
wxWindowID id,
const wxAnimation& anim = wxNullAnimation,
void FitToAnimation();
void ClearToBackgroundColour();
- void ResetAnim()
- {
- if (m_anim)
- g_object_unref(m_anim);
- m_anim = NULL;
- }
-
- void ResetIter()
- {
- if (m_iter)
- g_object_unref(m_iter);
- m_iter = NULL;
- }
+ void ResetAnim();
+ void ResetIter();
protected: // internal vars
bool m_bPlaying;
private:
+ typedef wxAnimationCtrlBase base_type;
DECLARE_DYNAMIC_CLASS(wxAnimationCtrl)
DECLARE_EVENT_TABLE()
};
#pragma hdrstop
#endif //__BORLANDC__
-
#if wxUSE_ANIMATIONCTRL
-#include "wx/log.h"
+#include "wx/animate.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/log.h"
+ #include "wx/image.h"
+ #include "wx/dcmemory.h"
+ #include "wx/dcclient.h"
+ #include "wx/module.h"
+#endif
+
#include "wx/wfstream.h"
-#include "wx/image.h"
#include "wx/gifdecod.h"
#include "wx/anidecod.h"
-#include "wx/dcmemory.h"
-#include "wx/dc.h"
-#include "wx/dcclient.h"
-#include "wx/animate.h"
-#include "wx/animdecod.h"
-
-#include <wx/listimpl.cpp>
+#include "wx/listimpl.cpp"
WX_DEFINE_LIST(wxAnimationDecoderList);
wxAnimationDecoderList wxAnimation::sm_handlers;
-
// ----------------------------------------------------------------------------
// wxAnimation
// ----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxAnimationModule, wxModule)
-
-
// ----------------------------------------------------------------------------
// wxAnimationCtrl
// ----------------------------------------------------------------------------
EVT_TIMER(wxID_ANY, wxAnimationCtrl::OnTimer)
END_EVENT_TABLE()
+wxAnimationCtrl::wxAnimationCtrl()
+{
+ m_currentFrame = 0;
+ m_looped = false;
+ m_isPlaying = false;
+ m_useWinBackgroundColour = false;
+}
+
bool wxAnimationCtrl::Create(wxWindow *parent, wxWindowID id,
const wxAnimation& animation, const wxPoint& pos,
const wxSize& size, long style, const wxString& name)
m_useWinBackgroundColour = false;
m_timer.SetOwner(this);
- if (!wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name))
+ if (!base_type::Create(parent, id, pos, size, style, wxDefaultValidator, name))
return false;
// by default we get the same background colour of our parent
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#if wxUSE_ANIMATIONCTRL
#include "wx/animate.h"
-#include "wx/log.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/image.h"
+ #include "wx/log.h"
+ #include "wx/stream.h"
+#endif
+
#include <gtk/gtk.h>
-#include <gtk/gtkimage.h>
// ============================================================================
IMPLEMENT_DYNAMIC_CLASS(wxAnimation, wxAnimationBase)
+wxAnimation::wxAnimation(const wxAnimation& that)
+ : base_type(that)
+{
+ m_pixbuf = that.m_pixbuf;
+ if (m_pixbuf)
+ g_object_ref(m_pixbuf);
+}
+
+wxAnimation& wxAnimation::operator=(const wxAnimation& that)
+{
+ if (this != &that)
+ {
+ base_type::operator=(that);
+ UnRef();
+ m_pixbuf = that.m_pixbuf;
+ if (m_pixbuf)
+ g_object_ref(m_pixbuf);
+ }
+ return *this;
+}
+
bool wxAnimation::LoadFile(const wxString &name, wxAnimationType WXUNUSED(type))
{
UnRef();
break;
default:
+ anim_type[0] = '\0';
break;
}
while (stream.IsOk())
{
// read a chunk of data
- stream.Read(buf, 2048);
+ stream.Read(buf, sizeof(buf));
// fetch all data into the loader
if (!gdk_pixbuf_loader_write(loader, buf, stream.LastRead(), &error))
return true;
}
+wxImage wxAnimation::GetFrame(size_t i) const
+{
+ return wxNullImage;
+}
+
+wxSize wxAnimation::GetSize() const
+{
+ return wxSize(gdk_pixbuf_animation_get_width(m_pixbuf),
+ gdk_pixbuf_animation_get_height(m_pixbuf));
+}
+
+void wxAnimation::UnRef()
+{
+ if (m_pixbuf)
+ g_object_unref(m_pixbuf);
+ m_pixbuf = NULL;
+}
+
+void wxAnimation::SetPixbuf(GdkPixbufAnimation* p)
+{
+ UnRef();
+ m_pixbuf = p;
+ if (m_pixbuf)
+ g_object_ref(m_pixbuf);
+}
//-----------------------------------------------------------------------------
// wxAnimationCtrl
EVT_TIMER(wxID_ANY, wxAnimationCtrl::OnTimer)
END_EVENT_TABLE()
+wxAnimationCtrl::wxAnimationCtrl()
+{
+ m_anim = NULL;
+ m_iter = NULL;
+ m_bPlaying = false;
+}
+
bool wxAnimationCtrl::Create( wxWindow *parent, wxWindowID id,
const wxAnimation& anim,
const wxPoint& pos,
m_acceptsFocus = true;
if (!PreCreation( parent, pos, size ) ||
- !wxControl::CreateBase(parent, id, pos, size, style & wxWINDOW_STYLE_MASK,
+ !base_type::CreateBase(parent, id, pos, size, style & wxWINDOW_STYLE_MASK,
wxDefaultValidator, name))
{
wxFAIL_MSG( wxT("wxAnimationCtrl creation failed") );
SetSize(w, h);
}
+void wxAnimationCtrl::ResetAnim()
+{
+ if (m_anim)
+ g_object_unref(m_anim);
+ m_anim = NULL;
+}
+
+void wxAnimationCtrl::ResetIter()
+{
+ if (m_iter)
+ g_object_unref(m_iter);
+ m_iter = NULL;
+}
+
bool wxAnimationCtrl::Play()
{
if (m_anim == NULL)