+void wxWebViewWebKit::Cut()
+{
+ if ( !m_webView )
+ return;
+
+ [(WebView*)m_webView cut:m_webView];
+}
+
+void wxWebViewWebKit::Copy()
+{
+ if ( !m_webView )
+ return;
+
+ [(WebView*)m_webView copy:m_webView];
+}
+
+void wxWebViewWebKit::Paste()
+{
+ if ( !m_webView )
+ return;
+
+ [(WebView*)m_webView paste:m_webView];
+}
+
+void wxWebViewWebKit::DeleteSelection()
+{
+ if ( !m_webView )
+ return;
+
+ [(WebView*)m_webView deleteSelection];
+}
+
+bool wxWebViewWebKit::HasSelection() const
+{
+ DOMRange* range = [m_webView selectedDOMRange];
+ if(!range)
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+}
+
+void wxWebViewWebKit::ClearSelection()
+{
+ //We use javascript as selection isn't exposed at the moment in webkit
+ RunScript("window.getSelection().removeAllRanges();");
+}
+
+void wxWebViewWebKit::SelectAll()
+{
+ RunScript("window.getSelection().selectAllChildren(document.body);");
+}
+
+wxString wxWebViewWebKit::GetSelectedSource() const
+{
+ wxString script = ("var range = window.getSelection().getRangeAt(0);"
+ "var element = document.createElement('div');"
+ "element.appendChild(range.cloneContents());"
+ "return element.innerHTML;");
+ NSString *result = [m_webView stringByEvaluatingJavaScriptFromString:
+ wxNSStringWithWxString(script)];
+ return wxStringWithNSString(result);
+}
+
+wxString wxWebViewWebKit::GetPageText() const
+{
+ NSString *result = [m_webView stringByEvaluatingJavaScriptFromString:
+ @"document.body.textContent"];
+ return wxStringWithNSString(result);
+}
+
+void wxWebViewWebKit::EnableHistory(bool enable)
+{
+ if ( !m_webView )
+ return;
+
+ [m_webView setMaintainsBackForwardList:enable];
+}
+
+void wxWebViewWebKit::ClearHistory()
+{
+ [m_webView setMaintainsBackForwardList:NO];
+ [m_webView setMaintainsBackForwardList:YES];
+}
+
+wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewWebKit::GetBackwardHistory()
+{
+ wxVector<wxSharedPtr<wxWebViewHistoryItem> > backhist;
+ WebBackForwardList* history = [m_webView backForwardList];
+ int count = [history backListCount];
+ for(int i = -count; i < 0; i++)
+ {
+ WebHistoryItem* item = [history itemAtIndex:i];
+ wxString url = wxStringWithNSString([item URLString]);
+ wxString title = wxStringWithNSString([item title]);
+ wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(url, title);
+ wxitem->m_histItem = item;
+ wxSharedPtr<wxWebViewHistoryItem> itemptr(wxitem);
+ backhist.push_back(itemptr);
+ }
+ return backhist;
+}
+
+wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewWebKit::GetForwardHistory()
+{
+ wxVector<wxSharedPtr<wxWebViewHistoryItem> > forwardhist;
+ WebBackForwardList* history = [m_webView backForwardList];
+ int count = [history forwardListCount];
+ for(int i = 1; i <= count; i++)
+ {
+ WebHistoryItem* item = [history itemAtIndex:i];
+ wxString url = wxStringWithNSString([item URLString]);
+ wxString title = wxStringWithNSString([item title]);
+ wxWebViewHistoryItem* wxitem = new wxWebViewHistoryItem(url, title);
+ wxitem->m_histItem = item;
+ wxSharedPtr<wxWebViewHistoryItem> itemptr(wxitem);
+ forwardhist.push_back(itemptr);
+ }
+ return forwardhist;
+}
+
+void wxWebViewWebKit::LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item)
+{
+ [m_webView goToBackForwardItem:item->m_histItem];
+}
+
+bool wxWebViewWebKit::CanUndo() const
+{
+ return [[m_webView undoManager] canUndo];
+}
+
+bool wxWebViewWebKit::CanRedo() const
+{
+ return [[m_webView undoManager] canRedo];
+}
+
+void wxWebViewWebKit::Undo()
+{
+ [[m_webView undoManager] undo];
+}
+
+void wxWebViewWebKit::Redo()
+{
+ [[m_webView undoManager] redo];
+}
+
+void wxWebViewWebKit::RegisterHandler(wxSharedPtr<wxWebViewHandler> handler)
+{
+ g_stringHandlerMap[handler->GetName()] = handler;
+}
+