Remove copied class definitions from missing.h. Disable custom scheme handling under...
[wxWidgets.git] / include / wx / msw / webview_ie.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: include/wx/msw/webviewie.h
3 // Purpose: wxMSW IE wxWebView backend
4 // Author: Marianne Gagnon
5 // Id: $Id$
6 // Copyright: (c) 2010 Marianne Gagnon, 2011 Steven Lamerton
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifndef wxWebViewIE_H
11 #define wxWebViewIE_H
12
13 #include "wx/setup.h"
14
15 #if wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE && defined(__WXMSW__)
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"
21 #include "wx/msw/missing.h"
22 #include "wx/sharedptr.h"
23 #include "wx/vector.h"
24
25 struct IHTMLDocument2;
26 class wxFSFile;
27
28 class WXDLLIMPEXP_WEBVIEW wxWebViewIE : public wxWebView
29 {
30 public:
31
32 wxWebViewIE() {}
33
34 wxWebViewIE(wxWindow* parent,
35 wxWindowID id,
36 const wxString& url = wxWebViewDefaultURLStr,
37 const wxPoint& pos = wxDefaultPosition,
38 const wxSize& size = wxDefaultSize,
39 long style = 0,
40 const wxString& name = wxWebViewNameStr)
41 {
42 Create(parent, id, url, pos, size, style, name);
43 }
44
45 bool Create(wxWindow* parent,
46 wxWindowID id,
47 const wxString& url = wxWebViewDefaultURLStr,
48 const wxPoint& pos = wxDefaultPosition,
49 const wxSize& size = wxDefaultSize,
50 long style = 0,
51 const wxString& name = wxWebViewNameStr);
52
53 virtual void LoadURL(const wxString& url);
54 virtual void LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item);
55 virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetBackwardHistory();
56 virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetForwardHistory();
57
58 virtual bool CanGoForward() const;
59 virtual bool CanGoBack() const;
60 virtual void GoBack();
61 virtual void GoForward();
62 virtual void ClearHistory();
63 virtual void EnableHistory(bool enable = true);
64 virtual void Stop();
65 virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT);
66
67 virtual wxString GetPageSource() const;
68 virtual wxString GetPageText() const;
69
70 virtual bool IsBusy() const;
71 virtual wxString GetCurrentURL() const;
72 virtual wxString GetCurrentTitle() const;
73
74 virtual void SetZoomType(wxWebViewZoomType);
75 virtual wxWebViewZoomType GetZoomType() const;
76 virtual bool CanSetZoomType(wxWebViewZoomType) const;
77
78 virtual void Print();
79
80 virtual void SetPage(const wxString& html, const wxString& baseUrl);
81
82 virtual wxWebViewZoom GetZoom() const;
83 virtual void SetZoom(wxWebViewZoom zoom);
84
85 //Clipboard functions
86 virtual bool CanCut() const;
87 virtual bool CanCopy() const;
88 virtual bool CanPaste() const;
89 virtual void Cut();
90 virtual void Copy();
91 virtual void Paste();
92
93 //Undo / redo functionality
94 virtual bool CanUndo() const;
95 virtual bool CanRedo() const;
96 virtual void Undo();
97 virtual void Redo();
98
99 //Editing functions
100 virtual void SetEditable(bool enable = true);
101 virtual bool IsEditable() const;
102
103 //Selection
104 virtual void SelectAll();
105 virtual bool HasSelection() const;
106 virtual void DeleteSelection();
107 virtual wxString GetSelectedText() const;
108 virtual wxString GetSelectedSource() const;
109 virtual void ClearSelection();
110
111 virtual void RunScript(const wxString& javascript);
112
113 //Virtual Filesystem Support
114 virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler);
115
116 // ---- IE-specific methods
117
118 // FIXME: I seem to be able to access remote webpages even in offline mode...
119 bool IsOfflineMode();
120 void SetOfflineMode(bool offline);
121
122 wxWebViewZoom GetIETextZoom() const;
123 void SetIETextZoom(wxWebViewZoom level);
124
125 wxWebViewZoom GetIEOpticalZoom() const;
126 void SetIEOpticalZoom(wxWebViewZoom level);
127
128 void onActiveXEvent(wxActiveXEvent& evt);
129 void onEraseBg(wxEraseEvent&) {}
130
131 DECLARE_EVENT_TABLE();
132
133 private:
134 wxActiveXContainer* m_container;
135 wxAutomationObject m_ie;
136 IWebBrowser2* m_webBrowser;
137 DWORD m_dwCookie;
138
139 //We store the current zoom type;
140 wxWebViewZoomType m_zoomType;
141
142 /** The "Busy" property of IWebBrowser2 does not always return busy when
143 * we'd want it to; this variable may be set to true in cases where the
144 * Busy property is false but should be true.
145 */
146 bool m_isBusy;
147 //We manage our own history, the history list contains the history items
148 //which are added as documentcomplete events arrive, unless we are loading
149 //an item from the history. The position is stored as an int, and reflects
150 //where we are in the history list.
151 wxVector<wxSharedPtr<wxWebViewHistoryItem> > m_historyList;
152 int m_historyPosition;
153 bool m_historyLoadingFromList;
154 bool m_historyEnabled;
155
156 //Generic helper functions for IHtmlDocument commands
157 bool CanExecCommand(wxString command) const;
158 void ExecCommand(wxString command);
159 IHTMLDocument2* GetDocument() const;
160
161 wxDECLARE_DYNAMIC_CLASS(wxWebViewIE);
162 };
163
164 #ifndef __MINGW32__
165
166 class VirtualProtocol : public IInternetProtocol
167 {
168 protected:
169 ULONG m_refCount;
170 IInternetProtocolSink* m_protocolSink;
171 wxString m_html;
172 VOID * fileP;
173
174 wxFSFile* m_file;
175 wxSharedPtr<wxWebViewHandler> m_handler;
176
177 public:
178 VirtualProtocol(wxSharedPtr<wxWebViewHandler> handler);
179 ~VirtualProtocol();
180
181 //IUnknown
182 ULONG STDMETHODCALLTYPE AddRef();
183 HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject);
184 ULONG STDMETHODCALLTYPE Release();
185
186 //IInternetProtocolRoot
187 HRESULT STDMETHODCALLTYPE Abort(HRESULT WXUNUSED(hrReason),
188 DWORD WXUNUSED(dwOptions))
189 { return E_NOTIMPL; }
190 HRESULT STDMETHODCALLTYPE Continue(PROTOCOLDATA *WXUNUSED(pProtocolData))
191 { return S_OK; }
192 HRESULT STDMETHODCALLTYPE Resume() { return S_OK; }
193 HRESULT STDMETHODCALLTYPE Start(LPCWSTR szUrl,
194 IInternetProtocolSink *pOIProtSink,
195 IInternetBindInfo *pOIBindInfo,
196 DWORD grfPI,
197 HANDLE_PTR dwReserved);
198 HRESULT STDMETHODCALLTYPE Suspend() { return S_OK; }
199 HRESULT STDMETHODCALLTYPE Terminate(DWORD WXUNUSED(dwOptions)) { return S_OK; }
200
201 //IInternetProtocol
202 HRESULT STDMETHODCALLTYPE LockRequest(DWORD WXUNUSED(dwOptions))
203 { return S_OK; }
204 HRESULT STDMETHODCALLTYPE Read(void *pv, ULONG cb, ULONG *pcbRead);
205 HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER WXUNUSED(dlibMove),
206 DWORD WXUNUSED(dwOrigin),
207 ULARGE_INTEGER* WXUNUSED(plibNewPosition))
208 { return E_FAIL; }
209 HRESULT STDMETHODCALLTYPE UnlockRequest() { return S_OK; }
210 };
211
212 class ClassFactory : public IClassFactory
213 {
214 public:
215 ClassFactory(wxSharedPtr<wxWebViewHandler> handler) : m_handler(handler), m_refCount(0) {}
216 //IUnknown
217 ULONG STDMETHODCALLTYPE AddRef();
218 HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject);
219 ULONG STDMETHODCALLTYPE Release();
220
221 //IClassFactory
222 HRESULT STDMETHODCALLTYPE CreateInstance(IUnknown* pUnkOuter,
223 REFIID riid, void** ppvObject);
224 HRESULT STDMETHODCALLTYPE LockServer(BOOL fLock);
225 private:
226 ULONG m_refCount;
227 wxSharedPtr<wxWebViewHandler> m_handler;
228 };
229
230 #endif // __MINGW32__
231
232 #endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE && defined(__WXMSW__)
233
234 #endif // wxWebViewIE_H