Add support for retrieving the currently selected text. Implement on all backends...
[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 IHTMLDocument2;
25
26 class WXDLLIMPEXP_WEB wxWebViewIE : public wxWebView
27 {
28 public:
29
30 wxWebViewIE() {}
31
32 wxWebViewIE(wxWindow* parent,
33 wxWindowID id,
34 const wxString& url = wxWebViewDefaultURLStr,
35 const wxPoint& pos = wxDefaultPosition,
36 const wxSize& size = wxDefaultSize,
37 long style = 0,
38 const wxString& name = wxWebViewNameStr)
39 {
40 Create(parent, id, url, pos, size, style, name);
41 }
42
43 bool Create(wxWindow* parent,
44 wxWindowID id,
45 const wxString& url = wxWebViewDefaultURLStr,
46 const wxPoint& pos = wxDefaultPosition,
47 const wxSize& size = wxDefaultSize,
48 long style = 0,
49 const wxString& name = wxWebViewNameStr);
50
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();
55
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);
62 virtual void Stop();
63 virtual void Reload(wxWebViewReloadFlags flags = wxWEB_VIEW_RELOAD_DEFAULT);
64
65 virtual wxString GetPageSource();
66
67 virtual bool IsBusy();
68 virtual wxString GetCurrentURL();
69 virtual wxString GetCurrentTitle();
70
71 virtual void SetZoomType(wxWebViewZoomType);
72 virtual wxWebViewZoomType GetZoomType() const;
73 virtual bool CanSetZoomType(wxWebViewZoomType) const;
74
75 virtual void Print();
76
77 virtual void SetPage(const wxString& html, const wxString& baseUrl);
78
79 virtual wxWebViewZoom GetZoom();
80 virtual void SetZoom(wxWebViewZoom zoom);
81
82 //Clipboard functions
83 virtual bool CanCut();
84 virtual bool CanCopy();
85 virtual bool CanPaste();
86 virtual void Cut();
87 virtual void Copy();
88 virtual void Paste();
89
90 //Undo / redo functionality
91 virtual bool CanUndo();
92 virtual bool CanRedo();
93 virtual void Undo();
94 virtual void Redo();
95
96 //Editing functions
97 virtual void SetEditable(bool enable = true);
98 virtual bool IsEditable();
99
100 //Selection
101 virtual void SelectAll();
102 virtual bool HasSelection();
103 virtual void DeleteSelection();
104 virtual wxString GetSelectedText();
105
106
107 // ---- IE-specific methods
108
109 // FIXME: I seem to be able to access remote webpages even in offline mode...
110 bool IsOfflineMode();
111 void SetOfflineMode(bool offline);
112
113 /**
114 * Get text zoom
115 * @return text zoom from 0 to 4
116 */
117 int GetIETextZoom();
118
119 /**
120 * @param level 0 to 4
121 */
122 void SetIETextZoom(int level);
123
124 void SetIEOpticalZoom(float zoom);
125 float GetIEOpticalZoom();
126
127 void onActiveXEvent(wxActiveXEvent& evt);
128 void onEraseBg(wxEraseEvent& evt) {}
129
130 DECLARE_EVENT_TABLE();
131
132 private:
133 wxActiveXContainer* m_container;
134 wxAutomationObject m_ie;
135 IWebBrowser2* m_webBrowser;
136 DWORD m_dwCookie;
137 bool m_canNavigateBack;
138 bool m_canNavigateForward;
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 #endif // wxUSE_WEBVIEW_IE
162
163 #endif // wxWebViewIE_H