Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/QtGui/qtextoption.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
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         IncludeTrailingSpaces = 0x80000000
0077     };
0078     Q_DECLARE_FLAGS(Flags, Flag)
0079     inline void setFlags(Flags flags);
0080     inline Flags flags() const { return Flags(f); }
0081 
0082     inline void setTabStopDistance(qreal tabStopDistance);
0083     inline qreal tabStopDistance() const { return tab; }
0084 
0085     void setTabArray(const QList<qreal> &tabStops);
0086     QList<qreal> tabArray() const;
0087 
0088     void setTabs(const QList<Tab> &tabStops);
0089     QList<Tab> tabs() const;
0090 
0091     void setUseDesignMetrics(bool b) { design = b; }
0092     bool useDesignMetrics() const { return design; }
0093 
0094 private:
0095     uint align : 9;
0096     uint wordWrap : 4;
0097     uint design : 1;
0098     uint direction : 2;
0099     uint unused : 16;
0100     uint f;
0101     qreal tab;
0102     QTextOptionPrivate *d;
0103 };
0104 
0105 Q_DECLARE_OPERATORS_FOR_FLAGS(QTextOption::Flags)
0106 
0107 inline void QTextOption::setAlignment(Qt::Alignment aalignment)
0108 { align = uint(aalignment.toInt()); }
0109 
0110 inline void QTextOption::setFlags(Flags aflags)
0111 { f = uint(aflags.toInt()); }
0112 
0113 inline void QTextOption::setTabStopDistance(qreal atabStop)
0114 { tab = atabStop; }
0115 
0116 QT_END_NAMESPACE
0117 
0118 QT_DECL_METATYPE_EXTERN_TAGGED(QTextOption::Tab, QTextOption_Tab, Q_GUI_EXPORT)
0119 
0120 #endif // QTEXTOPTION_H