Form push button - draw update

This commit is contained in:
Jakub Melka 2020-09-20 17:17:44 +02:00
parent a9acfa31e3
commit bf09629aa9

View File

@ -3147,6 +3147,8 @@ void PDFWidgetAnnotation::draw(AnnotationDrawParameters& parameters) const
{
QRectF rectangle = getRectangle();
if (!getContents().isEmpty())
{
QByteArray defaultAppearance = parameters.formManager->getForm()->getDefaultAppearance().value_or(QByteArray());
PDFAnnotationDefaultAppearance appearance = PDFAnnotationDefaultAppearance::parse(defaultAppearance);
@ -3188,6 +3190,53 @@ void PDFWidgetAnnotation::draw(AnnotationDrawParameters& parameters) const
option.fontMetrics = fontMetrics;
QApplication::style()->drawControl(QStyle::CE_PushButton, &option, painter, nullptr);
}
else
{
// This is push button without text. Just mark the area as highlighted.
QPainter* painter = parameters.painter;
if (parameters.key.first == PDFAppeareanceStreams::Appearance::Rollover ||
parameters.key.first == PDFAppeareanceStreams::Appearance::Down)
{
switch (m_highlightMode)
{
case LinkHighlightMode::Invert:
{
// Invert all
painter->setCompositionMode(QPainter::CompositionMode_Difference);
painter->fillRect(rectangle, QBrush(Qt::white, Qt::SolidPattern));
break;
}
case LinkHighlightMode::Outline:
{
// Invert the border
painter->setCompositionMode(QPainter::CompositionMode_Difference);
QPen pen = getPen();
pen.setColor(Qt::white);
painter->setPen(pen);
painter->setBrush(Qt::NoBrush);
painter->drawRect(rectangle);
break;
}
case LinkHighlightMode::Push:
{
// Draw border
painter->setCompositionMode(getCompositionMode());
painter->setPen(getPen());
painter->setBrush(Qt::NoBrush);
painter->drawRect(rectangle);
break;
}
default:
Q_ASSERT(false);
break;
}
}
}
break;
}