1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Common interface and events for web view component
4 // Author: Marianne Gagnon
6 // Copyright: (c) 2010 Marianne Gagnon, 2011 Steven Lamerton
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
15 #if defined(__BORLANDC__)
19 #include "wx/webview.h"
21 #if defined(__WXOSX_COCOA__) || defined(__WXOSX_CARBON__)
22 #include "wx/osx/webview_webkit.h"
23 #elif defined(__WXGTK__)
24 #include "wx/gtk/webview_webkit.h"
25 #elif defined(__WXMSW__)
26 #include "wx/msw/webview_ie.h"
29 // DLL options compatibility check:
31 WX_CHECK_BUILD_OPTIONS("wxWEBVIEW")
33 extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewNameStr
[] = "wxWebView";
34 extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewDefaultURLStr
[] = "about:blank";
35 extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendIE
[] = "wxWebViewIE";
36 extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendWebKit
[] = "wxWebViewWebKit";
39 extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendDefault
[] = "wxWebViewIE";
41 extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendDefault
[] = "wxWebViewWebKit";
44 wxIMPLEMENT_ABSTRACT_CLASS(wxWebView
, wxControl
);
45 wxIMPLEMENT_DYNAMIC_CLASS(wxWebViewEvent
, wxCommandEvent
);
47 wxDEFINE_EVENT( wxEVT_WEBVIEW_NAVIGATING
, wxWebViewEvent
);
48 wxDEFINE_EVENT( wxEVT_WEBVIEW_NAVIGATED
, wxWebViewEvent
);
49 wxDEFINE_EVENT( wxEVT_WEBVIEW_LOADED
, wxWebViewEvent
);
50 wxDEFINE_EVENT( wxEVT_WEBVIEW_ERROR
, wxWebViewEvent
);
51 wxDEFINE_EVENT( wxEVT_WEBVIEW_NEWWINDOW
, wxWebViewEvent
);
52 wxDEFINE_EVENT( wxEVT_WEBVIEW_TITLE_CHANGED
, wxWebViewEvent
);
54 wxStringWebViewFactoryMap
wxWebView::m_factoryMap
;
57 wxWebView
* wxWebView::New(const wxString
& backend
)
59 wxStringWebViewFactoryMap::iterator iter
= FindFactory(backend
);
61 if(iter
== m_factoryMap
.end())
64 return (*iter
).second
->Create();
68 wxWebView
* wxWebView::New(wxWindow
* parent
, wxWindowID id
, const wxString
& url
,
69 const wxPoint
& pos
, const wxSize
& size
,
70 const wxString
& backend
, long style
,
73 wxStringWebViewFactoryMap::iterator iter
= FindFactory(backend
);
75 if(iter
== m_factoryMap
.end())
78 return (*iter
).second
->Create(parent
, id
, url
, pos
, size
, style
, name
);
83 void wxWebView::RegisterFactory(const wxString
& backend
,
84 wxSharedPtr
<wxWebViewFactory
> factory
)
86 m_factoryMap
[backend
] = factory
;
90 wxStringWebViewFactoryMap::iterator
wxWebView::FindFactory(const wxString
&backend
)
92 // Initialise the map if needed
93 if(m_factoryMap
.empty())
96 return m_factoryMap
.find(backend
);
100 void wxWebView::InitFactoryMap()
103 RegisterFactory(wxWebViewBackendIE
, wxSharedPtr
<wxWebViewFactory
>
104 (new wxWebViewFactoryIE
));
106 RegisterFactory(wxWebViewBackendWebKit
, wxSharedPtr
<wxWebViewFactory
>
107 (new wxWebViewFactoryWebKit
));
111 #endif // wxUSE_WEBVIEW