QGIS API Documentation  2.13.0-Master
qgscomposerlegendstyle.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposerlegendstyle.h
3  -------------------
4  begin : March 2013
5  copyright : (C) 2013 by Radim Blazek
6  email : [email protected]
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 QGSCOMPOSERLEGENDSTYLE_H
19 #define QGSCOMPOSERLEGENDSTYLE_H
20 
21 #include <QFont>
22 #include <QMap>
23 #include <QString>
24 #include <QDomElement>
25 #include <QDomDocument>
26 
30 class CORE_EXPORT QgsComposerLegendStyle
31 {
32  public:
33  enum Style
34  {
35  Undefined, // should not happen, only if corrupted project file
36  Hidden, // special style, item is hidden includeing margins around
39  Subgroup, // layer
40  Symbol, // symbol without label
41  SymbolLabel
42  };
43  enum Side // margin side
44  {
45  Top = 0,
46  Bottom = 1,
47  Left = 2,
48  Right = 3
49  };
51 
52  QFont font() const { return mFont; }
53  QFont & rfont() { return mFont; }
54  void setFont( const QFont & font ) { mFont = font; }
55 
56  double margin( Side side ) { return mMarginMap.value( side ); }
57  void setMargin( Side side, double margin ) { mMarginMap[side] = margin; }
58 
59  // set all margins
60  void setMargin( double margin );
61 
62  void writeXML( const QString& name, QDomElement& elem, QDomDocument & doc ) const;
63 
64  void readXML( const QDomElement& elem, const QDomDocument& doc );
65 
67  static QString styleName( Style s );
68 
70  static Style styleFromName( const QString& styleName );
71 
73  static QString styleLabel( Style s );
74 
75  private:
76  QFont mFont;
77  // Space around element
78  QMap<Side, double> mMarginMap;
79 };
80 
81 #endif
void setMargin(Side side, double margin)
Composer legend components style.
void setFont(const QFont &font)