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