+#include "wx/xml/xml.h"
+
+//-----------------------------------------------------------------------------
+// wxSizerXmlHandler
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxSizerXmlHandler, wxXmlResourceHandler)
+
+wxSizerXmlHandler::wxSizerXmlHandler()
+ :wxXmlResourceHandler(),
+ m_isInside(false),
+ m_isGBS(false),
+ m_parentSizer(NULL)
+{
+ XRC_ADD_STYLE(wxHORIZONTAL);
+ XRC_ADD_STYLE(wxVERTICAL);
+
+ // and flags
+ XRC_ADD_STYLE(wxLEFT);
+ XRC_ADD_STYLE(wxRIGHT);
+ XRC_ADD_STYLE(wxTOP);
+ XRC_ADD_STYLE(wxBOTTOM);
+ XRC_ADD_STYLE(wxNORTH);
+ XRC_ADD_STYLE(wxSOUTH);
+ XRC_ADD_STYLE(wxEAST);
+ XRC_ADD_STYLE(wxWEST);
+ XRC_ADD_STYLE(wxALL);
+
+ XRC_ADD_STYLE(wxGROW);
+ XRC_ADD_STYLE(wxEXPAND);
+ XRC_ADD_STYLE(wxSHAPED);
+ XRC_ADD_STYLE(wxSTRETCH_NOT);
+
+ XRC_ADD_STYLE(wxALIGN_CENTER);
+ XRC_ADD_STYLE(wxALIGN_CENTRE);
+ XRC_ADD_STYLE(wxALIGN_LEFT);
+ XRC_ADD_STYLE(wxALIGN_TOP);
+ XRC_ADD_STYLE(wxALIGN_RIGHT);
+ XRC_ADD_STYLE(wxALIGN_BOTTOM);
+ XRC_ADD_STYLE(wxALIGN_CENTER_HORIZONTAL);
+ XRC_ADD_STYLE(wxALIGN_CENTRE_HORIZONTAL);
+ XRC_ADD_STYLE(wxALIGN_CENTER_VERTICAL);
+ XRC_ADD_STYLE(wxALIGN_CENTRE_VERTICAL);
+
+ XRC_ADD_STYLE(wxFIXED_MINSIZE);
+ XRC_ADD_STYLE(wxRESERVE_SPACE_EVEN_IF_HIDDEN);
+
+ // this flag doesn't do anything any more but we can just ignore its
+ // occurrences in the old resource files instead of raising a fuss because
+ // of it
+ AddStyle("wxADJUST_MINSIZE", 0);
+
+ // wxWrapSizer-specific flags
+ XRC_ADD_STYLE(wxEXTEND_LAST_ON_EACH_LINE);
+ XRC_ADD_STYLE(wxREMOVE_LEADING_SPACES);
+}
+
+
+
+bool wxSizerXmlHandler::CanHandle(wxXmlNode *node)
+{
+ return ( (!m_isInside && IsSizerNode(node)) ||
+ (m_isInside && IsOfClass(node, wxT("sizeritem"))) ||
+ (m_isInside && IsOfClass(node, wxT("spacer")))
+ );
+}
+
+
+wxObject* wxSizerXmlHandler::DoCreateResource()
+{
+ if (m_class == wxT("sizeritem"))
+ return Handle_sizeritem();
+
+ else if (m_class == wxT("spacer"))
+ return Handle_spacer();
+
+ else
+ return Handle_sizer();
+}
+
+
+wxSizer* wxSizerXmlHandler::DoCreateSizer(const wxString& name)
+{
+ if (name == wxT("wxBoxSizer"))
+ return Handle_wxBoxSizer();
+#if wxUSE_STATBOX
+ else if (name == wxT("wxStaticBoxSizer"))
+ return Handle_wxStaticBoxSizer();
+#endif
+ else if (name == wxT("wxGridSizer"))
+ {
+ if ( !ValidateGridSizerChildren() )
+ return NULL;
+ return Handle_wxGridSizer();
+ }
+ else if (name == wxT("wxFlexGridSizer"))
+ {
+ return Handle_wxFlexGridSizer();
+ }
+ else if (name == wxT("wxGridBagSizer"))
+ {
+ return Handle_wxGridBagSizer();
+ }
+ else if (name == wxT("wxWrapSizer"))
+ {
+ return Handle_wxWrapSizer();
+ }
+
+ ReportError(wxString::Format("unknown sizer class \"%s\"", name));
+ return NULL;
+}
+
+
+
+bool wxSizerXmlHandler::IsSizerNode(wxXmlNode *node) const