wxSize wxRibbonPanel::GetMinSize() const { if(m_expanded_panel != NULL) { // Minimum size depends upon children, who are currently in the // expanded panel return m_expanded_panel->GetMinSize(); } if(CanAutoMinimise()) { return m_minimised_size; } else { return GetMinNotMinimisedSize(); } }
// Checks if panel would be minimised at (client size) at_size bool wxRibbonPanel::IsMinimised(wxSize at_size) const { if(GetSizer()) { // we have no information on size change direction // so check both wxSize size = GetMinNotMinimisedSize(); if(size.x > at_size.x || size.y > at_size.y) return true; return false; } if(!m_minimised_size.IsFullySpecified()) return false; return (at_size.GetX() <= m_minimised_size.GetX() && at_size.GetY() <= m_minimised_size.GetY()) || at_size.GetX() < m_smallest_unminimised_size.GetX() || at_size.GetY() < m_smallest_unminimised_size.GetY(); }
bool wxRibbonPanel::Realize() { bool status = true; #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for (wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext()) { wxRibbonControl* child = wxDynamicCast(node->GetData(), wxRibbonControl); if(child == NULL) { continue; } if(!child->Realize()) { status = false; } } wxSize minimum_children_size(0, 0); // Ask sizer if there is one present if(GetSizer()) { minimum_children_size = GetPanelSizerMinSize(); } else if(GetChildren().GetCount() == 1) { minimum_children_size = GetChildren().GetFirst()->GetData()->GetMinSize(); } if(m_art != NULL) { wxClientDC temp_dc(this); m_smallest_unminimised_size = m_art->GetPanelSize(temp_dc, this, minimum_children_size, NULL); wxSize bitmap_size; wxSize panel_min_size = GetMinNotMinimisedSize(); m_minimised_size = m_art->GetMinimisedPanelMinimumSize(temp_dc, this, &bitmap_size, &m_preferred_expand_direction); if(m_minimised_icon.IsOk() && m_minimised_icon.GetSize() != bitmap_size) { wxImage img(m_minimised_icon.ConvertToImage()); img.Rescale(bitmap_size.GetWidth(), bitmap_size.GetHeight(), wxIMAGE_QUALITY_HIGH); m_minimised_icon_resized = wxBitmap(img); } else { m_minimised_icon_resized = m_minimised_icon; } if(m_minimised_size.x > panel_min_size.x && m_minimised_size.y > panel_min_size.y) { // No point in having a minimised size which is larger than the // minimum size which the children can go to. m_minimised_size = wxSize(-1, -1); } else { if(m_art->GetFlags() & wxRIBBON_BAR_FLOW_VERTICAL) { m_minimised_size.x = panel_min_size.x; } else { m_minimised_size.y = panel_min_size.y; } } } else { m_minimised_size = wxSize(-1, -1); } return Layout() && status; }
wxSize wxRibbonPanel::DoGetNextLargerSize(wxOrientation direction, wxSize relative_to) const { if(m_expanded_panel != NULL) { // Next size depends upon children, who are currently in the // expanded panel return m_expanded_panel->DoGetNextLargerSize(direction, relative_to); } if(IsMinimised(relative_to)) { wxSize current = relative_to; wxSize min_size = GetMinNotMinimisedSize(); switch(direction) { case wxHORIZONTAL: if(min_size.x > current.x && min_size.y == current.y) return min_size; break; case wxVERTICAL: if(min_size.x == current.x && min_size.y > current.y) return min_size; break; case wxBOTH: if(min_size.x > current.x && min_size.y > current.y) return min_size; break; default: break; } } if(m_art != NULL) { wxClientDC dc((wxRibbonPanel*) this); wxSize child_relative = m_art->GetPanelClientSize(dc, this, relative_to, NULL); wxSize larger(-1, -1); if(GetSizer()) { // We could just let the sizer expand in flow direction but see comment // in IsSizingContinuous() larger = GetPanelSizerBestSize(); // and adjust for page in non flow direction if(m_art->GetFlags() & wxRIBBON_BAR_FLOW_VERTICAL) { if(larger.x != child_relative.x) larger.x = child_relative.x; } else if(larger.y != child_relative.y) { larger.y = child_relative.y; } } else if(GetChildren().GetCount() == 1) { // Simple (and common) case of single ribbon child wxWindow* child = GetChildren().Item(0)->GetData(); wxRibbonControl* ribbon_child = wxDynamicCast(child, wxRibbonControl); if(ribbon_child != NULL) { larger = ribbon_child->GetNextLargerSize(direction, child_relative); } } if(larger.IsFullySpecified()) // Use fallback if !(sizer/child = 1) { if(larger == child_relative) { return relative_to; } else { return m_art->GetPanelSize(dc, this, larger, NULL); } } } // Fallback: Increase by 25% (equal to a prior or subsequent 20% decrease) // Note that due to rounding errors, this increase may not exactly equal a // matching decrease - an ideal solution would not have these errors, but // avoiding them is non-trivial unless an increase is by 100% rather than // a fractional amount. This would then be non-ideal as the resizes happen // at very large intervals. wxSize current(relative_to); if(direction & wxHORIZONTAL) { current.x = (current.x * 5 + 3) / 4; } if(direction & wxVERTICAL) { current.y = (current.y * 5 + 3) / 4; } return current; }
wxSize wxRibbonPanel::DoGetNextLargerSize(wxOrientation direction, wxSize relative_to) const { if(m_expanded_panel != NULL) { // Next size depends upon children, who are currently in the // expanded panel return m_expanded_panel->DoGetNextLargerSize(direction, relative_to); } if(IsMinimised(relative_to)) { wxSize current = relative_to; wxSize min_size = GetMinNotMinimisedSize(); switch(direction) { case wxHORIZONTAL: if(min_size.x > current.x && min_size.y == current.y) return min_size; break; case wxVERTICAL: if(min_size.x == current.x && min_size.y > current.y) return min_size; break; case wxBOTH: if(min_size.x > current.x && min_size.y > current.y) return min_size; break; default: break; } } // TODO: Check for, and delegate to, a sizer // Simple (and common) case of single ribbon child if(GetChildren().GetCount() == 1) { wxWindow* child = GetChildren().Item(0)->GetData(); wxRibbonControl* ribbon_child = wxDynamicCast(child, wxRibbonControl); if(ribbon_child != NULL) { wxClientDC dc((wxRibbonPanel*) this); wxSize child_relative = m_art->GetPanelClientSize(dc, this, relative_to, NULL); wxSize larger = ribbon_child->GetNextLargerSize(direction, child_relative); if(larger == child_relative) { return relative_to; } else { wxClientDC dc((wxRibbonPanel*) this); return m_art->GetPanelSize(dc, this, larger, NULL); } } } // Fallback: Increase by 25% (equal to a prior or subsequent 20% decrease) // Note that due to rounding errors, this increase may not exactly equal a // matching decrease - an ideal solution would not have these errors, but // avoiding them is non-trivial unless an increase is by 100% rather than // a fractional amount. This would then be non-ideal as the resizes happen // at very large intervals. wxSize current(relative_to); if(direction & wxHORIZONTAL) { current.x = (current.x * 5 + 3) / 4; } if(direction & wxVERTICAL) { current.y = (current.y * 5 + 3) / 4; } return current; }