$OpenBSD: patch-src_MuleGifCtrl_cpp,v 1.1 2007/10/26 15:00:39 steven Exp $ --- src/MuleGifCtrl.cpp.orig Fri Feb 3 20:14:05 2006 +++ src/MuleGifCtrl.cpp Wed Oct 10 17:53:08 2007 @@ -24,7 +24,6 @@ #include #include -#include #include #include "MuleGifCtrl.h" @@ -35,7 +34,51 @@ BEGIN_EVENT_TABLE(MuleGifCtrl, wxControl) EVT_ERASE_BACKGROUND(MuleGifCtrl::OnErase) END_EVENT_TABLE() +#if wxCHECK_VERSION(2, 7, 1) +// Wrapper that emulates old wxGIFDecoder API +class MuleGIFDecoder : public wxGIFDecoder { +public: + MuleGIFDecoder(wxInputStream* stream, bool dummy) { + m_stream = stream; + dummy = dummy; // Unused. + m_nframe = 0; + } + + ~MuleGIFDecoder() { /* don't delete the stream! */ } + + wxGIFErrorCode ReadGIF() { + return LoadGIF(*m_stream); + } + + void GoFirstFrame() { m_nframe = 0; } + void GoNextFrame(bool dummy) { m_nframe < GetFrameCount() ? m_nframe++ : m_nframe = 0; } + void GoLastFrame() { m_nframe = GetFrameCount(); } + + void ConvertToImage(wxImage* image) { wxGIFDecoder::ConvertToImage(m_nframe, image); } + + size_t GetLogicalScreenWidth() { return GetAnimationSize().GetWidth(); } + size_t GetLogicalScreenHeight() { return GetAnimationSize().GetHeight(); } + + size_t GetLeft() { return 0; } + size_t GetTop() { return 0; } + + long GetDelay() { return wxGIFDecoder::GetDelay(m_nframe); } + +private: + uint32_t m_nframe; + wxInputStream* m_stream; +}; + +#else +class MuleGIFDecoder : public wxGIFDecoder { +public: + MuleGIFDecoder(wxInputStream* stream, bool flag) : wxGIFDecoder(stream,flag) {}; +}; +#endif + + + MuleGifCtrl::MuleGifCtrl( wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name ) @@ -66,7 +109,7 @@ bool MuleGifCtrl::LoadData(const char* data, int size) } wxMemoryInputStream stream(data, size); - m_decoder = new wxGIFDecoder(&stream, TRUE); + m_decoder = new MuleGIFDecoder(&stream, TRUE); if ( m_decoder->ReadGIF() != wxGIF_OK ) { delete m_decoder; m_decoder = NULL; @@ -137,3 +180,4 @@ void MuleGifCtrl::OnPaint( wxPaintEvent& WXUNUSED(even dc.DrawBitmap( m_frame, x + m_decoder->GetLeft(), y + m_decoder->GetTop(), true); } +// File_checked_for_headers