| 1 |
#include "static_box_sizer_wrapper.h" |
| 2 |
|
| 3 |
#include "allocator_mgr.h" |
| 4 |
#include "choice_property.h" |
| 5 |
#include "string_property.h" |
| 6 |
#include "wxgui_helpers.h" |
| 7 |
#include "xmlutils.h" |
| 8 |
|
| 9 |
StaticBoxSizerWrapper::StaticBoxSizerWrapper() |
| 10 |
{ |
| 11 |
m_type = ID_WXSTATICBOXSIZER; |
| 12 |
m_styles.Clear(); // Sizer has no styles |
| 13 |
|
| 14 |
wxArrayString arr; |
| 15 |
arr.Add("Vertical"); |
| 16 |
arr.Add("Horizontal"); |
| 17 |
|
| 18 |
SetPropertyString(_("Common Settings"), "wxStaticBoxSizer"); |
| 19 |
AddProperty(new ChoiceProperty(PROP_ORIENTATION, arr, 0, _("Sizer orientation"))); |
| 20 |
AddProperty(new StringProperty(PROP_LABEL, _("My Label"), _("Label"))); |
| 21 |
|
| 22 |
m_namePattern = "staticBoxSizer"; |
| 23 |
SetName(GenerateName()); |
| 24 |
} |
| 25 |
|
| 26 |
StaticBoxSizerWrapper::~StaticBoxSizerWrapper() {} |
| 27 |
|
| 28 |
wxcWidget* StaticBoxSizerWrapper::Clone() const { return new StaticBoxSizerWrapper(); } |
| 29 |
|
| 30 |
wxString StaticBoxSizerWrapper::CppCtorCode() const |
| 31 |
{ |
| 32 |
wxString code; |
| 33 |
wxString orient; |
| 34 |
PropertyString(PROP_ORIENTATION) == "Horizontal" ? orient = "wxHORIZONTAL" : orient = "wxVERTICAL"; |
| 35 |
|
| 36 |
wxString staticBox; |
| 37 |
staticBox << " new wxStaticBox(" << GetWindowParent() << ", wxID_ANY, " << Label() << ")"; |
| 38 |
|
| 39 |
if(!KeepAsClassMember()) { |
| 40 |
code << "wxStaticBoxSizer* "; |
| 41 |
} |
| 42 |
|
| 43 |
code << GetName() << " = new wxStaticBoxSizer(" << staticBox << ", " << orient << ");\n"; |
| 44 |
code << GenerateMinSizeCode(); |
| 45 |
|
| 46 |
if(IsMainSizer()) { |
| 47 |
if(GetParent()->IsTopWindow()) { |
| 48 |
code << "this->SetSizer(" << GetName() << ");\n"; |
| 49 |
|
| 50 |
} else { |
| 51 |
code << GetParent()->GetName() << "->SetSizer(" << GetName() << ");\n"; |
| 52 |
} |
| 53 |
} |
| 54 |
return code; |
| 55 |
} |
| 56 |
|
| 57 |
wxString StaticBoxSizerWrapper::GetWxClassName() const { return "wxStaticBoxSizer"; } |
| 58 |
|
| 59 |
void StaticBoxSizerWrapper::SetOrientation(const wxString& orient) |
| 60 |
{ |
| 61 |
DoSetPropertyStringValue(PROP_ORIENTATION, orient); |
| 62 |
} |
| 63 |
|
| 64 |
void StaticBoxSizerWrapper::ToXRC(wxString& text, XRC_TYPE type) const |
| 65 |
{ |
| 66 |
wxString orient; |
| 67 |
PropertyString(PROP_ORIENTATION) == "Horizontal" ? orient = "wxHORIZONTAL" : orient = "wxVERTICAL"; |
| 68 |
text << XRCPrefix() << "<sizeritem><object class=\"spacer\"/></sizeritem>" << GenerateMinSizeXRC() << "<orient>" |
| 69 |
<< orient << "</orient>" << XRCLabel(); |
| 70 |
|
| 71 |
ChildrenXRC(text, type); |
| 72 |
text << XRCSuffix(); |
| 73 |
} |
| 74 |
|
| 75 |
void StaticBoxSizerWrapper::GetIncludeFile(wxArrayString& headers) const |
| 76 |
{ |
| 77 |
SizerWrapperBase::GetIncludeFile(headers); |
| 78 |
headers.Add("#include <wx/statbox.h>"); |
| 79 |
} |
| 80 |
|
| 81 |
void StaticBoxSizerWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) |
| 82 |
{ |
| 83 |
// First call the base-class for the standard things |
| 84 |
wxcWidget::LoadPropertiesFromXRC(node); |
| 85 |
|
| 86 |
wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, "orient"); |
| 87 |
if(propertynode) { |
| 88 |
// BoxSizerWrapper uses wxVERTICAL/wxHORIZONTAL but for some reason StaticBoxSizerWrapper has |
| 89 |
// Vertical/Horizontal |
| 90 |
bool horizontal = propertynode->GetNodeContent().Lower().Contains("horizontal"); |
| 91 |
SetPropertyString(PROP_ORIENTATION, horizontal ? "Horizontal" : "Vertical"); |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
void StaticBoxSizerWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) |
| 96 |
{ |
| 97 |
// First call the base-class for the standard things |
| 98 |
wxcWidget::LoadPropertiesFromwxSmith(node); |
| 99 |
|
| 100 |
wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, "orient"); |
| 101 |
if(propertynode) { |
| 102 |
bool horizontal = propertynode->GetNodeContent().Lower().Contains("horizontal"); |
| 103 |
SetPropertyString(PROP_ORIENTATION, horizontal ? "Horizontal" : "Vertical"); |
| 104 |
} |
| 105 |
} |
| 106 |
|
| 107 |
void StaticBoxSizerWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) |
| 108 |
{ |
| 109 |
// First call the base-class for the standard things |
| 110 |
wxcWidget::LoadPropertiesFromwxFB(node); |
| 111 |
|
| 112 |
wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "orient"); |
| 113 |
if(propertynode) { |
| 114 |
bool horizontal = propertynode->GetNodeContent().Lower().Contains("horizontal"); |
| 115 |
SetPropertyString(PROP_ORIENTATION, horizontal ? "Horizontal" : "Vertical"); |
| 116 |
} |
| 117 |
} |