reformatted; added more error checking
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36599 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -15,14 +15,14 @@
|
|||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif //__BORLANDC__
|
#endif //__BORLANDC__
|
||||||
|
|
||||||
|
#include "wx/log.h"
|
||||||
#include "wx/wfstream.h"
|
#include "wx/wfstream.h"
|
||||||
#include "wx/image.h"
|
#include "wx/image.h"
|
||||||
#include "wx/gifdecod.h"
|
#include "wx/gifdecod.h"
|
||||||
#include "wx/log.h"
|
|
||||||
#include "wx/dcmemory.h"
|
#include "wx/dcmemory.h"
|
||||||
#include "wx/animate/animate.h"
|
|
||||||
#include "wx/dc.h"
|
#include "wx/dc.h"
|
||||||
#include "wx/dcclient.h"
|
#include "wx/dcclient.h"
|
||||||
|
#include "wx/animate/animate.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* wxAnimationPlayer
|
* wxAnimationPlayer
|
||||||
@@ -34,15 +34,15 @@ wxAnimationPlayer::wxAnimationPlayer(wxAnimationBase *animation, bool destroyAni
|
|||||||
{
|
{
|
||||||
m_animation = animation;
|
m_animation = animation;
|
||||||
m_destroyAnimation = destroyAnimation;
|
m_destroyAnimation = destroyAnimation;
|
||||||
|
m_customBackgroundColour = wxColour(0, 0, 0);
|
||||||
m_currentFrame = 0;
|
m_currentFrame = 0;
|
||||||
m_window = (wxWindow*) NULL;
|
m_window = (wxWindow*) NULL;
|
||||||
m_position = wxPoint(0, 0);
|
m_position = wxPoint(0, 0);
|
||||||
m_looped = TRUE;
|
m_looped = true;
|
||||||
m_isPlaying = FALSE;
|
m_isPlaying = false;
|
||||||
m_useBackgroundColour = FALSE;
|
m_useBackgroundColour = false;
|
||||||
m_customBackgroundColour = wxColour(0, 0, 0);
|
m_useCustomBackgroundColour = false;
|
||||||
m_useCustomBackgroundColour = FALSE;
|
m_useParentBackground = false;
|
||||||
m_useParentBackground = FALSE;
|
|
||||||
m_timer.SetPlayer(this);
|
m_timer.SetPlayer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ bool wxAnimationPlayer::Play(wxWindow& window, const wxPoint& pos, bool WXUNUSED
|
|||||||
m_window = & window;
|
m_window = & window;
|
||||||
|
|
||||||
if (!m_animation || !m_animation->IsValid())
|
if (!m_animation || !m_animation->IsValid())
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
wxSize sz = GetLogicalScreenSize();
|
wxSize sz = GetLogicalScreenSize();
|
||||||
wxRect rect(pos, sz);
|
wxRect rect(pos, sz);
|
||||||
@@ -81,9 +81,11 @@ bool wxAnimationPlayer::Play(wxWindow& window, const wxPoint& pos, bool WXUNUSED
|
|||||||
if (!Build())
|
if (!Build())
|
||||||
{
|
{
|
||||||
wxLogWarning(_T("wxAnimationPlayer::Play: could not build the image cache."));
|
wxLogWarning(_T("wxAnimationPlayer::Play: could not build the image cache."));
|
||||||
return FALSE;
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_currentFrame = 0;
|
m_currentFrame = 0;
|
||||||
|
|
||||||
// Create the backing store
|
// Create the backing store
|
||||||
@@ -91,7 +93,7 @@ bool wxAnimationPlayer::Play(wxWindow& window, const wxPoint& pos, bool WXUNUSED
|
|||||||
|
|
||||||
PlayFrame();
|
PlayFrame();
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build animation (list of wxImages). If not called before Play
|
// Build animation (list of wxImages). If not called before Play
|
||||||
@@ -99,15 +101,18 @@ bool wxAnimationPlayer::Play(wxWindow& window, const wxPoint& pos, bool WXUNUSED
|
|||||||
bool wxAnimationPlayer::Build()
|
bool wxAnimationPlayer::Build()
|
||||||
{
|
{
|
||||||
ClearCache();
|
ClearCache();
|
||||||
if (m_animation)
|
if (!m_animation)
|
||||||
{
|
return false;
|
||||||
int n = GetFrameCount();
|
|
||||||
int i;
|
int i, n;
|
||||||
|
|
||||||
|
n = GetFrameCount();
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
wxImage* image = GetFrame(i);
|
wxImage* image = GetFrame(i);
|
||||||
if (image)
|
if (image == NULL)
|
||||||
{
|
return false;
|
||||||
|
|
||||||
// If the frame has transparency,
|
// If the frame has transparency,
|
||||||
// set the colour so converting to a bitmap
|
// set the colour so converting to a bitmap
|
||||||
// will create a mask
|
// will create a mask
|
||||||
@@ -115,27 +120,22 @@ bool wxAnimationPlayer::Build()
|
|||||||
if (GetTransparentColour(transparentColour))
|
if (GetTransparentColour(transparentColour))
|
||||||
image->SetMaskColour(transparentColour.Red(), transparentColour.Green(), transparentColour.Blue());
|
image->SetMaskColour(transparentColour.Red(), transparentColour.Green(), transparentColour.Blue());
|
||||||
|
|
||||||
wxBitmap* bitmap = new wxBitmap(* image);
|
wxBitmap* bitmap = new wxBitmap(*image);
|
||||||
delete image;
|
delete image;
|
||||||
if (bitmap)
|
if (bitmap == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
m_frames.Append(bitmap);
|
m_frames.Append(bitmap);
|
||||||
else
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return FALSE;
|
return true;
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop the animation
|
// Stop the animation
|
||||||
void wxAnimationPlayer::Stop()
|
void wxAnimationPlayer::Stop()
|
||||||
{
|
{
|
||||||
m_timer.Stop();
|
m_timer.Stop();
|
||||||
m_isPlaying = FALSE;
|
m_isPlaying = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the current view of the animation into this DC.
|
// Draw the current view of the animation into this DC.
|
||||||
@@ -145,7 +145,6 @@ void wxAnimationPlayer::Draw(wxDC& dc)
|
|||||||
dc.DrawBitmap(m_backingStore, m_position.x, m_position.y);
|
dc.DrawBitmap(m_backingStore, m_position.x, m_position.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int wxAnimationPlayer::GetFrameCount() const
|
int wxAnimationPlayer::GetFrameCount() const
|
||||||
{
|
{
|
||||||
if (m_animation)
|
if (m_animation)
|
||||||
@@ -199,7 +198,7 @@ bool wxAnimationPlayer::GetBackgroundColour(wxColour& col) const
|
|||||||
if (m_animation)
|
if (m_animation)
|
||||||
return m_animation->GetBackgroundColour(col);
|
return m_animation->GetBackgroundColour(col);
|
||||||
else
|
else
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxAnimationPlayer::GetTransparentColour(wxColour& col) const
|
bool wxAnimationPlayer::GetTransparentColour(wxColour& col) const
|
||||||
@@ -207,7 +206,7 @@ bool wxAnimationPlayer::GetTransparentColour(wxColour& col) const
|
|||||||
if (m_animation)
|
if (m_animation)
|
||||||
return m_animation->GetTransparentColour(col);
|
return m_animation->GetTransparentColour(col);
|
||||||
else
|
else
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Play the frame
|
// Play the frame
|
||||||
@@ -224,9 +223,7 @@ bool wxAnimationPlayer::PlayFrame(int frame, wxWindow& window, const wxPoint& WX
|
|||||||
if (UsingCustomBackgroundColour())
|
if (UsingCustomBackgroundColour())
|
||||||
col = GetCustomBackgroundColour();
|
col = GetCustomBackgroundColour();
|
||||||
else
|
else
|
||||||
{
|
|
||||||
GetBackgroundColour(col);
|
GetBackgroundColour(col);
|
||||||
}
|
|
||||||
|
|
||||||
// Draw the background colour loaded from the animation
|
// Draw the background colour loaded from the animation
|
||||||
// (or set by the user)
|
// (or set by the user)
|
||||||
@@ -238,16 +235,14 @@ bool wxAnimationPlayer::PlayFrame(int frame, wxWindow& window, const wxPoint& WX
|
|||||||
dc.DrawBitmap(m_savedBackground, 0, 0);
|
dc.DrawBitmap(m_savedBackground, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw all intermediate frames that haven't been removed from the
|
// Draw all intermediate frames that haven't been removed from the animation
|
||||||
// animation
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < frame; i++)
|
for (i = 0; i < frame; i++)
|
||||||
{
|
{
|
||||||
if ((GetDisposalMethod(i) == wxANIM_DONOTREMOVE) || (GetDisposalMethod(i) == wxANIM_UNSPECIFIED))
|
if ((GetDisposalMethod(i) == wxANIM_DONOTREMOVE) || (GetDisposalMethod(i) == wxANIM_UNSPECIFIED))
|
||||||
{
|
|
||||||
DrawFrame(i, dc, wxPoint(0, 0));
|
DrawFrame(i, dc, wxPoint(0, 0));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
DrawFrame(frame, dc, wxPoint(0, 0));
|
DrawFrame(frame, dc, wxPoint(0, 0));
|
||||||
|
|
||||||
dc.SelectObject(wxNullBitmap);
|
dc.SelectObject(wxNullBitmap);
|
||||||
@@ -256,12 +251,12 @@ bool wxAnimationPlayer::PlayFrame(int frame, wxWindow& window, const wxPoint& WX
|
|||||||
wxClientDC clientDC(& window);
|
wxClientDC clientDC(& window);
|
||||||
Draw(clientDC);
|
Draw(clientDC);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxAnimationPlayer::PlayFrame()
|
bool wxAnimationPlayer::PlayFrame()
|
||||||
{
|
{
|
||||||
m_isPlaying = TRUE;
|
m_isPlaying = true;
|
||||||
|
|
||||||
PlayFrame(GetCurrentFrame(), * GetWindow(), GetPosition());
|
PlayFrame(GetCurrentFrame(), * GetWindow(), GetPosition());
|
||||||
|
|
||||||
@@ -280,13 +275,13 @@ bool wxAnimationPlayer::PlayFrame()
|
|||||||
if (!m_looped)
|
if (!m_looped)
|
||||||
{
|
{
|
||||||
m_timer.Stop();
|
m_timer.Stop();
|
||||||
m_isPlaying = FALSE;
|
m_isPlaying = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_currentFrame = 0;
|
m_currentFrame = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear the wxImage cache
|
// Clear the wxImage cache
|
||||||
@@ -299,6 +294,7 @@ void wxAnimationPlayer::ClearCache()
|
|||||||
wxBitmap* bitmap = (wxBitmap*) node->GetData();
|
wxBitmap* bitmap = (wxBitmap*) node->GetData();
|
||||||
delete bitmap;
|
delete bitmap;
|
||||||
m_frames.Erase(node);
|
m_frames.Erase(node);
|
||||||
|
|
||||||
node = next;
|
node = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -307,7 +303,7 @@ void wxAnimationPlayer::ClearCache()
|
|||||||
void wxAnimationPlayer::DrawBackground(wxDC& dc, const wxPoint& pos, const wxColour& colour)
|
void wxAnimationPlayer::DrawBackground(wxDC& dc, const wxPoint& pos, const wxColour& colour)
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( (m_animation != NULL), _T("Animation 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"));
|
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,
|
// Optimization: if the first frame fills the whole area, and is non-transparent,
|
||||||
// don't bother drawing the background
|
// don't bother drawing the background
|
||||||
@@ -315,9 +311,7 @@ void wxAnimationPlayer::DrawBackground(wxDC& dc, const wxPoint& pos, const wxCol
|
|||||||
wxBitmap* firstBitmap = (wxBitmap*) m_frames.GetFirst()->GetData() ;
|
wxBitmap* firstBitmap = (wxBitmap*) m_frames.GetFirst()->GetData() ;
|
||||||
wxSize screenSize = GetLogicalScreenSize();
|
wxSize screenSize = GetLogicalScreenSize();
|
||||||
if (!firstBitmap->GetMask() && (firstBitmap->GetWidth() == screenSize.x) && (firstBitmap->GetHeight() == screenSize.y))
|
if (!firstBitmap->GetMask() && (firstBitmap->GetWidth() == screenSize.x) && (firstBitmap->GetHeight() == screenSize.y))
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
wxBrush brush(colour, wxSOLID);
|
wxBrush brush(colour, wxSOLID);
|
||||||
wxPen pen(colour, 1, wxSOLID);
|
wxPen pen(colour, 1, wxSOLID);
|
||||||
@@ -332,7 +326,7 @@ void wxAnimationPlayer::DrawBackground(wxDC& dc, const wxPoint& pos, const wxCol
|
|||||||
// it if drawing transparently
|
// it if drawing transparently
|
||||||
void wxAnimationPlayer::SaveBackground(const wxRect& rect)
|
void wxAnimationPlayer::SaveBackground(const wxRect& rect)
|
||||||
{
|
{
|
||||||
wxASSERT( GetWindow() );
|
wxASSERT( (GetWindow() != NULL) );
|
||||||
|
|
||||||
if (!GetWindow())
|
if (!GetWindow())
|
||||||
return;
|
return;
|
||||||
@@ -361,6 +355,7 @@ void wxAnimationPlayer::SaveBackground(const wxRect& rect)
|
|||||||
|
|
||||||
memDC.Blit(0, 0, rect.width, rect.height, & dc, rect.x, rect.y);
|
memDC.Blit(0, 0, rect.width, rect.height, & dc, rect.x, rect.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
memDC.SelectObject(wxNullBitmap);
|
memDC.SelectObject(wxNullBitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,10 +367,9 @@ void wxAnimationPlayer::DrawFrame(int frame, wxDC& dc, const wxPoint& pos)
|
|||||||
wxASSERT_MSG( !!m_frames.Item(frame), _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() ;
|
wxBitmap* bitmap = (wxBitmap*) m_frames.Item(frame)->GetData() ;
|
||||||
|
|
||||||
wxRect rect = GetFrameRect(frame);
|
wxRect rect = GetFrameRect(frame);
|
||||||
|
|
||||||
dc.DrawBitmap(* bitmap, pos.x + rect.x, pos.y + rect.y, (bitmap->GetMask() != NULL));
|
dc.DrawBitmap(*bitmap, pos.x + rect.x, pos.y + rect.y, (bitmap->GetMask() != NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxAnimationTimer::Notify()
|
void wxAnimationTimer::Notify()
|
||||||
@@ -420,6 +414,7 @@ wxImage* wxGIFAnimation::GetFrame(int i) const
|
|||||||
|
|
||||||
wxImage* image = new wxImage;
|
wxImage* image = new wxImage;
|
||||||
m_decoder->ConvertToImage(image);
|
m_decoder->ConvertToImage(image);
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,6 +435,7 @@ wxRect wxGIFAnimation::GetFrameRect(int i) const
|
|||||||
m_decoder->GoFrame(i + 1);
|
m_decoder->GoFrame(i + 1);
|
||||||
|
|
||||||
wxRect rect(m_decoder->GetLeft(), m_decoder->GetTop(), m_decoder->GetWidth(), m_decoder->GetHeight());
|
wxRect rect(m_decoder->GetLeft(), m_decoder->GetTop(), m_decoder->GetWidth(), m_decoder->GetHeight());
|
||||||
|
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -448,6 +444,7 @@ int wxGIFAnimation::GetDelay(int i) const
|
|||||||
wxASSERT_MSG( (m_decoder != (wxGIFDecoder*) NULL), _T("m_decoder must be non-NULL"));
|
wxASSERT_MSG( (m_decoder != (wxGIFDecoder*) NULL), _T("m_decoder must be non-NULL"));
|
||||||
|
|
||||||
m_decoder->GoFrame(i + 1);
|
m_decoder->GoFrame(i + 1);
|
||||||
|
|
||||||
return m_decoder->GetDelay();
|
return m_decoder->GetDelay();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -464,19 +461,15 @@ bool wxGIFAnimation::GetBackgroundColour(wxColour& col) const
|
|||||||
|
|
||||||
int i = m_decoder->GetBackgroundColour();
|
int i = m_decoder->GetBackgroundColour();
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
return FALSE;
|
return false;
|
||||||
else
|
|
||||||
{
|
|
||||||
unsigned char* pal = m_decoder->GetPalette();
|
|
||||||
|
|
||||||
if (pal)
|
const unsigned char *pal = m_decoder->GetPalette();
|
||||||
{
|
bool result = (pal != NULL);
|
||||||
|
|
||||||
|
if (result)
|
||||||
col = wxColour(pal[3*i + 0], pal[3*i + 1], pal[3*i + 2]);
|
col = wxColour(pal[3*i + 0], pal[3*i + 1], pal[3*i + 2]);
|
||||||
return TRUE;
|
|
||||||
}
|
return result;
|
||||||
else
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGIFAnimation::GetTransparentColour(wxColour& col) const
|
bool wxGIFAnimation::GetTransparentColour(wxColour& col) const
|
||||||
@@ -485,19 +478,15 @@ bool wxGIFAnimation::GetTransparentColour(wxColour& col) const
|
|||||||
|
|
||||||
int i = m_decoder->GetTransparentColour();
|
int i = m_decoder->GetTransparentColour();
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
return FALSE;
|
return false;
|
||||||
else
|
|
||||||
{
|
|
||||||
unsigned char* pal = m_decoder->GetPalette();
|
|
||||||
|
|
||||||
if (pal)
|
const unsigned char *pal = m_decoder->GetPalette();
|
||||||
{
|
bool result = (pal != NULL);
|
||||||
|
|
||||||
|
if (result)
|
||||||
col = wxColour(pal[3*i + 0], pal[3*i + 1], pal[3*i + 2]);
|
col = wxColour(pal[3*i + 0], pal[3*i + 1], pal[3*i + 2]);
|
||||||
return TRUE;
|
|
||||||
}
|
return result;
|
||||||
else
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGIFAnimation::IsValid() const
|
bool wxGIFAnimation::IsValid() const
|
||||||
@@ -507,34 +496,35 @@ bool wxGIFAnimation::IsValid() const
|
|||||||
|
|
||||||
bool wxGIFAnimation::LoadFile(const wxString& filename)
|
bool wxGIFAnimation::LoadFile(const wxString& filename)
|
||||||
{
|
{
|
||||||
|
if (!wxFileExists(filename))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool result = true;
|
||||||
|
|
||||||
if (m_decoder)
|
if (m_decoder)
|
||||||
|
{
|
||||||
delete m_decoder;
|
delete m_decoder;
|
||||||
m_decoder = NULL;
|
m_decoder = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (wxFileExists(filename))
|
|
||||||
{
|
{
|
||||||
wxFileInputStream stream(filename);
|
wxFileInputStream stream(filename);
|
||||||
m_decoder = new wxGIFDecoder(& stream, TRUE);
|
|
||||||
|
|
||||||
if (m_decoder->ReadGIF() != wxGIF_OK)
|
if (stream.GetLength() > 0)
|
||||||
|
m_decoder = new wxGIFDecoder(&stream, true);
|
||||||
|
|
||||||
|
result = ((m_decoder != NULL) && (m_decoder->ReadGIF() == wxGIF_OK));
|
||||||
|
if (result)
|
||||||
|
result = m_decoder->IsAnimation();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!result && (m_decoder != NULL))
|
||||||
{
|
{
|
||||||
delete m_decoder;
|
delete m_decoder;
|
||||||
m_decoder = NULL;
|
m_decoder = NULL;
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_decoder->IsAnimation())
|
return result;
|
||||||
{
|
|
||||||
delete m_decoder;
|
|
||||||
m_decoder = NULL;
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -558,30 +548,32 @@ bool wxAnimationCtrlBase::Create(wxWindow *parent, wxWindowID id,
|
|||||||
m_filename = filename;
|
m_filename = filename;
|
||||||
|
|
||||||
if (!wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name))
|
if (!wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
SetBackgroundColour(parent->GetBackgroundColour());
|
SetBackgroundColour(parent->GetBackgroundColour());
|
||||||
|
|
||||||
m_animationPlayer.SetCustomBackgroundColour(GetBackgroundColour());
|
m_animationPlayer.SetCustomBackgroundColour(GetBackgroundColour());
|
||||||
|
|
||||||
// Want to give the impression of transparency by painting
|
// give the impression of transparency by painting
|
||||||
// the parent background
|
// with the parent background
|
||||||
// if (parent)
|
// if (parent)
|
||||||
// m_animationPlayer.UseParentBackground(TRUE);
|
// m_animationPlayer.UseParentBackground(true);
|
||||||
|
|
||||||
m_animationPlayer.SetWindow(this);
|
m_animationPlayer.SetWindow(this);
|
||||||
m_animationPlayer.SetPosition(wxPoint(0, 0));
|
m_animationPlayer.SetPosition(wxPoint(0, 0));
|
||||||
m_animationPlayer.SetDestroyAnimation(FALSE);
|
m_animationPlayer.SetDestroyAnimation(false);
|
||||||
|
|
||||||
LoadFile(filename);
|
LoadFile(filename);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxAnimationCtrlBase::~wxAnimationCtrlBase()
|
wxAnimationCtrlBase::~wxAnimationCtrlBase()
|
||||||
{
|
{
|
||||||
if (m_animationPlayer.IsPlaying())
|
if (m_animationPlayer.IsPlaying())
|
||||||
m_animationPlayer.Stop();
|
m_animationPlayer.Stop();
|
||||||
m_animationPlayer.SetAnimation(NULL, FALSE);
|
m_animationPlayer.SetAnimation(NULL, false);
|
||||||
|
|
||||||
delete m_animation;
|
delete m_animation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -593,10 +585,11 @@ bool wxAnimationCtrlBase::LoadFile(const wxString& filename)
|
|||||||
wxString filename1(filename);
|
wxString filename1(filename);
|
||||||
|
|
||||||
if (filename1.IsEmpty())
|
if (filename1.IsEmpty())
|
||||||
|
{
|
||||||
filename1 = m_filename;
|
filename1 = m_filename;
|
||||||
|
|
||||||
if (filename1.IsEmpty())
|
if (filename1.IsEmpty())
|
||||||
return FALSE;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_animation)
|
if (m_animation)
|
||||||
{
|
{
|
||||||
@@ -606,20 +599,22 @@ bool wxAnimationCtrlBase::LoadFile(const wxString& filename)
|
|||||||
|
|
||||||
m_animation = DoCreateAnimation(filename1);
|
m_animation = DoCreateAnimation(filename1);
|
||||||
if (!m_animation)
|
if (!m_animation)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (!m_animation->LoadFile(filename) || !m_animation->IsValid())
|
if (!m_animation->LoadFile(filename) || !m_animation->IsValid())
|
||||||
{
|
{
|
||||||
delete m_animation;
|
delete m_animation;
|
||||||
m_animation = NULL;
|
m_animation = NULL;
|
||||||
return FALSE;
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
m_animationPlayer.SetAnimation(m_animation, FALSE);
|
|
||||||
|
m_animationPlayer.SetAnimation(m_animation, false);
|
||||||
|
|
||||||
if (GetWindowStyle() & wxAN_FIT_ANIMATION)
|
if (GetWindowStyle() & wxAN_FIT_ANIMATION)
|
||||||
FitToAnimation();
|
FitToAnimation();
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxAnimationCtrlBase::Play(bool looped)
|
bool wxAnimationCtrlBase::Play(bool looped)
|
||||||
@@ -630,13 +625,9 @@ bool wxAnimationCtrlBase::Play(bool looped)
|
|||||||
wxSize wxAnimationCtrlBase::DoGetBestSize() const
|
wxSize wxAnimationCtrlBase::DoGetBestSize() const
|
||||||
{
|
{
|
||||||
if (m_animationPlayer.HasAnimation() && (GetWindowStyle() & wxAN_FIT_ANIMATION))
|
if (m_animationPlayer.HasAnimation() && (GetWindowStyle() & wxAN_FIT_ANIMATION))
|
||||||
{
|
|
||||||
return m_animationPlayer.GetLogicalScreenSize();
|
return m_animationPlayer.GetLogicalScreenSize();
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
return GetSize();
|
return GetSize();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxAnimationCtrlBase::FitToAnimation()
|
void wxAnimationCtrlBase::FitToAnimation()
|
||||||
@@ -653,9 +644,7 @@ void wxAnimationCtrlBase::OnPaint(wxPaintEvent& WXUNUSED(event))
|
|||||||
wxPaintDC dc(this);
|
wxPaintDC dc(this);
|
||||||
|
|
||||||
if (GetPlayer().IsPlaying())
|
if (GetPlayer().IsPlaying())
|
||||||
{
|
|
||||||
GetPlayer().Draw(dc);
|
GetPlayer().Draw(dc);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -669,3 +658,4 @@ wxAnimationBase* wxGIFAnimationCtrl::DoCreateAnimation(const wxString& WXUNUSED(
|
|||||||
{
|
{
|
||||||
return new wxGIFAnimation;
|
return new wxGIFAnimation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user