1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QTEXTOPTION_H
|
---|
43 | #define QTEXTOPTION_H
|
---|
44 |
|
---|
45 | #include <QtCore/qnamespace.h>
|
---|
46 | #include <QtCore/qchar.h>
|
---|
47 | #include <QtCore/qmetatype.h>
|
---|
48 |
|
---|
49 |
|
---|
50 | QT_BEGIN_HEADER
|
---|
51 |
|
---|
52 | QT_BEGIN_NAMESPACE
|
---|
53 |
|
---|
54 | QT_MODULE(Gui)
|
---|
55 |
|
---|
56 | template <typename T> class QList;
|
---|
57 | struct QTextOptionPrivate;
|
---|
58 |
|
---|
59 | class Q_GUI_EXPORT QTextOption
|
---|
60 | {
|
---|
61 | public:
|
---|
62 | enum TabType {
|
---|
63 | LeftTab,
|
---|
64 | RightTab,
|
---|
65 | CenterTab,
|
---|
66 | DelimiterTab
|
---|
67 | };
|
---|
68 |
|
---|
69 | struct Q_GUI_EXPORT Tab {
|
---|
70 | inline Tab() : position(80), type(QTextOption::LeftTab) { }
|
---|
71 |
|
---|
72 | inline bool operator==(const Tab &other) const {
|
---|
73 | return type == other.type
|
---|
74 | && qFuzzyCompare(position, other.position)
|
---|
75 | && delimiter == other.delimiter;
|
---|
76 | }
|
---|
77 |
|
---|
78 | inline bool operator!=(const Tab &other) const {
|
---|
79 | return !operator==(other);
|
---|
80 | }
|
---|
81 |
|
---|
82 | qreal position;
|
---|
83 | TabType type;
|
---|
84 | QChar delimiter;
|
---|
85 | };
|
---|
86 |
|
---|
87 | QTextOption();
|
---|
88 | QTextOption(Qt::Alignment alignment);
|
---|
89 | ~QTextOption();
|
---|
90 |
|
---|
91 | QTextOption(const QTextOption &o);
|
---|
92 | QTextOption &operator=(const QTextOption &o);
|
---|
93 |
|
---|
94 | inline void setAlignment(Qt::Alignment alignment);
|
---|
95 | inline Qt::Alignment alignment() const { return Qt::Alignment(align); }
|
---|
96 |
|
---|
97 | inline void setTextDirection(Qt::LayoutDirection aDirection) { this->direction = aDirection; }
|
---|
98 | inline Qt::LayoutDirection textDirection() const { return Qt::LayoutDirection(direction); }
|
---|
99 |
|
---|
100 | enum WrapMode {
|
---|
101 | NoWrap,
|
---|
102 | WordWrap,
|
---|
103 | ManualWrap,
|
---|
104 | WrapAnywhere,
|
---|
105 | WrapAtWordBoundaryOrAnywhere
|
---|
106 | };
|
---|
107 | inline void setWrapMode(WrapMode wrap) { wordWrap = wrap; }
|
---|
108 | inline WrapMode wrapMode() const { return static_cast<WrapMode>(wordWrap); }
|
---|
109 |
|
---|
110 | enum Flag {
|
---|
111 | ShowTabsAndSpaces = 0x1,
|
---|
112 | ShowLineAndParagraphSeparators = 0x2,
|
---|
113 | AddSpaceForLineAndParagraphSeparators = 0x4,
|
---|
114 | SuppressColors = 0x8,
|
---|
115 | IncludeTrailingSpaces = 0x80000000
|
---|
116 | };
|
---|
117 | Q_DECLARE_FLAGS(Flags, Flag)
|
---|
118 | inline void setFlags(Flags flags);
|
---|
119 | inline Flags flags() const { return Flags(f); }
|
---|
120 |
|
---|
121 | inline void setTabStop(qreal tabStop);
|
---|
122 | inline qreal tabStop() const { return tab; }
|
---|
123 |
|
---|
124 | void setTabArray(QList<qreal> tabStops);
|
---|
125 | QList<qreal> tabArray() const;
|
---|
126 |
|
---|
127 | void setTabs(QList<Tab> tabStops);
|
---|
128 | QList<Tab> tabs() const;
|
---|
129 |
|
---|
130 | void setUseDesignMetrics(bool b) { design = b; }
|
---|
131 | bool useDesignMetrics() const { return design; }
|
---|
132 |
|
---|
133 | private:
|
---|
134 | uint align : 8;
|
---|
135 | uint wordWrap : 4;
|
---|
136 | uint design : 1;
|
---|
137 | uint direction : 1;
|
---|
138 | uint unused : 19;
|
---|
139 | uint f;
|
---|
140 | qreal tab;
|
---|
141 | QTextOptionPrivate *d;
|
---|
142 | };
|
---|
143 |
|
---|
144 | Q_DECLARE_OPERATORS_FOR_FLAGS(QTextOption::Flags)
|
---|
145 |
|
---|
146 | inline void QTextOption::setAlignment(Qt::Alignment aalignment)
|
---|
147 | { align = aalignment; }
|
---|
148 |
|
---|
149 | inline void QTextOption::setFlags(Flags aflags)
|
---|
150 | { f = aflags; }
|
---|
151 |
|
---|
152 | inline void QTextOption::setTabStop(qreal atabStop)
|
---|
153 | { tab = atabStop; }
|
---|
154 |
|
---|
155 | QT_END_NAMESPACE
|
---|
156 |
|
---|
157 | Q_DECLARE_METATYPE( QTextOption::Tab )
|
---|
158 |
|
---|
159 | QT_END_HEADER
|
---|
160 |
|
---|
161 | #endif // QTEXTOPTION_H
|
---|