+bool wxSizerXmlHandler::ValidateGridSizerChildren()
+{
+ int rows = GetLong("rows");
+ int cols = GetLong("cols");
+
+ if ( rows && cols )
+ {
+ // fixed number of cells, need to verify children count
+ int children = 0;
+ for ( wxXmlNode *n = m_node->GetChildren(); n; n = n->GetNext() )
+ {
+ if ( n->GetType() == wxXML_ELEMENT_NODE &&
+ (n->GetName() == "object" || n->GetName() == "object_ref") )
+ {
+ children++;
+ }
+ }
+
+ if ( children > rows * cols )
+ {
+ ReportError
+ (
+ wxString::Format
+ (
+ "too many children in grid sizer: %d > %d x %d"
+ " (consider omitting the number of rows or columns)",
+ children,
+ cols,
+ rows
+ )
+ );
+ return false;
+ }
+ }
+
+ return true;
+}
+
+
+void wxSizerXmlHandler::SetFlexibleMode(wxFlexGridSizer* fsizer)
+{
+ if (HasParam(wxT("flexibledirection")))
+ {
+ wxString dir = GetParamValue(wxT("flexibledirection"));
+
+ if (dir == wxT("wxVERTICAL"))
+ fsizer->SetFlexibleDirection(wxVERTICAL);
+ else if (dir == wxT("wxHORIZONTAL"))
+ fsizer->SetFlexibleDirection(wxHORIZONTAL);
+ else if (dir == wxT("wxBOTH"))
+ fsizer->SetFlexibleDirection(wxBOTH);
+ else
+ {
+ ReportParamError
+ (
+ wxT("flexibledirection"),
+ wxString::Format("unknown direction \"%s\"", dir)
+ );
+ }
+ }
+
+ if (HasParam(wxT("nonflexiblegrowmode")))
+ {
+ wxString mode = GetParamValue(wxT("nonflexiblegrowmode"));
+
+ if (mode == wxT("wxFLEX_GROWMODE_NONE"))
+ fsizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_NONE);
+ else if (mode == wxT("wxFLEX_GROWMODE_SPECIFIED"))
+ fsizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
+ else if (mode == wxT("wxFLEX_GROWMODE_ALL"))
+ fsizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_ALL);
+ else
+ {
+ ReportParamError
+ (
+ wxT("nonflexiblegrowmode"),
+ wxString::Format("unknown grow mode \"%s\"", mode)
+ );
+ }
+ }
+}
+