Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qtextoption.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QTEXTOPTION_H
5#define QTEXTOPTION_H
6
7#include <QtGui/qtguiglobal.h>
8#include <QtCore/qnamespace.h>
9#include <QtCore/qchar.h>
10#include <QtCore/qmetatype.h>
11
12
14
16
17class Q_GUI_EXPORT QTextOption
18{
19public:
20 enum TabType {
24 DelimiterTab
25 };
26
27 struct Q_GUI_EXPORT Tab {
28 inline Tab() : position(80), type(QTextOption::LeftTab) { }
29 inline Tab(qreal pos, TabType tabType, QChar delim = QChar())
30 : position(pos), type(tabType), delimiter(delim) {}
31
32 inline bool operator==(const Tab &other) const {
33 return type == other.type
34 && qFuzzyCompare(position, other.position)
35 && delimiter == other.delimiter;
36 }
37
38 inline bool operator!=(const Tab &other) const {
39 return !operator==(other);
40 }
41
45 };
46
48 Q_IMPLICIT QTextOption(Qt::Alignment alignment);
50
52 QTextOption &operator=(const QTextOption &o);
53
54 inline void setAlignment(Qt::Alignment alignment);
55 inline Qt::Alignment alignment() const { return Qt::Alignment(align); }
56
57 inline void setTextDirection(Qt::LayoutDirection aDirection) { this->direction = aDirection; }
59
60 enum WrapMode {
65 WrapAtWordBoundaryOrAnywhere
66 };
67 inline void setWrapMode(WrapMode wrap) { wordWrap = wrap; }
68 inline WrapMode wrapMode() const { return static_cast<WrapMode>(wordWrap); }
69
70 enum Flag {
71 ShowTabsAndSpaces = 0x1,
72 ShowLineAndParagraphSeparators = 0x2,
73 AddSpaceForLineAndParagraphSeparators = 0x4,
74 SuppressColors = 0x8,
75 ShowDocumentTerminator = 0x10,
76 IncludeTrailingSpaces = 0x80000000
77 };
79 inline void setFlags(Flags flags);
80 inline Flags flags() const { return Flags(f); }
81
82 inline void setTabStopDistance(qreal tabStopDistance);
83 inline qreal tabStopDistance() const { return tab; }
84
85 void setTabArray(const QList<qreal> &tabStops);
86 QList<qreal> tabArray() const;
87
88 void setTabs(const QList<Tab> &tabStops);
89 QList<Tab> tabs() const;
90
91 void setUseDesignMetrics(bool b) { design = b; }
92 bool useDesignMetrics() const { return design; }
93
94private:
95 uint align : 9;
96 uint wordWrap : 4;
97 uint design : 1;
98 uint direction : 2;
99 uint unused : 16;
100 uint f;
101 qreal tab;
103};
104
105Q_DECLARE_OPERATORS_FOR_FLAGS(QTextOption::Flags)
106
107inline void QTextOption::setAlignment(Qt::Alignment aalignment)
108{ align = uint(aalignment.toInt()); }
109
110inline void QTextOption::setFlags(Flags aflags)
111{ f = uint(aflags.toInt()); }
112
114{ tab = atabStop; }
115
117
118QT_DECL_METATYPE_EXTERN_TAGGED(QTextOption::Tab, QTextOption_Tab, Q_GUI_EXPORT)
119
120#endif // QTEXTOPTION_H
\inmodule QtCore
\reentrant
Definition qtextoption.h:18
void setFlags(Flags flags)
Sets the flags associated with the option to the given flags.
void setTextDirection(Qt::LayoutDirection aDirection)
Sets the direction of the text layout defined by the option to the given direction.
Definition qtextoption.h:57
WrapMode wrapMode() const
Returns the text wrap mode defined by the option.
Definition qtextoption.h:68
Qt::Alignment alignment() const
Returns the text alignment defined by the option.
Definition qtextoption.h:55
qreal tabStopDistance() const
Definition qtextoption.h:83
Qt::LayoutDirection textDirection() const
Returns the direction of the text layout defined by the option.
Definition qtextoption.h:58
void setWrapMode(WrapMode wrap)
Sets the option's text wrap mode to the given mode.
Definition qtextoption.h:67
void setUseDesignMetrics(bool b)
If enable is true then the layout will use design metrics; otherwise it will use the metrics of the p...
Definition qtextoption.h:91
Flags flags() const
Returns the flags associated with the option.
Definition qtextoption.h:80
bool useDesignMetrics() const
Returns true if the layout uses design rather than device metrics; otherwise returns false.
Definition qtextoption.h:92
Flag
\value IncludeTrailingSpaces When this option is set, QTextLine::naturalTextWidth() and naturalTextRe...
Definition qtextoption.h:70
WrapMode
This enum describes how text is wrapped in a document.
Definition qtextoption.h:60
void setTabStopDistance(qreal tabStopDistance)
uint alignment
direction
Combined button and popup list for selecting options.
Definition qcompare.h:63
LayoutDirection
#define Q_IMPLICIT
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
Definition qfloat16.h:333
Flags
#define QT_DECL_METATYPE_EXTERN_TAGGED(TYPE, TAG, EXPORT)
Definition qmetatype.h:1376
GLboolean GLboolean GLboolean b
GLfloat GLfloat f
GLenum type
GLbitfield flags
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1220
static QT_BEGIN_NAMESPACE QAsn1Element wrap(quint8 type, const QAsn1Element &child)
unsigned int uint
Definition qtypes.h:34
double qreal
Definition qtypes.h:187
label setAlignment(Qt::AlignLeft|Qt::AlignTop)
[0]
QSharedPointer< T > other(t)
[5]
Tab(qreal pos, TabType tabType, QChar delim=QChar())
Creates a tab with the given position, tab type, and delimiter (pos, tabType, delim).
Definition qtextoption.h:29
Tab()
\variable QTextOption::Tab::position Distance from the start of the paragraph.
Definition qtextoption.h:28
bool operator!=(const Tab &other) const
Returns true if tab other is not equal to this tab; otherwise returns false.
Definition qtextoption.h:38
bool operator==(const Tab &other) const
Returns true if tab other is equal to this tab; otherwise returns false.
Definition qtextoption.h:32