From 4a00e77ce6fe935b99a3a92dd5dcd7bfcddf4b6d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 10 Aug 2009 11:18:23 +0000 Subject: [PATCH] Update wxFlexGridSizer ctors to match (new) wxGridSizer ones. Confusing wxFlexGridSizer(int cols, int vgap = 0, int hgap = 0) was removed as well as corresponding wxGridSizer ctor overload. New ctor overloads taking gap as wxSize were added. See #11040. Closes #11091. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61635 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 3 ++- include/wx/sizer.h | 16 +++++++++----- interface/wx/sizer.h | 26 ++++++++++++++++------- src/common/sizer.cpp | 50 ++++++++++++++++++++++++++++---------------- 4 files changed, 63 insertions(+), 32 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index a3f2ff23e2..494d413e22 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -141,7 +141,8 @@ Changes in behaviour not resulting in compilation errors, please read this! easy to mistake for wxGridSizer(int rows, int cols) overload was removed, you will need to specify both vertical and horizontal gap if you want to use this overload or specify both rows and columns and the gap otherwise. Use of the - new constructors taking wxSize for the gap argument is preferred. + new constructors taking wxSize for the gap argument is preferred. The same + applies to wxFlexGridSizer as well. Changes in behaviour which may result in compilation errors diff --git a/include/wx/sizer.h b/include/wx/sizer.h index f07d6f5886..7839946cd1 100644 --- a/include/wx/sizer.h +++ b/include/wx/sizer.h @@ -730,8 +730,8 @@ public: wxGridSizer( int cols, const wxSize& gap = wxSize(0, 0) ); // ctors specifying the number of rows and columns - wxGridSizer( int rows, int cols, const wxSize& gap ); wxGridSizer( int rows, int cols, int vgap, int hgap ); + wxGridSizer( int rows, int cols, const wxSize& gap ); virtual wxSizerItem *Insert(size_t index, wxSizerItem *item); @@ -794,11 +794,17 @@ enum wxFlexSizerGrowMode class WXDLLIMPEXP_CORE wxFlexGridSizer: public wxGridSizer { public: - // ctors/dtor - wxFlexGridSizer( int rows, int cols, int vgap, int hgap ); - wxFlexGridSizer( int cols, int vgap = 0, int hgap = 0 ); - virtual ~wxFlexGridSizer(); + // ctors specifying the number of columns only: number of rows will be + // deduced automatically depending on the number of sizer elements + wxFlexGridSizer( int cols, int vgap, int hgap ); + wxFlexGridSizer( int cols, const wxSize& gap = wxSize(0, 0) ); + // ctors specifying the number of rows and columns + wxFlexGridSizer( int rows, int cols, int vgap, int hgap ); + wxFlexGridSizer( int rows, int cols, const wxSize& gap ); + + // dtor + virtual ~wxFlexGridSizer(); // set the rows/columns which will grow (the others will remain of the // constant initial size) diff --git a/interface/wx/sizer.h b/interface/wx/sizer.h index 2296c39f61..886ba9ddb0 100644 --- a/interface/wx/sizer.h +++ b/interface/wx/sizer.h @@ -1435,17 +1435,27 @@ class wxFlexGridSizer : public wxGridSizer public: //@{ /** - Constructor for a wxFlexGridSizer. + wxFlexGridSizer constructors. - @a rows and @a cols determine the number of columns and rows in the sizer - - if either of the parameters is zero, it will be calculated to form the - total number of children in the sizer, thus making the sizer grow - dynamically. + Usually only the number of columns in the flex grid sizer needs to be + specified using @a cols argument. The number of rows will be deduced + automatically depending on the number of the elements added to the + sizer. If the number of @a rows is explicitly specified (and not zero), + the sizer will check that it no more than @code cols*rows @endcode + elements are added to it. - @a vgap and @a hgap define extra space between all children. + The @a gap (or @a vgap and @a hgap, which correspond to the height and + width of the wxSize object) argument defines the size of the padding + between the rows (its vertical component, or @a vgap) and columns + (its horizontal component, or @a hgap), in pixels. + + @since 2.9.1 (except for the four argument overload) */ - wxFlexGridSizer(int rows, int cols, int vgap, int hgap); - wxFlexGridSizer(int cols, int vgap = 0, int hgap = 0); + wxFlexGridSizer( int cols, int vgap, int hgap ); + wxFlexGridSizer( int cols, const wxSize& gap = wxSize(0, 0) ); + + wxFlexGridSizer( int rows, int cols, int vgap, int hgap ); + wxFlexGridSizer( int rows, int cols, const wxSize& gap ); //@} /** diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index e9e7ad1193..3d94c8bce8 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -1317,22 +1317,6 @@ bool wxSizer::IsShown( size_t index ) const // wxGridSizer //--------------------------------------------------------------------------- -wxGridSizer::wxGridSizer( int rows, int cols, int vgap, int hgap ) - : m_rows( rows || cols ? rows : 1 ), - m_cols( cols ), - m_vgap( vgap ), - m_hgap( hgap ) -{ -} - -wxGridSizer::wxGridSizer( int rows, int cols, const wxSize& gap ) - : m_rows( rows || cols ? rows : 1 ), - m_cols( cols ), - m_vgap( gap.GetHeight() ), - m_hgap( gap.GetWidth() ) -{ -} - wxGridSizer::wxGridSizer( int cols, int vgap, int hgap ) : m_rows( cols == 0 ? 1 : 0 ), m_cols( cols ), @@ -1349,6 +1333,22 @@ wxGridSizer::wxGridSizer( int cols, const wxSize& gap ) { } +wxGridSizer::wxGridSizer( int rows, int cols, int vgap, int hgap ) + : m_rows( rows || cols ? rows : 1 ), + m_cols( cols ), + m_vgap( vgap ), + m_hgap( hgap ) +{ +} + +wxGridSizer::wxGridSizer( int rows, int cols, const wxSize& gap ) + : m_rows( rows || cols ? rows : 1 ), + m_cols( cols ), + m_vgap( gap.GetHeight() ), + m_hgap( gap.GetWidth() ) +{ +} + wxSizerItem *wxGridSizer::Insert(size_t index, wxSizerItem *item) { // if only the number of columns or the number of rows is specified for a @@ -1541,6 +1541,20 @@ void wxGridSizer::SetItemBounds( wxSizerItem *item, int x, int y, int w, int h ) // wxFlexGridSizer //--------------------------------------------------------------------------- +wxFlexGridSizer::wxFlexGridSizer( int cols, int vgap, int hgap ) + : wxGridSizer( cols, vgap, hgap ), + m_flexDirection(wxBOTH), + m_growMode(wxFLEX_GROWMODE_SPECIFIED) +{ +} + +wxFlexGridSizer::wxFlexGridSizer( int cols, const wxSize& gap ) + : wxGridSizer( cols, gap ), + m_flexDirection(wxBOTH), + m_growMode(wxFLEX_GROWMODE_SPECIFIED) +{ +} + wxFlexGridSizer::wxFlexGridSizer( int rows, int cols, int vgap, int hgap ) : wxGridSizer( rows, cols, vgap, hgap ), m_flexDirection(wxBOTH), @@ -1548,8 +1562,8 @@ wxFlexGridSizer::wxFlexGridSizer( int rows, int cols, int vgap, int hgap ) { } -wxFlexGridSizer::wxFlexGridSizer( int cols, int vgap, int hgap ) - : wxGridSizer( cols, vgap, hgap ), +wxFlexGridSizer::wxFlexGridSizer( int rows, int cols, const wxSize& gap ) + : wxGridSizer( rows, cols, gap ), m_flexDirection(wxBOTH), m_growMode(wxFLEX_GROWMODE_SPECIFIED) {