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