X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/102174443d106f34859644c7ee7c20f1eb3fd541..3285ee538be44537a0d4e43252db18f5e7362782:/contrib/src/animate/animate.cpp diff --git a/contrib/src/animate/animate.cpp b/contrib/src/animate/animate.cpp index b85d93baea..64309fc8a6 100644 --- a/contrib/src/animate/animate.cpp +++ b/contrib/src/animate/animate.cpp @@ -22,11 +22,11 @@ #include "wx/wfstream.h" #include "wx/image.h" #include "wx/gifdecod.h" -#include "wx/animate/animate.h" #include "wx/log.h" +#include "wx/dcmemory.h" +#include "wx/animate/animate.h" #include "wx/dc.h" #include "wx/dcclient.h" -#include "wx/dcmemory.h" /* * wxAnimationPlayer @@ -69,7 +69,7 @@ void wxAnimationPlayer::SetAnimation(wxAnimationBase* animation, bool destroyAni } // Play -bool wxAnimationPlayer::Play(wxWindow& window, const wxPoint& pos, bool looped) +bool wxAnimationPlayer::Play(wxWindow& window, const wxPoint& pos, bool WXUNUSED(looped)) { m_window = & window; @@ -109,7 +109,6 @@ bool wxAnimationPlayer::Build() int i; for (i = 0; i < n; i++) { - wxBitmap* bitmap = NULL; wxImage* image = GetFrame(i); if (image) { @@ -120,7 +119,7 @@ bool wxAnimationPlayer::Build() if (GetTransparentColour(transparentColour)) image->SetMaskColour(transparentColour.Red(), transparentColour.Green(), transparentColour.Blue()); - bitmap = new wxBitmap(* image); + wxBitmap* bitmap = new wxBitmap(* image); delete image; if (bitmap) m_frames.Append(bitmap); @@ -216,7 +215,7 @@ bool wxAnimationPlayer::GetTransparentColour(wxColour& col) const } // Play the frame -bool wxAnimationPlayer::PlayFrame(int frame, wxWindow& window, const wxPoint& pos) +bool wxAnimationPlayer::PlayFrame(int frame, wxWindow& window, const wxPoint& WXUNUSED(pos)) { wxMemoryDC dc; dc.SelectObject(m_backingStore); @@ -246,7 +245,7 @@ bool wxAnimationPlayer::PlayFrame(int frame, wxWindow& window, const wxPoint& po // Draw all intermediate frames that haven't been removed from the // animation int i; - for (i = 0; i < (frame - 1); i++) + for (i = 0; i < frame; i++) { if ((GetDisposalMethod(i) == wxANIM_DONOTREMOVE) || (GetDisposalMethod(i) == wxANIM_UNSPECIFIED)) { @@ -271,7 +270,11 @@ bool wxAnimationPlayer::PlayFrame() PlayFrame(GetCurrentFrame(), * GetWindow(), GetPosition()); // Set the timer for the next frame - m_timer.Start(GetDelay(GetCurrentFrame())); + int delay = GetDelay(GetCurrentFrame()); + if (delay == 0) + delay = 1; // 0 is invalid timeout for wxTimer. + + m_timer.Start(delay); m_currentFrame ++; @@ -293,13 +296,13 @@ bool wxAnimationPlayer::PlayFrame() // Clear the wxImage cache void wxAnimationPlayer::ClearCache() { - wxNode* node = m_frames.GetFirst(); + wxList::compatibility_iterator node = m_frames.GetFirst(); while (node) { - wxNode* next = node->GetNext(); + wxList::compatibility_iterator next = node->GetNext(); wxBitmap* bitmap = (wxBitmap*) node->GetData(); delete bitmap; - delete node; + m_frames.Erase(node); node = next; } } @@ -370,7 +373,7 @@ void wxAnimationPlayer::DrawFrame(int frame, wxDC& dc, const wxPoint& pos) { wxASSERT_MSG( (m_animation != NULL), _T("Animation not present in wxAnimationPlayer")); wxASSERT_MSG( (m_frames.GetCount() != 0), _T("Animation cache not present in wxAnimationPlayer")); - wxASSERT_MSG( (m_frames.Item(frame) != (wxNode*) NULL), _T("Image not present in wxAnimationPlayer::DrawFrame")); + wxASSERT_MSG( !!m_frames.Item(frame), _T("Image not present in wxAnimationPlayer::DrawFrame")); wxBitmap* bitmap = (wxBitmap*) m_frames.Item(frame)->GetData() ; @@ -417,7 +420,7 @@ wxImage* wxGIFAnimation::GetFrame(int i) const { wxASSERT_MSG( (m_decoder != (wxGIFDecoder*) NULL), _T("m_decoder must be non-NULL")); - m_decoder->GoFrame(i); + m_decoder->GoFrame(i + 1); wxImage* image = new wxImage; m_decoder->ConvertToImage(image); @@ -428,7 +431,7 @@ wxAnimationDisposal wxGIFAnimation::GetDisposalMethod(int i) const { wxASSERT_MSG( (m_decoder != (wxGIFDecoder*) NULL), _T("m_decoder must be non-NULL")); - m_decoder->GoFrame(i); + m_decoder->GoFrame(i + 1); int disposalMethod = m_decoder->GetDisposalMethod(); return (wxAnimationDisposal) disposalMethod; @@ -438,7 +441,7 @@ wxRect wxGIFAnimation::GetFrameRect(int i) const { wxASSERT_MSG( (m_decoder != (wxGIFDecoder*) NULL), _T("m_decoder must be non-NULL")); - m_decoder->GoFrame(i); + m_decoder->GoFrame(i + 1); wxRect rect(m_decoder->GetLeft(), m_decoder->GetTop(), m_decoder->GetWidth(), m_decoder->GetHeight()); return rect; @@ -448,7 +451,7 @@ int wxGIFAnimation::GetDelay(int i) const { wxASSERT_MSG( (m_decoder != (wxGIFDecoder*) NULL), _T("m_decoder must be non-NULL")); - m_decoder->GoFrame(i); + m_decoder->GoFrame(i + 1); return m_decoder->GetDelay(); } @@ -573,6 +576,8 @@ bool wxAnimationCtrlBase::Create(wxWindow *parent, wxWindowID id, m_animationPlayer.SetPosition(wxPoint(0, 0)); m_animationPlayer.SetDestroyAnimation(FALSE); + LoadFile(filename); + return TRUE; } @@ -647,7 +652,7 @@ void wxAnimationCtrlBase::FitToAnimation() SetClientSize(sz); } -void wxAnimationCtrlBase::OnPaint(wxPaintEvent& event) +void wxAnimationCtrlBase::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this);