+wxObject* wxSizerXmlHandler::Handle_spacer()
+{
+ wxCHECK_MSG(m_parentSizer, NULL, wxT("Incorrect syntax of XRC resource: spacer not within sizer!"));
+
+ wxSizerItem* sitem = MakeSizerItem();
+ SetSizerItemAttributes(sitem);
+ sitem->SetSpacer(GetSize());
+ AddSizerItem(sitem);
+ return NULL;
+}
+
+
+wxObject* wxSizerXmlHandler::Handle_sizer()
+{
+ wxSizer *sizer = NULL;
+
+ wxXmlNode *parentNode = m_node->GetParent();
+
+ wxCHECK_MSG(m_parentSizer != NULL ||
+ (parentNode && parentNode->GetType() == wxXML_ELEMENT_NODE &&
+ m_parentAsWindow != NULL &&
+ (m_parentAsWindow->IsKindOf(CLASSINFO(wxPanel)) ||
+ m_parentAsWindow->IsKindOf(CLASSINFO(wxFrame)) ||
+ m_parentAsWindow->IsKindOf(CLASSINFO(wxDialog)))
+ ), NULL,
+ wxT("Incorrect use of sizer: parent is not 'wxDialog', 'wxFrame' or 'wxPanel'."));
+
+ if (m_class == wxT("wxBoxSizer"))
+ sizer = Handle_wxBoxSizer();
+
+ else if (m_class == wxT("wxStaticBoxSizer"))
+ sizer = Handle_wxStaticBoxSizer();
+
+ else if (m_class == wxT("wxGridSizer"))
+ sizer = Handle_wxGridSizer();
+
+ else if (m_class == wxT("wxFlexGridSizer"))
+ sizer = Handle_wxFlexGridSizer();
+
+ else if (m_class == wxT("wxGridBagSizer"))
+ sizer = Handle_wxGridBagSizer();
+
+
+ wxSize minsize = GetSize(wxT("minsize"));
+ if (!(minsize == wxDefaultSize))
+ sizer->SetMinSize(minsize);
+
+ // save state
+ wxSizer *old_par = m_parentSizer;
+ bool old_ins = m_isInside;
+
+ // set new state
+ m_parentSizer = sizer;
+ m_isInside = true;
+ m_isGBS = (m_class == wxT("wxGridBagSizer"));
+
+ CreateChildren(m_parent, true/*only this handler*/);
+
+ // restore state
+ m_isInside = old_ins;
+ m_parentSizer = old_par;
+
+ if (m_parentSizer == NULL) // setup window:
+ {
+ m_parentAsWindow->SetSizer(sizer);
+
+ wxXmlNode *nd = m_node;
+ m_node = parentNode;
+ if (GetSize() == wxDefaultSize)
+ sizer->Fit(m_parentAsWindow);
+ m_node = nd;
+
+ if (m_parentAsWindow->GetWindowStyle() & (wxRESIZE_BOX | wxRESIZE_BORDER))
+ sizer->SetSizeHints(m_parentAsWindow);
+ }
+
+ return sizer;
+}
+
+
+wxSizer* wxSizerXmlHandler::Handle_wxBoxSizer()
+{
+ return new wxBoxSizer(GetStyle(wxT("orient"), wxHORIZONTAL));
+}
+
+wxSizer* wxSizerXmlHandler::Handle_wxStaticBoxSizer()
+{
+ return new wxStaticBoxSizer(
+ new wxStaticBox(m_parentAsWindow,
+ GetID(),
+ GetText(wxT("label")),
+ wxDefaultPosition, wxDefaultSize,
+ 0/*style*/,
+ GetName()),
+ GetStyle(wxT("orient"), wxHORIZONTAL));
+}
+
+wxSizer* wxSizerXmlHandler::Handle_wxGridSizer()
+{
+ return new wxGridSizer(GetLong(wxT("rows")), GetLong(wxT("cols")),
+ GetDimension(wxT("vgap")), GetDimension(wxT("hgap")));
+}
+
+
+wxSizer* wxSizerXmlHandler::Handle_wxFlexGridSizer()
+{
+ wxFlexGridSizer *sizer =
+ new wxFlexGridSizer(GetLong(wxT("rows")), GetLong(wxT("cols")),
+ GetDimension(wxT("vgap")), GetDimension(wxT("hgap")));
+ SetGrowables(sizer, wxT("growablerows"), true);
+ SetGrowables(sizer, wxT("growablecols"), false);
+ return sizer;
+}
+
+
+wxSizer* wxSizerXmlHandler::Handle_wxGridBagSizer()
+{
+ wxGridBagSizer *sizer =
+ new wxGridBagSizer(GetDimension(wxT("vgap")), GetDimension(wxT("hgap")));
+ SetGrowables(sizer, wxT("growablerows"), true);
+ SetGrowables(sizer, wxT("growablecols"), false);
+ return sizer;
+}
+
+
+
+
+void wxSizerXmlHandler::SetGrowables(wxFlexGridSizer* sizer,
+ const wxChar* param,
+ bool rows)
+{
+ wxStringTokenizer tkn;
+ unsigned long l;
+ tkn.SetString(GetParamValue(param), wxT(","));
+ while (tkn.HasMoreTokens())
+ {
+ if (!tkn.GetNextToken().ToULong(&l))
+ wxLogError(wxT("growable[rows|cols] must be comma-separated list of row numbers"));
+ else {
+ if (rows)
+ sizer->AddGrowableRow(l);
+ else
+ sizer->AddGrowableCol(l);