]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/webview.h
Add some missing wxGraphicsContext methods
[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
ce7fe42e 247 that are provided. Specifically @c wxEVT_WEBVIEW_LOADED notifies
34326da7 248 when the page or a sub-frame has finished loading and
ce7fe42e 249 @c wxEVT_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 268 @event{EVT_WEBVIEW_NAVIGATING(id, func)}
ce7fe42e 269 Process a @c wxEVT_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 273 @event{EVT_WEBVIEW_NAVIGATED(id, func)}
ce7fe42e 274 Process a @c wxEVT_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 278 @event{EVT_WEBVIEW_LOADED(id, func)}
ce7fe42e 279 Process a @c wxEVT_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 282 @event{EVT_WEBVIEW_ERROR(id, func)}
ce7fe42e 283 Process a @c wxEVT_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 288 @event{EVT_WEBVIEW_NEWWINDOW(id, func)}
ce7fe42e 289 Process a @c wxEVT_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 292 @event{EVT_WEBVIEW_TITLE_CHANGED(id, func)}
ce7fe42e 293 Process a @c wxEVT_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.
178a73f3
SL
469 @note When using @c wxWEBVIEW_BACKEND_IE you must wait for the current
470 page to finish loading before calling SetPage(). The baseURL
471 parameter is not used in this backend.
968a7de2
SL
472 */
473 virtual void SetPage(const wxString& html, const wxString& baseUrl) = 0;
474
475 /**
476 Set the displayed page source to the contents of the given stream.
477 @param html The stream to read HTML data from.
478 @param baseUrl URL assigned to the HTML data, to be used to resolve
479 relative paths, for instance.
480 */
2339d6df 481 virtual void SetPage(wxInputStream& html, wxString baseUrl);
968a7de2
SL
482
483 /**
484 Stop the current page loading process, if any.
236cff73
SL
485 May trigger an error event of type @c wxWEBVIEW_NAV_ERR_USER_CANCELLED.
486 TODO: make @c wxWEBVIEW_NAV_ERR_USER_CANCELLED errors uniform across ports.
968a7de2
SL
487 */
488 virtual void Stop() = 0;
489
490 /**
491 @name Clipboard
492 */
493
494 /**
495 Returns @true if the current selection can be copied.
34326da7 496
6849a4b7 497 @note This always returns @c true on the OSX WebKit backend.
968a7de2 498 */
e669ddde 499 virtual bool CanCopy() const = 0;
968a7de2
SL
500
501 /**
502 Returns @true if the current selection can be cut.
34326da7 503
6849a4b7 504 @note This always returns @c true on the OSX WebKit backend.
968a7de2 505 */
e669ddde 506 virtual bool CanCut() const = 0;
968a7de2
SL
507
508 /**
509 Returns @true if data can be pasted.
34326da7 510
6849a4b7 511 @note This always returns @c true on the OSX WebKit backend.
968a7de2 512 */
e669ddde 513 virtual bool CanPaste() const = 0;
968a7de2
SL
514
515 /**
34326da7 516 Copies the current selection.
968a7de2
SL
517 */
518 virtual void Copy() = 0;
519
520 /**
521 Cuts the current selection.
522 */
523 virtual void Cut() = 0;
524
525 /**
526 Pastes the current data.
527 */
528 virtual void Paste() = 0;
529
c420d57b
SL
530 /**
531 @name Context Menu
532 */
533
534 /**
103df4a1
VZ
535 Enable or disable the right click context menu.
536
537 By default the standard context menu is enabled, this method can be
538 used to disable it or re-enable it later.
539
540 @since 2.9.5
c420d57b
SL
541 */
542 virtual void EnableContextMenu(bool enable = true);
543
544 /**
545 Returns @true if a context menu will be shown on right click.
103df4a1
VZ
546
547 @since 2.9.5
c420d57b
SL
548 */
549 virtual bool IsContextMenuEnabled() const;
550
968a7de2
SL
551 /**
552 @name History
553 */
554
34326da7 555 /**
968a7de2
SL
556 Returns @true if it is possible to navigate backward in the history of
557 visited pages.
558 */
e669ddde 559 virtual bool CanGoBack() const = 0;
968a7de2 560
34326da7 561 /**
968a7de2
SL
562 Returns @true if it is possible to navigate forward in the history of
563 visited pages.
564 */
e669ddde 565 virtual bool CanGoForward() const = 0;
968a7de2
SL
566
567 /**
568 Clear the history, this will also remove the visible page.
569 */
570 virtual void ClearHistory() = 0;
571
572 /**
573 Enable or disable the history. This will also clear the history.
574 */
575 virtual void EnableHistory(bool enable = true) = 0;
576
577 /**
578 Returns a list of items in the back history. The first item in the
579 vector is the first page that was loaded by the control.
580 */
c13d6ac1 581 virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetBackwardHistory() = 0;
968a7de2
SL
582
583 /**
34326da7
SL
584 Returns a list of items in the forward history. The first item in the
585 vector is the next item in the history with respect to the curently
968a7de2
SL
586 loaded page.
587 */
c13d6ac1 588 virtual wxVector<wxSharedPtr<wxWebViewHistoryItem> > GetForwardHistory() = 0;
968a7de2 589
34326da7 590 /**
968a7de2
SL
591 Navigate back in the history of visited pages.
592 Only valid if CanGoBack() returns true.
593 */
594 virtual void GoBack() = 0;
595
596 /**
597 Navigate forward in the history of visited pages.
598 Only valid if CanGoForward() returns true.
599 */
600 virtual void GoForward() = 0;
601
602 /**
34326da7 603 Loads a history item.
968a7de2 604 */
c13d6ac1 605 virtual void LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item) = 0;
34326da7 606
63a65070
SL
607 /**
608 @name Selection
609 */
34326da7 610
41933aa5 611 /**
34326da7 612 Clears the current selection.
41933aa5
SL
613 */
614 virtual void ClearSelection() = 0;
34326da7 615
63a65070 616 /**
236cff73 617 Deletes the current selection. Note that for @c wxWEBVIEW_BACKEND_WEBKIT
34326da7 618 the selection must be editable, either through SetEditable or the
63a65070
SL
619 correct HTML attribute.
620 */
621 virtual void DeleteSelection() = 0;
34326da7 622
0fe8a1b6 623 /**
97ba4d81 624 Returns the currently selected source, if any.
0fe8a1b6 625 */
e669ddde 626 virtual wxString GetSelectedSource() const = 0;
34326da7 627
c9355a3d
SL
628 /**
629 Returns the currently selected text, if any.
630 */
e669ddde 631 virtual wxString GetSelectedText() const = 0;
63a65070
SL
632
633 /**
634 Returns @true if there is a current selection.
635 */
e669ddde 636 virtual bool HasSelection() const = 0;
63a65070
SL
637
638 /**
639 Selects the entire page.
640 */
641 virtual void SelectAll() = 0;
968a7de2
SL
642
643 /**
644 @name Undo / Redo
645 */
646
647 /**
648 Returns @true if there is an action to redo.
649 */
e669ddde 650 virtual bool CanRedo() const = 0;
968a7de2
SL
651
652 /**
653 Returns @true if there is an action to undo.
654 */
e669ddde 655 virtual bool CanUndo() const = 0;
968a7de2
SL
656
657 /**
658 Redos the last action.
659 */
660 virtual void Redo() = 0;
661
662 /**
663 Undos the last action.
664 */
665 virtual void Undo() = 0;
666
66ac0400
SL
667 /**
668 @name Finding
669 */
670
671 /**
672 Finds a phrase on the current page and if found, the control will
673 scroll the phrase into view and select it.
674 @param text The phrase to search for.
675 @param flags The flags for the search.
676 @return If search phrase was not found in combination with the flags
677 then @c wxNOT_FOUND is returned. If called for the first time
0bfd90b3 678 with search phrase then the total number of results will be
66ac0400
SL
679 returned. Then for every time its called with the same search
680 phrase it will return the number of the current match.
681 @note This function will restart the search if the flags
236cff73 682 @c wxWEBVIEW_FIND_ENTIRE_WORD or @c wxWEBVIEW_FIND_MATCH_CASE
66ac0400 683 are changed, since this will require a new search. To reset the
0bfd90b3 684 search, for example reseting the highlights call the function
66ac0400
SL
685 with an empty search phrase. This always returns @c wxNOT_FOUND
686 on the OSX WebKit backend.
687 @since 2.9.5
688 */
236cff73 689 virtual long Find(const wxString& text, wxWebViewFindFlags flags = wxWEBVIEW_FIND_DEFAULT) = 0;
66ac0400 690
968a7de2
SL
691 /**
692 @name Zoom
693 */
694
695 /**
696 Retrieve whether the current HTML engine supports a zoom type.
697 @param type The zoom type to test.
698 @return Whether this type of zoom is supported by this HTML engine
699 (and thus can be set through SetZoomType()).
700 */
701 virtual bool CanSetZoomType(wxWebViewZoomType type) const = 0;
702
703 /**
704 Get the zoom factor of the page.
705 @return The current level of zoom.
706 */
e669ddde 707 virtual wxWebViewZoom GetZoom() const = 0;
968a7de2
SL
708
709 /**
710 Get how the zoom factor is currently interpreted.
711 @return How the zoom factor is currently interpreted by the HTML engine.
712 */
713 virtual wxWebViewZoomType GetZoomType() const = 0;
714
715 /**
716 Set the zoom factor of the page.
717 @param zoom How much to zoom (scale) the HTML document.
718 */
719 virtual void SetZoom(wxWebViewZoom zoom) = 0;
720
721 /**
722 Set how to interpret the zoom factor.
723 @param zoomType How the zoom factor should be interpreted by the
724 HTML engine.
725 @note invoke CanSetZoomType() first, some HTML renderers may not
726 support all zoom types.
727 */
728 virtual void SetZoomType(wxWebViewZoomType zoomType) = 0;
729};
730
731
732
733
734/**
04fa04d8 735 @class wxWebViewEvent
968a7de2 736
34326da7 737 A navigation event holds information about events associated with
968a7de2
SL
738 wxWebView objects.
739
04fa04d8 740 @beginEventEmissionTable{wxWebViewEvent}
236cff73 741 @event{EVT_WEBVIEW_NAVIGATING(id, func)}
ce7fe42e 742 Process a @c wxEVT_WEBVIEW_NAVIGATING event, generated before trying
968a7de2
SL
743 to get a resource. This event may be vetoed to prevent navigating to this
744 resource. Note that if the displayed HTML document has several frames, one
745 such event will be generated per frame.
236cff73 746 @event{EVT_WEBVIEW_NAVIGATED(id, func)}
ce7fe42e 747 Process a @c wxEVT_WEBVIEW_NAVIGATED event generated after it was
968a7de2
SL
748 confirmed that a resource would be requested. This event may not be vetoed.
749 Note that if the displayed HTML document has several frames, one such event
750 will be generated per frame.
236cff73 751 @event{EVT_WEBVIEW_LOADED(id, func)}
ce7fe42e 752 Process a @c wxEVT_WEBVIEW_LOADED event generated when the document
34326da7 753 is fully loaded and displayed. Note that if the displayed HTML document has
113e0a92 754 several frames, one such event will be generated per frame.
236cff73 755 @event{EVT_WEBVIEW_ERROR(id, func)}
ce7fe42e 756 Process a @c wxEVT_WEBVIEW_ERROR event generated when a navigation
968a7de2 757 error occurs.
276c32e1 758 The integer associated with this event will be a #wxWebViewNavigationError item.
968a7de2
SL
759 The string associated with this event may contain a backend-specific more
760 precise error message/code.
236cff73 761 @event{EVT_WEBVIEW_NEWWINDOW(id, func)}
ce7fe42e 762 Process a @c wxEVT_WEBVIEW_NEWWINDOW event, generated when a new
34326da7 763 window is created. You must handle this event if you want anything to
d676fb21 764 happen, for example to load the page in a new window or tab.
236cff73 765 @event{EVT_WEBVIEW_TITLE_CHANGED(id, func)}
ce7fe42e 766 Process a @c wxEVT_WEBVIEW_TITLE_CHANGED event, generated when
153530af 767 the page title changes. Use GetString to get the title.
968a7de2 768 @endEventTable
34326da7 769
b2b31b87 770 @since 2.9.3
43d53ee5
SL
771 @library{wxwebview}
772 @category{events,webview}
968a7de2
SL
773
774 @see wxWebView
775*/
3225a4b8 776class wxWebViewEvent : public wxNotifyEvent
968a7de2
SL
777{
778public:
04fa04d8
SL
779 wxWebViewEvent();
780 wxWebViewEvent(wxEventType type, int id, const wxString href,
3225a4b8 781 const wxString target);
968a7de2
SL
782
783 /**
45aa63c2
SL
784 Get the name of the target frame which the url of this event
785 has been or will be loaded into. This may return an emptry string
c44db939 786 if the frame is not available.
968a7de2
SL
787 */
788 const wxString& GetTarget() const;
789
e40741b9
SL
790 /**
791 Get the URL being visited
792 */
793 const wxString& GetURL() const;
cce10ca0
RD
794};
795
796
ce7fe42e
VZ
797wxEventType wxEVT_WEBVIEW_NAVIGATING;
798wxEventType wxEVT_WEBVIEW_NAVIGATED;
799wxEventType wxEVT_WEBVIEW_LOADED;
800wxEventType wxEVT_WEBVIEW_ERROR;
801wxEventType wxEVT_WEBVIEW_NEWWINDOW;
802wxEventType wxEVT_WEBVIEW_TITLE_CHANGED;