Exemplo n.º 1
0
void QgsComposerScaleBar::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
{
  Q_UNUSED( itemStyle );
  Q_UNUSED( pWidget );
  if ( !mStyle || !painter )
  {
    return;
  }
  if ( !shouldDrawItem() )
  {
    return;
  }

  drawBackground( painter );

  //x-offset is half of first label width because labels are drawn centered
  QString firstLabel = firstLabelString();
  double firstLabelWidth = QgsComposerUtils::textWidthMM( mFont, firstLabel );

  mStyle->draw( painter, firstLabelWidth / 2 );

  //draw frame and selection boxes if necessary
  drawFrame( painter );
  if ( isSelected() )
  {
    drawSelectionBoxes( painter );
  }
}
Exemplo n.º 2
0
void QgsComposerScaleBar::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
{
    Q_UNUSED( itemStyle );
    Q_UNUSED( pWidget );
    if ( !mStyle || !painter )
    {
        return;
    }

    drawBackground( painter );
    painter->setPen( QPen( QColor( 0, 0, 0 ) ) ); //draw all text black

    //x-offset is half of first label width because labels are drawn centered
    QString firstLabel = firstLabelString();
    double firstLabelWidth = textWidthMillimeters( mFont, firstLabel );

    mStyle->draw( painter, firstLabelWidth / 2 );

    //draw frame and selection boxes if necessary
    drawFrame( painter );
    if ( isSelected() )
    {
        drawSelectionBoxes( painter );
    }
}