Extend history api using the ie backend to include loading history items, and getting the backward and forward history lists.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68120 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Steve Lamerton 2011-07-01 10:57:37 +00:00
parent 3e7968c2da
commit 5cbda74b66
4 changed files with 61 additions and 12 deletions

View File

@ -19,18 +19,7 @@
#include "wx/msw/ole/automtn.h" #include "wx/msw/ole/automtn.h"
#include "wx/msw/ole/activex.h" #include "wx/msw/ole/activex.h"
#include "wx/sharedptr.h" #include "wx/sharedptr.h"
#include "wx/vector.h"
class WXDLLIMPEXP_WEB wxWebHistoryItem
{
public:
wxWebHistoryItem(const wxString& url, const wxString& title) :
m_url(url), m_title(title) {}
wxString GetUrl() { return m_url; }
wxString GetTitle() { return m_title; }
private:
wxString m_url, m_title;
};
class WXDLLIMPEXP_WEB wxWebViewIE : public wxWebView class WXDLLIMPEXP_WEB wxWebViewIE : public wxWebView
{ {
@ -59,6 +48,8 @@ public:
virtual void LoadUrl(const wxString& url); virtual void LoadUrl(const wxString& url);
virtual void LoadHistoryItem(wxSharedPtr<wxWebHistoryItem> item); virtual void LoadHistoryItem(wxSharedPtr<wxWebHistoryItem> item);
virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetBackwardHistory();
virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetForwardHistory();
virtual bool CanGoForward(); virtual bool CanGoForward();
virtual bool CanGoBack(); virtual bool CanGoBack();

View File

@ -17,6 +17,19 @@
#include <wx/control.h> #include <wx/control.h>
#include <wx/event.h> #include <wx/event.h>
#include <wx/sstream.h> #include <wx/sstream.h>
#include "wx/sharedptr.h"
class WXDLLIMPEXP_WEB wxWebHistoryItem
{
public:
wxWebHistoryItem(const wxString& url, const wxString& title) :
m_url(url), m_title(title) {}
wxString GetUrl() { return m_url; }
wxString GetTitle() { return m_title; }
private:
wxString m_url, m_title;
};
/** /**
* Zoom level in web view component * Zoom level in web view component
@ -175,6 +188,9 @@ public:
virtual void ClearHistory() = 0; virtual void ClearHistory() = 0;
virtual void EnableHistory(bool enable = true) = 0; virtual void EnableHistory(bool enable = true) = 0;
virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetBackwardHistory() = 0;
virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetForwardHistory() = 0;
virtual void LoadHistoryItem(wxSharedPtr<wxWebHistoryItem> item) = 0;
/** /**
* Stop the current page loading process, if any. * Stop the current page loading process, if any.

View File

@ -208,6 +208,24 @@ public:
Enable or disable the history. This will also clear the history. Enable or disable the history. This will also clear the history.
*/ */
virtual void EnableHistory(bool enable = true) = 0; virtual void EnableHistory(bool enable = true) = 0;
/**
Returns a list of items in the back history. The first item in the
vector is the first page that was loaded by the control.
*/
virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetBackwardHistory() = 0;
/**
Returns a list of items in the forward history. The first item in the
vector is the next item in the history with respect to the curently
loaded page.
*/
virtual wxVector<wxSharedPtr<wxWebHistoryItem> > GetForwardHistory() = 0;
/**
Loads a history item.
*/
virtual void LoadHistoryItem(wxSharedPtr<wxWebHistoryItem> item) = 0;
/** /**
Load a HTMl document (web page) from a URL Load a HTMl document (web page) from a URL

View File

@ -388,6 +388,30 @@ void wxWebViewIE::LoadHistoryItem(wxSharedPtr<wxWebHistoryItem> item)
m_historyPosition = pos; m_historyPosition = pos;
} }
wxVector<wxSharedPtr<wxWebHistoryItem> > wxWebViewIE::GetBackwardHistory()
{
wxVector<wxSharedPtr<wxWebHistoryItem> > backhist;
//As we don't have std::copy or an iterator constructor in the wxwidgets
//native vector we construct it by hand
for(int i = 0; i < m_historyPosition; i++)
{
backhist.push_back(m_historyList[i]);
}
return backhist;
}
wxVector<wxSharedPtr<wxWebHistoryItem> > wxWebViewIE::GetForwardHistory()
{
wxVector<wxSharedPtr<wxWebHistoryItem> > forwardhist;
//As we don't have std::copy or an iterator constructor in the wxwidgets
//native vector we construct it by hand
for(int i = m_historyPosition + 1; i < m_historyList.size(); i++)
{
forwardhist.push_back(m_historyList[i]);
}
return forwardhist;
}
void wxWebViewIE::GoBack() void wxWebViewIE::GoBack()
{ {
LoadHistoryItem(m_historyList[m_historyPosition - 1]); LoadHistoryItem(m_historyList[m_historyPosition - 1]);