]> git.saurik.com Git - wxWidgets.git/blob - src/common/webview.cpp
Remove the unused code instead of commenting it out.
[wxWidgets.git] / src / common / webview.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: webview.cpp
3 // Purpose: Common interface and events for web view component
4 // Author: Marianne Gagnon
5 // Id: $Id$
6 // Copyright: (c) 2010 Marianne Gagnon, 2011 Steven Lamerton
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
12
13 #if wxUSE_WEBVIEW
14
15 #if defined(__BORLANDC__)
16 #pragma hdrstop
17 #endif
18
19 #include "wx/webview.h"
20
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"
27 #endif
28
29 // DLL options compatibility check:
30 #include "wx/app.h"
31 WX_CHECK_BUILD_OPTIONS("wxWEBVIEW")
32
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";
37
38 #ifdef __WXMSW__
39 extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendDefault[] = "wxWebViewIE";
40 #else
41 extern WXDLLIMPEXP_DATA_WEBVIEW(const char) wxWebViewBackendDefault[] = "wxWebViewWebKit";
42 #endif
43
44 wxIMPLEMENT_ABSTRACT_CLASS(wxWebView, wxControl);
45 wxIMPLEMENT_DYNAMIC_CLASS(wxWebViewEvent, wxCommandEvent);
46
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 );
53
54 wxStringWebViewFactoryMap wxWebView::m_factoryMap;
55
56 // static
57 wxWebView* wxWebView::New(const wxString& backend)
58 {
59 wxStringWebViewFactoryMap::iterator iter = FindFactory(backend);
60
61 if(iter == m_factoryMap.end())
62 return NULL;
63 else
64 return (*iter).second->Create();
65 }
66
67 // static
68 wxWebView* wxWebView::New(wxWindow* parent, wxWindowID id, const wxString& url,
69 const wxPoint& pos, const wxSize& size,
70 const wxString& backend, long style,
71 const wxString& name)
72 {
73 wxStringWebViewFactoryMap::iterator iter = FindFactory(backend);
74
75 if(iter == m_factoryMap.end())
76 return NULL;
77 else
78 return (*iter).second->Create(parent, id, url, pos, size, style, name);
79
80 }
81
82 // static
83 void wxWebView::RegisterFactory(const wxString& backend,
84 wxSharedPtr<wxWebViewFactory> factory)
85 {
86 m_factoryMap[backend] = factory;
87 }
88
89 // static
90 wxStringWebViewFactoryMap::iterator wxWebView::FindFactory(const wxString &backend)
91 {
92 // Initialise the map if needed
93 if(m_factoryMap.empty())
94 InitFactoryMap();
95
96 return m_factoryMap.find(backend);
97 }
98
99 // static
100 void wxWebView::InitFactoryMap()
101 {
102 #ifdef __WXMSW__
103 RegisterFactory(wxWebViewBackendIE, wxSharedPtr<wxWebViewFactory>
104 (new wxWebViewFactoryIE));
105 #else
106 RegisterFactory(wxWebViewBackendWebKit, wxSharedPtr<wxWebViewFactory>
107 (new wxWebViewFactoryWebKit));
108 #endif
109 }
110
111 #endif // wxUSE_WEBVIEW