/src/qtbase/src/gui/text/qtextformat.h
Line | Count | Source |
1 | | // Copyright (C) 2021 The Qt Company Ltd. |
2 | | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | | |
4 | | #ifndef QTEXTFORMAT_H |
5 | | #define QTEXTFORMAT_H |
6 | | |
7 | | #include <QtGui/qbrush.h> |
8 | | #include <QtGui/qcolor.h> |
9 | | #include <QtGui/qfont.h> |
10 | | #include <QtGui/qpen.h> |
11 | | #include <QtGui/qtextoption.h> |
12 | | #include <QtGui/qtguiglobal.h> |
13 | | |
14 | | #include <QtCore/qlist.h> |
15 | | #include <QtCore/qshareddata.h> |
16 | | #include <QtCore/qvariant.h> |
17 | | #include <QtCore/qmap.h> |
18 | | |
19 | | QT_BEGIN_NAMESPACE |
20 | | |
21 | | |
22 | | class QString; |
23 | | class QVariant; |
24 | | class QFont; |
25 | | |
26 | | class QTextFormatCollection; |
27 | | class QTextFormatPrivate; |
28 | | class QTextBlockFormat; |
29 | | class QTextCharFormat; |
30 | | class QTextListFormat; |
31 | | class QTextTableFormat; |
32 | | class QTextFrameFormat; |
33 | | class QTextImageFormat; |
34 | | class QTextTableCellFormat; |
35 | | class QTextFormat; |
36 | | class QTextObject; |
37 | | class QTextCursor; |
38 | | class QTextDocument; |
39 | | class QTextLength; |
40 | | |
41 | | #ifndef QT_NO_DEBUG_STREAM |
42 | | Q_GUI_EXPORT QDebug operator<<(QDebug, const QTextLength &); |
43 | | #endif |
44 | | |
45 | | class Q_GUI_EXPORT QTextLength |
46 | | { |
47 | | public: |
48 | | enum Type { VariableLength = 0, FixedLength, PercentageLength }; |
49 | | |
50 | 132k | inline QTextLength() : lengthType(VariableLength), fixedValueOrPercentage(0) {} |
51 | | |
52 | | inline explicit QTextLength(Type type, qreal value); |
53 | | |
54 | 66.2k | inline Type type() const { return lengthType; } |
55 | | inline qreal value(qreal maximumLength) const |
56 | 66.2k | { |
57 | 66.2k | switch (lengthType) { |
58 | 0 | case FixedLength: return fixedValueOrPercentage; |
59 | 66.2k | case VariableLength: return maximumLength; |
60 | 0 | case PercentageLength: return fixedValueOrPercentage * maximumLength / qreal(100); |
61 | 66.2k | } |
62 | 0 | return -1; |
63 | 66.2k | } |
64 | | |
65 | 0 | inline qreal rawValue() const { return fixedValueOrPercentage; } |
66 | | |
67 | | inline bool operator==(const QTextLength &other) const |
68 | 0 | { return lengthType == other.lengthType |
69 | 0 | && qFuzzyCompare(fixedValueOrPercentage, other.fixedValueOrPercentage); } |
70 | | inline bool operator!=(const QTextLength &other) const |
71 | 0 | { return lengthType != other.lengthType |
72 | 0 | || !qFuzzyCompare(fixedValueOrPercentage, other.fixedValueOrPercentage); } |
73 | | operator QVariant() const; |
74 | | |
75 | | private: |
76 | | Type lengthType; |
77 | | qreal fixedValueOrPercentage; |
78 | | friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextLength &); |
79 | | friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextLength &); |
80 | | }; |
81 | | Q_DECLARE_TYPEINFO(QTextLength, Q_PRIMITIVE_TYPE); |
82 | | |
83 | | inline QTextLength::QTextLength(Type atype, qreal avalue) |
84 | 0 | : lengthType(atype), fixedValueOrPercentage(avalue) {} |
85 | | |
86 | | #ifndef QT_NO_DEBUG_STREAM |
87 | | Q_GUI_EXPORT QDebug operator<<(QDebug, const QTextFormat &); |
88 | | #endif |
89 | | |
90 | | class Q_GUI_EXPORT QTextFormat |
91 | | { |
92 | | Q_GADGET |
93 | | public: |
94 | | enum FormatType { |
95 | | InvalidFormat = -1, |
96 | | BlockFormat = 1, |
97 | | CharFormat = 2, |
98 | | ListFormat = 3, |
99 | | FrameFormat = 5, |
100 | | |
101 | | UserFormat = 100 |
102 | | }; |
103 | 0 | Q_ENUM(FormatType) Unexecuted instantiation: qt_getEnumMetaObject(QTextFormat::FormatType) Unexecuted instantiation: qt_getEnumName(QTextFormat::FormatType) |
104 | 0 |
|
105 | 0 | enum Property { |
106 | 0 | ObjectIndex = 0x0, |
107 | 0 |
|
108 | 0 | // paragraph and char |
109 | 0 | CssFloat = 0x0800, |
110 | 0 | LayoutDirection = 0x0801, |
111 | 0 |
|
112 | 0 | OutlinePen = 0x810, |
113 | 0 | BackgroundBrush = 0x820, |
114 | 0 | ForegroundBrush = 0x821, |
115 | 0 | // Internal to qtextlayout.cpp: ObjectSelectionBrush = 0x822 |
116 | 0 | BackgroundImageUrl = 0x823, |
117 | 0 |
|
118 | 0 | // paragraph |
119 | 0 | BlockAlignment = 0x1010, |
120 | 0 | BlockTopMargin = 0x1030, |
121 | 0 | BlockBottomMargin = 0x1031, |
122 | 0 | BlockLeftMargin = 0x1032, |
123 | 0 | BlockRightMargin = 0x1033, |
124 | 0 | TextIndent = 0x1034, |
125 | 0 | TabPositions = 0x1035, |
126 | 0 | BlockIndent = 0x1040, |
127 | 0 | LineHeight = 0x1048, |
128 | 0 | LineHeightType = 0x1049, |
129 | 0 | BlockNonBreakableLines = 0x1050, |
130 | 0 | BlockTrailingHorizontalRulerWidth = 0x1060, |
131 | 0 | HeadingLevel = 0x1070, |
132 | 0 | BlockQuoteLevel = 0x1080, |
133 | 0 | BlockCodeLanguage = 0x1090, |
134 | 0 | BlockCodeFence = 0x1091, |
135 | 0 | BlockMarker = 0x10A0, |
136 | 0 |
|
137 | 0 | // character properties |
138 | 0 | FirstFontProperty = 0x1FE0, |
139 | 0 | FontCapitalization = FirstFontProperty, |
140 | 0 | FontLetterSpacing = 0x1FE1, |
141 | 0 | FontWordSpacing = 0x1FE2, |
142 | 0 | FontStyleHint = 0x1FE3, |
143 | 0 | FontStyleStrategy = 0x1FE4, |
144 | 0 | FontKerning = 0x1FE5, |
145 | 0 | FontHintingPreference = 0x1FE6, |
146 | 0 | FontFamilies = 0x1FE7, |
147 | 0 | FontStyleName = 0x1FE8, |
148 | 0 | FontLetterSpacingType = 0x1FE9, |
149 | 0 | FontStretch = 0x1FEA, |
150 | 0 | #if QT_DEPRECATED_SINCE(6, 0) |
151 | 0 | FontFamily = 0x2000, |
152 | 0 | #endif |
153 | 0 | FontPointSize = 0x2001, |
154 | 0 | FontSizeAdjustment = 0x2002, |
155 | 0 | FontSizeIncrement = FontSizeAdjustment, // old name, compat |
156 | 0 | FontWeight = 0x2003, |
157 | 0 | FontItalic = 0x2004, |
158 | 0 | FontUnderline = 0x2005, // deprecated, use TextUnderlineStyle instead |
159 | 0 | FontOverline = 0x2006, |
160 | 0 | FontStrikeOut = 0x2007, |
161 | 0 | FontFixedPitch = 0x2008, |
162 | 0 | FontPixelSize = 0x2009, |
163 | 0 | FontFeatures = 0x2010, // Note: Same as OldTextUnderlineColor |
164 | 0 | FontVariableAxes = 0x2011, |
165 | 0 | LastFontProperty = FontVariableAxes, |
166 | 0 |
|
167 | 0 | TextUnderlineColor = 0x2020, |
168 | 0 | TextVerticalAlignment = 0x2021, |
169 | 0 | TextOutline = 0x2022, |
170 | 0 | TextUnderlineStyle = 0x2023, |
171 | 0 | TextToolTip = 0x2024, |
172 | 0 | TextSuperScriptBaseline = 0x2025, |
173 | 0 | TextSubScriptBaseline = 0x2026, |
174 | 0 | TextBaselineOffset = 0x2027, |
175 | 0 |
|
176 | 0 | IsAnchor = 0x2030, |
177 | 0 | AnchorHref = 0x2031, |
178 | 0 | AnchorName = 0x2032, |
179 | 0 |
|
180 | 0 | // Included for backwards compatibility with old QDataStreams. |
181 | 0 | // Should not be referenced in user code. |
182 | 0 | OldFontLetterSpacingType = 0x2033, |
183 | 0 | OldFontStretch = 0x2034, |
184 | 0 | OldTextUnderlineColor = 0x2010, |
185 | 0 | OldFontFamily = 0x2000, // same as FontFamily |
186 | 0 |
|
187 | 0 | ObjectType = 0x2f00, |
188 | 0 |
|
189 | 0 | // list properties |
190 | 0 | ListStyle = 0x3000, |
191 | 0 | ListIndent = 0x3001, |
192 | 0 | ListNumberPrefix = 0x3002, |
193 | 0 | ListNumberSuffix = 0x3003, |
194 | 0 | ListStart = 0x3004, |
195 | 0 |
|
196 | 0 | // table and frame properties |
197 | 0 | FrameBorder = 0x4000, |
198 | 0 | FrameMargin = 0x4001, |
199 | 0 | FramePadding = 0x4002, |
200 | 0 | FrameWidth = 0x4003, |
201 | 0 | FrameHeight = 0x4004, |
202 | 0 | FrameTopMargin = 0x4005, |
203 | 0 | FrameBottomMargin = 0x4006, |
204 | 0 | FrameLeftMargin = 0x4007, |
205 | 0 | FrameRightMargin = 0x4008, |
206 | 0 | FrameBorderBrush = 0x4009, |
207 | 0 | FrameBorderStyle = 0x4010, |
208 | 0 |
|
209 | 0 | TableColumns = 0x4100, |
210 | 0 | TableColumnWidthConstraints = 0x4101, |
211 | 0 | TableCellSpacing = 0x4102, |
212 | 0 | TableCellPadding = 0x4103, |
213 | 0 | TableHeaderRowCount = 0x4104, |
214 | 0 | TableBorderCollapse = 0x4105, |
215 | 0 |
|
216 | 0 | // table cell properties |
217 | 0 | TableCellRowSpan = 0x4810, |
218 | 0 | TableCellColumnSpan = 0x4811, |
219 | 0 |
|
220 | 0 | TableCellTopPadding = 0x4812, |
221 | 0 | TableCellBottomPadding = 0x4813, |
222 | 0 | TableCellLeftPadding = 0x4814, |
223 | 0 | TableCellRightPadding = 0x4815, |
224 | 0 |
|
225 | 0 | TableCellTopBorder = 0x4816, |
226 | 0 | TableCellBottomBorder = 0x4817, |
227 | 0 | TableCellLeftBorder = 0x4818, |
228 | 0 | TableCellRightBorder = 0x4819, |
229 | 0 |
|
230 | 0 | TableCellTopBorderStyle = 0x481a, |
231 | 0 | TableCellBottomBorderStyle = 0x481b, |
232 | 0 | TableCellLeftBorderStyle = 0x481c, |
233 | 0 | TableCellRightBorderStyle = 0x481d, |
234 | 0 |
|
235 | 0 | TableCellTopBorderBrush = 0x481e, |
236 | 0 | TableCellBottomBorderBrush = 0x481f, |
237 | 0 | TableCellLeftBorderBrush = 0x4820, |
238 | 0 | TableCellRightBorderBrush = 0x4821, |
239 | 0 |
|
240 | 0 | // image properties |
241 | 0 | ImageName = 0x5000, |
242 | 0 | ImageTitle = 0x5001, |
243 | 0 | ImageAltText = 0x5002, |
244 | 0 | ImageWidth = 0x5010, |
245 | 0 | ImageHeight = 0x5011, |
246 | 0 | ImageQuality = 0x5014, |
247 | 0 | ImageMaxWidth = 0x5015, |
248 | 0 |
|
249 | 0 | // internal |
250 | 0 | /* |
251 | 0 | SuppressText = 0x5012, |
252 | 0 | SuppressBackground = 0x513 |
253 | 0 | */ |
254 | 0 |
|
255 | 0 | // selection properties |
256 | 0 | FullWidthSelection = 0x06000, |
257 | 0 |
|
258 | 0 | // page break properties |
259 | 0 | PageBreakPolicy = 0x7000, |
260 | 0 |
|
261 | 0 | // -- |
262 | 0 | UserProperty = 0x100000 |
263 | 0 | }; |
264 | 0 | Q_ENUM(Property) Unexecuted instantiation: qt_getEnumMetaObject(QTextFormat::Property) Unexecuted instantiation: qt_getEnumName(QTextFormat::Property) |
265 | 0 |
|
266 | 0 | enum ObjectTypes { |
267 | 0 | NoObject, |
268 | 0 | ImageObject, |
269 | 0 | TableObject, |
270 | 0 | TableCellObject, |
271 | 0 |
|
272 | 0 | UserObject = 0x1000 |
273 | 0 | }; |
274 | 0 | Q_ENUM(ObjectTypes) Unexecuted instantiation: qt_getEnumMetaObject(QTextFormat::ObjectTypes) Unexecuted instantiation: qt_getEnumName(QTextFormat::ObjectTypes) |
275 | 0 |
|
276 | 0 | enum PageBreakFlag { |
277 | 0 | PageBreak_Auto = 0, |
278 | 0 | PageBreak_AlwaysBefore = 0x001, |
279 | 0 | PageBreak_AlwaysAfter = 0x010 |
280 | 0 | // PageBreak_AlwaysInside = 0x100 |
281 | 0 | }; |
282 | 0 | Q_DECLARE_FLAGS(PageBreakFlags, PageBreakFlag) |
283 | 0 |
|
284 | 0 | QTextFormat(); |
285 | 0 |
|
286 | 0 | explicit QTextFormat(int type); |
287 | 0 |
|
288 | 0 | QTextFormat(const QTextFormat &rhs); |
289 | 0 | QTextFormat &operator=(const QTextFormat &rhs); |
290 | 0 | ~QTextFormat(); |
291 | 0 |
|
292 | 0 | void swap(QTextFormat &other) |
293 | 0 | { d.swap(other.d); std::swap(format_type, other.format_type); } |
294 | | |
295 | | void merge(const QTextFormat &other); |
296 | | |
297 | 0 | inline bool isValid() const { return type() != InvalidFormat; } |
298 | 0 | inline bool isEmpty() const { return propertyCount() == 0; } |
299 | | |
300 | | int type() const; |
301 | | |
302 | | int objectIndex() const; |
303 | | void setObjectIndex(int object); |
304 | | |
305 | | QVariant property(int propertyId) const; |
306 | | void setProperty(int propertyId, const QVariant &value); |
307 | | void clearProperty(int propertyId); |
308 | | bool hasProperty(int propertyId) const; |
309 | | |
310 | | bool boolProperty(int propertyId) const; |
311 | | int intProperty(int propertyId) const; |
312 | | qreal doubleProperty(int propertyId) const; |
313 | | QString stringProperty(int propertyId) const; |
314 | | QColor colorProperty(int propertyId) const; |
315 | | QPen penProperty(int propertyId) const; |
316 | | QBrush brushProperty(int propertyId) const; |
317 | | QTextLength lengthProperty(int propertyId) const; |
318 | | QList<QTextLength> lengthVectorProperty(int propertyId) const; |
319 | | |
320 | | void setProperty(int propertyId, const QList<QTextLength> &lengths); |
321 | | |
322 | | QMap<int, QVariant> properties() const; |
323 | | int propertyCount() const; |
324 | | |
325 | | inline void setObjectType(int type); |
326 | | inline int objectType() const |
327 | 26.0k | { return intProperty(ObjectType); } |
328 | | |
329 | 618k | inline bool isCharFormat() const { return type() == CharFormat; } |
330 | 875k | inline bool isBlockFormat() const { return type() == BlockFormat; } |
331 | 16.5k | inline bool isListFormat() const { return type() == ListFormat; } |
332 | 16.5k | inline bool isFrameFormat() const { return type() == FrameFormat; } |
333 | 0 | inline bool isImageFormat() const { return type() == CharFormat && objectType() == ImageObject; } |
334 | 16.5k | inline bool isTableFormat() const { return type() == FrameFormat && objectType() == TableObject; } |
335 | 0 | inline bool isTableCellFormat() const { return type() == CharFormat && objectType() == TableCellObject; } |
336 | | |
337 | | QTextBlockFormat toBlockFormat() const; |
338 | | QTextCharFormat toCharFormat() const; |
339 | | QTextListFormat toListFormat() const; |
340 | | QTextTableFormat toTableFormat() const; |
341 | | QTextFrameFormat toFrameFormat() const; |
342 | | QTextImageFormat toImageFormat() const; |
343 | | QTextTableCellFormat toTableCellFormat() const; |
344 | | |
345 | | bool operator==(const QTextFormat &rhs) const; |
346 | 0 | inline bool operator!=(const QTextFormat &rhs) const { return !operator==(rhs); } |
347 | | operator QVariant() const; |
348 | | |
349 | | inline void setLayoutDirection(Qt::LayoutDirection direction) |
350 | 0 | { setProperty(QTextFormat::LayoutDirection, direction); } |
351 | | inline Qt::LayoutDirection layoutDirection() const |
352 | 875k | { return Qt::LayoutDirection(intProperty(QTextFormat::LayoutDirection)); } |
353 | | |
354 | | inline void setBackground(const QBrush &brush) |
355 | 0 | { setProperty(BackgroundBrush, brush); } |
356 | | inline QBrush background() const |
357 | 337k | { return brushProperty(BackgroundBrush); } |
358 | | inline void clearBackground() |
359 | 0 | { clearProperty(BackgroundBrush); } |
360 | | |
361 | | inline void setForeground(const QBrush &brush) |
362 | 0 | { setProperty(ForegroundBrush, brush); } |
363 | | inline QBrush foreground() const |
364 | 267k | { return brushProperty(ForegroundBrush); } |
365 | | inline void clearForeground() |
366 | 0 | { clearProperty(ForegroundBrush); } |
367 | | |
368 | | private: |
369 | | QSharedDataPointer<QTextFormatPrivate> d; |
370 | | qint32 format_type; |
371 | | |
372 | | friend class QTextFormatCollection; |
373 | | friend class QTextCharFormat; |
374 | | friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextFormat &); |
375 | | friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextFormat &); |
376 | | }; |
377 | | |
378 | 0 | Q_DECLARE_SHARED(QTextFormat) |
379 | 0 |
|
380 | 0 | inline void QTextFormat::setObjectType(int atype) |
381 | 0 | { setProperty(ObjectType, atype); } |
382 | | |
383 | 0 | Q_DECLARE_OPERATORS_FOR_FLAGS(QTextFormat::PageBreakFlags) Unexecuted instantiation: operator|(QTextFormat::PageBreakFlag, QTextFormat::PageBreakFlag) Unexecuted instantiation: operator|(QTextFormat::PageBreakFlag, QFlags<QTextFormat::PageBreakFlag>) Unexecuted instantiation: operator&(QTextFormat::PageBreakFlag, QTextFormat::PageBreakFlag) Unexecuted instantiation: operator&(QTextFormat::PageBreakFlag, QFlags<QTextFormat::PageBreakFlag>) Unexecuted instantiation: operator^(QTextFormat::PageBreakFlag, QTextFormat::PageBreakFlag) Unexecuted instantiation: operator^(QTextFormat::PageBreakFlag, QFlags<QTextFormat::PageBreakFlag>) Unexecuted instantiation: operator|(QTextFormat::PageBreakFlag, int) |
384 | 0 |
|
385 | 0 | class Q_GUI_EXPORT QTextCharFormat : public QTextFormat |
386 | 0 | { |
387 | 0 | public: |
388 | 0 | enum VerticalAlignment { |
389 | 0 | AlignNormal = 0, |
390 | 0 | AlignSuperScript, |
391 | 0 | AlignSubScript, |
392 | 0 | AlignMiddle, |
393 | 0 | AlignTop, |
394 | 0 | AlignBottom, |
395 | 0 | AlignBaseline |
396 | 0 | }; |
397 | 0 | enum UnderlineStyle { // keep in sync with Qt::PenStyle! |
398 | 0 | NoUnderline, |
399 | 0 | SingleUnderline, |
400 | 0 | DashUnderline, |
401 | 0 | DotLine, |
402 | 0 | DashDotLine, |
403 | 0 | DashDotDotLine, |
404 | 0 | WaveUnderline, |
405 | 0 | SpellCheckUnderline |
406 | 0 | }; |
407 | 0 |
|
408 | 0 | QTextCharFormat(); |
409 | 0 |
|
410 | 43.3k | bool isValid() const { return isCharFormat(); } |
411 | | |
412 | | enum FontPropertiesInheritanceBehavior { |
413 | | FontPropertiesSpecifiedOnly, |
414 | | FontPropertiesAll |
415 | | }; |
416 | | void setFont(const QFont &font, FontPropertiesInheritanceBehavior behavior = FontPropertiesAll); |
417 | | QFont font() const; |
418 | | |
419 | | #if QT_DEPRECATED_SINCE(6, 1) |
420 | | QT_DEPRECATED_VERSION_X_6_1("Use setFontFamilies instead") inline void setFontFamily(const QString &family) |
421 | 0 | { setProperty(FontFamilies, QVariant(QStringList(family))); } |
422 | | QT_DEPRECATED_VERSION_X_6_1("Use fontFamilies instead") inline QString fontFamily() const |
423 | 0 | { return property(FontFamilies).toStringList().first(); } |
424 | | #endif |
425 | | |
426 | | inline void setFontFamilies(const QStringList &families) |
427 | 0 | { setProperty(FontFamilies, QVariant(families)); } |
428 | | #if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) |
429 | | inline QVariant fontFamilies() const |
430 | 0 | { return property(FontFamilies); } |
431 | | #else |
432 | | inline QStringList fontFamilies() const |
433 | | { return property(FontFamilies).toStringList(); } |
434 | | #endif |
435 | | |
436 | | inline void setFontStyleName(const QString &styleName) |
437 | 0 | { setProperty(FontStyleName, styleName); } |
438 | | #if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) |
439 | | inline QVariant fontStyleName() const |
440 | 0 | { return property(FontStyleName); } |
441 | | #else |
442 | | inline QStringList fontStyleName() const |
443 | | { return property(FontStyleName).toStringList(); } |
444 | | #endif |
445 | | |
446 | | inline void setFontPointSize(qreal size) |
447 | 0 | { setProperty(FontPointSize, size); } |
448 | | inline qreal fontPointSize() const |
449 | 0 | { return doubleProperty(FontPointSize); } |
450 | | |
451 | | inline void setFontWeight(int weight) |
452 | 0 | { setProperty(FontWeight, weight); } |
453 | | inline int fontWeight() const |
454 | 0 | { return hasProperty(FontWeight) ? intProperty(FontWeight) : QFont::Normal; } |
455 | | inline void setFontItalic(bool italic) |
456 | 0 | { setProperty(FontItalic, italic); } |
457 | | inline bool fontItalic() const |
458 | 0 | { return boolProperty(FontItalic); } |
459 | | inline void setFontCapitalization(QFont::Capitalization capitalization) |
460 | 0 | { setProperty(FontCapitalization, capitalization); } |
461 | | inline QFont::Capitalization fontCapitalization() const |
462 | 0 | { return static_cast<QFont::Capitalization>(intProperty(FontCapitalization)); } |
463 | | inline void setFontLetterSpacingType(QFont::SpacingType letterSpacingType) |
464 | 0 | { setProperty(FontLetterSpacingType, letterSpacingType); } |
465 | | inline QFont::SpacingType fontLetterSpacingType() const |
466 | 0 | { return static_cast<QFont::SpacingType>(intProperty(FontLetterSpacingType)); } |
467 | | inline void setFontLetterSpacing(qreal spacing) |
468 | 0 | { setProperty(FontLetterSpacing, spacing); } |
469 | | inline qreal fontLetterSpacing() const |
470 | 0 | { return doubleProperty(FontLetterSpacing); } |
471 | | inline void setFontWordSpacing(qreal spacing) |
472 | 0 | { setProperty(FontWordSpacing, spacing); } |
473 | | inline qreal fontWordSpacing() const |
474 | 0 | { return doubleProperty(FontWordSpacing); } |
475 | | |
476 | | inline void setFontUnderline(bool underline) |
477 | 0 | { setProperty(TextUnderlineStyle, underline ? SingleUnderline : NoUnderline); } |
478 | | bool fontUnderline() const; |
479 | | |
480 | | inline void setFontOverline(bool overline) |
481 | 0 | { setProperty(FontOverline, overline); } |
482 | | inline bool fontOverline() const |
483 | 266k | { return boolProperty(FontOverline); } |
484 | | |
485 | | inline void setFontStrikeOut(bool strikeOut) |
486 | 0 | { setProperty(FontStrikeOut, strikeOut); } |
487 | | inline bool fontStrikeOut() const |
488 | 266k | { return boolProperty(FontStrikeOut); } |
489 | | |
490 | | inline void setUnderlineColor(const QColor &color) |
491 | 0 | { setProperty(TextUnderlineColor, color); } |
492 | | inline QColor underlineColor() const |
493 | 0 | { return colorProperty(TextUnderlineColor); } |
494 | | |
495 | | inline void setFontFixedPitch(bool fixedPitch) |
496 | 0 | { setProperty(FontFixedPitch, fixedPitch); } |
497 | | inline bool fontFixedPitch() const |
498 | 0 | { return boolProperty(FontFixedPitch); } |
499 | | |
500 | | inline void setFontStretch(int factor) |
501 | 0 | { setProperty(FontStretch, factor); } |
502 | | inline int fontStretch() const |
503 | 0 | { return intProperty(FontStretch); } |
504 | | |
505 | | inline void setFontStyleHint(QFont::StyleHint hint, QFont::StyleStrategy strategy = QFont::PreferDefault) |
506 | 0 | { setProperty(FontStyleHint, hint); setProperty(FontStyleStrategy, strategy); } |
507 | | inline void setFontStyleStrategy(QFont::StyleStrategy strategy) |
508 | 0 | { setProperty(FontStyleStrategy, strategy); } |
509 | | QFont::StyleHint fontStyleHint() const |
510 | 0 | { return static_cast<QFont::StyleHint>(intProperty(FontStyleHint)); } |
511 | | QFont::StyleStrategy fontStyleStrategy() const |
512 | 0 | { return static_cast<QFont::StyleStrategy>(intProperty(FontStyleStrategy)); } |
513 | | |
514 | | inline void setFontHintingPreference(QFont::HintingPreference hintingPreference) |
515 | 0 | { |
516 | 0 | setProperty(FontHintingPreference, hintingPreference); |
517 | 0 | } |
518 | | |
519 | | inline QFont::HintingPreference fontHintingPreference() const |
520 | 0 | { |
521 | 0 | return static_cast<QFont::HintingPreference>(intProperty(FontHintingPreference)); |
522 | 0 | } |
523 | | |
524 | | void setFontFeatures(const QMap<QFont::Tag, quint32> &fontFeatures); |
525 | | QMap<QFont::Tag, quint32> fontFeatures() const; |
526 | | void setFontVariableAxes(const QMap<QFont::Tag, float> &fontVariableAxes); |
527 | | QMap<QFont::Tag, float> fontVariableAxes() const; |
528 | | |
529 | | inline void setFontKerning(bool enable) |
530 | 0 | { setProperty(FontKerning, enable); } |
531 | | inline bool fontKerning() const |
532 | 0 | { return boolProperty(FontKerning); } |
533 | | |
534 | | void setUnderlineStyle(UnderlineStyle style); |
535 | | inline UnderlineStyle underlineStyle() const |
536 | 0 | { return static_cast<UnderlineStyle>(intProperty(TextUnderlineStyle)); } |
537 | | |
538 | | inline void setVerticalAlignment(VerticalAlignment alignment) |
539 | 0 | { setProperty(TextVerticalAlignment, alignment); } |
540 | | inline VerticalAlignment verticalAlignment() const |
541 | 4.82M | { return static_cast<VerticalAlignment>(intProperty(TextVerticalAlignment)); } |
542 | | |
543 | | inline void setTextOutline(const QPen &pen) |
544 | 0 | { setProperty(TextOutline, pen); } |
545 | | inline QPen textOutline() const |
546 | 0 | { return penProperty(TextOutline); } |
547 | | |
548 | | inline void setToolTip(const QString &tip) |
549 | 0 | { setProperty(TextToolTip, tip); } |
550 | | inline QString toolTip() const |
551 | 0 | { return stringProperty(TextToolTip); } |
552 | | |
553 | | inline void setSuperScriptBaseline(qreal baseline) |
554 | 0 | { setProperty(TextSuperScriptBaseline, baseline); } |
555 | | inline qreal superScriptBaseline() const |
556 | 0 | { return hasProperty(TextSuperScriptBaseline) ? doubleProperty(TextSuperScriptBaseline) : 50.0; } |
557 | | |
558 | | inline void setSubScriptBaseline(qreal baseline) |
559 | 0 | { setProperty(TextSubScriptBaseline, baseline); } |
560 | | inline qreal subScriptBaseline() const |
561 | 0 | { return hasProperty(TextSubScriptBaseline) ? doubleProperty(TextSubScriptBaseline) : 100.0 / 6.0; } |
562 | | |
563 | | inline void setBaselineOffset(qreal baseline) |
564 | 0 | { setProperty(TextBaselineOffset, baseline); } |
565 | | inline qreal baselineOffset() const |
566 | 267k | { return hasProperty(TextBaselineOffset) ? doubleProperty(TextBaselineOffset) : 0.0; } |
567 | | |
568 | | inline void setAnchor(bool anchor) |
569 | 0 | { setProperty(IsAnchor, anchor); } |
570 | | inline bool isAnchor() const |
571 | 0 | { return boolProperty(IsAnchor); } |
572 | | |
573 | | inline void setAnchorHref(const QString &value) |
574 | 0 | { setProperty(AnchorHref, value); } |
575 | | inline QString anchorHref() const |
576 | 0 | { return stringProperty(AnchorHref); } |
577 | | |
578 | | inline void setAnchorNames(const QStringList &names) |
579 | 0 | { setProperty(AnchorName, names); } |
580 | | QStringList anchorNames() const; |
581 | | |
582 | | inline void setTableCellRowSpan(int tableCellRowSpan); |
583 | | inline int tableCellRowSpan() const |
584 | 0 | { int s = intProperty(TableCellRowSpan); if (s == 0) s = 1; return s; } |
585 | | inline void setTableCellColumnSpan(int tableCellColumnSpan); |
586 | | inline int tableCellColumnSpan() const |
587 | 0 | { int s = intProperty(TableCellColumnSpan); if (s == 0) s = 1; return s; } |
588 | | |
589 | | protected: |
590 | | explicit QTextCharFormat(const QTextFormat &fmt); |
591 | | friend class QTextFormat; |
592 | | friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextCharFormat &); |
593 | | friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextCharFormat &); |
594 | | }; |
595 | | |
596 | 0 | Q_DECLARE_SHARED(QTextCharFormat) |
597 | 0 |
|
598 | 0 | inline void QTextCharFormat::setTableCellRowSpan(int _tableCellRowSpan) |
599 | 0 | { |
600 | 0 | if (_tableCellRowSpan <= 1) |
601 | 0 | clearProperty(TableCellRowSpan); // the getter will return 1 here. |
602 | 0 | else |
603 | 0 | setProperty(TableCellRowSpan, _tableCellRowSpan); |
604 | 0 | } |
605 | | |
606 | | inline void QTextCharFormat::setTableCellColumnSpan(int _tableCellColumnSpan) |
607 | 0 | { |
608 | 0 | if (_tableCellColumnSpan <= 1) |
609 | 0 | clearProperty(TableCellColumnSpan); // the getter will return 1 here. |
610 | 0 | else |
611 | 0 | setProperty(TableCellColumnSpan, _tableCellColumnSpan); |
612 | 0 | } |
613 | | |
614 | | class Q_GUI_EXPORT QTextBlockFormat : public QTextFormat |
615 | | { |
616 | | public: |
617 | | enum LineHeightTypes { |
618 | | SingleHeight = 0, |
619 | | ProportionalHeight = 1, |
620 | | FixedHeight = 2, |
621 | | MinimumHeight = 3, |
622 | | LineDistanceHeight = 4 |
623 | | }; |
624 | | |
625 | | enum class MarkerType { |
626 | | NoMarker = 0, |
627 | | Unchecked = 1, |
628 | | Checked = 2 |
629 | | }; |
630 | | |
631 | | QTextBlockFormat(); |
632 | | |
633 | 0 | bool isValid() const { return isBlockFormat(); } |
634 | | |
635 | | inline void setAlignment(Qt::Alignment alignment); |
636 | | inline Qt::Alignment alignment() const |
637 | 0 | { int a = intProperty(BlockAlignment); if (a == 0) a = Qt::AlignLeft; return QFlag(a); } |
638 | | |
639 | | inline void setTopMargin(qreal margin) |
640 | 0 | { setProperty(BlockTopMargin, margin); } |
641 | | inline qreal topMargin() const |
642 | 826k | { return doubleProperty(BlockTopMargin); } |
643 | | |
644 | | inline void setBottomMargin(qreal margin) |
645 | 0 | { setProperty(BlockBottomMargin, margin); } |
646 | | inline qreal bottomMargin() const |
647 | 826k | { return doubleProperty(BlockBottomMargin); } |
648 | | |
649 | | inline void setLeftMargin(qreal margin) |
650 | 0 | { setProperty(BlockLeftMargin, margin); } |
651 | | inline qreal leftMargin() const |
652 | 859k | { return doubleProperty(BlockLeftMargin); } |
653 | | |
654 | | inline void setRightMargin(qreal margin) |
655 | 0 | { setProperty(BlockRightMargin, margin); } |
656 | | inline qreal rightMargin() const |
657 | 859k | { return doubleProperty(BlockRightMargin); } |
658 | | |
659 | | inline void setTextIndent(qreal aindent) |
660 | 0 | { setProperty(TextIndent, aindent); } |
661 | | inline qreal textIndent() const |
662 | 859k | { return doubleProperty(TextIndent); } |
663 | | |
664 | | inline void setIndent(int indent); |
665 | | inline int indent() const |
666 | 859k | { return intProperty(BlockIndent); } |
667 | | |
668 | | inline void setHeadingLevel(int alevel) |
669 | 0 | { setProperty(HeadingLevel, alevel); } |
670 | | inline int headingLevel() const |
671 | 0 | { return intProperty(HeadingLevel); } |
672 | | |
673 | | inline void setLineHeight(qreal height, int heightType) |
674 | 0 | { setProperty(LineHeight, height); setProperty(LineHeightType, heightType); } |
675 | | inline qreal lineHeight(qreal scriptLineHeight, qreal scaling) const; |
676 | | inline qreal lineHeight() const |
677 | 0 | { return doubleProperty(LineHeight); } |
678 | | inline int lineHeightType() const |
679 | 1.39M | { return intProperty(LineHeightType); } |
680 | | |
681 | | inline void setNonBreakableLines(bool b) |
682 | 0 | { setProperty(BlockNonBreakableLines, b); } |
683 | | inline bool nonBreakableLines() const |
684 | 859k | { return boolProperty(BlockNonBreakableLines); } |
685 | | |
686 | | inline void setPageBreakPolicy(PageBreakFlags flags) |
687 | 0 | { setProperty(PageBreakPolicy, int(flags.toInt())); } |
688 | | inline PageBreakFlags pageBreakPolicy() const |
689 | 1.71M | { return PageBreakFlags(intProperty(PageBreakPolicy)); } |
690 | | |
691 | | void setTabPositions(const QList<QTextOption::Tab> &tabs); |
692 | | QList<QTextOption::Tab> tabPositions() const; |
693 | | |
694 | | inline void setMarker(MarkerType marker) |
695 | 0 | { setProperty(BlockMarker, int(marker)); } |
696 | | inline MarkerType marker() const |
697 | 0 | { return MarkerType(intProperty(BlockMarker)); } |
698 | | |
699 | | protected: |
700 | | explicit QTextBlockFormat(const QTextFormat &fmt); |
701 | | friend class QTextFormat; |
702 | | friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextBlockFormat &); |
703 | | friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextBlockFormat &); |
704 | | }; |
705 | | |
706 | 0 | Q_DECLARE_SHARED(QTextBlockFormat) |
707 | 0 |
|
708 | 0 | inline void QTextBlockFormat::setAlignment(Qt::Alignment aalignment) |
709 | 0 | { setProperty(BlockAlignment, int(aalignment.toInt())); } |
710 | | |
711 | | inline void QTextBlockFormat::setIndent(int aindent) |
712 | 0 | { setProperty(BlockIndent, aindent); } |
713 | | |
714 | | inline qreal QTextBlockFormat::lineHeight(qreal scriptLineHeight, qreal scaling = 1.0) const |
715 | 2.78M | { |
716 | 2.78M | switch(intProperty(LineHeightType)) { |
717 | 2.78M | case SingleHeight: |
718 | 2.78M | return(scriptLineHeight); |
719 | 0 | case ProportionalHeight: |
720 | 0 | return(scriptLineHeight * doubleProperty(LineHeight) / 100.0); |
721 | 0 | case FixedHeight: |
722 | 0 | return(doubleProperty(LineHeight) * scaling); |
723 | 0 | case MinimumHeight: |
724 | 0 | return(qMax(scriptLineHeight, doubleProperty(LineHeight) * scaling)); |
725 | 0 | case LineDistanceHeight: |
726 | 0 | return(scriptLineHeight + doubleProperty(LineHeight) * scaling); |
727 | 2.78M | } |
728 | 0 | return(0); |
729 | 2.78M | } |
730 | | |
731 | | class Q_GUI_EXPORT QTextListFormat : public QTextFormat |
732 | | { |
733 | | public: |
734 | | QTextListFormat(); |
735 | | |
736 | 0 | bool isValid() const { return isListFormat(); } |
737 | | |
738 | | enum Style { |
739 | | ListDisc = -1, |
740 | | ListCircle = -2, |
741 | | ListSquare = -3, |
742 | | ListDecimal = -4, |
743 | | ListLowerAlpha = -5, |
744 | | ListUpperAlpha = -6, |
745 | | ListLowerRoman = -7, |
746 | | ListUpperRoman = -8, |
747 | | ListStyleUndefined = 0 |
748 | | }; |
749 | | |
750 | | inline void setStyle(Style style); |
751 | | inline Style style() const |
752 | 0 | { return static_cast<Style>(intProperty(ListStyle)); } |
753 | | |
754 | | inline void setIndent(int indent); |
755 | | inline int indent() const |
756 | 0 | { return intProperty(ListIndent); } |
757 | | |
758 | | inline void setNumberPrefix(const QString &numberPrefix); |
759 | | inline QString numberPrefix() const |
760 | 0 | { return stringProperty(ListNumberPrefix); } |
761 | | |
762 | | inline void setNumberSuffix(const QString &numberSuffix); |
763 | | inline QString numberSuffix() const |
764 | 0 | { return stringProperty(ListNumberSuffix); } |
765 | | |
766 | | inline void setStart(int indent); |
767 | 0 | inline int start() const { return intProperty(ListStart); } |
768 | | |
769 | | protected: |
770 | | explicit QTextListFormat(const QTextFormat &fmt); |
771 | | friend class QTextFormat; |
772 | | }; |
773 | | |
774 | 0 | Q_DECLARE_SHARED(QTextListFormat) |
775 | 0 |
|
776 | 0 | inline void QTextListFormat::setStyle(Style astyle) |
777 | 0 | { setProperty(ListStyle, astyle); } |
778 | | |
779 | | inline void QTextListFormat::setIndent(int aindent) |
780 | 0 | { setProperty(ListIndent, aindent); } |
781 | | |
782 | | inline void QTextListFormat::setNumberPrefix(const QString &np) |
783 | 0 | { setProperty(ListNumberPrefix, np); } |
784 | | |
785 | | inline void QTextListFormat::setNumberSuffix(const QString &ns) |
786 | 0 | { setProperty(ListNumberSuffix, ns); } |
787 | | |
788 | | inline void QTextListFormat::setStart(int astart) |
789 | 0 | { |
790 | 0 | setProperty(ListStart, astart); |
791 | 0 | } |
792 | | |
793 | | class Q_GUI_EXPORT QTextImageFormat : public QTextCharFormat |
794 | | { |
795 | | public: |
796 | | QTextImageFormat(); |
797 | | |
798 | 0 | bool isValid() const { return isImageFormat(); } |
799 | | |
800 | | inline void setName(const QString &name); |
801 | | inline QString name() const |
802 | 0 | { return stringProperty(ImageName); } |
803 | | |
804 | | inline void setWidth(qreal width); |
805 | | inline qreal width() const |
806 | 0 | { return doubleProperty(ImageWidth); } |
807 | | |
808 | | inline void setMaximumWidth(QTextLength maxWidth); |
809 | | inline QTextLength maximumWidth() const |
810 | 0 | { return lengthProperty(ImageMaxWidth); } |
811 | | |
812 | | inline void setHeight(qreal height); |
813 | | inline qreal height() const |
814 | 0 | { return doubleProperty(ImageHeight); } |
815 | | |
816 | | inline void setQuality(int quality); |
817 | | #if QT_DEPRECATED_SINCE(6, 3) |
818 | | QT_DEPRECATED_VERSION_X_6_3("Pass a quality value, the default is 100") inline void setQuality() |
819 | 0 | { setQuality(100); } |
820 | | #endif |
821 | | inline int quality() const |
822 | 0 | { return intProperty(ImageQuality); } |
823 | | |
824 | | protected: |
825 | | explicit QTextImageFormat(const QTextFormat &format); |
826 | | friend class QTextFormat; |
827 | | friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextListFormat &); |
828 | | friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextListFormat &); |
829 | | }; |
830 | | |
831 | 0 | Q_DECLARE_SHARED(QTextImageFormat) |
832 | 0 |
|
833 | 0 | inline void QTextImageFormat::setName(const QString &aname) |
834 | 0 | { setProperty(ImageName, aname); } |
835 | | |
836 | | inline void QTextImageFormat::setWidth(qreal awidth) |
837 | 0 | { setProperty(ImageWidth, awidth); } |
838 | | |
839 | | inline void QTextImageFormat::setMaximumWidth(QTextLength maxWidth) |
840 | 0 | { setProperty(ImageMaxWidth, maxWidth); } |
841 | | |
842 | | inline void QTextImageFormat::setHeight(qreal aheight) |
843 | 0 | { setProperty(ImageHeight, aheight); } |
844 | | |
845 | | inline void QTextImageFormat::setQuality(int aquality) |
846 | 0 | { setProperty(ImageQuality, aquality); } |
847 | | |
848 | | class Q_GUI_EXPORT QTextFrameFormat : public QTextFormat |
849 | | { |
850 | | public: |
851 | | QTextFrameFormat(); |
852 | | |
853 | 0 | bool isValid() const { return isFrameFormat(); } |
854 | | |
855 | | enum Position { |
856 | | InFlow, |
857 | | FloatLeft, |
858 | | FloatRight |
859 | | // ###### |
860 | | // Absolute |
861 | | }; |
862 | | |
863 | | enum BorderStyle { |
864 | | BorderStyle_None, |
865 | | BorderStyle_Dotted, |
866 | | BorderStyle_Dashed, |
867 | | BorderStyle_Solid, |
868 | | BorderStyle_Double, |
869 | | BorderStyle_DotDash, |
870 | | BorderStyle_DotDotDash, |
871 | | BorderStyle_Groove, |
872 | | BorderStyle_Ridge, |
873 | | BorderStyle_Inset, |
874 | | BorderStyle_Outset |
875 | | }; |
876 | | |
877 | | inline void setPosition(Position f) |
878 | 0 | { setProperty(CssFloat, f); } |
879 | | inline Position position() const |
880 | 0 | { return static_cast<Position>(intProperty(CssFloat)); } |
881 | | |
882 | | inline void setBorder(qreal border); |
883 | | inline qreal border() const |
884 | 33.1k | { return doubleProperty(FrameBorder); } |
885 | | |
886 | | inline void setBorderBrush(const QBrush &brush) |
887 | 16.5k | { setProperty(FrameBorderBrush, brush); } |
888 | | inline QBrush borderBrush() const |
889 | 0 | { return brushProperty(FrameBorderBrush); } |
890 | | |
891 | | inline void setBorderStyle(BorderStyle style) |
892 | 16.5k | { setProperty(FrameBorderStyle, style); } |
893 | | inline BorderStyle borderStyle() const |
894 | 0 | { return static_cast<BorderStyle>(intProperty(FrameBorderStyle)); } |
895 | | |
896 | | void setMargin(qreal margin); |
897 | | inline qreal margin() const |
898 | 0 | { return doubleProperty(FrameMargin); } |
899 | | |
900 | | inline void setTopMargin(qreal margin); |
901 | | qreal topMargin() const; |
902 | | |
903 | | inline void setBottomMargin(qreal margin); |
904 | | qreal bottomMargin() const; |
905 | | |
906 | | inline void setLeftMargin(qreal margin); |
907 | | qreal leftMargin() const; |
908 | | |
909 | | inline void setRightMargin(qreal margin); |
910 | | qreal rightMargin() const; |
911 | | |
912 | | inline void setPadding(qreal padding); |
913 | | inline qreal padding() const |
914 | 33.1k | { return doubleProperty(FramePadding); } |
915 | | |
916 | | inline void setWidth(qreal width); |
917 | | inline void setWidth(const QTextLength &length) |
918 | 0 | { setProperty(FrameWidth, length); } |
919 | | inline QTextLength width() const |
920 | 66.2k | { return lengthProperty(FrameWidth); } |
921 | | |
922 | | inline void setHeight(qreal height); |
923 | | inline void setHeight(const QTextLength &height); |
924 | | inline QTextLength height() const |
925 | 66.2k | { return lengthProperty(FrameHeight); } |
926 | | |
927 | | inline void setPageBreakPolicy(PageBreakFlags flags) |
928 | 0 | { setProperty(PageBreakPolicy, int(flags.toInt())); } |
929 | | inline PageBreakFlags pageBreakPolicy() const |
930 | 0 | { return PageBreakFlags(intProperty(PageBreakPolicy)); } |
931 | | |
932 | | protected: |
933 | | explicit QTextFrameFormat(const QTextFormat &fmt); |
934 | | friend class QTextFormat; |
935 | | friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextFrameFormat &); |
936 | | friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextFrameFormat &); |
937 | | }; |
938 | | |
939 | 0 | Q_DECLARE_SHARED(QTextFrameFormat) |
940 | 0 |
|
941 | 0 | inline void QTextFrameFormat::setBorder(qreal aborder) |
942 | 0 | { setProperty(FrameBorder, aborder); } |
943 | | |
944 | | inline void QTextFrameFormat::setPadding(qreal apadding) |
945 | 0 | { setProperty(FramePadding, apadding); } |
946 | | |
947 | | inline void QTextFrameFormat::setWidth(qreal awidth) |
948 | 0 | { setProperty(FrameWidth, QTextLength(QTextLength::FixedLength, awidth)); } |
949 | | |
950 | | inline void QTextFrameFormat::setHeight(qreal aheight) |
951 | 0 | { setProperty(FrameHeight, QTextLength(QTextLength::FixedLength, aheight)); } |
952 | | inline void QTextFrameFormat::setHeight(const QTextLength &aheight) |
953 | 0 | { setProperty(FrameHeight, aheight); } |
954 | | |
955 | | inline void QTextFrameFormat::setTopMargin(qreal amargin) |
956 | 0 | { setProperty(FrameTopMargin, amargin); } |
957 | | |
958 | | inline void QTextFrameFormat::setBottomMargin(qreal amargin) |
959 | 0 | { setProperty(FrameBottomMargin, amargin); } |
960 | | |
961 | | inline void QTextFrameFormat::setLeftMargin(qreal amargin) |
962 | 0 | { setProperty(FrameLeftMargin, amargin); } |
963 | | |
964 | | inline void QTextFrameFormat::setRightMargin(qreal amargin) |
965 | 0 | { setProperty(FrameRightMargin, amargin); } |
966 | | |
967 | | class Q_GUI_EXPORT QTextTableFormat : public QTextFrameFormat |
968 | | { |
969 | | public: |
970 | | QTextTableFormat(); |
971 | | |
972 | 0 | inline bool isValid() const { return isTableFormat(); } |
973 | | |
974 | | inline int columns() const |
975 | 0 | { int cols = intProperty(TableColumns); if (cols == 0) cols = 1; return cols; } |
976 | | inline void setColumns(int columns); |
977 | | |
978 | | inline void setColumnWidthConstraints(const QList<QTextLength> &constraints) |
979 | 0 | { setProperty(TableColumnWidthConstraints, constraints); } |
980 | | |
981 | | inline QList<QTextLength> columnWidthConstraints() const |
982 | 0 | { return lengthVectorProperty(TableColumnWidthConstraints); } |
983 | | |
984 | | inline void clearColumnWidthConstraints() |
985 | 0 | { clearProperty(TableColumnWidthConstraints); } |
986 | | |
987 | | inline qreal cellSpacing() const |
988 | 0 | { return doubleProperty(TableCellSpacing); } |
989 | | inline void setCellSpacing(qreal spacing) |
990 | 0 | { setProperty(TableCellSpacing, spacing); } |
991 | | |
992 | | inline qreal cellPadding() const |
993 | 0 | { return doubleProperty(TableCellPadding); } |
994 | | inline void setCellPadding(qreal padding); |
995 | | |
996 | | inline void setAlignment(Qt::Alignment alignment); |
997 | | inline Qt::Alignment alignment() const |
998 | 0 | { return QFlag(intProperty(BlockAlignment)); } |
999 | | |
1000 | | inline void setHeaderRowCount(int count) |
1001 | 0 | { setProperty(TableHeaderRowCount, count); } |
1002 | | inline int headerRowCount() const |
1003 | 0 | { return intProperty(TableHeaderRowCount); } |
1004 | | |
1005 | | inline void setBorderCollapse(bool borderCollapse) |
1006 | 0 | { setProperty(TableBorderCollapse, borderCollapse); } |
1007 | | inline bool borderCollapse() const |
1008 | 0 | { return boolProperty(TableBorderCollapse); } |
1009 | | |
1010 | | protected: |
1011 | | explicit QTextTableFormat(const QTextFormat &fmt); |
1012 | | friend class QTextFormat; |
1013 | | }; |
1014 | | |
1015 | 0 | Q_DECLARE_SHARED(QTextTableFormat) |
1016 | 0 |
|
1017 | 0 | inline void QTextTableFormat::setColumns(int acolumns) |
1018 | 0 | { |
1019 | 0 | if (acolumns == 1) |
1020 | 0 | acolumns = 0; |
1021 | 0 | setProperty(TableColumns, acolumns); |
1022 | 0 | } |
1023 | | |
1024 | | inline void QTextTableFormat::setCellPadding(qreal apadding) |
1025 | 0 | { setProperty(TableCellPadding, apadding); } |
1026 | | |
1027 | | inline void QTextTableFormat::setAlignment(Qt::Alignment aalignment) |
1028 | 0 | { setProperty(BlockAlignment, int(aalignment.toInt())); } |
1029 | | |
1030 | | class Q_GUI_EXPORT QTextTableCellFormat : public QTextCharFormat |
1031 | | { |
1032 | | public: |
1033 | | QTextTableCellFormat(); |
1034 | | |
1035 | 0 | inline bool isValid() const { return isTableCellFormat(); } |
1036 | | |
1037 | | inline void setTopPadding(qreal padding); |
1038 | | inline qreal topPadding() const; |
1039 | | |
1040 | | inline void setBottomPadding(qreal padding); |
1041 | | inline qreal bottomPadding() const; |
1042 | | |
1043 | | inline void setLeftPadding(qreal padding); |
1044 | | inline qreal leftPadding() const; |
1045 | | |
1046 | | inline void setRightPadding(qreal padding); |
1047 | | inline qreal rightPadding() const; |
1048 | | |
1049 | | inline void setPadding(qreal padding); |
1050 | | |
1051 | | inline void setTopBorder(qreal width) |
1052 | 0 | { setProperty(TableCellTopBorder, width); } |
1053 | | inline qreal topBorder() const |
1054 | 0 | { return doubleProperty(TableCellTopBorder); } |
1055 | | |
1056 | | inline void setBottomBorder(qreal width) |
1057 | 0 | { setProperty(TableCellBottomBorder, width); } |
1058 | | inline qreal bottomBorder() const |
1059 | 0 | { return doubleProperty(TableCellBottomBorder); } |
1060 | | |
1061 | | inline void setLeftBorder(qreal width) |
1062 | 0 | { setProperty(TableCellLeftBorder, width); } |
1063 | | inline qreal leftBorder() const |
1064 | 0 | { return doubleProperty(TableCellLeftBorder); } |
1065 | | |
1066 | | inline void setRightBorder(qreal width) |
1067 | 0 | { setProperty(TableCellRightBorder, width); } |
1068 | | inline qreal rightBorder() const |
1069 | 0 | { return doubleProperty(TableCellRightBorder); } |
1070 | | |
1071 | | inline void setBorder(qreal width); |
1072 | | |
1073 | | inline void setTopBorderStyle(QTextFrameFormat::BorderStyle style) |
1074 | 0 | { setProperty(TableCellTopBorderStyle, style); } |
1075 | | inline QTextFrameFormat::BorderStyle topBorderStyle() const |
1076 | 0 | { return static_cast<QTextFrameFormat::BorderStyle>(intProperty(TableCellTopBorderStyle)); } |
1077 | | |
1078 | | inline void setBottomBorderStyle(QTextFrameFormat::BorderStyle style) |
1079 | 0 | { setProperty(TableCellBottomBorderStyle, style); } |
1080 | | inline QTextFrameFormat::BorderStyle bottomBorderStyle() const |
1081 | 0 | { return static_cast<QTextFrameFormat::BorderStyle>(intProperty(TableCellBottomBorderStyle)); } |
1082 | | |
1083 | | inline void setLeftBorderStyle(QTextFrameFormat::BorderStyle style) |
1084 | 0 | { setProperty(TableCellLeftBorderStyle, style); } |
1085 | | inline QTextFrameFormat::BorderStyle leftBorderStyle() const |
1086 | 0 | { return static_cast<QTextFrameFormat::BorderStyle>(intProperty(TableCellLeftBorderStyle)); } |
1087 | | |
1088 | | inline void setRightBorderStyle(QTextFrameFormat::BorderStyle style) |
1089 | 0 | { setProperty(TableCellRightBorderStyle, style); } |
1090 | | inline QTextFrameFormat::BorderStyle rightBorderStyle() const |
1091 | 0 | { return static_cast<QTextFrameFormat::BorderStyle>(intProperty(TableCellRightBorderStyle)); } |
1092 | | |
1093 | | inline void setBorderStyle(QTextFrameFormat::BorderStyle style); |
1094 | | |
1095 | | inline void setTopBorderBrush(const QBrush &brush) |
1096 | 0 | { setProperty(TableCellTopBorderBrush, brush); } |
1097 | | inline QBrush topBorderBrush() const |
1098 | 0 | { return brushProperty(TableCellTopBorderBrush); } |
1099 | | |
1100 | | inline void setBottomBorderBrush(const QBrush &brush) |
1101 | 0 | { setProperty(TableCellBottomBorderBrush, brush); } |
1102 | | inline QBrush bottomBorderBrush() const |
1103 | 0 | { return brushProperty(TableCellBottomBorderBrush); } |
1104 | | |
1105 | | inline void setLeftBorderBrush(const QBrush &brush) |
1106 | 0 | { setProperty(TableCellLeftBorderBrush, brush); } |
1107 | | inline QBrush leftBorderBrush() const |
1108 | 0 | { return brushProperty(TableCellLeftBorderBrush); } |
1109 | | |
1110 | | inline void setRightBorderBrush(const QBrush &brush) |
1111 | 0 | { setProperty(TableCellRightBorderBrush, brush); } |
1112 | | inline QBrush rightBorderBrush() const |
1113 | 0 | { return brushProperty(TableCellRightBorderBrush); } |
1114 | | |
1115 | | inline void setBorderBrush(const QBrush &brush); |
1116 | | |
1117 | | protected: |
1118 | | explicit QTextTableCellFormat(const QTextFormat &fmt); |
1119 | | friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextTableCellFormat &); |
1120 | | friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextTableCellFormat &); |
1121 | | friend class QTextFormat; |
1122 | | }; |
1123 | | |
1124 | 0 | Q_DECLARE_SHARED(QTextTableCellFormat) |
1125 | 0 |
|
1126 | 0 | inline void QTextTableCellFormat::setTopPadding(qreal padding) |
1127 | 0 | { |
1128 | 0 | setProperty(TableCellTopPadding, padding); |
1129 | 0 | } |
1130 | | |
1131 | | inline qreal QTextTableCellFormat::topPadding() const |
1132 | 0 | { |
1133 | 0 | return doubleProperty(TableCellTopPadding); |
1134 | 0 | } |
1135 | | |
1136 | | inline void QTextTableCellFormat::setBottomPadding(qreal padding) |
1137 | 0 | { |
1138 | 0 | setProperty(TableCellBottomPadding, padding); |
1139 | 0 | } |
1140 | | |
1141 | | inline qreal QTextTableCellFormat::bottomPadding() const |
1142 | 0 | { |
1143 | 0 | return doubleProperty(TableCellBottomPadding); |
1144 | 0 | } |
1145 | | |
1146 | | inline void QTextTableCellFormat::setLeftPadding(qreal padding) |
1147 | 0 | { |
1148 | 0 | setProperty(TableCellLeftPadding, padding); |
1149 | 0 | } |
1150 | | |
1151 | | inline qreal QTextTableCellFormat::leftPadding() const |
1152 | 0 | { |
1153 | 0 | return doubleProperty(TableCellLeftPadding); |
1154 | 0 | } |
1155 | | |
1156 | | inline void QTextTableCellFormat::setRightPadding(qreal padding) |
1157 | 0 | { |
1158 | 0 | setProperty(TableCellRightPadding, padding); |
1159 | 0 | } |
1160 | | |
1161 | | inline qreal QTextTableCellFormat::rightPadding() const |
1162 | 0 | { |
1163 | 0 | return doubleProperty(TableCellRightPadding); |
1164 | 0 | } |
1165 | | |
1166 | | inline void QTextTableCellFormat::setPadding(qreal padding) |
1167 | 0 | { |
1168 | 0 | setTopPadding(padding); |
1169 | 0 | setBottomPadding(padding); |
1170 | 0 | setLeftPadding(padding); |
1171 | 0 | setRightPadding(padding); |
1172 | 0 | } |
1173 | | |
1174 | | inline void QTextTableCellFormat::setBorder(qreal width) |
1175 | 0 | { |
1176 | 0 | setTopBorder(width); |
1177 | 0 | setBottomBorder(width); |
1178 | 0 | setLeftBorder(width); |
1179 | 0 | setRightBorder(width); |
1180 | 0 | } |
1181 | | |
1182 | | inline void QTextTableCellFormat::setBorderStyle(QTextFrameFormat::BorderStyle style) |
1183 | 0 | { |
1184 | 0 | setTopBorderStyle(style); |
1185 | 0 | setBottomBorderStyle(style); |
1186 | 0 | setLeftBorderStyle(style); |
1187 | 0 | setRightBorderStyle(style); |
1188 | 0 | } |
1189 | | |
1190 | | inline void QTextTableCellFormat::setBorderBrush(const QBrush &brush) |
1191 | 0 | { |
1192 | 0 | setTopBorderBrush(brush); |
1193 | 0 | setBottomBorderBrush(brush); |
1194 | 0 | setLeftBorderBrush(brush); |
1195 | 0 | setRightBorderBrush(brush); |
1196 | 0 | } |
1197 | | |
1198 | | QT_END_NAMESPACE |
1199 | | |
1200 | | #endif // QTEXTFORMAT_H |