19#include <QTextBlockFormat>
24 set = format.hasProperty( QTextFormat::BlockAlignment );
25 if ( format.alignment() & Qt::AlignLeft )
29 else if ( format.alignment() & Qt::AlignRight )
33 else if ( format.alignment() & Qt::AlignHCenter )
37 else if ( format.alignment() & Qt::AlignJustify )
47 : mBackgroundBrush( format.background() )
48 , mBackgroundPath( format.stringProperty( QTextFormat::BackgroundImageUrl ) )
49 , mLineHeight( format.hasProperty( QTextFormat::LineHeight ) && format.lineHeightType() != QTextBlockFormat::ProportionalHeight ? format.lineHeight() : std::numeric_limits< double >::quiet_NaN() )
50 , mLineHeightPercentage( format.hasProperty( QTextFormat::LineHeight ) && format.lineHeightType() == QTextBlockFormat::ProportionalHeight ? ( format.lineHeight() / 100.0 ) : std::numeric_limits< double >::quiet_NaN() )
54 const double topMargin = format.hasProperty( QTextFormat::BlockTopMargin ) ? format.topMargin() : std::numeric_limits< double >::quiet_NaN();
55 const double leftMargin = format.hasProperty( QTextFormat::BlockLeftMargin ) ? format.leftMargin() : std::numeric_limits< double >::quiet_NaN();
56 const double rightMargin = format.hasProperty( QTextFormat::BlockRightMargin ) ? format.rightMargin() : std::numeric_limits< double >::quiet_NaN();
57 const double bottomMargin = format.hasProperty( QTextFormat::BlockBottomMargin ) ? format.bottomMargin() : std::numeric_limits< double >::quiet_NaN();
58 mMargins =
QgsMargins( leftMargin, topMargin, rightMargin, bottomMargin );
65 mHorizontalAlign = other.mHorizontalAlign;
66 mHasHorizontalAlignSet =
true;
69 if ( std::isnan( mLineHeight ) )
70 mLineHeight = other.mLineHeight;
71 if ( std::isnan( mLineHeightPercentage ) )
72 mLineHeightPercentage = other.mLineHeightPercentage;
74 if ( std::isnan( mMargins.
left() ) )
76 if ( std::isnan( mMargins.
right() ) )
78 if ( std::isnan( mMargins.
top() ) )
80 if ( std::isnan( mMargins.
bottom() ) )
96 return mLineHeightPercentage;
101 mLineHeightPercentage = height;
111 return mBackgroundBrush.style() != Qt::NoBrush || !mBackgroundPath.isEmpty();
116 return mBackgroundBrush;
121 mBackgroundBrush = brush;
126 return mBackgroundPath;
131 mBackgroundPath = path;
TextHorizontalAlignment
Text horizontal alignment.
The QgsMargins class defines the four margins of a rectangle.
void setBottom(double bottom)
Sets the bottom margin to bottom.
double top() const
Returns the top margin.
void setLeft(double left)
Sets the left margin to left.
double right() const
Returns the right margin.
double bottom() const
Returns the bottom margin.
void setRight(double right)
Sets the right margin to right.
void setTop(double top)
Sets the top margin to top.
double left() const
Returns the left margin.
Contains information about the context of a rendering operation.
Stores information relating to individual block formatting.
bool hasBackground() const
Returns true if the block has a background set.
QBrush backgroundBrush() const
Returns the brush used for rendering the background of the block.
double lineHeight() const
Returns the line height in points, or NaN if the line height is not set and should be auto calculated...
double lineHeightPercentage() const
Returns the line height percentage size (as fraction of font size from 0.0 to 1.0),...
void overrideWith(const QgsTextBlockFormat &other)
Override all the default/unset properties of the current block format with the settings from another ...
void updateFontForFormat(QFont &font, const QgsRenderContext &context, double scaleFactor=1.0) const
Updates the specified font in place, applying block formatting options which are applicable on a font...
QString backgroundImagePath() const
Returns the path for the image to be used for rendering the background of the fragment.
void setBackgroundImagePath(const QString &path)
Sets the path for the image to be used for rendering the background of the fragment.
bool hasHorizontalAlignmentSet() const
Returns true if the format has an explicit horizontal alignment set.
void setLineHeightPercentage(double height)
Sets the line height percentage height (as fraction of font size from 0.0 to 1.0).
QgsTextBlockFormat()=default
void setLineHeight(double height)
Sets the font line height, in points.
void setBackgroundBrush(const QBrush &brush)
Sets the brush used for rendering the background of the block.
Qgis::TextHorizontalAlignment convertTextBlockFormatAlign(const QTextBlockFormat &format, bool &set)