]>
Commit | Line | Data |
---|---|---|
968a7de2 SL |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: webview.h | |
3 | // Purpose: interface of wxWebView | |
4 | // Author: wxWidgets team | |
968a7de2 SL |
5 | // Licence: wxWindows licence |
6 | ///////////////////////////////////////////////////////////////////////////// | |
7 | ||
8 | /** | |
c44db939 | 9 | Zoom levels available in wxWebView |
968a7de2 SL |
10 | */ |
11 | enum wxWebViewZoom | |
12 | { | |
236cff73 SL |
13 | wxWEBVIEW_ZOOM_TINY, |
14 | wxWEBVIEW_ZOOM_SMALL, | |
15 | wxWEBVIEW_ZOOM_MEDIUM, //!< default size | |
16 | wxWEBVIEW_ZOOM_LARGE, | |
17 | wxWEBVIEW_ZOOM_LARGEST | |
968a7de2 SL |
18 | }; |
19 | ||
20 | /** | |
21 | The type of zooming that the web view control can perform | |
22 | */ | |
23 | enum wxWebViewZoomType | |
24 | { | |
34326da7 SL |
25 | /** |
26 | The entire layout scales when zooming, including images | |
968a7de2 | 27 | */ |
236cff73 | 28 | wxWEBVIEW_ZOOM_TYPE_LAYOUT, |
34326da7 | 29 | /** |
968a7de2 | 30 | Only the text changes in size when zooming, images and other layout |
34326da7 | 31 | elements retain their initial size |
968a7de2 | 32 | */ |
236cff73 | 33 | wxWEBVIEW_ZOOM_TYPE_TEXT |
968a7de2 SL |
34 | }; |
35 | ||
34326da7 | 36 | /** |
968a7de2 SL |
37 | Types of errors that can cause navigation to fail |
38 | */ | |
04fa04d8 | 39 | enum wxWebViewNavigationError |
968a7de2 SL |
40 | { |
41 | /** Connection error (timeout, etc.) */ | |
236cff73 | 42 | wxWEBVIEW_NAV_ERR_CONNECTION, |
968a7de2 | 43 | /** Invalid certificate */ |
236cff73 | 44 | wxWEBVIEW_NAV_ERR_CERTIFICATE, |
968a7de2 | 45 | /** Authentication required */ |
236cff73 | 46 | wxWEBVIEW_NAV_ERR_AUTH, |
968a7de2 | 47 | /** Other security error */ |
236cff73 | 48 | wxWEBVIEW_NAV_ERR_SECURITY, |
968a7de2 | 49 | /** Requested resource not found */ |
236cff73 | 50 | wxWEBVIEW_NAV_ERR_NOT_FOUND, |
968a7de2 SL |
51 | /** Invalid request/parameters (e.g. bad URL, bad protocol, |
52 | unsupported resource type) */ | |
236cff73 | 53 | wxWEBVIEW_NAV_ERR_REQUEST, |
968a7de2 | 54 | /** The user cancelled (e.g. in a dialog) */ |
236cff73 | 55 | wxWEBVIEW_NAV_ERR_USER_CANCELLED, |
968a7de2 | 56 | /** Another (exotic) type of error that didn't fit in other categories*/ |
236cff73 | 57 | wxWEBVIEW_NAV_ERR_OTHER |
968a7de2 SL |
58 | }; |
59 | ||
34326da7 SL |
60 | /** |
61 | Type of refresh | |
968a7de2 SL |
62 | */ |
63 | enum wxWebViewReloadFlags | |
64 | { | |
65 | /** Default reload, will access cache */ | |
236cff73 | 66 | wxWEBVIEW_RELOAD_DEFAULT, |
968a7de2 | 67 | /** Reload the current view without accessing the cache */ |
236cff73 | 68 | wxWEBVIEW_RELOAD_NO_CACHE |
968a7de2 SL |
69 | }; |
70 | ||
66ac0400 SL |
71 | /** |
72 | Find flags used when searching for text on page. | |
73 | */ | |
74 | enum wxWebViewFindFlags | |
75 | { | |
76 | /** Causes the search to restart when end or beginning reached */ | |
236cff73 | 77 | wxWEBVIEW_FIND_WRAP = 0x0001, |
66ac0400 SL |
78 | |
79 | /** Matches an entire word when searching */ | |
236cff73 | 80 | wxWEBVIEW_FIND_ENTIRE_WORD = 0x0002, |
66ac0400 SL |
81 | |
82 | /** Match case, i.e. case sensitive searching */ | |
236cff73 | 83 | wxWEBVIEW_FIND_MATCH_CASE = 0x0004, |
66ac0400 SL |
84 | |
85 | /** Highlights the search results */ | |
236cff73 | 86 | wxWEBVIEW_FIND_HIGHLIGHT_RESULT = 0x0008, |
66ac0400 SL |
87 | |
88 | /** Searches for phrase in backward direction */ | |
236cff73 | 89 | wxWEBVIEW_FIND_BACKWARDS = 0x0010, |
66ac0400 SL |
90 | |
91 | /** The default flag, which is simple searching */ | |
236cff73 | 92 | wxWEBVIEW_FIND_DEFAULT = 0 |
66ac0400 SL |
93 | }; |
94 | ||
968a7de2 SL |
95 | |
96 | /** | |
c13d6ac1 | 97 | @class wxWebViewHistoryItem |
34326da7 | 98 | |
968a7de2 | 99 | A simple class that contains the URL and title of an element of the history |
34326da7 SL |
100 | of a wxWebView. |
101 | ||
b2b31b87 | 102 | @since 2.9.3 |
43d53ee5 SL |
103 | @library{wxwebview} |
104 | @category{webview} | |
34326da7 | 105 | |
bf39189b | 106 | @see wxWebView |
968a7de2 | 107 | */ |
c13d6ac1 | 108 | class wxWebViewHistoryItem |
968a7de2 SL |
109 | { |
110 | public: | |
111 | /** | |
112 | Construtor. | |
113 | */ | |
c13d6ac1 | 114 | wxWebViewHistoryItem(const wxString& url, const wxString& title); |
34326da7 | 115 | |
968a7de2 SL |
116 | /** |
117 | @return The url of the page. | |
118 | */ | |
119 | wxString GetUrl(); | |
34326da7 | 120 | |
968a7de2 SL |
121 | /** |
122 | @return The title of the page. | |
123 | */ | |
124 | wxString GetTitle(); | |
125 | }; | |
126 | ||
4c687fff SL |
127 | /** |
128 | @class wxWebViewFactory | |
129 | ||
130 | An abstract factory class for creating wxWebView backends. Each | |
131 | implementation of wxWebView should have its own factory. | |
132 | ||
133 | @since 2.9.5 | |
134 | @library{wxwebview} | |
135 | @category{webview} | |
136 | ||
137 | @see wxWebView | |
138 | */ | |
139 | class wxWebViewFactory : public wxObject | |
140 | { | |
141 | public: | |
142 | /** | |
143 | Function to create a new wxWebView with two-step creation, | |
144 | wxWebView::Create should be called on the returned object. | |
145 | @return the created wxWebView | |
146 | */ | |
147 | virtual wxWebView* Create() = 0; | |
148 | ||
149 | /** | |
150 | Function to create a new wxWebView with parameters. | |
151 | @param parent Parent window for the control | |
152 | @param id ID of this control | |
153 | @param url Initial URL to load | |
154 | @param pos Position of the control | |
155 | @param size Size of the control | |
70f92ede SL |
156 | @param style |
157 | Window style. For generic window styles, please see wxWindow. | |
158 | @param name Window name. | |
4c687fff SL |
159 | @return the created wxWebView |
160 | */ | |
161 | virtual wxWebView* Create(wxWindow* parent, | |
162 | wxWindowID id, | |
163 | const wxString& url = wxWebViewDefaultURLStr, | |
164 | const wxPoint& pos = wxDefaultPosition, | |
165 | const wxSize& size = wxDefaultSize, | |
166 | long style = 0, | |
167 | const wxString& name = wxWebViewNameStr) = 0; | |
168 | }; | |
169 | ||
42be0c56 | 170 | /** |
7d8d6163 | 171 | @class wxWebViewHandler |
34326da7 SL |
172 | |
173 | The base class for handling custom schemes in wxWebView, for example to | |
42be0c56 | 174 | allow virtual file system support. |
34326da7 | 175 | |
b2b31b87 | 176 | @since 2.9.3 |
43d53ee5 SL |
177 | @library{wxwebview} |
178 | @category{webview} | |
34326da7 | 179 | |
42be0c56 SL |
180 | @see wxWebView |
181 | */ | |
7d8d6163 | 182 | class wxWebViewHandler |
42be0c56 SL |
183 | { |
184 | public: | |
7d8d6163 SL |
185 | /** |
186 | Constructor. Takes the name of the scheme that will be handled by this | |
187 | class for example @c file or @c zip. | |
188 | */ | |
189 | wxWebViewHandler(const wxString& scheme); | |
190 | ||
42be0c56 SL |
191 | /** |
192 | @return A pointer to the file represented by @c uri. | |
34326da7 | 193 | */ |
42be0c56 SL |
194 | virtual wxFSFile* GetFile(const wxString &uri) = 0; |
195 | ||
196 | /** | |
7d8d6163 | 197 | @return The name of the scheme, as passed to the constructor. |
42be0c56 | 198 | */ |
cce10ca0 | 199 | virtual wxString GetName() const; |
42be0c56 SL |
200 | }; |
201 | ||
968a7de2 SL |
202 | /** |
203 | @class wxWebView | |
34326da7 | 204 | |
968a7de2 | 205 | This control may be used to render web (HTML / CSS / javascript) documents. |
34326da7 | 206 | It is designed to allow the creation of multiple backends for each port, |
66a8d414 SL |
207 | although currently just one is available. It differs from wxHtmlWindow in |
208 | that each backend is actually a full rendering engine, Trident on MSW and | |
209 | Webkit on OSX and GTK. This allows the correct viewing complex pages with | |
34326da7 SL |
210 | javascript and css. |
211 | ||
062dfc9a | 212 | @section descriptions Backend Descriptions |
34326da7 | 213 | |
236cff73 | 214 | @par wxWEBVIEW_BACKEND_IE (MSW) |
34326da7 | 215 | |
0abf6824 | 216 | The IE backend uses Microsoft's Trident rendering engine, specifically the |
062dfc9a | 217 | version used by the locally installed copy of Internet Explorer. As such it |
34326da7 | 218 | is only available for the MSW port. By default recent versions of the |
062dfc9a SL |
219 | <a href="http://msdn.microsoft.com/en-us/library/aa752085%28v=VS.85%29.aspx">WebBrowser</a> |
220 | control, which this backend uses, emulate Internet Explorer 7. This can be | |
34326da7 | 221 | changed with a registry setting, see |
c36818c8 | 222 | <a href="http://msdn.microsoft.com/en-us/library/ee330730%28v=vs.85%29.aspx#browser_emulation"> |
062dfc9a | 223 | this</a> article for more information. This backend has full support for |
ad410224 | 224 | custom schemes and virtual file systems. |
34326da7 | 225 | |
236cff73 | 226 | @par wxWEBVIEW_WEBKIT (GTK) |
34326da7 SL |
227 | |
228 | Under GTK the WebKit backend uses | |
062dfc9a | 229 | <a href="http://webkitgtk.org/">WebKitGTK+</a>. The current minimum version |
0abf6824 | 230 | required is 1.3.1 which ships by default with Ubuntu Natty and Debian |
34326da7 | 231 | Wheezy and has the package name libwebkitgtk-dev. Custom schemes and |
0abf6824 | 232 | virtual files systems are supported under this backend, however embedded |
fe104ff9 SL |
233 | resources such as images and stylesheets are currently loaded using the |
234 | data:// scheme. | |
34326da7 | 235 | |
236cff73 | 236 | @par wxWEBVIEW_WEBKIT (OSX) |
34326da7 SL |
237 | |
238 | The OSX WebKit backend uses Apple's | |
062dfc9a | 239 | <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/WebKit/Classes/WebView_Class/Reference/Reference.html#//apple_ref/doc/uid/20001903">WebView</a> |
fe104ff9 SL |
240 | class. This backend has full support for custom schemes and virtual file |
241 | systems. | |
25b2deb8 SL |
242 | |
243 | @section async Asynchronous Notifications | |
34326da7 | 244 | |
25b2deb8 SL |
245 | Many of the methods in wxWebView are asynchronous, i.e. they return |
246 | immediately and perform their work in the background. This includes | |
026a6ed6 | 247 | functions such as LoadURL() and Reload(). To receive notification of the |
25b2deb8 | 248 | progress and completion of these functions you need to handle the events |
ce7fe42e | 249 | that are provided. Specifically @c wxEVT_WEBVIEW_LOADED notifies |
34326da7 | 250 | when the page or a sub-frame has finished loading and |
ce7fe42e | 251 | @c wxEVT_WEBVIEW_ERROR notifies that an error has occurred. |
34326da7 | 252 | |
42be0c56 | 253 | @section vfs Virtual File Systems and Custom Schemes |
34326da7 | 254 | |
42be0c56 | 255 | wxWebView supports the registering of custom scheme handlers, for example |
34326da7 SL |
256 | @c file or @c http. To do this create a new class which inherits from |
257 | wxWebViewHandler, where wxWebHandler::GetFile() returns a pointer to a | |
42be0c56 SL |
258 | wxFSFile which represents the given url. You can then register your handler |
259 | with RegisterHandler() it will be called for all pages and resources. | |
34326da7 | 260 | |
0bfd90b3 SL |
261 | wxWebViewFSHandler is provided to access the virtual file system encapsulated by |
262 | wxFileSystem. The wxMemoryFSHandler documentation gives an example of how this | |
263 | may be used. | |
264 | ||
265 | wxWebViewArchiveHandler is provided to allow the navigation of pages inside a zip | |
266 | archive. It supports paths of the form: | |
267 | @c scheme:///C:/example/docs.zip;protocol=zip/main.htm | |
34326da7 | 268 | |
04fa04d8 | 269 | @beginEventEmissionTable{wxWebViewEvent} |
236cff73 | 270 | @event{EVT_WEBVIEW_NAVIGATING(id, func)} |
ce7fe42e | 271 | Process a @c wxEVT_WEBVIEW_NAVIGATING event, generated before trying |
968a7de2 SL |
272 | to get a resource. This event may be vetoed to prevent navigating to this |
273 | resource. Note that if the displayed HTML document has several frames, one | |
274 | such event will be generated per frame. | |
236cff73 | 275 | @event{EVT_WEBVIEW_NAVIGATED(id, func)} |
ce7fe42e | 276 | Process a @c wxEVT_WEBVIEW_NAVIGATED event generated after it was |
968a7de2 SL |
277 | confirmed that a resource would be requested. This event may not be vetoed. |
278 | Note that if the displayed HTML document has several frames, one such event | |
279 | will be generated per frame. | |
236cff73 | 280 | @event{EVT_WEBVIEW_LOADED(id, func)} |
ce7fe42e | 281 | Process a @c wxEVT_WEBVIEW_LOADED event generated when the document |
34326da7 | 282 | is fully loaded and displayed. Note that if the displayed HTML document has |
113e0a92 | 283 | several frames, one such event will be generated per frame. |
236cff73 | 284 | @event{EVT_WEBVIEW_ERROR(id, func)} |
ce7fe42e | 285 | Process a @c wxEVT_WEBVIEW_ERROR event generated when a navigation |
968a7de2 SL |
286 | error occurs. |
287 | The integer associated with this event will be a wxWebNavigationError item. | |
288 | The string associated with this event may contain a backend-specific more | |
289 | precise error message/code. | |
236cff73 | 290 | @event{EVT_WEBVIEW_NEWWINDOW(id, func)} |
ce7fe42e | 291 | Process a @c wxEVT_WEBVIEW_NEWWINDOW event, generated when a new |
34326da7 | 292 | window is created. You must handle this event if you want anything to |
d676fb21 | 293 | happen, for example to load the page in a new window or tab. |
236cff73 | 294 | @event{EVT_WEBVIEW_TITLE_CHANGED(id, func)} |
ce7fe42e | 295 | Process a @c wxEVT_WEBVIEW_TITLE_CHANGED event, generated when |
153530af | 296 | the page title changes. Use GetString to get the title. |
968a7de2 | 297 | @endEventTable |
34326da7 | 298 | |
b2b31b87 | 299 | @since 2.9.3 |
43d53ee5 SL |
300 | @library{wxwebview} |
301 | @category{ctrl,webview} | |
3225a4b8 | 302 | @see wxWebViewHandler, wxWebViewEvent |
968a7de2 SL |
303 | */ |
304 | class wxWebView : public wxControl | |
305 | { | |
306 | public: | |
307 | ||
308 | /** | |
309 | Creation function for two-step creation. | |
310 | */ | |
311 | virtual bool Create(wxWindow* parent, | |
312 | wxWindowID id, | |
cce10ca0 RD |
313 | const wxString& url = wxWebViewDefaultURLStr, |
314 | const wxPoint& pos = wxDefaultPosition, | |
315 | const wxSize& size = wxDefaultSize, | |
316 | long style = 0, | |
317 | const wxString& name = wxWebViewNameStr) = 0; | |
968a7de2 SL |
318 | |
319 | /** | |
4c687fff SL |
320 | Factory function to create a new wxWebView with two-step creation, |
321 | wxWebView::Create should be called on the returned object. | |
322 | @param backend The backend web rendering engine to use. | |
323 | @c wxWebViewBackendDefault, @c wxWebViewBackendIE and | |
324 | @c wxWebViewBackendWebKit are predefined where appropriate. | |
325 | @return The created wxWebView | |
326 | @since 2.9.5 | |
968a7de2 | 327 | */ |
4c687fff SL |
328 | static wxWebView* New(const wxString& backend = wxWebViewBackendDefault); |
329 | ||
968a7de2 | 330 | /** |
4c687fff SL |
331 | Factory function to create a new wxWebView using a wxWebViewFactory. |
332 | @param parent Parent window for the control | |
968a7de2 | 333 | @param id ID of this control |
4c687fff SL |
334 | @param url Initial URL to load |
335 | @param pos Position of the control | |
336 | @param size Size of the control | |
337 | @param backend The backend web rendering engine to use. | |
338 | @c wxWebViewBackendDefault, @c wxWebViewBackendIE and | |
339 | @c wxWebViewBackendWebKit are predefined where appropriate. | |
70f92ede SL |
340 | @param style |
341 | Window style. For generic window styles, please see wxWindow. | |
342 | @param name Window name. | |
4c687fff | 343 | @return The created wxWebView, or @c NULL if the requested backend |
968a7de2 | 344 | is not available |
4c687fff | 345 | @since 2.9.5 |
968a7de2 SL |
346 | */ |
347 | static wxWebView* New(wxWindow* parent, | |
4c687fff SL |
348 | wxWindowID id, |
349 | const wxString& url = wxWebViewDefaultURLStr, | |
350 | const wxPoint& pos = wxDefaultPosition, | |
351 | const wxSize& size = wxDefaultSize, | |
352 | const wxString& backend = wxWebViewBackendDefault, | |
353 | long style = 0, | |
354 | const wxString& name = wxWebViewNameStr); | |
355 | ||
356 | /** | |
357 | Allows the registering of new backend for wxWebView. @a backend can be | |
358 | used as an argument to New(). | |
359 | @param backend The name for the new backend to be registered under | |
360 | @param factory A shared pointer to the factory which creates the | |
361 | appropriate backend. | |
362 | @since 2.9.5 | |
363 | */ | |
364 | static void RegisterFactory(const wxString& backend, | |
365 | wxSharedPtr<wxWebViewFactory> factory); | |
968a7de2 SL |
366 | |
367 | /** | |
368 | Get the title of the current web page, or its URL/path if title is not | |
369 | available. | |
370 | */ | |
e669ddde | 371 | virtual wxString GetCurrentTitle() const = 0; |
968a7de2 SL |
372 | |
373 | /** | |
374 | Get the URL of the currently displayed document. | |
375 | */ | |
e669ddde | 376 | virtual wxString GetCurrentURL() const = 0; |
968a7de2 | 377 | |
b6a49c2b VZ |
378 | /** |
379 | Return the pointer to the native backend used by this control. | |
380 | ||
381 | This method can be used to retrieve the pointer to the native rendering | |
382 | engine used by this control. The return value needs to be down-casted | |
383 | to the appropriate type depending on the platform: under Windows, it's | |
384 | a pointer to IWebBrowser2 interface, under OS X it's a WebView pointer | |
385 | and under GTK it's a WebKitWebView. | |
386 | ||
387 | For example, you could set the WebKit options using this method: | |
388 | @code | |
389 | #include <webkit/webkit.h> | |
390 | ||
391 | #ifdef __WXGTK__ | |
392 | WebKitWebView* | |
393 | wv = static_cast<WebKitWebView*>(m_window->GetNativeBackend()); | |
394 | ||
395 | WebKitWebSettings* settings = webkit_web_view_get_settings(wv); | |
396 | g_object_set(G_OBJECT(settings), | |
397 | "enable-frame-flattening", TRUE, | |
398 | NULL); | |
399 | #endif | |
400 | @endcode | |
401 | ||
402 | @since 2.9.5 | |
403 | */ | |
404 | virtual void* GetNativeBackend() const = 0; | |
405 | ||
968a7de2 SL |
406 | /** |
407 | Get the HTML source code of the currently displayed document. | |
408 | @return The HTML source code, or an empty string if no page is currently | |
409 | shown. | |
410 | */ | |
e669ddde | 411 | virtual wxString GetPageSource() const = 0; |
34326da7 | 412 | |
241b769f SL |
413 | /** |
414 | Get the text of the current page. | |
415 | */ | |
e669ddde | 416 | virtual wxString GetPageText() const = 0; |
34326da7 | 417 | |
968a7de2 | 418 | /** |
0824e369 | 419 | Returns whether the web control is currently busy (e.g.\ loading a page). |
968a7de2 | 420 | */ |
e669ddde | 421 | virtual bool IsBusy() const = 0; |
c7cbe308 SL |
422 | |
423 | /** | |
424 | Returns whether the web control is currently editable | |
425 | */ | |
e669ddde | 426 | virtual bool IsEditable() const = 0; |
968a7de2 SL |
427 | |
428 | /** | |
429 | Load a web page from a URL | |
430 | @param url The URL of the page to be loaded. | |
431 | @note Web engines generally report errors asynchronously, so if you wish | |
432 | to know whether loading the URL was successful, register to receive | |
433 | navigation error events. | |
434 | */ | |
4d0dddc7 | 435 | virtual void LoadURL(const wxString& url) = 0; |
968a7de2 SL |
436 | |
437 | /** | |
438 | Opens a print dialog so that the user may print the currently | |
439 | displayed page. | |
440 | */ | |
441 | virtual void Print() = 0; | |
34326da7 | 442 | |
42be0c56 SL |
443 | /** |
444 | Registers a custom scheme handler. | |
3baf235f | 445 | @param handler A shared pointer to a wxWebHandler. |
42be0c56 | 446 | */ |
7d8d6163 | 447 | virtual void RegisterHandler(wxSharedPtr<wxWebViewHandler> handler) = 0; |
968a7de2 SL |
448 | |
449 | /** | |
450 | Reload the currently displayed URL. | |
451 | @param flags A bit array that may optionally contain reload options. | |
452 | */ | |
236cff73 | 453 | virtual void Reload(wxWebViewReloadFlags flags = wxWEBVIEW_RELOAD_DEFAULT) = 0; |
34326da7 | 454 | |
c9ccc09c | 455 | /** |
34326da7 | 456 | Runs the given javascript code. |
236cff73 | 457 | @note When using wxWEBVIEW_BACKEND_IE you must wait for the current |
d8088f27 | 458 | page to finish loading before calling RunScript(). |
c9ccc09c SL |
459 | */ |
460 | virtual void RunScript(const wxString& javascript) = 0; | |
34326da7 | 461 | |
c7cbe308 SL |
462 | /** |
463 | Set the editable property of the web control. Enabling allows the user | |
464 | to edit the page even if the @c contenteditable attribute is not set. | |
465 | The exact capabilities vary with the backend being used. | |
466 | */ | |
467 | virtual void SetEditable(bool enable = true) = 0; | |
968a7de2 SL |
468 | |
469 | /** | |
470 | Set the displayed page source to the contents of the given string. | |
471 | @param html The string that contains the HTML data to display. | |
472 | @param baseUrl URL assigned to the HTML data, to be used to resolve | |
473 | relative paths, for instance. | |
178a73f3 SL |
474 | @note When using @c wxWEBVIEW_BACKEND_IE you must wait for the current |
475 | page to finish loading before calling SetPage(). The baseURL | |
476 | parameter is not used in this backend. | |
968a7de2 SL |
477 | */ |
478 | virtual void SetPage(const wxString& html, const wxString& baseUrl) = 0; | |
479 | ||
480 | /** | |
481 | Set the displayed page source to the contents of the given stream. | |
482 | @param html The stream to read HTML data from. | |
483 | @param baseUrl URL assigned to the HTML data, to be used to resolve | |
484 | relative paths, for instance. | |
485 | */ | |
2339d6df | 486 | virtual void SetPage(wxInputStream& html, wxString baseUrl); |
968a7de2 SL |
487 | |
488 | /** | |
489 | Stop the current page loading process, if any. | |
236cff73 SL |
490 | May trigger an error event of type @c wxWEBVIEW_NAV_ERR_USER_CANCELLED. |
491 | TODO: make @c wxWEBVIEW_NAV_ERR_USER_CANCELLED errors uniform across ports. | |
968a7de2 SL |
492 | */ |
493 | virtual void Stop() = 0; | |
494 | ||
495 | /** | |
496 | @name Clipboard | |
497 | */ | |
498 | ||
499 | /** | |
500 | Returns @true if the current selection can be copied. | |
34326da7 | 501 | |
6849a4b7 | 502 | @note This always returns @c true on the OSX WebKit backend. |
968a7de2 | 503 | */ |
e669ddde | 504 | virtual bool CanCopy() const = 0; |
968a7de2 SL |
505 | |
506 | /** | |
507 | Returns @true if the current selection can be cut. | |
34326da7 | 508 | |
6849a4b7 | 509 | @note This always returns @c true on the OSX WebKit backend. |
968a7de2 | 510 | */ |
e669ddde | 511 | virtual bool CanCut() const = 0; |
968a7de2 SL |
512 | |
513 | /** | |
514 | Returns @true if data can be pasted. | |
34326da7 | 515 | |
6849a4b7 | 516 | @note This always returns @c true on the OSX WebKit backend. |
968a7de2 | 517 | */ |
e669ddde | 518 | virtual bool CanPaste() const = 0; |
968a7de2 SL |
519 | |
520 | /** | |
34326da7 | 521 | Copies the current selection. |
968a7de2 SL |
522 | */ |
523 | virtual void Copy() = 0; | |
524 | ||
525 | /** | |
526 | Cuts the current selection. | |
527 | */ | |
528 | virtual void Cut() = 0; | |
529 | ||
530 | /** | |
531 | Pastes the current data. | |
532 | */ | |
533 | virtual void Paste() = 0; | |
534 | ||
c420d57b SL |
535 | /** |
536 | @name Context Menu | |
537 | */ | |
538 | ||
539 | /** | |
103df4a1 VZ |
540 | Enable or disable the right click context menu. |
541 | ||
542 | By default the standard context menu is enabled, this method can be | |
543 | used to disable it or re-enable it later. | |
544 | ||
545 | @since 2.9.5 | |
c420d57b SL |
546 | */ |
547 | virtual void EnableContextMenu(bool enable = true); | |
548 | ||
549 | /** | |
550 | Returns @true if a context menu will be shown on right click. | |
103df4a1 VZ |
551 | |
552 | @since 2.9.5 | |
c420d57b SL |
553 | */ |
554 | virtual bool IsContextMenuEnabled() const; | |
555 | ||
968a7de2 SL |
556 | /** |
557 | @name History | |
558 | */ | |
559 | ||
34326da7 | 560 | /** |
968a7de2 SL |
561 | Returns @true if it is possible to navigate backward in the history of |
562 | visited pages. | |
563 | */ | |
e669ddde | 564 | virtual bool CanGoBack() const = 0; |
968a7de2 | 565 | |
34326da7 | 566 | /** |
968a7de2 SL |
567 | Returns @true if it is possible to navigate forward in the history of |
568 | visited pages. | |
569 | */ | |
e669ddde | 570 | virtual bool CanGoForward() const = 0; |
968a7de2 SL |
571 | |
572 | /** | |
573 | Clear the history, this will also remove the visible page. | |
574 | */ | |
575 | virtual void ClearHistory() = 0; | |
576 | ||
577 | /** | |
578 | Enable or disable the history. This will also clear the history. | |
579 | */ | |
580 | virtual void EnableHistory(bool enable = true) = 0; | |
581 | ||
582 | /** | |
583 | Returns a list of items in the back history. The first item in the | |
584 | vector is the first page that was loaded by the control. | |
585 | */ | |
c13d6ac1 | 586 | virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetBackwardHistory() = 0; |
968a7de2 SL |
587 | |
588 | /** | |
34326da7 SL |
589 | Returns a list of items in the forward history. The first item in the |
590 | vector is the next item in the history with respect to the curently | |
968a7de2 SL |
591 | loaded page. |
592 | */ | |
c13d6ac1 | 593 | virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetForwardHistory() = 0; |
968a7de2 | 594 | |
34326da7 | 595 | /** |
968a7de2 SL |
596 | Navigate back in the history of visited pages. |
597 | Only valid if CanGoBack() returns true. | |
598 | */ | |
599 | virtual void GoBack() = 0; | |
600 | ||
601 | /** | |
602 | Navigate forward in the history of visited pages. | |
603 | Only valid if CanGoForward() returns true. | |
604 | */ | |
605 | virtual void GoForward() = 0; | |
606 | ||
607 | /** | |
34326da7 | 608 | Loads a history item. |
968a7de2 | 609 | */ |
c13d6ac1 | 610 | virtual void LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item) = 0; |
34326da7 | 611 | |
63a65070 SL |
612 | /** |
613 | @name Selection | |
614 | */ | |
34326da7 | 615 | |
41933aa5 | 616 | /** |
34326da7 | 617 | Clears the current selection. |
41933aa5 SL |
618 | */ |
619 | virtual void ClearSelection() = 0; | |
34326da7 | 620 | |
63a65070 | 621 | /** |
236cff73 | 622 | Deletes the current selection. Note that for @c wxWEBVIEW_BACKEND_WEBKIT |
34326da7 | 623 | the selection must be editable, either through SetEditable or the |
63a65070 SL |
624 | correct HTML attribute. |
625 | */ | |
626 | virtual void DeleteSelection() = 0; | |
34326da7 | 627 | |
0fe8a1b6 | 628 | /** |
97ba4d81 | 629 | Returns the currently selected source, if any. |
0fe8a1b6 | 630 | */ |
e669ddde | 631 | virtual wxString GetSelectedSource() const = 0; |
34326da7 | 632 | |
c9355a3d SL |
633 | /** |
634 | Returns the currently selected text, if any. | |
635 | */ | |
e669ddde | 636 | virtual wxString GetSelectedText() const = 0; |
63a65070 SL |
637 | |
638 | /** | |
639 | Returns @true if there is a current selection. | |
640 | */ | |
e669ddde | 641 | virtual bool HasSelection() const = 0; |
63a65070 SL |
642 | |
643 | /** | |
644 | Selects the entire page. | |
645 | */ | |
646 | virtual void SelectAll() = 0; | |
968a7de2 SL |
647 | |
648 | /** | |
649 | @name Undo / Redo | |
650 | */ | |
651 | ||
652 | /** | |
653 | Returns @true if there is an action to redo. | |
654 | */ | |
e669ddde | 655 | virtual bool CanRedo() const = 0; |
968a7de2 SL |
656 | |
657 | /** | |
658 | Returns @true if there is an action to undo. | |
659 | */ | |
e669ddde | 660 | virtual bool CanUndo() const = 0; |
968a7de2 SL |
661 | |
662 | /** | |
663 | Redos the last action. | |
664 | */ | |
665 | virtual void Redo() = 0; | |
666 | ||
667 | /** | |
668 | Undos the last action. | |
669 | */ | |
670 | virtual void Undo() = 0; | |
671 | ||
66ac0400 SL |
672 | /** |
673 | @name Finding | |
674 | */ | |
675 | ||
676 | /** | |
677 | Finds a phrase on the current page and if found, the control will | |
678 | scroll the phrase into view and select it. | |
679 | @param text The phrase to search for. | |
680 | @param flags The flags for the search. | |
681 | @return If search phrase was not found in combination with the flags | |
682 | then @c wxNOT_FOUND is returned. If called for the first time | |
0bfd90b3 | 683 | with search phrase then the total number of results will be |
66ac0400 SL |
684 | returned. Then for every time its called with the same search |
685 | phrase it will return the number of the current match. | |
686 | @note This function will restart the search if the flags | |
236cff73 | 687 | @c wxWEBVIEW_FIND_ENTIRE_WORD or @c wxWEBVIEW_FIND_MATCH_CASE |
66ac0400 | 688 | are changed, since this will require a new search. To reset the |
0bfd90b3 | 689 | search, for example reseting the highlights call the function |
66ac0400 SL |
690 | with an empty search phrase. This always returns @c wxNOT_FOUND |
691 | on the OSX WebKit backend. | |
692 | @since 2.9.5 | |
693 | */ | |
236cff73 | 694 | virtual long Find(const wxString& text, wxWebViewFindFlags flags = wxWEBVIEW_FIND_DEFAULT) = 0; |
66ac0400 | 695 | |
968a7de2 SL |
696 | /** |
697 | @name Zoom | |
698 | */ | |
699 | ||
700 | /** | |
701 | Retrieve whether the current HTML engine supports a zoom type. | |
702 | @param type The zoom type to test. | |
703 | @return Whether this type of zoom is supported by this HTML engine | |
704 | (and thus can be set through SetZoomType()). | |
705 | */ | |
706 | virtual bool CanSetZoomType(wxWebViewZoomType type) const = 0; | |
707 | ||
708 | /** | |
709 | Get the zoom factor of the page. | |
710 | @return The current level of zoom. | |
711 | */ | |
e669ddde | 712 | virtual wxWebViewZoom GetZoom() const = 0; |
968a7de2 SL |
713 | |
714 | /** | |
715 | Get how the zoom factor is currently interpreted. | |
716 | @return How the zoom factor is currently interpreted by the HTML engine. | |
717 | */ | |
718 | virtual wxWebViewZoomType GetZoomType() const = 0; | |
719 | ||
720 | /** | |
721 | Set the zoom factor of the page. | |
722 | @param zoom How much to zoom (scale) the HTML document. | |
723 | */ | |
724 | virtual void SetZoom(wxWebViewZoom zoom) = 0; | |
725 | ||
726 | /** | |
727 | Set how to interpret the zoom factor. | |
728 | @param zoomType How the zoom factor should be interpreted by the | |
729 | HTML engine. | |
730 | @note invoke CanSetZoomType() first, some HTML renderers may not | |
731 | support all zoom types. | |
732 | */ | |
733 | virtual void SetZoomType(wxWebViewZoomType zoomType) = 0; | |
734 | }; | |
735 | ||
736 | ||
737 | ||
738 | ||
739 | /** | |
04fa04d8 | 740 | @class wxWebViewEvent |
968a7de2 | 741 | |
34326da7 | 742 | A navigation event holds information about events associated with |
968a7de2 SL |
743 | wxWebView objects. |
744 | ||
04fa04d8 | 745 | @beginEventEmissionTable{wxWebViewEvent} |
236cff73 | 746 | @event{EVT_WEBVIEW_NAVIGATING(id, func)} |
ce7fe42e | 747 | Process a @c wxEVT_WEBVIEW_NAVIGATING event, generated before trying |
968a7de2 SL |
748 | to get a resource. This event may be vetoed to prevent navigating to this |
749 | resource. Note that if the displayed HTML document has several frames, one | |
750 | such event will be generated per frame. | |
236cff73 | 751 | @event{EVT_WEBVIEW_NAVIGATED(id, func)} |
ce7fe42e | 752 | Process a @c wxEVT_WEBVIEW_NAVIGATED event generated after it was |
968a7de2 SL |
753 | confirmed that a resource would be requested. This event may not be vetoed. |
754 | Note that if the displayed HTML document has several frames, one such event | |
755 | will be generated per frame. | |
236cff73 | 756 | @event{EVT_WEBVIEW_LOADED(id, func)} |
ce7fe42e | 757 | Process a @c wxEVT_WEBVIEW_LOADED event generated when the document |
34326da7 | 758 | is fully loaded and displayed. Note that if the displayed HTML document has |
113e0a92 | 759 | several frames, one such event will be generated per frame. |
236cff73 | 760 | @event{EVT_WEBVIEW_ERROR(id, func)} |
ce7fe42e | 761 | Process a @c wxEVT_WEBVIEW_ERROR event generated when a navigation |
968a7de2 | 762 | error occurs. |
276c32e1 | 763 | The integer associated with this event will be a #wxWebViewNavigationError item. |
968a7de2 SL |
764 | The string associated with this event may contain a backend-specific more |
765 | precise error message/code. | |
236cff73 | 766 | @event{EVT_WEBVIEW_NEWWINDOW(id, func)} |
ce7fe42e | 767 | Process a @c wxEVT_WEBVIEW_NEWWINDOW event, generated when a new |
34326da7 | 768 | window is created. You must handle this event if you want anything to |
d676fb21 | 769 | happen, for example to load the page in a new window or tab. |
236cff73 | 770 | @event{EVT_WEBVIEW_TITLE_CHANGED(id, func)} |
ce7fe42e | 771 | Process a @c wxEVT_WEBVIEW_TITLE_CHANGED event, generated when |
153530af | 772 | the page title changes. Use GetString to get the title. |
968a7de2 | 773 | @endEventTable |
34326da7 | 774 | |
b2b31b87 | 775 | @since 2.9.3 |
43d53ee5 SL |
776 | @library{wxwebview} |
777 | @category{events,webview} | |
968a7de2 SL |
778 | |
779 | @see wxWebView | |
780 | */ | |
3225a4b8 | 781 | class wxWebViewEvent : public wxNotifyEvent |
968a7de2 SL |
782 | { |
783 | public: | |
04fa04d8 SL |
784 | wxWebViewEvent(); |
785 | wxWebViewEvent(wxEventType type, int id, const wxString href, | |
3225a4b8 | 786 | const wxString target); |
968a7de2 SL |
787 | |
788 | /** | |
45aa63c2 SL |
789 | Get the name of the target frame which the url of this event |
790 | has been or will be loaded into. This may return an emptry string | |
c44db939 | 791 | if the frame is not available. |
968a7de2 SL |
792 | */ |
793 | const wxString& GetTarget() const; | |
794 | ||
e40741b9 SL |
795 | /** |
796 | Get the URL being visited | |
797 | */ | |
798 | const wxString& GetURL() const; | |
cce10ca0 RD |
799 | }; |
800 | ||
801 | ||
ce7fe42e VZ |
802 | wxEventType wxEVT_WEBVIEW_NAVIGATING; |
803 | wxEventType wxEVT_WEBVIEW_NAVIGATED; | |
804 | wxEventType wxEVT_WEBVIEW_LOADED; | |
805 | wxEventType wxEVT_WEBVIEW_ERROR; | |
806 | wxEventType wxEVT_WEBVIEW_NEWWINDOW; | |
807 | wxEventType wxEVT_WEBVIEW_TITLE_CHANGED; |