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,6 +163,36 @@ wxSize wxSizerItem::CalcMin() void wxSizerItem::SetDimension( wxPoint pos, wxSize size ) { + if (m_flag & wxSHAPED) + { + // adjust aspect ratio + int rwidth = (int) (size.y * m_ratio); + if (rwidth > size.x) + { + // fit horizontally + int rheight = (int) (size.x / m_ratio); + // add vertical space + if (m_flag & wxALIGN_CENTER_VERTICAL) + pos.y += (size.y - rheight) / 2; + else if (m_flag & wxALIGN_BOTTOM) + pos.y += (size.y - rheight); + // use reduced dimensions + size.y =rheight; + } + else if (rwidth < size.x) + { + // add horizontal space + if (m_flag & wxALIGN_CENTER_HORIZONTAL) + pos.x += (size.x - rwidth) / 2; + else if (m_flag & wxALIGN_RIGHT) + pos.x += (size.x - rwidth); + 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) @@ -183,28 +213,6 @@ void wxSizerItem::SetDimension( wxPoint pos, wxSize size ) { size.y -= m_border; } - if (m_flag & wxSHAPED) { - // adjust aspect ratio - int rwidth = (int) (size.y * m_ratio); - if (rwidth > size.x) { - // fit horizontally - int rheight = (int) (size.x / m_ratio); - // add vertical space - if (m_flag & wxALIGN_CENTER_VERTICAL) - pos.y += (size.y - rheight) / 2; - else if (m_flag & wxALIGN_BOTTOM) - pos.y += (size.y - rheight); - // use reduced dimensions - size.y =rheight; - } else if (rwidth < size.x) { - // add horizontal space - if (m_flag & wxALIGN_CENTER_HORIZONTAL) - pos.x += (size.x - rwidth) / 2; - else if (m_flag & wxALIGN_RIGHT) - pos.x += (size.x - rwidth); - size.x = rwidth; - } - } if (IsSizer()) m_sizer->SetDimension( pos.x, pos.y, size.x, size.y );