Debian Codegraph @

wxcrafter/controls/web_view_wrapper.cpp

raw
1 #include "web_view_wrapper.h"
2
3 #include "allocator_mgr.h"
4 #include "wxgui_helpers.h"
5
6 WebViewWrapper::WebViewWrapper()
7 : wxcWidget(ID_WXWEBVIEW)
8 {
9 RegisterEvent("wxEVT_COMMAND_WEBVIEW_NAVIGATING", "wxWebViewEvent",
10 _("Process a wxEVT_COMMAND_WEBVIEW_NAVIGATING event, generated before trying to get a resource. This "
11 "event may be vetoed to prevent navigating to this resource. Note that if the displayed HTML "
12 "document has several frames, one such event will be generated per frame"));
13 RegisterEvent("wxEVT_COMMAND_WEBVIEW_NAVIGATED", "wxWebViewEvent",
14 _("Process a wxEVT_COMMAND_WEBVIEW_NAVIGATED event generated after it was confirmed that a resource "
15 "would be requested. This event may not be vetoed. Note that if the displayed HTML document has "
16 "several frames, one such event will be generated per frame."));
17 RegisterEvent("wxEVT_COMMAND_WEBVIEW_LOADED", "wxWebViewEvent",
18 _("Process a wxEVT_COMMAND_WEBVIEW_LOADED event generated when the document is fully loaded and "
19 "displayed. Note that if the displayed HTML document has several frames, one such event will be "
20 "generated per frame."));
21 RegisterEvent("wxEVT_COMMAND_WEBVIEW_ERROR", "wxWebViewEvent",
22 _("Process a wxEVT_COMMAND_WEBVIEW_ERROR event generated when a navigation error occurs. The integer "
23 "associated with this event will be a wxWebNavigationError item. The string associated with this "
24 "event may contain a backend-specific more precise error message/code"));
25 RegisterEvent("wxEVT_COMMAND_WEBVIEW_NEWWINDOW", "wxWebViewEvent",
26 _("Process a wxEVT_COMMAND_WEBVIEW_NEWWINDOW event, generated when a new window is created. You must "
27 "handle this event if you want anything to happen, for example to load the page in a new window or "
28 "tab."));
29 RegisterEvent("wxEVT_COMMAND_WEBVIEW_TITLE_CHANGED", "wxWebViewEvent",
30 _("Process a wxEVT_COMMAND_WEBVIEW_TITLE_CHANGED event, generated when the page title changes. Use "
31 "GetString to get the title."));
32
33 SetPropertyString(_("Common Settings"), "wxWebView");
34 AddProperty(new StringProperty(PROP_URL, _("about:blank"),
35 _("URL to load by default in the web view.\nNote that the designer will display "
36 "about:blank. The preview and generated code will use the actual URL")));
37
38 EnableSizerFlag("wxEXPAND", true);
39 m_sizerItem.SetProportion(1);
40
41 m_namePattern = "m_webView";
42 SetName(GenerateName());
43
44 // All generated code by this class should be wrapped with '#if wxUSE_WEBVIEW' blocks
45 // we do this by simply telling wxcWidget that this class requires this macro definition
46 SetIfBlockCond("wxUSE_WEBVIEW");
47 }
48
49 WebViewWrapper::~WebViewWrapper() {}
50
51 wxcWidget* WebViewWrapper::Clone() const { return new WebViewWrapper(); }
52
53 wxString WebViewWrapper::CppCtorCode() const
54 {
55 wxString cppCode;
56 cppCode << GetName() << " = wxWebView::New(" << GetWindowParent() << ", " << GetId() << ", "
57 << wxCrafter::UNDERSCORE(PropertyString(PROP_URL)) << ", "
58 << "wxDefaultPosition, " << SizeAsString() << ", "
59 << "wxWebViewBackendDefault, " << StyleFlags("0") << ");\n";
60 cppCode << CPPCommonAttributes();
61 return cppCode;
62 }
63
64 void WebViewWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add("#include <wx/webview.h>"); }
65
66 wxString WebViewWrapper::GetWxClassName() const { return "wxWebView"; }
67
68 void WebViewWrapper::ToXRC(wxString& text, XRC_TYPE type) const
69 {
70 if(type == XRC_LIVE) {
71 text << XRCUnknown();
72 } else if(type == XRC_PREVIEW) {
73 text << XRCPrefix() << XRCSize() << XRCStyle() << XRCCommonAttributes() << "<url>"
74 << wxCrafter::CDATA(PropertyString(PROP_URL)) << "</url>" << XRCSuffix();
75 } else {
76 // Designer
77 text << XRCPrefix() << XRCSize() << XRCStyle() << XRCCommonAttributes() << "<url>about:blank</url>"
78 << XRCSuffix();
79 }
80 }