QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgslayoutitempage.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutitempage.h
3 --------------------
4 begin : July 2017
5 copyright : (C) 2017 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#ifndef QGSLAYOUTITEMPAGE_H
18#define QGSLAYOUTITEMPAGE_H
19
20#include <QPageLayout>
21
22#include "qgis_core.h"
23#include "qgslayoutitem.h"
25#include "qgis_sip.h"
26
27
29#ifndef SIP_RUN
30
38class CORE_EXPORT QgsLayoutItemPageGrid: public QGraphicsRectItem
39{
40 public:
41 QgsLayoutItemPageGrid( double x, double y, double width, double height, QgsLayout *layout );
42
43 void paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget ) override;
44
45 private:
46 QgsLayout *mLayout = nullptr;
47};
48#endif
50
56class CORE_EXPORT QgsLayoutItemPage : public QgsLayoutItem
57{
58
59 Q_OBJECT
60
61 public:
62
65 {
67 Landscape
68 };
69
72 {
73 UndoPageSymbol = 3000,
74 };
75
79 explicit QgsLayoutItemPage( QgsLayout *layout );
81
87 static QgsLayoutItemPage *create( QgsLayout *layout ) SIP_FACTORY;
88
89 int type() const override;
90 QString displayName() const override;
91
96 void setPageSize( const QgsLayoutSize &size );
97
107 bool setPageSize( const QString &size, Orientation orientation = Portrait );
108
113 QPageLayout pageLayout() const;
114
119 QgsLayoutSize pageSize() const;
120
125 Orientation orientation() const;
126
136 void setPageStyleSymbol( QgsFillSymbol *symbol SIP_TRANSFER );
137
145 const QgsFillSymbol *pageStyleSymbol() const { return mPageStyleSymbol.get(); }
146
152 static QgsLayoutItemPage::Orientation decodePageOrientation( const QString &string, bool *ok SIP_OUT = nullptr );
153
154 QRectF boundingRect() const override;
155 void attemptResize( const QgsLayoutSize &size, bool includesFrame = false ) override;
156 QgsAbstractLayoutUndoCommand *createCommand( const QString &text, int id, QUndoCommand *parent = nullptr ) override SIP_FACTORY;
157 ExportLayerBehavior exportLayerBehavior() const override;
158 bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
159
160 public slots:
161
162 void redraw() override;
163
164 protected:
165
166 void draw( QgsLayoutItemRenderContext &context ) override;
167 void drawFrame( QgsRenderContext &context ) override;
168 void drawBackground( QgsRenderContext &context ) override;
169 bool writePropertiesToElement( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const override;
170 bool readPropertiesFromElement( const QDomElement &itemElement, const QDomDocument &document, const QgsReadWriteContext &context ) override;
171
172 private:
173
174 double mMaximumShadowWidth = -1;
175
176 std::unique_ptr< QgsLayoutItemPageGrid > mGrid;
177 mutable QRectF mBoundingRect;
178
180 std::unique_ptr< QgsFillSymbol > mPageStyleSymbol;
181
182 void createDefaultPageStyleSymbol();
183
184 friend class TestQgsLayoutPage;
185};
186
187#endif //QGSLAYOUTITEMPAGE_H
Base class for commands to undo/redo layout and layout object changes.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition: qgsfillsymbol.h:30
Item representing the paper in a layout.
~QgsLayoutItemPage() override
const QgsFillSymbol * pageStyleSymbol() const
Returns the symbol to use for drawing the page background.
Orientation
Page orientation.
@ Portrait
Portrait orientation.
Contains settings and helpers relating to a render of a QgsLayoutItem.
Definition: qgslayoutitem.h:43
Base class for graphical items within a QgsLayout.
UndoCommand
Layout item undo commands, used for collapsing undo commands.
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layo...
Definition: qgslayoutsize.h:40
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:49
The class is used as a container of context for various read/write operations on other objects.
Contains information about the context of a rendering operation.
An interface for classes which can visit style entity (e.g.
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
Definition: qgsgeos.h:73
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_OUT
Definition: qgis_sip.h:58
#define SIP_FACTORY
Definition: qgis_sip.h:76