Go to the
documentation of this file.
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef QTEXTOPTION_H
00043 #define QTEXTOPTION_H
00044
00045 #include <QtCore/qnamespace.h>
00046 #include <QtCore/qchar.h>
00047 #include <QtCore/qmetatype.h>
00048
00049
00050 QT_BEGIN_HEADER
00051
00052 QT_BEGIN_NAMESPACE
00053
00054 QT_MODULE(Gui)
00055
00056 template <typename T> class QList;
00057 struct QTextOptionPrivate;
00058
00059 class Q_GUI_EXPORT QTextOption
00060 {
00061 public:
00062 enum TabType {
00063 LeftTab,
00064 RightTab,
00065 CenterTab,
00066 DelimiterTab
00067 };
00068
00069 struct Q_GUI_EXPORT Tab {
00070 inline Tab() : position(80), type(QTextOption::LeftTab) { }
00071 inline Tab(qreal pos, TabType tabType, QChar delim = QChar())
00072 : position(pos), type(tabType), delimiter(delim) {}
00073
00074 inline bool operator==(const Tab &other) const {
00075 return type == other.type
00076 && qFuzzyCompare(position, other.position)
00077 && delimiter == other.delimiter;
00078 }
00079
00080 inline bool operator!=(const Tab &other) const {
00081 return !operator==(other);
00082 }
00083
00084 qreal position;
00085 TabType type;
00086 QChar delimiter;
00087 };
00088
00089 QTextOption();
00090 QTextOption(Qt::Alignment alignment);
00091 ~QTextOption();
00092
00093 QTextOption(const QTextOption &o);
00094 QTextOption &operator=(const QTextOption &o);
00095
00096 inline void setAlignment(Qt::Alignment alignment);
00097 inline Qt::Alignment alignment() const { return Qt::Alignment(align); }
00098
00099 inline void setTextDirection(Qt::LayoutDirection aDirection) { this->direction = aDirection; }
00100 inline Qt::LayoutDirection textDirection() const { return Qt::LayoutDirection(direction); }
00101
00102 enum WrapMode {
00103 NoWrap,
00104 WordWrap,
00105 ManualWrap,
00106 WrapAnywhere,
00107 WrapAtWordBoundaryOrAnywhere
00108 };
00109 inline void setWrapMode(WrapMode wrap) { wordWrap = wrap; }
00110 inline WrapMode wrapMode() const { return static_cast<WrapMode>(wordWrap); }
00111
00112 enum Flag {
00113 ShowTabsAndSpaces = 0x1,
00114 ShowLineAndParagraphSeparators = 0x2,
00115 AddSpaceForLineAndParagraphSeparators = 0x4,
00116 SuppressColors = 0x8,
00117 IncludeTrailingSpaces = 0x80000000
00118 };
00119 Q_DECLARE_FLAGS(Flags, Flag)
00120 inline void setFlags(Flags flags);
00121 inline Flags flags() const { return Flags(f); }
00122
00123 inline void setTabStop(qreal tabStop);
00124 inline qreal tabStop() const { return tab; }
00125
00126 void setTabArray(QList<qreal> tabStops);
00127 QList<qreal> tabArray() const;
00128
00129 void setTabs(QList<Tab> tabStops);
00130 QList<Tab> tabs() const;
00131
00132 void setUseDesignMetrics(bool b) { design = b; }
00133 bool useDesignMetrics() const { return design; }
00134
00135 private:
00136 uint align : 8;
00137 uint wordWrap : 4;
00138 uint design : 1;
00139 uint direction : 2;
00140 uint unused : 18;
00141 uint f;
00142 qreal tab;
00143 QTextOptionPrivate *d;
00144 };
00145
00146 Q_DECLARE_OPERATORS_FOR_FLAGS(QTextOption::Flags)
00147
00148 inline void QTextOption::setAlignment(Qt::Alignment aalignment)
00149 { align = aalignment; }
00150
00151 inline void QTextOption::setFlags(Flags aflags)
00152 { f = aflags; }
00153
00154 inline void QTextOption::setTabStop(qreal atabStop)
00155 { tab = atabStop; }
00156
00157 QT_END_NAMESPACE
00158
00159 Q_DECLARE_METATYPE( QTextOption::Tab )
00160
00161 QT_END_HEADER
00162
00163 #endif // QTEXTOPTION_H