author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 06 Jul 2010 15:10:48 +0300 | |
changeset 30 | 5dc02b23752f |
parent 18 | 2f34d5167611 |
child 33 | 3e2da88830cd |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtGui module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
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 |