X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/75738bb65b5db3f5d3106e6fad78c7a4a07f993b..ec080ef1873995bcd9b20b0fc1a6d208a78540d3:/src/common/sizer.cpp diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index 31f2503850..518ccce91f 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -582,25 +582,20 @@ bool wxSizerItem::IsShown() const return m_window->IsShown(); case Item_Sizer: + { // arbitrarily decide that if at least one of our elements is // shown, so are we (this arbitrariness is the reason for // deprecating this function) + for ( wxSizerItemList::compatibility_iterator + node = m_sizer->GetChildren().GetFirst(); + node; + node = node->GetNext() ) { - // Some apps (such as dialog editors) depend on an empty sizer still - // being laid out correctly and reporting the correct size and position. - if (m_sizer->GetChildren().GetCount() == 0) + if ( node->GetData()->IsShown() ) return true; - - for ( wxSizerItemList::compatibility_iterator - node = m_sizer->GetChildren().GetFirst(); - node; - node = node->GetNext() ) - { - if ( node->GetData()->IsShown() ) - return true; - } } return false; + } case Item_Spacer: return m_spacer->IsShown(); @@ -2300,7 +2295,12 @@ wxSize wxBoxSizer::CalcMin() m_totalProportion = 0; m_minSize = wxSize(0, 0); - // calculate the minimal sizes for all items and count sum of proportions + // The minimal size for the sizer should be big enough to allocate its + // element at least its minimal size but also, and this is the non trivial + // part, to respect the children proportion. To satisfy the latter + // condition we must find the greatest min-size-to-proportion ratio for all + // elements with non-zero proportion. + float maxMinSizeToProp = 0.; for ( wxSizerItemList::const_iterator i = m_children.begin(); i != m_children.end(); ++i ) @@ -2311,13 +2311,31 @@ wxSize wxBoxSizer::CalcMin() continue; const wxSize sizeMinThis = item->CalcMin(); - SizeInMajorDir(m_minSize) += GetSizeInMajorDir(sizeMinThis); + if ( const int propThis = item->GetProportion() ) + { + float minSizeToProp = GetSizeInMajorDir(sizeMinThis); + minSizeToProp /= propThis; + + if ( minSizeToProp > maxMinSizeToProp ) + maxMinSizeToProp = minSizeToProp; + + m_totalProportion += item->GetProportion(); + } + else // fixed size item + { + // Just account for its size directly + SizeInMajorDir(m_minSize) += GetSizeInMajorDir(sizeMinThis); + } + + // In the transversal direction we just need to find the maximum. if ( GetSizeInMinorDir(sizeMinThis) > GetSizeInMinorDir(m_minSize) ) SizeInMinorDir(m_minSize) = GetSizeInMinorDir(sizeMinThis); - - m_totalProportion += item->GetProportion(); } + // Using the max ratio ensures that the min size is big enough for all + // items to have their min size and satisfy the proportions among them. + SizeInMajorDir(m_minSize) += (int)(maxMinSizeToProp*m_totalProportion); + return m_minSize; } @@ -2560,19 +2578,35 @@ void wxStdDialogButtonSizer::Realize() Add((wxWindow*)m_buttonNegative, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, 3); } - // according to HIG, in explicit apply windows the order is: - // [ Help Apply Cancel OK ] if (m_buttonApply) - Add((wxWindow*)m_buttonApply, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, 3); + { + // according to HIG, in explicit apply windows the order is: + // [ Help Apply Cancel OK ] - if (m_buttonCancel){ - Add((wxWindow*)m_buttonCancel, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, 3); - // Cancel or help should be default - // m_buttonCancel->SetDefaultButton(); + Add((wxWindow*)m_buttonApply, + 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, 3); + + if (m_buttonCancel) + Add((wxWindow*)m_buttonCancel, + 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, 3); + + if (m_buttonAffirmative) + Add((wxWindow*)m_buttonAffirmative, + 0, wxALIGN_CENTRE | wxLEFT, 6); + } + else + { + // without an Apply button, have the buttons representing + // affirmative and negative close to each other. + + if (m_buttonAffirmative) + Add((wxWindow*)m_buttonAffirmative, + 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, 3); + + if (m_buttonCancel) + Add((wxWindow*)m_buttonCancel, 0, wxALIGN_CENTRE | wxLEFT, 6); } - if (m_buttonAffirmative) - Add((wxWindow*)m_buttonAffirmative, 0, wxALIGN_CENTRE | wxLEFT, 6); #elif defined(__WXMSW__) // Windows