- Many enhancements to wxRichTextCtrl including URL support,
formatting and symbol dialogs, print/preview, and better list
formatting.
-- Support for loading TGA files added (Seth Jackson)
+- Support for loading TGA files added (Seth Jackson).
+- Added events API to wxHtmlWindow (Francesco Montorsi).
Unix Ports:
\helpref{wxSimpleHtmlListBox}{wxsimplehtmllistbox}
+\wxheading{Event handling}
+
+To process input from a wxHtmlListBox, use these event handler macros to direct input to member
+functions that take a \helpref{wxHtmlCellEvent}{wxhtmlcellevent} argument or a \helpref{wxHtmlLinkEvent}{wxhtmllinkevent}.
+
+\twocolwidtha{7cm}
+\begin{twocollist}\itemsep=0pt
+\twocolitem{{\bf EVT\_HTMLWINDOW\_CELL\_CLICKED(id, func)}}{A \helpref{wxHtmlCell}{wxhtmlcell} was clicked.}
+\twocolitem{{\bf EVT\_HTMLWINDOW\_CELL\_HOVER(id, func)}}{The mouse passed over a {\helpref{wxHtmlCell}{wxhtmlcell}.}
+\twocolitem{{\bf EVT\_HTMLWINDOW\_LINK\_CLICKED(id, func)}}{A \helpref{wxHtmlCell}{wxhtmlcell} which contains an hyperlink was clicked.}
+\end{twocollist}
+
+
\latexignore{\rtfignore{\wxheading{Members}}}
\func{virtual void}{OnLinkClicked}{\param{size\_t }{n}, \param{const wxHtmlLinkInfo\& }{link}}
Called when the user clicks on hypertext link. Does nothing by default.
+Overloading this method is deprecated; intercept the event instead.
\wxheading{Parameters}
\wxheading{Event handling}
-A wxSimpleHtmlListBox emits the same events used by \helpref{wxListBox}{wxlistbox}:
+A wxSimpleHtmlListBox emits the same events used by \helpref{wxListBox}{wxlistbox} and by
+\helpref{wxHtmlListBox}{wxhtmllistbox}.
+
+The event handlers for the following events take a \helpref{wxCommandEvent}{wxcommandevent}:
\twocolwidtha{7cm}
\begin{twocollist}\itemsep=0pt
when the listbox is double-clicked.}
\end{twocollist}
+The event handlers for the following events take a \helpref{wxHtmlCellEvent}{wxhtmlcellevent}
+or a \helpref{wxHtmlLinkEvent}{wxhtmllinkevent}:
+
+\twocolwidtha{7cm}
+\begin{twocollist}\itemsep=0pt
+\twocolitem{{\bf EVT\_HTMLWINDOW\_CELL\_CLICKED(id, func)}}{A \helpref{wxHtmlCell}{wxhtmlcell} was clicked.}
+\twocolitem{{\bf EVT\_HTMLWINDOW\_CELL\_HOVER(id, func)}}{The mouse passed over a {\helpref{wxHtmlCell}{wxhtmlcell}.}
+\twocolitem{{\bf EVT\_HTMLWINDOW\_LINK\_CLICKED(id, func)}}{A \helpref{wxHtmlCell}{wxhtmlcell} which contains an hyperlink was clicked.}
+\end{twocollist}
+
\latexignore{\rtfignore{\wxheading{Members}}}
text.}
\end{twocollist}
+
+\wxheading{Event handling}
+
+To process input from a wxHtmlWindow, use these event handler macros to direct input to member
+functions that take a \helpref{wxHtmlCellEvent}{wxhtmlcellevent} argument or a \helpref{wxHtmlLinkEvent}{wxhtmllinkevent}.
+
+\twocolwidtha{7cm}
+\begin{twocollist}\itemsep=0pt
+\twocolitem{{\bf EVT\_HTMLWINDOW\_CELL\_CLICKED(id, func)}}{A \helpref{wxHtmlCell}{wxhtmlcell} was clicked.}
+\twocolitem{{\bf EVT\_HTMLWINDOW\_CELL\_HOVER(id, func)}}{The mouse passed over a {\helpref{wxHtmlCell}{wxhtmlcell}.}
+\twocolitem{{\bf EVT\_HTMLWINDOW\_LINK\_CLICKED(id, func)}}{A \helpref{wxHtmlCell}{wxhtmlcell} which contains an hyperlink was clicked.}
+\end{twocollist}
+
+
+\wxheading{See also}
+
+\helpref{wxHtmlLinkEvent}{wxhtmllinkevent}, \helpref{wxHtmlCellEvent}{wxhtmlcellevent}
+
+
+
\membersection{wxHtmlWindow::wxHtmlWindow}\label{wxhtmlwindowwxhtmlwindow}
\func{}{wxHtmlWindow}{\void}
\func{virtual bool}{OnCellClicked}{\param{wxHtmlCell }{*cell}, \param{wxCoord }{x}, \param{wxCoord }{y}, \param{const wxMouseEvent\& }{event}}
This method is called when a mouse button is clicked inside wxHtmlWindow.
-The default behaviour is to call
-\helpref{OnLinkClicked}{wxhtmlwindowonlinkclicked} if the cell contains a
+
+The default behaviour is to emit a \helpref{wxHtmlCellEvent}{wxhtmlcellevent}
+and, if the event was not processed or skipped, call
+\helpref{OnLinkClicked}{wxhtmlwindowonlinkclicked} if the cell contains an
hypertext link.
+Overloading this method is deprecated; intercept the event instead.
+
+
\wxheading{Parameters}
\docparam{cell}{The cell inside which the mouse was clicked, always a simple
\func{virtual void}{OnCellMouseHover}{\param{wxHtmlCell }{*cell}, \param{wxCoord }{x}, \param{wxCoord }{y}}
This method is called when a mouse moves over an HTML cell.
+Default behaviour is to emit a \helpref{wxHtmlCellEvent}{wxhtmlcellevent}.
+Overloading this method is deprecated; intercept the event instead.
\wxheading{Parameters}
\func{virtual void}{OnLinkClicked}{\param{const wxHtmlLinkInfo\& }{link}}
-Called when user clicks on hypertext link. Default behaviour is to call
-\helpref{LoadPage}{wxhtmlwindowloadpage} and do nothing else.
+Called when user clicks on hypertext link. Default behaviour is to emit a
+\helpref{wxHtmlLinkEvent}{wxhtmllinkevent} and, if the event was not processed
+or skipped, call \helpref{LoadPage}{wxhtmlwindowloadpage} and do nothing else.
+Overloading this method is deprecated; intercept the event instead.
Also see \helpref{wxHtmlLinkInfo}{wxhtmllinkinfo}.
\docparam{path}{Optional path in config tree. If not given, the current path is used.}
+
+
+
+
+
+
+\section{\class{wxHtmlLinkEvent}}\label{wxhtmllinkevent}
+
+This event class is used for the events generated by \helpref{wxHtmlWindow}{wxhtmlwindow}.
+
+\wxheading{Derived from}
+
+\helpref{wxCommandEvent}{wxcommandevent}\\
+\helpref{wxEvent}{wxevent}\\
+\helpref{wxObject}{wxobject}
+
+\wxheading{Include files}
+
+<wx/html/htmlwin.h>
+
+\wxheading{Event handling}
+
+To process input from a wxHtmlLinkEvent, use one of these event handler macros to
+direct input to member function that take a \helpref{wxHtmlLinkEvent}{wxhtmllinkevent} argument:
+
+\twocolwidtha{7cm}
+\begin{twocollist}
+\twocolitem{{\bf EVT\_HTMLWINDOW\_LINK\_CLICKED(id, func)}}{User clicked on an hyperlink.}
+\end{twocollist}
+
+
+\latexignore{\rtfignore{\wxheading{Members}}}
+
+\membersection{wxHtmlLinkEvent::wxHtmlLinkEvent}\label{wxhtmllinkeventctor}
+
+\func{}{wxHyperlinkEvent}{\param{int}{ id}, \param{const wxHtmlLinkInfo \&}{ linkinfo}}
+
+The constructor is not normally used by the user code.
+
+
+\membersection{wxHtmlLinkEvent::GetLinkInfo}\label{wxhtmllinkeventgetlinkinfo}
+
+\constfunc{const wxHtmlLinkInfo &}{GetLinkInfo}{\void}
+
+Returns the \helpref{wxHtmlLinkInfo}{wxhtmllinkinfo} which contains info about the cell clicked and the hyperlink it contains.
+
+
+
+
+
+
+\section{\class{wxHtmlCellEvent}}\label{wxhtmlcellevent}
+
+This event class is used for the events generated by \helpref{wxHtmlWindow}{wxhtmlwindow}.
+
+\wxheading{Derived from}
+
+\helpref{wxCommandEvent}{wxcommandevent}\\
+\helpref{wxEvent}{wxevent}\\
+\helpref{wxObject}{wxobject}
+
+\wxheading{Include files}
+
+<wx/html/htmlwin.h>
+
+\wxheading{Event handling}
+
+To process input from a wxHtmlCellEvent, use one of these event handler macros to
+direct input to member function that take a \helpref{wxHtmlCellEvent}{wxhtmlcellevent} argument:
+
+\twocolwidtha{7cm}
+\begin{twocollist}
+\twocolitem{{\bf EVT\_HTMLWINDOW\_CELL\_HOVER(id, func)}}{User moved the mouse over a \helpref{wxHtmlCell}{wxhtmlcell}.}
+\twocolitem{{\bf EVT\_HTMLWINDOW\_CELL\_CLICKED(id, func)}}{User clicked on a \helpref{wxHtmlCell}{wxhtmlcell}. When handling this event, remember to use \helpref{wxHtmlCell::SetLinkClicked(true)}{wxhtmlcelleventsetlinkclicked} if the cell contains a link.}
+\end{twocollist}
+
+
+\latexignore{\rtfignore{\wxheading{Members}}}
+
+\membersection{wxHtmlCellEvent::wxHtmlCellEvent}\label{wxhtmlcelleventctor}
+
+\func{}{wxHtmlCellEvent}{\param{wxEventType}{ commandType}, \param{int}{ id}, \param{wxHtmlCell *}{ cell}, \param{const wxPoint \&}{ point}}
+
+The constructor is not normally used by the user code.
+
+
+\membersection{wxHtmlCellEvent::GetCell}\label{wxhtmlcelleventgetcell}
+
+\constfunc{wxHtmlCell *}{GetCell}{\void}
+
+Returns the \helpref{wxHtmlCellEvent}{wxhtmlcellevent} associated with the event.
+
+
+\membersection{wxHtmlCellEvent::GetPoint}\label{wxhtmlcelleventgetpoint}
+
+\constfunc{wxPoint}{GetPoint}{\void}
+
+Returns the \helpref{wxPoint}{wxpoint} associated with the event.
+
+
+\membersection{wxHtmlCellEvent::SetLinkClicked}\label{wxhtmlcelleventsetlinkclicked}
+
+\func{bool}{SetLinkClicked}{\param{bool}{ linkclicked}}
+
+Call this function with {\tt linkclicked} set to \true if the cell which has been clicked contained a link or
+\false otherwise (which is the default). With this function the event handler can return info to the
+wxHtmlWindow which sent the event.
+
+
+\membersection{wxHtmlCellEvent::GetLinkClicked}\label{wxhtmlcelleventgetlinkclicked}
+
+\constfunc{bool}{GetLinkClicked}{\void}
+
+Returns \true if \helpref{SetLinkClicked(true)}{wxhtmlcelleventsetlinkclicked} has previously been called;
+\false otherwise.
+
wxID_HTML_COUNTINFO
};
-/*!
- * Help window event
- */
-
-class WXDLLIMPEXP_HTML wxHtmlWindowEvent: public wxNotifyEvent
-{
-public:
- wxHtmlWindowEvent(wxEventType commandType = wxEVT_NULL, int id = 0):
- wxNotifyEvent(commandType, id)
- {
-
- }
-
- void SetURL(const wxString& url) { m_url = url; }
- const wxString& GetURL() const { return m_url; }
-
-private:
- wxString m_url;
-
- DECLARE_DYNAMIC_CLASS(wxHtmlWindowEvent)
-};
-
-typedef void (wxEvtHandler::*wxHtmlWindowEventFunction)(wxHtmlWindowEvent&);
-
-BEGIN_DECLARE_EVENT_TYPES()
- DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_HTML,
- wxEVT_COMMAND_HTMLWINDOW_URL_CLICKED, 1000)
-END_DECLARE_EVENT_TYPES()
-
-#define EVT_HTMLWINDOW_URL_CLICKED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_HTMLWINDOW_URL_CLICKED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxHtmlWindowEventFunction) & fn, (wxObject *) NULL ),
-
#endif // wxUSE_WXHTML_HELP
#endif
class wxHtmlHistoryArray;
class wxHtmlProcessorList;
class WXDLLIMPEXP_HTML wxHtmlWinAutoScrollTimer;
+class WXDLLIMPEXP_HTML wxHtmlCellEvent;
+class WXDLLIMPEXP_HTML wxHtmlLinkEvent;
// wxHtmlWindow flags:
};
+
+
+BEGIN_DECLARE_EVENT_TYPES()
+ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_HTML,
+ wxEVT_COMMAND_HTML_CELL_CLICKED, 1000)
+ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_HTML,
+ wxEVT_COMMAND_HTML_CELL_HOVER, 1001)
+ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_HTML,
+ wxEVT_COMMAND_HTML_LINK_CLICKED, 1002)
+END_DECLARE_EVENT_TYPES()
+
+
+/*!
+ * Html cell window event
+ */
+
+class WXDLLIMPEXP_HTML wxHtmlCellEvent : public wxCommandEvent
+{
+public:
+ wxHtmlCellEvent() {}
+ wxHtmlCellEvent(wxEventType commandType, int id,
+ wxHtmlCell *cell, const wxPoint &pt,
+ const wxMouseEvent &ev)
+ : wxCommandEvent(commandType, id)
+ {
+ m_cell = cell;
+ m_pt = pt;
+ m_mouseEvent = ev;
+ m_bLinkWasClicked = false;
+ }
+
+ wxHtmlCell* GetCell() const { return m_cell; }
+ wxPoint GetPoint() const { return m_pt; }
+ wxMouseEvent GetMouseEvent() const { return m_mouseEvent; }
+
+ void SetLinkClicked(bool linkclicked) { m_bLinkWasClicked=linkclicked; }
+ bool GetLinkClicked() const { return m_bLinkWasClicked; }
+
+ // default copy ctor, assignment operator and dtor are ok
+ virtual wxEvent *Clone() const { return new wxHtmlCellEvent(*this); }
+
+private:
+ wxHtmlCell *m_cell;
+ wxMouseEvent m_mouseEvent;
+ wxPoint m_pt;
+
+ bool m_bLinkWasClicked;
+
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxHtmlCellEvent)
+};
+
+
+
+/*!
+ * Html link event
+ */
+
+class WXDLLIMPEXP_HTML wxHtmlLinkEvent : public wxCommandEvent
+{
+public:
+ wxHtmlLinkEvent() {}
+ wxHtmlLinkEvent(int id, const wxHtmlLinkInfo &linkinfo)
+ : wxCommandEvent(wxEVT_COMMAND_HTML_LINK_CLICKED, id)
+ {
+ m_linkInfo = linkinfo;
+ }
+
+ const wxHtmlLinkInfo &GetLinkInfo() const { return m_linkInfo; }
+
+ // default copy ctor, assignment operator and dtor are ok
+ virtual wxEvent *Clone() const { return new wxHtmlLinkEvent(*this); }
+
+private:
+ wxHtmlLinkInfo m_linkInfo;
+
+ DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxHtmlLinkEvent)
+};
+
+
+typedef void (wxEvtHandler::*wxHtmlCellEventFunction)(wxHtmlCellEvent&);
+typedef void (wxEvtHandler::*wxHtmlLinkEventFunction)(wxHtmlLinkEvent&);
+
+#define wxHtmlCellEventHandler(func) \
+ (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxHtmlCellEventFunction, &func)
+#define wxHtmlLinkEventHandler(func) \
+ (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxHtmlLinkEventFunction, &func)
+
+#define EVT_HTML_CELL_CLICKED(id, fn) \
+ wx__DECLARE_EVT1(wxEVT_COMMAND_HTML_CELL_CLICKED, id, wxHtmlCellEventHandler(fn))
+#define EVT_HTML_CELL_HOVER(id, fn) \
+ wx__DECLARE_EVT1(wxEVT_COMMAND_HTML_CELL_HOVER, id, wxHtmlCellEventHandler(fn))
+#define EVT_HTML_LINK_CLICKED(id, fn) \
+ wx__DECLARE_EVT1(wxEVT_COMMAND_HTML_LINK_CLICKED, id, wxHtmlLinkEventHandler(fn))
+
+
#endif // wxUSE_HTML
#endif // _WX_HTMLWIN_H_
// This method may be overriden to handle clicking on a link in
// the listbox. By default, clicking links is ignored.
- virtual void OnLinkClicked(size_t WXUNUSED(n),
- const wxHtmlLinkInfo& WXUNUSED(link)) { }
+ virtual void OnLinkClicked(size_t n, const wxHtmlLinkInfo& link);
// event handlers
void OnSize(wxSizeEvent& event);
virtual void OnDrawSeparator(wxDC& dc, wxRect& rect, size_t n) const;
virtual wxColour GetSelectedTextColour(const wxColour& colFg) const;
- // override this method to handle mouse clicks
- virtual void OnLinkClicked(size_t n, const wxHtmlLinkInfo& link);
-
// flag telling us whether we should use fg colour even for the selected
// item
bool m_change;
// flag which we toggle to update the first items text in OnGetItem()
bool m_firstItemUpdated;
+public:
+
// flag which we toggle when the user clicks on the link in 2nd item
// to change 2nd item's text
bool m_linkClicked;
-
#ifdef USE_HTML_FILE
wxTextFile m_file;
#endif
wxLogMessage(_T("Listbox item %d double clicked."), event.GetInt());
}
+ void OnHtmlLinkClicked(wxHtmlLinkEvent& event);
+ void OnHtmlCellHover(wxHtmlCellEvent &event);
+ void OnHtmlCellClicked(wxHtmlCellEvent &event);
+
wxSimpleHtmlListBox *GetSimpleBox()
{ return wxDynamicCast(m_hlbox, wxSimpleHtmlListBox); }
MyHtmlListBox *GetMyBox()
EVT_LISTBOX(wxID_ANY, MyFrame::OnLboxSelect)
EVT_LISTBOX_DCLICK(wxID_ANY, MyFrame::OnLboxDClick)
+
+
+ // the HTML listbox's events
+ EVT_HTML_LINK_CLICKED(wxID_ANY, MyFrame::OnHtmlLinkClicked)
+ EVT_HTML_CELL_HOVER(wxID_ANY, MyFrame::OnHtmlCellHover)
+ EVT_HTML_CELL_CLICKED(wxID_ANY, MyFrame::OnHtmlCellClicked)
+
END_EVENT_TABLE()
IMPLEMENT_APP(MyApp)
}
}
+void MyFrame::OnHtmlLinkClicked(wxHtmlLinkEvent &event)
+{
+ wxLogMessage(wxT("The url '%s' has been clicked!"), event.GetLinkInfo().GetHref().c_str());
+
+ if (GetMyBox())
+ {
+ GetMyBox()->m_linkClicked = true;
+ GetMyBox()->RefreshLine(1);
+ }
+}
+
+void MyFrame::OnHtmlCellHover(wxHtmlCellEvent &event)
+{
+ wxLogMessage(wxT("Mouse moved over cell %p at %d;%d"),
+ event.GetCell(), event.GetPoint().x, event.GetPoint().y);
+}
+
+void MyFrame::OnHtmlCellClicked(wxHtmlCellEvent &event)
+{
+ wxLogMessage(wxT("Click over cell %p at %d;%d"),
+ event.GetCell(), event.GetPoint().x, event.GetPoint().y);
+
+ // if we don't skip the event, OnHtmlLinkClicked won't be called!
+ event.Skip();
+}
+
// ----------------------------------------------------------------------------
// listbox event handlers
// ----------------------------------------------------------------------------
RefreshLine(0);
}
-
-void MyHtmlListBox::OnLinkClicked(size_t WXUNUSED(n),
- const wxHtmlLinkInfo& WXUNUSED(link))
-{
- m_linkClicked = true;
-
- RefreshLine(1);
-}
-
void OnForward(wxCommandEvent& event);
void OnProcessor(wxCommandEvent& event);
+ void OnHtmlLinkClicked(wxHtmlLinkEvent& event);
+ void OnHtmlCellHover(wxHtmlCellEvent &event);
+ void OnHtmlCellClicked(wxHtmlCellEvent &event);
+
private:
MyHtmlWindow *m_Html;
wxHtmlProcessor *m_Processor;
EVT_MENU(ID_Back, MyFrame::OnBack)
EVT_MENU(ID_Forward, MyFrame::OnForward)
EVT_MENU(ID_Processor, MyFrame::OnProcessor)
+
+ EVT_HTML_LINK_CLICKED(wxID_ANY, MyFrame::OnHtmlLinkClicked)
+ EVT_HTML_CELL_HOVER(wxID_ANY, MyFrame::OnHtmlCellHover)
+ EVT_HTML_CELL_CLICKED(wxID_ANY, MyFrame::OnHtmlCellClicked)
END_EVENT_TABLE()
IMPLEMENT_APP(MyApp)
m_Html->ReadCustomization(wxConfig::Get());
m_Html->LoadFile(wxFileName(wxT("test.htm")));
m_Html->AddProcessor(m_Processor);
+
+ wxTextCtrl *text = new wxTextCtrl(this, wxID_ANY, _T(""),
+ wxDefaultPosition, wxDefaultSize,
+ wxTE_MULTILINE);
+
+ delete wxLog::SetActiveTarget(new wxLogTextCtrl(text));
+
+ wxSizer *sz = new wxBoxSizer(wxVERTICAL);
+ sz->Add(m_Html, 3, wxGROW);
+ sz->Add(text, 1, wxGROW);
+ SetSizer(sz);
}
m_Html->LoadPage(m_Html->GetOpenedPage());
}
+void MyFrame::OnHtmlLinkClicked(wxHtmlLinkEvent &event)
+{
+ wxLogMessage(wxT("The url '%s' has been clicked!"), event.GetLinkInfo().GetHref().c_str());
+
+ // skipping this event the default behaviour (load the clicked URL)
+ // will happen...
+ event.Skip();
+}
+
+void MyFrame::OnHtmlCellHover(wxHtmlCellEvent &event)
+{
+ wxLogMessage(wxT("Mouse moved over cell %d at %d;%d"),
+ event.GetCell(), event.GetPoint().x, event.GetPoint().y);
+}
+
+void MyFrame::OnHtmlCellClicked(wxHtmlCellEvent &event)
+{
+ wxLogMessage(wxT("Click over cell %d at %d;%d"),
+ event.GetCell(), event.GetPoint().x, event.GetPoint().y);
+
+ // if we don't skip the event, OnHtmlLinkClicked won't be called!
+ event.Skip();
+}
+
wxHtmlOpeningStatus MyHtmlWindow::OnOpeningURL(wxHtmlURLType WXUNUSED(type),
const wxString& url,
wxString *WXUNUSED(redirect)) const
// wxHtmlHelpHtmlWindow (private)
//--------------------------------------------------------------------------
-DEFINE_EVENT_TYPE(wxEVT_COMMAND_HTMLWINDOW_URL_CLICKED)
-IMPLEMENT_DYNAMIC_CLASS(wxHtmlWindowEvent, wxNotifyEvent)
class wxHtmlHelpHtmlWindow : public wxHtmlWindow
{
SetStandardFonts();
}
- virtual void OnLinkClicked(const wxHtmlLinkInfo& link)
+ void OnLinkClicked(wxHtmlLinkEvent& ev)
{
- wxHtmlWindowEvent event(wxEVT_COMMAND_HTMLWINDOW_URL_CLICKED, GetId());
- event.SetURL(link.GetHref());
- if (!ProcessEvent(event))
- {
- wxHtmlWindow::OnLinkClicked(link);
- }
- const wxMouseEvent *e = link.GetEvent();
+ const wxMouseEvent *e = ev.GetLinkInfo().GetEvent();
if (e == NULL || e->LeftUp())
m_Window->NotifyPageChanged();
}
wxHtmlHelpWindow *m_Window;
DECLARE_NO_COPY_CLASS(wxHtmlHelpHtmlWindow)
+ DECLARE_EVENT_TABLE()
};
+BEGIN_EVENT_TABLE(wxHtmlHelpHtmlWindow, wxHtmlWindow)
+ EVT_HTML_LINK_CLICKED(wxID_ANY, wxHtmlHelpHtmlWindow::OnLinkClicked)
+END_EVENT_TABLE()
+
//---------------------------------------------------------------------------
// wxHtmlHelpWindow::m_mergedIndex
#include "wx/arrimpl.cpp"
#include "wx/listimpl.cpp"
+// HTML events:
+IMPLEMENT_DYNAMIC_CLASS(wxHtmlLinkEvent, wxCommandEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxHtmlCellEvent, wxCommandEvent)
+
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_HTML_CELL_CLICKED)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_HTML_CELL_HOVER)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_HTML_LINK_CLICKED)
+
#if wxUSE_CLIPBOARD
// ----------------------------------------------------------------------------
wxCoord x, wxCoord y,
const wxMouseEvent& event)
{
- wxCHECK_MSG( cell, false, _T("can't be called with NULL cell") );
+ 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, _T("can't be called with NULL cell") );
+
+ cell->ProcessMouseClick(m_interface, ev.GetPoint(), ev.GetMouseEvent());
+ }
- return cell->ProcessMouseClick(m_interface, wxPoint(x, y), event);
+ // true if a link was clicked, false otherwise
+ return ev.GetLinkClicked();
}
-void wxHtmlWindowMouseHelper::OnCellMouseHover(wxHtmlCell * WXUNUSED(cell),
- wxCoord WXUNUSED(x),
- wxCoord WXUNUSED(y))
+void wxHtmlWindowMouseHelper::OnCellMouseHover(wxHtmlCell * cell,
+ wxCoord x,
+ wxCoord y)
{
- // do nothing here
+ wxHtmlCellEvent ev(wxEVT_COMMAND_HTML_CELL_HOVER,
+ m_interface->GetHTMLWindow()->GetId(),
+ cell, wxPoint(x,y), wxMouseEvent());
+ m_interface->GetHTMLWindow()->GetEventHandler()->ProcessEvent(ev);
}
+
+
+
//-----------------------------------------------------------------------------
// wxHtmlWindow
//-----------------------------------------------------------------------------
void wxHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link)
{
- const wxMouseEvent *e = link.GetEvent();
- if (e == NULL || e->LeftUp())
- LoadPage(link.GetHref());
+ wxHtmlLinkEvent event(GetId(), link);
+ if (!GetEventHandler()->ProcessEvent(event))
+ {
+ // the default behaviour is to load the URL in this window
+ const wxMouseEvent *e = event.GetLinkInfo().GetEvent();
+ if (e == NULL || e->LeftUp())
+ LoadPage(event.GetLinkInfo().GetHref());
+ }
}
void wxHtmlWindow::OnEraseBackground(wxEraseEvent& event)
if ( m_tmpSelFromCell->IsBefore(selcell) )
{
m_selection->Set(m_tmpSelFromPos, m_tmpSelFromCell,
- wxPoint(x,y), selcell); }
+ wxPoint(x,y), selcell);
+ }
else
{
m_selection->Set(wxPoint(x,y), selcell,