X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ba763a45d85d8b70326da65895b7753f86fc3ea3..b6a20a20d010d643e52914f51aa0700df0da925f:/src/common/sizer.cpp diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index 165d7d8bba..b171d66ae5 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -105,13 +105,13 @@ wxSizerItem::wxSizerItem( wxWindow *window, int proportion, int flag, int border , m_show( true ) , m_userData( userData ) { - // aspect ratio calculated from initial size - SetRatio( m_minSize ); - if (flag & wxFIXED_MINSIZE) window->SetMinSize(window->GetSize()); m_minSize = window->GetSize(); + // aspect ratio calculated from initial size + SetRatio( m_minSize ); + // m_size is calculated later } @@ -180,8 +180,6 @@ wxSize wxSizerItem::GetSize() const wxSize wxSizerItem::CalcMin() { - wxSize ret; - if (IsSizer()) { m_minSize = m_sizer->GetMinSize(); @@ -189,7 +187,7 @@ wxSize wxSizerItem::CalcMin() // if we have to preserve aspect ratio _AND_ this is // the first-time calculation, consider ret to be initial size if ((m_flag & wxSHAPED) && !m_ratio) - SetRatio(ret); + SetRatio(m_minSize); } else if ( IsWindow() ) { @@ -368,6 +366,16 @@ void wxSizer::Add( wxSizerItem *item ) item->GetWindow()->SetContainingSizer( this ); } +void wxSizer::AddSpacer(int size) +{ + Add(size, size); +} + +void wxSizer::AddStretchSpacer(int prop) +{ + Add(0, 0, prop); +} + void wxSizer::Prepend( wxWindow *window, int proportion, int flag, int border, wxObject* userData ) { m_children.Insert( new wxSizerItem( window, proportion, flag, border, userData ) ); @@ -392,6 +400,16 @@ void wxSizer::Prepend( wxSizerItem *item ) item->GetWindow()->SetContainingSizer( this ); } +void wxSizer::PrependSpacer(int size) +{ + Prepend(size, size); +} + +void wxSizer::PrependStretchSpacer(int prop) +{ + Prepend(0, 0, prop); +} + void wxSizer::Insert( size_t index, wxWindow *window, int proportion, @@ -435,6 +453,16 @@ void wxSizer::Insert( size_t index, wxSizerItem *item ) item->GetWindow()->SetContainingSizer( this ); } +void wxSizer::InsertSpacer(size_t index, int size) +{ + Insert(index, size, size); +} + +void wxSizer::InsertStretchSpacer(size_t index, int prop) +{ + Insert(index, 0, 0, prop); +} + bool wxSizer::Remove( wxWindow *window ) { return Detach( window ); @@ -1044,7 +1072,7 @@ wxSize wxGridSizer::CalcMin() void wxGridSizer::SetItemBounds( wxSizerItem *item, int x, int y, int w, int h ) { wxPoint pt( x,y ); - wxSize sz( item->CalcMin() ); + wxSize sz( item->GetMinSizeWithBorder() ); int flag = item->GetFlag(); if ((flag & wxEXPAND) || (flag & wxSHAPED)) @@ -1055,20 +1083,20 @@ void wxGridSizer::SetItemBounds( wxSizerItem *item, int x, int y, int w, int h ) { if (flag & wxALIGN_CENTER_HORIZONTAL) { - pt.x = x + (w - sz.x - m_hgap) / 2; + pt.x = x + (w - sz.x) / 2; } else if (flag & wxALIGN_RIGHT) { - pt.x = x + (w - sz.x - m_hgap); + pt.x = x + (w - sz.x); } if (flag & wxALIGN_CENTER_VERTICAL) { - pt.y = y + (h - sz.y - m_vgap) / 2; + pt.y = y + (h - sz.y) / 2; } else if (flag & wxALIGN_BOTTOM) { - pt.y = y + (h - sz.y - m_vgap); + pt.y = y + (h - sz.y); } }