1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtGui module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
45 #include <QtGui/qcolor.h>
46 #include <QtGui/qfont.h>
47 #include <QtCore/qshareddata.h>
48 #include <QtCore/qvector.h>
49 #include <QtCore/qvariant.h>
50 #include <QtGui/qpen.h>
51 #include <QtGui/qbrush.h>
52 #include <QtGui/qtextoption.h>
63 class QTextFormatCollection;
64 class QTextFormatPrivate;
65 class QTextBlockFormat;
66 class QTextCharFormat;
67 class QTextListFormat;
68 class QTextTableFormat;
69 class QTextFrameFormat;
70 class QTextImageFormat;
71 class QTextTableCellFormat;
78 #ifndef QT_NO_DATASTREAM
79 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextLength &);
80 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextLength &);
83 #ifndef QT_NO_DEBUG_STREAM
84 Q_GUI_EXPORT QDebug operator<<(QDebug, const QTextLength &);
87 class Q_GUI_EXPORT QTextLength
90 enum Type { VariableLength = 0, FixedLength, PercentageLength };
92 inline QTextLength() : lengthType(VariableLength), fixedValueOrPercentage(0) {}
94 inline explicit QTextLength(Type type, qreal value);
96 inline Type type() const { return lengthType; }
97 inline qreal value(qreal maximumLength) const
100 case FixedLength: return fixedValueOrPercentage;
101 case VariableLength: return maximumLength;
102 case PercentageLength: return fixedValueOrPercentage * maximumLength / qreal(100);
107 inline qreal rawValue() const { return fixedValueOrPercentage; }
109 inline bool operator==(const QTextLength &other) const
110 { return lengthType == other.lengthType
111 && qFuzzyCompare(fixedValueOrPercentage, other.fixedValueOrPercentage); }
112 inline bool operator!=(const QTextLength &other) const
113 { return lengthType != other.lengthType
114 || !qFuzzyCompare(fixedValueOrPercentage, other.fixedValueOrPercentage); }
115 operator QVariant() const;
119 qreal fixedValueOrPercentage;
120 friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextLength &);
121 friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextLength &);
124 inline QTextLength::QTextLength(Type atype, qreal avalue)
125 : lengthType(atype), fixedValueOrPercentage(avalue) {}
127 #ifndef QT_NO_DATASTREAM
128 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextFormat &);
129 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextFormat &);
132 #ifndef QT_NO_DEBUG_STREAM
133 Q_GUI_EXPORT QDebug operator<<(QDebug, const QTextFormat &);
136 class Q_GUI_EXPORT QTextFormat
139 Q_ENUMS(FormatType Property ObjectTypes)
155 // paragraph and char
157 LayoutDirection = 0x0801,
160 BackgroundBrush = 0x820,
161 ForegroundBrush = 0x821,
162 // Internal to qtextlayout.cpp: ObjectSelectionBrush = 0x822
163 BackgroundImageUrl = 0x823,
166 BlockAlignment = 0x1010,
167 BlockTopMargin = 0x1030,
168 BlockBottomMargin = 0x1031,
169 BlockLeftMargin = 0x1032,
170 BlockRightMargin = 0x1033,
172 TabPositions = 0x1035,
173 BlockIndent = 0x1040,
175 LineHeightType = 0x1049,
176 BlockNonBreakableLines = 0x1050,
177 BlockTrailingHorizontalRulerWidth = 0x1060,
179 // character properties
180 FirstFontProperty = 0x1FE0,
181 FontCapitalization = FirstFontProperty,
182 FontAbsoluteLetterSpacing = 0x2033, // if true FontLetterSpacing is absolute
183 FontLetterSpacing = 0x1FE1,
184 FontWordSpacing = 0x1FE2,
185 FontStretch = 0x2034,
186 FontStyleHint = 0x1FE3,
187 FontStyleStrategy = 0x1FE4,
188 FontKerning = 0x1FE5,
189 FontHintingPreference = 0x1FE6,
191 FontPointSize = 0x2001,
192 FontSizeAdjustment = 0x2002,
193 FontSizeIncrement = FontSizeAdjustment, // old name, compat
196 FontUnderline = 0x2005, // deprecated, use TextUnderlineStyle instead
197 FontOverline = 0x2006,
198 FontStrikeOut = 0x2007,
199 FontFixedPitch = 0x2008,
200 FontPixelSize = 0x2009,
201 LastFontProperty = FontPixelSize,
203 TextUnderlineColor = 0x2010,
204 TextVerticalAlignment = 0x2021,
205 TextOutline = 0x2022,
206 TextUnderlineStyle = 0x2023,
207 TextToolTip = 0x2024,
217 ListNumberPrefix = 0x3002,
218 ListNumberSuffix = 0x3003,
220 // table and frame properties
221 FrameBorder = 0x4000,
222 FrameMargin = 0x4001,
223 FramePadding = 0x4002,
225 FrameHeight = 0x4004,
226 FrameTopMargin = 0x4005,
227 FrameBottomMargin = 0x4006,
228 FrameLeftMargin = 0x4007,
229 FrameRightMargin = 0x4008,
230 FrameBorderBrush = 0x4009,
231 FrameBorderStyle = 0x4010,
233 TableColumns = 0x4100,
234 TableColumnWidthConstraints = 0x4101,
235 TableCellSpacing = 0x4102,
236 TableCellPadding = 0x4103,
237 TableHeaderRowCount = 0x4104,
239 // table cell properties
240 TableCellRowSpan = 0x4810,
241 TableCellColumnSpan = 0x4811,
243 TableCellTopPadding = 0x4812,
244 TableCellBottomPadding = 0x4813,
245 TableCellLeftPadding = 0x4814,
246 TableCellRightPadding = 0x4815,
251 ImageHeight = 0x5011,
255 SuppressText = 0x5012,
256 SuppressBackground = 0x513
259 // selection properties
260 FullWidthSelection = 0x06000,
262 // page break properties
263 PageBreakPolicy = 0x7000,
266 UserProperty = 0x100000
280 PageBreak_AlwaysBefore = 0x001,
281 PageBreak_AlwaysAfter = 0x010
282 // PageBreak_AlwaysInside = 0x100
284 Q_DECLARE_FLAGS(PageBreakFlags, PageBreakFlag)
288 explicit QTextFormat(int type);
290 QTextFormat(const QTextFormat &rhs);
291 QTextFormat &operator=(const QTextFormat &rhs);
294 void merge(const QTextFormat &other);
296 inline bool isValid() const { return type() != InvalidFormat; }
300 int objectIndex() const;
301 void setObjectIndex(int object);
303 QVariant property(int propertyId) const;
304 void setProperty(int propertyId, const QVariant &value);
305 void clearProperty(int propertyId);
306 bool hasProperty(int propertyId) const;
308 bool boolProperty(int propertyId) const;
309 int intProperty(int propertyId) const;
310 qreal doubleProperty(int propertyId) const;
311 QString stringProperty(int propertyId) const;
312 QColor colorProperty(int propertyId) const;
313 QPen penProperty(int propertyId) const;
314 QBrush brushProperty(int propertyId) const;
315 QTextLength lengthProperty(int propertyId) const;
316 QVector<QTextLength> lengthVectorProperty(int propertyId) const;
318 void setProperty(int propertyId, const QVector<QTextLength> &lengths);
320 QMap<int, QVariant> properties() const;
321 int propertyCount() const;
323 inline void setObjectType(int type);
324 inline int objectType() const
325 { return intProperty(ObjectType); }
327 inline bool isCharFormat() const { return type() == CharFormat; }
328 inline bool isBlockFormat() const { return type() == BlockFormat; }
329 inline bool isListFormat() const { return type() == ListFormat; }
330 inline bool isFrameFormat() const { return type() == FrameFormat; }
331 inline bool isImageFormat() const { return type() == CharFormat && objectType() == ImageObject; }
332 inline bool isTableFormat() const { return type() == FrameFormat && objectType() == TableObject; }
333 inline bool isTableCellFormat() const { return type() == CharFormat && objectType() == TableCellObject; }
335 QTextBlockFormat toBlockFormat() const;
336 QTextCharFormat toCharFormat() const;
337 QTextListFormat toListFormat() const;
338 QTextTableFormat toTableFormat() const;
339 QTextFrameFormat toFrameFormat() const;
340 QTextImageFormat toImageFormat() const;
341 QTextTableCellFormat toTableCellFormat() const;
343 bool operator==(const QTextFormat &rhs) const;
344 inline bool operator!=(const QTextFormat &rhs) const { return !operator==(rhs); }
345 operator QVariant() const;
347 inline void setLayoutDirection(Qt::LayoutDirection direction)
348 { setProperty(QTextFormat::LayoutDirection, direction); }
349 inline Qt::LayoutDirection layoutDirection() const
350 { return Qt::LayoutDirection(intProperty(QTextFormat::LayoutDirection)); }
352 inline void setBackground(const QBrush &brush)
353 { setProperty(BackgroundBrush, brush); }
354 inline QBrush background() const
355 { return brushProperty(BackgroundBrush); }
356 inline void clearBackground()
357 { clearProperty(BackgroundBrush); }
359 inline void setForeground(const QBrush &brush)
360 { setProperty(ForegroundBrush, brush); }
361 inline QBrush foreground() const
362 { return brushProperty(ForegroundBrush); }
363 inline void clearForeground()
364 { clearProperty(ForegroundBrush); }
367 QSharedDataPointer<QTextFormatPrivate> d;
370 friend class QTextFormatCollection;
371 friend class QTextCharFormat;
372 friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextFormat &);
373 friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextFormat &);
376 inline void QTextFormat::setObjectType(int atype)
377 { setProperty(ObjectType, atype); }
379 Q_DECLARE_OPERATORS_FOR_FLAGS(QTextFormat::PageBreakFlags)
381 class Q_GUI_EXPORT QTextCharFormat : public QTextFormat
384 enum VerticalAlignment {
393 enum UnderlineStyle { // keep in sync with Qt::PenStyle!
406 bool isValid() const { return isCharFormat(); }
407 void setFont(const QFont &font);
410 inline void setFontFamily(const QString &family)
411 { setProperty(FontFamily, family); }
412 inline QString fontFamily() const
413 { return stringProperty(FontFamily); }
415 inline void setFontPointSize(qreal size)
416 { setProperty(FontPointSize, size); }
417 inline qreal fontPointSize() const
418 { return doubleProperty(FontPointSize); }
420 inline void setFontWeight(int weight)
421 { if (weight == QFont::Normal) weight = 0; setProperty(FontWeight, weight); }
422 inline int fontWeight() const
423 { int weight = intProperty(FontWeight); if (weight == 0) weight = QFont::Normal; return weight; }
424 inline void setFontItalic(bool italic)
425 { setProperty(FontItalic, italic); }
426 inline bool fontItalic() const
427 { return boolProperty(FontItalic); }
428 inline void setFontCapitalization(QFont::Capitalization capitalization)
429 { setProperty(FontCapitalization, capitalization); }
430 inline QFont::Capitalization fontCapitalization() const
431 { return static_cast<QFont::Capitalization>(intProperty(FontCapitalization)); }
432 inline void setFontAbsoluteLetterSpacing(qreal absoluteSpacing)
433 { setProperty(FontAbsoluteLetterSpacing, absoluteSpacing);
434 clearProperty(FontLetterSpacing); }
435 inline qreal fontAbsoluteLetterSpacing() const
436 { return doubleProperty(FontAbsoluteLetterSpacing); }
437 inline void setFontLetterSpacing(qreal spacing)
438 { setProperty(FontLetterSpacing, spacing);
439 clearProperty(FontAbsoluteLetterSpacing); }
440 inline qreal fontLetterSpacing() const
441 { return doubleProperty(FontLetterSpacing); }
442 inline void setFontWordSpacing(qreal spacing)
443 { setProperty(FontWordSpacing, spacing); }
444 inline qreal fontWordSpacing() const
445 { return doubleProperty(FontWordSpacing); }
447 inline void setFontUnderline(bool underline)
448 { setProperty(TextUnderlineStyle, underline ? SingleUnderline : NoUnderline); }
449 bool fontUnderline() const;
451 inline void setFontOverline(bool overline)
452 { setProperty(FontOverline, overline); }
453 inline bool fontOverline() const
454 { return boolProperty(FontOverline); }
456 inline void setFontStrikeOut(bool strikeOut)
457 { setProperty(FontStrikeOut, strikeOut); }
458 inline bool fontStrikeOut() const
459 { return boolProperty(FontStrikeOut); }
461 inline void setUnderlineColor(const QColor &color)
462 { setProperty(TextUnderlineColor, color); }
463 inline QColor underlineColor() const
464 { return colorProperty(TextUnderlineColor); }
466 inline void setFontFixedPitch(bool fixedPitch)
467 { setProperty(FontFixedPitch, fixedPitch); }
468 inline bool fontFixedPitch() const
469 { return boolProperty(FontFixedPitch); }
471 inline void setFontStretch(qreal factor)
472 { setProperty(FontStretch, factor); }
473 inline int fontStretch() const
474 { return intProperty(FontStretch); }
476 inline void setFontStyleHint(QFont::StyleHint hint, QFont::StyleStrategy strategy = QFont::PreferDefault)
477 { setProperty(FontStyleHint, hint); setProperty(FontStyleStrategy, strategy); }
478 inline void setFontStyleStrategy(QFont::StyleStrategy strategy)
479 { setProperty(FontStyleStrategy, strategy); }
480 QFont::StyleHint fontStyleHint() const
481 { return static_cast<QFont::StyleHint>(intProperty(FontStyleHint)); }
482 QFont::StyleStrategy fontStyleStrategy() const
483 { return static_cast<QFont::StyleStrategy>(intProperty(FontStyleStrategy)); }
485 inline void setFontHintingPreference(QFont::HintingPreference hintingPreference)
487 setProperty(FontHintingPreference, hintingPreference);
490 inline QFont::HintingPreference fontHintingPreference() const
492 return static_cast<QFont::HintingPreference>(intProperty(FontHintingPreference));
495 inline void setFontKerning(bool enable)
496 { setProperty(FontKerning, enable); }
497 inline bool fontKerning() const
498 { return boolProperty(FontKerning); }
500 void setUnderlineStyle(UnderlineStyle style);
501 inline UnderlineStyle underlineStyle() const
502 { return static_cast<UnderlineStyle>(intProperty(TextUnderlineStyle)); }
504 inline void setVerticalAlignment(VerticalAlignment alignment)
505 { setProperty(TextVerticalAlignment, alignment); }
506 inline VerticalAlignment verticalAlignment() const
507 { return static_cast<VerticalAlignment>(intProperty(TextVerticalAlignment)); }
509 inline void setTextOutline(const QPen &pen)
510 { setProperty(TextOutline, pen); }
511 inline QPen textOutline() const
512 { return penProperty(TextOutline); }
514 inline void setToolTip(const QString &tip)
515 { setProperty(TextToolTip, tip); }
516 inline QString toolTip() const
517 { return stringProperty(TextToolTip); }
519 inline void setAnchor(bool anchor)
520 { setProperty(IsAnchor, anchor); }
521 inline bool isAnchor() const
522 { return boolProperty(IsAnchor); }
524 inline void setAnchorHref(const QString &value)
525 { setProperty(AnchorHref, value); }
526 inline QString anchorHref() const
527 { return stringProperty(AnchorHref); }
529 inline void setAnchorName(const QString &name)
530 { setAnchorNames(QStringList(name)); }
531 QString anchorName() const;
533 inline void setAnchorNames(const QStringList &names)
534 { setProperty(AnchorName, names); }
535 QStringList anchorNames() const;
537 inline void setTableCellRowSpan(int tableCellRowSpan);
538 inline int tableCellRowSpan() const
539 { int s = intProperty(TableCellRowSpan); if (s == 0) s = 1; return s; }
540 inline void setTableCellColumnSpan(int tableCellColumnSpan);
541 inline int tableCellColumnSpan() const
542 { int s = intProperty(TableCellColumnSpan); if (s == 0) s = 1; return s; }
545 explicit QTextCharFormat(const QTextFormat &fmt);
546 friend class QTextFormat;
549 inline void QTextCharFormat::setTableCellRowSpan(int _tableCellRowSpan)
551 if (_tableCellRowSpan <= 1)
552 clearProperty(TableCellRowSpan); // the getter will return 1 here.
554 setProperty(TableCellRowSpan, _tableCellRowSpan);
557 inline void QTextCharFormat::setTableCellColumnSpan(int _tableCellColumnSpan)
559 if (_tableCellColumnSpan <= 1)
560 clearProperty(TableCellColumnSpan); // the getter will return 1 here.
562 setProperty(TableCellColumnSpan, _tableCellColumnSpan);
565 class Q_GUI_EXPORT QTextBlockFormat : public QTextFormat
568 enum LineHeightTypes {
570 ProportionalHeight = 1,
573 LineDistanceHeight = 4
578 bool isValid() const { return isBlockFormat(); }
580 inline void setAlignment(Qt::Alignment alignment);
581 inline Qt::Alignment alignment() const
582 { int a = intProperty(BlockAlignment); if (a == 0) a = Qt::AlignLeft; return QFlag(a); }
584 inline void setTopMargin(qreal margin)
585 { setProperty(BlockTopMargin, margin); }
586 inline qreal topMargin() const
587 { return doubleProperty(BlockTopMargin); }
589 inline void setBottomMargin(qreal margin)
590 { setProperty(BlockBottomMargin, margin); }
591 inline qreal bottomMargin() const
592 { return doubleProperty(BlockBottomMargin); }
594 inline void setLeftMargin(qreal margin)
595 { setProperty(BlockLeftMargin, margin); }
596 inline qreal leftMargin() const
597 { return doubleProperty(BlockLeftMargin); }
599 inline void setRightMargin(qreal margin)
600 { setProperty(BlockRightMargin, margin); }
601 inline qreal rightMargin() const
602 { return doubleProperty(BlockRightMargin); }
604 inline void setTextIndent(qreal aindent)
605 { setProperty(TextIndent, aindent); }
606 inline qreal textIndent() const
607 { return doubleProperty(TextIndent); }
609 inline void setIndent(int indent);
610 inline int indent() const
611 { return intProperty(BlockIndent); }
613 inline void setLineHeight(qreal height, int heightType)
614 { setProperty(LineHeight, height); setProperty(LineHeightType, heightType); }
615 inline qreal lineHeight(qreal scriptLineHeight, qreal scaling) const;
616 inline qreal lineHeight() const
617 { return doubleProperty(LineHeight); }
618 inline int lineHeightType() const
619 { return intProperty(LineHeightType); }
621 inline void setNonBreakableLines(bool b)
622 { setProperty(BlockNonBreakableLines, b); }
623 inline bool nonBreakableLines() const
624 { return boolProperty(BlockNonBreakableLines); }
626 inline void setPageBreakPolicy(PageBreakFlags flags)
627 { setProperty(PageBreakPolicy, int(flags)); }
628 inline PageBreakFlags pageBreakPolicy() const
629 { return PageBreakFlags(intProperty(PageBreakPolicy)); }
631 void setTabPositions(const QList<QTextOption::Tab> &tabs);
632 QList<QTextOption::Tab> tabPositions() const;
635 explicit QTextBlockFormat(const QTextFormat &fmt);
636 friend class QTextFormat;
639 inline void QTextBlockFormat::setAlignment(Qt::Alignment aalignment)
640 { setProperty(BlockAlignment, int(aalignment)); }
642 inline void QTextBlockFormat::setIndent(int aindent)
643 { setProperty(BlockIndent, aindent); }
645 inline qreal QTextBlockFormat::lineHeight(qreal scriptLineHeight, qreal scaling = 1.0) const
647 switch(intProperty(LineHeightType)) {
649 return(scriptLineHeight);
650 case ProportionalHeight:
651 return(scriptLineHeight * doubleProperty(LineHeight) / 100.0);
653 return(doubleProperty(LineHeight) * scaling);
655 return(qMax(scriptLineHeight, doubleProperty(LineHeight) * scaling));
656 case LineDistanceHeight:
657 return(scriptLineHeight + doubleProperty(LineHeight) * scaling);
662 class Q_GUI_EXPORT QTextListFormat : public QTextFormat
667 bool isValid() const { return isListFormat(); }
678 ListStyleUndefined = 0
681 inline void setStyle(Style style);
682 inline Style style() const
683 { return static_cast<Style>(intProperty(ListStyle)); }
685 inline void setIndent(int indent);
686 inline int indent() const
687 { return intProperty(ListIndent); }
689 inline void setNumberPrefix(const QString &numberPrefix);
690 inline QString numberPrefix() const
691 { return stringProperty(ListNumberPrefix); }
693 inline void setNumberSuffix(const QString &numberSuffix);
694 inline QString numberSuffix() const
695 { return stringProperty(ListNumberSuffix); }
698 explicit QTextListFormat(const QTextFormat &fmt);
699 friend class QTextFormat;
702 inline void QTextListFormat::setStyle(Style astyle)
703 { setProperty(ListStyle, astyle); }
705 inline void QTextListFormat::setIndent(int aindent)
706 { setProperty(ListIndent, aindent); }
708 inline void QTextListFormat::setNumberPrefix(const QString &np)
709 { setProperty(ListNumberPrefix, np); }
711 inline void QTextListFormat::setNumberSuffix(const QString &ns)
712 { setProperty(ListNumberSuffix, ns); }
714 class Q_GUI_EXPORT QTextImageFormat : public QTextCharFormat
719 bool isValid() const { return isImageFormat(); }
721 inline void setName(const QString &name);
722 inline QString name() const
723 { return stringProperty(ImageName); }
725 inline void setWidth(qreal width);
726 inline qreal width() const
727 { return doubleProperty(ImageWidth); }
729 inline void setHeight(qreal height);
730 inline qreal height() const
731 { return doubleProperty(ImageHeight); }
734 explicit QTextImageFormat(const QTextFormat &format);
735 friend class QTextFormat;
738 inline void QTextImageFormat::setName(const QString &aname)
739 { setProperty(ImageName, aname); }
741 inline void QTextImageFormat::setWidth(qreal awidth)
742 { setProperty(ImageWidth, awidth); }
744 inline void QTextImageFormat::setHeight(qreal aheight)
745 { setProperty(ImageHeight, aheight); }
747 class Q_GUI_EXPORT QTextFrameFormat : public QTextFormat
752 bool isValid() const { return isFrameFormat(); }
769 BorderStyle_DotDotDash,
776 inline void setPosition(Position f)
777 { setProperty(CssFloat, f); }
778 inline Position position() const
779 { return static_cast<Position>(intProperty(CssFloat)); }
781 inline void setBorder(qreal border);
782 inline qreal border() const
783 { return doubleProperty(FrameBorder); }
785 inline void setBorderBrush(const QBrush &brush)
786 { setProperty(FrameBorderBrush, brush); }
787 inline QBrush borderBrush() const
788 { return brushProperty(FrameBorderBrush); }
790 inline void setBorderStyle(BorderStyle style)
791 { setProperty(FrameBorderStyle, style); }
792 inline BorderStyle borderStyle() const
793 { return static_cast<BorderStyle>(intProperty(FrameBorderStyle)); }
795 void setMargin(qreal margin);
796 inline qreal margin() const
797 { return doubleProperty(FrameMargin); }
799 inline void setTopMargin(qreal margin);
800 qreal topMargin() const;
802 inline void setBottomMargin(qreal margin);
803 qreal bottomMargin() const;
805 inline void setLeftMargin(qreal margin);
806 qreal leftMargin() const;
808 inline void setRightMargin(qreal margin);
809 qreal rightMargin() const;
811 inline void setPadding(qreal padding);
812 inline qreal padding() const
813 { return doubleProperty(FramePadding); }
815 inline void setWidth(qreal width);
816 inline void setWidth(const QTextLength &length)
817 { setProperty(FrameWidth, length); }
818 inline QTextLength width() const
819 { return lengthProperty(FrameWidth); }
821 inline void setHeight(qreal height);
822 inline void setHeight(const QTextLength &height);
823 inline QTextLength height() const
824 { return lengthProperty(FrameHeight); }
826 inline void setPageBreakPolicy(PageBreakFlags flags)
827 { setProperty(PageBreakPolicy, int(flags)); }
828 inline PageBreakFlags pageBreakPolicy() const
829 { return PageBreakFlags(intProperty(PageBreakPolicy)); }
832 explicit QTextFrameFormat(const QTextFormat &fmt);
833 friend class QTextFormat;
836 inline void QTextFrameFormat::setBorder(qreal aborder)
837 { setProperty(FrameBorder, aborder); }
839 inline void QTextFrameFormat::setPadding(qreal apadding)
840 { setProperty(FramePadding, apadding); }
842 inline void QTextFrameFormat::setWidth(qreal awidth)
843 { setProperty(FrameWidth, QTextLength(QTextLength::FixedLength, awidth)); }
845 inline void QTextFrameFormat::setHeight(qreal aheight)
846 { setProperty(FrameHeight, QTextLength(QTextLength::FixedLength, aheight)); }
847 inline void QTextFrameFormat::setHeight(const QTextLength &aheight)
848 { setProperty(FrameHeight, aheight); }
850 inline void QTextFrameFormat::setTopMargin(qreal amargin)
851 { setProperty(FrameTopMargin, amargin); }
853 inline void QTextFrameFormat::setBottomMargin(qreal amargin)
854 { setProperty(FrameBottomMargin, amargin); }
856 inline void QTextFrameFormat::setLeftMargin(qreal amargin)
857 { setProperty(FrameLeftMargin, amargin); }
859 inline void QTextFrameFormat::setRightMargin(qreal amargin)
860 { setProperty(FrameRightMargin, amargin); }
862 class Q_GUI_EXPORT QTextTableFormat : public QTextFrameFormat
867 inline bool isValid() const { return isTableFormat(); }
869 inline int columns() const
870 { int cols = intProperty(TableColumns); if (cols == 0) cols = 1; return cols; }
871 inline void setColumns(int columns);
873 inline void setColumnWidthConstraints(const QVector<QTextLength> &constraints)
874 { setProperty(TableColumnWidthConstraints, constraints); }
876 inline QVector<QTextLength> columnWidthConstraints() const
877 { return lengthVectorProperty(TableColumnWidthConstraints); }
879 inline void clearColumnWidthConstraints()
880 { clearProperty(TableColumnWidthConstraints); }
882 inline qreal cellSpacing() const
883 { return doubleProperty(TableCellSpacing); }
884 inline void setCellSpacing(qreal spacing)
885 { setProperty(TableCellSpacing, spacing); }
887 inline qreal cellPadding() const
888 { return doubleProperty(TableCellPadding); }
889 inline void setCellPadding(qreal padding);
891 inline void setAlignment(Qt::Alignment alignment);
892 inline Qt::Alignment alignment() const
893 { return QFlag(intProperty(BlockAlignment)); }
895 inline void setHeaderRowCount(int count)
896 { setProperty(TableHeaderRowCount, count); }
897 inline int headerRowCount() const
898 { return intProperty(TableHeaderRowCount); }
901 explicit QTextTableFormat(const QTextFormat &fmt);
902 friend class QTextFormat;
905 inline void QTextTableFormat::setColumns(int acolumns)
909 setProperty(TableColumns, acolumns);
912 inline void QTextTableFormat::setCellPadding(qreal apadding)
913 { setProperty(TableCellPadding, apadding); }
915 inline void QTextTableFormat::setAlignment(Qt::Alignment aalignment)
916 { setProperty(BlockAlignment, int(aalignment)); }
918 class Q_GUI_EXPORT QTextTableCellFormat : public QTextCharFormat
921 QTextTableCellFormat();
923 inline bool isValid() const { return isTableCellFormat(); }
925 inline void setTopPadding(qreal padding);
926 inline qreal topPadding() const;
928 inline void setBottomPadding(qreal padding);
929 inline qreal bottomPadding() const;
931 inline void setLeftPadding(qreal padding);
932 inline qreal leftPadding() const;
934 inline void setRightPadding(qreal padding);
935 inline qreal rightPadding() const;
937 inline void setPadding(qreal padding);
940 explicit QTextTableCellFormat(const QTextFormat &fmt);
941 friend class QTextFormat;
944 inline void QTextTableCellFormat::setTopPadding(qreal padding)
946 setProperty(TableCellTopPadding, padding);
949 inline qreal QTextTableCellFormat::topPadding() const
951 return doubleProperty(TableCellTopPadding);
954 inline void QTextTableCellFormat::setBottomPadding(qreal padding)
956 setProperty(TableCellBottomPadding, padding);
959 inline qreal QTextTableCellFormat::bottomPadding() const
961 return doubleProperty(TableCellBottomPadding);
964 inline void QTextTableCellFormat::setLeftPadding(qreal padding)
966 setProperty(TableCellLeftPadding, padding);
969 inline qreal QTextTableCellFormat::leftPadding() const
971 return doubleProperty(TableCellLeftPadding);
974 inline void QTextTableCellFormat::setRightPadding(qreal padding)
976 setProperty(TableCellRightPadding, padding);
979 inline qreal QTextTableCellFormat::rightPadding() const
981 return doubleProperty(TableCellRightPadding);
984 inline void QTextTableCellFormat::setPadding(qreal padding)
986 setTopPadding(padding);
987 setBottomPadding(padding);
988 setLeftPadding(padding);
989 setRightPadding(padding);
997 #endif // QTEXTFORMAT_H