Add a new event type for new window creation, document and implement under MSW. Updat...
[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 wxHAVE_WEB_BACKEND_OSX_WEBKIT
46 case wxWEB_VIEW_BACKEND_OSX_WEBKIT:
47 return new wxOSXWebKitCtrl();
48 #endif
49
50 #if wxHAVE_WEB_BACKEND_GTK_WEBKIT
51 case wxWEB_VIEW_BACKEND_GTK_WEBKIT:
52 return new wxGtkWebKitCtrl();
53 #endif
54
55 #if wxHAVE_WEB_BACKEND_IE
56 case wxWEB_VIEW_BACKEND_IE:
57 return new wxWebViewIE();
58 #endif
59
60 case wxWEB_VIEW_BACKEND_DEFAULT:
61
62 #if wxHAVE_WEB_BACKEND_OSX_WEBKIT
63 return new wxOSXWebKitCtrl();
64 #endif
65
66 #if wxHAVE_WEB_BACKEND_GTK_WEBKIT
67 return new wxGtkWebKitCtrl();
68 #endif
69
70 #if wxHAVE_WEB_BACKEND_IE
71 return new wxWebViewIE();
72 #endif
73
74 // fall-through intended
75 default:
76 return NULL;
77 }
78 }
79
80 // static
81 wxWebView* wxWebView::New(wxWindow* parent,
82 wxWindowID id,
83 const wxString& url,
84 const wxPoint& pos,
85 const wxSize& size,
86 wxWebViewBackend backend,
87 long style,
88 const wxString& name)
89 {
90 switch (backend)
91 {
92 #if wxHAVE_WEB_BACKEND_OSX_WEBKIT
93 case wxWEB_VIEW_BACKEND_OSX_WEBKIT:
94 return new wxOSXWebKitCtrl(parent, id, url, pos, size, style,
95 name);
96 #endif
97
98 #if wxHAVE_WEB_BACKEND_GTK_WEBKIT
99 case wxWEB_VIEW_BACKEND_GTK_WEBKIT:
100 return new wxGtkWebKitCtrl(parent, id, url, pos, size, style,
101 name);
102 #endif
103
104 #if wxHAVE_WEB_BACKEND_IE
105 case wxWEB_VIEW_BACKEND_IE:
106 return new wxWebViewIE(parent, id, url, pos, size, style, name);
107 #endif
108
109 case wxWEB_VIEW_BACKEND_DEFAULT:
110
111 #if wxHAVE_WEB_BACKEND_OSX_WEBKIT
112 return new wxOSXWebKitCtrl(parent, id, url, pos, size, style, name);
113 #endif
114
115 #if wxHAVE_WEB_BACKEND_GTK_WEBKIT
116 return new wxGtkWebKitCtrl(parent, id, url, pos, size, style, name);
117 #endif
118
119 #if wxHAVE_WEB_BACKEND_IE
120 return new wxWebViewIE(parent, id, url, pos, size, style, name);
121 #endif
122
123 // fall-through intended
124 default:
125 return NULL;
126 }
127 }
128
129 #endif // wxUSE_WEB