QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
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 "qgis_core.h"
21#include "qgis_sip.h"
22#include "qgslayoutitem.h"
24
25#include <QPageLayout>
26
28#ifndef SIP_RUN
29
37class CORE_EXPORT QgsLayoutItemPageGrid: public QGraphicsRectItem
38{
39 public:
40 QgsLayoutItemPageGrid( double x, double y, double width, double height, QgsLayout *layout );
41
42 void paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget ) override;
43
44 private:
45 QgsLayout *mLayout = nullptr;
46};
47#endif
49
55class CORE_EXPORT QgsLayoutItemPage : public QgsLayoutItem
56{
57
58 Q_OBJECT
59
60 public:
61
68
71 {
73 };
74
78 explicit QgsLayoutItemPage( QgsLayout *layout );
80
87
88 int type() const override;
89 QString displayName() const override;
90
95 void setPageSize( const QgsLayoutSize &size );
96
106 bool setPageSize( const QString &size, Orientation orientation = Portrait );
107
112 QPageLayout pageLayout() const;
113
118 QgsLayoutSize pageSize() const;
119
124 Orientation orientation() const;
125
136
144 const QgsFillSymbol *pageStyleSymbol() const { return mPageStyleSymbol.get(); }
145
151 static QgsLayoutItemPage::Orientation decodePageOrientation( const QString &string, bool *ok SIP_OUT = nullptr );
152
153 QRectF boundingRect() const override;
154 void attemptResize( const QgsLayoutSize &size, bool includesFrame = false ) override;
155 QgsAbstractLayoutUndoCommand *createCommand( const QString &text, int id, QUndoCommand *parent = nullptr ) override SIP_FACTORY;
156 ExportLayerBehavior exportLayerBehavior() const override;
157 bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
158
159 public slots:
160
161 void redraw() override;
162
163 protected:
164
165 void draw( QgsLayoutItemRenderContext &context ) override;
166 void drawFrame( QgsRenderContext &context ) override;
167 void drawBackground( QgsRenderContext &context ) override;
168 bool writePropertiesToElement( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const override;
169 bool readPropertiesFromElement( const QDomElement &itemElement, const QDomDocument &document, const QgsReadWriteContext &context ) override;
170
171 private:
172
173 double mMaximumShadowWidth = -1;
174
175 std::unique_ptr< QgsLayoutItemPageGrid > mGrid;
176 mutable QRectF mBoundingRect;
177
179 std::unique_ptr< QgsFillSymbol > mPageStyleSymbol;
180
181 void createDefaultPageStyleSymbol();
182
183 friend class TestQgsLayoutPage;
184};
185
186#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.
Item representing the paper in a layout.
friend class TestQgsLayoutPage
~QgsLayoutItemPage() override
void setPageSize(const QgsLayoutSize &size)
Sets the size of the page.
int type() const override
QgsLayoutSize pageSize() const
Returns the size of the page.
const QgsFillSymbol * pageStyleSymbol() const
Returns the symbol to use for drawing the page background.
Orientation orientation() const
Returns the page orientation.
QString displayName() const override
Gets item display name.
static QgsLayoutItemPage * create(QgsLayout *layout)
Returns a new page item for the specified layout.
QgsLayoutItemPage(QgsLayout *layout)
Constructor for QgsLayoutItemPage, with the specified parent layout.
void setPageStyleSymbol(QgsFillSymbol *symbol)
Sets the symbol to use for drawing the page background.
Orientation
Page orientation.
@ Landscape
Landscape orientation.
@ Portrait
Portrait orientation.
QPageLayout pageLayout() const
Returns the page layout for the page, suitable to pass to QPrinter::setPageLayout.
UndoCommand
Page item undo commands, used for collapsing undo commands.
@ UndoPageSymbol
Layout page symbol change.
Contains settings and helpers relating to a render of a QgsLayoutItem.
friend class QgsLayout
QgsLayoutItem(QgsLayout *layout, bool manageZValue=true)
Constructor for QgsLayoutItem, with the specified parent layout.
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.
An interface for classes which can visit style entity (e.g.
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_OUT
Definition qgis_sip.h:58
#define SIP_FACTORY
Definition qgis_sip.h:84