mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-04-04 21:51:14 +02:00
Form push button - draw update
This commit is contained in:
parent
a9acfa31e3
commit
bf09629aa9
@ -3147,6 +3147,8 @@ void PDFWidgetAnnotation::draw(AnnotationDrawParameters& parameters) const
|
|||||||
{
|
{
|
||||||
QRectF rectangle = getRectangle();
|
QRectF rectangle = getRectangle();
|
||||||
|
|
||||||
|
if (!getContents().isEmpty())
|
||||||
|
{
|
||||||
QByteArray defaultAppearance = parameters.formManager->getForm()->getDefaultAppearance().value_or(QByteArray());
|
QByteArray defaultAppearance = parameters.formManager->getForm()->getDefaultAppearance().value_or(QByteArray());
|
||||||
PDFAnnotationDefaultAppearance appearance = PDFAnnotationDefaultAppearance::parse(defaultAppearance);
|
PDFAnnotationDefaultAppearance appearance = PDFAnnotationDefaultAppearance::parse(defaultAppearance);
|
||||||
|
|
||||||
@ -3188,6 +3190,53 @@ void PDFWidgetAnnotation::draw(AnnotationDrawParameters& parameters) const
|
|||||||
option.fontMetrics = fontMetrics;
|
option.fontMetrics = fontMetrics;
|
||||||
|
|
||||||
QApplication::style()->drawControl(QStyle::CE_PushButton, &option, painter, nullptr);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user