QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
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 "qgis.h"
25#include "qgstextmasksettings.h"
26#include "qgsstringutils.h"
27#include "qgsscreenproperties.h"
28
29#include <QSharedDataPointer>
30
31class QMimeData;
32class QgsTextSettingsPrivate;
33
40class CORE_EXPORT QgsTextFormat
41{
42 public:
43
49
50 QgsTextFormat( const QgsTextFormat &other );
51
52 QgsTextFormat &operator=( const QgsTextFormat &other );
53
55
56 bool operator==( const QgsTextFormat &other ) const;
57 bool operator!=( const QgsTextFormat &other ) const;
58
71 bool isValid() const;
72
79 void setValid();
80
85 QgsTextBufferSettings &buffer();
86
91 SIP_SKIP QgsTextBufferSettings buffer() const { return mBufferSettings; }
92
98 void setBuffer( const QgsTextBufferSettings &bufferSettings );
99
104 QgsTextBackgroundSettings &background();
105
110 SIP_SKIP QgsTextBackgroundSettings background() const { return mBackgroundSettings; }
111
117 void setBackground( const QgsTextBackgroundSettings &backgroundSettings );
118
123 QgsTextShadowSettings &shadow();
124
129 SIP_SKIP QgsTextShadowSettings shadow() const { return mShadowSettings; }
130
136 void setShadow( const QgsTextShadowSettings &shadowSettings );
137
142 QgsTextMaskSettings &mask();
143
150 SIP_SKIP QgsTextMaskSettings mask() const { return mMaskSettings; }
151
159 void setMask( const QgsTextMaskSettings &maskSettings );
160
170 QFont font() const;
171
185 QFont scaledFont( const QgsRenderContext &context, double scaleFactor = 1.0, bool *isZeroSize SIP_PYARGREMOVE = nullptr ) const;
186
196 void setFont( const QFont &font );
197
203 QString namedStyle() const;
204
211 void setNamedStyle( const QString &style );
212
224 bool forcedBold() const;
225
237 void setForcedBold( bool forced );
238
250 bool forcedItalic() const;
251
263 void setForcedItalic( bool forced );
264
274 QStringList families() const;
275
289 void setFamilies( const QStringList &families );
290
296 double size() const;
297
304 void setSize( double size );
305
312 Qgis::RenderUnit sizeUnit() const;
313
321 void setSizeUnit( Qgis::RenderUnit unit );
322
329 QgsMapUnitScale sizeMapUnitScale() const;
330
337 void setSizeMapUnitScale( const QgsMapUnitScale &scale );
338
343 QColor color() const;
344
350 void setColor( const QColor &color );
351
357 double opacity() const;
358
367 void multiplyOpacity( double opacityFactor );
368
375 void setOpacity( double opacity );
376
389 int stretchFactor() const;
390
403 void setStretchFactor( int factor );
404
409 QPainter::CompositionMode blendMode() const;
410
416 void setBlendMode( QPainter::CompositionMode mode );
417
428 double lineHeight() const;
429
440 void setLineHeight( double height );
441
450 Qgis::RenderUnit lineHeightUnit() const;
451
460 void setLineHeightUnit( Qgis::RenderUnit unit );
461
470 double tabStopDistance() const;
471
480 void setTabStopDistance( double distance );
481
490 Qgis::RenderUnit tabStopDistanceUnit() const;
491
500 void setTabStopDistanceUnit( Qgis::RenderUnit unit );
501
511 QgsMapUnitScale tabStopDistanceMapUnitScale() const;
512
522 void setTabStopDistanceMapUnitScale( const QgsMapUnitScale &scale );
523
529 Qgis::TextOrientation orientation() const;
530
536 void setOrientation( Qgis::TextOrientation orientation );
537
544 Qgis::Capitalization capitalization() const;
545
552 void setCapitalization( Qgis::Capitalization capitalization );
553
568 bool allowHtmlFormatting() const;
569
584 void setAllowHtmlFormatting( bool allow );
585
591 QColor previewBackgroundColor() const;
592
598 void setPreviewBackgroundColor( const QColor &color );
599
604 void readFromLayer( QgsVectorLayer *layer );
605
610 void readXml( const QDomElement &elem, const QgsReadWriteContext &context );
611
616 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
617
623 QMimeData *toMimeData() const SIP_FACTORY;
624
632 static QgsTextFormat fromQFont( const QFont &font );
633
641 QFont toQFont() const;
642
648 static QgsTextFormat fromMimeData( const QMimeData *data, bool *ok SIP_OUT = nullptr );
649
654 bool containsAdvancedEffects() const;
655
661 bool fontFound() const { return mTextFontFound; }
662
669 QString resolvedFontFamily() const { return mTextFontFamily; }
670
676 QgsPropertyCollection &dataDefinedProperties();
677
684 const QgsPropertyCollection &dataDefinedProperties() const SIP_SKIP;
685
690 QSet<QString> referencedFields( const QgsRenderContext &context ) const;
691
698 void setDataDefinedProperties( const QgsPropertyCollection &collection );
699
704 void updateDataDefinedProperties( QgsRenderContext &context );
705
715 static QPixmap textFormatPreviewPixmap( const QgsTextFormat &format, QSize size, const QString &previewText = QString(), int padding = 0, const QgsScreenProperties &screen = QgsScreenProperties() );
716
726 QString asCSS( double pointToPixelMultiplier = 1.0 ) const;
727
728 private:
729
730 QgsTextBufferSettings mBufferSettings;
731 QgsTextBackgroundSettings mBackgroundSettings;
732 QgsTextShadowSettings mShadowSettings;
733 QgsTextMaskSettings mMaskSettings;
734
735 QString mTextFontFamily;
736 bool mTextFontFound = true;
737
738 QSharedDataPointer<QgsTextSettingsPrivate> d;
739
740};
741
743
744#endif // QGSTEXTFORMAT_H
Capitalization
String capitalization options.
Definition qgis.h:3132
TextOrientation
Text orientations.
Definition qgis.h:2684
RenderUnit
Rendering size units.
Definition qgis.h:4839
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.
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.
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)