1 /////////////////////////////////////////////////////////////////////////////
2 // Name: include/wx/msw/webviewie.h
3 // Purpose: wxMSW IE wxWebView backend
4 // Author: Marianne Gagnon
6 // Copyright: (c) 2010 Marianne Gagnon, Steven Lamerton
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
17 #include "wx/control.h"
18 #include "wx/webview.h"
19 #include "wx/msw/ole/automtn.h"
20 #include "wx/msw/ole/activex.h"
21 #include "wx/sharedptr.h"
22 #include "wx/vector.h"
24 struct IHTMLDocument2
;
29 class WXDLLIMPEXP_WEB wxWebViewIE
: public wxWebView
35 wxWebViewIE(wxWindow
* parent
,
37 const wxString
& url
= wxWebViewDefaultURLStr
,
38 const wxPoint
& pos
= wxDefaultPosition
,
39 const wxSize
& size
= wxDefaultSize
,
41 const wxString
& name
= wxWebViewNameStr
)
43 Create(parent
, id
, url
, pos
, size
, style
, name
);
46 bool Create(wxWindow
* parent
,
48 const wxString
& url
= wxWebViewDefaultURLStr
,
49 const wxPoint
& pos
= wxDefaultPosition
,
50 const wxSize
& size
= wxDefaultSize
,
52 const wxString
& name
= wxWebViewNameStr
);
54 virtual void LoadUrl(const wxString
& url
);
55 virtual void LoadHistoryItem(wxSharedPtr
<wxWebHistoryItem
> item
);
56 virtual wxVector
<wxSharedPtr
<wxWebHistoryItem
> > GetBackwardHistory();
57 virtual wxVector
<wxSharedPtr
<wxWebHistoryItem
> > GetForwardHistory();
59 virtual bool CanGoForward();
60 virtual bool CanGoBack();
61 virtual void GoBack();
62 virtual void GoForward();
63 virtual void ClearHistory();
64 virtual void EnableHistory(bool enable
= true);
66 virtual void Reload(wxWebViewReloadFlags flags
= wxWEB_VIEW_RELOAD_DEFAULT
);
68 virtual wxString
GetPageSource();
69 virtual wxString
GetPageText();
71 virtual bool IsBusy();
72 virtual wxString
GetCurrentURL();
73 virtual wxString
GetCurrentTitle();
75 virtual void SetZoomType(wxWebViewZoomType
);
76 virtual wxWebViewZoomType
GetZoomType() const;
77 virtual bool CanSetZoomType(wxWebViewZoomType
) const;
81 virtual void SetPage(const wxString
& html
, const wxString
& baseUrl
);
83 virtual wxWebViewZoom
GetZoom();
84 virtual void SetZoom(wxWebViewZoom zoom
);
87 virtual bool CanCut();
88 virtual bool CanCopy();
89 virtual bool CanPaste();
94 //Undo / redo functionality
95 virtual bool CanUndo();
96 virtual bool CanRedo();
101 virtual void SetEditable(bool enable
= true);
102 virtual bool IsEditable();
105 virtual void SelectAll();
106 virtual bool HasSelection();
107 virtual void DeleteSelection();
108 virtual wxString
GetSelectedText();
109 virtual wxString
GetSelectedSource();
110 virtual void ClearSelection();
112 virtual void RunScript(const wxString
& javascript
);
114 // ---- IE-specific methods
116 // FIXME: I seem to be able to access remote webpages even in offline mode...
117 bool IsOfflineMode();
118 void SetOfflineMode(bool offline
);
120 wxWebViewZoom
GetIETextZoom();
121 void SetIETextZoom(wxWebViewZoom level
);
123 wxWebViewZoom
GetIEOpticalZoom();
124 void SetIEOpticalZoom(wxWebViewZoom level
);
126 void onActiveXEvent(wxActiveXEvent
& evt
);
127 void onEraseBg(wxEraseEvent
&) {}
129 DECLARE_EVENT_TABLE();
132 wxActiveXContainer
* m_container
;
133 wxAutomationObject m_ie
;
134 IWebBrowser2
* m_webBrowser
;
137 //We store the current zoom type;
138 wxWebViewZoomType m_zoomType
;
140 /** The "Busy" property of IWebBrowser2 does not always return busy when
141 * we'd want it to; this variable may be set to true in cases where the
142 * Busy property is false but should be true.
145 //We manage our own history, the history list contains the history items
146 //which are added as documentcomplete events arrive, unless we are loading
147 //an item from the history. The position is stored as an int, and reflects
148 //where we are in the history list.
149 wxVector
<wxSharedPtr
<wxWebHistoryItem
> > m_historyList
;
150 int m_historyPosition
;
151 bool m_historyLoadingFromList
;
152 bool m_historyEnabled
;
154 //Generic helper functions for IHtmlDocument commands
155 bool CanExecCommand(wxString command
);
156 void ExecCommand(wxString command
);
157 IHTMLDocument2
* GetDocument();
161 class VirtualProtocol
: public IInternetProtocol
165 IInternetProtocolSink
* m_protocolSink
;
170 wxFileSystem
* m_fileSys
;
177 ULONG STDMETHODCALLTYPE
AddRef();
178 HRESULT STDMETHODCALLTYPE
QueryInterface(REFIID riid
, void **ppvObject
);
179 ULONG STDMETHODCALLTYPE
Release();
181 //IInternetProtocolRoot
182 HRESULT STDMETHODCALLTYPE
Abort(HRESULT
WXUNUSED(hrReason
),
183 DWORD
WXUNUSED(dwOptions
))
184 { return E_NOTIMPL
; }
185 HRESULT STDMETHODCALLTYPE
Continue(PROTOCOLDATA
*WXUNUSED(pProtocolData
))
187 HRESULT STDMETHODCALLTYPE
Resume() { return S_OK
; }
188 HRESULT STDMETHODCALLTYPE
Start(LPCWSTR szUrl
,
189 IInternetProtocolSink
*pOIProtSink
,
190 IInternetBindInfo
*pOIBindInfo
,
192 HANDLE_PTR dwReserved
);
193 HRESULT STDMETHODCALLTYPE
Suspend() { return S_OK
; }
194 HRESULT STDMETHODCALLTYPE
Terminate(DWORD
WXUNUSED(dwOptions
)) { return S_OK
; }
197 HRESULT STDMETHODCALLTYPE
LockRequest(DWORD
WXUNUSED(dwOptions
))
199 HRESULT STDMETHODCALLTYPE
Read(void *pv
, ULONG cb
, ULONG
*pcbRead
);
200 HRESULT STDMETHODCALLTYPE
Seek(LARGE_INTEGER
WXUNUSED(dlibMove
),
201 DWORD
WXUNUSED(dwOrigin
),
202 ULARGE_INTEGER
* WXUNUSED(plibNewPosition
))
204 HRESULT STDMETHODCALLTYPE
UnlockRequest() { return S_OK
; }
207 class ClassFactory
: public IClassFactory
213 ULONG STDMETHODCALLTYPE
AddRef();
214 HRESULT STDMETHODCALLTYPE
QueryInterface(REFIID riid
, void **ppvObject
);
215 ULONG STDMETHODCALLTYPE
Release();
218 HRESULT STDMETHODCALLTYPE
CreateInstance(IUnknown
* pUnkOuter
,
219 REFIID riid
, void** ppvObject
);
220 HRESULT STDMETHODCALLTYPE
LockServer(BOOL fLock
);
223 #endif // wxUSE_WEBVIEW_IE
225 #endif // wxWebViewIE_H