void Doc::LayOut( ) { this->SetCurrentScoreDef(); Page *contentPage = this->SetDrawingPage( 0 ); assert( contentPage ); contentPage->LayOutHorizontally(); System *contentSystem = dynamic_cast<System*>(contentPage->DetachChild( 0 )); assert( contentSystem ); System *currentSystem = new System(); contentPage->AddSystem( currentSystem ); int shift = 0; int systemFullWidth = this->m_drawingPageWidth - this->m_drawingPageLeftMar - this->m_drawingPageRightMar - currentSystem->m_systemLeftMar - currentSystem->m_systemRightMar; ArrayPtrVoid params; params.push_back( contentSystem ); params.push_back( contentPage ); params.push_back( ¤tSystem ); params.push_back( &shift ); params.push_back( &systemFullWidth ); Functor castOffSystems( &Object::CastOffSystems ); contentSystem->Process( &castOffSystems, params ); delete contentSystem; LogDebug("Layout: %d systems", contentPage->GetSystemCount()); // Reset the scoreDef at the beginning of each system this->SetCurrentScoreDef( true ); contentPage->LayOutVertically( ); // Detach the contentPage this->DetachChild( 0 ); assert( contentPage && !contentPage->m_parent ); Page *currentPage = new Page(); this->AddPage( currentPage ); shift = 0; int pageFullHeight = this->m_drawingPageHeight - this->m_drawingPageTopMar; // obviously we need a bottom margin params.clear(); params.push_back( contentPage ); params.push_back( this ); params.push_back( ¤tPage ); params.push_back( &shift ); params.push_back( &pageFullHeight ); Functor castOffPages( &Object::CastOffPages ); contentPage->Process( &castOffPages, params ); delete contentPage; LogDebug("Layout: %d pages", this->GetChildCount()); // We need to reset the drawing page to NULL // because idx will still be 0 but contentPage is dead! this->ResetDrawingPage( ); this->SetCurrentScoreDef( true ); }