Make it possible to combine wxEXPAND and alignment in wxGridSizer.

Allow overriding wxEXPAND effect in one of the directions by specifying
wxALIGN_{RIGHT,BOTTOM} or wxALIGN_CENTRE_{HORIZONTAL,VERTICAL} together with
it (unfortunately this doesn't work for wxALIGN_{LEFT,TOP} as their value is 0
and so their presence in flags can't be detected).
This commit is contained in:
Vadim Zeitlin
2015-04-04 18:59:06 +02:00
parent 233a7fe77b
commit 9aaa38c7c8
3 changed files with 43 additions and 4 deletions

View File

@@ -1517,11 +1517,13 @@ void wxGridSizer::SetItemBounds( wxSizerItem *item, int x, int y, int w, int h )
wxSize sz( item->GetMinSizeWithBorder() );
int flag = item->GetFlag();
if ((flag & wxEXPAND) || (flag & wxSHAPED))
// wxSHAPED maintains aspect ratio and so always applies to both
// directions.
if ( flag & wxSHAPED )
{
sz = wxSize(w, h);
sz = wxSize(w, h);
}
else
else // Otherwise we handle each direction individually.
{
if (flag & wxALIGN_CENTER_HORIZONTAL)
{
@@ -1531,6 +1533,10 @@ void wxGridSizer::SetItemBounds( wxSizerItem *item, int x, int y, int w, int h )
{
pt.x = x + (w - sz.x);
}
else if (flag & wxEXPAND)
{
sz.x = w;
}
if (flag & wxALIGN_CENTER_VERTICAL)
{
@@ -1540,6 +1546,10 @@ void wxGridSizer::SetItemBounds( wxSizerItem *item, int x, int y, int w, int h )
{
pt.y = y + (h - sz.y);
}
else if ( flag & wxEXPAND )
{
sz.y = h;
}
}
item->SetDimension(pt, sz);