]> git.saurik.com Git - wxWidgets.git/blame - src/common/webview.cpp
wxMessageBox off the main thread lost result code.
[wxWidgets.git] / src / common / webview.cpp
CommitLineData
61b98a2d
SL
1/////////////////////////////////////////////////////////////////////////////
2// Name: webview.cpp
3// Purpose: Common interface and events for web view component
4// Author: Marianne Gagnon
153530af 5// Copyright: (c) 2010 Marianne Gagnon, 2011 Steven Lamerton
61b98a2d
SL
6// Licence: wxWindows licence
7/////////////////////////////////////////////////////////////////////////////
8
384b8d9f
SL
9// For compilers that support precompilation, includes "wx.h".
10#include "wx/wxprec.h"
11
88cc66f7 12#if wxUSE_WEBVIEW
9c805dec 13
384b8d9f
SL
14#if defined(__BORLANDC__)
15 #pragma hdrstop
16#endif
17
61b98a2d
SL
18#include "wx/webview.h"
19
91614f1a 20#if defined(__WXOSX_COCOA__) || defined(__WXOSX_CARBON__)
8290e3cd 21#include "wx/osx/webview_webkit.h"
91614f1a 22#elif defined(__WXGTK__)
8290e3cd 23#include "wx/gtk/webview_webkit.h"
91614f1a 24#elif defined(__WXMSW__)
8290e3cd 25#include "wx/msw/webview_ie.h"
91614f1a 26#endif
61b98a2d 27
3544f421
SL
28// DLL options compatibility check:
29#include "wx/app.h"
467d261e 30WX_CHECK_BUILD_OPTIONS("wxWEBVIEW")
3544f421 31
467d261e
SL
32extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewNameStr[] = "wxWebView";
33extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewDefaultURLStr[] = "about:blank";
4c687fff
SL
34extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendIE[] = "wxWebViewIE";
35extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendWebKit[] = "wxWebViewWebKit";
36
37#ifdef __WXMSW__
38extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendDefault[] = "wxWebViewIE";
39#else
40extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendDefault[] = "wxWebViewWebKit";
41#endif
61b98a2d 42
cddf4541 43wxIMPLEMENT_ABSTRACT_CLASS(wxWebView, wxControl);
04fa04d8
SL
44wxIMPLEMENT_DYNAMIC_CLASS(wxWebViewEvent, wxCommandEvent);
45
ce7fe42e
VZ
46wxDEFINE_EVENT( wxEVT_WEBVIEW_NAVIGATING, wxWebViewEvent );
47wxDEFINE_EVENT( wxEVT_WEBVIEW_NAVIGATED, wxWebViewEvent );
48wxDEFINE_EVENT( wxEVT_WEBVIEW_LOADED, wxWebViewEvent );
49wxDEFINE_EVENT( wxEVT_WEBVIEW_ERROR, wxWebViewEvent );
50wxDEFINE_EVENT( wxEVT_WEBVIEW_NEWWINDOW, wxWebViewEvent );
51wxDEFINE_EVENT( wxEVT_WEBVIEW_TITLE_CHANGED, wxWebViewEvent );
61b98a2d 52
4c687fff
SL
53wxStringWebViewFactoryMap wxWebView::m_factoryMap;
54
55// static
56wxWebView* wxWebView::New(const wxString& backend)
57{
58 wxStringWebViewFactoryMap::iterator iter = FindFactory(backend);
59
60 if(iter == m_factoryMap.end())
61 return NULL;
62 else
63 return (*iter).second->Create();
64}
65
66// static
67wxWebView* wxWebView::New(wxWindow* parent, wxWindowID id, const wxString& url,
68 const wxPoint& pos, const wxSize& size,
69 const wxString& backend, long style,
70 const wxString& name)
71{
72 wxStringWebViewFactoryMap::iterator iter = FindFactory(backend);
73
74 if(iter == m_factoryMap.end())
75 return NULL;
76 else
77 return (*iter).second->Create(parent, id, url, pos, size, style, name);
78
79}
80
61b98a2d 81// static
4c687fff
SL
82void wxWebView::RegisterFactory(const wxString& backend,
83 wxSharedPtr<wxWebViewFactory> factory)
61b98a2d 84{
4c687fff 85 m_factoryMap[backend] = factory;
61b98a2d
SL
86}
87
4c687fff
SL
88// static
89wxStringWebViewFactoryMap::iterator wxWebView::FindFactory(const wxString &backend)
90{
8fdbcf4d
SL
91 // Initialise the map, it checks internally for existing factories
92 InitFactoryMap();
4c687fff
SL
93
94 return m_factoryMap.find(backend);
95}
96
61b98a2d 97// static
4c687fff 98void wxWebView::InitFactoryMap()
61b98a2d 99{
4c687fff 100#ifdef __WXMSW__
8fdbcf4d
SL
101 if(m_factoryMap.find(wxWebViewBackendIE) == m_factoryMap.end())
102 RegisterFactory(wxWebViewBackendIE, wxSharedPtr<wxWebViewFactory>
4c687fff
SL
103 (new wxWebViewFactoryIE));
104#else
8fdbcf4d
SL
105 if(m_factoryMap.find(wxWebViewBackendWebKit) == m_factoryMap.end())
106 RegisterFactory(wxWebViewBackendWebKit, wxSharedPtr<wxWebViewFactory>
4c687fff
SL
107 (new wxWebViewFactoryWebKit));
108#endif
61b98a2d 109}
9c805dec 110
88cc66f7 111#endif // wxUSE_WEBVIEW