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