]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/webview_ie.h
Include some more declarations & defines.
[wxWidgets.git] / include / wx / msw / webview_ie.h
CommitLineData
61b98a2d
SL
1/////////////////////////////////////////////////////////////////////////////
2// Name: include/wx/msw/webviewie.h
3// Purpose: wxMSW IE wxWebView backend
4// Author: Marianne Gagnon
5// Id: $Id$
153530af 6// Copyright: (c) 2010 Marianne Gagnon, 2011 Steven Lamerton
61b98a2d
SL
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10#ifndef wxWebViewIE_H
11#define wxWebViewIE_H
12
13#include "wx/setup.h"
14
9d2f31db 15#if wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE && defined(__WXMSW__)
61b98a2d
SL
16
17#include "wx/control.h"
18#include "wx/webview.h"
19#include "wx/msw/ole/automtn.h"
20#include "wx/msw/ole/activex.h"
9f194b9d 21#include "wx/msw/ole/oleutils.h"
97aa7b99 22#include "wx/msw/wrapwin.h"
e924e848 23#include "wx/msw/missing.h"
74af0b13 24#include "wx/sharedptr.h"
5cbda74b 25#include "wx/vector.h"
61b98a2d 26
f559d1a2
VZ
27/* Classes and definitions from urlmon.h vary in their
28 * completeness between compilers and versions of compilers.
29 * We implement our own versions here which should work
30 * for all compilers. The definitions are taken from the
31 * mingw-w64 headers which are public domain.
32 */
33
34#ifndef REFRESH_NORMAL
35#define REFRESH_NORMAL 0
36#endif
37
38#ifndef REFRESH_COMPLETELY
39#define REFRESH_COMPLETELY 3
40#endif
41
42typedef enum __wxMIDL_IBindStatusCallback_0006
43{
44 wxBSCF_FIRSTDATANOTIFICATION = 0x1,
45 wxBSCF_INTERMEDIATEDATANOTIFICATION = 0x2,
46 wxBSCF_LASTDATANOTIFICATION = 0x4,
47 wxBSCF_DATAFULLYAVAILABLE = 0x8,
48 wxBSCF_AVAILABLEDATASIZEUNKNOWN = 0x10
49} wxBSCF;
50
51EXTERN_C const IID CLSID_FileProtocol;
52
53typedef struct _tagwxBINDINFO
54{
55 ULONG cbSize;
56 LPWSTR szExtraInfo;
57 STGMEDIUM stgmedData;
58 DWORD grfBindInfoF;
59 DWORD dwBindVerb;
60 LPWSTR szCustomVerb;
61 DWORD cbstgmedData;
62 DWORD dwOptions;
63 DWORD dwOptionsFlags;
64 DWORD dwCodePage;
65 SECURITY_ATTRIBUTES securityAttributes;
66 IID iid;
67 IUnknown *pUnk;
68 DWORD dwReserved;
69} wxBINDINFO;
70
71typedef struct _tagwxPROTOCOLDATA
72{
73 DWORD grfFlags;
74 DWORD dwState;
75 LPVOID pData;
76 ULONG cbData;
77} wxPROTOCOLDATA;
78
79class wxIInternetBindInfo : public IUnknown
80{
81public:
82 virtual HRESULT wxSTDCALL GetBindInfo(DWORD *grfBINDF,wxBINDINFO *pbindinfo) = 0;
83 virtual HRESULT wxSTDCALL GetBindString(ULONG ulStringType,LPOLESTR *ppwzStr,
84 ULONG cEl,ULONG *pcElFetched) = 0;
85};
86
87class wxIInternetProtocolSink : public IUnknown
88{
89public:
90 virtual HRESULT wxSTDCALL Switch(wxPROTOCOLDATA *pProtocolData) = 0;
91 virtual HRESULT wxSTDCALL ReportProgress(ULONG ulStatusCode,
92 LPCWSTR szStatusText) = 0;
93 virtual HRESULT wxSTDCALL ReportData(DWORD grfBSCF,ULONG ulProgress,
94 ULONG ulProgressMax) = 0;
95 virtual HRESULT wxSTDCALL ReportResult(HRESULT hrResult,DWORD dwError,
96 LPCWSTR szResult) = 0;
97};
98
99class wxIInternetProtocolRoot : public IUnknown
100{
101public:
102 virtual HRESULT wxSTDCALL Start(LPCWSTR szUrl,wxIInternetProtocolSink *pOIProtSink,
103 wxIInternetBindInfo *pOIBindInfo,DWORD grfPI,
104 HANDLE_PTR dwReserved) = 0;
105 virtual HRESULT wxSTDCALL Continue(wxPROTOCOLDATA *pProtocolData) = 0;
106 virtual HRESULT wxSTDCALL Abort(HRESULT hrReason,DWORD dwOptions) = 0;
107 virtual HRESULT wxSTDCALL Terminate(DWORD dwOptions) = 0;
108 virtual HRESULT wxSTDCALL Suspend(void) = 0;
109 virtual HRESULT wxSTDCALL Resume(void) = 0;
110};
111
112
113class wxIInternetProtocol : public wxIInternetProtocolRoot
114{
115public:
116 virtual HRESULT wxSTDCALL Read(void *pv,ULONG cb,ULONG *pcbRead) = 0;
117 virtual HRESULT wxSTDCALL Seek(LARGE_INTEGER dlibMove,DWORD dwOrigin,
118 ULARGE_INTEGER *plibNewPosition) = 0;
119 virtual HRESULT wxSTDCALL LockRequest(DWORD dwOptions) = 0;
120 virtual HRESULT wxSTDCALL UnlockRequest(void) = 0;
121};
122
123
124class wxIInternetSession : public IUnknown
125{
126 public:
127 virtual HRESULT wxSTDCALL RegisterNameSpace(IClassFactory *pCF,REFCLSID rclsid,
128 LPCWSTR pwzProtocol,
129 ULONG cPatterns,
130 const LPCWSTR *ppwzPatterns,
131 DWORD dwReserved) = 0;
132 virtual HRESULT wxSTDCALL UnregisterNameSpace(IClassFactory *pCF,
133 LPCWSTR pszProtocol) = 0;
134 virtual HRESULT wxSTDCALL RegisterMimeFilter(IClassFactory *pCF,
135 REFCLSID rclsid,
136 LPCWSTR pwzType) = 0;
137 virtual HRESULT wxSTDCALL UnregisterMimeFilter(IClassFactory *pCF,
138 LPCWSTR pwzType) = 0;
139 virtual HRESULT wxSTDCALL CreateBinding(LPBC pBC,LPCWSTR szUrl,
140 IUnknown *pUnkOuter,IUnknown **ppUnk,
141 wxIInternetProtocol **ppOInetProt,
142 DWORD dwOption) = 0;
143 virtual HRESULT wxSTDCALL SetSessionOption(DWORD dwOption,LPVOID pBuffer,
144 DWORD dwBufferLength,
145 DWORD dwReserved) = 0;
146 virtual HRESULT wxSTDCALL GetSessionOption(DWORD dwOption,LPVOID pBuffer,
147 DWORD *pdwBufferLength,
148 DWORD dwReserved) = 0;
149};
150
151/* END OF URLMON.H implementation */
152
22ca10fa 153struct IHTMLDocument2;
7d3f6b4d 154class wxFSFile;
39498710 155class ClassFactory;
29365629 156
467d261e 157class WXDLLIMPEXP_WEBVIEW wxWebViewIE : public wxWebView
61b98a2d
SL
158{
159public:
160
161 wxWebViewIE() {}
162
163 wxWebViewIE(wxWindow* parent,
164 wxWindowID id,
165 const wxString& url = wxWebViewDefaultURLStr,
166 const wxPoint& pos = wxDefaultPosition,
167 const wxSize& size = wxDefaultSize,
168 long style = 0,
169 const wxString& name = wxWebViewNameStr)
170 {
171 Create(parent, id, url, pos, size, style, name);
172 }
173
39498710
SL
174 ~wxWebViewIE();
175
61b98a2d
SL
176 bool Create(wxWindow* parent,
177 wxWindowID id,
178 const wxString& url = wxWebViewDefaultURLStr,
179 const wxPoint& pos = wxDefaultPosition,
180 const wxSize& size = wxDefaultSize,
181 long style = 0,
182 const wxString& name = wxWebViewNameStr);
183
4d0dddc7 184 virtual void LoadURL(const wxString& url);
c13d6ac1
SL
185 virtual void LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item);
186 virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetBackwardHistory();
187 virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetForwardHistory();
61b98a2d 188
e669ddde
SL
189 virtual bool CanGoForward() const;
190 virtual bool CanGoBack() const;
61b98a2d
SL
191 virtual void GoBack();
192 virtual void GoForward();
74af0b13
SL
193 virtual void ClearHistory();
194 virtual void EnableHistory(bool enable = true);
61b98a2d 195 virtual void Stop();
a703012a 196 virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT);
61b98a2d 197
e669ddde
SL
198 virtual wxString GetPageSource() const;
199 virtual wxString GetPageText() const;
61b98a2d 200
e669ddde
SL
201 virtual bool IsBusy() const;
202 virtual wxString GetCurrentURL() const;
203 virtual wxString GetCurrentTitle() const;
61b98a2d
SL
204
205 virtual void SetZoomType(wxWebViewZoomType);
206 virtual wxWebViewZoomType GetZoomType() const;
207 virtual bool CanSetZoomType(wxWebViewZoomType) const;
208
209 virtual void Print();
210
211 virtual void SetPage(const wxString& html, const wxString& baseUrl);
212
e669ddde 213 virtual wxWebViewZoom GetZoom() const;
61b98a2d
SL
214 virtual void SetZoom(wxWebViewZoom zoom);
215
4681a3ea 216 //Clipboard functions
e669ddde
SL
217 virtual bool CanCut() const;
218 virtual bool CanCopy() const;
219 virtual bool CanPaste() const;
4681a3ea
SL
220 virtual void Cut();
221 virtual void Copy();
222 virtual void Paste();
223
97e49559 224 //Undo / redo functionality
e669ddde
SL
225 virtual bool CanUndo() const;
226 virtual bool CanRedo() const;
97e49559
SL
227 virtual void Undo();
228 virtual void Redo();
229
c7cbe308
SL
230 //Editing functions
231 virtual void SetEditable(bool enable = true);
e669ddde 232 virtual bool IsEditable() const;
c7cbe308 233
63a65070
SL
234 //Selection
235 virtual void SelectAll();
e669ddde 236 virtual bool HasSelection() const;
63a65070 237 virtual void DeleteSelection();
e669ddde
SL
238 virtual wxString GetSelectedText() const;
239 virtual wxString GetSelectedSource() const;
41933aa5 240 virtual void ClearSelection();
63a65070 241
c9ccc09c 242 virtual void RunScript(const wxString& javascript);
63a65070 243
29365629 244 //Virtual Filesystem Support
7d8d6163 245 virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler);
29365629 246
61b98a2d
SL
247 // ---- IE-specific methods
248
249 // FIXME: I seem to be able to access remote webpages even in offline mode...
250 bool IsOfflineMode();
251 void SetOfflineMode(bool offline);
252
e669ddde 253 wxWebViewZoom GetIETextZoom() const;
c5f417cb 254 void SetIETextZoom(wxWebViewZoom level);
61b98a2d 255
e669ddde 256 wxWebViewZoom GetIEOpticalZoom() const;
c5f417cb 257 void SetIEOpticalZoom(wxWebViewZoom level);
61b98a2d
SL
258
259 void onActiveXEvent(wxActiveXEvent& evt);
22ca10fa 260 void onEraseBg(wxEraseEvent&) {}
61b98a2d
SL
261
262 DECLARE_EVENT_TABLE();
263
264private:
265 wxActiveXContainer* m_container;
266 wxAutomationObject m_ie;
267 IWebBrowser2* m_webBrowser;
268 DWORD m_dwCookie;
61b98a2d 269
c5f417cb
SL
270 //We store the current zoom type;
271 wxWebViewZoomType m_zoomType;
272
61b98a2d
SL
273 /** The "Busy" property of IWebBrowser2 does not always return busy when
274 * we'd want it to; this variable may be set to true in cases where the
275 * Busy property is false but should be true.
276 */
277 bool m_isBusy;
60eabdbe 278 //We manage our own history, the history list contains the history items
3e7968c2
SL
279 //which are added as documentcomplete events arrive, unless we are loading
280 //an item from the history. The position is stored as an int, and reflects
281 //where we are in the history list.
c13d6ac1 282 wxVector<wxSharedPtr<wxWebViewHistoryItem> > m_historyList;
39498710 283 wxVector<ClassFactory*> m_factories;
74af0b13
SL
284 int m_historyPosition;
285 bool m_historyLoadingFromList;
286 bool m_historyEnabled;
287
4681a3ea 288 //Generic helper functions for IHtmlDocument commands
e669ddde 289 bool CanExecCommand(wxString command) const;
4681a3ea 290 void ExecCommand(wxString command);
e669ddde 291 IHTMLDocument2* GetDocument() const;
4681a3ea 292
cddf4541 293 wxDECLARE_DYNAMIC_CLASS(wxWebViewIE);
61b98a2d
SL
294};
295
f559d1a2 296class VirtualProtocol : public wxIInternetProtocol
7d3f6b4d
SL
297{
298protected:
f559d1a2 299 wxIInternetProtocolSink* m_protocolSink;
7d3f6b4d
SL
300 wxString m_html;
301 VOID * fileP;
302
303 wxFSFile* m_file;
7d8d6163 304 wxSharedPtr<wxWebViewHandler> m_handler;
7d3f6b4d
SL
305
306public:
7d8d6163 307 VirtualProtocol(wxSharedPtr<wxWebViewHandler> handler);
9f194b9d 308 ~VirtualProtocol() {};
7d3f6b4d
SL
309
310 //IUnknown
9f194b9d 311 DECLARE_IUNKNOWN_METHODS;
7d3f6b4d
SL
312
313 //IInternetProtocolRoot
60eabdbe 314 HRESULT STDMETHODCALLTYPE Abort(HRESULT WXUNUSED(hrReason),
0995b9dc 315 DWORD WXUNUSED(dwOptions))
7d3f6b4d 316 { return E_NOTIMPL; }
f559d1a2 317 HRESULT STDMETHODCALLTYPE Continue(wxPROTOCOLDATA *WXUNUSED(pProtocolData))
7d3f6b4d
SL
318 { return S_OK; }
319 HRESULT STDMETHODCALLTYPE Resume() { return S_OK; }
60eabdbe 320 HRESULT STDMETHODCALLTYPE Start(LPCWSTR szUrl,
f559d1a2
VZ
321 wxIInternetProtocolSink *pOIProtSink,
322 wxIInternetBindInfo *pOIBindInfo,
60eabdbe 323 DWORD grfPI,
7d3f6b4d
SL
324 HANDLE_PTR dwReserved);
325 HRESULT STDMETHODCALLTYPE Suspend() { return S_OK; }
0995b9dc 326 HRESULT STDMETHODCALLTYPE Terminate(DWORD WXUNUSED(dwOptions)) { return S_OK; }
7d3f6b4d
SL
327
328 //IInternetProtocol
60eabdbe 329 HRESULT STDMETHODCALLTYPE LockRequest(DWORD WXUNUSED(dwOptions))
0995b9dc 330 { return S_OK; }
7d3f6b4d 331 HRESULT STDMETHODCALLTYPE Read(void *pv, ULONG cb, ULONG *pcbRead);
60eabdbe
VZ
332 HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER WXUNUSED(dlibMove),
333 DWORD WXUNUSED(dwOrigin),
334 ULARGE_INTEGER* WXUNUSED(plibNewPosition))
7d3f6b4d
SL
335 { return E_FAIL; }
336 HRESULT STDMETHODCALLTYPE UnlockRequest() { return S_OK; }
337};
338
339class ClassFactory : public IClassFactory
340{
7d3f6b4d 341public:
9f194b9d 342 ClassFactory(wxSharedPtr<wxWebViewHandler> handler) : m_handler(handler) {}
7d3f6b4d
SL
343
344 //IClassFactory
60eabdbe 345 HRESULT STDMETHODCALLTYPE CreateInstance(IUnknown* pUnkOuter,
7d3f6b4d
SL
346 REFIID riid, void** ppvObject);
347 HRESULT STDMETHODCALLTYPE LockServer(BOOL fLock);
9f194b9d
SL
348
349 //IUnknown
350 DECLARE_IUNKNOWN_METHODS;
351
29365629 352private:
7d8d6163 353 wxSharedPtr<wxWebViewHandler> m_handler;
7d3f6b4d
SL
354};
355
9d2f31db 356#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE && defined(__WXMSW__)
61b98a2d
SL
357
358#endif // wxWebViewIE_H