#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>
-WX_DEFINE_LIST(wxAnimationDecoderList);
+#include "wx/listimpl.cpp"
+WX_DEFINE_LIST(wxAnimationDecoderList)
wxAnimationDecoderList wxAnimation::sm_handlers;
-
// ----------------------------------------------------------------------------
// wxAnimation
// ----------------------------------------------------------------------------
bool wxAnimation::LoadFile(const wxString& filename, wxAnimationType type)
{
wxFileInputStream stream(filename);
- if (!stream.Ok())
+ if ( !stream.IsOk() )
return false;
return Load(stream, type);
const wxAnimationDecoder *handler;
if ( type == wxANIMATION_TYPE_ANY )
{
- for ( wxAnimationDecoderList::compatibility_iterator node = sm_handlers.GetFirst();
+ for ( wxAnimationDecoderList::compatibility_iterator node = sm_handlers.GetFirst();
node; node = node->GetNext() )
{
handler=(const wxAnimationDecoder*)node->GetData();
void wxAnimation::InitStandardHandlers()
{
+#if wxUSE_GIF
AddHandler(new wxGIFDecoder);
+#endif // wxUSE_GIF
+#if wxUSE_ICO_CUR
AddHandler(new wxANIDecoder);
+#endif // wxUSE_ICO_CUR
}
void wxAnimation::CleanUpHandlers()
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
bool wxAnimationCtrl::LoadFile(const wxString& filename, wxAnimationType type)
{
wxAnimation anim;
- if (!anim.LoadFile(filename, type) ||
+ if (!anim.LoadFile(filename, type) ||
!anim.IsOk())
return false;
RebuildBackingStoreUpToFrame(0);
else
{
- // clear to
+ // clear to
wxMemoryDC dc;
dc.SelectObject(m_backingStore);
int w = wxMin(sz.GetWidth(), winsz.GetWidth());
int h = wxMin(sz.GetHeight(), winsz.GetHeight());
- if ( !m_backingStore.Ok() ||
+ if ( !m_backingStore.IsOk() ||
m_backingStore.GetWidth() < w || m_backingStore.GetHeight() < h )
{
m_backingStore.Create(w, h);
case wxANIM_TOPREVIOUS:
// this disposal should never be used too often.
// E.g. GIF specification explicitely say to keep the usage of this
- // disposal limited to the minimum.
- // In fact it may require a lot of time to restore
+ // disposal limited to the minimum.
+ // In fact it may require a lot of time to restore
if (m_currentFrame == 1)
{
// if 0-th frame disposal is to restore to previous frame,
void wxAnimationCtrl::DrawCurrentFrame(wxDC& dc)
{
- wxASSERT(m_backingStore.Ok());
+ wxASSERT( m_backingStore.IsOk() );
// m_backingStore always contains the current frame
dc.DrawBitmap(m_backingStore, 0, 0);
}
void wxAnimationCtrl::DisposeToBackground(wxDC& dc)
-{
- wxBrush brush(IsUsingWindowBackgroundColour() ?
- this->GetBackgroundColour() : m_animation.GetBackgroundColour(), wxSOLID);
+{
+ wxColour col = IsUsingWindowBackgroundColour()
+ ? GetBackgroundColour()
+ : m_animation.GetBackgroundColour() ;
+ wxBrush brush(col);
dc.SetBackground(brush);
dc.Clear();
}
wxPaintDC dc(this);
// both if we are playing or not, we need to refresh the current frame
- if (m_backingStore.Ok())
+ if ( m_backingStore.IsOk() )
DrawCurrentFrame(dc);
//else: m_animation is not valid and thus we don't have a valid backing store...
}
wxClientDC dc(this);
DrawCurrentFrame(dc);
+#ifdef __WXMAC__
+ // without this, the animation currently doesn't redraw under Mac
+ Refresh();
+#endif // __WXMAC__
+
// Set the timer for the next frame
int delay = m_animation.GetDelay(m_currentFrame);
if (delay == 0)