]>
Commit | Line | Data |
---|---|---|
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" | |
e924e848 | 21 | #include "wx/msw/missing.h" |
74af0b13 | 22 | #include "wx/sharedptr.h" |
5cbda74b | 23 | #include "wx/vector.h" |
61b98a2d | 24 | |
22ca10fa | 25 | struct IHTMLDocument2; |
7d3f6b4d | 26 | class wxFSFile; |
29365629 | 27 | |
467d261e | 28 | class WXDLLIMPEXP_WEBVIEW wxWebViewIE : public wxWebView |
61b98a2d SL |
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 | ||
4d0dddc7 | 53 | virtual void LoadURL(const wxString& url); |
c13d6ac1 SL |
54 | virtual void LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item); |
55 | virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetBackwardHistory(); | |
56 | virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetForwardHistory(); | |
61b98a2d | 57 | |
e669ddde SL |
58 | virtual bool CanGoForward() const; |
59 | virtual bool CanGoBack() const; | |
61b98a2d SL |
60 | virtual void GoBack(); |
61 | virtual void GoForward(); | |
74af0b13 SL |
62 | virtual void ClearHistory(); |
63 | virtual void EnableHistory(bool enable = true); | |
61b98a2d | 64 | virtual void Stop(); |
a703012a | 65 | virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT); |
61b98a2d | 66 | |
e669ddde SL |
67 | virtual wxString GetPageSource() const; |
68 | virtual wxString GetPageText() const; | |
61b98a2d | 69 | |
e669ddde SL |
70 | virtual bool IsBusy() const; |
71 | virtual wxString GetCurrentURL() const; | |
72 | virtual wxString GetCurrentTitle() const; | |
61b98a2d SL |
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 | ||
e669ddde | 82 | virtual wxWebViewZoom GetZoom() const; |
61b98a2d SL |
83 | virtual void SetZoom(wxWebViewZoom zoom); |
84 | ||
4681a3ea | 85 | //Clipboard functions |
e669ddde SL |
86 | virtual bool CanCut() const; |
87 | virtual bool CanCopy() const; | |
88 | virtual bool CanPaste() const; | |
4681a3ea SL |
89 | virtual void Cut(); |
90 | virtual void Copy(); | |
91 | virtual void Paste(); | |
92 | ||
97e49559 | 93 | //Undo / redo functionality |
e669ddde SL |
94 | virtual bool CanUndo() const; |
95 | virtual bool CanRedo() const; | |
97e49559 SL |
96 | virtual void Undo(); |
97 | virtual void Redo(); | |
98 | ||
c7cbe308 SL |
99 | //Editing functions |
100 | virtual void SetEditable(bool enable = true); | |
e669ddde | 101 | virtual bool IsEditable() const; |
c7cbe308 | 102 | |
63a65070 SL |
103 | //Selection |
104 | virtual void SelectAll(); | |
e669ddde | 105 | virtual bool HasSelection() const; |
63a65070 | 106 | virtual void DeleteSelection(); |
e669ddde SL |
107 | virtual wxString GetSelectedText() const; |
108 | virtual wxString GetSelectedSource() const; | |
41933aa5 | 109 | virtual void ClearSelection(); |
63a65070 | 110 | |
c9ccc09c | 111 | virtual void RunScript(const wxString& javascript); |
63a65070 | 112 | |
29365629 | 113 | //Virtual Filesystem Support |
7d8d6163 | 114 | virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler); |
29365629 | 115 | |
61b98a2d SL |
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 | ||
e669ddde | 122 | wxWebViewZoom GetIETextZoom() const; |
c5f417cb | 123 | void SetIETextZoom(wxWebViewZoom level); |
61b98a2d | 124 | |
e669ddde | 125 | wxWebViewZoom GetIEOpticalZoom() const; |
c5f417cb | 126 | void SetIEOpticalZoom(wxWebViewZoom level); |
61b98a2d SL |
127 | |
128 | void onActiveXEvent(wxActiveXEvent& evt); | |
22ca10fa | 129 | void onEraseBg(wxEraseEvent&) {} |
61b98a2d SL |
130 | |
131 | DECLARE_EVENT_TABLE(); | |
132 | ||
133 | private: | |
134 | wxActiveXContainer* m_container; | |
135 | wxAutomationObject m_ie; | |
136 | IWebBrowser2* m_webBrowser; | |
137 | DWORD m_dwCookie; | |
61b98a2d | 138 | |
c5f417cb SL |
139 | //We store the current zoom type; |
140 | wxWebViewZoomType m_zoomType; | |
141 | ||
61b98a2d SL |
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; | |
3e7968c2 SL |
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. | |
c13d6ac1 | 151 | wxVector<wxSharedPtr<wxWebViewHistoryItem> > m_historyList; |
74af0b13 SL |
152 | int m_historyPosition; |
153 | bool m_historyLoadingFromList; | |
154 | bool m_historyEnabled; | |
155 | ||
4681a3ea | 156 | //Generic helper functions for IHtmlDocument commands |
e669ddde | 157 | bool CanExecCommand(wxString command) const; |
4681a3ea | 158 | void ExecCommand(wxString command); |
e669ddde | 159 | IHTMLDocument2* GetDocument() const; |
4681a3ea | 160 | |
cddf4541 | 161 | wxDECLARE_DYNAMIC_CLASS(wxWebViewIE); |
61b98a2d SL |
162 | }; |
163 | ||
b7d3a622 | 164 | class VirtualProtocol : public IInternetProtocol |
7d3f6b4d SL |
165 | { |
166 | protected: | |
167 | ULONG m_refCount; | |
168 | IInternetProtocolSink* m_protocolSink; | |
169 | wxString m_html; | |
170 | VOID * fileP; | |
171 | ||
172 | wxFSFile* m_file; | |
7d8d6163 | 173 | wxSharedPtr<wxWebViewHandler> m_handler; |
7d3f6b4d SL |
174 | |
175 | public: | |
7d8d6163 | 176 | VirtualProtocol(wxSharedPtr<wxWebViewHandler> handler); |
7d3f6b4d SL |
177 | ~VirtualProtocol(); |
178 | ||
179 | //IUnknown | |
180 | ULONG STDMETHODCALLTYPE AddRef(); | |
181 | HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); | |
182 | ULONG STDMETHODCALLTYPE Release(); | |
183 | ||
184 | //IInternetProtocolRoot | |
0995b9dc SL |
185 | HRESULT STDMETHODCALLTYPE Abort(HRESULT WXUNUSED(hrReason), |
186 | DWORD WXUNUSED(dwOptions)) | |
7d3f6b4d | 187 | { return E_NOTIMPL; } |
0995b9dc | 188 | HRESULT STDMETHODCALLTYPE Continue(PROTOCOLDATA *WXUNUSED(pProtocolData)) |
7d3f6b4d SL |
189 | { return S_OK; } |
190 | HRESULT STDMETHODCALLTYPE Resume() { return S_OK; } | |
191 | HRESULT STDMETHODCALLTYPE Start(LPCWSTR szUrl, | |
192 | IInternetProtocolSink *pOIProtSink, | |
193 | IInternetBindInfo *pOIBindInfo, | |
194 | DWORD grfPI, | |
195 | HANDLE_PTR dwReserved); | |
196 | HRESULT STDMETHODCALLTYPE Suspend() { return S_OK; } | |
0995b9dc | 197 | HRESULT STDMETHODCALLTYPE Terminate(DWORD WXUNUSED(dwOptions)) { return S_OK; } |
7d3f6b4d SL |
198 | |
199 | //IInternetProtocol | |
0995b9dc SL |
200 | HRESULT STDMETHODCALLTYPE LockRequest(DWORD WXUNUSED(dwOptions)) |
201 | { return S_OK; } | |
7d3f6b4d | 202 | HRESULT STDMETHODCALLTYPE Read(void *pv, ULONG cb, ULONG *pcbRead); |
0995b9dc SL |
203 | HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER WXUNUSED(dlibMove), |
204 | DWORD WXUNUSED(dwOrigin), | |
205 | ULARGE_INTEGER* WXUNUSED(plibNewPosition)) | |
7d3f6b4d SL |
206 | { return E_FAIL; } |
207 | HRESULT STDMETHODCALLTYPE UnlockRequest() { return S_OK; } | |
208 | }; | |
209 | ||
210 | class ClassFactory : public IClassFactory | |
211 | { | |
212 | private: | |
213 | ULONG m_refCount; | |
214 | public: | |
7d8d6163 | 215 | ClassFactory(wxSharedPtr<wxWebViewHandler> handler) : m_handler(handler) {} |
7d3f6b4d SL |
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); | |
29365629 | 225 | private: |
7d8d6163 | 226 | wxSharedPtr<wxWebViewHandler> m_handler; |
7d3f6b4d SL |
227 | }; |
228 | ||
9d2f31db | 229 | #endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE && defined(__WXMSW__) |
61b98a2d SL |
230 | |
231 | #endif // wxWebViewIE_H |