diff --git a/samples/webview/webview.cpp b/samples/webview/webview.cpp index a1c6217d5f..8911f6b513 100644 --- a/samples/webview/webview.cpp +++ b/samples/webview/webview.cpp @@ -116,6 +116,7 @@ public: void OnNewWindow(wxWebViewEvent& evt); void OnTitleChanged(wxWebViewEvent& evt); void OnViewSourceRequest(wxCommandEvent& evt); + void OnViewTextRequest(wxCommandEvent& evt); void OnToolsClicked(wxCommandEvent& evt); void OnSetZoom(wxCommandEvent& evt); void OnError(wxWebViewEvent& evt); @@ -346,6 +347,7 @@ WebFrame::WebFrame(const wxString& url) : m_tools_menu = new wxMenu(); wxMenuItem* print = m_tools_menu->Append(wxID_ANY , _("Print")); wxMenuItem* viewSource = m_tools_menu->Append(wxID_ANY , _("View Source")); + wxMenuItem* viewText = m_tools_menu->Append(wxID_ANY, _("View Text")); m_tools_menu->AppendSeparator(); m_tools_layout = m_tools_menu->AppendCheckItem(wxID_ANY, _("Use Layout Zoom")); m_tools_tiny = m_tools_menu->AppendCheckItem(wxID_ANY, _("Tiny")); @@ -459,7 +461,9 @@ WebFrame::WebFrame(const wxString& url) : // Connect the menu events Connect(viewSource->GetId(), wxEVT_MENU, - wxCommandEventHandler(WebFrame::OnViewSourceRequest), NULL, this ); + wxCommandEventHandler(WebFrame::OnViewSourceRequest), NULL, this ); + Connect(viewText->GetId(), wxEVT_MENU, + wxCommandEventHandler(WebFrame::OnViewTextRequest), NULL, this ); Connect(print->GetId(), wxEVT_MENU, wxCommandEventHandler(WebFrame::OnPrint), NULL, this ); Connect(m_tools_layout->GetId(), wxEVT_MENU, @@ -816,6 +820,22 @@ void WebFrame::OnViewSourceRequest(wxCommandEvent& WXUNUSED(evt)) dlg.ShowModal(); } +/** + * Invoked when user selects the "View Text" menu item + */ +void WebFrame::OnViewTextRequest(wxCommandEvent& WXUNUSED(evt)) +{ + wxDialog textViewDialog(this, wxID_ANY, "Page Text", + wxDefaultPosition, wxSize(700,500), + wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER); + wxStyledTextCtrl* text = new wxStyledTextCtrl(&textViewDialog, wxID_ANY); + text->SetText(m_browser->GetPageText()); + wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL); + sizer->Add(text, 1, wxEXPAND); + SetSizer(sizer); + textViewDialog.ShowModal(); +} + /** * Invoked when user selects the "Menu" item */