QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
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
39class CORE_EXPORT QgsLayoutItemPageGrid: public QGraphicsRectItem
40{
41 public:
42 QgsLayoutItemPageGrid( double x, double y, double width, double height, QgsLayout *layout );
43
44 void paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget ) override;
45
46 private:
47 QgsLayout *mLayout = nullptr;
48};
49#endif
51
58class CORE_EXPORT QgsLayoutItemPage : public QgsLayoutItem
59{
60
61 Q_OBJECT
62
63 public:
64
67 {
69 Landscape
70 };
71
74 {
75 UndoPageSymbol = 3000,
76 };
77
81 explicit QgsLayoutItemPage( QgsLayout *layout );
83
89 static QgsLayoutItemPage *create( QgsLayout *layout ) SIP_FACTORY;
90
91 int type() const override;
92 QString displayName() const override;
93
98 void setPageSize( const QgsLayoutSize &size );
99
109 bool setPageSize( const QString &size, Orientation orientation = Portrait );
110
115 QPageLayout pageLayout() const;
116
121 QgsLayoutSize pageSize() const;
122
127 Orientation orientation() const;
128
138 void setPageStyleSymbol( QgsFillSymbol *symbol SIP_TRANSFER );
139
147 const QgsFillSymbol *pageStyleSymbol() const { return mPageStyleSymbol.get(); }
148
154 static QgsLayoutItemPage::Orientation decodePageOrientation( const QString &string, bool *ok SIP_OUT = nullptr );
155
156 QRectF boundingRect() const override;
157 void attemptResize( const QgsLayoutSize &size, bool includesFrame = false ) override;
158 QgsAbstractLayoutUndoCommand *createCommand( const QString &text, int id, QUndoCommand *parent = nullptr ) override SIP_FACTORY;
159 ExportLayerBehavior exportLayerBehavior() const override;
160 bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
161
162 public slots:
163
164 void redraw() override;
165
166 protected:
167
168 void draw( QgsLayoutItemRenderContext &context ) override;
169 void drawFrame( QgsRenderContext &context ) override;
170 void drawBackground( QgsRenderContext &context ) override;
171 bool writePropertiesToElement( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const override;
172 bool readPropertiesFromElement( const QDomElement &itemElement, const QDomDocument &document, const QgsReadWriteContext &context ) override;
173
174 private:
175
176 double mMaximumShadowWidth = -1;
177
178 std::unique_ptr< QgsLayoutItemPageGrid > mGrid;
179 mutable QRectF mBoundingRect;
180
182 std::unique_ptr< QgsFillSymbol > mPageStyleSymbol;
183
184 void createDefaultPageStyleSymbol();
185
186 friend class TestQgsLayoutPage;
187};
188
189#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:44
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:41
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:50
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:74
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_OUT
Definition: qgis_sip.h:58
#define SIP_FACTORY
Definition: qgis_sip.h:76