QGIS API Documentation 3.39.0-Master (d0dedde5474)
Loading...
Searching...
No Matches
qgsannotationrectangletextitem.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsannotationrectangletextitem.h
3 ----------------
4 begin : July 2024
5 copyright : (C) 2024 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSANNOTATIONRECTANGLETEXTITEM_H
19#define QGSANNOTATIONRECTANGLETEXTITEM_H
20
21#include "qgis_core.h"
22#include "qgis_sip.h"
24#include "qgstextformat.h"
25#include "qgsmargins.h"
26
34{
35 public:
36
41 QgsAnnotationRectangleTextItem( const QString &text, const QgsRectangle &bounds );
43
44 QString type() const override;
45 Qgis::AnnotationItemFlags flags() const override;
46 bool writeXml( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
47
52
53 bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) override;
54 QgsAnnotationRectangleTextItem *clone() const override SIP_FACTORY;
55
61 QString text() const { return mText; }
62
68 void setText( const QString &text ) { mText = text; }
69
75 QgsTextFormat format() const;
76
82 void setFormat( const QgsTextFormat &format );
83
89 Qt::Alignment alignment() const;
90
96 void setAlignment( Qt::Alignment alignment );
97
106 const QgsMargins &margins() const { return mMargins; }
107
116 void setMargins( const QgsMargins &margins ) { mMargins = margins; }
117
124 void setMarginsUnit( Qgis::RenderUnit unit ) { mMarginUnit = unit; }
125
132 Qgis::RenderUnit marginsUnit() const { return mMarginUnit; }
133
134 protected:
135
136 void renderInBounds( QgsRenderContext &context, const QRectF &painterBounds, QgsFeedback *feedback ) override;
137
138 private:
139
140 QString mText;
141 QgsTextFormat mTextFormat;
142 Qt::Alignment mAlignment = Qt::AlignLeft;
143
144 QgsMargins mMargins;
146
147#ifdef SIP_RUN
149#endif
150
151};
152#endif // QGSANNOTATIONRECTANGLETEXTITEM_H
QFlags< AnnotationItemFlag > AnnotationItemFlags
Annotation item flags.
Definition qgis.h:2281
RenderUnit
Rendering size units.
Definition qgis.h:4734
@ Millimeters
Millimeters.
virtual bool writeXml(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const =0
Writes the item's state into an XML element.
virtual QString type() const =0
Returns a unique (untranslated) string identifying the type of item.
Abstract base class for annotation items which render annotations in a rectangular shape.
virtual void renderInBounds(QgsRenderContext &context, const QRectF &painterRect, QgsFeedback *feedback)=0
Renders the item to the specified render context.
Qgis::AnnotationItemFlags flags() const override
Returns item flags.
An annotation item which renders paragraphs of text within a rectangle.
void setMarginsUnit(Qgis::RenderUnit unit)
Sets the unit for the margins between the item's frame and the interior text.
void setMargins(const QgsMargins &margins)
Sets the margins between the outside of the item's frame and the interior text.
const QgsMargins & margins() const
Returns the margins between the outside of the item's frame and the interior text.
void setText(const QString &text)
Sets the text rendered by the item.
~QgsAnnotationRectangleTextItem() override
Qgis::RenderUnit marginsUnit() const
Returns the units for the margins between the item's frame and the interior text.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
The QgsMargins class defines the four margins of a rectangle.
Definition qgsmargins.h:37
The class is used as a container of context for various read/write operations on other objects.
A rectangle specified with double values.
Contains information about the context of a rendering operation.
Container for all settings relating to text rendering.
#define SIP_FACTORY
Definition qgis_sip.h:76