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"
26 class WXDLLIMPEXP_WEB wxWebViewIE
: public wxWebView
32 wxWebViewIE(wxWindow
* parent
,
34 const wxString
& url
= wxWebViewDefaultURLStr
,
35 const wxPoint
& pos
= wxDefaultPosition
,
36 const wxSize
& size
= wxDefaultSize
,
38 const wxString
& name
= wxWebViewNameStr
)
40 Create(parent
, id
, url
, pos
, size
, style
, name
);
43 bool Create(wxWindow
* parent
,
45 const wxString
& url
= wxWebViewDefaultURLStr
,
46 const wxPoint
& pos
= wxDefaultPosition
,
47 const wxSize
& size
= wxDefaultSize
,
49 const wxString
& name
= wxWebViewNameStr
);
51 virtual void LoadUrl(const wxString
& url
);
52 virtual void LoadHistoryItem(wxSharedPtr
<wxWebHistoryItem
> item
);
53 virtual wxVector
<wxSharedPtr
<wxWebHistoryItem
> > GetBackwardHistory();
54 virtual wxVector
<wxSharedPtr
<wxWebHistoryItem
> > GetForwardHistory();
56 virtual bool CanGoForward();
57 virtual bool CanGoBack();
58 virtual void GoBack();
59 virtual void GoForward();
60 virtual void ClearHistory();
61 virtual void EnableHistory(bool enable
= true);
63 virtual void Reload(wxWebViewReloadFlags flags
= wxWEB_VIEW_RELOAD_DEFAULT
);
65 virtual wxString
GetPageSource();
67 virtual bool IsBusy();
68 virtual wxString
GetCurrentURL();
69 virtual wxString
GetCurrentTitle();
71 virtual void SetZoomType(wxWebViewZoomType
);
72 virtual wxWebViewZoomType
GetZoomType() const;
73 virtual bool CanSetZoomType(wxWebViewZoomType
) const;
77 virtual void SetPage(const wxString
& html
, const wxString
& baseUrl
);
79 virtual wxWebViewZoom
GetZoom();
80 virtual void SetZoom(wxWebViewZoom zoom
);
83 virtual bool CanCut();
84 virtual bool CanCopy();
85 virtual bool CanPaste();
90 //Undo / redo functionality
91 virtual bool CanUndo();
92 virtual bool CanRedo();
97 virtual void SetEditable(bool enable
= true);
98 virtual bool IsEditable();
100 // ---- IE-specific methods
102 // FIXME: I seem to be able to access remote webpages even in offline mode...
103 bool IsOfflineMode();
104 void SetOfflineMode(bool offline
);
108 * @return text zoom from 0 to 4
113 * @param level 0 to 4
115 void SetIETextZoom(int level
);
117 void SetIEOpticalZoom(float zoom
);
118 float GetIEOpticalZoom();
120 void onActiveXEvent(wxActiveXEvent
& evt
);
121 void onEraseBg(wxEraseEvent
& evt
) {}
123 DECLARE_EVENT_TABLE();
126 wxActiveXContainer
* m_container
;
127 wxAutomationObject m_ie
;
128 IWebBrowser2
* m_webBrowser
;
130 bool m_canNavigateBack
;
131 bool m_canNavigateForward
;
133 /** The "Busy" property of IWebBrowser2 does not always return busy when
134 * we'd want it to; this variable may be set to true in cases where the
135 * Busy property is false but should be true.
138 //We manage our own history, the history list contains the history items
139 //which are added as documentcomplete events arrive, unless we are loading
140 //an item from the history. The position is stored as an int, and reflects
141 //where we are in the history list.
142 wxVector
<wxSharedPtr
<wxWebHistoryItem
> > m_historyList
;
143 int m_historyPosition
;
144 bool m_historyLoadingFromList
;
145 bool m_historyEnabled
;
147 //Generic helper functions for IHtmlDocument commands
148 bool CanExecCommand(wxString command
);
149 void ExecCommand(wxString command
);
150 IHTMLDocument2
* GetDocument();
154 #endif // wxUSE_WEBVIEW_IE
156 #endif // wxWebViewIE_H