- 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(-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)