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