- if (n)
- {
- bool old_ins = m_isInside;
- wxSizer *old_par = m_parentSizer;
- m_isInside = FALSE;
- if (!IsSizerNode(n)) m_parentSizer = NULL;
- wxObject *item = CreateResFromNode(n, m_parent, NULL);
- m_isInside = old_ins;
- m_parentSizer = old_par;
- wxSizer *sizer = wxDynamicCast(item, wxSizer);
- wxWindow *wnd = wxDynamicCast(item, wxWindow);
- wxSize minsize = GetSize(wxT("minsize"));
+ // and figure out what type it is
+ wxSizer *sizer = wxDynamicCast(item, wxSizer);
+ wxWindow *wnd = wxDynamicCast(item, wxWindow);
+
+ if (sizer)
+ sitem->AssignSizer(sizer);
+ else if (wnd)
+ sitem->AssignWindow(wnd);
+ else
+ ReportError(n, "unexpected item in sizer");
+
+ // finally, set other wxSizerItem attributes
+ SetSizerItemAttributes(sitem);
+
+ AddSizerItem(sitem);
+ return item;
+ }
+ else /*n == NULL*/
+ {
+ ReportError("no window/sizer/spacer within sizeritem object");
+ return NULL;
+ }
+}
+
+
+wxObject* wxSizerXmlHandler::Handle_spacer()
+{
+ if ( !m_parentSizer )
+ {
+ ReportError("spacer only allowed inside a sizer");
+ return NULL;
+ }
+
+ wxSizerItem* sitem = MakeSizerItem();
+ SetSizerItemAttributes(sitem);
+ sitem->AssignSpacer(GetSize());
+ AddSizerItem(sitem);
+ return NULL;
+}
+
+
+wxObject* wxSizerXmlHandler::Handle_sizer()
+{
+ wxSizer *sizer = NULL;
+ wxFlexGridSizer *flexsizer = NULL;
+
+ wxXmlNode *parentNode = m_node->GetParent();
+
+ if ( !m_parentSizer &&
+ (!parentNode || parentNode->GetType() != wxXML_ELEMENT_NODE ||
+ !m_parentAsWindow) )
+ {
+ ReportError("sizer must have a window parent");
+ return NULL;
+ }
+
+ if (m_class == wxT("wxBoxSizer"))
+ sizer = Handle_wxBoxSizer();
+#if wxUSE_STATBOX
+ else if (m_class == wxT("wxStaticBoxSizer"))
+ sizer = Handle_wxStaticBoxSizer();
+#endif
+ else if (m_class == wxT("wxGridSizer"))
+ {
+ if ( !ValidateGridSizerChildren() )
+ return NULL;
+ sizer = Handle_wxGridSizer();
+ }
+ else if (m_class == wxT("wxFlexGridSizer"))
+ {
+ flexsizer = Handle_wxFlexGridSizer();
+ sizer = flexsizer;
+ }
+ else if (m_class == wxT("wxGridBagSizer"))
+ {
+ flexsizer = Handle_wxGridBagSizer();
+ sizer = flexsizer;
+ }
+ else if (m_class == wxT("wxWrapSizer"))
+ {
+ sizer = Handle_wxWrapSizer();
+ }
+ else
+ {
+ ReportError(wxString::Format("unknown sizer class \"%s\"", m_class));
+ }
+
+ // creation of sizer failed for some (already reported) reason, so exit:
+ if ( !sizer )
+ 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*/);
+
+ // set growable rows and cols for sizers which support this
+ if ( flexsizer )
+ {
+ SetGrowables(flexsizer, wxT("growablerows"), true);
+ SetGrowables(flexsizer, wxT("growablecols"), false);
+ }
+
+ // restore state
+ m_isInside = old_ins;
+ m_parentSizer = old_par;
+
+ if (m_parentSizer == NULL) // setup window:
+ {
+ m_parentAsWindow->SetSizer(sizer);