File indexing completed on 2025-09-16 09:05:17
0001
0002
0003
0004 #ifndef QTEXTOPTION_H
0005 #define QTEXTOPTION_H
0006
0007 #include <QtGui/qtguiglobal.h>
0008 #include <QtCore/qnamespace.h>
0009 #include <QtCore/qchar.h>
0010 #include <QtCore/qmetatype.h>
0011
0012
0013 QT_BEGIN_NAMESPACE
0014
0015 struct QTextOptionPrivate;
0016
0017 class Q_GUI_EXPORT QTextOption
0018 {
0019 public:
0020 enum TabType {
0021 LeftTab,
0022 RightTab,
0023 CenterTab,
0024 DelimiterTab
0025 };
0026
0027 struct Q_GUI_EXPORT Tab {
0028 inline Tab() : position(80), type(QTextOption::LeftTab) { }
0029 inline Tab(qreal pos, TabType tabType, QChar delim = QChar())
0030 : position(pos), type(tabType), delimiter(delim) {}
0031
0032 inline bool operator==(const Tab &other) const {
0033 return type == other.type
0034 && qFuzzyCompare(position, other.position)
0035 && delimiter == other.delimiter;
0036 }
0037
0038 inline bool operator!=(const Tab &other) const {
0039 return !operator==(other);
0040 }
0041
0042 qreal position;
0043 TabType type;
0044 QChar delimiter;
0045 };
0046
0047 QTextOption();
0048 Q_IMPLICIT QTextOption(Qt::Alignment alignment);
0049 ~QTextOption();
0050
0051 QTextOption(const QTextOption &o);
0052 QTextOption &operator=(const QTextOption &o);
0053
0054 inline void setAlignment(Qt::Alignment alignment);
0055 inline Qt::Alignment alignment() const { return Qt::Alignment(align); }
0056
0057 inline void setTextDirection(Qt::LayoutDirection aDirection) { this->direction = aDirection; }
0058 inline Qt::LayoutDirection textDirection() const { return Qt::LayoutDirection(direction); }
0059
0060 enum WrapMode {
0061 NoWrap,
0062 WordWrap,
0063 ManualWrap,
0064 WrapAnywhere,
0065 WrapAtWordBoundaryOrAnywhere,
0066 };
0067 inline void setWrapMode(WrapMode wrap) { wordWrap = wrap; }
0068 inline WrapMode wrapMode() const { return static_cast<WrapMode>(wordWrap); }
0069
0070 enum Flag {
0071 ShowTabsAndSpaces = 0x1,
0072 ShowLineAndParagraphSeparators = 0x2,
0073 AddSpaceForLineAndParagraphSeparators = 0x4,
0074 SuppressColors = 0x8,
0075 ShowDocumentTerminator = 0x10,
0076 ShowDefaultIgnorables = 0x20,
0077 DisableEmojiParsing = 0x40,
0078 IncludeTrailingSpaces = 0x80000000,
0079 };
0080 Q_DECLARE_FLAGS(Flags, Flag)
0081 inline void setFlags(Flags flags);
0082 inline Flags flags() const { return Flags(f); }
0083
0084 inline void setTabStopDistance(qreal tabStopDistance);
0085 inline qreal tabStopDistance() const { return tab; }
0086
0087 void setTabArray(const QList<qreal> &tabStops);
0088 QList<qreal> tabArray() const;
0089
0090 void setTabs(const QList<Tab> &tabStops);
0091 QList<Tab> tabs() const;
0092
0093 void setUseDesignMetrics(bool b) { design = b; }
0094 bool useDesignMetrics() const { return design; }
0095
0096 private:
0097 uint align : 9;
0098 uint wordWrap : 4;
0099 uint design : 1;
0100 uint direction : 2;
0101 uint unused : 16;
0102 uint f;
0103 qreal tab;
0104 QTextOptionPrivate *d;
0105 };
0106
0107 Q_DECLARE_OPERATORS_FOR_FLAGS(QTextOption::Flags)
0108
0109 inline void QTextOption::setAlignment(Qt::Alignment aalignment)
0110 { align = uint(aalignment.toInt()); }
0111
0112 inline void QTextOption::setFlags(Flags aflags)
0113 { f = uint(aflags.toInt()); }
0114
0115 inline void QTextOption::setTabStopDistance(qreal atabStop)
0116 { tab = atabStop; }
0117
0118 QT_END_NAMESPACE
0119
0120 QT_DECL_METATYPE_EXTERN_TAGGED(QTextOption::Tab, QTextOption_Tab, Q_GUI_EXPORT)
0121
0122 #endif