~ubuntu-branches/ubuntu/quantal/mysql-workbench/quantal

« back to all changes in this revision

Viewing changes to library/forms/mforms/webbrowser.h

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2012-03-01 21:57:30 UTC
  • Revision ID: package-import@ubuntu.com-20120301215730-o7y8av8y38n162ro
Tags: upstream-5.2.38+dfsg
ImportĀ upstreamĀ versionĀ 5.2.38+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
 
3
 *
 
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
 
7
 * License.
 
8
 * 
 
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.
 
13
 * 
 
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
 
17
 * 02110-1301  USA
 
18
 */
 
19
 
 
20
#ifndef _WebBROWSER_H_
 
21
#define _WebBROWSER_H_
 
22
 
 
23
#include <mforms/view.h>
 
24
 
 
25
namespace mforms {
 
26
 
 
27
#ifndef DOXYGEN_SHOULD_SKIP_THIS
 
28
#ifndef SWIG
 
29
  class WebBrowser;
 
30
 
 
31
  struct MFORMS_EXPORT WebBrowserImplPtrs
 
32
  {
 
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*);
 
37
  };
 
38
#endif
 
39
#endif
 
40
 
 
41
  /** HTML browser.
 
42
   
 
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
 
46
  {
 
47
  public:
 
48
    WebBrowser();
 
49
 
 
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();
 
56
 
 
57
    /** Sets a handle for link clicks */
 
58
    void set_link_click_handler(const boost::function<bool (const std::string &)> &slot);
 
59
 
 
60
#ifndef SWIG
 
61
    /** Signal emitted when the document finishes loading 
 
62
     
 
63
     In Python use add_loaded_callback()
 
64
     */
 
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);
 
68
 
 
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);
 
72
#endif
 
73
#endif
 
74
  protected:
 
75
    WebBrowserImplPtrs *_webbrowser_impl;
 
76
    boost::signals2::signal<void (const std::string&)> _document_loaded;
 
77
    boost::function<bool (const std::string&)> _handle_link_click;
 
78
  };
 
79
};
 
80
 
 
81
#endif // #fndef _WebBROWSER_H_