+ if ( !sizer )
+ {
+ wxLogError(_T("Failed to create size of class \"%s\""), m_class.c_str());
+ return NULL;
+ }
+
+ 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() & (wxMAXIMIZE_BOX | wxRESIZE_BORDER))
+ sizer->SetSizeHints(m_parentAsWindow);
+ }
+
+ return sizer;
+}
+
+
+wxSizer* wxSizerXmlHandler::Handle_wxBoxSizer()
+{
+ return new wxBoxSizer(GetStyle(wxT("orient"), wxHORIZONTAL));
+}
+
+#if wxUSE_STATBOX
+wxSizer* wxSizerXmlHandler::Handle_wxStaticBoxSizer()
+{
+ return new wxStaticBoxSizer(
+ new wxStaticBox(m_parentAsWindow,
+ GetID(),
+ GetText(wxT("label")),
+ wxDefaultPosition, wxDefaultSize,
+ 0/*style*/,
+ GetName()),
+ GetStyle(wxT("orient"), wxHORIZONTAL));
+}
+#endif // wxUSE_STATBOX
+
+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);