Skip to content
Permalink
Browse files

Draw missing character backgrounds with different color

  • Loading branch information
nyalldawson committed May 2, 2019
1 parent 57fa547 commit dd47298090399ee95faa00a3d4d2f2e62e76aa15
Showing with 4 additions and 5 deletions.
  1. +4 −5 src/gui/symbology/characterwidget.cpp
@@ -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 )

0 comments on commit dd47298

Please sign in to comment.
You can’t perform that action at this time.