+
+void MyFrame::OnDrawCustomBg(wxCommandEvent& event)
+{
+ m_Html->DrawCustomBg(event.IsChecked());
+}
+
+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 %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();
+}
+
+wxHtmlOpeningStatus MyHtmlWindow::OnOpeningURL(wxHtmlURLType WXUNUSED(type),
+ const wxString& url,
+ wxString *WXUNUSED(redirect)) const
+{
+ GetRelatedFrame()->SetStatusText(url + wxT(" lately opened"),1);
+ return wxHTML_OPEN;
+}
+
+BEGIN_EVENT_TABLE(MyHtmlWindow, wxHtmlWindow)
+#if wxUSE_CLIPBOARD
+ EVT_TEXT_COPY(wxID_ANY, MyHtmlWindow::OnClipboardEvent)
+#endif // wxUSE_CLIPBOARD
+ EVT_ERASE_BACKGROUND(MyHtmlWindow::OnEraseBgEvent)
+END_EVENT_TABLE()
+
+#if wxUSE_CLIPBOARD
+void MyHtmlWindow::OnClipboardEvent(wxClipboardTextEvent& WXUNUSED(event))
+{
+ // explicitly call wxHtmlWindow::CopySelection() method
+ // and show the first 100 characters of the text copied in the status bar
+ if ( CopySelection() )
+ {
+ wxTextDataObject data;
+ if ( wxTheClipboard && wxTheClipboard->Open() && wxTheClipboard->GetData(data) )
+ {
+ const wxString text = data.GetText();
+ const size_t maxTextLength = 100;
+
+ wxLogStatus(wxString::Format(wxT("Clipboard: '%s%s'"),
+ wxString(text, maxTextLength).c_str(),
+ (text.length() > maxTextLength) ? wxT("...")
+ : wxT("")));
+ wxTheClipboard->Close();
+
+ return;
+ }
+ }
+
+ wxLogStatus(wxT("Clipboard: nothing"));
+}
+#endif // wxUSE_CLIPBOARD
+
+void MyHtmlWindow::OnEraseBgEvent(wxEraseEvent& event)
+{
+ if ( !m_drawCustomBg )
+ {
+ event.Skip();
+ return;
+ }
+
+ // draw a background grid to show that this handler is indeed executed
+
+ wxDC& dc = *event.GetDC();
+ dc.SetPen(*wxBLUE_PEN);
+ dc.Clear();
+
+ const wxSize size = GetVirtualSize();
+ for ( int x = 0; x < size.x; x += 15 )
+ {
+ dc.DrawLine(x, 0, x, size.y);
+ }
+
+ for ( int y = 0; y < size.y; y += 15 )
+ {
+ dc.DrawLine(0, y, size.x, y);
+ }
+}
+