]>
Commit | Line | Data |
---|---|---|
61b98a2d SL |
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 | ||
384b8d9f SL |
10 | // For compilers that support precompilation, includes "wx.h". |
11 | #include "wx/wxprec.h" | |
12 | ||
9c805dec SL |
13 | #if wxUSE_WEB |
14 | ||
384b8d9f SL |
15 | #if defined(__BORLANDC__) |
16 | #pragma hdrstop | |
17 | #endif | |
18 | ||
61b98a2d SL |
19 | #include "wx/webview.h" |
20 | ||
8290e3cd SL |
21 | #include "wx/osx/webview_webkit.h" |
22 | #include "wx/gtk/webview_webkit.h" | |
23 | #include "wx/msw/webview_ie.h" | |
61b98a2d | 24 | |
3544f421 SL |
25 | // DLL options compatibility check: |
26 | #include "wx/app.h" | |
27 | WX_CHECK_BUILD_OPTIONS("wxWEB") | |
28 | ||
9c805dec SL |
29 | extern WXDLLIMPEXP_DATA_WEB(const char) wxWebViewNameStr[] = "wxWebView"; |
30 | extern WXDLLIMPEXP_DATA_WEB(const char) wxWebViewDefaultURLStr[] = "about:blank"; | |
61b98a2d SL |
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 ); | |
853b6cd0 | 38 | wxDEFINE_EVENT( wxEVT_COMMAND_WEB_VIEW_NEWWINDOW, wxWebNavigationEvent ); |
61b98a2d SL |
39 | |
40 | // static | |
41 | wxWebView* wxWebView::New(wxWebViewBackend backend) | |
42 | { | |
43 | switch (backend) | |
44 | { | |
ea179539 | 45 | #if defined(wxUSE_WEBVIEW_WEBKIT) && defined(__WXOSX__) |
61b98a2d SL |
46 | case wxWEB_VIEW_BACKEND_OSX_WEBKIT: |
47 | return new wxOSXWebKitCtrl(); | |
48 | #endif | |
49 | ||
ea179539 | 50 | #if defined(wxUSE_WEBVIEW_WEBKIT) && defined(__WXGTK__) |
61b98a2d | 51 | case wxWEB_VIEW_BACKEND_GTK_WEBKIT: |
b64b4e70 | 52 | return new wxWebViewWebKit(); |
61b98a2d SL |
53 | #endif |
54 | ||
ea179539 | 55 | #if wxUSE_WEBVIEW_IE |
61b98a2d | 56 | case wxWEB_VIEW_BACKEND_IE: |
97ad1425 | 57 | return new wxWebViewIE(); |
61b98a2d SL |
58 | #endif |
59 | ||
60 | case wxWEB_VIEW_BACKEND_DEFAULT: | |
61 | ||
ea179539 | 62 | #if defined(wxUSE_WEBVIEW_WEBKIT) && defined(__WXOSX__) |
61b98a2d SL |
63 | return new wxOSXWebKitCtrl(); |
64 | #endif | |
65 | ||
ea179539 | 66 | #if defined(wxUSE_WEBVIEW_WEBKIT) && defined(__WXGTK__) |
b64b4e70 | 67 | return new wxWebViewWebKit(); |
61b98a2d SL |
68 | #endif |
69 | ||
ea179539 | 70 | #if wxUSE_WEBVIEW_IE |
97ad1425 | 71 | return new wxWebViewIE(); |
61b98a2d SL |
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 | { | |
ea179539 | 92 | #if defined(wxUSE_WEBVIEW_WEBKIT) && defined(__WXOSX__) |
61b98a2d SL |
93 | case wxWEB_VIEW_BACKEND_OSX_WEBKIT: |
94 | return new wxOSXWebKitCtrl(parent, id, url, pos, size, style, | |
95 | name); | |
96 | #endif | |
97 | ||
ea179539 | 98 | #if defined(wxUSE_WEBVIEW_WEBKIT) && defined(__WXGTK__) |
61b98a2d | 99 | case wxWEB_VIEW_BACKEND_GTK_WEBKIT: |
b64b4e70 | 100 | return new wxWebViewWebKit(parent, id, url, pos, size, style, |
61b98a2d SL |
101 | name); |
102 | #endif | |
103 | ||
ea179539 | 104 | #if wxUSE_WEBVIEW_IE |
61b98a2d | 105 | case wxWEB_VIEW_BACKEND_IE: |
97ad1425 | 106 | return new wxWebViewIE(parent, id, url, pos, size, style, name); |
61b98a2d SL |
107 | #endif |
108 | ||
109 | case wxWEB_VIEW_BACKEND_DEFAULT: | |
110 | ||
ea179539 | 111 | #if defined(wxUSE_WEBVIEW_WEBKIT) && defined(__WXOSX__) |
61b98a2d SL |
112 | return new wxOSXWebKitCtrl(parent, id, url, pos, size, style, name); |
113 | #endif | |
114 | ||
ea179539 | 115 | #if defined(wxUSE_WEBVIEW_WEBKIT) && defined(__WXGTK__) |
b64b4e70 | 116 | return new wxWebViewWebKit(parent, id, url, pos, size, style, name); |
61b98a2d SL |
117 | #endif |
118 | ||
ea179539 | 119 | #if wxUSE_WEBVIEW_IE |
97ad1425 | 120 | return new wxWebViewIE(parent, id, url, pos, size, style, name); |
61b98a2d SL |
121 | #endif |
122 | ||
123 | // fall-through intended | |
124 | default: | |
125 | return NULL; | |
126 | } | |
127 | } | |
9c805dec SL |
128 | |
129 | #endif // wxUSE_WEB |