Add "View text" menu item to the webview sample.
Allow to view just the text of the web page. Closes #16098. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76195 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
Reference in New Issue
Block a user