Debian Codegraph @

wxcrafter/controls/spacer_wrapper.cpp

raw
1 #include "spacer_wrapper.h"
2 #include "allocator_mgr.h"
3 #include "wxgui_defs.h"
4 #include "wxgui_helpers.h"
5 #include "xmlutils.h"
6
7 SpacerWrapper::SpacerWrapper()
8 : wxcWidget(ID_WXSPACER)
9 {
10 m_styles.Clear();
11 m_properties.DeleteValues();
12
13 AddProperty(new CategoryProperty(_("Spacer")));
14 AddProperty(new StringProperty(PROP_NAME, wxT("Spacer"), wxT("")));
15 // This was removed above because sizers don't do 'size'. But wxSpacer does...
16 AddProperty(new StringProperty(PROP_SIZE, wxT("0,0"), _("The spacer's size: width,height")));
17
18 m_namePattern = wxT("Spacer");
19 SetName(GenerateName());
20 }
21
22 SpacerWrapper::~SpacerWrapper() {}
23
24 wxcWidget* SpacerWrapper::Clone() const { return new SpacerWrapper(); }
25
26 wxString SpacerWrapper::CppCtorCode() const
27 {
28 wxString cpp;
29 wxSize size = GetSize();
30
31 if(GetParent()->GetType() == ID_WXGRIDBAGSIZER) {
32 cpp << GetParent()->GetName() << wxT("->Add(") << wxCrafter::ToString(size.x) << wxT(", ")
33 << wxCrafter::ToString(size.y) << wxT(", ") << wxT("wxGBPosition(") << GetGbPos() << wxT("), ")
34 << wxT("wxGBSpan(") << GetGbSpan() << wxT("), ") << SizerFlags(wxT("0")) << wxT(", ")
35 << m_sizerItem.GetBorderScaled() << wxT(");\n");
36 } else {
37 cpp << GetParent()->GetName() << wxT("->Add(") << wxCrafter::ToString(size.x) << wxT(", ")
38 << wxCrafter::ToString(size.y) << wxT(", ") << m_sizerItem.GetProportion() << wxT(", ")
39 << SizerFlags(wxT("0")) << wxT(", ") << m_sizerItem.GetBorderScaled() << wxT(");\n");
40 }
41 return cpp;
42 }
43
44 void SpacerWrapper::GetIncludeFile(wxArrayString& headers) const { wxUnusedVar(headers); }
45
46 wxString SpacerWrapper::GetWxClassName() const { return wxT(""); }
47
48 void SpacerWrapper::ToXRC(wxString& text, XRC_TYPE type) const
49 {
50 wxUnusedVar(type);
51 wxUnusedVar(text);
52 }
53
54 void SpacerWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node)
55 {
56 // First call the base-class for the standard things
57 wxcWidget::LoadPropertiesFromwxFB(node);
58
59 // For some curious reason, wxFB stores spacer size in separate height and width nodes :/
60 wxString ht("0"), wd("0");
61 wxXmlNode* child = node->GetChildren();
62 while(child) {
63 wxString childname(child->GetName());
64 if(childname == wxT("property")) {
65 wxString attr(XmlUtils::ReadString(child, wxT("name")));
66
67 if(attr == "height") { ht = child->GetNodeContent(); }
68 }
69 if(childname == wxT("property")) {
70 wxString attr(XmlUtils::ReadString(child, wxT("name")));
71
72 if(attr == "width") { wd = child->GetNodeContent(); }
73 }
74 child = child->GetNext();
75 }
76
77 PropertyBase* prop = GetProperty(PROP_SIZE);
78 if(prop) { prop->SetValue(wd + "," + ht); }
79 }