| 1 |
#include "grid_sizer_wrapper.h" |
| 2 |
|
| 3 |
#include "allocator_mgr.h" |
| 4 |
#include "wxgui_helpers.h" |
| 5 |
#include "xmlutils.h" |
| 6 |
|
| 7 |
GridSizerWrapper::GridSizerWrapper() |
| 8 |
{ |
| 9 |
m_type = ID_WXGRIDSIZER; |
| 10 |
m_styles.Clear(); // Sizer has no styles |
| 11 |
|
| 12 |
SetPropertyString(_("Common Settings"), "wxGridSizer"); |
| 13 |
AddProperty(new StringProperty(PROP_COLS, "2", _("Number of columns in the grid"))); |
| 14 |
AddProperty(new StringProperty(PROP_ROWS, "0", _("Number of rows in the grid"))); |
| 15 |
AddProperty(new StringProperty(PROP_HGAP, "0", _("The horizontal gap between grid cells"))); |
| 16 |
AddProperty(new StringProperty(PROP_VGAP, "0", _("The vertical gap between grid cells"))); |
| 17 |
|
| 18 |
EnableSizerFlag("wxEXPAND", true); |
| 19 |
m_sizerItem.SetProportion(1); |
| 20 |
|
| 21 |
m_namePattern = "gridSizer"; |
| 22 |
SetName(GenerateName()); |
| 23 |
} |
| 24 |
|
| 25 |
GridSizerWrapper::~GridSizerWrapper() {} |
| 26 |
|
| 27 |
wxString GridSizerWrapper::CppCtorCode() const |
| 28 |
{ |
| 29 |
wxString code; |
| 30 |
|
| 31 |
if(!KeepAsClassMember()) { |
| 32 |
code << "wxGridSizer* "; |
| 33 |
} |
| 34 |
|
| 35 |
code << GetName() << " = new wxGridSizer(" << PropertyString(PROP_ROWS) << ", " << PropertyString(PROP_COLS) << ", " |
| 36 |
<< PropertyString(PROP_VGAP) << ", " << PropertyString(PROP_HGAP) << ");\n"; |
| 37 |
|
| 38 |
code << GenerateMinSizeCode(); |
| 39 |
|
| 40 |
if(IsMainSizer()) { |
| 41 |
if(GetParent()->IsTopWindow()) { |
| 42 |
code << "this->SetSizer(" << GetName() << ");\n"; |
| 43 |
} else { |
| 44 |
code << GetParent()->GetName() << "->SetSizer(" << GetName() << ");\n"; |
| 45 |
} |
| 46 |
} |
| 47 |
return code; |
| 48 |
} |
| 49 |
|
| 50 |
void GridSizerWrapper::ToXRC(wxString& text, XRC_TYPE type) const |
| 51 |
{ |
| 52 |
text << wxT("<object class=\"wxGridSizer\">") << GenerateMinSizeXRC() << "<cols>" << PropertyString(PROP_COLS) |
| 53 |
<< "</cols>" |
| 54 |
<< "<rows>" << PropertyString(PROP_ROWS) << "</rows>" |
| 55 |
<< "<vgap>" << PropertyString(PROP_VGAP) << "</vgap>" |
| 56 |
<< "<hgap>" << PropertyString(PROP_HGAP) << "</hgap>"; |
| 57 |
ChildrenXRC(text, type); |
| 58 |
text << "</object>"; |
| 59 |
} |
| 60 |
|
| 61 |
wxString GridSizerWrapper::GetWxClassName() const { return "wxGridSizer"; } |
| 62 |
|
| 63 |
void GridSizerWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) |
| 64 |
{ |
| 65 |
wxcWidget::LoadPropertiesFromXRC(node); // Baseclass stuff first |
| 66 |
|
| 67 |
DoLoadXRCProperties(node); |
| 68 |
} |
| 69 |
|
| 70 |
void GridSizerWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) |
| 71 |
{ |
| 72 |
wxcWidget::LoadPropertiesFromXRC(node); // Baseclass stuff first |
| 73 |
|
| 74 |
DoLoadXRCProperties(node); |
| 75 |
} |
| 76 |
|
| 77 |
void GridSizerWrapper::DoLoadXRCProperties(const wxXmlNode* node) |
| 78 |
{ |
| 79 |
wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, "cols"); |
| 80 |
if(propertynode) { |
| 81 |
SetPropertyString(PROP_COLS, propertynode->GetNodeContent()); |
| 82 |
} |
| 83 |
|
| 84 |
propertynode = XmlUtils::FindFirstByTagName(node, "rows"); |
| 85 |
if(propertynode) { |
| 86 |
SetPropertyString(PROP_ROWS, propertynode->GetNodeContent()); |
| 87 |
} |
| 88 |
|
| 89 |
propertynode = XmlUtils::FindFirstByTagName(node, "vgap"); |
| 90 |
if(propertynode) { |
| 91 |
SetPropertyString(PROP_VGAP, propertynode->GetNodeContent()); |
| 92 |
} |
| 93 |
|
| 94 |
propertynode = XmlUtils::FindFirstByTagName(node, "hgap"); |
| 95 |
if(propertynode) { |
| 96 |
SetPropertyString(PROP_HGAP, propertynode->GetNodeContent()); |
| 97 |
} |
| 98 |
} |
| 99 |
|
| 100 |
void GridSizerWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) |
| 101 |
{ |
| 102 |
// First call the base-class for the standard things |
| 103 |
wxcWidget::LoadPropertiesFromwxFB(node); |
| 104 |
|
| 105 |
wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "cols"); |
| 106 |
if(propertynode) { |
| 107 |
SetPropertyString(PROP_COLS, propertynode->GetNodeContent()); |
| 108 |
} |
| 109 |
|
| 110 |
propertynode = XmlUtils::FindNodeByName(node, "property", "rows"); |
| 111 |
if(propertynode) { |
| 112 |
SetPropertyString(PROP_ROWS, propertynode->GetNodeContent()); |
| 113 |
} |
| 114 |
|
| 115 |
propertynode = XmlUtils::FindNodeByName(node, "property", "vgap"); |
| 116 |
if(propertynode) { |
| 117 |
SetPropertyString(PROP_VGAP, propertynode->GetNodeContent()); |
| 118 |
} |
| 119 |
|
| 120 |
propertynode = XmlUtils::FindNodeByName(node, "property", "hgap"); |
| 121 |
if(propertynode) { |
| 122 |
SetPropertyString(PROP_HGAP, propertynode->GetNodeContent()); |
| 123 |
} |
| 124 |
} |