Skip to content
Permalink
Browse files
line color starts to work
  • Loading branch information
redlegoreng authored and mhugent committed Jan 22, 2013
1 parent 3d275e3 commit 310875ea89317b2d3216762de4c445dc7288a4ac
@@ -297,6 +297,30 @@ void QgsComposerScaleBarWidget::on_mFontButton_clicked()
mComposerScaleBar->update();
}

void QgsComposerScaleBarWidget::on_mFontColorPushButton_clicked()
{
if ( !mComposerScaleBar )
{
return;
}

QColor oldColor = mComposerScaleBar->fontPen().color();
QColor newColor = QColorDialog::getColor( oldColor, 0 );

if ( !newColor.isValid() ) //user canceled the dialog
{
return;
}

mComposerScaleBar->beginCommand( tr( "Scalebar font color changed" ) );
disconnectUpdateSignal();
QPen newPen( newColor );
mComposerScaleBar->setFontPen( newPen );
mComposerScaleBar->update();
connectUpdateSignal();
mComposerScaleBar->endCommand();
}

void QgsComposerScaleBarWidget::on_mColorPushButton_clicked()
{
if ( !mComposerScaleBar )
@@ -336,7 +360,7 @@ void QgsComposerScaleBarWidget::on_mStrokeColorPushButton_clicked()
return;
}

mComposerScaleBar->beginCommand( tr( "Scalebar color changed" ) );
mComposerScaleBar->beginCommand( tr( "Scalebar stroke color changed" ) );
disconnectUpdateSignal();
QPen newPen( newColor );
mComposerScaleBar->setPen( newPen );
@@ -44,6 +44,7 @@ class QgsComposerScaleBarWidget: public QWidget, private Ui::QgsComposerScaleBar
void on_mColorPushButton_clicked();
void on_mStrokeColorPushButton_clicked();
void on_mFontButton_clicked();
void on_mFontColorPushButton_clicked();
void on_mStyleComboBox_currentIndexChanged( const QString& text );
void on_mLabelBarSpaceSpinBox_valueChanged( double d );
void on_mBoxSizeSpinBox_valueChanged( double d );
@@ -60,7 +60,7 @@ void QgsComposerScaleBar::paint( QPainter* painter, const QStyleOptionGraphicsIt
}

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

//x-offset is half of first label width because labels are drawn centered
QString firstLabel = firstLabelString();
@@ -228,6 +228,7 @@ void QgsComposerScaleBar::applyDefaultSettings()
mBrush.setStyle( Qt::SolidPattern );

mFont.setPointSizeF( 12.0 );
mFontColor = QColor(0,0,0);

mLabelBarSpace = 3.0;
mBoxContentSpace = 1.0;
@@ -18,6 +18,7 @@

#include "qgscomposeritem.h"
#include <QPen>
#include <QColor>

class QgsComposerMap;
class QgsScaleBarStyle;
@@ -74,6 +75,9 @@ class CORE_EXPORT QgsComposerScaleBar: public QgsComposerItem

QFont font() const;

QPen fontPen()const {return mFontPen;}
void setFontPen( const QPen& pen ) {mFontPen = pen;}

void setFont( const QFont& font );

QPen pen() const {return mPen;}
@@ -172,6 +176,7 @@ class CORE_EXPORT QgsComposerScaleBar: public QgsComposerItem
QString mUnitLabeling;
/**Font*/
QFont mFont;
QPen mFontPen;
/**Outline*/
QPen mPen;
/**Fill*/
@@ -49,7 +49,7 @@ void QgsDoubleBoxScaleBarStyle::draw( QPainter* p, double xOffset ) const
double segmentHeight = mScaleBar->height() / 2;

p->save();
p->setPen( p->pen() );
p->setPen( mScaleBar->pen() );

QList<QPair<double, double> > segmentInfo;
mScaleBar->segmentPositions( segmentInfo );
@@ -78,7 +78,7 @@ void QgsScaleBarStyle::drawLabels( QPainter* p ) const

if ( segmentCounter == 0 || segmentCounter >= nSegmentsLeft ) //don't draw label for intermediate left segments
{
p->setPen( QColor( 0, 0, 0 ) );
p->setPen( mScaleBar->fontColor() );//THIS SEEMS USELESS ?
mScaleBar->drawText( p, segmentIt->first - mScaleBar->textWidthMillimeters( mScaleBar->font(), currentNumericLabel ) / 2 + xOffset, mScaleBar->fontAscentMillimeters( mScaleBar->font() ) + mScaleBar->boxContentSpace(), currentNumericLabel, mScaleBar->font() );
}

@@ -93,7 +93,7 @@ void QgsScaleBarStyle::drawLabels( QPainter* p ) const
if ( !segmentInfo.isEmpty() )
{
currentNumericLabel = QString::number( currentLabelNumber / mScaleBar->numMapUnitsPerScaleBarUnit() );
p->setPen( QColor( 0, 0, 0 ) );
p->setPen( mScaleBar->fontColor() );//THIS SEEMS USELESS ?
mScaleBar->drawText( p, segmentInfo.last().first + mScaleBar->segmentMillimeters() - mScaleBar->textWidthMillimeters( mScaleBar->font(), currentNumericLabel ) / 2 + xOffset, mScaleBar->fontAscentMillimeters( mScaleBar->font() ) + mScaleBar->boxContentSpace(), currentNumericLabel + " " + mScaleBar->unitLabeling(), mScaleBar->font() );
}

@@ -43,7 +43,8 @@ void QgsSingleBoxScaleBarStyle::draw( QPainter* p, double xOffset ) const
double barTopPosition = mScaleBar->fontAscentMillimeters( mScaleBar->font() ) + mScaleBar->labelBarSpace() + mScaleBar->boxContentSpace();

p->save();
p->setPen( p->pen() );
p->setPen( mScaleBar->pen() );


QList<QPair<double, double> > segmentInfo;
mScaleBar->segmentPositions( segmentInfo );
@@ -35,9 +35,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-138</y>
<y>0</y>
<width>415</width>
<height>636</height>
<height>552</height>
</rect>
</property>
<attribute name="label">
@@ -270,10 +270,7 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="mFontColorButton">
<property name="enabled">
<bool>false</bool>
</property>
<widget class="QPushButton" name="mFontColorPushButton">
<property name="text">
<string>Font color...</string>
</property>

0 comments on commit 310875e

Please sign in to comment.