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