+//-----------------------------------------------------------------------------
+// wxHtmlWindowMouseHelper
+//-----------------------------------------------------------------------------
+
+wxHtmlWindowMouseHelper::wxHtmlWindowMouseHelper(wxHtmlWindowInterface *iface)
+ : m_tmpMouseMoved(false),
+ m_tmpLastLink(NULL),
+ m_tmpLastCell(NULL),
+ m_interface(iface)
+{
+}
+
+void wxHtmlWindowMouseHelper::HandleMouseMoved()
+{
+ m_tmpMouseMoved = true;
+}
+
+bool wxHtmlWindowMouseHelper::HandleMouseClick(wxHtmlCell *rootCell,
+ const wxPoint& pos,
+ const wxMouseEvent& event)
+{
+ if (!rootCell)
+ return false;
+
+ wxHtmlCell *cell = rootCell->FindCellByPos(pos.x, pos.y);
+ // this check is needed because FindCellByPos returns terminal cell and
+ // containers may have empty borders -- in this case NULL will be
+ // returned
+ if (!cell)
+ return false;
+
+ // adjust the coordinates to be relative to this cell:
+ wxPoint relpos = pos - cell->GetAbsPos(rootCell);
+
+ return OnCellClicked(cell, relpos.x, relpos.y, event);
+}
+
+void wxHtmlWindowMouseHelper::HandleIdle(wxHtmlCell *rootCell,
+ const wxPoint& pos)
+{
+ wxHtmlCell *cell = rootCell ? rootCell->FindCellByPos(pos.x, pos.y) : NULL;
+
+ if (cell != m_tmpLastCell)
+ {
+ wxHtmlLinkInfo *lnk = NULL;
+ if (cell)
+ {
+ // adjust the coordinates to be relative to this cell:
+ wxPoint relpos = pos - cell->GetAbsPos(rootCell);
+ lnk = cell->GetLink(relpos.x, relpos.y);
+ }
+
+ wxCursor cur;
+ if (cell)
+ cur = cell->GetMouseCursor(m_interface);
+ else
+ cur = m_interface->GetHTMLCursor(
+ wxHtmlWindowInterface::HTMLCursor_Default);
+
+ m_interface->GetHTMLWindow()->SetCursor(cur);
+
+ if (lnk != m_tmpLastLink)
+ {
+ if (lnk)
+ m_interface->SetHTMLStatusText(lnk->GetHref());
+ else
+ m_interface->SetHTMLStatusText(wxEmptyString);
+
+ m_tmpLastLink = lnk;
+ }
+
+ m_tmpLastCell = cell;
+ }
+ else // mouse moved but stayed in the same cell
+ {
+ if ( cell )
+ {
+ OnCellMouseHover(cell, pos.x, pos.y);
+ }
+ }
+
+ m_tmpMouseMoved = false;
+}
+
+bool wxHtmlWindowMouseHelper::OnCellClicked(wxHtmlCell *cell,
+ wxCoord x, wxCoord y,
+ const wxMouseEvent& event)
+{
+ wxHtmlCellEvent ev(wxEVT_COMMAND_HTML_CELL_CLICKED,
+ m_interface->GetHTMLWindow()->GetId(),
+ cell, wxPoint(x,y), event);
+
+ if (!m_interface->GetHTMLWindow()->GetEventHandler()->ProcessEvent(ev))
+ {
+ // if the event wasn't handled, do the default processing here:
+
+ wxASSERT_MSG( cell, wxT("can't be called with NULL cell") );
+
+ cell->ProcessMouseClick(m_interface, ev.GetPoint(), ev.GetMouseEvent());
+ }
+
+ // true if a link was clicked, false otherwise
+ return ev.GetLinkClicked();
+}
+
+void wxHtmlWindowMouseHelper::OnCellMouseHover(wxHtmlCell * cell,
+ wxCoord x,
+ wxCoord y)
+{
+ wxHtmlCellEvent ev(wxEVT_COMMAND_HTML_CELL_HOVER,
+ m_interface->GetHTMLWindow()->GetId(),
+ cell, wxPoint(x,y), wxMouseEvent());
+ m_interface->GetHTMLWindow()->GetEventHandler()->ProcessEvent(ev);
+}
+
+
+
+