| 1 |
#include "wx/wxprec.h" |
| 2 |
|
| 3 |
#ifdef __BORLANDC__ |
| 4 |
#pragma hdrstop |
| 5 |
#endif |
| 6 |
|
| 7 |
#if defined(__WXMSW__) || defined(__WXMAC__) |
| 8 |
#define USE_WEBVIEW 0 |
| 9 |
#else |
| 10 |
#define USE_WEBVIEW 0 |
| 11 |
#endif |
| 12 |
|
| 13 |
#include "myxh_webview.h" |
| 14 |
#if USE_WEBVIEW |
| 15 |
#include <wx/webview.h> |
| 16 |
#else |
| 17 |
#include <wx/html/htmlwin.h> |
| 18 |
#endif |
| 19 |
|
| 20 |
MyWxWebViewXmlHandler::MyWxWebViewXmlHandler() |
| 21 |
: wxXmlResourceHandler() |
| 22 |
{ |
| 23 |
AddWindowStyles(); |
| 24 |
} |
| 25 |
|
| 26 |
wxObject* MyWxWebViewXmlHandler::DoCreateResource() |
| 27 |
{ |
| 28 |
#if USE_WEBVIEW |
| 29 |
wxString url = GetText("url", false); |
| 30 |
if(url.IsEmpty()) { url = "http://www.google.com"; } |
| 31 |
#if wxCHECK_VERSION(2, 9, 5) |
| 32 |
wxWebView* webview = wxWebView::New(m_parentAsWindow, GetID(), url, GetPosition(), GetSize(), |
| 33 |
wxWebViewBackendDefault, GetStyle(wxT("style")), GetName()); |
| 34 |
#else |
| 35 |
wxWebView* webview = wxWebView::New(m_parentAsWindow, GetID(), url, GetPosition(), GetSize(), |
| 36 |
wxWEB_VIEW_BACKEND_DEFAULT, GetStyle(wxT("style")), GetName()); |
| 37 |
#endif |
| 38 |
#else |
| 39 |
wxHtmlWindow* webview = |
| 40 |
new wxHtmlWindow(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(wxT("style")), GetName()); |
| 41 |
webview->SetPage("<html><body><b>wxWebView</b></body></html>"); |
| 42 |
#endif |
| 43 |
|
| 44 |
SetupWindow(webview); |
| 45 |
return webview; |
| 46 |
} |
| 47 |
|
| 48 |
bool MyWxWebViewXmlHandler::CanHandle(wxXmlNode* node) { return IsOfClass(node, wxT("wxWebView")); } |