Allow specifying all wxFlexGridSizer parameters in XRC.
Add support for specifying flexible direction, grow mode in non-flexible direction and row/column proportions for the growable ones. Closes #14767. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72710 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -572,6 +572,7 @@ All (GUI):
|
||||
- Implement incremental search in wxGenericListCtrl (Jonathan Dagresta).
|
||||
- Make TAB behaviour in wxGrid more flexible (Fulvio Senore).
|
||||
- Add missing styles support to wxWindow XRC hanlder (Steffen Olszewski).
|
||||
- Allow specifying all wxFlexGridSizer parameters in XRC (Steffen Olszewski).
|
||||
|
||||
wxGTK:
|
||||
|
||||
|
@@ -1919,8 +1919,8 @@ Example of sizers XRC code:
|
||||
<rows>0</rows>
|
||||
<vgap>0</vgap>
|
||||
<hgap>0</hgap>
|
||||
<growablecols>0</growablecols>
|
||||
<growablerows>0</growablerows>
|
||||
<growablecols>0:1</growablecols>
|
||||
<growablerows>0:1</growablerows>
|
||||
<object class="sizeritem">
|
||||
<flag>wxALIGN_CENTRE|wxALL</flag>
|
||||
<border>5</border>
|
||||
@@ -2001,12 +2001,22 @@ class-specific properties. All classes support the following properties:
|
||||
@row3col{cols, integer, Number of columns in the grid (default: 0 - determine automatically).}
|
||||
@row3col{vgap, integer, Vertical gap between children (default: 0).}
|
||||
@row3col{hgap, integer, Horizontal gap between children (default: 0).}
|
||||
@row3col{flexibledirection, @ref overview_xrcformat_type_style,
|
||||
Flexible direction, @c wxVERTICAL, @c wxHORIZONTAL or @c wxBOTH (default).
|
||||
This property is only available since wxWidgets 2.9.5.}
|
||||
@row3col{nonflexiblegrowmode, @ref overview_xrcformat_type_style,
|
||||
Grow mode in the non-flexible direction,
|
||||
@c wxFLEX_GROWMODE_NONE, @c wxFLEX_GROWMODE_SPECIFIED (default) or
|
||||
@c wxFLEX_GROWMODE_ALL.
|
||||
This property is only available since wxWidgets 2.9.5.}
|
||||
@row3col{growablerows, comma-separated integers list,
|
||||
Comma-separated list of indexes of rows that are growable
|
||||
(default: none).}
|
||||
Comma-separated list of indexes of rows that are growable (none by default).
|
||||
Since wxWidgets 2.9.5 optional proportion can be appended to each number
|
||||
after a colon (@c :).}
|
||||
@row3col{growablecols, comma-separated integers list,
|
||||
Comma-separated list of indexes of columns that are growable
|
||||
(default: none).}
|
||||
Comma-separated list of indexes of columns that are growable (none by default).
|
||||
Since wxWidgets 2.9.5 optional proportion can be appended to each number
|
||||
after a colon (@c :).}
|
||||
@endTable
|
||||
|
||||
@subsection overview_xrcformat_wxgridbagsizer wxGridBagSizer
|
||||
@@ -2015,11 +2025,21 @@ class-specific properties. All classes support the following properties:
|
||||
@hdr3col{property, type, description}
|
||||
@row3col{vgap, integer, Vertical gap between children (default: 0).}
|
||||
@row3col{hgap, integer, Horizontal gap between children (default: 0).}
|
||||
@row3col{flexibledirection, @ref overview_xrcformat_type_style,
|
||||
Flexible direction, @c wxVERTICAL, @c wxHORIZONTAL, @c wxBOTH (default: @c wxBOTH).}
|
||||
@row3col{nonflexiblegrowmode, @ref overview_xrcformat_type_style,
|
||||
Grow mode in the non-flexible direction,
|
||||
@c wxFLEX_GROWMODE_NONE, @c wxFLEX_GROWMODE_SPECIFIED, @c wxFLEX_GROWMODE_ALL
|
||||
(default: @c wxFLEX_GROWMODE_SPECIFIED).}
|
||||
@row3col{growablerows, comma-separated integers list,
|
||||
Comma-separated list of indexes of rows that are growable
|
||||
Comma-separated list of indexes of rows that are growable,
|
||||
optionally the proportion can be appended after each number
|
||||
separated by a @c :
|
||||
(default: none).}
|
||||
@row3col{growablecols, comma-separated integers list,
|
||||
Comma-separated list of indexes of columns that are growable
|
||||
Comma-separated list of indexes of columns that are growable,
|
||||
optionally the proportion can be appended after each number
|
||||
separated by a @c :
|
||||
(default: none).}
|
||||
@endTable
|
||||
|
||||
|
@@ -51,6 +51,7 @@ private:
|
||||
wxSizer* Handle_wxWrapSizer();
|
||||
|
||||
bool ValidateGridSizerChildren();
|
||||
void SetFlexibleMode(wxFlexGridSizer* fsizer);
|
||||
void SetGrowables(wxFlexGridSizer* fsizer, const wxChar* param, bool rows);
|
||||
wxGBPosition GetGBPos(const wxString& param);
|
||||
wxGBSpan GetGBSpan(const wxString& param);
|
||||
|
@@ -270,6 +270,7 @@ wxObject* wxSizerXmlHandler::Handle_sizer()
|
||||
// set growable rows and cols for sizers which support this
|
||||
if ( wxFlexGridSizer *flexsizer = wxDynamicCast(sizer, wxFlexGridSizer) )
|
||||
{
|
||||
SetFlexibleMode(flexsizer);
|
||||
SetGrowables(flexsizer, wxT("growablerows"), true);
|
||||
SetGrowables(flexsizer, wxT("growablecols"), false);
|
||||
}
|
||||
@@ -395,6 +396,50 @@ bool wxSizerXmlHandler::ValidateGridSizerChildren()
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void wxSizerXmlHandler::SetGrowables(wxFlexGridSizer* sizer,
|
||||
const wxChar* param,
|
||||
bool rows)
|
||||
@@ -408,18 +453,35 @@ void wxSizerXmlHandler::SetGrowables(wxFlexGridSizer* sizer,
|
||||
|
||||
while (tkn.HasMoreTokens())
|
||||
{
|
||||
unsigned long l;
|
||||
if (!tkn.GetNextToken().ToULong(&l))
|
||||
wxString propStr;
|
||||
wxString idxStr = tkn.GetNextToken().BeforeFirst(wxT(':'), &propStr);
|
||||
|
||||
unsigned long li;
|
||||
if (!idxStr.ToULong(&li))
|
||||
{
|
||||
ReportParamError
|
||||
(
|
||||
param,
|
||||
"value must be comma-separated list of row numbers"
|
||||
"value must be a comma-separated list of numbers"
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
const int n = static_cast<int>(l);
|
||||
unsigned long lp = 0;
|
||||
if (!propStr.empty())
|
||||
{
|
||||
if (!propStr.ToULong(&lp))
|
||||
{
|
||||
ReportParamError
|
||||
(
|
||||
param,
|
||||
"value must be a comma-separated list of numbers"
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const int n = static_cast<int>(li);
|
||||
if ( n >= nslots )
|
||||
{
|
||||
ReportParamError
|
||||
@@ -439,9 +501,9 @@ void wxSizerXmlHandler::SetGrowables(wxFlexGridSizer* sizer,
|
||||
}
|
||||
|
||||
if (rows)
|
||||
sizer->AddGrowableRow(n);
|
||||
sizer->AddGrowableRow(n, static_cast<int>(lp));
|
||||
else
|
||||
sizer->AddGrowableCol(n);
|
||||
sizer->AddGrowableCol(n, static_cast<int>(lp));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user