QGIS API Documentation 4.1.0-Master (60fea48833c)
Loading...
Searching...
No Matches
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
23class QgsLayout;
25
30class CORE_EXPORT QgsLayoutFrame : public QgsLayoutItem
31{
32 Q_OBJECT
33
34 public:
40 ~QgsLayoutFrame() override;
41
46
47 int type() const override;
48 QIcon icon() const override;
49
50 //Overridden to allow multiframe to set display name
51 QString displayName() const override;
52
53 void cleanup() override;
54
60 void setContentSection( const QRectF &section ) { mSection = section; }
61
65 QgsLayoutMultiFrame *multiFrame() const;
66
67 QgsLayoutSize minimumSize() const override;
68 QgsLayoutSize fixedSize() const override;
69
75 QRectF extent() const { return mSection; }
76
82 bool hidePageIfEmpty() const { return mHidePageIfEmpty; }
83
89 void setHidePageIfEmpty( bool hidePageIfEmpty );
90
96 bool hideBackgroundIfEmpty() const { return mHideBackgroundIfEmpty; }
97
103 void setHideBackgroundIfEmpty( bool hideBackgroundIfEmpty );
104
109 bool isEmpty() const;
110
112 ExportLayerBehavior exportLayerBehavior() const override;
113
114 protected:
115 void draw( QgsLayoutItemRenderContext &context ) override;
116 void drawFrame( QgsRenderContext &context ) override;
117 void drawBackground( QgsRenderContext &context ) override;
118 bool writePropertiesToElement( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const override;
119 bool readPropertiesFromElement( const QDomElement &itemElement, const QDomDocument &document, const QgsReadWriteContext &context ) override;
120
121 private:
122 QgsLayoutFrame() = delete;
123 QgsLayoutMultiFrame *mMultiFrame = nullptr;
124 QString mMultiFrameUuid;
125 QRectF mSection;
126
128 bool mHidePageIfEmpty = false;
130 bool mHideBackgroundIfEmpty = false;
131
133};
134
135#endif // QGSLAYOUTFRAME_H
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Base class for frame items, which form a layout multiframe item.
friend class QgsLayoutMultiFrame
QgsLayoutFrame(QgsLayout *layout, QgsLayoutMultiFrame *multiFrame)
Constructor for QgsLayoutFrame, with the specified parent layout and belonging to a multiFrame.
QgsLayoutMultiFrame * multiFrame() const
Returns the parent multiframe for the frame.
void setContentSection(const QRectF &section)
Sets the visible part of the multiframe's content which is visible within this frame (relative to the...
QRectF extent() const
Returns the visible portion of the multi frame's content which is shown in this frame,...
static QgsLayoutFrame * create(QgsLayout *layout)
Creates a new QgsLayoutFrame belonging to the specified layout.
bool hideBackgroundIfEmpty() const
Returns whether the background and frame stroke should be hidden if this frame is empty.
bool hidePageIfEmpty() const
Returns whether the page should be hidden (ie, not included in layout exports) if this frame is empty...
Contains settings and helpers relating to a render of a QgsLayoutItem.
virtual void drawFrame(QgsRenderContext &context)
Draws the frame around the item.
friend class QgsLayout
virtual void cleanup()
Called just before a batch of items are deleted, allowing them to run cleanup tasks.
QgsLayoutItem(QgsLayout *layout, bool manageZValue=true)
Constructor for QgsLayoutItem, with the specified parent layout.
virtual QIcon icon() const
Returns the item's icon.
virtual bool writePropertiesToElement(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores item state within an XML DOM element.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
int type() const override
Returns a unique graphics item type identifier.
virtual void drawBackground(QgsRenderContext &context)
Draws the background for the item.
virtual QString displayName() const
Gets item display name.
virtual QgsLayoutSize minimumSize() const
Returns the minimum allowed size of the item, if applicable, or an empty size if item can be freely r...
virtual QgsLayoutSize fixedSize() const
Returns the fixed size of the item, if applicable, or an empty size if item can be freely resized.
virtual bool readPropertiesFromElement(const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context)
Sets item state from a DOM element.
virtual ExportLayerBehavior exportLayerBehavior() const
Returns the behavior of this item during exporting to layered exports (e.g.
virtual void draw(QgsLayoutItemRenderContext &context)=0
Draws the item's contents using the specified item render context.
Abstract base class for layout items with the ability to distribute the content to several frames (Qg...
const QgsLayout * layout() const
Returns the layout the object is attached to.
Provides a method of storing sizes, consisting of a width and height, for use in QGIS layouts.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition qgslayout.h:50
A container for the context for various read/write operations on objects.
Contains information about the context of a rendering operation.
#define SIP_FACTORY
Definition qgis_sip.h:83