Debian Codegraph @

wxcrafter/controls/html_window_wrapper.cpp

raw
1 #include "html_window_wrapper.h"
2 #include "allocator_mgr.h"
3 #include "string_property.h"
4 #include "wxgui_defs.h"
5 #include "wxgui_helpers.h"
6 #include "xmlutils.h"
7 #include <wx/html/htmlwin.h>
8
9 HtmlWindowWrapper::HtmlWindowWrapper()
10 : wxcWidget(ID_WXHTMLWIN)
11 {
12 PREPEND_STYLE(wxHW_SCROLLBAR_NEVER, false);
13 PREPEND_STYLE(wxHW_SCROLLBAR_AUTO, true);
14 PREPEND_STYLE(wxHW_NO_SELECTION, false);
15
16 SetPropertyString(_("Common Settings"), "wxHtmlWindow");
17 AddProperty(new StringProperty(PROP_HTMLCODE, wxT("<b>wxHtmlWindow control!</b>"), _("HTML code to load")));
18 AddProperty(new StringProperty(PROP_URL, wxT(""), _("URL to load")));
19
20 RegisterEvent(wxT("wxEVT_COMMAND_HTML_CELL_CLICKED"), wxT("wxHtmlCellEvent"), _("A wxHtmlCell was clicked."));
21 RegisterEvent(wxT("wxEVT_COMMAND_HTML_CELL_HOVER"), wxT("wxHtmlCellEvent"),
22 _("The mouse passed over a wxHtmlCell."));
23 RegisterEvent(wxT("wxEVT_COMMAND_HTML_LINK_CLICKED"), wxT("wxHtmlLinkEvent"),
24 _("A wxHtmlCell which contains an hyperlink was clicked."));
25
26 m_namePattern = wxT("m_htmlWin");
27 SetName(GenerateName());
28 }
29
30 HtmlWindowWrapper::~HtmlWindowWrapper() {}
31
32 wxcWidget* HtmlWindowWrapper::Clone() const { return new HtmlWindowWrapper(); }
33
34 wxString HtmlWindowWrapper::CppCtorCode() const
35 {
36 wxString code;
37 code << CPPStandardWxCtor(wxT("wxHW_DEFAULT_STYLE"));
38
39 wxString htmlCode = PropertyString(PROP_HTMLCODE);
40 htmlCode.Trim().Trim(false);
41 if(htmlCode.IsEmpty() == false) { code << GetName() << wxT("->SetPage(") << wxCrafter::WXT(htmlCode) << wxT(");\n"); }
42
43 wxString url = PropertyFile(PROP_URL);
44 url.Trim().Trim(false);
45 if(url.IsEmpty() == false) { code << GetName() << wxT("->LoadPage(") << wxCrafter::WXT(url) << wxT(");\n"); }
46
47 code << CPPCommonAttributes();
48 return code;
49 }
50
51 void HtmlWindowWrapper::GetIncludeFile(wxArrayString& headers) const
52 {
53 headers.Add(wxT("#include <wx/html/htmlwin.h>"));
54 }
55
56 wxString HtmlWindowWrapper::GetWxClassName() const { return wxT("wxHtmlWindow"); }
57
58 void HtmlWindowWrapper::ToXRC(wxString& text, XRC_TYPE type) const
59 {
60 text << XRCPrefix() << XRCStyle() << XRCSize() << XRCCommonAttributes();
61
62 wxString html = PropertyString(PROP_HTMLCODE);
63 html.Trim().Trim(false);
64 if(html.IsEmpty() == false) { text << wxT("<htmlcode><![CDATA[") << html << wxT("]]></htmlcode>"); }
65 text << XRCSuffix();
66 }
67
68 void HtmlWindowWrapper::LoadPropertiesFromXRC(const wxXmlNode* node)
69 {
70 // First call the base-class for the standard things
71 wxcWidget::LoadPropertiesFromXRC(node);
72
73 wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("htmlcode"));
74 if(propertynode) { SetPropertyString(PROP_HTMLCODE, propertynode->GetNodeContent()); }
75
76 propertynode = XmlUtils::FindFirstByTagName(node, wxT("url"));
77 if(propertynode) { SetPropertyString(PROP_URL, propertynode->GetNodeContent()); }
78 }
79
80 void HtmlWindowWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node)
81 {
82 // First call the base-class for the standard things
83 wxcWidget::LoadPropertiesFromwxSmith(node);
84
85 wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("htmlcode"));
86 if(propertynode) { SetPropertyString(PROP_HTMLCODE, propertynode->GetNodeContent()); }
87
88 propertynode = XmlUtils::FindFirstByTagName(node, wxT("url"));
89 if(propertynode) { SetPropertyString(PROP_URL, propertynode->GetNodeContent()); }
90 }
91
92 // wxFB doesn't do anything useful for this