QGIS API Documentation  3.9.0-Master (224899f119)
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 "qgslayoutitem.h"
22 #include "qgslayoutitemregistry.h"
23 #include "qgis_sip.h"
24 
25 
27 #ifndef SIP_RUN
28 
35 class CORE_EXPORT QgsLayoutItemPageGrid: public QGraphicsRectItem
36 {
37  public:
38  QgsLayoutItemPageGrid( double x, double y, double width, double height, QgsLayout *layout );
39 
40  void paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget ) override;
41 
42  private:
43  QgsLayout *mLayout = nullptr;
44 };
45 #endif
46 
54 class CORE_EXPORT QgsLayoutItemPage : public QgsLayoutItem
55 {
56 
57  Q_OBJECT
58 
59  public:
60 
63  {
65  Landscape
66  };
67 
70  {
71  UndoPageSymbol = 3000,
72  };
73 
77  explicit QgsLayoutItemPage( QgsLayout *layout );
78 
84  static QgsLayoutItemPage *create( QgsLayout *layout ) SIP_FACTORY;
85 
86  int type() const override;
87  QString displayName() const override;
88 
93  void setPageSize( const QgsLayoutSize &size );
94 
104  bool setPageSize( const QString &size, Orientation orientation = Portrait );
105 
110  QgsLayoutSize pageSize() const;
111 
116  Orientation orientation() const;
117 
123  static QgsLayoutItemPage::Orientation decodePageOrientation( const QString &string, bool *ok SIP_OUT = nullptr );
124 
125  QRectF boundingRect() const override;
126  void attemptResize( const QgsLayoutSize &size, bool includesFrame = false ) override;
127  QgsAbstractLayoutUndoCommand *createCommand( const QString &text, int id, QUndoCommand *parent = nullptr ) override SIP_FACTORY;
128  ExportLayerBehavior exportLayerBehavior() const override;
129 
130  public slots:
131 
132  void redraw() override;
133 
134  protected:
135 
136  void draw( QgsLayoutItemRenderContext &context ) override;
137  void drawFrame( QgsRenderContext &context ) override;
138  void drawBackground( QgsRenderContext &context ) override;
139 
140  private:
141 
142  double mMaximumShadowWidth = -1;
143 
144  std::unique_ptr< QgsLayoutItemPageGrid > mGrid;
145  mutable QRectF mBoundingRect;
146 
147  friend class TestQgsLayoutPage;
148 };
149 
150 #endif //QGSLAYOUTITEMPAGE_H
Portrait orientation.
Base class for graphical items within a QgsLayout.
int type() const override
Returns a unique graphics item type identifier.
Base class for commands to undo/redo layout and layout object changes.
UndoCommand
Layout item undo commands, used for collapsing undo commands.
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
Definition: qgsgeos.h:79
virtual void attemptResize(const QgsLayoutSize &size, bool includesFrame=false)
Attempts to resize the item to a specified target size.
#define SIP_FACTORY
Definition: qgis_sip.h:76
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:49
Contains settings and helpers relating to a render of a QgsLayoutItem.
Definition: qgslayoutitem.h:44
virtual QString displayName() const
Gets item display name.
Contains information about the context of a rendering operation.
ExportLayerBehavior
Behavior of item when exporting to layered outputs.
#define SIP_OUT
Definition: qgis_sip.h:58
Orientation
Page orientation.
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layo...
Definition: qgslayoutsize.h:40
QgsAbstractLayoutUndoCommand * createCommand(const QString &text, int id, QUndoCommand *parent=nullptr) override
Creates a new layout undo command with the specified text and parent.
Item representing the paper in a layout.