Use shared pointers throughout when managing history with the ie backend, simplifying...
[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
23 class WXDLLIMPEXP_WEB wxWebHistoryItem
24 {
25 public:
26 wxWebHistoryItem(const wxString& url, const wxString& title) :
27 m_url(url), m_title(title) {}
28 wxString GetUrl() { return m_url; }
29 wxString GetTitle() { return m_title; }
30
31 private:
32 wxString m_url, m_title;
33 };
34
35 class WXDLLIMPEXP_WEB wxWebViewIE : public wxWebView
36 {
37 public:
38
39 wxWebViewIE() {}
40
41 wxWebViewIE(wxWindow* parent,
42 wxWindowID id,
43 const wxString& url = wxWebViewDefaultURLStr,
44 const wxPoint& pos = wxDefaultPosition,
45 const wxSize& size = wxDefaultSize,
46 long style = 0,
47 const wxString& name = wxWebViewNameStr)
48 {
49 Create(parent, id, url, pos, size, style, name);
50 }
51
52 bool Create(wxWindow* parent,
53 wxWindowID id,
54 const wxString& url = wxWebViewDefaultURLStr,
55 const wxPoint& pos = wxDefaultPosition,
56 const wxSize& size = wxDefaultSize,
57 long style = 0,
58 const wxString& name = wxWebViewNameStr);
59
60 virtual void LoadUrl(const wxString& url);
61 virtual void LoadHistoryItem(wxSharedPtr<wxWebHistoryItem> item);
62
63 virtual bool CanGoForward();
64 virtual bool CanGoBack();
65 virtual void GoBack();
66 virtual void GoForward();
67 virtual void ClearHistory();
68 virtual void EnableHistory(bool enable = true);
69 virtual void Stop();
70 virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT);
71
72 virtual wxString GetPageSource();
73
74 virtual bool IsBusy();
75 virtual wxString GetCurrentURL();
76 virtual wxString GetCurrentTitle();
77
78 virtual void SetZoomType(wxWebViewZoomType);
79 virtual wxWebViewZoomType GetZoomType() const;
80 virtual bool CanSetZoomType(wxWebViewZoomType) const;
81
82 virtual void Print();
83
84 virtual void SetPage(const wxString& html, const wxString& baseUrl);
85
86 virtual wxWebViewZoom GetZoom();
87 virtual void SetZoom(wxWebViewZoom zoom);
88
89 // ---- IE-specific methods
90
91 // FIXME: I seem to be able to access remote webpages even in offline mode...
92 bool IsOfflineMode();
93 void SetOfflineMode(bool offline);
94
95 /**
96 * Get text zoom
97 * @return text zoom from 0 to 4
98 */
99 int GetIETextZoom();
100
101 /**
102 * @param level 0 to 4
103 */
104 void SetIETextZoom(int level);
105
106 void SetIEOpticalZoom(float zoom);
107 float GetIEOpticalZoom();
108
109 void onActiveXEvent(wxActiveXEvent& evt);
110 void onEraseBg(wxEraseEvent& evt) {}
111
112 DECLARE_EVENT_TABLE();
113
114 private:
115 wxActiveXContainer* m_container;
116 wxAutomationObject m_ie;
117 IWebBrowser2* m_webBrowser;
118 DWORD m_dwCookie;
119 bool m_canNavigateBack;
120 bool m_canNavigateForward;
121
122 /** The "Busy" property of IWebBrowser2 does not always return busy when
123 * we'd want it to; this variable may be set to true in cases where the
124 * Busy property is false but should be true.
125 */
126 bool m_isBusy;
127 //We manage our own history, the history list contains the history items
128 //which are added as documentcomplete events arrive, unless we are loading
129 //an item from the history. The position is stored as an int, and reflects
130 //where we are in the history list.
131 wxVector<wxSharedPtr<wxWebHistoryItem> > m_historyList;
132 int m_historyPosition;
133 bool m_historyLoadingFromList;
134 bool m_historyEnabled;
135
136 };
137
138 #endif // wxUSE_WEBVIEW_IE
139
140 #endif // wxWebViewIE_H