It used to add a spacer with the given size in both directions but this was
counter-intuitive and wasn't expected even by the original author of this code
so change it to behave more reasonably.
Closes #11197.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61939
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
new constructors taking wxSize for the gap argument is preferred. The same
applies to wxFlexGridSizer as well.
new constructors taking wxSize for the gap argument is preferred. The same
applies to wxFlexGridSizer as well.
+- wxBoxSizer::AddSpacer(x) now adds space in the direction of the sizer only
+ and not in both this and the orthogonal directions. This behaviour is what
+ most of the people expect but if you really relied on this overload adding
+ space in both directions you should change your code to use AddSpacer(x, x).
+
Changes in behaviour which may result in compilation errors
-----------------------------------------------------------
Changes in behaviour which may result in compilation errors
-----------------------------------------------------------
wxSizerItem* Add( int width, int height, const wxSizerFlags& flags);
wxSizerItem* Add( wxSizerItem *item);
wxSizerItem* Add( int width, int height, const wxSizerFlags& flags);
wxSizerItem* Add( wxSizerItem *item);
- wxSizerItem* AddSpacer(int size);
+ virtual wxSizerItem *AddSpacer(int size);
wxSizerItem* AddStretchSpacer(int prop = 1);
wxSizerItem* Insert(size_t index,
wxSizerItem* AddStretchSpacer(int prop = 1);
wxSizerItem* Insert(size_t index,
wxT("invalid value for wxBoxSizer orientation") );
}
wxT("invalid value for wxBoxSizer orientation") );
}
+ virtual wxSizerItem *AddSpacer(int size);
+
int GetOrientation() const { return m_orient; }
bool IsVertical() const { return m_orient == wxVERTICAL; }
int GetOrientation() const { return m_orient; }
bool IsVertical() const { return m_orient == wxVERTICAL; }
wxObject* userData = NULL);
/**
wxObject* userData = NULL);
/**
- Adds non-stretchable space to the sizer.
+ This base function adds non-stretchable space to both the horizontal
+ and vertical orientation of the sizer.
More readable way of calling:
@code
wxSizer::Add(size, size, 0).
@endcode
More readable way of calling:
@code
wxSizer::Add(size, size, 0).
@endcode
+ @see wxBoxSizer::AddSpacer()
- wxSizerItem* AddSpacer(int size);
+ virtual wxSizerItem *AddSpacer(int size);
/**
Adds stretchable space to the sizer.
/**
Adds stretchable space to the sizer.
*/
wxBoxSizer(int orient);
*/
wxBoxSizer(int orient);
+ /**
+ Adds non-stretchable space to the main orientation of the sizer only.
+ More readable way of calling:
+ @code
+ if ( wxBoxSizer::IsVertical() )
+ {
+ wxBoxSizer::Add(0, size, 0).
+ }
+ else
+ {
+ wxBoxSizer::Add(size, 0, 0).
+ }
+ @endcode
+ */
+ virtual wxSizerItem *AddSpacer(int size);
+
/**
Implements the calculation of a box sizer's minimal.
/**
Implements the calculation of a box sizer's minimal.
// wxBoxSizer
//---------------------------------------------------------------------------
// wxBoxSizer
//---------------------------------------------------------------------------
+wxSizerItem *wxBoxSizer::AddSpacer(int size)
+{
+ return IsVertical() ? Add(0, size) : Add(size, 0);
+}
+
void wxBoxSizer::RecalcSizes()
{
if ( m_children.empty() )
void wxBoxSizer::RecalcSizes()
{
if ( m_children.empty() )