+bool wxSizerXmlHandler::IsSizerNode(wxXmlNode *node) const
+{
+ return (IsOfClass(node, wxT("wxBoxSizer"))) ||
+ (IsOfClass(node, wxT("wxStaticBoxSizer"))) ||
+ (IsOfClass(node, wxT("wxGridSizer"))) ||
+ (IsOfClass(node, wxT("wxFlexGridSizer"))) ||
+ (IsOfClass(node, wxT("wxGridBagSizer"))) ||
+ (IsOfClass(node, wxT("wxWrapSizer")));
+}
+
+
+wxObject* wxSizerXmlHandler::Handle_sizeritem()
+{
+ // find the item to be managed by this sizeritem
+ wxXmlNode *n = GetParamNode(wxT("object"));
+ if ( !n )
+ n = GetParamNode(wxT("object_ref"));
+
+ // did we find one?
+ if (n)
+ {
+ // create a sizer item for it
+ wxSizerItem* sitem = MakeSizerItem();
+
+ // now fetch the item to be managed
+ bool old_gbs = m_isGBS;
+ 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;
+ m_isGBS = old_gbs;
+
+ // 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()
+{
+ 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;
+ }
+
+ // Create the sizer of the appropriate class.
+ wxSizer * const sizer = DoCreateSizer(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 ( wxFlexGridSizer *flexsizer = wxDynamicCast(sizer, wxFlexGridSizer) )
+ {
+ 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);
+
+ wxXmlNode *nd = m_node;
+ m_node = parentNode;
+ if (GetSize() == wxDefaultSize)
+ {
+ if ( wxDynamicCast(m_parentAsWindow, wxScrolledWindow) != NULL )