QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
qgstextformat.h
Go to the documentation of this file.
1/***************************************************************************
2 qgstextformat.h
3 ---------------
4 begin : May 2020
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 QGSTEXTFORMAT_H
17#define QGSTEXTFORMAT_H
18
19#include "qgis_sip.h"
20#include "qgis_core.h"
21#include "qgis.h"
25#include "qgstextmasksettings.h"
26#include "qgsstringutils.h"
27#include "qgsscreenproperties.h"
28
29#include <QSharedDataPointer>
30
31class QMimeData;
32class QgsTextSettingsPrivate;
33
41class CORE_EXPORT QgsTextFormat
42{
43 public:
44
50
55 QgsTextFormat( const QgsTextFormat &other );
56
57 QgsTextFormat &operator=( const QgsTextFormat &other );
58
60
61 bool operator==( const QgsTextFormat &other ) const;
62 bool operator!=( const QgsTextFormat &other ) const;
63
76 bool isValid() const;
77
84 void setValid();
85
90 QgsTextBufferSettings &buffer();
91
96 SIP_SKIP QgsTextBufferSettings buffer() const { return mBufferSettings; }
97
103 void setBuffer( const QgsTextBufferSettings &bufferSettings );
104
109 QgsTextBackgroundSettings &background();
110
115 SIP_SKIP QgsTextBackgroundSettings background() const { return mBackgroundSettings; }
116
122 void setBackground( const QgsTextBackgroundSettings &backgroundSettings );
123
128 QgsTextShadowSettings &shadow();
129
134 SIP_SKIP QgsTextShadowSettings shadow() const { return mShadowSettings; }
135
141 void setShadow( const QgsTextShadowSettings &shadowSettings );
142
147 QgsTextMaskSettings &mask();
148
155 SIP_SKIP QgsTextMaskSettings mask() const { return mMaskSettings; }
156
164 void setMask( const QgsTextMaskSettings &maskSettings );
165
175 QFont font() const;
176
190 QFont scaledFont( const QgsRenderContext &context, double scaleFactor = 1.0, bool *isZeroSize SIP_PYARGREMOVE = nullptr ) const;
191
201 void setFont( const QFont &font );
202
208 QString namedStyle() const;
209
216 void setNamedStyle( const QString &style );
217
229 bool forcedBold() const;
230
242 void setForcedBold( bool forced );
243
255 bool forcedItalic() const;
256
268 void setForcedItalic( bool forced );
269
279 QStringList families() const;
280
294 void setFamilies( const QStringList &families );
295
301 double size() const;
302
309 void setSize( double size );
310
317 Qgis::RenderUnit sizeUnit() const;
318
326 void setSizeUnit( Qgis::RenderUnit unit );
327
334 QgsMapUnitScale sizeMapUnitScale() const;
335
342 void setSizeMapUnitScale( const QgsMapUnitScale &scale );
343
348 QColor color() const;
349
355 void setColor( const QColor &color );
356
362 double opacity() const;
363
372 void multiplyOpacity( double opacityFactor );
373
380 void setOpacity( double opacity );
381
394 int stretchFactor() const;
395
408 void setStretchFactor( int factor );
409
414 QPainter::CompositionMode blendMode() const;
415
421 void setBlendMode( QPainter::CompositionMode mode );
422
433 double lineHeight() const;
434
445 void setLineHeight( double height );
446
455 Qgis::RenderUnit lineHeightUnit() const;
456
465 void setLineHeightUnit( Qgis::RenderUnit unit );
466
472 Qgis::TextOrientation orientation() const;
473
479 void setOrientation( Qgis::TextOrientation orientation );
480
487 Qgis::Capitalization capitalization() const;
488
495 void setCapitalization( Qgis::Capitalization capitalization );
496
511 bool allowHtmlFormatting() const;
512
527 void setAllowHtmlFormatting( bool allow );
528
534 QColor previewBackgroundColor() const;
535
541 void setPreviewBackgroundColor( const QColor &color );
542
547 void readFromLayer( QgsVectorLayer *layer );
548
553 void readXml( const QDomElement &elem, const QgsReadWriteContext &context );
554
559 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
560
566 QMimeData *toMimeData() const SIP_FACTORY;
567
575 static QgsTextFormat fromQFont( const QFont &font );
576
584 QFont toQFont() const;
585
591 static QgsTextFormat fromMimeData( const QMimeData *data, bool *ok SIP_OUT = nullptr );
592
597 bool containsAdvancedEffects() const;
598
604 bool fontFound() const { return mTextFontFound; }
605
612 QString resolvedFontFamily() const { return mTextFontFamily; }
613
619 QgsPropertyCollection &dataDefinedProperties();
620
627 const QgsPropertyCollection &dataDefinedProperties() const SIP_SKIP;
628
633 QSet<QString> referencedFields( const QgsRenderContext &context ) const;
634
641 void setDataDefinedProperties( const QgsPropertyCollection &collection );
642
647 void updateDataDefinedProperties( QgsRenderContext &context );
648
658 static QPixmap textFormatPreviewPixmap( const QgsTextFormat &format, QSize size, const QString &previewText = QString(), int padding = 0, const QgsScreenProperties &screen = QgsScreenProperties() );
659
660 private:
661
662 QgsTextBufferSettings mBufferSettings;
663 QgsTextBackgroundSettings mBackgroundSettings;
664 QgsTextShadowSettings mShadowSettings;
665 QgsTextMaskSettings mMaskSettings;
666
667 QString mTextFontFamily;
668 bool mTextFontFound = true;
669
670 QSharedDataPointer<QgsTextSettingsPrivate> d;
671
672};
673
675
676#endif // QGSTEXTFORMAT_H
Capitalization
String capitalization options.
Definition: qgis.h:2323
TextOrientation
Text orientations.
Definition: qgis.h:1944
RenderUnit
Rendering size units.
Definition: qgis.h:3441
Struct for storing maximum and minimum scales for measurements in map units.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
The class is used as a container of context for various read/write operations on other objects.
Contains information about the context of a rendering operation.
Stores properties relating to a screen.
Container for settings relating to a text background object.
Container for settings relating to a text buffer.
Container for all settings relating to text rendering.
Definition: qgstextformat.h:42
QgsTextBufferSettings buffer() const
Returns a reference to the text buffer settings.
Definition: qgstextformat.h:96
QString resolvedFontFamily() const
Returns the family for the resolved font, ie if the specified font was not found on the system this w...
QgsTextMaskSettings mask() const
Returns a reference to the masking settings.
QgsTextBackgroundSettings background() const
Returns a reference to the text background settings.
QgsTextShadowSettings shadow() const
Returns a reference to the text drop shadow settings.
Container for settings relating to a selective masking around a text.
Container for settings relating to a text shadow.
Represents a vector layer which manages a vector based data sets.
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_PYARGREMOVE
Definition: qgis_sip.h:151
#define SIP_OUT
Definition: qgis_sip.h:58
#define SIP_FACTORY
Definition: qgis_sip.h:76
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)