webview.h 26 KB

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