QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
qgstextblockformat.h
Go to the documentation of this file.
1/***************************************************************************
2 qgstextblockformat.h
3 -----------------
4 begin : September 2024
5 copyright : (C) Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSTEXTBLOCKFORMAT_H
17#define QGSTEXTBLOCKFORMAT_H
18
19#include "qgis_sip.h"
20#include "qgis_core.h"
21#include "qgis.h"
22#include "qgsmargins.h"
23
24#include <QFont>
25#include <QColor>
26#include <QBrush>
27
28class QTextBlockFormat;
30
43class CORE_EXPORT QgsTextBlockFormat
44{
45 public:
46
47 QgsTextBlockFormat() = default;
48
52 QgsTextBlockFormat( const QTextBlockFormat &format );
53
55 enum class BooleanValue
56 {
57 NotSet,
58 SetTrue,
59 SetFalse,
60 };
61
73 void overrideWith( const QgsTextBlockFormat &other );
74
83 bool hasHorizontalAlignmentSet() const { return mHasHorizontalAlignSet; }
84
93 void setHasHorizontalAlignmentSet( bool set ) { mHasHorizontalAlignSet = set; }
94
103 Qgis::TextHorizontalAlignment horizontalAlignment() const { return mHorizontalAlign; }
104
113 void setHorizontalAlignment( Qgis::TextHorizontalAlignment alignment ) { mHorizontalAlign = alignment; }
114
126 double lineHeight() const;
127
141 void setLineHeight( double height );
142
153 double lineHeightPercentage() const;
154
167 void setLineHeightPercentage( double height );
168
175 QgsMargins margins() const { return mMargins; }
176
183 void setMargins( const QgsMargins &margins ) { mMargins = margins; }
184
191 bool hasBackground() const;
192
202 QBrush backgroundBrush() const;
203
212 void setBackgroundBrush( const QBrush &brush );
213
223 QString backgroundImagePath() const;
224
233 void setBackgroundImagePath( const QString &path );
234
244 void updateFontForFormat( QFont &font, const QgsRenderContext &context, double scaleFactor = 1.0 ) const;
245
246 private:
247
248 QBrush mBackgroundBrush;
249 QString mBackgroundPath;
250
251 double mLineHeight = std::numeric_limits< double >::quiet_NaN();
252 double mLineHeightPercentage = std::numeric_limits< double >::quiet_NaN();
253
254 bool mHasHorizontalAlignSet = false;
256
257 QgsMargins mMargins { std::numeric_limits< double >::quiet_NaN(), std::numeric_limits< double >::quiet_NaN(), std::numeric_limits< double >::quiet_NaN(), std::numeric_limits< double >::quiet_NaN() };
258};
259
260#endif // QGSTEXTBLOCKFORMAT_H
TextHorizontalAlignment
Text horizontal alignment.
Definition qgis.h:2785
The QgsMargins class defines the four margins of a rectangle.
Definition qgsmargins.h:37
Contains information about the context of a rendering operation.
Stores information relating to individual block formatting.
Qgis::TextHorizontalAlignment horizontalAlignment() const
Returns the format horizontal alignment.
void setHasHorizontalAlignmentSet(bool set)
Sets whether the format has an explicit horizontal alignment set.
void setHorizontalAlignment(Qgis::TextHorizontalAlignment alignment)
Sets the format horizontal alignment.
void setMargins(const QgsMargins &margins)
Sets the block margins, in points.
bool hasHorizontalAlignmentSet() const
Returns true if the format has an explicit horizontal alignment set.
BooleanValue
Status values for boolean format properties.
QgsMargins margins() const
Returns the block margins, in points.
QgsTextBlockFormat()=default