call wxFlexGridSizer::AddGrowableRow/Col() only after creating the sizer children, otherwise row/col index could be out of range (#10294)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57519 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -18,8 +18,6 @@
|
|||||||
#include "wx/sizer.h"
|
#include "wx/sizer.h"
|
||||||
#include "wx/gbsizer.h"
|
#include "wx/gbsizer.h"
|
||||||
|
|
||||||
class WXDLLIMPEXP_FWD_CORE wxSizer;
|
|
||||||
|
|
||||||
class WXDLLIMPEXP_XRC wxSizerXmlHandler : public wxXmlResourceHandler
|
class WXDLLIMPEXP_XRC wxSizerXmlHandler : public wxXmlResourceHandler
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxSizerXmlHandler)
|
DECLARE_DYNAMIC_CLASS(wxSizerXmlHandler)
|
||||||
@@ -45,7 +43,7 @@ private:
|
|||||||
wxSizer* Handle_wxStaticBoxSizer();
|
wxSizer* Handle_wxStaticBoxSizer();
|
||||||
#endif
|
#endif
|
||||||
wxSizer* Handle_wxGridSizer();
|
wxSizer* Handle_wxGridSizer();
|
||||||
wxSizer* Handle_wxFlexGridSizer();
|
wxFlexGridSizer* Handle_wxFlexGridSizer();
|
||||||
wxSizer* Handle_wxGridBagSizer();
|
wxSizer* Handle_wxGridBagSizer();
|
||||||
wxSizer* Handle_wxWrapSizer();
|
wxSizer* Handle_wxWrapSizer();
|
||||||
|
|
||||||
|
@@ -197,6 +197,7 @@ wxObject* wxSizerXmlHandler::Handle_spacer()
|
|||||||
wxObject* wxSizerXmlHandler::Handle_sizer()
|
wxObject* wxSizerXmlHandler::Handle_sizer()
|
||||||
{
|
{
|
||||||
wxSizer *sizer = NULL;
|
wxSizer *sizer = NULL;
|
||||||
|
wxFlexGridSizer *flexsizer = NULL;
|
||||||
|
|
||||||
wxXmlNode *parentNode = m_node->GetParent();
|
wxXmlNode *parentNode = m_node->GetParent();
|
||||||
|
|
||||||
@@ -210,21 +211,19 @@ wxObject* wxSizerXmlHandler::Handle_sizer()
|
|||||||
|
|
||||||
if (m_class == wxT("wxBoxSizer"))
|
if (m_class == wxT("wxBoxSizer"))
|
||||||
sizer = Handle_wxBoxSizer();
|
sizer = Handle_wxBoxSizer();
|
||||||
|
|
||||||
#if wxUSE_STATBOX
|
#if wxUSE_STATBOX
|
||||||
else if (m_class == wxT("wxStaticBoxSizer"))
|
else if (m_class == wxT("wxStaticBoxSizer"))
|
||||||
sizer = Handle_wxStaticBoxSizer();
|
sizer = Handle_wxStaticBoxSizer();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
else if (m_class == wxT("wxGridSizer"))
|
else if (m_class == wxT("wxGridSizer"))
|
||||||
sizer = Handle_wxGridSizer();
|
sizer = Handle_wxGridSizer();
|
||||||
|
|
||||||
else if (m_class == wxT("wxFlexGridSizer"))
|
else if (m_class == wxT("wxFlexGridSizer"))
|
||||||
sizer = Handle_wxFlexGridSizer();
|
{
|
||||||
|
flexsizer = Handle_wxFlexGridSizer();
|
||||||
|
sizer = flexsizer;
|
||||||
|
}
|
||||||
else if (m_class == wxT("wxGridBagSizer"))
|
else if (m_class == wxT("wxGridBagSizer"))
|
||||||
sizer = Handle_wxGridBagSizer();
|
sizer = Handle_wxGridBagSizer();
|
||||||
|
|
||||||
else if (m_class == wxT("wxWrapSizer"))
|
else if (m_class == wxT("wxWrapSizer"))
|
||||||
sizer = Handle_wxWrapSizer();
|
sizer = Handle_wxWrapSizer();
|
||||||
|
|
||||||
@@ -249,6 +248,13 @@ wxObject* wxSizerXmlHandler::Handle_sizer()
|
|||||||
|
|
||||||
CreateChildren(m_parent, true/*only this handler*/);
|
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
|
// restore state
|
||||||
m_isInside = old_ins;
|
m_isInside = old_ins;
|
||||||
m_parentSizer = old_par;
|
m_parentSizer = old_par;
|
||||||
@@ -308,24 +314,16 @@ wxSizer* wxSizerXmlHandler::Handle_wxGridSizer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxSizer* wxSizerXmlHandler::Handle_wxFlexGridSizer()
|
wxFlexGridSizer* wxSizerXmlHandler::Handle_wxFlexGridSizer()
|
||||||
{
|
{
|
||||||
wxFlexGridSizer *sizer =
|
return new wxFlexGridSizer(GetLong(wxT("rows")), GetLong(wxT("cols")),
|
||||||
new wxFlexGridSizer(GetLong(wxT("rows")), GetLong(wxT("cols")),
|
GetDimension(wxT("vgap")), GetDimension(wxT("hgap")));
|
||||||
GetDimension(wxT("vgap")), GetDimension(wxT("hgap")));
|
|
||||||
SetGrowables(sizer, wxT("growablerows"), true);
|
|
||||||
SetGrowables(sizer, wxT("growablecols"), false);
|
|
||||||
return sizer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxSizer* wxSizerXmlHandler::Handle_wxGridBagSizer()
|
wxSizer* wxSizerXmlHandler::Handle_wxGridBagSizer()
|
||||||
{
|
{
|
||||||
wxGridBagSizer *sizer =
|
return new wxGridBagSizer(GetDimension(wxT("vgap")), GetDimension(wxT("hgap")));
|
||||||
new wxGridBagSizer(GetDimension(wxT("vgap")), GetDimension(wxT("hgap")));
|
|
||||||
SetGrowables(sizer, wxT("growablerows"), true);
|
|
||||||
SetGrowables(sizer, wxT("growablecols"), false);
|
|
||||||
return sizer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSizer* wxSizerXmlHandler::Handle_wxWrapSizer()
|
wxSizer* wxSizerXmlHandler::Handle_wxWrapSizer()
|
||||||
@@ -346,13 +344,15 @@ void wxSizerXmlHandler::SetGrowables(wxFlexGridSizer* sizer,
|
|||||||
while (tkn.HasMoreTokens())
|
while (tkn.HasMoreTokens())
|
||||||
{
|
{
|
||||||
if (!tkn.GetNextToken().ToULong(&l))
|
if (!tkn.GetNextToken().ToULong(&l))
|
||||||
|
{
|
||||||
wxLogError(wxT("growable[rows|cols] must be comma-separated list of row numbers"));
|
wxLogError(wxT("growable[rows|cols] must be comma-separated list of row numbers"));
|
||||||
else {
|
break;
|
||||||
if (rows)
|
|
||||||
sizer->AddGrowableRow(l);
|
|
||||||
else
|
|
||||||
sizer->AddGrowableCol(l);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rows)
|
||||||
|
sizer->AddGrowableRow(l);
|
||||||
|
else
|
||||||
|
sizer->AddGrowableCol(l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user