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