X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8b492f67ab10417d061556f97b7298ff37055393..8f4745feeb2850f3bebb3af45407e164550d541a:/src/common/sizer.cpp diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index f8d4d2ddf1..ad5f899c8c 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -1341,10 +1341,15 @@ wxSizerItem *wxGridSizer::Insert(size_t index, wxSizerItem *item) // this here to ensure that we detect errors as soon as possible if ( m_cols && m_rows ) { - if ( m_children.GetCount() == m_cols*m_rows ) + const int nitems = m_children.GetCount(); + if ( nitems == m_cols*m_rows ) { - wxFAIL_MSG( "too many items in grid sizer (maybe you should omit " - "the number of either rows or columns?)" ); + wxFAIL_MSG( + wxString::Format( + "too many items (%d > %d*%d) in grid sizer (maybe you " + "should omit the number of either rows or columns?)", + nitems + 1, m_cols, m_rows) + ); // additionally, continuing to use the specified number of columns // and rows is not a good idea as callers of CalcRowsCols() expect @@ -1808,7 +1813,7 @@ DoAdjustForGrowables(int delta, void wxFlexGridSizer::AdjustForGrowables(const wxSize& sz) { -#ifdef __WXDEBUG__ +#if wxDEBUG_LEVEL // 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 @@ -1836,7 +1841,7 @@ void wxFlexGridSizer::AdjustForGrowables(const wxSize& sz) } } } -#endif // __WXDEBUG__ +#endif // wxDEBUG_LEVEL if ( (m_flexDirection & wxHORIZONTAL) || (m_growMode != wxFLEX_GROWMODE_NONE) ) @@ -2146,29 +2151,44 @@ wxStaticBoxSizer::~wxStaticBoxSizer() delete m_staticBox; } -static void GetStaticBoxBorders( wxStaticBox *box, - int *borderTop, - int *borderOther) -{ - // this has to be done platform by platform as there is no way to - // guess the thickness of a wxStaticBox border - box->GetBordersForSizer(borderTop, borderOther); -} - void wxStaticBoxSizer::RecalcSizes() { int top_border, other_border; - GetStaticBoxBorders(m_staticBox, &top_border, &other_border); + m_staticBox->GetBordersForSizer(&top_border, &other_border); m_staticBox->SetSize( m_position.x, m_position.y, m_size.x, m_size.y ); - wxPoint old_pos( m_position ); - m_position.x += other_border; - m_position.y += top_border; wxSize old_size( m_size ); m_size.x -= 2*other_border; m_size.y -= top_border + other_border; + wxPoint old_pos( m_position ); + if (m_staticBox->GetChildren().GetCount() > 0) + { +#if defined( __WXGTK20__ ) + // if the wxStaticBox has created a wxPizza to contain its children + // (see wxStaticBox::AddChild) then we need to place the items it contains + // in the wxBoxSizer::RecalcSizes() call below using coordinates relative + // to the top-left corner of the staticbox: + m_position.x = m_position.y = 0; +#else + // if the wxStaticBox has childrens, then these windows must be placed + // by the wxBoxSizer::RecalcSizes() call below using coordinates relative + // to the top-left corner of the staticbox (but unlike wxGTK, we need + // to keep in count the static borders here!): + m_position.x = other_border; + m_position.y = top_border; +#endif + } + else + { + // the windows contained in the staticbox have been created as siblings of the + // staticbox (this is the "old" way of staticbox contents creation); in this + // case we need to position them with coordinates relative to our common parent + m_position.x += other_border; + m_position.y += top_border; + } + wxBoxSizer::RecalcSizes(); m_position = old_pos; @@ -2178,10 +2198,17 @@ void wxStaticBoxSizer::RecalcSizes() wxSize wxStaticBoxSizer::CalcMin() { int top_border, other_border; - GetStaticBoxBorders(m_staticBox, &top_border, &other_border); + m_staticBox->GetBordersForSizer(&top_border, &other_border); wxSize ret( wxBoxSizer::CalcMin() ); ret.x += 2*other_border; + + // ensure that we're wide enough to show the static box label (there is no + // need to check for the static box best size in vertical direction though) + const int boxWidth = m_staticBox->GetBestSize().x; + if ( ret.x < boxWidth ) + ret.x = boxWidth; + ret.y += other_border + top_border; return ret; @@ -2209,6 +2236,10 @@ bool wxStaticBoxSizer::Detach( wxWindow *window ) #endif // wxUSE_STATBOX +//--------------------------------------------------------------------------- +// wxStdDialogButtonSizer +//--------------------------------------------------------------------------- + #if wxUSE_BUTTON wxStdDialogButtonSizer::wxStdDialogButtonSizer()