Add ClearSelection for msw ie and gtk webkit, with a stub for osx webkit. Document...
[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 struct 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 virtual wxString GetPageText();
67
68 virtual bool IsBusy();
69 virtual wxString GetCurrentURL();
70 virtual wxString GetCurrentTitle();
71
72 virtual void SetZoomType(wxWebViewZoomType);
73 virtual wxWebViewZoomType GetZoomType() const;
74 virtual bool CanSetZoomType(wxWebViewZoomType) const;
75
76 virtual void Print();
77
78 virtual void SetPage(const wxString& html, const wxString& baseUrl);
79
80 virtual wxWebViewZoom GetZoom();
81 virtual void SetZoom(wxWebViewZoom zoom);
82
83 //Clipboard functions
84 virtual bool CanCut();
85 virtual bool CanCopy();
86 virtual bool CanPaste();
87 virtual void Cut();
88 virtual void Copy();
89 virtual void Paste();
90
91 //Undo / redo functionality
92 virtual bool CanUndo();
93 virtual bool CanRedo();
94 virtual void Undo();
95 virtual void Redo();
96
97 //Editing functions
98 virtual void SetEditable(bool enable = true);
99 virtual bool IsEditable();
100
101 //Selection
102 virtual void SelectAll();
103 virtual bool HasSelection();
104 virtual void DeleteSelection();
105 virtual wxString GetSelectedText();
106 virtual wxString GetSelectedSource();
107 virtual void ClearSelection();
108
109
110 // ---- IE-specific methods
111
112 // FIXME: I seem to be able to access remote webpages even in offline mode...
113 bool IsOfflineMode();
114 void SetOfflineMode(bool offline);
115
116 wxWebViewZoom GetIETextZoom();
117 void SetIETextZoom(wxWebViewZoom level);
118
119 wxWebViewZoom GetIEOpticalZoom();
120 void SetIEOpticalZoom(wxWebViewZoom level);
121
122 void onActiveXEvent(wxActiveXEvent& evt);
123 void onEraseBg(wxEraseEvent&) {}
124
125 DECLARE_EVENT_TABLE();
126
127 private:
128 wxActiveXContainer* m_container;
129 wxAutomationObject m_ie;
130 IWebBrowser2* m_webBrowser;
131 DWORD m_dwCookie;
132 bool m_canNavigateBack;
133 bool m_canNavigateForward;
134
135 //We store the current zoom type;
136 wxWebViewZoomType m_zoomType;
137
138 /** The "Busy" property of IWebBrowser2 does not always return busy when
139 * we'd want it to; this variable may be set to true in cases where the
140 * Busy property is false but should be true.
141 */
142 bool m_isBusy;
143 //We manage our own history, the history list contains the history items
144 //which are added as documentcomplete events arrive, unless we are loading
145 //an item from the history. The position is stored as an int, and reflects
146 //where we are in the history list.
147 wxVector<wxSharedPtr<wxWebHistoryItem> > m_historyList;
148 int m_historyPosition;
149 bool m_historyLoadingFromList;
150 bool m_historyEnabled;
151
152 //Generic helper functions for IHtmlDocument commands
153 bool CanExecCommand(wxString command);
154 void ExecCommand(wxString command);
155 IHTMLDocument2* GetDocument();
156
157 };
158
159 #endif // wxUSE_WEBVIEW_IE
160
161 #endif // wxWebViewIE_H