44 it !=
itemList.constEnd(); ++it, index++ )
59 int margin,
int spacing ):
64 setSpacing( spacing );
65 setContentsMargins( margin, margin, margin, margin );
75 setSpacing( spacing );
99 QLayout::invalidate();
225 QLayout::setGeometry( rect );
241 ( *it )->setGeometry( itemGeometries[index] );
272 if ( rowWidth > width )
301 colWidth[col] = qMax( colWidth[col],
305 const QMargins m = contentsMargins();
307 int rowWidth = m.left() + m.right() + ( numColumns - 1 ) * spacing();
309 rowWidth += colWidth[col];
349 if ( numColumns == 0 ||
isEmpty() )
350 return itemGeometries;
357 return itemGeometries;
362 layoutGrid( numColumns, rowHeight, colWidth );
364 bool expandH, expandV;
368 if ( expandH || expandV )
369 stretchGrid( rect, numColumns, rowHeight, colWidth );
373 const QRect alignedRect = alignmentRect( rect );
376 const int xOffset = expandH ? 0 : alignedRect.x();
377 const int yOffset = expandV ? 0 : alignedRect.y();
382 const int xySpace = spacing();
384 const QMargins m = contentsMargins();
386 rowY[0] = yOffset + m.top();
387 for ( uint r = 1; r <
numRows; r++ )
388 rowY[r] = rowY[r-1] + rowHeight[r-1] + xySpace;
390 colX[0] = xOffset + m.left();
392 colX[
c] = colX[
c-1] + colWidth[
c-1] + xySpace;
395 itemGeometries.reserve( itemCount );
402 const QRect itemGeometry( colX[col], rowY[row],
403 colWidth[col], rowHeight[row] );
404 itemGeometries.append( itemGeometry );
407 return itemGeometries;
423 if ( numColumns <= 0 )
436 rowHeight[row] = ( col == 0 )
437 ? size.height() : qMax( rowHeight[row], size.height() );
438 colWidth[col] = ( row == 0 )
439 ? size.width() : qMax( colWidth[col], size.width() );
469 layoutGrid( numColumns, rowHeight, colWidth );
471 const QMargins m = contentsMargins();
473 int h = m.top() + m.bottom() + ( numRows - 1 ) * spacing();
474 for ( uint row = 0; row <
numRows; row++ )
495 if ( numColumns == 0 ||
isEmpty() )
498 bool expandH, expandV;
502 const QMargins m = contentsMargins();
506 int xDelta = rect.width() - m.left() - m.right() - ( numColumns - 1 ) * spacing();
508 xDelta -= colWidth[col];
514 const int space = xDelta / ( numColumns - col );
515 colWidth[col] +=
space;
527 int yDelta = rect.height() - m.top() - m.bottom() - ( numRows - 1 ) * spacing();
528 for ( uint row = 0; row <
numRows; row++ )
529 yDelta -= rowHeight[row];
533 for ( uint row = 0; row <
numRows; row++ )
535 const int space = yDelta / ( numRows - row );
536 rowHeight[row] +=
space;
567 layoutGrid( numColumns, rowHeight, colWidth );
569 const QMargins m = contentsMargins();
571 int h = m.top() + m.bottom() + ( numRows - 1 ) * spacing();
572 for ( uint row = 0; row <
numRows; row++ )
575 int w = m.left() + m.right() + ( numColumns - 1 ) * spacing();
579 return QSize( w, h );
603 #include "moc_qwt_dyngrid_layout.cpp" virtual int heightForWidth(int) const QWT_OVERRIDE
virtual int maxItemWidth() const
Qt::Orientations expanding
QwtDynGridLayout(QWidget *, int margin=0, int spacing=-1)
virtual uint columnsForWidth(int width) const
Calculate the number of columns for a given width.
virtual bool hasHeightForWidth() const QWT_OVERRIDE
virtual QLayoutItem * takeAt(int index) QWT_OVERRIDE
void stretchGrid(const QRect &rect, uint numColumns, QVector< int > &rowHeight, QVector< int > &colWidth) const
void setMaxColumns(uint maxColumns)
virtual QSize sizeHint() const QWT_OVERRIDE
int maxRowWidth(int numColumns) const
virtual QLayoutItem * itemAt(int index) const QWT_OVERRIDE
QList< QRect > layoutItems(const QRect &, uint numColumns) const
virtual Qt::Orientations expandingDirections() const QWT_OVERRIDE
Returns whether this layout can make use of more space than sizeHint().
void layoutGrid(uint numColumns, QVector< int > &rowHeight, QVector< int > &colWidth) const
QList< QLayoutItem * > itemList
virtual void addItem(QLayoutItem *) QWT_OVERRIDE
Add an item to the next free position.
virtual void invalidate() QWT_OVERRIDE
Invalidate all internal caches.
uint maxColumns() const
Return the upper limit for the number of columns.
QVector< QSize > itemSizeHints
virtual ~QwtDynGridLayout()
Destructor.
virtual bool isEmpty() const QWT_OVERRIDE
virtual void setGeometry(const QRect &) QWT_OVERRIDE
virtual int count() const QWT_OVERRIDE
void setExpandingDirections(Qt::Orientations)