]> git.saurik.com Git - wxWidgets.git/blob - src/common/webview.cpp
492745a6b85fedfce0080cbcba9a2a74c079a180
[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 defined(__BORLANDC__)
14 #pragma hdrstop
15 #endif
16
17 #include "wx/webview.h"
18
19 #include "wx/osx/webview.h"
20 #include "wx/gtk/webview.h"
21 #include "wx/msw/webviewie.h"
22
23 // DLL options compatibility check:
24 #include "wx/app.h"
25 WX_CHECK_BUILD_OPTIONS("wxWEB")
26
27 extern WXDLLEXPORT_DATA(const char) wxWebViewNameStr[] = "wxWebView";
28 extern WXDLLEXPORT_DATA(const char) wxWebViewDefaultURLStr[] = "about:blank";
29
30 IMPLEMENT_DYNAMIC_CLASS(wxWebNavigationEvent, wxCommandEvent)
31
32 wxDEFINE_EVENT( wxEVT_COMMAND_WEB_VIEW_NAVIGATING, wxWebNavigationEvent );
33 wxDEFINE_EVENT( wxEVT_COMMAND_WEB_VIEW_NAVIGATED, wxWebNavigationEvent );
34 wxDEFINE_EVENT( wxEVT_COMMAND_WEB_VIEW_LOADED, wxWebNavigationEvent );
35 wxDEFINE_EVENT( wxEVT_COMMAND_WEB_VIEW_ERROR, wxWebNavigationEvent );
36
37 // static
38 wxWebView* wxWebView::New(wxWebViewBackend backend)
39 {
40 switch (backend)
41 {
42 #if wxHAVE_WEB_BACKEND_OSX_WEBKIT
43 case wxWEB_VIEW_BACKEND_OSX_WEBKIT:
44 return new wxOSXWebKitCtrl();
45 #endif
46
47 #if wxHAVE_WEB_BACKEND_GTK_WEBKIT
48 case wxWEB_VIEW_BACKEND_GTK_WEBKIT:
49 return new wxGtkWebKitCtrl();
50 #endif
51
52 #if wxHAVE_WEB_BACKEND_IE
53 case wxWEB_VIEW_BACKEND_IE:
54 return new wxIEPanel();
55 #endif
56
57 case wxWEB_VIEW_BACKEND_DEFAULT:
58
59 #if wxHAVE_WEB_BACKEND_OSX_WEBKIT
60 return new wxOSXWebKitCtrl();
61 #endif
62
63 #if wxHAVE_WEB_BACKEND_GTK_WEBKIT
64 return new wxGtkWebKitCtrl();
65 #endif
66
67 #if wxHAVE_WEB_BACKEND_IE
68 return new wxIEPanel();
69 #endif
70
71 // fall-through intended
72 default:
73 return NULL;
74 }
75 }
76
77 // static
78 wxWebView* wxWebView::New(wxWindow* parent,
79 wxWindowID id,
80 const wxString& url,
81 const wxPoint& pos,
82 const wxSize& size,
83 wxWebViewBackend backend,
84 long style,
85 const wxString& name)
86 {
87 switch (backend)
88 {
89 #if wxHAVE_WEB_BACKEND_OSX_WEBKIT
90 case wxWEB_VIEW_BACKEND_OSX_WEBKIT:
91 return new wxOSXWebKitCtrl(parent, id, url, pos, size, style,
92 name);
93 #endif
94
95 #if wxHAVE_WEB_BACKEND_GTK_WEBKIT
96 case wxWEB_VIEW_BACKEND_GTK_WEBKIT:
97 return new wxGtkWebKitCtrl(parent, id, url, pos, size, style,
98 name);
99 #endif
100
101 #if wxHAVE_WEB_BACKEND_IE
102 case wxWEB_VIEW_BACKEND_IE:
103 return new wxIEPanel(parent, id, url, pos, size, style, name);
104 #endif
105
106 case wxWEB_VIEW_BACKEND_DEFAULT:
107
108 #if wxHAVE_WEB_BACKEND_OSX_WEBKIT
109 return new wxOSXWebKitCtrl(parent, id, url, pos, size, style, name);
110 #endif
111
112 #if wxHAVE_WEB_BACKEND_GTK_WEBKIT
113 return new wxGtkWebKitCtrl(parent, id, url, pos, size, style, name);
114 #endif
115
116 #if wxHAVE_WEB_BACKEND_IE
117 return new wxIEPanel(parent, id, url, pos, size, style, name);
118 #endif
119
120 // fall-through intended
121 default:
122 return NULL;
123 }
124 }