]> git.saurik.com Git - wxWidgets.git/blobdiff - src/html/m_image.cpp
Fixed bug in border style translation
[wxWidgets.git] / src / html / m_image.cpp
index 59881ad023c4c55b75c7343be025faf69c724fc6..85f9fb770fb9480bc742ee56d7c000721a28ea1b 100644 (file)
 
 #if wxUSE_HTML && wxUSE_STREAMS
 
 
 #if wxUSE_HTML && wxUSE_STREAMS
 
-#ifndef WXPRECOMP
+#ifndef WX_PRECOMP
+    #include "wx/dynarray.h"
     #include "wx/dc.h"
     #include "wx/scrolwin.h"
     #include "wx/timer.h"
     #include "wx/dcmemory.h"
     #include "wx/dc.h"
     #include "wx/scrolwin.h"
     #include "wx/timer.h"
     #include "wx/dcmemory.h"
+    #include "wx/log.h"
+    #include "wx/math.h"
+    #include "wx/image.h"
 #endif
 
 #include "wx/html/forcelnk.h"
 #include "wx/html/m_templ.h"
 #include "wx/html/htmlwin.h"
 
 #endif
 
 #include "wx/html/forcelnk.h"
 #include "wx/html/m_templ.h"
 #include "wx/html/htmlwin.h"
 
-#include "wx/image.h"
 #include "wx/gifdecod.h"
 #include "wx/gifdecod.h"
-#include "wx/dynarray.h"
-#include "wx/log.h"
 #include "wx/artprov.h"
 #include "wx/artprov.h"
-#include "wx/math.h"
 
 #include <float.h>
 
 
 #include <float.h>
 
@@ -289,7 +289,7 @@ public:
                     wxFSFile *input, int w = wxDefaultCoord, int h = wxDefaultCoord,
                     double scale = 1.0, int align = wxHTML_ALIGN_BOTTOM,
                     const wxString& mapname = wxEmptyString);
                     wxFSFile *input, int w = wxDefaultCoord, int h = wxDefaultCoord,
                     double scale = 1.0, int align = wxHTML_ALIGN_BOTTOM,
                     const wxString& mapname = wxEmptyString);
-    ~wxHtmlImageCell();
+    virtual ~wxHtmlImageCell();
     void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2,
               wxHtmlRenderingInfo& info);
     virtual wxHtmlLinkInfo *GetLink(int x = 0, int y = 0) const;
     void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2,
               wxHtmlRenderingInfo& info);
     virtual wxHtmlLinkInfo *GetLink(int x = 0, int y = 0) const;
@@ -309,6 +309,7 @@ private:
     wxGIFDecoder       *m_gifDecoder;
     wxTimer            *m_gifTimer;
     int                 m_physX, m_physY;
     wxGIFDecoder       *m_gifDecoder;
     wxTimer            *m_gifTimer;
     int                 m_physX, m_physY;
+    size_t              m_nCurrFrame;
 #endif
     double              m_scale;
     wxHtmlImageMapCell *m_imageMap;
 #endif
     double              m_scale;
     wxHtmlImageMapCell *m_imageMap;
