QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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 <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
41 enum Style
42 {
50 };
51
52 // TODO QGIS 4.0 - use Qt enum instead
53
55 enum Side
56 {
57 Top = 0,
58 Bottom = 1,
59 Left = 2,
60 Right = 3,
61 };
62
64
70 Q_DECL_DEPRECATED QFont font() const SIP_DEPRECATED { return mTextFormat.font(); }
71
77 Q_DECL_DEPRECATED void setFont( const QFont &font ) SIP_DEPRECATED;
78
84 QgsTextFormat &textFormat() { return mTextFormat; }
85
91 QgsTextFormat textFormat() const SIP_SKIP { return mTextFormat; }
92
98 void setTextFormat( const QgsTextFormat &format ) { mTextFormat = format; }
99
107 double margin( Side side ) { return mMarginMap.value( side ); }
108
116 void setMargin( Side side, double margin ) { mMarginMap[side] = margin; }
117
122 void setMargin( double margin );
123
130 Qt::Alignment alignment() const { return mAlignment; }
131
138 void setAlignment( Qt::Alignment alignment ) { mAlignment = alignment; }
139
146 double indent() const { return mIndent; }
147
154 void setIndent( double indent ) { mIndent = indent; }
155
160 void writeXml( const QString &name, QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() ) const;
161
166 void readXml( const QDomElement &elem, const QDomDocument &doc, const QgsReadWriteContext &context = QgsReadWriteContext() );
167
176 static QString styleName( Style s );
177
182 static Style styleFromName( const QString &styleName );
183
188 static QString styleLabel( Style s );
189
190 private:
191 QgsTextFormat mTextFormat;
192 QMap<Side, double> mMarginMap;
193 Qt::Alignment mAlignment = Qt::AlignLeft;
194 double mIndent = 0;
195};
196
197#endif
Contains detailed styling information relating to how a layout legend should be rendered.
double margin(Side side)
Returns the margin (in mm) for the specified side of the component.
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.
Style
Component of legends which can be styled.
@ Group
Legend group title.
@ Symbol
Symbol icon (excluding label)
@ Undefined
Should not happen, only if corrupted project file.
@ Subgroup
Legend subgroup title.
@ Title
Legend title.
@ Hidden
Special style, item is hidden including margins around.
@ SymbolLabel
Symbol label (excluding icon)
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.
Container for all settings relating to text rendering.
Definition: qgstextformat.h:41
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
#define SIP_SKIP
Definition: qgis_sip.h:126