Overhaul wxWebHandler naming to try and make it consistent with the rest of wxWidgets...
[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_WEB
14
15 #if defined(__BORLANDC__)
16 #pragma hdrstop
17 #endif
18
19 #include "wx/webview.h"
20
21 #include "wx/osx/webview_webkit.h"
22 #include "wx/gtk/webview_webkit.h"
23 #include "wx/msw/webview_ie.h"
24
25 // DLL options compatibility check:
26 #include "wx/app.h"
27 WX_CHECK_BUILD_OPTIONS("wxWEB")
28
29 extern WXDLLIMPEXP_DATA_WEB(const char) wxWebViewNameStr[] = "wxWebView";
30 extern WXDLLIMPEXP_DATA_WEB(const char) wxWebViewDefaultURLStr[] = "about:blank";
31
32 IMPLEMENT_DYNAMIC_CLASS(wxWebNavigationEvent, wxCommandEvent)
33
34 wxDEFINE_EVENT( wxEVT_COMMAND_WEB_VIEW_NAVIGATING, wxWebNavigationEvent );
35 wxDEFINE_EVENT( wxEVT_COMMAND_WEB_VIEW_NAVIGATED, wxWebNavigationEvent );
36 wxDEFINE_EVENT( wxEVT_COMMAND_WEB_VIEW_LOADED, wxWebNavigationEvent );
37 wxDEFINE_EVENT( wxEVT_COMMAND_WEB_VIEW_ERROR, wxWebNavigationEvent );
38 wxDEFINE_EVENT( wxEVT_COMMAND_WEB_VIEW_NEWWINDOW, wxWebNavigationEvent );
39 wxDEFINE_EVENT( wxEVT_COMMAND_WEB_VIEW_TITLE_CHANGED, wxWebNavigationEvent );
40
41 // static
42 wxWebView* wxWebView::New(wxWebViewBackend backend)
43 {
44 switch (backend)
45 {
46 #if defined(wxUSE_WEBVIEW_WEBKIT) && \
47 (defined(__WXGTK__) || defined(__WXOSX__))
48 case wxWEB_VIEW_BACKEND_WEBKIT:
49 return new wxWebViewWebKit();
50 #endif
51
52 #if wxUSE_WEBVIEW_IE
53 case wxWEB_VIEW_BACKEND_IE:
54 return new wxWebViewIE();
55 #endif
56
57 case wxWEB_VIEW_BACKEND_DEFAULT:
58
59 #if defined(wxUSE_WEBVIEW_WEBKIT) && \
60 (defined(__WXGTK__) || defined(__WXOSX__))
61 return new wxWebViewWebKit();
62 #endif
63
64 #if wxUSE_WEBVIEW_IE
65 return new wxWebViewIE();
66 #endif
67
68 // fall-through intended
69 default:
70 return NULL;
71 }
72 }
73
74 // static
75 wxWebView* wxWebView::New(wxWindow* parent,
76 wxWindowID id,
77 const wxString& url,
78 const wxPoint& pos,
79 const wxSize& size,
80 wxWebViewBackend backend,
81 long style,
82 const wxString& name)
83 {
84 switch (backend)
85 {
86 #if defined(wxUSE_WEBVIEW_WEBKIT) && \
87 (defined(__WXGTK__) || defined(__WXOSX__))
88 case wxWEB_VIEW_BACKEND_WEBKIT:
89 return new wxWebViewWebKit(parent, id, url, pos, size, style, name);
90 #endif
91
92 #if wxUSE_WEBVIEW_IE
93 case wxWEB_VIEW_BACKEND_IE:
94 return new wxWebViewIE(parent, id, url, pos, size, style, name);
95 #endif
96
97 case wxWEB_VIEW_BACKEND_DEFAULT:
98
99 #if defined(wxUSE_WEBVIEW_WEBKIT) && \
100 (defined(__WXGTK__) || defined(__WXOSX__))
101 return new wxWebViewWebKit(parent, id, url, pos, size, style, name);
102 #endif
103
104 #if wxUSE_WEBVIEW_IE
105 return new wxWebViewIE(parent, id, url, pos, size, style, name);
106 #endif
107
108 // fall-through intended
109 default:
110 return NULL;
111 }
112 }
113
114 #endif // wxUSE_WEB