QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgslayoutframe.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayoutframe.cpp
3  ------------------
4  begin : October 2017
5  copyright : (C) 2017 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
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 QGSLAYOUTFRAME_H
17 #define QGSLAYOUTFRAME_H
18 
19 #include "qgis_core.h"
20 #include "qgis_sip.h"
21 #include "qgslayoutitem.h"
22 
23 class QgsLayout;
25 
31 class CORE_EXPORT QgsLayoutFrame: public QgsLayoutItem
32 {
33  Q_OBJECT
34 
35  public:
36 
41  QgsLayoutFrame( QgsLayout *layout, QgsLayoutMultiFrame *multiFrame );
42 
46  static QgsLayoutFrame *create( QgsLayout *layout ) SIP_FACTORY;
47 
48  int type() const override;
49  QIcon icon() const override;
50 
51  //Overridden to allow multiframe to set display name
52  QString displayName() const override;
53 
54  void cleanup() override;
55 
61  void setContentSection( const QRectF &section ) { mSection = section; }
62 
66  QgsLayoutMultiFrame *multiFrame() const;
67 
68  QgsLayoutSize minimumSize() const override;
69  QgsLayoutSize fixedSize() const override;
70 
76  QRectF extent() const { return mSection; }
77 
83  bool hidePageIfEmpty() const { return mHidePageIfEmpty; }
84 
90  void setHidePageIfEmpty( bool hidePageIfEmpty );
91 
97  bool hideBackgroundIfEmpty() const { return mHideBackgroundIfEmpty; }
98 
104  void setHideBackgroundIfEmpty( bool hideBackgroundIfEmpty );
105 
110  bool isEmpty() const;
111 
113  ExportLayerBehavior exportLayerBehavior() const override;
114 
115  protected:
116 
117  void draw( QgsLayoutItemRenderContext &context ) override;
118  void drawFrame( QgsRenderContext &context ) override;
119  void drawBackground( QgsRenderContext &context ) override;
120  bool writePropertiesToElement( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const override;
121  bool readPropertiesFromElement( const QDomElement &itemElement, const QDomDocument &document, const QgsReadWriteContext &context ) override;
122 
123  private:
124  QgsLayoutFrame() = delete;
125  QgsLayoutMultiFrame *mMultiFrame = nullptr;
126  QString mMultiFrameUuid;
127  QRectF mSection;
128 
130  bool mHidePageIfEmpty = false;
132  bool mHideBackgroundIfEmpty = false;
133 
134  friend class QgsLayoutMultiFrame;
135 
136 };
137 
138 #endif // QGSLAYOUTFRAME_H
QgsLayoutItem::cleanup
virtual void cleanup()
Called just before a batch of items are deleted, allowing them to run cleanup tasks.
Definition: qgslayoutitem.cpp:99
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:370
QgsLayoutItem::writePropertiesToElement
virtual bool writePropertiesToElement(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores item state within an XML DOM element.
Definition: qgslayoutitem.cpp:1325
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:35
QgsLayoutFrame::hidePageIfEmpty
bool hidePageIfEmpty() const
Returns whether the page should be hidden (ie, not included in layout exports) if this frame is empty...
Definition: qgslayoutframe.h:83
QgsLayoutItem::icon
virtual QIcon icon() const
Returns the item's icon.
Definition: qgslayoutitem.h:334
QgsLayoutItemRenderContext
Contains settings and helpers relating to a render of a QgsLayoutItem.
Definition: qgslayoutitem.h:45
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:58
QgsLayoutItem::drawFrame
virtual void drawFrame(QgsRenderContext &context)
Draws the frame around the item.
Definition: qgslayoutitem.cpp:1220
QgsLayoutMultiFrame
Abstract base class for layout items with the ability to distribute the content to several frames (Qg...
Definition: qgslayoutmultiframe.h:49
QgsLayoutFrame::hideBackgroundIfEmpty
bool hideBackgroundIfEmpty() const
Returns whether the background and frame stroke should be hidden if this frame is empty.
Definition: qgslayoutframe.h:97
QgsLayoutItem::readPropertiesFromElement
virtual bool readPropertiesFromElement(const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context)
Sets item state from a DOM element.
Definition: qgslayoutitem.cpp:1330
QgsLayoutItem::draw
virtual void draw(QgsLayoutItemRenderContext &context)=0
Draws the item's contents using the specified item render context.
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsLayoutItem::minimumSize
virtual QgsLayoutSize minimumSize() const
Returns the minimum allowed size of the item, if applicable, or an empty size if item can be freely r...
Definition: qgslayoutitem.h:560
QgsLayoutItem::type
int type() const override
Returns a unique graphics item type identifier.
Definition: qgslayoutitem.cpp:124
QgsLayoutItem::drawBackground
virtual void drawBackground(QgsRenderContext &context)
Draws the background for the item.
Definition: qgslayoutitem.cpp:1236
QgsLayoutItem::exportLayerBehavior
virtual ExportLayerBehavior exportLayerBehavior() const
Returns the behavior of this item during exporting to layered exports (e.g.
Definition: qgslayoutitem.cpp:247
qgslayoutitem.h
QgsLayoutFrame
Base class for frame items, which form a layout multiframe item.
Definition: qgslayoutframe.h:32
QgsLayoutFrame::setContentSection
void setContentSection(const QRectF &section)
Sets the visible part of the multiframe's content which is visible within this frame (relative to the...
Definition: qgslayoutframe.h:61
QgsLayoutFrame::extent
QRectF extent() const
Returns the visible portion of the multi frame's content which is shown in this frame,...
Definition: qgslayoutframe.h:76
qgis_sip.h
QgsLayoutItem
Base class for graphical items within a QgsLayout.
Definition: qgslayoutitem.h:113
QgsLayout
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:50
QgsLayoutItem::displayName
virtual QString displayName() const
Gets item display name.
Definition: qgslayoutitem.cpp:107
QgsLayoutSize
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layo...
Definition: qgslayoutsize.h:41
QgsLayoutItem::createExpressionContext
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Definition: qgslayoutitem.cpp:1158
QgsLayoutItem::fixedSize
virtual QgsLayoutSize fixedSize() const
Returns the fixed size of the item, if applicable, or an empty size if item can be freely resized.
Definition: qgslayoutitem.h:552