Skip to content
Permalink
Browse files
Fix minimum size of composer legend
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13493 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed May 15, 2010
1 parent 129b398 commit add39a3b37969569a3cd88616169cafd694da242
Showing with 16 additions and 14 deletions.
  1. +16 −14 src/core/composer/qgscomposerlegend.cpp
@@ -117,6 +117,19 @@ QSizeF QgsComposerLegend::paintAndDetermineSize( QPainter* painter )

currentYCoordinate += mBoxSpace;

size.setHeight( currentYCoordinate );
size.setWidth( maxXCoord );

//adjust box if width or height is to small
if ( painter && currentYCoordinate > rect().height() )
{
setSceneRect( QRectF( transform().dx(), transform().dy(), rect().width(), currentYCoordinate ) );
}
if ( painter && maxXCoord > rect().width() )
{
setSceneRect( QRectF( transform().dx(), transform().dy(), maxXCoord, rect().height() ) );
}

if ( painter )
{
painter->restore();
@@ -129,19 +142,6 @@ QSizeF QgsComposerLegend::paintAndDetermineSize( QPainter* painter )
}
}

size.setHeight( currentYCoordinate );
size.setWidth( maxXCoord );

//adjust box if width or height is to small
if ( painter && currentYCoordinate > rect().width() )
{
setSceneRect( QRectF( transform().dx(), transform().dy(), rect().width(), currentYCoordinate ) );
}
if ( painter && maxXCoord > rect().height() )
{
setSceneRect( QRectF( transform().dx(), transform().dy(), maxXCoord, rect().height() ) );
}

return size;
}

@@ -295,9 +295,11 @@ void QgsComposerLegend::drawLayerChildItems( QPainter* p, QStandardItem* layerIt
{
p->setPen( QColor( 0, 0, 0 ) );
drawText( p, currentXCoord, currentYCoord + fontAscentMillimeters( mItemFont ) + ( realItemHeight - fontAscentMillimeters( mItemFont ) ) / 2, currentItem->text(), mItemFont );
currentXCoord += textWidthMillimeters( mItemFont, currentItem->text() );
}
currentXCoord += mBoxSpace;

maxXCoord = std::max( maxXCoord, currentXCoord + textWidthMillimeters( mItemFont, currentItem->text() ) + mBoxSpace );
maxXCoord = std::max( maxXCoord, currentXCoord );

currentYCoord += realItemHeight;
}

0 comments on commit add39a3

Please sign in to comment.