X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6115b1b5d90ffac0ead7082fb8106f44d45783e6..4e916e61ea24c165fb55e78172f1093bf7481b48:/src/common/sizer.cpp diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index af8275b478..c4502c852e 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -480,10 +480,21 @@ void wxSizerItem::SetDimension( const wxPoint& pos_, const wxSize& size_ ) break; case Item_Window: + { + // Use wxSIZE_FORCE_EVENT here since a sizer item might + // have changed alignment or some other property which would + // not change the size of the window. In such a case, no + // wxSizeEvent would normally be generated and thus the + // control wouldn't get layed out correctly here. +#if 1 + m_window->SetSize(pos.x, pos.y, size.x, size.y, + wxSIZE_ALLOW_MINUS_ONE|wxSIZE_FORCE_EVENT ); +#else m_window->SetSize(pos.x, pos.y, size.x, size.y, - wxSIZE_ALLOW_MINUS_ONE); + wxSIZE_ALLOW_MINUS_ONE ); +#endif break; - + } case Item_Sizer: m_sizer->SetDimension(pos, size); break; @@ -1328,9 +1339,12 @@ int wxGridSizer::CalcRowsCols(int& nrows, int& ncols) const if ( m_cols && m_rows ) { // if both rows and columns are specified by user, use the provided - // values even if we don't have enough items + // values even if we don't have enough items but check that we don't + // have too many of them as this is going to result in problems later ncols = m_cols; nrows = m_rows; + + wxASSERT_MSG( ncols*nrows >= nitems, "too many items in grid sizer" ); } else if ( m_cols ) { @@ -1767,6 +1781,37 @@ DoAdjustForGrowables(int delta, void wxFlexGridSizer::AdjustForGrowables(const wxSize& sz) { +#ifdef __WXDEBUG__ + // by the time this function is called, the sizer should be already fully + // initialized and hence the number of its columns and rows is known and we + // can check that all indices in m_growableCols/Rows are valid (see also + // comments in AddGrowableCol/Row()) + if ( !m_rows || !m_cols ) + { + int nrows, ncols; + CalcRowsCols(nrows, ncols); + + if ( !m_rows ) + { + for ( size_t n = 0; n < m_growableRows.size(); n++ ) + { + wxASSERT_MSG( m_growableRows[n] < nrows, + "invalid growable row index" ); + } + } + + if ( !m_cols ) + { + for ( size_t n = 0; n < m_growableCols.size(); n++ ) + { + wxASSERT_MSG( m_growableCols[n] < ncols, + "invalid growable column index" ); + } + } + } +#endif // __WXDEBUG__ + + if ( (m_flexDirection & wxHORIZONTAL) || (m_growMode != wxFLEX_GROWMODE_NONE) ) { DoAdjustForGrowables @@ -1837,10 +1882,16 @@ void wxFlexGridSizer::AddGrowableRow( size_t idx, int proportion ) { int nrows, ncols; CalcRowsCols(nrows, ncols); - wxCHECK_RET( idx < (size_t)nrows, "invalid row index" ); wxASSERT_MSG( !IsRowGrowable( idx ), "AddGrowableRow() called for growable row" ); + + // notice that we intentionally don't check the index validity here in (the + // common) case when the number of rows was not specified in the ctor -- in + // this case it will be computed only later, when all items are added to + // the sizer, and the check will be done in AdjustForGrowables() + wxCHECK_RET( !m_rows || idx < (size_t)m_rows, "invalid row index" ); + m_growableRows.Add( idx ); m_growableRowsProportions.Add( proportion ); } @@ -1849,10 +1900,14 @@ void wxFlexGridSizer::AddGrowableCol( size_t idx, int proportion ) { int nrows, ncols; CalcRowsCols(nrows, ncols); - wxCHECK_RET( idx < (size_t)ncols, "invalid column index" ); wxASSERT_MSG( !IsColGrowable( idx ), "AddGrowableCol() called for growable column" ); + + // see comment in AddGrowableRow(): although it's less common to omit the + // specification of the number of columns, it still can also happen + wxCHECK_RET( !m_cols || idx < (size_t)ncols, "invalid column index" ); + m_growableCols.Add( idx ); m_growableColsProportions.Add( proportion ); } @@ -1984,7 +2039,7 @@ void wxBoxSizer::RecalcSizes() } // NB: wxCENTRE is used here only for backwards compatibility, // wxALIGN_CENTRE should be used in new code - else if ( flag & (wxCENTER | wxALIGN_CENTRE) ) + else if ( flag & (wxCENTER | (IsVertical() ? wxALIGN_CENTRE_HORIZONTAL : wxALIGN_CENTRE_VERTICAL))) { PosInMinorDir(posChild) += (totalMinorSize - minorSize) / 2; } @@ -2234,7 +2289,7 @@ void wxStdDialogButtonSizer::Realize() } // Extra space around and at the right - Add(12, 24); + Add(12, 40); #elif defined(__WXGTK20__) Add(0, 0, 0, wxLEFT, 9); if (m_buttonHelp)