- wxCHECK_MSG(m_parentSizer != NULL ||
- (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();
-
-
+ 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;
+