Debian Codegraph @

wxcrafter/sizers/box_sizer_wrapper.cpp

raw
1 #include "box_sizer_wrapper.h"
2
3 #include "allocator_mgr.h"
4 #include "choice_property.h"
5 #include "wxgui_defs.h"
6 #include "wxgui_helpers.h"
7 #include "xmlutils.h"
8
9 BoxSizerWrapper::BoxSizerWrapper()
10 {
11 m_type = ID_WXBOXSIZER;
12 m_styles.Clear(); // Sizer has no styles
13
14 wxArrayString arr;
15 arr.Add("wxVERTICAL");
16 arr.Add("wxHORIZONTAL");
17
18 SetPropertyString(_("Common Settings"), "wxBoxSizer");
19 AddProperty(new ChoiceProperty(PROP_ORIENTATION, arr, 0, _("Sizer orientation")));
20
21 EnableSizerFlag("wxEXPAND", true);
22 m_sizerItem.SetProportion(1);
23
24 m_namePattern = "boxSizer";
25 SetName(GenerateName());
26 }
27
28 BoxSizerWrapper::~BoxSizerWrapper() {}
29
30 wxString BoxSizerWrapper::GetWxClassName() const { return "wxBoxSizer"; }
31
32 wxString BoxSizerWrapper::CppCtorCode() const
33 {
34 wxString code;
35 if(!KeepAsClassMember()) {
36 code << "wxBoxSizer* ";
37 }
38
39 code << GetName() << " = new wxBoxSizer(" << PropertyString(PROP_ORIENTATION) << ");\n";
40
41 code << GenerateMinSizeCode();
42
43 if(IsMainSizer()) {
44 if(GetParent()->IsTopWindow()) {
45 code << "this->SetSizer(" << GetName() << ");\n";
46
47 } else {
48 code << GetWindowParent() << "->SetSizer(" << GetName() << ");\n";
49 }
50 }
51 return code;
52 }
53
54 void BoxSizerWrapper::ToXRC(wxString& text, XRC_TYPE type) const
55 {
56 text << wxT("<object class=\"wxBoxSizer\">") << "<orient>" << PropertyString(PROP_ORIENTATION) << "</orient>\n";
57 text << GenerateMinSizeXRC();
58 ChildrenXRC(text, type);
59 text << "</object>";
60 }
61
62 wxcWidget* BoxSizerWrapper::Clone() const { return new BoxSizerWrapper(); }
63
64 void BoxSizerWrapper::SetOrientation(const wxString& orient) { DoSetPropertyStringValue(PROP_ORIENTATION, orient); }
65
66 void BoxSizerWrapper::LoadPropertiesFromXRC(const wxXmlNode* node)
67 {
68 // First call the base-class for the standard things
69 wxcWidget::LoadPropertiesFromXRC(node);
70
71 wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, "orient");
72 if(propertynode) {
73 SetPropertyString(PROP_ORIENTATION, propertynode->GetNodeContent());
74 }
75 }
76
77 void BoxSizerWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node)
78 {
79 // First call the base-class for the standard things
80 wxcWidget::LoadPropertiesFromwxSmith(node);
81
82 // wxSmith doesn't use "name" here, but "variable" means the same thing afaict
83 wxString value = XmlUtils::ReadString(node, "variable");
84 if(!value.empty()) {
85 SetName(value);
86 }
87
88 wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, "orient");
89 if(propertynode) {
90 SetPropertyString(PROP_ORIENTATION, propertynode->GetNodeContent());
91 }
92 }
93
94 void BoxSizerWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node)
95 {
96 // First call the base-class for the standard things
97 wxcWidget::LoadPropertiesFromwxFB(node);
98
99 wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "orient");
100 if(propertynode) {
101 SetPropertyString(PROP_ORIENTATION, propertynode->GetNodeContent());
102 }
103 }