QGIS API Documentation 3.39.0-Master (d85f3c2a281)
Loading...
Searching...
No Matches
qgstextblockformat.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgstextblockformat.cpp
3 -----------------
4 begin : September 2024
5 copyright : (C) Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#include "qgstextblockformat.h"
17#include "qgsrendercontext.h"
18
19#include <QTextBlockFormat>
20
21
22Qgis::TextHorizontalAlignment convertTextBlockFormatAlign( const QTextBlockFormat &format, bool &set )
23{
24 set = format.hasProperty( QTextFormat::BlockAlignment );
25 if ( format.alignment() & Qt::AlignLeft )
26 {
28 }
29 else if ( format.alignment() & Qt::AlignRight )
30 {
32 }
33 else if ( format.alignment() & Qt::AlignHCenter )
34 {
36 }
37 else if ( format.alignment() & Qt::AlignJustify )
38 {
40 }
41
42 set = false;
44}
45
46QgsTextBlockFormat::QgsTextBlockFormat( const QTextBlockFormat &format )
47{
48 mHorizontalAlign = convertTextBlockFormatAlign( format, mHasHorizontalAlignSet );
49}
50
52{
53 if ( mHasHorizontalAlignSet && other.hasHorizontalAlignmentSet() )
54 {
55 mHorizontalAlign = other.mHorizontalAlign;
56 mHasHorizontalAlignSet = true;
57 }
58}
59
60void QgsTextBlockFormat::updateFontForFormat( QFont &, const QgsRenderContext &, const double ) const
61{
62
63}
TextHorizontalAlignment
Text horizontal alignment.
Definition qgis.h:2730
Contains information about the context of a rendering operation.
Stores information relating to individual block formatting.
void overrideWith(const QgsTextBlockFormat &other)
Override all the default/unset properties of the current block format with the settings from another ...
void updateFontForFormat(QFont &font, const QgsRenderContext &context, double scaleFactor=1.0) const
Updates the specified font in place, applying block formatting options which are applicable on a font...
bool hasHorizontalAlignmentSet() const
Returns true if the format has an explicit horizontal alignment set.
QgsTextBlockFormat()=default
Qgis::TextHorizontalAlignment convertTextBlockFormatAlign(const QTextBlockFormat &format, bool &set)