2011-05-04 18:24:30 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: include/wx/msw/webviewie.h
|
|
|
|
// Purpose: wxMSW IE wxWebView backend
|
|
|
|
// Author: Marianne Gagnon
|
|
|
|
// Id: $Id$
|
2011-07-30 11:26:55 +00:00
|
|
|
// Copyright: (c) 2010 Marianne Gagnon, 2011 Steven Lamerton
|
2011-05-04 18:24:30 +00:00
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef wxWebViewIE_H
|
|
|
|
#define wxWebViewIE_H
|
|
|
|
|
|
|
|
#include "wx/setup.h"
|
|
|
|
|
2011-08-01 10:10:20 +00:00
|
|
|
#if wxUSE_WEBVIEW_IE && defined(__WXMSW__)
|
2011-05-04 18:24:30 +00:00
|
|
|
|
|
|
|
#include "wx/control.h"
|
|
|
|
#include "wx/webview.h"
|
|
|
|
#include "wx/msw/ole/automtn.h"
|
|
|
|
#include "wx/msw/ole/activex.h"
|
2011-06-30 19:57:26 +00:00
|
|
|
#include "wx/sharedptr.h"
|
2011-07-01 10:57:37 +00:00
|
|
|
#include "wx/vector.h"
|
2011-05-04 18:24:30 +00:00
|
|
|
|
2011-07-11 09:35:41 +00:00
|
|
|
struct IHTMLDocument2;
|
2011-07-22 12:31:18 +00:00
|
|
|
class wxFSFile;
|
2011-07-28 16:08:59 +00:00
|
|
|
|
2011-08-19 10:45:16 +00:00
|
|
|
class WXDLLIMPEXP_WEBVIEW wxWebViewIE : public wxWebView
|
2011-05-04 18:24:30 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
wxWebViewIE() {}
|
|
|
|
|
|
|
|
wxWebViewIE(wxWindow* parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxString& url = wxWebViewDefaultURLStr,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxWebViewNameStr)
|
|
|
|
{
|
|
|
|
Create(parent, id, url, pos, size, style, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Create(wxWindow* parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxString& url = wxWebViewDefaultURLStr,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxWebViewNameStr);
|
|
|
|
|
2011-08-17 10:55:59 +00:00
|
|
|
virtual void LoadURL(const wxString& url);
|
2011-08-15 12:31:31 +00:00
|
|
|
virtual void LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item);
|
|
|
|
virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetBackwardHistory();
|
|
|
|
virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetForwardHistory();
|
2011-05-04 18:24:30 +00:00
|
|
|
|
2011-08-17 10:26:09 +00:00
|
|
|
virtual bool CanGoForward() const;
|
|
|
|
virtual bool CanGoBack() const;
|
2011-05-04 18:24:30 +00:00
|
|
|
virtual void GoBack();
|
|
|
|
virtual void GoForward();
|
2011-06-30 19:57:26 +00:00
|
|
|
virtual void ClearHistory();
|
|
|
|
virtual void EnableHistory(bool enable = true);
|
2011-05-04 18:24:30 +00:00
|
|
|
virtual void Stop();
|
2011-05-06 13:37:01 +00:00
|
|
|
virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT);
|
2011-05-04 18:24:30 +00:00
|
|
|
|
2011-08-17 10:26:09 +00:00
|
|
|
virtual wxString GetPageSource() const;
|
|
|
|
virtual wxString GetPageText() const;
|
2011-05-04 18:24:30 +00:00
|
|
|
|
2011-08-17 10:26:09 +00:00
|
|
|
virtual bool IsBusy() const;
|
|
|
|
virtual wxString GetCurrentURL() const;
|
|
|
|
virtual wxString GetCurrentTitle() const;
|
2011-05-04 18:24:30 +00:00
|
|
|
|
|
|
|
virtual void SetZoomType(wxWebViewZoomType);
|
|
|
|
virtual wxWebViewZoomType GetZoomType() const;
|
|
|
|
virtual bool CanSetZoomType(wxWebViewZoomType) const;
|
|
|
|
|
|
|
|
virtual void Print();
|
|
|
|
|
|
|
|
virtual void SetPage(const wxString& html, const wxString& baseUrl);
|
|
|
|
|
2011-08-17 10:26:09 +00:00
|
|
|
virtual wxWebViewZoom GetZoom() const;
|
2011-05-04 18:24:30 +00:00
|
|
|
virtual void SetZoom(wxWebViewZoom zoom);
|
|
|
|
|
2011-07-02 11:45:19 +00:00
|
|
|
//Clipboard functions
|
2011-08-17 10:26:09 +00:00
|
|
|
virtual bool CanCut() const;
|
|
|
|
virtual bool CanCopy() const;
|
|
|
|
virtual bool CanPaste() const;
|
2011-07-02 11:45:19 +00:00
|
|
|
virtual void Cut();
|
|
|
|
virtual void Copy();
|
|
|
|
virtual void Paste();
|
|
|
|
|
2011-07-02 15:07:46 +00:00
|
|
|
//Undo / redo functionality
|
2011-08-17 10:26:09 +00:00
|
|
|
virtual bool CanUndo() const;
|
|
|
|
virtual bool CanRedo() const;
|
2011-07-02 15:07:46 +00:00
|
|
|
virtual void Undo();
|
|
|
|
virtual void Redo();
|
|
|
|
|
2011-07-08 19:34:56 +00:00
|
|
|
//Editing functions
|
|
|
|
virtual void SetEditable(bool enable = true);
|
2011-08-17 10:26:09 +00:00
|
|
|
virtual bool IsEditable() const;
|
2011-07-08 19:34:56 +00:00
|
|
|
|
2011-07-09 14:31:29 +00:00
|
|
|
//Selection
|
|
|
|
virtual void SelectAll();
|
2011-08-17 10:26:09 +00:00
|
|
|
virtual bool HasSelection() const;
|
2011-07-09 14:31:29 +00:00
|
|
|
virtual void DeleteSelection();
|
2011-08-17 10:26:09 +00:00
|
|
|
virtual wxString GetSelectedText() const;
|
|
|
|
virtual wxString GetSelectedSource() const;
|
2011-07-15 09:36:08 +00:00
|
|
|
virtual void ClearSelection();
|
2011-07-09 14:31:29 +00:00
|
|
|
|
2011-07-15 12:38:47 +00:00
|
|
|
virtual void RunScript(const wxString& javascript);
|
2011-07-09 14:31:29 +00:00
|
|
|
|
2011-07-28 16:08:59 +00:00
|
|
|
//Virtual Filesystem Support
|
2011-08-14 12:15:34 +00:00
|
|
|
virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler);
|
2011-07-28 16:08:59 +00:00
|
|
|
|
2011-05-04 18:24:30 +00:00
|
|
|
// ---- IE-specific methods
|
|
|
|
|
|
|
|
// FIXME: I seem to be able to access remote webpages even in offline mode...
|
|
|
|
bool IsOfflineMode();
|
|
|
|
void SetOfflineMode(bool offline);
|
|
|
|
|
2011-08-17 10:26:09 +00:00
|
|
|
wxWebViewZoom GetIETextZoom() const;
|
2011-07-14 09:58:33 +00:00
|
|
|
void SetIETextZoom(wxWebViewZoom level);
|
2011-05-04 18:24:30 +00:00
|
|
|
|
2011-08-17 10:26:09 +00:00
|
|
|
wxWebViewZoom GetIEOpticalZoom() const;
|
2011-07-14 09:58:33 +00:00
|
|
|
void SetIEOpticalZoom(wxWebViewZoom level);
|
2011-05-04 18:24:30 +00:00
|
|
|
|
|
|
|
void onActiveXEvent(wxActiveXEvent& evt);
|
2011-07-11 09:35:41 +00:00
|
|
|
void onEraseBg(wxEraseEvent&) {}
|
2011-05-04 18:24:30 +00:00
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE();
|
|
|
|
|
|
|
|
private:
|
|
|
|
wxActiveXContainer* m_container;
|
|
|
|
wxAutomationObject m_ie;
|
|
|
|
IWebBrowser2* m_webBrowser;
|
|
|
|
DWORD m_dwCookie;
|
|
|
|
|
2011-07-14 09:58:33 +00:00
|
|
|
//We store the current zoom type;
|
|
|
|
wxWebViewZoomType m_zoomType;
|
|
|
|
|
2011-05-04 18:24:30 +00:00
|
|
|
/** The "Busy" property of IWebBrowser2 does not always return busy when
|
|
|
|
* we'd want it to; this variable may be set to true in cases where the
|
|
|
|
* Busy property is false but should be true.
|
|
|
|
*/
|
|
|
|
bool m_isBusy;
|
2011-07-01 10:01:45 +00:00
|
|
|
//We manage our own history, the history list contains the history items
|
|
|
|
//which are added as documentcomplete events arrive, unless we are loading
|
|
|
|
//an item from the history. The position is stored as an int, and reflects
|
|
|
|
//where we are in the history list.
|
2011-08-15 12:31:31 +00:00
|
|
|
wxVector<wxSharedPtr<wxWebViewHistoryItem> > m_historyList;
|
2011-06-30 19:57:26 +00:00
|
|
|
int m_historyPosition;
|
|
|
|
bool m_historyLoadingFromList;
|
|
|
|
bool m_historyEnabled;
|
|
|
|
|
2011-07-02 11:45:19 +00:00
|
|
|
//Generic helper functions for IHtmlDocument commands
|
2011-08-17 10:26:09 +00:00
|
|
|
bool CanExecCommand(wxString command) const;
|
2011-07-02 11:45:19 +00:00
|
|
|
void ExecCommand(wxString command);
|
2011-08-17 10:26:09 +00:00
|
|
|
IHTMLDocument2* GetDocument() const;
|
2011-07-02 11:45:19 +00:00
|
|
|
|
2011-08-01 15:49:05 +00:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxWebViewIE);
|
2011-05-04 18:24:30 +00:00
|
|
|
};
|
|
|
|
|
2011-08-03 18:31:48 +00:00
|
|
|
class VirtualProtocol : public IInternetProtocol
|
2011-07-22 12:31:18 +00:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
ULONG m_refCount;
|
|
|
|
IInternetProtocolSink* m_protocolSink;
|
|
|
|
wxString m_html;
|
|
|
|
VOID * fileP;
|
|
|
|
|
|
|
|
wxFSFile* m_file;
|
2011-08-14 12:15:34 +00:00
|
|
|
wxSharedPtr<wxWebViewHandler> m_handler;
|
2011-07-22 12:31:18 +00:00
|
|
|
|
|
|
|
public:
|
2011-08-14 12:15:34 +00:00
|
|
|
VirtualProtocol(wxSharedPtr<wxWebViewHandler> handler);
|
2011-07-22 12:31:18 +00:00
|
|
|
~VirtualProtocol();
|
|
|
|
|
|
|
|
//IUnknown
|
|
|
|
ULONG STDMETHODCALLTYPE AddRef();
|
|
|
|
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject);
|
|
|
|
ULONG STDMETHODCALLTYPE Release();
|
|
|
|
|
|
|
|
//IInternetProtocolRoot
|
2011-07-25 15:43:18 +00:00
|
|
|
HRESULT STDMETHODCALLTYPE Abort(HRESULT WXUNUSED(hrReason),
|
|
|
|
DWORD WXUNUSED(dwOptions))
|
2011-07-22 12:31:18 +00:00
|
|
|
{ return E_NOTIMPL; }
|
2011-07-25 15:43:18 +00:00
|
|
|
HRESULT STDMETHODCALLTYPE Continue(PROTOCOLDATA *WXUNUSED(pProtocolData))
|
2011-07-22 12:31:18 +00:00
|
|
|
{ return S_OK; }
|
|
|
|
HRESULT STDMETHODCALLTYPE Resume() { return S_OK; }
|
|
|
|
HRESULT STDMETHODCALLTYPE Start(LPCWSTR szUrl,
|
|
|
|
IInternetProtocolSink *pOIProtSink,
|
|
|
|
IInternetBindInfo *pOIBindInfo,
|
|
|
|
DWORD grfPI,
|
|
|
|
HANDLE_PTR dwReserved);
|
|
|
|
HRESULT STDMETHODCALLTYPE Suspend() { return S_OK; }
|
2011-07-25 15:43:18 +00:00
|
|
|
HRESULT STDMETHODCALLTYPE Terminate(DWORD WXUNUSED(dwOptions)) { return S_OK; }
|
2011-07-22 12:31:18 +00:00
|
|
|
|
|
|
|
//IInternetProtocol
|
2011-07-25 15:43:18 +00:00
|
|
|
HRESULT STDMETHODCALLTYPE LockRequest(DWORD WXUNUSED(dwOptions))
|
|
|
|
{ return S_OK; }
|
2011-07-22 12:31:18 +00:00
|
|
|
HRESULT STDMETHODCALLTYPE Read(void *pv, ULONG cb, ULONG *pcbRead);
|
2011-07-25 15:43:18 +00:00
|
|
|
HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER WXUNUSED(dlibMove),
|
|
|
|
DWORD WXUNUSED(dwOrigin),
|
|
|
|
ULARGE_INTEGER* WXUNUSED(plibNewPosition))
|
2011-07-22 12:31:18 +00:00
|
|
|
{ return E_FAIL; }
|
|
|
|
HRESULT STDMETHODCALLTYPE UnlockRequest() { return S_OK; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class ClassFactory : public IClassFactory
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
ULONG m_refCount;
|
|
|
|
public:
|
2011-08-14 12:15:34 +00:00
|
|
|
ClassFactory(wxSharedPtr<wxWebViewHandler> handler) : m_handler(handler) {}
|
2011-07-22 12:31:18 +00:00
|
|
|
//IUnknown
|
|
|
|
ULONG STDMETHODCALLTYPE AddRef();
|
|
|
|
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject);
|
|
|
|
ULONG STDMETHODCALLTYPE Release();
|
|
|
|
|
|
|
|
//IClassFactory
|
|
|
|
HRESULT STDMETHODCALLTYPE CreateInstance(IUnknown* pUnkOuter,
|
|
|
|
REFIID riid, void** ppvObject);
|
|
|
|
HRESULT STDMETHODCALLTYPE LockServer(BOOL fLock);
|
2011-07-28 16:08:59 +00:00
|
|
|
private:
|
2011-08-14 12:15:34 +00:00
|
|
|
wxSharedPtr<wxWebViewHandler> m_handler;
|
2011-07-22 12:31:18 +00:00
|
|
|
};
|
|
|
|
|
2011-08-01 10:10:20 +00:00
|
|
|
#endif // wxUSE_WEBVIEW_IE && defined(__WXMSW__)
|
2011-05-04 18:24:30 +00:00
|
|
|
|
|
|
|
#endif // wxWebViewIE_H
|