@@ -358,6 +359,7 @@ wxHtmlImageCell::wxHtmlImageCell(wxHtmlWindowInterface *windowIface,
     m_gifDecoder = NULL;
     m_gifTimer = NULL;
     m_physX = m_physY = wxDefaultCoord;
     m_gifDecoder = NULL;
     m_gifTimer = NULL;
     m_physX = m_physY = wxDefaultCoord;
+    m_nCurrFrame = 0;
 #endif
 
     if ( m_bmpW && m_bmpH )
 #endif
 
     if ( m_bmpW && m_bmpH )
@@ -374,11 +376,11 @@ wxHtmlImageCell::wxHtmlImageCell(wxHtmlWindowInterface *windowIface,
                      (input->GetLocation().Matches(wxT("*.gif")) ||
                       input->GetLocation().Matches(wxT("*.GIF"))) )
                 {
                      (input->GetLocation().Matches(wxT("*.gif")) ||
                       input->GetLocation().Matches(wxT("*.GIF"))) )
                 {
-                    m_gifDecoder = new wxGIFDecoder(s, true);
-                    if ( m_gifDecoder->ReadGIF() == wxGIF_OK )
+                    m_gifDecoder = new wxGIFDecoder();
+                    if ( m_gifDecoder->LoadGIF(*s) == wxGIF_OK )
                     {
                         wxImage img;
                     {
                         wxImage img;
-                        if ( m_gifDecoder->ConvertToImage(&img) )
+                        if ( m_gifDecoder->ConvertToImage(0, &img) )
                             SetImage(img);
 
                         readImg = false;
                             SetImage(img);
 
                         readImg = false;
@@ -386,7 +388,7 @@ wxHtmlImageCell::wxHtmlImageCell(wxHtmlWindowInterface *windowIface,
                         if ( m_gifDecoder->IsAnimation() )
                         {
                             m_gifTimer = new wxGIFTimer(this);
                         if ( m_gifDecoder->IsAnimation() )
                         {
                             m_gifTimer = new wxGIFTimer(this);
-                            m_gifTimer->Start(m_gifDecoder->GetDelay(), true);
+                            m_gifTimer->Start(m_gifDecoder->GetDelay(0), true);
                         }
                         else
                         {
                         }
                         else
                         {
@@ -481,7 +483,10 @@ void wxHtmlImageCell::AdvanceAnimation(wxTimer *timer)
 {
     wxImage img;
 
 {
     wxImage img;
 
-    m_gifDecoder->GoNextFrame(true);
+    // advance current frame
+    m_nCurrFrame++;
+    if (m_nCurrFrame == m_gifDecoder->GetFrameCount())
+        m_nCurrFrame = 0;
 
     if ( m_physX == wxDefaultCoord )
     {
 
     if ( m_physX == wxDefaultCoord )
     {
@@ -499,17 +504,16 @@ void wxHtmlImageCell::AdvanceAnimation(wxTimer *timer)
     wxRect rect(pos, wxSize(m_Width, m_Height));
 
     if ( win->GetClientRect().Intersects(rect) &&
     wxRect rect(pos, wxSize(m_Width, m_Height));
 
     if ( win->GetClientRect().Intersects(rect) &&
-         m_gifDecoder->ConvertToImage(&img) )
+         m_gifDecoder->ConvertToImage(m_nCurrFrame, &img) )
     {
 #if !defined(__WXMSW__) || wxUSE_WXDIB
     {
 #if !defined(__WXMSW__) || wxUSE_WXDIB
-        if ( (int)m_gifDecoder->GetWidth() != m_Width ||
-             (int)m_gifDecoder->GetHeight() != m_Height ||
-             m_gifDecoder->GetLeft() != 0 || m_gifDecoder->GetTop() != 0 )
+        if ( m_gifDecoder->GetFrameSize(m_nCurrFrame) != wxSize(m_Width, m_Height) ||
+             m_gifDecoder->GetFramePosition(m_nCurrFrame) != wxPoint(0, 0) )
         {
             wxBitmap bmp(img);
             wxMemoryDC dc;
             dc.SelectObject(*m_bitmap);
         {
             wxBitmap bmp(img);
             wxMemoryDC dc;
             dc.SelectObject(*m_bitmap);
-            dc.DrawBitmap(bmp, m_gifDecoder->GetLeft(), m_gifDecoder->GetTop(),
+            dc.DrawBitmap(bmp, m_gifDecoder->GetFramePosition(m_nCurrFrame),
                           true /* use mask */);
         }
         else
                           true /* use mask */);
         }
         else
@@ -518,7 +522,7 @@ void wxHtmlImageCell::AdvanceAnimation(wxTimer *timer)
         win->Refresh(img.HasMask(), &rect);
     }
 
         win->Refresh(img.HasMask(), &rect);
     }
 
-    timer->Start(m_gifDecoder->GetDelay(), true);
+    timer->Start(m_gifDecoder->GetDelay(m_nCurrFrame), true);
 }
 
 void wxHtmlImageCell::Layout(int w)
 }
 
 void wxHtmlImageCell::Layout(int w)