Skip to content

Commit

Permalink
Draw missing character backgrounds with different color
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 2, 2019
1 parent 57fa547 commit dd47298
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/gui/symbology/characterwidget.cpp
Expand Up @@ -220,27 +220,26 @@ void CharacterWidget::paintEvent( QPaintEvent *event )
QPainter painter( this );
painter.setFont( mDisplayFont );

QFontMetrics fontMetrics( mDisplayFont );

QRect redrawRect = event->rect();
int beginRow = redrawRect.top() / mSquareSize;
int endRow = redrawRect.bottom() / mSquareSize;
int beginColumn = redrawRect.left() / mSquareSize;
int endColumn = std::min( mColumns - 1, redrawRect.right() / mSquareSize );

QPalette palette = qApp->palette();
QRectF backgroundRect = event->rect();
backgroundRect.setWidth( std::min( backgroundRect.width(), ( endColumn + 1 ) * mSquareSize - backgroundRect.left() ) );
painter.fillRect( backgroundRect, QBrush( palette.color( QPalette::Base ) ) );

painter.setPen( QPen( palette.color( QPalette::Mid ) ) );
for ( int row = beginRow; row <= endRow; ++row )
{
for ( int column = beginColumn; column <= endColumn; ++column )
{
int key = row * mColumns + column;
painter.setBrush( fontMetrics.inFont( QChar( key ) ) ? QBrush( palette.color( QPalette::Base ) ) : Qt::NoBrush );
painter.drawRect( column * mSquareSize, row * mSquareSize, mSquareSize, mSquareSize );
}
}

QFontMetrics fontMetrics( mDisplayFont );
for ( int row = beginRow; row <= endRow; ++row )
{
for ( int column = beginColumn; column <= endColumn; ++column )
Expand Down

0 comments on commit dd47298

Please sign in to comment.