QGIS API Documentation 3.28.14-Firenze (exported)
Loading...
Searching...
No Matches
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 "qgsunittypes.h"
25#include "qgstextmasksettings.h"
26#include "qgsstringutils.h"
27
28#include <QSharedDataPointer>
29
30class QMimeData;
31class QgsTextSettingsPrivate;
32
40class CORE_EXPORT QgsTextFormat
41{
42 public:
43
49
54 QgsTextFormat( const QgsTextFormat &other );
55
56 QgsTextFormat &operator=( const QgsTextFormat &other );
57
59
60 bool operator==( const QgsTextFormat &other ) const;
61 bool operator!=( const QgsTextFormat &other ) const;
62
75 bool isValid() const;
76
83 void setValid();
84
89 QgsTextBufferSettings &buffer();
90
95 SIP_SKIP QgsTextBufferSettings buffer() const { return mBufferSettings; }
96
102 void setBuffer( const QgsTextBufferSettings &bufferSettings );
103
108 QgsTextBackgroundSettings &background();
109
114 SIP_SKIP QgsTextBackgroundSettings background() const { return mBackgroundSettings; }
115
121 void setBackground( const QgsTextBackgroundSettings &backgroundSettings );
122
127 QgsTextShadowSettings &shadow();
128
133 SIP_SKIP QgsTextShadowSettings shadow() const { return mShadowSettings; }
134
140 void setShadow( const QgsTextShadowSettings &shadowSettings );
141
146 QgsTextMaskSettings &mask();
147
154 SIP_SKIP QgsTextMaskSettings mask() const { return mMaskSettings; }
155
163 void setMask( const QgsTextMaskSettings &maskSettings );
164
174 QFont font() const;
175
189 QFont scaledFont( const QgsRenderContext &context, double scaleFactor = 1.0, bool *isZeroSize SIP_PYARGREMOVE = nullptr ) const;
190
200 void setFont( const QFont &font );
201
207 QString namedStyle() const;
208
215 void setNamedStyle( const QString &style );
216
228 bool forcedBold() const;
229
241 void setForcedBold( bool forced );
242
254 bool forcedItalic() const;
255
267 void setForcedItalic( bool forced );
268
278 QStringList families() const;
279
293 void setFamilies( const QStringList &families );
294
300 double size() const;
301
308 void setSize( double size );
309
316 QgsUnitTypes::RenderUnit sizeUnit() const;
317
325 void setSizeUnit( QgsUnitTypes::RenderUnit unit );
326
333 QgsMapUnitScale sizeMapUnitScale() const;
334
341 void setSizeMapUnitScale( const QgsMapUnitScale &scale );
342
347 QColor color() const;
348
354 void setColor( const QColor &color );
355
361 double opacity() const;
362
369 void setOpacity( double opacity );
370
383 int stretchFactor() const;
384
397 void setStretchFactor( int factor );
398
403 QPainter::CompositionMode blendMode() const;
404
410 void setBlendMode( QPainter::CompositionMode mode );
411
422 double lineHeight() const;
423
434 void setLineHeight( double height );
435
444 QgsUnitTypes::RenderUnit lineHeightUnit() const;
445
454 void setLineHeightUnit( QgsUnitTypes::RenderUnit unit );
455
461 Qgis::TextOrientation orientation() const;
462
468 void setOrientation( Qgis::TextOrientation orientation );
469
476 Qgis::Capitalization capitalization() const;
477
484 void setCapitalization( Qgis::Capitalization capitalization );
485
500 bool allowHtmlFormatting() const;
501
516 void setAllowHtmlFormatting( bool allow );
517
523 QColor previewBackgroundColor() const;
524
530 void setPreviewBackgroundColor( const QColor &color );
531
536 void readFromLayer( QgsVectorLayer *layer );
537
542 void readXml( const QDomElement &elem, const QgsReadWriteContext &context );
543
548 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
549
555 QMimeData *toMimeData() const SIP_FACTORY;
556
564 static QgsTextFormat fromQFont( const QFont &font );
565
573 QFont toQFont() const;
574
580 static QgsTextFormat fromMimeData( const QMimeData *data, bool *ok SIP_OUT = nullptr );
581
586 bool containsAdvancedEffects() const;
587
593 bool fontFound() const { return mTextFontFound; }
594
601 QString resolvedFontFamily() const { return mTextFontFamily; }
602
608 QgsPropertyCollection &dataDefinedProperties();
609
616 const QgsPropertyCollection &dataDefinedProperties() const SIP_SKIP;
617
622 QSet<QString> referencedFields( const QgsRenderContext &context ) const;
623
630 void setDataDefinedProperties( const QgsPropertyCollection &collection );
631
636 void updateDataDefinedProperties( QgsRenderContext &context );
637
646 static QPixmap textFormatPreviewPixmap( const QgsTextFormat &format, QSize size, const QString &previewText = QString(), int padding = 0 );
647
648 private:
649
650 QgsTextBufferSettings mBufferSettings;
651 QgsTextBackgroundSettings mBackgroundSettings;
652 QgsTextShadowSettings mShadowSettings;
653 QgsTextMaskSettings mMaskSettings;
654
655 QString mTextFontFamily;
656 bool mTextFontFound = true;
657
658 QSharedDataPointer<QgsTextSettingsPrivate> d;
659
660};
661
663
664#endif // QGSTEXTFORMAT_H
Capitalization
String capitalization options.
Definition qgis.h:1762
TextOrientation
Text orientations.
Definition qgis.h:1430
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.
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.
QgsTextBufferSettings buffer() const
Returns a reference to the text buffer settings.
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.
RenderUnit
Rendering size units.
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)