X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4638d697a3cf0b71597b1cedbbd8f62d2a4d3797..9c112555198f51fcec71106530cddba95a17f3dc:/contrib/src/animate/animate.cpp diff --git a/contrib/src/animate/animate.cpp b/contrib/src/animate/animate.cpp index 6a17313299..f033901e62 100644 --- a/contrib/src/animate/animate.cpp +++ b/contrib/src/animate/animate.cpp @@ -22,7 +22,11 @@ #include "wx/wfstream.h" #include "wx/image.h" #include "wx/gifdecod.h" +#include "wx/log.h" +#include "wx/dcmemory.h" #include "wx/animate/animate.h" +#include "wx/dc.h" +#include "wx/dcclient.h" /* * wxAnimationPlayer @@ -65,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; @@ -76,11 +80,11 @@ bool wxAnimationPlayer::Play(wxWindow& window, const wxPoint& pos, bool looped) wxRect rect(pos, sz); SaveBackground(rect); - if (m_frames.Number() == 0) + if (m_frames.GetCount() == 0) { if (!Build()) { - wxLogWarning("wxAnimationPlayer::Play: could not build the image cache."); + wxLogWarning(_T("wxAnimationPlayer::Play: could not build the image cache.")); return FALSE; } } @@ -105,7 +109,6 @@ bool wxAnimationPlayer::Build() int i; for (i = 0; i < n; i++) { - wxBitmap* bitmap = NULL; wxImage* image = GetFrame(i); if (image) { @@ -116,7 +119,7 @@ bool wxAnimationPlayer::Build() if (GetTransparentColour(transparentColour)) image->SetMaskColour(transparentColour.Red(), transparentColour.Green(), transparentColour.Blue()); - bitmap = new wxBitmap(image->ConvertToBitmap()); + wxBitmap* bitmap = new wxBitmap(* image); delete image; if (bitmap) m_frames.Append(bitmap); @@ -212,7 +215,7 @@ bool wxAnimationPlayer::GetTransparentColour(wxColour& col) const } // Play the frame -bool wxAnimationPlayer::PlayFrame(int frame, wxWindow& window, wxPoint& pos) +bool wxAnimationPlayer::PlayFrame(int frame, wxWindow& window, const wxPoint& WXUNUSED(pos)) { wxMemoryDC dc; dc.SelectObject(m_backingStore); @@ -242,7 +245,7 @@ bool wxAnimationPlayer::PlayFrame(int frame, wxWindow& window, wxPoint& pos) // 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)) { @@ -289,13 +292,13 @@ bool wxAnimationPlayer::PlayFrame() // Clear the wxImage cache void wxAnimationPlayer::ClearCache() { - wxNode* node = m_frames.First(); + wxList::compatibility_iterator node = m_frames.GetFirst(); while (node) { - wxNode* next = node->Next(); - wxBitmap* bitmap = (wxBitmap*) node->Data(); + wxList::compatibility_iterator next = node->GetNext(); + wxBitmap* bitmap = (wxBitmap*) node->GetData(); delete bitmap; - delete node; + m_frames.Erase(node); node = next; } } @@ -303,13 +306,13 @@ void wxAnimationPlayer::ClearCache() // Draw the background colour void wxAnimationPlayer::DrawBackground(wxDC& dc, const wxPoint& pos, const wxColour& colour) { - wxASSERT_MSG( (m_animation != NULL), "Animation not present in wxAnimationPlayer"); - wxASSERT_MSG( (m_frames.Number() != 0), "Animation cache not present in wxAnimationPlayer"); + wxASSERT_MSG( (m_animation != NULL), _T("Animation not present in wxAnimationPlayer")); + wxASSERT_MSG( (m_frames.GetCount() != 0), _T("Animation cache not present in wxAnimationPlayer")); // Optimization: if the first frame fills the whole area, and is non-transparent, // don't bother drawing the background - wxBitmap* firstBitmap = (wxBitmap*) m_frames.First()->Data() ; + wxBitmap* firstBitmap = (wxBitmap*) m_frames.GetFirst()->GetData() ; wxSize screenSize = GetLogicalScreenSize(); if (!firstBitmap->GetMask() && (firstBitmap->GetWidth() == screenSize.x) && (firstBitmap->GetHeight() == screenSize.y)) { @@ -364,11 +367,11 @@ void wxAnimationPlayer::SaveBackground(const wxRect& rect) // Draw this frame void wxAnimationPlayer::DrawFrame(int frame, wxDC& dc, const wxPoint& pos) { - wxASSERT_MSG( (m_animation != NULL), "Animation not present in wxAnimationPlayer"); - wxASSERT_MSG( (m_frames.Number() != 0), "Animation cache not present in wxAnimationPlayer"); - wxASSERT_MSG( (m_frames.Nth(frame) != (wxNode*) NULL), "Image not present in wxAnimationPlayer::DrawFrame"); + 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), _T("Image not present in wxAnimationPlayer::DrawFrame")); - wxBitmap* bitmap = (wxBitmap*) m_frames.Nth(frame)->Data() ; + wxBitmap* bitmap = (wxBitmap*) m_frames.Item(frame)->GetData() ; wxRect rect = GetFrameRect(frame); @@ -404,16 +407,16 @@ wxGIFAnimation::~wxGIFAnimation() int wxGIFAnimation::GetFrameCount() const { - wxASSERT_MSG( (m_decoder != (wxGIFDecoder*) NULL), "m_decoder must be non-NULL"); + wxASSERT_MSG( (m_decoder != (wxGIFDecoder*) NULL), _T("m_decoder must be non-NULL")); return m_decoder->GetNumberOfFrames(); } wxImage* wxGIFAnimation::GetFrame(int i) const { - wxASSERT_MSG( (m_decoder != (wxGIFDecoder*) NULL), "m_decoder must be non-NULL"); + 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); @@ -422,9 +425,9 @@ wxImage* wxGIFAnimation::GetFrame(int i) const wxAnimationDisposal wxGIFAnimation::GetDisposalMethod(int i) const { - wxASSERT_MSG( (m_decoder != (wxGIFDecoder*) NULL), "m_decoder must be non-NULL"); + 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; @@ -432,9 +435,9 @@ wxAnimationDisposal wxGIFAnimation::GetDisposalMethod(int i) const wxRect wxGIFAnimation::GetFrameRect(int i) const { - wxASSERT_MSG( (m_decoder != (wxGIFDecoder*) NULL), "m_decoder must be non-NULL"); + 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; @@ -442,22 +445,22 @@ wxRect wxGIFAnimation::GetFrameRect(int i) const int wxGIFAnimation::GetDelay(int i) const { - wxASSERT_MSG( (m_decoder != (wxGIFDecoder*) NULL), "m_decoder must be non-NULL"); + 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(); } wxSize wxGIFAnimation::GetLogicalScreenSize() const { - wxASSERT_MSG( (m_decoder != (wxGIFDecoder*) NULL), "m_decoder must be non-NULL"); + wxASSERT_MSG( (m_decoder != (wxGIFDecoder*) NULL), _T("m_decoder must be non-NULL")); return wxSize(m_decoder->GetLogicalScreenWidth(), m_decoder->GetLogicalScreenHeight()); } bool wxGIFAnimation::GetBackgroundColour(wxColour& col) const { - wxASSERT_MSG( (m_decoder != (wxGIFDecoder*) NULL), "m_decoder must be non-NULL"); + wxASSERT_MSG( (m_decoder != (wxGIFDecoder*) NULL), _T("m_decoder must be non-NULL")); int i = m_decoder->GetBackgroundColour(); if (i == -1) @@ -478,7 +481,7 @@ bool wxGIFAnimation::GetBackgroundColour(wxColour& col) const bool wxGIFAnimation::GetTransparentColour(wxColour& col) const { - wxASSERT_MSG( (m_decoder != (wxGIFDecoder*) NULL), "m_decoder must be non-NULL"); + wxASSERT_MSG( (m_decoder != (wxGIFDecoder*) NULL), _T("m_decoder must be non-NULL")); int i = m_decoder->GetTransparentColour(); if (i == -1) @@ -569,6 +572,8 @@ bool wxAnimationCtrlBase::Create(wxWindow *parent, wxWindowID id, m_animationPlayer.SetPosition(wxPoint(0, 0)); m_animationPlayer.SetDestroyAnimation(FALSE); + LoadFile(filename); + return TRUE; } @@ -643,7 +648,7 @@ void wxAnimationCtrlBase::FitToAnimation() SetClientSize(sz); } -void wxAnimationCtrlBase::OnPaint(wxPaintEvent& event) +void wxAnimationCtrlBase::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this);