]> git.saurik.com Git - wxWidgets.git/commitdiff
Implement GetBackwardHistory, GetForwardHistory and LoadHistoryItem for OSX WebKit.
authorSteve Lamerton <steve.lamerton@gmail.com>
Fri, 5 Aug 2011 16:40:46 +0000 (16:40 +0000)
committerSteve Lamerton <steve.lamerton@gmail.com>
Fri, 5 Aug 2011 16:40:46 +0000 (16:40 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68559 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/osx/webhistoryitem_webkit.h
include/wx/osx/webview_webkit.h
src/osx/webview_webkit.mm

index 44e7be50c59a896f221d9b56e7db5a60fae80692..e3b7a50ace12780044b9b8238810f6ed3372a882 100644 (file)
 class WXDLLIMPEXP_WEB wxWebHistoryItem
 {
 public:
-    wxWebHistoryItem(const wxString& url, const wxString& title) : 
+    wxWebHistoryItem(const wxString& url, const wxString& title) :
                      m_url(url), m_title(title) {}
     wxString GetUrl() { return m_url; }
     wxString GetTitle() { return m_title; }
 
+    friend class wxWebViewWebKit;
+
 private:
     wxString m_url, m_title;
+    struct objc_object *m_histItem;
 };
 
 #endif // wxUSE_WEBVIEW_WEBKIT && defined(__WXOSX_MAC__)
index b9e228f36818ecaf41dcdc3a4ac0d596c69f86b7..a63428b0485c4f158ed96f3d02231c8c649163fd 100644 (file)
@@ -85,11 +85,9 @@ public:
     //History functions
     virtual void ClearHistory();
     virtual void EnableHistory(bool enable = true);
-    virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetBackwardHistory()
-            { return wxVector<wxSharedPtr<wxWebHistoryItem> >(); }
-    virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetForwardHistory() 
-            { return wxVector<wxSharedPtr<wxWebHistoryItem> >(); }
-    virtual void LoadHistoryItem(wxSharedPtr<wxWebHistoryItem> WXUNUSED(item)) {}
+    virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetBackwardHistory();
+    virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetForwardHistory();
+    virtual void LoadHistoryItem(wxSharedPtr<wxWebHistoryItem> item);
     
     //Undo / redo functionality
     virtual bool CanUndo();
index 392e81b72295188ea0258bdc70b8807075bbd233..c3a8e7458d99be5aeaa0e5230953a04800b7fa3e 100644 (file)
@@ -958,6 +958,47 @@ void wxWebViewWebKit::ClearHistory()
     [m_webView setMaintainsBackForwardList:YES];
 }
 
+wxVector<wxSharedPtr<wxWebHistoryItem> > wxWebViewWebKit::GetBackwardHistory()
+{
+    wxVector<wxSharedPtr<wxWebHistoryItem> > 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]);
+        wxWebHistoryItem* wxitem = new wxWebHistoryItem(url, title);
+        wxitem->m_histItem = item;
+        wxSharedPtr<wxWebHistoryItem> itemptr(wxitem);
+        backhist.push_back(itemptr);
+    }
+    return backhist;
+}
+
+wxVector<wxSharedPtr<wxWebHistoryItem> > wxWebViewWebKit::GetForwardHistory()
+{
+    wxVector<wxSharedPtr<wxWebHistoryItem> > 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]);
+        wxWebHistoryItem* wxitem = new wxWebHistoryItem(url, title);
+        wxitem->m_histItem = item;
+        wxSharedPtr<wxWebHistoryItem> itemptr(wxitem);
+        forwardhist.push_back(itemptr);
+    }
+    return forwardhist;
+}
+
+void wxWebViewWebKit::LoadHistoryItem(wxSharedPtr<wxWebHistoryItem> item)
+{
+    [m_webView goToBackForwardItem:item->m_histItem];
+}
+
 bool wxWebViewWebKit::CanUndo()
 {
     return [[m_webView undoManager] canUndo];