1 /////////////////////////////////////////////////////////////////////////////
2 // Name: include/wx/msw/webviewie.h
3 // Purpose: wxMSW IE wxWebView backend
4 // Author: Marianne Gagnon
6 // Copyright: (c) 2010 Marianne Gagnon, Steven Lamerton
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
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"
24 struct IHTMLDocument2
;
29 class WXDLLIMPEXP_WEB wxWebViewIE
: public wxWebView
35 wxWebViewIE(wxWindow
* parent
,
37 const wxString
& url
= wxWebViewDefaultURLStr
,
38 const wxPoint
& pos
= wxDefaultPosition
,
39 const wxSize
& size
= wxDefaultSize
,
41 const wxString
& name
= wxWebViewNameStr
)
43 Create(parent
, id
, url
, pos
, size
, style
, name
);
46 bool Create(wxWindow
* parent
,
48 const wxString
& url
= wxWebViewDefaultURLStr
,
49 const wxPoint
& pos
= wxDefaultPosition
,
50 const wxSize
& size
= wxDefaultSize
,
52 const wxString
& name
= wxWebViewNameStr
);
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();
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);
66 virtual void Reload(wxWebViewReloadFlags flags
= wxWEB_VIEW_RELOAD_DEFAULT
);
68 virtual wxString
GetPageSource();
69 virtual wxString
GetPageText();
71 virtual bool IsBusy();
72 virtual wxString
GetCurrentURL();
73 virtual wxString
GetCurrentTitle();
75 virtual void SetZoomType(wxWebViewZoomType
);
76 virtual wxWebViewZoomType
GetZoomType() const;
77 virtual bool CanSetZoomType(wxWebViewZoomType
) const;
81 virtual void SetPage(const wxString
& html
, const wxString
& baseUrl
);
83 virtual wxWebViewZoom
GetZoom();
84 virtual void SetZoom(wxWebViewZoom zoom
);
87 virtual bool CanCut();
88 virtual bool CanCopy();
89 virtual bool CanPaste();
94 //Undo / redo functionality
95 virtual bool CanUndo();
96 virtual bool CanRedo();
101 virtual void SetEditable(bool enable
= true);
102 virtual bool IsEditable();
105 virtual void SelectAll();
106 virtual bool HasSelection();
107 virtual void DeleteSelection();
108 virtual wxString
GetSelectedText();
109 virtual wxString
GetSelectedSource();
110 virtual void ClearSelection();
112 virtual void RunScript(const wxString
& javascript
);
114 // ---- IE-specific methods
116 // FIXME: I seem to be able to access remote webpages even in offline mode...
117 bool IsOfflineMode();
118 void SetOfflineMode(bool offline
);
120 wxWebViewZoom
GetIETextZoom();
121 void SetIETextZoom(wxWebViewZoom level
);
123 wxWebViewZoom
GetIEOpticalZoom();
124 void SetIEOpticalZoom(wxWebViewZoom level
);
126 void onActiveXEvent(wxActiveXEvent
& evt
);
127 void onEraseBg(wxEraseEvent
&) {}
129 DECLARE_EVENT_TABLE();
132 wxActiveXContainer
* m_container
;
133 wxAutomationObject m_ie
;
134 IWebBrowser2
* m_webBrowser
;
136 bool m_canNavigateBack
;
137 bool m_canNavigateForward
;
139 //We store the current zoom type;
140 wxWebViewZoomType m_zoomType
;
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.
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
<wxWebHistoryItem
> > m_historyList
;
152 int m_historyPosition
;
153 bool m_historyLoadingFromList
;
154 bool m_historyEnabled
;
156 //Generic helper functions for IHtmlDocument commands
157 bool CanExecCommand(wxString command
);
158 void ExecCommand(wxString command
);
159 IHTMLDocument2
* GetDocument();
163 class VirtualProtocol
: public IInternetProtocol
167 IInternetProtocolSink
* m_protocolSink
;
172 wxFileSystem
* m_fileSys
;
179 ULONG STDMETHODCALLTYPE
AddRef();
180 HRESULT STDMETHODCALLTYPE
QueryInterface(REFIID riid
, void **ppvObject
);
181 ULONG STDMETHODCALLTYPE
Release();
183 //IInternetProtocolRoot
184 HRESULT STDMETHODCALLTYPE
Abort(HRESULT hrReason
, DWORD dwOptions
)
185 { return E_NOTIMPL
; }
186 HRESULT STDMETHODCALLTYPE
Continue(PROTOCOLDATA
*pProtocolData
)
188 HRESULT STDMETHODCALLTYPE
Resume() { return S_OK
; }
189 HRESULT STDMETHODCALLTYPE
Start(LPCWSTR szUrl
,
190 IInternetProtocolSink
*pOIProtSink
,
191 IInternetBindInfo
*pOIBindInfo
,
193 HANDLE_PTR dwReserved
);
194 HRESULT STDMETHODCALLTYPE
Suspend() { return S_OK
; }
195 HRESULT STDMETHODCALLTYPE
Terminate(DWORD dwOptions
) { return S_OK
; }
198 HRESULT STDMETHODCALLTYPE
LockRequest(DWORD dwOptions
) { return S_OK
; }
199 HRESULT STDMETHODCALLTYPE
Read(void *pv
, ULONG cb
, ULONG
*pcbRead
);
200 HRESULT STDMETHODCALLTYPE
Seek(LARGE_INTEGER dlibMove
, DWORD dwOrigin
,
201 ULARGE_INTEGER
* plibNewPosition
)
203 HRESULT STDMETHODCALLTYPE
UnlockRequest() { return S_OK
; }
206 class ClassFactory
: public IClassFactory
212 ULONG STDMETHODCALLTYPE
AddRef();
213 HRESULT STDMETHODCALLTYPE
QueryInterface(REFIID riid
, void **ppvObject
);
214 ULONG STDMETHODCALLTYPE
Release();
217 HRESULT STDMETHODCALLTYPE
CreateInstance(IUnknown
* pUnkOuter
,
218 REFIID riid
, void** ppvObject
);
219 HRESULT STDMETHODCALLTYPE
LockServer(BOOL fLock
);
222 #endif // wxUSE_WEBVIEW_IE
224 #endif // wxWebViewIE_H