Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 add39a3
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/core/composer/qgscomposerlegend.cpp
Expand Up @@ -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();
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit add39a3

Please sign in to comment.