- {
- if (coords.GetCount() >= 6)
- {
- int intersects = 0;
- int wherex = x;
- int wherey = y;
- int totalv = coords.GetCount() / 2;
- int totalc = totalv * 2;
- int xval = coords[totalc - 2];
- int yval = coords[totalc - 1];
- int end = totalc;
- int pointer = 1;
-
- if ((yval >= wherey) != (coords[pointer] >= wherey))
- {
- if ((xval >= wherex) == (coords[0] >= wherex))
- {
- intersects += (xval >= wherex) ? 1 : 0;
- }
- else
- {
- intersects += ((xval - (yval - wherey) *
- (coords[0] - xval) /
- (coords[pointer] - yval)) >= wherex) ? 1 : 0;
- }
- }
-
- while (pointer < end)
- {
- yval = coords[pointer];
- pointer += 2;
- if (yval >= wherey)
- {
- while ((pointer < end) && (coords[pointer] >= wherey))
- {
- pointer += 2;
- }
- if (pointer >= end)
- {
- break;
- }
- if ((coords[pointer - 3] >= wherex) ==
- (coords[pointer - 1] >= wherex)) {
- intersects += (coords[pointer - 3] >= wherex) ? 1 : 0;
- }
- else
- {
- intersects +=
- ((coords[pointer - 3] - (coords[pointer - 2] - wherey) *
- (coords[pointer - 1] - coords[pointer - 3]) /
- (coords[pointer] - coords[pointer - 2])) >= wherex) ? 1 : 0;
- }
- }
- else
- {
- while ((pointer < end) && (coords[pointer] < wherey))
- {
- pointer += 2;
- }
- if (pointer >= end)
- {
- break;
- }
- if ((coords[pointer - 3] >= wherex) ==
- (coords[pointer - 1] >= wherex))
- {
- intersects += (coords[pointer - 3] >= wherex) ? 1 : 0;
- }
- else
- {
- intersects +=
- ((coords[pointer - 3] - (coords[pointer - 2] - wherey) *
- (coords[pointer - 1] - coords[pointer - 3]) /
- (coords[pointer] - coords[pointer - 2])) >= wherex) ? 1 : 0;
- }
- }
- }
- if ((intersects & 1) != 0)
- {
- return m_Link;
- }
- }
+ if (coords.GetCount() >= 6)
+ {
+ int intersects = 0;
+ int wherex = x;
+ int wherey = y;
+ int totalv = coords.GetCount() / 2;
+ int totalc = totalv * 2;
+ int xval = coords[totalc - 2];
+ int yval = coords[totalc - 1];
+ int end = totalc;
+ int pointer = 1;
+
+ if ((yval >= wherey) != (coords[pointer] >= wherey))
+ {
+ if ((xval >= wherex) == (coords[0] >= wherex))
+ {
+ intersects += (xval >= wherex) ? 1 : 0;
+ }
+ else
+ {
+ intersects += ((xval - (yval - wherey) *
+ (coords[0] - xval) /
+ (coords[pointer] - yval)) >= wherex) ? 1 : 0;
+ }
+ }
+
+ while (pointer < end)
+ {
+ yval = coords[pointer];
+ pointer += 2;
+ if (yval >= wherey)
+ {
+ while ((pointer < end) && (coords[pointer] >= wherey))
+ {
+ pointer += 2;
+ }
+ if (pointer >= end)
+ {
+ break;
+ }
+ if ((coords[pointer - 3] >= wherex) ==
+ (coords[pointer - 1] >= wherex)) {
+ intersects += (coords[pointer - 3] >= wherex) ? 1 : 0;
+ }
+ else
+ {
+ intersects +=
+ ((coords[pointer - 3] - (coords[pointer - 2] - wherey) *
+ (coords[pointer - 1] - coords[pointer - 3]) /
+ (coords[pointer] - coords[pointer - 2])) >= wherex) ? 1 : 0;
+ }
+ }
+ else
+ {
+ while ((pointer < end) && (coords[pointer] < wherey))
+ {
+ pointer += 2;
+ }
+ if (pointer >= end)
+ {
+ break;
+ }
+ if ((coords[pointer - 3] >= wherex) ==
+ (coords[pointer - 1] >= wherex))
+ {
+ intersects += (coords[pointer - 3] >= wherex) ? 1 : 0;
+ }
+ else
+ {
+ intersects +=
+ ((coords[pointer - 3] - (coords[pointer - 2] - wherey) *
+ (coords[pointer - 1] - coords[pointer - 3]) /
+ (coords[pointer] - coords[pointer - 2])) >= wherex) ? 1 : 0;
+ }
+ }
+ }
+ if ((intersects & 1) != 0)
+ {
+ return m_Link;
+ }
- wxHtmlImageCell(wxWindow *window,
- wxFSFile *input, int w = wxDefaultCoord, int h = wxDefaultCoord,
+ wxHtmlImageCell(wxHtmlWindowInterface *windowIface,
+ wxFSFile *input,
+ int w = wxDefaultCoord, bool wpercent = false,
+ int h = wxDefaultCoord, bool hpresent = false,
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 SetImage(const wxImage& img);
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 SetImage(const wxImage& img);
-wxHtmlImageCell::wxHtmlImageCell(wxWindow *window, wxFSFile *input,
- int w, int h, double scale, int align,
+wxHtmlImageCell::wxHtmlImageCell(wxHtmlWindowInterface *windowIface,
+ wxFSFile *input,
+ int w, bool wpercent, int h, bool hpresent, double scale, int align,
- 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 ( (int)m_gifDecoder->GetWidth() != m_Width ||
- (int)m_gifDecoder->GetHeight() != m_Height ||
- m_gifDecoder->GetLeft() != 0 || m_gifDecoder->GetTop() != 0 )
+#if !defined(__WXMSW__) || wxUSE_WXDIB
+ if ( m_gifDecoder->GetFrameSize(m_nCurrFrame) != wxSize(m_Width, m_Height) ||
+ m_gifDecoder->GetFramePosition(m_nCurrFrame) != wxPoint(0, 0) )
+ if (m_bmpWpercent)
+ {
+
+ m_Width = w*m_bmpW/100;
+
+ if (!m_bmpHpresent && m_bitmap != NULL)
+ m_Height = m_bitmap->GetHeight()*m_Width/m_bitmap->GetWidth();
+ else
+ m_Height = static_cast<int>(m_scale*m_bmpH);
+ } else
+ {
+ m_Width = static_cast<int>(m_scale*m_bmpW);
+ m_Height = static_cast<int>(m_scale*m_bmpH);
+ }
+
+ switch (m_align)
+ {
+ case wxHTML_ALIGN_TOP :
+ m_Descent = m_Height;
+ break;
+ case wxHTML_ALIGN_CENTER :
+ m_Descent = m_Height / 2;
+ break;
+ case wxHTML_ALIGN_BOTTOM :
+ default :
+ m_Descent = 0;
+ break;
+ }
+
- if (m_bmpW != m_bitmap->GetWidth())
- imageScaleX = (double) m_bmpW / (double) m_bitmap->GetWidth();
- if (m_bmpH != m_bitmap->GetHeight())
- imageScaleY = (double) m_bmpH / (double) m_bitmap->GetHeight();
+ if (m_Width != m_bitmap->GetWidth())
+ imageScaleX = (double) m_Width / (double) m_bitmap->GetWidth();
+ if (m_Height != m_bitmap->GetHeight())
+ imageScaleY = (double) m_Height / (double) m_bitmap->GetHeight();
- if (tag.HasParam(wxT("WIDTH")))
- tag.GetParamAsInt(wxT("WIDTH"), &w);
- if (tag.HasParam(wxT("HEIGHT")))
- tag.GetParamAsInt(wxT("HEIGHT"), &h);
+ if (tag.GetParamAsIntOrPercent(wxT("WIDTH"), &w, wpercent))
+ {
+ if (wpercent)
+ {
+ if (w < 0)
+ w = 0;
+ else if (w > 100)
+ w = 100;
+ }
+ }
+
+ if (tag.GetParamAsInt(wxT("HEIGHT"), &h))
+ {
+ hpresent = true;
+ }
+
alstr.MakeUpper(); // for the case alignment was in ".."
if (alstr == wxT("TEXTTOP"))
al = wxHTML_ALIGN_TOP;
else if ((alstr == wxT("CENTER")) || (alstr == wxT("ABSCENTER")))
al = wxHTML_ALIGN_CENTER;
}
alstr.MakeUpper(); // for the case alignment was in ".."
if (alstr == wxT("TEXTTOP"))
al = wxHTML_ALIGN_TOP;
else if ((alstr == wxT("CENTER")) || (alstr == wxT("ABSCENTER")))
al = wxHTML_ALIGN_CENTER;
}
- 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));
- }
- if (cel != NULL) m_WParser->GetContainer()->InsertCell( cel );
+ wxString href;
+ if (cel != NULL && tag.GetParamAsString(wxT("HREF"), &href))
+ cel->SetLink(wxHtmlLinkInfo(href, tag.GetParam(wxT("TARGET"))));
+ if (cel != NULL)
+ m_WParser->GetContainer()->InsertCell( cel );