From 465de0be705e52c7f97e9bb6169af9d20a7f72a8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 15 Aug 2012 23:34:22 +0000 Subject: [PATCH] No real changes, just add wxSizerItem::AddBorderToSize() helper. Factor out this function from GetMinSizeWithBorder() as it will be used for max size too in a next commit. See #11497. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72344 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/sizer.h | 4 ++++ src/common/sizer.cpp | 30 ++++++++++++++++++------------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/include/wx/sizer.h b/include/wx/sizer.h index 0e1b968481..73229cc8a1 100644 --- a/include/wx/sizer.h +++ b/include/wx/sizer.h @@ -436,6 +436,10 @@ protected: void DoSetSizer(wxSizer *sizer); void DoSetSpacer(const wxSize& size); + // Add the border specified for this item to the given size + // if it's != wxDefaultSize, just return wxDefaultSize otherwise. + wxSize AddBorderToSize(const wxSize& size) const; + // discriminated union: depending on m_kind one of the fields is valid enum { diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index 1e100d2973..e0bdaa7c5b 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -207,6 +207,23 @@ void wxSizerItem::DoSetSpacer(const wxSize& size) SetRatio(size); } +wxSize wxSizerItem::AddBorderToSize(const wxSize& size) const +{ + if (size == wxDefaultSize) + return size; + + wxSize result = size; + if (m_flag & wxWEST) + result.x += m_border; + if (m_flag & wxEAST) + result.x += m_border; + if (m_flag & wxNORTH) + result.y += m_border; + if (m_flag & wxSOUTH) + result.y += m_border; + return result; +} + wxSizerItem::wxSizerItem(int width, int height, int proportion, @@ -397,18 +414,7 @@ wxSize wxSizerItem::CalcMin() wxSize wxSizerItem::GetMinSizeWithBorder() const { - wxSize ret = m_minSize; - - if (m_flag & wxWEST) - ret.x += m_border; - if (m_flag & wxEAST) - ret.x += m_border; - if (m_flag & wxNORTH) - ret.y += m_border; - if (m_flag & wxSOUTH) - ret.y += m_border; - - return ret; + return AddBorderToSize(m_minSize); } -- 2.47.2