QGIS API Documentation 3.43.0-Master (3ee7834ace6)
qgslegendstyle.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslegendstyle.h
3 -------------------
4 begin : March 2013
5 copyright : (C) 2013 by Radim Blazek
6 email : radim.blazek@gmail.com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSLEGENDSTYLE_H
19#define QGSLEGENDSTYLE_H
20
21#include <QFont>
22#include <QMap>
23#include <QString>
24#include <QDomElement>
25#include <QDomDocument>
26
27#include "qgis_core.h"
28#include "qgis_sip.h"
29#include "qgstextformat.h"
30#include "qgsreadwritecontext.h"
31
36class CORE_EXPORT QgsLegendStyle
37{
38 public:
39
40 // TODO QGIS 4.0 - use Qt enum instead
41
43 enum Side
44 {
45 Top = 0,
46 Bottom = 1,
47 Left = 2,
48 Right = 3,
49 };
50
52
58 Q_DECL_DEPRECATED QFont font() const SIP_DEPRECATED { return mTextFormat.font(); }
59
65 Q_DECL_DEPRECATED void setFont( const QFont &font ) SIP_DEPRECATED;
66
72 QgsTextFormat &textFormat() { return mTextFormat; }
73
79 QgsTextFormat textFormat() const SIP_SKIP { return mTextFormat; }
80
86 void setTextFormat( const QgsTextFormat &format ) { mTextFormat = format; }
87
95 double margin( Side side ) const { return mMarginMap.value( side ); }
96
104 void setMargin( Side side, double margin ) { mMarginMap[side] = margin; }
105
110 void setMargin( double margin );
111
118 Qt::Alignment alignment() const { return mAlignment; }
119
126 void setAlignment( Qt::Alignment alignment ) { mAlignment = alignment; }
127
134 double indent() const { return mIndent; }
135
142 void setIndent( double indent ) { mIndent = indent; }
143
148 void writeXml( const QString &name, QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
149
154 void readXml( const QDomElement &elem, const QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() );
155
162 void updateDataDefinedProperties( QgsRenderContext &context );
163
172 static QString styleName( Qgis::LegendComponent s );
173
178 static Qgis::LegendComponent styleFromName( const QString &styleName );
179
184 static QString styleLabel( Qgis::LegendComponent s );
185
186 private:
187 QgsTextFormat mTextFormat;
188 QMap<Side, double> mMarginMap;
189 Qt::Alignment mAlignment = Qt::AlignLeft;
190 double mIndent = 0;
191};
192
193#endif
LegendComponent
Component of legends which can be styled.
Definition qgis.h:4401
Contains detailed styling information relating to how a layout legend should be rendered.
Q_DECL_DEPRECATED QFont font() const
Returns the font used for rendering this legend component.
void setIndent(double indent)
Sets the indent (in mm) of a group or subgroup.
Qt::Alignment alignment() const
Returns the alignment for the legend component.
void setAlignment(Qt::Alignment alignment)
Sets the alignment for the legend component.
QgsTextFormat & textFormat()
Returns the text format used for rendering this legend component.
void setMargin(Side side, double margin)
Sets the margin (in mm) for the specified side of the component.
Side
Margin sides.
QgsTextFormat textFormat() const
Returns the text format used for rendering this legend component.
double margin(Side side) const
Returns the margin (in mm) for the specified side of the component.
double indent() const
Returns the indent (in mm) of a group or subgroup.
void setTextFormat(const QgsTextFormat &format)
Sets the text format used for rendering this legend component.
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 all settings relating to text rendering.
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_SKIP
Definition qgis_sip.h:126