QGIS API Documentation  2.99.0-Master (7fe5405)
qgscomposerframe.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscomposerframe.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 QGSCOMPOSERFRAME_H
17 #define QGSCOMPOSERFRAME_H
18 
19 #include "qgis_core.h"
20 #include "qgscomposeritem.h"
21 
22 class QgsComposition;
24 
28 class CORE_EXPORT QgsComposerFrame: public QgsComposerItem
29 {
30  Q_OBJECT
31 
32  public:
33  QgsComposerFrame( QgsComposition* c, QgsComposerMultiFrame* mf, qreal x, qreal y, qreal width, qreal height );
34 
40  void setContentSection( const QRectF& section ) { mSection = section; }
41 
45  QgsComposerMultiFrame* multiFrame() const { return mMultiFrame; }
46 
47  //Overridden to allow multiframe to set display name
48  virtual QString displayName() const override;
49 
50  //Overridden to handle fixed frame sizes set by multi frame
51  void setSceneRect( const QRectF& rectangle ) override;
52 
53  void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget ) override;
54  void beginItemCommand( const QString& text ) override;
55  void endItemCommand() override;
56  bool writeXml( QDomElement& elem, QDomDocument & doc ) const override;
57  bool readXml( const QDomElement& itemElem, const QDomDocument& doc ) override;
58  int type() const override { return ComposerFrame; }
59 
66  QRectF extent() const { return mSection; }
67 
73  bool hidePageIfEmpty() const { return mHidePageIfEmpty; }
74 
80  void setHidePageIfEmpty( const bool hidePageIfEmpty );
81 
87  bool hideBackgroundIfEmpty() const { return mHideBackgroundIfEmpty; }
88 
94  void setHideBackgroundIfEmpty( const bool hideBackgroundIfEmpty );
95 
101  bool isEmpty() const;
102 
103  virtual QgsExpressionContext createExpressionContext() const override;
104 
105  private:
106  QgsComposerFrame(); //forbidden
107  QgsComposerMultiFrame* mMultiFrame;
108  QRectF mSection;
109 
111  bool mHidePageIfEmpty;
113  bool mHideBackgroundIfEmpty;
114 
115 };
116 
117 #endif // QGSCOMPOSERFRAME_H
virtual QString displayName() const
Get item display name.
virtual void beginItemCommand(const QString &text)
A item that forms part of a map composition.
QRectF extent() const
Returns the visible portion of the multi frame's content which is shown in this frame.
virtual bool readXml(const QDomElement &itemElem, const QDomDocument &doc)
Sets item state from DOM element.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Abstract base class for composer items with the ability to distribute the content to several frames (...
int type() const override
Return correct graphics item type.
Graphics scene for map printing.
Frame item for a composer multiframe item.
virtual QgsExpressionContext createExpressionContext() const override
Creates an expression context relating to the item's current state.
bool hidePageIfEmpty() const
Returns whether the page should be hidden (ie, not included in composer exports) if this frame is emp...
virtual void endItemCommand()
bool hideBackgroundIfEmpty() const
Returns whether the background and frame border should be hidden if this frame is empty...
QgsComposerMultiFrame * multiFrame() const
Returns the parent multiframe for the frame.
virtual void setSceneRect(const QRectF &rectangle)
Sets this items bound in scene coordinates such that 1 item size units corresponds to 1 scene size un...
void setContentSection(const QRectF &section)
Sets the visible part of the multiframe's content which is visible within this frame (relative to the...
virtual bool writeXml(QDomElement &elem, QDomDocument &doc) const
Stores item state in DOM element.