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