+
+// ----------------------------------------------------------------------------
+// wxWizardSizer
+// ----------------------------------------------------------------------------
+
+wxWizardSizer::wxWizardSizer(wxWizard *owner)
+ : m_owner(owner),
+ m_childSize(wxDefaultSize)
+{
+}
+
+wxSizerItem *wxWizardSizer::Insert(size_t index, wxSizerItem *item)
+{
+ m_owner->m_usingSizer = true;
+
+ if ( item->IsWindow() )
+ {
+ // we must pretend that the window is shown as otherwise it wouldn't be
+ // taken into account for the layout -- but avoid really showing it, so
+ // just set the internal flag instead of calling wxWindow::Show()
+ item->GetWindow()->wxWindowBase::Show();
+ }
+
+ return wxSizer::Insert(index, item);
+}
+
+void wxWizardSizer::HidePages()
+{
+ for ( wxSizerItemList::compatibility_iterator node = GetChildren().GetFirst();
+ node;
+ node = node->GetNext() )
+ {
+ wxSizerItem * const item = node->GetData();
+ if ( item->IsWindow() )
+ item->GetWindow()->wxWindowBase::Show(false);
+ }
+}
+
+void wxWizardSizer::RecalcSizes()
+{
+ // Effect of this function depends on m_owner->m_page and
+ // it should be called whenever it changes (wxWizard::ShowPage)
+ if ( m_owner->m_page )
+ {
+ m_owner->m_page->SetSize(wxRect(m_position, m_size));
+ }
+}
+
+wxSize wxWizardSizer::CalcMin()
+{
+ return m_owner->GetPageSize();
+}
+
+wxSize wxWizardSizer::GetMaxChildSize()
+{
+#if !defined(__WXDEBUG__)
+ if ( m_childSize.IsFullySpecified() )
+ return m_childSize;
+#endif
+
+ wxSize maxOfMin;
+
+ for ( wxSizerItemList::compatibility_iterator childNode = m_children.GetFirst();
+ childNode;
+ childNode = childNode->GetNext() )
+ {
+ wxSizerItem *child = childNode->GetData();
+ maxOfMin.IncTo(child->CalcMin());
+ maxOfMin.IncTo(SiblingSize(child));
+ }
+
+#ifdef __WXDEBUG__
+ if ( m_childSize.IsFullySpecified() && m_childSize != maxOfMin )
+ {
+ wxFAIL_MSG( _T("Size changed in wxWizard::GetPageAreaSizer()")
+ _T("after RunWizard().\n")
+ _T("Did you forget to call GetSizer()->Fit(this) ")
+ _T("for some page?")) ;
+
+ return m_childSize;
+ }
+#endif // __WXDEBUG__
+
+ if ( m_owner->m_started )
+ {
+ m_childSize = maxOfMin;
+ }
+
+ return maxOfMin;
+}
+
+int wxWizardSizer::GetBorder() const
+{
+ return m_owner->m_border;
+}
+
+wxSize wxWizardSizer::SiblingSize(wxSizerItem *child)
+{
+ wxSize maxSibling;
+
+ if ( child->IsWindow() )
+ {
+ wxWizardPage *page = wxDynamicCast(child->GetWindow(), wxWizardPage);
+ if ( page )
+ {
+ for ( wxWizardPage *sibling = page->GetNext();
+ sibling;
+ sibling = sibling->GetNext() )
+ {
+ if ( sibling->GetSizer() )
+ {
+ maxSibling.IncTo(sibling->GetSizer()->CalcMin());
+ }
+ }
+ }
+ }
+
+ return maxSibling;
+}
+