Debian Codegraph @

wxcrafter/controls/static_text_wrapper.cpp

raw
1 #include "static_text_wrapper.h"
2 #include "allocator_mgr.h"
3 #include "multi_strings_property.h"
4 #include "wxgui_helpers.h"
5 #include "xmlutils.h"
6
7 StaticTextWrapper::StaticTextWrapper()
8 : wxcWidget(ID_WXSTATICTEXT)
9 {
10 PREPEND_STYLE(wxALIGN_LEFT, false);
11 PREPEND_STYLE(wxALIGN_RIGHT, false);
12 PREPEND_STYLE(wxALIGN_CENTRE, false);
13 PREPEND_STYLE(wxST_NO_AUTORESIZE, false);
14
15 SetPropertyString(_("Common Settings"), "wxStaticText");
16 AddProperty(new MultiStringsProperty(PROP_LABEL, _("Static Text Label"), wxT("\\n"), _("Label:")));
17 m_properties.Item(PROP_LABEL)->SetValue(_("Static Text Label"));
18
19 AddProperty(
20 new StringProperty(PROP_WRAP, wxT("-1"), _("Wrap the text after N pixels. If set to -1, don't wrap")));
21
22 m_namePattern = wxT("m_staticText");
23 SetName(GenerateName());
24 }
25
26 StaticTextWrapper::~StaticTextWrapper() {}
27
28 wxString StaticTextWrapper::GetWxClassName() const { return wxT("wxStaticText"); }
29
30 wxString StaticTextWrapper::CppCtorCode() const
31 {
32 // ( this, wxID_ANY, wxT("MyLabel"), wxDefaultPosition, wxDefaultSize, 0 );
33 wxString code;
34 code << GetName() << wxT(" = new ") << GetRealClassName() << "(" << GetWindowParent() << wxT(", ") << WindowID()
35 << wxT(", ") << Label() << wxT(", wxDefaultPosition, ") << SizeAsString() << wxT(", ") << StyleFlags(wxT("0"))
36 << wxT(");\n");
37
38 if(wxCrafter::ToNumber(PropertyString(PROP_WRAP), -1) >= 0) { // The default value is -1
39 code << GetName() << "->Wrap(" << PropertyString(PROP_WRAP) << ");\n";
40 }
41
42 code << CPPCommonAttributes();
43 return code;
44 }
45
46 void StaticTextWrapper::ToXRC(wxString& text, XRC_TYPE type) const
47 {
48 wxString xrc;
49 xrc << XRCPrefix() << XRCLabel() << XRCStyle() << XRCSize() << XRCCommonAttributes();
50 if(wxCrafter::ToNumber(PropertyString(PROP_WRAP), -1) >= 0) { // The default value is -1
51 xrc << wxT("<wrap>") << PropertyString(PROP_WRAP) << wxT("</wrap>");
52 }
53 xrc << XRCSuffix();
54 text << xrc;
55 }
56
57 void StaticTextWrapper::LoadPropertiesFromXRC(const wxXmlNode* node)
58 {
59 // First call the base-class for the standard things
60 wxcWidget::LoadPropertiesFromXRC(node);
61
62 wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("wrap"));
63 if(propertynode) { SetPropertyString(PROP_WRAP, propertynode->GetNodeContent()); }
64 }
65
66 // wxSmith doesn't wrap
67
68 void StaticTextWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node)
69 {
70 // First call the base-class for the standard things
71 wxcWidget::LoadPropertiesFromwxFB(node);
72
73 wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "wrap");
74 if(propertynode) { SetPropertyString(PROP_WRAP, propertynode->GetNodeContent()); }
75 }
76
77 wxcWidget* StaticTextWrapper::Clone() const { return new StaticTextWrapper(); }
78
79 void StaticTextWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add(wxT("#include <wx/stattext.h>")); }