QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  };
52 
53  QFont font() const { return mFont; }
54  QFont & rfont() { return mFont; }
55  void setFont( const QFont & font ) { mFont = font; }
56 
57  double margin( Side side ) { return mMarginMap.value( side ); }
58  void setMargin( Side side, double margin ) { mMarginMap[side] = margin; }
59 
60  // set all margins
61  void setMargin( double margin );
62 
63  void writeXML( QString name, QDomElement& elem, QDomDocument & doc ) const;
64 
65  void readXML( const QDomElement& elem, const QDomDocument& doc );
66 
68  static QString styleName( Style s );
69 
71  static Style styleFromName( QString styleName );
72 
74  static QString styleLabel( Style s );
75 
76  private:
77  QFont mFont;
78  // Space around element
79  QMap<Side, double> mMarginMap;
80 };
81 
82 #endif