/work/prefix/include/QtGui/qtextoption.h
Line | Count | Source |
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 | | |
13 | | QT_BEGIN_NAMESPACE |
14 | | |
15 | | struct QTextOptionPrivate; |
16 | | |
17 | | class Q_GUI_EXPORT QTextOption |
18 | | { |
19 | | public: |
20 | | enum TabType { |
21 | | LeftTab, |
22 | | RightTab, |
23 | | CenterTab, |
24 | | DelimiterTab |
25 | | }; |
26 | | |
27 | | struct Q_GUI_EXPORT Tab { |
28 | 0 | inline Tab() : position(80), type(QTextOption::LeftTab) { } |
29 | | inline Tab(qreal pos, TabType tabType, QChar delim = QChar()) |
30 | 0 | : position(pos), type(tabType), delimiter(delim) {} |
31 | | |
32 | 0 | inline bool operator==(const Tab &other) const { |
33 | 0 | return type == other.type |
34 | 0 | && qFuzzyCompare(position, other.position) |
35 | 0 | && delimiter == other.delimiter; |
36 | 0 | } |
37 | | |
38 | 0 | inline bool operator!=(const Tab &other) const { |
39 | 0 | return !operator==(other); |
40 | 0 | } |
41 | | |
42 | | qreal position; |
43 | | TabType type; |
44 | | QChar delimiter; |
45 | | }; |
46 | | |
47 | | QTextOption(); |
48 | | Q_IMPLICIT QTextOption(Qt::Alignment alignment); |
49 | | ~QTextOption(); |
50 | | |
51 | | QTextOption(const QTextOption &o); |
52 | | QTextOption &operator=(const QTextOption &o); |
53 | | |
54 | | inline void setAlignment(Qt::Alignment alignment); |
55 | 0 | inline Qt::Alignment alignment() const { return Qt::Alignment(align); } |
56 | | |
57 | 0 | inline void setTextDirection(Qt::LayoutDirection aDirection) { this->direction = aDirection; } |
58 | 0 | inline Qt::LayoutDirection textDirection() const { return Qt::LayoutDirection(direction); } |
59 | | |
60 | | enum WrapMode { |
61 | | NoWrap, |
62 | | WordWrap, |
63 | | ManualWrap, |
64 | | WrapAnywhere, |
65 | | WrapAtWordBoundaryOrAnywhere, |
66 | | }; |
67 | 0 | inline void setWrapMode(WrapMode wrap) { wordWrap = wrap; } |
68 | 0 | 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 | | ShowDefaultIgnorables = 0x20, |
77 | | DisableEmojiParsing = 0x40, |
78 | | IncludeTrailingSpaces = 0x80000000, |
79 | | }; |
80 | | Q_DECLARE_FLAGS(Flags, Flag) |
81 | | inline void setFlags(Flags flags); |
82 | 0 | inline Flags flags() const { return Flags(f); } |
83 | | |
84 | | inline void setTabStopDistance(qreal tabStopDistance); |
85 | 0 | inline qreal tabStopDistance() const { return tab; } |
86 | | |
87 | | void setTabArray(const QList<qreal> &tabStops); |
88 | | QList<qreal> tabArray() const; |
89 | | |
90 | | void setTabs(const QList<Tab> &tabStops); |
91 | | QList<Tab> tabs() const; |
92 | | |
93 | 0 | void setUseDesignMetrics(bool b) { design = b; } |
94 | 0 | bool useDesignMetrics() const { return design; } |
95 | | |
96 | | private: |
97 | | uint align : 9; |
98 | | uint wordWrap : 4; |
99 | | uint design : 1; |
100 | | uint direction : 2; |
101 | | uint unused : 16; |
102 | | uint f; |
103 | | qreal tab; |
104 | | QTextOptionPrivate *d; |
105 | | }; |
106 | | |
107 | | Q_DECLARE_OPERATORS_FOR_FLAGS(QTextOption::Flags) |
108 | | |
109 | | inline void QTextOption::setAlignment(Qt::Alignment aalignment) |
110 | 0 | { align = uint(aalignment.toInt()); } |
111 | | |
112 | | inline void QTextOption::setFlags(Flags aflags) |
113 | 0 | { f = uint(aflags.toInt()); } |
114 | | |
115 | | inline void QTextOption::setTabStopDistance(qreal atabStop) |
116 | 0 | { tab = atabStop; } |
117 | | |
118 | | QT_END_NAMESPACE |
119 | | |
120 | | QT_DECL_METATYPE_EXTERN_TAGGED(QTextOption::Tab, QTextOption_Tab, Q_GUI_EXPORT) |
121 | | |
122 | | #endif // QTEXTOPTION_H |