void wxSFGridShape::DoChildrenLayout() { if( !m_nCols || !m_nRows ) return; wxSFShapeBase *pShape; int nIndex, nRow, nCol; //wxRealPoint nAbsPos = GetAbsolutePosition(); wxRect currRect, maxRect = wxRect(0,0,0,0); // get maximum size of all managed (child) shapes SerializableList::compatibility_iterator node = GetFirstChildNode(); while(node) { pShape = (wxSFShapeBase*)node->GetData(); currRect = pShape->GetBoundingBox(); if( (pShape->GetHAlign() != halignEXPAND) && (currRect.GetWidth() > maxRect.GetWidth()) ) maxRect.SetWidth(currRect.GetWidth()); if( (pShape->GetVAlign() != valignEXPAND) && (currRect.GetHeight() > maxRect.GetHeight()) ) maxRect.SetHeight(currRect.GetHeight()); node = node->GetNext(); } // put managed shapes to appropriate positions nIndex = nCol = 0; nRow = -1; for(size_t i = 0; i < m_arrCells.GetCount(); i++ ) { pShape = (wxSFShapeBase*) GetChild(m_arrCells[i]); if( pShape ) { if( nIndex++ % m_nCols == 0 ) { nCol = 0; nRow++; } else nCol++; FitShapeToRect( pShape, wxRect( nCol*maxRect.GetWidth() + (nCol+1)*m_nCellSpace, nRow*maxRect.GetHeight() + (nRow+1)*m_nCellSpace, maxRect.GetWidth(), maxRect.GetHeight() ) ); } } }
void uddFlexGridShape::DoChildrenLayout() { if( !m_nCols || !m_nRows ) return; wxSFShapeBase *pShape; int nIndex, nRow, nCol, nTotalX, nTotalY; size_t i; wxRect nCurrRect; // initialize size arrays m_arrRowSizes.SetCount( m_nRows ); m_arrColSizes.SetCount( m_nCols ); for( i = 0; i < (size_t)m_nRows; i++ ) m_arrRowSizes[i] = 0; for( i = 0; i < (size_t)m_nCols; i++ ) m_arrColSizes[i] = 0; nIndex = nCol = nTotalX = nTotalY = 0; nRow = -1; // prepare a storage for processed shapes pointers m_arrChildShapes.SetCount( m_arrCells.GetCount() ); // get maximum size of all managed (child) shapes per row and collumn for( i = 0; i < m_arrCells.GetCount(); i++ ) { pShape = (wxSFShapeBase*)GetChild(m_arrCells[i]); if( pShape ) { // store used shape pointer for further processing (optimization for speed) m_arrChildShapes[i] = pShape; if( nIndex++ % m_nCols == 0 ) { nCol = 0; nRow++; } else nCol++; nCurrRect = pShape->GetBoundingBox(); // update maximum rows and columns sizes if( (pShape->GetHAlign() != halignEXPAND) && (nCurrRect.GetWidth() > m_arrColSizes[nCol]) ) m_arrColSizes[nCol] = nCurrRect.GetWidth(); if( (pShape->GetVAlign() != valignEXPAND) && (nCurrRect.GetHeight() > m_arrRowSizes[nRow]) ) m_arrRowSizes[nRow] = nCurrRect.GetHeight(); } } // put managed shapes to appropriate positions nIndex = nCol = 0; nRow = -1; for( i = 0; i < m_arrCells.GetCount(); i++ ) { pShape = m_arrChildShapes[i]; if( pShape ) { if( nIndex++ % m_nCols == 0 ) { nCol = 0; nTotalX = 0; nRow++; if( nRow > 0 ) nTotalY += m_arrRowSizes[ nRow-1 ]; } else { nCol++; if( nCol > 0 ) nTotalX += m_arrColSizes[ nCol-1 ]; } FitShapeToRect( pShape, wxRect( nTotalX + (nCol+1)*m_nCellSpace, nTotalY + (nRow+1)*m_nCellSpace, m_arrColSizes[ nCol ], m_arrRowSizes[ nRow ] ) ); } } }