Implement GetBackwardHistory, GetForwardHistory and LoadHistoryItem for OSX WebKit.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68559 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -18,13 +18,16 @@
|
||||
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__)
|
||||
|
@@ -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();
|
||||
|
@@ -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];
|
||||
|
Reference in New Issue
Block a user