QGIS API Documentation  3.6.0-Noosa (5873452)
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 
92  void setPageSize( const QgsLayoutSize &size );
93 
103  bool setPageSize( const QString &size, Orientation orientation = Portrait );
104 
109  QgsLayoutSize pageSize() const;
110 
115  Orientation orientation() const;
116 
122  static QgsLayoutItemPage::Orientation decodePageOrientation( const QString &string, bool *ok SIP_OUT = nullptr );
123 
124  QRectF boundingRect() const override;
125  void attemptResize( const QgsLayoutSize &size, bool includesFrame = false ) override;
126  QgsAbstractLayoutUndoCommand *createCommand( const QString &text, int id, QUndoCommand *parent = nullptr ) override SIP_FACTORY;
127 
128  public slots:
129 
130  void redraw() override;
131 
132  protected:
133 
134  void draw( QgsLayoutItemRenderContext &context ) override;
135  void drawFrame( QgsRenderContext &context ) override;
136  void drawBackground( QgsRenderContext &context ) override;
137 
138  private:
139 
140  double mMaximumShadowWidth = -1;
141 
142  std::unique_ptr< QgsLayoutItemPageGrid > mGrid;
143  mutable QRectF mBoundingRect;
144 
145  friend class TestQgsLayoutPage;
146 };
147 
148 #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:69
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
Contains information about the context of a rendering operation.
#define SIP_OUT
Definition: qgis_sip.h:51
Orientation
Page orientiation.
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.