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