From 1eba21938708bcd10ab13837b4ad51e44f783b40 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 14 Apr 2004 23:45:21 +0000 Subject: [PATCH] Added wxSizerItem::SetMinSize that calls m_window->SetSizeHints if not wxFIXED_MINSIZE, SetInitSize and SetItemMinSize uses SetMinSize, and fixed [ 934651 ] sizeritem's 'minsize' value has no effect in xrc resources git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26778 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/src/xrc/xh_sizer.cpp | 6 ++++-- include/wx/sizer.h | 10 +++++++++- src/common/sizer.cpp | 7 ++----- src/xrc/xh_sizer.cpp | 6 ++++-- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/contrib/src/xrc/xh_sizer.cpp b/contrib/src/xrc/xh_sizer.cpp index 5590ded11e..2e3f3e4908 100644 --- a/contrib/src/xrc/xh_sizer.cpp +++ b/contrib/src/xrc/xh_sizer.cpp @@ -122,7 +122,6 @@ wxObject* wxSizerXmlHandler::Handle_sizeritem() { // create a sizer item for it wxSizerItem* sitem = MakeSizerItem(); - SetSizerItemAttributes(sitem); // now fetch the item to be managed bool old_gbs = m_isGBS; @@ -146,6 +145,9 @@ wxObject* wxSizerXmlHandler::Handle_sizeritem() else wxLogError(wxT("Error in resource.")); + // finally, set other wxSizerItem attributes + SetSizerItemAttributes(sitem); + AddSizerItem(sitem); return item; } @@ -339,7 +341,7 @@ void wxSizerXmlHandler::SetSizerItemAttributes(wxSizerItem* sitem) sitem->SetBorder(GetDimension(wxT("border"))); wxSize sz = GetSize(wxT("minsize")); if (!(sz == wxDefaultSize)) - sitem->SetInitSize(sz.x, sz.y); + sitem->SetMinSize(sz); sz = GetSize(wxT("ratio")); if (!(sz == wxDefaultSize)) sitem->SetRatio(sz); diff --git a/include/wx/sizer.h b/include/wx/sizer.h index eeed12325b..5f7738dce2 100644 --- a/include/wx/sizer.h +++ b/include/wx/sizer.h @@ -74,8 +74,16 @@ public: wxSize GetMinSize() const { return m_minSize; } + void SetMinSize(const wxSize& size) + { + if (IsWindow() && !(m_flag & wxFIXED_MINSIZE)) + m_window->SetSizeHints(size); + m_minSize = size; + } + void SetMinSize( int x, int y ) + { SetMinSize(wxSize(x, y)); } void SetInitSize( int x, int y ) - { m_minSize.x = x; m_minSize.y = y; } + { SetMinSize(wxSize(x, y)); } void SetRatio( int width, int height ) // if either of dimensions is zero, ratio is assumed to be 1 diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index 424968309f..2fd2d9f854 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -735,8 +735,7 @@ bool wxSizer::DoSetItemMinSize( wxWindow *window, int width, int height ) if (item->GetWindow() == window) { - item->SetInitSize( width, height ); - item->GetWindow()->SetSizeHints(width, height); + item->SetMinSize( width, height ); return true; } node = node->GetNext(); @@ -815,9 +814,7 @@ bool wxSizer::DoSetItemMinSize( size_t index, int width, int height ) else { // ... but the minimal size of spacers and windows in stored in them - item->SetInitSize( width, height ); - if (item->GetWindow()) - item->GetWindow()->SetSizeHints(width, height); + item->SetMinSize( width, height ); } return true; diff --git a/src/xrc/xh_sizer.cpp b/src/xrc/xh_sizer.cpp index 5590ded11e..2e3f3e4908 100644 --- a/src/xrc/xh_sizer.cpp +++ b/src/xrc/xh_sizer.cpp @@ -122,7 +122,6 @@ wxObject* wxSizerXmlHandler::Handle_sizeritem() { // create a sizer item for it wxSizerItem* sitem = MakeSizerItem(); - SetSizerItemAttributes(sitem); // now fetch the item to be managed bool old_gbs = m_isGBS; @@ -146,6 +145,9 @@ wxObject* wxSizerXmlHandler::Handle_sizeritem() else wxLogError(wxT("Error in resource.")); + // finally, set other wxSizerItem attributes + SetSizerItemAttributes(sitem); + AddSizerItem(sitem); return item; } @@ -339,7 +341,7 @@ void wxSizerXmlHandler::SetSizerItemAttributes(wxSizerItem* sitem) sitem->SetBorder(GetDimension(wxT("border"))); wxSize sz = GetSize(wxT("minsize")); if (!(sz == wxDefaultSize)) - sitem->SetInitSize(sz.x, sz.y); + sitem->SetMinSize(sz); sz = GetSize(wxT("ratio")); if (!(sz == wxDefaultSize)) sitem->SetRatio(sz);