Simplify backend enum naming, we do not need separate values for gtk and osx webkit...
[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
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
40 // static
41 wxWebView* wxWebView::New(wxWebViewBackend backend)
42 {
43 switch (backend)
44 {
45 #if defined(wxUSE_WEBVIEW_WEBKIT) && \
46 (defined(__WXGTK__) || defined(__WXOSX__))
47 case wxWEB_VIEW_BACKEND_WEBKIT:
48 return new wxWebViewWebKit();
49 #endif
50
51 #if wxUSE_WEBVIEW_IE
52 case wxWEB_VIEW_BACKEND_IE:
53 return new wxWebViewIE();
54 #endif
55
56 case wxWEB_VIEW_BACKEND_DEFAULT:
57
58 #if defined(wxUSE_WEBVIEW_WEBKIT) && \
59 (defined(__WXGTK__) || defined(__WXOSX__))
60 return new wxWebViewWebKit();
61 #endif
62
63 #if wxUSE_WEBVIEW_IE
64 return new wxWebViewIE();
65 #endif
66
67 // fall-through intended
68 default:
69 return NULL;
70 }
71 }
72
73 // static
74 wxWebView* wxWebView::New(wxWindow* parent,
75 wxWindowID id,
76 const wxString& url,
77 const wxPoint& pos,
78 const wxSize& size,
79 wxWebViewBackend backend,
80 long style,
81 const wxString& name)
82 {
83 switch (backend)
84 {
85 #if defined(wxUSE_WEBVIEW_WEBKIT) && \
86 (defined(__WXGTK__) || defined(__WXOSX__))
87 case wxWEB_VIEW_BACKEND_WEBKIT:
88 return new wxWebViewWebKit(parent, id, url, pos, size, style, name);
89 #endif
90
91 #if wxUSE_WEBVIEW_IE
92 case wxWEB_VIEW_BACKEND_IE:
93 return new wxWebViewIE(parent, id, url, pos, size, style, name);
94 #endif
95
96 case wxWEB_VIEW_BACKEND_DEFAULT:
97
98 #if defined(wxUSE_WEBVIEW_WEBKIT) && \
99 (defined(__WXGTK__) || defined(__WXOSX__))
100 return new wxWebViewWebKit(parent, id, url, pos, size, style, name);
101 #endif
102
103 #if wxUSE_WEBVIEW_IE
104 return new wxWebViewIE(parent, id, url, pos, size, style, name);
105 #endif
106
107 // fall-through intended
108 default:
109 return NULL;
110 }
111 }
112
113 #endif // wxUSE_WEB