QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
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
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 "qgis_core.h"
22#include "qgis_sip.h"
23#include "qgsreadwritecontext.h"
24#include "qgstextformat.h"
25
26#include <QDomDocument>
27#include <QDomElement>
28#include <QFont>
29#include <QMap>
30#include <QString>
31
36class CORE_EXPORT QgsLegendStyle
37{
38 public:
39 // TODO QGIS 5.0 - use Qt enum instead
40
42 enum Side
43 {
44 Top = 0,
45 Bottom = 1,
46 Left = 2,
47 Right = 3,
48 };
49
51
57 Q_DECL_DEPRECATED QFont font() const SIP_DEPRECATED { return mTextFormat.font(); }
58
64 Q_DECL_DEPRECATED void setFont( const QFont &font ) SIP_DEPRECATED;
65
71 QgsTextFormat &textFormat() { return mTextFormat; }
72
78 QgsTextFormat textFormat() const SIP_SKIP { return mTextFormat; }
79
85 void setTextFormat( const QgsTextFormat &format ) { mTextFormat = format; }
86
94 double margin( Side side ) const { return mMarginMap.value( side ); }
95
103 void setMargin( Side side, double margin ) { mMarginMap[side] = margin; }
104
109 void setMargin( double margin );
110
117 Qt::Alignment alignment() const { return mAlignment; }
118
125 void setAlignment( Qt::Alignment alignment ) { mAlignment = alignment; }
126
133 double indent() const { return mIndent; }
134
141 void setIndent( double indent ) { mIndent = indent; }
142
147 void writeXml( const QString &name, QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
148
153 void readXml( const QDomElement &elem, const QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() );
154
161 void updateDataDefinedProperties( QgsRenderContext &context );
162
171 static QString styleName( Qgis::LegendComponent s );
172
177 static Qgis::LegendComponent styleFromName( const QString &styleName );
178
183 static QString styleLabel( Qgis::LegendComponent s );
184
185 private:
186 QgsTextFormat mTextFormat;
187 QMap<Side, double> mMarginMap;
188 Qt::Alignment mAlignment = Qt::AlignLeft;
189 double mIndent = 0;
190};
191
192#endif
LegendComponent
Component of legends which can be styled.
Definition qgis.h:4719
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.
@ Right
Right side.
@ Left
Left side.
@ Bottom
Bottom side.
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.
A container for the context for various read/write operations on 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:113
#define SIP_SKIP
Definition qgis_sip.h:133