2
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation; version 2 of the
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20
#ifndef _WebBROWSER_H_
21
#define _WebBROWSER_H_
23
#include <mforms/view.h>
27
#ifndef DOXYGEN_SHOULD_SKIP_THIS
31
struct MFORMS_EXPORT WebBrowserImplPtrs
33
bool (__stdcall *create)(WebBrowser*);
34
void (__stdcall *set_html)(WebBrowser*, const std::string&);
35
void (__stdcall *navigate)(WebBrowser*, const std::string&);
36
std::string (__stdcall *get_document_title)(WebBrowser*);
43
This is implemented using the native Browser widget (IE in Windows and WebKit in Mac)
44
Currently not supported in Linux */
45
class MFORMS_EXPORT WebBrowser : public View
50
/** Sets an HTML file to be displayed */
51
void set_html(const std::string &path);
52
/** Opens given URL in the brower */
53
void navigate(const std::string &url);
54
/** Gets the title of the displayed document */
55
std::string get_document_title();
57
/** Sets a handle for link clicks */
58
void set_link_click_handler(const boost::function<bool (const std::string &)> &slot);
61
/** Signal emitted when the document finishes loading
63
In Python use add_loaded_callback()
65
boost::signals2::signal<void (const std::string&)>* signal_loaded() { return &_document_loaded; }
66
#ifndef DOXYGEN_SHOULD_SKIP_THIS
67
virtual void document_loaded(const std::string& actualUrl);
69
// called when a URL is clicked. A return value of true means the link was
70
// handled and the URL should not be opened by the browser
71
bool on_link_clicked(const std::string& uri);
75
WebBrowserImplPtrs *_webbrowser_impl;
76
boost::signals2::signal<void (const std::string&)> _document_loaded;
77
boost::function<bool (const std::string&)> _handle_link_click;
81
#endif // #fndef _WebBROWSER_H_