/////////////////////////////////////////////////////////////////////////////
-// Name: m_image.cpp
+// Name: src/html/m_image.cpp
// Purpose: wxHtml module for displaying images
// Author: Vaclav Slavik
// RCS-ID: $Id$
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation
-#endif
-
#include "wx/wxprec.h"
-#include "wx/defs.h"
-#if wxUSE_HTML && wxUSE_STREAMS
-
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
+#if wxUSE_HTML && wxUSE_STREAMS
+
#ifndef WXPRECOMP
+ #include "wx/dynarray.h"
#include "wx/dc.h"
#include "wx/scrolwin.h"
#include "wx/timer.h"
#include "wx/dcmemory.h"
+ #include "wx/log.h"
#endif
#include "wx/html/forcelnk.h"
#include "wx/image.h"
#include "wx/gifdecod.h"
-#include "wx/dynarray.h"
-#include "wx/log.h"
#include "wx/artprov.h"
#include "wx/math.h"
WX_DECLARE_OBJARRAY(int, CoordArray);
#include "wx/arrimpl.cpp" // this is a magic incantation which must be done!
-WX_DEFINE_OBJARRAY(CoordArray);
+WX_DEFINE_OBJARRAY(CoordArray)
// ---------------------------------------------------------------------------
class wxHtmlImageCell : public wxHtmlCell
{
public:
- wxHtmlImageCell(wxWindow *window,
+ wxHtmlImageCell(wxHtmlWindowInterface *windowIface,
wxFSFile *input, int w = wxDefaultCoord, int h = wxDefaultCoord,
double scale = 1.0, int align = wxHTML_ALIGN_BOTTOM,
const wxString& mapname = wxEmptyString);
wxBitmap *m_bitmap;
int m_bmpW, m_bmpH;
bool m_showFrame:1;
- wxScrolledWindow *m_window;
+ wxHtmlWindowInterface *m_windowIface;
#if wxUSE_GIF && wxUSE_TIMER
wxGIFDecoder *m_gifDecoder;
wxTimer *m_gifTimer;
//----------------------------------------------------------------------------
-wxHtmlImageCell::wxHtmlImageCell(wxWindow *window, wxFSFile *input,
+wxHtmlImageCell::wxHtmlImageCell(wxHtmlWindowInterface *windowIface,
+ wxFSFile *input,
int w, int h, double scale, int align,
const wxString& mapname) : wxHtmlCell()
{
- m_window = window ? wxStaticCast(window, wxScrolledWindow) : NULL;
+ m_windowIface = windowIface;
m_scale = scale;
m_showFrame = false;
m_bitmap = NULL;
if ( s )
{
- bool readImg = true;
-
#if wxUSE_GIF && wxUSE_TIMER
- if ( (input->GetLocation().Matches(wxT("*.gif")) ||
- input->GetLocation().Matches(wxT("*.GIF"))) && m_window )
+ bool readImg = true;
+ if ( m_windowIface &&
+ (input->GetLocation().Matches(wxT("*.gif")) ||
+ input->GetLocation().Matches(wxT("*.GIF"))) )
{
m_gifDecoder = new wxGIFDecoder(s, true);
if ( m_gifDecoder->ReadGIF() == wxGIF_OK )
void wxHtmlImageCell::SetImage(const wxImage& img)
{
+#if !defined(__WXMSW__) || wxUSE_WXDIB
if ( img.Ok() )
{
delete m_bitmap;
*/
m_bitmap = new wxBitmap(img);
}
+#endif
}
#if wxUSE_GIF && wxUSE_TIMER
}
}
- int x, y;
- m_window->CalcScrolledPosition(m_physX, m_physY, &x, &y);
- wxRect rect(x, y, m_Width, m_Height);
+ wxWindow *win = m_windowIface->GetHTMLWindow();
+ wxPoint pos =
+ m_windowIface->HTMLCoordsToWindow(this, wxPoint(m_physX, m_physY));
+ wxRect rect(pos, wxSize(m_Width, m_Height));
- if ( m_window->GetClientRect().Intersects(rect) &&
+ if ( win->GetClientRect().Intersects(rect) &&
m_gifDecoder->ConvertToImage(&img) )
{
+#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 )
true /* use mask */);
}
else
+#endif
SetImage(img);
- m_window->Refresh(img.HasMask(), &rect);
+ win->Refresh(img.HasMask(), &rect);
}
timer->Start(m_gifDecoder->GetDelay(), true);
}
}
wxHtmlImageCell *cel = new wxHtmlImageCell(
- m_WParser->GetWindow(),
+ m_WParser->GetWindowInterface(),
str, w, h,
m_WParser->GetPixelScale(),
al, mn);
- cel->SetLink(m_WParser->GetLink());
+ m_WParser->ApplyStateToCell(cel);
cel->SetId(tag.GetParam(wxT("id"))); // may be empty
m_WParser->GetContainer()->InsertCell(cel);
if (str)
}
if (cel != NULL && tag.HasParam(wxT("HREF")))
{
- wxString tmp = tag.GetParam(wxT("HREF"));
- wxString target = wxEmptyString;
- if (tag.HasParam(wxT("TARGET"))) target = tag.GetParam(wxT("TARGET"));
- cel->SetLink( wxHtmlLinkInfo(tmp, target));
+ wxString target;
+ if (tag.HasParam(wxT("TARGET")))
+ target = tag.GetParam(wxT("TARGET"));
+ cel->SetLink(wxHtmlLinkInfo(tag.GetParam(wxT("HREF")), target));
}
- if (cel != NULL) m_WParser->GetContainer()->InsertCell( cel );
+ if (cel != NULL)
+ m_WParser->GetContainer()->InsertCell( cel );
}
}