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