virtual wxWebViewZoom GetZoom();
virtual void SetZoom(wxWebViewZoom zoom);
+ //Clipboard functions
+ virtual bool CanCut();
+ virtual bool CanCopy();
+ virtual bool CanPaste();
+ virtual void Cut();
+ virtual void Copy();
+ virtual void Paste();
+
// ---- IE-specific methods
// FIXME: I seem to be able to access remote webpages even in offline mode...
bool m_historyLoadingFromList;
bool m_historyEnabled;
+ //Generic helper functions for IHtmlDocument commands
+ bool CanExecCommand(wxString command);
+ void ExecCommand(wxString command);
+
};
#endif // wxUSE_WEBVIEW_IE
void OnSetZoom(wxCommandEvent& evt);
void OnError(wxWebNavigationEvent& evt);
void OnPrint(wxCommandEvent& evt);
+ void OnCut(wxCommandEvent& evt);
+ void OnCopy(wxCommandEvent& evt);
+ void OnPaste(wxCommandEvent& evt);
private:
wxTextCtrl* m_url;
wxMenuItem* m_tools_handle_navigation;
wxMenuItem* m_tools_handle_new_window;
wxMenuItem* m_tools_enable_history;
+ wxMenuItem* m_edit_cut;
+ wxMenuItem* m_edit_copy;
+ wxMenuItem* m_edit_paste;
wxTimer* m_timer;
int m_animation_angle;
wxMenuItem* clearhist = m_tools_menu->Append(wxID_ANY, _("Clear History"));
m_tools_enable_history = m_tools_menu->AppendCheckItem(wxID_ANY, _("Enable History"));
+ //Create an editing menu
+ wxMenu* editmenu = new wxMenu();
+ m_edit_cut = editmenu->Append(wxID_ANY, _("Cut"));
+ m_edit_copy = editmenu->Append(wxID_ANY, _("Copy"));
+ m_edit_paste = editmenu->Append(wxID_ANY, _("Paste"));
+
+ m_tools_menu->AppendSeparator();
+ m_tools_menu->AppendSubMenu(editmenu, "Edit");
+
//By default we want to handle navigation and new windows
m_tools_handle_navigation->Check();
m_tools_handle_new_window->Check();
wxCommandEventHandler(WebFrame::OnClearHistory), NULL, this );
Connect(m_tools_enable_history->GetId(), wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(WebFrame::OnEnableHistory), NULL, this );
+ Connect(m_edit_cut->GetId(), wxEVT_COMMAND_MENU_SELECTED,
+ wxCommandEventHandler(WebFrame::OnCut), NULL, this );
+ Connect(m_edit_copy->GetId(), wxEVT_COMMAND_MENU_SELECTED,
+ wxCommandEventHandler(WebFrame::OnCopy), NULL, this );
+ Connect(m_edit_paste->GetId(), wxEVT_COMMAND_MENU_SELECTED,
+ wxCommandEventHandler(WebFrame::OnPaste), NULL, this );
}
void WebFrame::OnAnimationTimer(wxTimerEvent& evt)
UpdateState();
}
+void WebFrame::OnCut(wxCommandEvent& evt)
+{
+ m_browser->Cut();
+}
+
+void WebFrame::OnCopy(wxCommandEvent& evt)
+{
+ m_browser->Copy();
+}
+
+void WebFrame::OnPaste(wxCommandEvent& evt)
+{
+ m_browser->Paste();
+}
+
/**
* Callback invoked when there is a request to load a new page (for instance
* when the user clicks a link)
m_tools_largest->Check();
break;
}
+
+ m_edit_cut->Enable(m_browser->CanCut());
+ m_edit_copy->Enable(m_browser->CanCopy());
+ m_edit_paste->Enable(m_browser->CanPaste());
wxPoint position = ScreenToClient( wxGetMousePosition() );
PopupMenu(m_tools_menu, position.x, position.y);
return out.GetString();
}
+bool wxWebViewIE::CanCut()
+{
+ return CanExecCommand("Cut");
+}
+
+bool wxWebViewIE::CanCopy()
+{
+ return CanExecCommand("Copy");
+}
+bool wxWebViewIE::CanPaste()
+{
+ return CanExecCommand("Paste");
+}
+
+void wxWebViewIE::Cut()
+{
+ ExecCommand("Cut");
+}
+
+void wxWebViewIE::Copy()
+{
+ ExecCommand("Copy");
+}
+
+void wxWebViewIE::Paste()
+{
+ ExecCommand("Paste");
+}
+
+bool wxWebViewIE::CanExecCommand(wxString command)
+{
+ wxVariant documentVariant = m_ie.GetProperty("Document");
+ void* documentPtr = documentVariant.GetVoidPtr();
+ IHTMLDocument2* document = (IHTMLDocument2*)documentPtr;
+
+ wxASSERT(documentPtr && document);
+
+ VARIANT_BOOL enabled;
+ document->queryCommandEnabled(SysAllocString(command.wc_str()), &enabled);
+
+ return (enabled == VARIANT_TRUE);
+}
+
+void wxWebViewIE::ExecCommand(wxString command)
+{
+ wxVariant documentVariant = m_ie.GetProperty("Document");
+ void* documentPtr = documentVariant.GetVoidPtr();
+ IHTMLDocument2* document = (IHTMLDocument2*)documentPtr;
+
+ wxASSERT(documentPtr && document);
+
+ document->execCommand(SysAllocString(command.wc_str()), VARIANT_FALSE, VARIANT(), NULL);
+}
+
void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
{
if (m_webBrowser == NULL) return;