1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Common interface and events for web view component
4 // Author: Marianne Gagnon
5 // Copyright: (c) 2010 Marianne Gagnon, 2011 Steven Lamerton
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
14 #if defined(__BORLANDC__)
18 #include "wx/webview.h"
20 #if defined(__WXOSX_COCOA__) || defined(__WXOSX_CARBON__)
21 #include "wx/osx/webview_webkit.h"
22 #elif defined(__WXGTK__)
23 #include "wx/gtk/webview_webkit.h"
24 #elif defined(__WXMSW__)
25 #include "wx/msw/webview_ie.h"
28 // DLL options compatibility check:
30 WX_CHECK_BUILD_OPTIONS("wxWEBVIEW")
32 extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewNameStr
[] = "wxWebView";
33 extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewDefaultURLStr
[] = "about:blank";
34 extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendIE
[] = "wxWebViewIE";
35 extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendWebKit
[] = "wxWebViewWebKit";
38 extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendDefault
[] = "wxWebViewIE";
40 extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendDefault
[] = "wxWebViewWebKit";
43 wxIMPLEMENT_ABSTRACT_CLASS(wxWebView
, wxControl
);
44 wxIMPLEMENT_DYNAMIC_CLASS(wxWebViewEvent
, wxCommandEvent
);
46 wxDEFINE_EVENT( wxEVT_WEBVIEW_NAVIGATING
, wxWebViewEvent
);
47 wxDEFINE_EVENT( wxEVT_WEBVIEW_NAVIGATED
, wxWebViewEvent
);
48 wxDEFINE_EVENT( wxEVT_WEBVIEW_LOADED
, wxWebViewEvent
);
49 wxDEFINE_EVENT( wxEVT_WEBVIEW_ERROR
, wxWebViewEvent
);
50 wxDEFINE_EVENT( wxEVT_WEBVIEW_NEWWINDOW
, wxWebViewEvent
);
51 wxDEFINE_EVENT( wxEVT_WEBVIEW_TITLE_CHANGED
, wxWebViewEvent
);
53 wxStringWebViewFactoryMap
wxWebView::m_factoryMap
;
56 wxWebView
* wxWebView::New(const wxString
& backend
)
58 wxStringWebViewFactoryMap::iterator iter
= FindFactory(backend
);
60 if(iter
== m_factoryMap
.end())
63 return (*iter
).second
->Create();
67 wxWebView
* wxWebView::New(wxWindow
* parent
, wxWindowID id
, const wxString
& url
,
68 const wxPoint
& pos
, const wxSize
& size
,
69 const wxString
& backend
, long style
,
72 wxStringWebViewFactoryMap::iterator iter
= FindFactory(backend
);
74 if(iter
== m_factoryMap
.end())
77 return (*iter
).second
->Create(parent
, id
, url
, pos
, size
, style
, name
);
82 void wxWebView::RegisterFactory(const wxString
& backend
,
83 wxSharedPtr
<wxWebViewFactory
> factory
)
85 m_factoryMap
[backend
] = factory
;
89 wxStringWebViewFactoryMap::iterator
wxWebView::FindFactory(const wxString
&backend
)
91 // Initialise the map, it checks internally for existing factories
94 return m_factoryMap
.find(backend
);
98 void wxWebView::InitFactoryMap()
101 if(m_factoryMap
.find(wxWebViewBackendIE
) == m_factoryMap
.end())
102 RegisterFactory(wxWebViewBackendIE
, wxSharedPtr
<wxWebViewFactory
>
103 (new wxWebViewFactoryIE
));
105 if(m_factoryMap
.find(wxWebViewBackendWebKit
) == m_factoryMap
.end())
106 RegisterFactory(wxWebViewBackendWebKit
, wxSharedPtr
<wxWebViewFactory
>
107 (new wxWebViewFactoryWebKit
));
111 #endif // wxUSE_WEBVIEW