X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/aa21b5090ad75a806fe20b6371933302f67d821e..4a377e137527eb7f4a26b9e3bc1cd88e8c108676:/src/common/sizer.cpp diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index a412637448..e71d728a8b 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -163,30 +163,12 @@ wxSize wxSizerItem::CalcMin() void wxSizerItem::SetDimension( wxPoint pos, wxSize size ) { - m_pos = pos; - - if (m_flag & wxWEST) + if (m_flag & wxSHAPED) { - pos.x += m_border; - size.x -= m_border; - } - if (m_flag & wxEAST) - { - size.x -= m_border; - } - if (m_flag & wxNORTH) - { - pos.y += m_border; - size.y -= m_border; - } - if (m_flag & wxSOUTH) - { - size.y -= m_border; - } - if (m_flag & wxSHAPED) { // adjust aspect ratio int rwidth = (int) (size.y * m_ratio); - if (rwidth > size.x) { + if (rwidth > size.x) + { // fit horizontally int rheight = (int) (size.x / m_ratio); // add vertical space @@ -196,7 +178,9 @@ void wxSizerItem::SetDimension( wxPoint pos, wxSize size ) pos.y += (size.y - rheight); // use reduced dimensions size.y =rheight; - } else if (rwidth < size.x) { + } + else if (rwidth < size.x) + { // add horizontal space if (m_flag & wxALIGN_CENTER_HORIZONTAL) pos.x += (size.x - rwidth) / 2; @@ -205,6 +189,30 @@ void wxSizerItem::SetDimension( wxPoint pos, wxSize size ) size.x = rwidth; } } + + // This is what GetPosition() returns. Since we calculate + // borders afterwards, GetPosition() will be the left/top + // corner of the surrounding border. + m_pos = pos; + + if (m_flag & wxWEST) + { + pos.x += m_border; + size.x -= m_border; + } + if (m_flag & wxEAST) + { + size.x -= m_border; + } + if (m_flag & wxNORTH) + { + pos.y += m_border; + size.y -= m_border; + } + if (m_flag & wxSOUTH) + { + size.y -= m_border; + } if (IsSizer()) m_sizer->SetDimension( pos.x, pos.y, size.x, size.y );