From cdddaeea1043fa8fd0c0efdce98b7370fb02ac05 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 26 Sep 2000 13:54:47 +0000 Subject: [PATCH] fix from Robert git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8420 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/sizer.cpp | 52 +++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 22 deletions(-) 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 ); -- 2.47.2