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