if(minimised != m_minimised)
{
m_minimised = minimised;
- // Note that for sizers, this routine disallows the use of mixed shown
+ // Note that for sizers, this routine disallows the use of mixed shown
// and hidden controls
// TODO ? use some list of user set invisible children to restore status.
for (wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
{
if(GetSizer())
{
- // we have no information on size change direction
+ // 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)
{
// A panel never sizes continuously, even if all of its children can,
// as it would appear out of place along side non-continuous panels.
- return false;
+
+ // JS 2012-03-09: introducing wxRIBBON_PANEL_STRETCH to allow
+ // the panel to fill its parent page. For example we might have
+ // a list of styles in one of the pages, which should stretch to
+ // fill available space.
+ return (m_flags & wxRIBBON_PANEL_STRETCH) != 0;
+}
+
+// Finds the best width and height given the parent's width and height
+wxSize wxRibbonPanel::GetBestSizeForParentSize(const wxSize& parentSize) const
+{
+ if (GetChildren().GetCount() == 1)
+ {
+ wxWindow* win = GetChildren().GetFirst()->GetData();
+ wxRibbonControl* control = wxDynamicCast(win, wxRibbonControl);
+ if (control)
+ {
+ wxClientDC temp_dc((wxRibbonPanel*) this);
+ wxSize clientParentSize = m_art->GetPanelClientSize(temp_dc, this, parentSize, NULL);
+ wxSize childSize = control->GetBestSizeForParentSize(clientParentSize);
+ wxSize overallSize = m_art->GetPanelSize(temp_dc, this, childSize, NULL);
+ return overallSize;
+ }
+ }
+ return GetSize();
}
wxSize wxRibbonPanel::DoGetNextSmallerSize(wxOrientation direction,
wxRibbonControl* ribbon_child = wxDynamicCast(child, wxRibbonControl);
if(ribbon_child != NULL)
{
- smaller = ribbon_child->GetNextSmallerSize(direction, child_relative);
+ smaller = ribbon_child->GetNextSmallerSize(direction, child_relative);
minimise = (smaller == child_relative);
}
}
if(GetSizer())
{
- // We could just let the sizer expand in flow direction but see comment
+ // 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
}
// else use previously calculated m_smallest_unminimised_size
wxClientDC dc((wxRibbonPanel*) this);
- return m_art->GetPanelClientSize(dc,
- this,
+ return m_art->GetPanelClientSize(dc,
+ this,
m_smallest_unminimised_size,
NULL);
}
}
wxSize size = GetBestSize();
+
+ // Special case for flexible panel layout, where GetBestSize doesn't work
+ if (GetFlags() & wxRIBBON_PANEL_FLEXIBLE)
+ {
+ size = GetBestSizeForParentSize(wxSize(400, 1000));
+ }
+
wxPoint pos = GetExpandedPosition(wxRect(GetScreenPosition(), GetSize()),
size, m_preferred_expand_direction).GetTopLeft();
pos, size, wxFRAME_NO_TASKBAR | wxBORDER_NONE);
m_expanded_panel = new wxRibbonPanel(container, wxID_ANY,
- GetLabel(), m_minimised_icon, wxPoint(0, 0), size, m_flags);
+ GetLabel(), m_minimised_icon, wxPoint(0, 0), size, (m_flags /* & ~wxRIBBON_PANEL_FLEXIBLE */));
m_expanded_panel->SetArtProvider(m_art);
m_expanded_panel->m_expanded_dummy = this;
}
// Move sizer to new panel
- if(GetSizer())
+ if(GetSizer())
{
wxSizer* sizer = GetSizer();
- SetSizer(NULL, false);
+ SetSizer(NULL, false);
m_expanded_panel->SetSizer(sizer);
}
m_expanded_panel->Realize();
Refresh();
+ container->SetMinClientSize(size);
container->Show();
m_expanded_panel->SetFocus();