QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgscomposerlegend.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposerlegend.h - description
3  -------------------
4  begin : June 2008
5  copyright : (C) 2008 by Marco Hugentobler
6  email : marco dot hugentobler at karto dot baug dot ethz dot ch
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 QGSCOMPOSERLEGEND_H
19 #define QGSCOMPOSERLEGEND_H
20 
21 #include "qgscomposerlegendstyle.h"
22 #include "qgscomposeritem.h"
23 #include "qgscomposerlegenditem.h"
24 #include "qgslegendmodel.h"
25 #include "qgslegendsettings.h"
26 
27 class QgsSymbolV2;
30 class QgsComposerMap;
31 class QgsLegendRenderer;
32 
33 
37 class CORE_EXPORT QgsComposerLegend : public QgsComposerItem
38 {
39  Q_OBJECT;
40 
41  public:
42  QgsComposerLegend( QgsComposition* composition );
44 
46  virtual int type() const { return ComposerLegend; }
47 
49  void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
50 
52  QSizeF paintAndDetermineSize( QPainter* painter );
53 
55  void adjustBoxSize();
56 
58  QgsLegendModel* model() {return &mLegendModel;}
59 
60  //setters and getters
61  void setTitle( const QString& t );
62  QString title() const;
63 
69  Qt::AlignmentFlag titleAlignment() const;
75  void setTitleAlignment( Qt::AlignmentFlag alignment );
76 
81  void setStyle( QgsComposerLegendStyle::Style s, const QgsComposerLegendStyle style );
82 
83  QFont styleFont( QgsComposerLegendStyle::Style s ) const;
85  void setStyleFont( QgsComposerLegendStyle::Style s, const QFont& f );
86 
88  void setStyleMargin( QgsComposerLegendStyle::Style s, double margin );
89  void setStyleMargin( QgsComposerLegendStyle::Style s, QgsComposerLegendStyle::Side side, double margin );
90 
91  double boxSpace() const;
92  void setBoxSpace( double s );
93 
94  double columnSpace() const;
95  void setColumnSpace( double s );
96 
97  QColor fontColor() const;
98  void setFontColor( const QColor& c );
99 
100  double symbolWidth() const;
101  void setSymbolWidth( double w );
102 
103  double symbolHeight() const;
104  void setSymbolHeight( double h );
105 
106  double wmsLegendWidth() const;
107  void setWmsLegendWidth( double w );
108 
109  double wmsLegendHeight() const;
110  void setWmsLegendHeight( double h );
111 
112  void setWrapChar( const QString& t );
113  QString wrapChar() const;
114 
115  int columnCount() const;
116  void setColumnCount( int c );
117 
118  int splitLayer() const;
119  void setSplitLayer( bool s );
120 
121  int equalColumnWidth() const;
122  void setEqualColumnWidth( bool s );
123 
124  void setComposerMap( const QgsComposerMap* map );
125  const QgsComposerMap* composerMap() const { return mComposerMap;}
126 
128  void updateLegend();
129 
134  bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
135 
140  bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
141 
142  //Overriden to show legend title
143  virtual QString displayName() const;
144 
145  public slots:
147  void synchronizeWithModel();
149  void invalidateCurrentMap();
150 
151  private:
152  QgsComposerLegend(); //forbidden
153 
155 
157 
159 };
160 
161 #endif
162 
virtual bool writeXML(QDomElement &elem, QDomDocument &doc) const
Stores item state in DOM element.
A model that provides group, layer and classification items.
A item that forms part of a map composition.
QgsLegendModel mLegendModel
const QgsComposerMap * mComposerMap
The QgsLegendSettings class stores the appearance and layout settings for legend drawing with QgsLege...
Graphics scene for map printing.
Object representing map window.
virtual QString displayName() const
Get item display name.
Composer legend components style.
virtual bool readXML(const QDomElement &itemElem, const QDomDocument &doc)
Sets item state from DOM element.
const QgsComposerMap * composerMap() const
QgsLegendSettings mSettings
QgsLegendModel * model()
Returns pointer to the legend model.
A legend that can be placed onto a map composition.
virtual int type() const
return correct graphics item type.
The QgsLegendRenderer class handles automatic layout and rendering of legend.