QGIS API Documentation  2.4.0-Chugiak
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgscomposermultiframe.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposermultiframe.h
3  ------------------------------------------------------------
4  begin : July 2012
5  copyright : (C) 2012 by Marco Hugentobler
6  email : marco dot hugentobler at sourcepole dot ch
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSCOMPOSERMULTIFRAME_H
17 #define QGSCOMPOSERMULTIFRAME_H
18 
19 #include <QObject>
20 #include <QSizeF>
21 #include <QPointF>
22 
23 class QgsComposerFrame;
24 class QgsComposerItem;
25 class QgsComposition;
26 class QDomDocument;
27 class QDomElement;
28 class QRectF;
29 class QPainter;
30 
32 class CORE_EXPORT QgsComposerMultiFrame: public QObject
33 {
34  Q_OBJECT
35  public:
36 
38  {
39  UseExistingFrames = 0,
40  ExtendToNextPage, //uses the next page(s) until the content has been printed
41  RepeatOnEveryPage, //repeats the same frame on every page
42  RepeatUntilFinished //duplicates last frame to next page to fit the total size
43  };
44 
45  QgsComposerMultiFrame( QgsComposition* c, bool createUndoCommands );
46  virtual ~QgsComposerMultiFrame();
47  virtual QSizeF totalSize() const = 0;
48  virtual void render( QPainter* p, const QRectF& renderExtent ) = 0;
49 
50  virtual void addFrame( QgsComposerFrame* frame, bool recalcFrameSizes = true ) = 0;
51 
57  virtual double findNearbyPageBreak( double yPos ) { return yPos; }
58 
59  void removeFrame( int i );
60 
61  void update();
62 
63  void setResizeMode( ResizeMode mode );
64  ResizeMode resizeMode() const { return mResizeMode; }
65 
66  virtual bool writeXML( QDomElement& elem, QDomDocument & doc, bool ignoreFrames = false ) const = 0;
67  bool _writeXML( QDomElement& elem, QDomDocument& doc, bool ignoreFrames = false ) const;
68 
69  virtual bool readXML( const QDomElement& itemElem, const QDomDocument& doc, bool ignoreFrames = false ) = 0;
70  bool _readXML( const QDomElement& itemElem, const QDomDocument& doc, bool ignoreFrames = false );
71 
72  QgsComposition* composition() { return mComposition; }
73 
74  bool createUndoCommands() const { return mCreateUndoCommands; }
75  void setCreateUndoCommands( bool enabled ) { mCreateUndoCommands = enabled; }
76 
78  void deleteFrames();
79 
83  int frameCount() const { return mFrameItems.size(); }
84  QgsComposerFrame* frame( int i ) const;
85 
94  QgsComposerFrame* createNewFrame( QgsComposerFrame* currentFrame, QPointF pos, QSizeF size );
95 
96  public slots:
97 
103  void recalculateFrameSizes();
104 
105  protected:
107  QList<QgsComposerFrame*> mFrameItems;
111 
112  protected slots:
114  void handleFrameRemoval( QgsComposerItem* item );
116  void handlePageChange();
117 
118  private:
119  QgsComposerMultiFrame(); //forbidden
120 
122 
123  signals:
124  void changed();
125 };
126 
127 #endif // QGSCOMPOSERMULTIFRAME_H
virtual double findNearbyPageBreak(double yPos)
Finds the optimal position to break a frame at.
A item that forms part of a map composition.
ResizeMode resizeMode() const
void setCreateUndoCommands(bool enabled)
Abstract base class for composer entries with the ability to distribute the content to several frames...
QList< QgsComposerFrame * > mFrameItems
bool mCreateUndoCommands
True: creates QgsMultiFrameCommands on internal changes (e.g.
int frameCount() const
Return the number of frames associated with this multiframeset.
Graphics scene for map printing.
Frame for html, table, text which can be divided onto several frames.
QgsComposition * composition()
double size
Definition: qgssvgcache.cpp:77