+wxHtmlCell::~wxHtmlCell()
+{
+ delete m_Link;
+}
+
+
+void wxHtmlCell::OnMouseClick(wxWindow *parent, int x, int y,
+ const wxMouseEvent& event)
+{
+ wxHtmlLinkInfo *lnk = GetLink(x, y);
+ if (lnk != NULL)
+ {
+ wxHtmlLinkInfo lnk2(*lnk);
+ lnk2.SetEvent(&event);
+ lnk2.SetHtmlCell(this);
+
+ // note : this cast is legal because parent is *always* wxHtmlWindow
+ wxStaticCast(parent, wxHtmlWindow)->OnLinkClicked(lnk2);
+ }
+}
+
+
+wxCursor wxHtmlCell::GetCursor() const
+{
+ if ( GetLink() )
+ {
+ if ( !gs_cursorLink )
+ gs_cursorLink = new wxCursor(wxCURSOR_HAND);
+ return *gs_cursorLink;
+ }
+ else
+ return *wxSTANDARD_CURSOR;
+}
+
+
+bool wxHtmlCell::AdjustPagebreak(int *pagebreak, int* WXUNUSED(known_pagebreaks), int WXUNUSED(number_of_pages)) const
+{
+ if ((!m_CanLiveOnPagebreak) &&
+ m_PosY < *pagebreak && m_PosY + m_Height > *pagebreak)
+ {
+ *pagebreak = m_PosY;
+ return true;
+ }
+
+ return false;
+}
+
+
+
+void wxHtmlCell::SetLink(const wxHtmlLinkInfo& link)
+{
+ if (m_Link) delete m_Link;
+ m_Link = NULL;
+ if (link.GetHref() != wxEmptyString)
+ m_Link = new wxHtmlLinkInfo(link);
+}
+
+
+void wxHtmlCell::Layout(int WXUNUSED(w))
+{
+ SetPos(0, 0);
+}
+
+
+
+const wxHtmlCell* wxHtmlCell::Find(int WXUNUSED(condition), const void* WXUNUSED(param)) const
+{
+ return NULL;
+}
+
+
+wxHtmlCell *wxHtmlCell::FindCellByPos(wxCoord x, wxCoord y,
+ unsigned flags) const
+{
+ if ( x >= 0 && x < m_Width && y >= 0 && y < m_Height )
+ {
+ return wxConstCast(this, wxHtmlCell);
+ }
+ else
+ {
+ if ((flags & wxHTML_FIND_NEAREST_AFTER) &&
+ (y < 0 || (y < 0+m_Height && x < 0+m_Width)))
+ return wxConstCast(this, wxHtmlCell);
+ else if ((flags & wxHTML_FIND_NEAREST_BEFORE) &&
+ (y >= 0+m_Height || (y >= 0 && x >= 0)))
+ return wxConstCast(this, wxHtmlCell);
+ else
+ return NULL;
+ }
+}
+
+
+wxPoint wxHtmlCell::GetAbsPos() const
+{
+ wxPoint p(m_PosX, m_PosY);
+ for (wxHtmlCell *parent = m_Parent; parent; parent = parent->m_Parent)
+ {
+ p.x += parent->m_PosX;
+ p.y += parent->m_PosY;
+ }
+ return p;
+}
+
+unsigned wxHtmlCell::GetDepth() const
+{
+ unsigned d = 0;
+ for (wxHtmlCell *p = m_Parent; p; p = p->m_Parent)
+ d++;
+ return d;
+}
+
+bool wxHtmlCell::IsBefore(wxHtmlCell *cell) const
+{
+ const wxHtmlCell *c1 = this;
+ const wxHtmlCell *c2 = cell;
+ unsigned d1 = GetDepth();
+ unsigned d2 = cell->GetDepth();
+
+ if ( d1 > d2 )
+ for (; d1 != d2; d1-- )
+ c1 = c1->m_Parent;
+ else if ( d1 < d2 )
+ for (; d1 != d2; d2-- )
+ c2 = c2->m_Parent;
+
+ if ( cell == this )
+ return true;
+
+ while ( c1 && c2 )
+ {
+ if ( c1->m_Parent == c2->m_Parent )
+ {
+ while ( c1 )
+ {
+ if ( c1 == c2 )
+ return true;
+ c1 = c1->GetNext();
+ }
+ return false;
+ }
+ else
+ {
+ c1 = c1->m_Parent;
+ c2 = c2->m_Parent;
+ }
+ }
+
+ wxFAIL_MSG(_T("Cells are in different trees"));
+ return false;
+}