1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtGui module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** 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>
64 class QTextFormatCollection;
65 class QTextFormatPrivate;
66 class QTextBlockFormat;
67 class QTextCharFormat;
68 class QTextListFormat;
69 class QTextTableFormat;
70 class QTextFrameFormat;
71 class QTextImageFormat;
72 class QTextTableCellFormat;
79 #ifndef QT_NO_DATASTREAM
80 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextLength &);
81 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextLength &);
84 class Q_GUI_EXPORT QTextLength
87 enum Type { VariableLength = 0, FixedLength, PercentageLength };
89 inline QTextLength() : lengthType(VariableLength), fixedValueOrPercentage(0) {}
91 inline explicit QTextLength(Type type, qreal value);
93 inline Type type() const { return lengthType; }
94 inline qreal value(qreal maximumLength) const
97 case FixedLength: return fixedValueOrPercentage;
98 case VariableLength: return maximumLength;
99 case PercentageLength: return fixedValueOrPercentage * maximumLength / qreal(100);
104 inline qreal rawValue() const { return fixedValueOrPercentage; }
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;
116 qreal fixedValueOrPercentage;
117 friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextLength &);
118 friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextLength &);
121 inline QTextLength::QTextLength(Type atype, qreal avalue)
122 : lengthType(atype), fixedValueOrPercentage(avalue) {}
124 #ifndef QT_NO_DATASTREAM
125 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextFormat &);
126 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextFormat &);
129 class Q_GUI_EXPORT QTextFormat
132 Q_ENUMS(FormatType Property ObjectTypes)
148 // paragraph and char
150 LayoutDirection = 0x0801,
153 BackgroundBrush = 0x820,
154 ForegroundBrush = 0x821,
155 // Internal to qtextlayout.cpp: ObjectSelectionBrush = 0x822
156 BackgroundImageUrl = 0x823,
159 BlockAlignment = 0x1010,
160 BlockTopMargin = 0x1030,
161 BlockBottomMargin = 0x1031,
162 BlockLeftMargin = 0x1032,
163 BlockRightMargin = 0x1033,
165 TabPositions = 0x1035,
166 BlockIndent = 0x1040,
168 LineHeightType = 0x1049,
169 BlockNonBreakableLines = 0x1050,
170 BlockTrailingHorizontalRulerWidth = 0x1060,
172 // character properties
173 FirstFontProperty = 0x1FE0,
174 FontCapitalization = FirstFontProperty,
175 FontLetterSpacing = 0x1FE1,
176 FontWordSpacing = 0x1FE2,
177 FontStyleHint = 0x1FE3,
178 FontStyleStrategy = 0x1FE4,
179 FontKerning = 0x1FE5,
180 FontHintingPreference = 0x1FE6,
182 FontPointSize = 0x2001,
183 FontSizeAdjustment = 0x2002,
184 FontSizeIncrement = FontSizeAdjustment, // old name, compat
187 FontUnderline = 0x2005, // deprecated, use TextUnderlineStyle instead
188 FontOverline = 0x2006,
189 FontStrikeOut = 0x2007,
190 FontFixedPitch = 0x2008,
191 FontPixelSize = 0x2009,
192 LastFontProperty = FontPixelSize,
194 TextUnderlineColor = 0x2010,
195 TextVerticalAlignment = 0x2021,
196 TextOutline = 0x2022,
197 TextUnderlineStyle = 0x2023,
198 TextToolTip = 0x2024,
208 ListNumberPrefix = 0x3002,
209 ListNumberSuffix = 0x3003,
211 // table and frame properties
212 FrameBorder = 0x4000,
213 FrameMargin = 0x4001,
214 FramePadding = 0x4002,
216 FrameHeight = 0x4004,
217 FrameTopMargin = 0x4005,
218 FrameBottomMargin = 0x4006,
219 FrameLeftMargin = 0x4007,
220 FrameRightMargin = 0x4008,
221 FrameBorderBrush = 0x4009,
222 FrameBorderStyle = 0x4010,
224 TableColumns = 0x4100,
225 TableColumnWidthConstraints = 0x4101,
226 TableCellSpacing = 0x4102,
227 TableCellPadding = 0x4103,
228 TableHeaderRowCount = 0x4104,
230 // table cell properties
231 TableCellRowSpan = 0x4810,
232 TableCellColumnSpan = 0x4811,
234 TableCellTopPadding = 0x4812,
235 TableCellBottomPadding = 0x4813,
236 TableCellLeftPadding = 0x4814,
237 TableCellRightPadding = 0x4815,
242 ImageHeight = 0x5011,
246 SuppressText = 0x5012,
247 SuppressBackground = 0x513
250 // selection properties
251 FullWidthSelection = 0x06000,
253 // page break properties
254 PageBreakPolicy = 0x7000,
257 UserProperty = 0x100000
271 PageBreak_AlwaysBefore = 0x001,
272 PageBreak_AlwaysAfter = 0x010
273 // PageBreak_AlwaysInside = 0x100
275 Q_DECLARE_FLAGS(PageBreakFlags, PageBreakFlag)
279 explicit QTextFormat(int type);
281 QTextFormat(const QTextFormat &rhs);
282 QTextFormat &operator=(const QTextFormat &rhs);
285 void merge(const QTextFormat &other);
287 inline bool isValid() const { return type() != InvalidFormat; }
291 int objectIndex() const;
292 void setObjectIndex(int object);
294 QVariant property(int propertyId) const;
295 void setProperty(int propertyId, const QVariant &value);
296 void clearProperty(int propertyId);
297 bool hasProperty(int propertyId) const;
299 bool boolProperty(int propertyId) const;
300 int intProperty(int propertyId) const;
301 qreal doubleProperty(int propertyId) const;
302 QString stringProperty(int propertyId) const;
303 QColor colorProperty(int propertyId) const;
304 QPen penProperty(int propertyId) const;
305 QBrush brushProperty(int propertyId) const;
306 QTextLength lengthProperty(int propertyId) const;
307 QVector<QTextLength> lengthVectorProperty(int propertyId) const;
309 void setProperty(int propertyId, const QVector<QTextLength> &lengths);
311 QMap<int, QVariant> properties() const;
312 int propertyCount() const;
314 inline void setObjectType(int type);
315 inline int objectType() const
316 { return intProperty(ObjectType); }
318 inline bool isCharFormat() const { return type() == CharFormat; }
319 inline bool isBlockFormat() const { return type() == BlockFormat; }
320 inline bool isListFormat() const { return type() == ListFormat; }
321 inline bool isFrameFormat() const { return type() == FrameFormat; }
322 inline bool isImageFormat() const { return type() == CharFormat && objectType() == ImageObject; }
323 inline bool isTableFormat() const { return type() == FrameFormat && objectType() == TableObject; }
324 inline bool isTableCellFormat() const { return type() == CharFormat && objectType() == TableCellObject; }
326 QTextBlockFormat toBlockFormat() const;
327 QTextCharFormat toCharFormat() const;
328 QTextListFormat toListFormat() const;
329 QTextTableFormat toTableFormat() const;
330 QTextFrameFormat toFrameFormat() const;
331 QTextImageFormat toImageFormat() const;
332 QTextTableCellFormat toTableCellFormat() const;
334 bool operator==(const QTextFormat &rhs) const;
335 inline bool operator!=(const QTextFormat &rhs) const { return !operator==(rhs); }
336 operator QVariant() const;
338 inline void setLayoutDirection(Qt::LayoutDirection direction)
339 { setProperty(QTextFormat::LayoutDirection, direction); }
340 inline Qt::LayoutDirection layoutDirection() const
341 { return Qt::LayoutDirection(intProperty(QTextFormat::LayoutDirection)); }
343 inline void setBackground(const QBrush &brush)
344 { setProperty(BackgroundBrush, brush); }
345 inline QBrush background() const
346 { return brushProperty(BackgroundBrush); }
347 inline void clearBackground()
348 { clearProperty(BackgroundBrush); }
350 inline void setForeground(const QBrush &brush)
351 { setProperty(ForegroundBrush, brush); }
352 inline QBrush foreground() const
353 { return brushProperty(ForegroundBrush); }
354 inline void clearForeground()
355 { clearProperty(ForegroundBrush); }
358 QSharedDataPointer<QTextFormatPrivate> d;
361 friend class QTextFormatCollection;
362 friend class QTextCharFormat;
363 friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextFormat &);
364 friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextFormat &);
367 inline void QTextFormat::setObjectType(int atype)
368 { setProperty(ObjectType, atype); }
370 Q_DECLARE_OPERATORS_FOR_FLAGS(QTextFormat::PageBreakFlags)
372 class Q_GUI_EXPORT QTextCharFormat : public QTextFormat
375 enum VerticalAlignment {
384 enum UnderlineStyle { // keep in sync with Qt::PenStyle!
397 bool isValid() const { return isCharFormat(); }
398 void setFont(const QFont &font);
401 inline void setFontFamily(const QString &family)
402 { setProperty(FontFamily, family); }
403 inline QString fontFamily() const
404 { return stringProperty(FontFamily); }
406 inline void setFontPointSize(qreal size)
407 { setProperty(FontPointSize, size); }
408 inline qreal fontPointSize() const
409 { return doubleProperty(FontPointSize); }
411 inline void setFontWeight(int weight)
412 { if (weight == QFont::Normal) weight = 0; setProperty(FontWeight, weight); }
413 inline int fontWeight() const
414 { int weight = intProperty(FontWeight); if (weight == 0) weight = QFont::Normal; return weight; }
415 inline void setFontItalic(bool italic)
416 { setProperty(FontItalic, italic); }
417 inline bool fontItalic() const
418 { return boolProperty(FontItalic); }
419 inline void setFontCapitalization(QFont::Capitalization capitalization)
420 { setProperty(FontCapitalization, capitalization); }
421 inline QFont::Capitalization fontCapitalization() const
422 { return static_cast<QFont::Capitalization>(intProperty(FontCapitalization)); }
423 inline void setFontLetterSpacing(qreal spacing)
424 { setProperty(FontLetterSpacing, spacing); }
425 inline qreal fontLetterSpacing() const
426 { return doubleProperty(FontLetterSpacing); }
427 inline void setFontWordSpacing(qreal spacing)
428 { setProperty(FontWordSpacing, spacing); }
429 inline qreal fontWordSpacing() const
430 { return doubleProperty(FontWordSpacing); }
432 inline void setFontUnderline(bool underline)
433 { setProperty(TextUnderlineStyle, underline ? SingleUnderline : NoUnderline); }
434 bool fontUnderline() const;
436 inline void setFontOverline(bool overline)
437 { setProperty(FontOverline, overline); }
438 inline bool fontOverline() const
439 { return boolProperty(FontOverline); }
441 inline void setFontStrikeOut(bool strikeOut)
442 { setProperty(FontStrikeOut, strikeOut); }
443 inline bool fontStrikeOut() const
444 { return boolProperty(FontStrikeOut); }
446 inline void setUnderlineColor(const QColor &color)
447 { setProperty(TextUnderlineColor, color); }
448 inline QColor underlineColor() const
449 { return colorProperty(TextUnderlineColor); }
451 inline void setFontFixedPitch(bool fixedPitch)
452 { setProperty(FontFixedPitch, fixedPitch); }
453 inline bool fontFixedPitch() const
454 { return boolProperty(FontFixedPitch); }
456 inline void setFontStyleHint(QFont::StyleHint hint, QFont::StyleStrategy strategy = QFont::PreferDefault)
457 { setProperty(FontStyleHint, hint); setProperty(FontStyleStrategy, strategy); }
458 inline void setFontStyleStrategy(QFont::StyleStrategy strategy)
459 { setProperty(FontStyleStrategy, strategy); }
460 QFont::StyleHint fontStyleHint() const
461 { return static_cast<QFont::StyleHint>(intProperty(FontStyleHint)); }
462 QFont::StyleStrategy fontStyleStrategy() const
463 { return static_cast<QFont::StyleStrategy>(intProperty(FontStyleStrategy)); }
465 inline void setFontHintingPreference(QFont::HintingPreference hintingPreference)
467 setProperty(FontHintingPreference, hintingPreference);
470 inline QFont::HintingPreference fontHintingPreference() const
472 return static_cast<QFont::HintingPreference>(intProperty(FontHintingPreference));
475 inline void setFontKerning(bool enable)
476 { setProperty(FontKerning, enable); }
477 inline bool fontKerning() const
478 { return boolProperty(FontKerning); }
480 void setUnderlineStyle(UnderlineStyle style);
481 inline UnderlineStyle underlineStyle() const
482 { return static_cast<UnderlineStyle>(intProperty(TextUnderlineStyle)); }
484 inline void setVerticalAlignment(VerticalAlignment alignment)
485 { setProperty(TextVerticalAlignment, alignment); }
486 inline VerticalAlignment verticalAlignment() const
487 { return static_cast<VerticalAlignment>(intProperty(TextVerticalAlignment)); }
489 inline void setTextOutline(const QPen &pen)
490 { setProperty(TextOutline, pen); }
491 inline QPen textOutline() const
492 { return penProperty(TextOutline); }
494 inline void setToolTip(const QString &tip)
495 { setProperty(TextToolTip, tip); }
496 inline QString toolTip() const
497 { return stringProperty(TextToolTip); }
499 inline void setAnchor(bool anchor)
500 { setProperty(IsAnchor, anchor); }
501 inline bool isAnchor() const
502 { return boolProperty(IsAnchor); }
504 inline void setAnchorHref(const QString &value)
505 { setProperty(AnchorHref, value); }
506 inline QString anchorHref() const
507 { return stringProperty(AnchorHref); }
509 inline void setAnchorName(const QString &name)
510 { setAnchorNames(QStringList(name)); }
511 QString anchorName() const;
513 inline void setAnchorNames(const QStringList &names)
514 { setProperty(AnchorName, names); }
515 QStringList anchorNames() const;
517 inline void setTableCellRowSpan(int tableCellRowSpan);
518 inline int tableCellRowSpan() const
519 { int s = intProperty(TableCellRowSpan); if (s == 0) s = 1; return s; }
520 inline void setTableCellColumnSpan(int tableCellColumnSpan);
521 inline int tableCellColumnSpan() const
522 { int s = intProperty(TableCellColumnSpan); if (s == 0) s = 1; return s; }
525 explicit QTextCharFormat(const QTextFormat &fmt);
526 friend class QTextFormat;
529 inline void QTextCharFormat::setTableCellRowSpan(int _tableCellRowSpan)
531 if (_tableCellRowSpan <= 1)
532 clearProperty(TableCellRowSpan); // the getter will return 1 here.
534 setProperty(TableCellRowSpan, _tableCellRowSpan);
537 inline void QTextCharFormat::setTableCellColumnSpan(int _tableCellColumnSpan)
539 if (_tableCellColumnSpan <= 1)
540 clearProperty(TableCellColumnSpan); // the getter will return 1 here.
542 setProperty(TableCellColumnSpan, _tableCellColumnSpan);
545 class Q_GUI_EXPORT QTextBlockFormat : public QTextFormat
548 enum LineHeightTypes {
550 ProportionalHeight = 1,
553 LineDistanceHeight = 4
558 bool isValid() const { return isBlockFormat(); }
560 inline void setAlignment(Qt::Alignment alignment);
561 inline Qt::Alignment alignment() const
562 { int a = intProperty(BlockAlignment); if (a == 0) a = Qt::AlignLeft; return QFlag(a); }
564 inline void setTopMargin(qreal margin)
565 { setProperty(BlockTopMargin, margin); }
566 inline qreal topMargin() const
567 { return doubleProperty(BlockTopMargin); }
569 inline void setBottomMargin(qreal margin)
570 { setProperty(BlockBottomMargin, margin); }
571 inline qreal bottomMargin() const
572 { return doubleProperty(BlockBottomMargin); }
574 inline void setLeftMargin(qreal margin)
575 { setProperty(BlockLeftMargin, margin); }
576 inline qreal leftMargin() const
577 { return doubleProperty(BlockLeftMargin); }
579 inline void setRightMargin(qreal margin)
580 { setProperty(BlockRightMargin, margin); }
581 inline qreal rightMargin() const
582 { return doubleProperty(BlockRightMargin); }
584 inline void setTextIndent(qreal aindent)
585 { setProperty(TextIndent, aindent); }
586 inline qreal textIndent() const
587 { return doubleProperty(TextIndent); }
589 inline void setIndent(int indent);
590 inline int indent() const
591 { return intProperty(BlockIndent); }
593 inline void setLineHeight(qreal height, int heightType)
594 { setProperty(LineHeight, height); setProperty(LineHeightType, heightType); }
595 inline qreal lineHeight(qreal scriptLineHeight, qreal scaling) const;
596 inline qreal lineHeight() const
597 { return doubleProperty(LineHeight); }
598 inline int lineHeightType() const
599 { return intProperty(LineHeightType); }
601 inline void setNonBreakableLines(bool b)
602 { setProperty(BlockNonBreakableLines, b); }
603 inline bool nonBreakableLines() const
604 { return boolProperty(BlockNonBreakableLines); }
606 inline void setPageBreakPolicy(PageBreakFlags flags)
607 { setProperty(PageBreakPolicy, int(flags)); }
608 inline PageBreakFlags pageBreakPolicy() const
609 { return PageBreakFlags(intProperty(PageBreakPolicy)); }
611 void setTabPositions(const QList<QTextOption::Tab> &tabs);
612 QList<QTextOption::Tab> tabPositions() const;
615 explicit QTextBlockFormat(const QTextFormat &fmt);
616 friend class QTextFormat;
619 inline void QTextBlockFormat::setAlignment(Qt::Alignment aalignment)
620 { setProperty(BlockAlignment, int(aalignment)); }
622 inline void QTextBlockFormat::setIndent(int aindent)
623 { setProperty(BlockIndent, aindent); }
625 inline qreal QTextBlockFormat::lineHeight(qreal scriptLineHeight, qreal scaling = 1.0) const
627 switch(intProperty(LineHeightType)) {
629 return(scriptLineHeight);
630 case ProportionalHeight:
631 return(scriptLineHeight * doubleProperty(LineHeight) / 100.0);
633 return(doubleProperty(LineHeight) * scaling);
635 return(qMax(scriptLineHeight, doubleProperty(LineHeight) * scaling));
636 case LineDistanceHeight:
637 return(scriptLineHeight + doubleProperty(LineHeight) * scaling);
642 class Q_GUI_EXPORT QTextListFormat : public QTextFormat
647 bool isValid() const { return isListFormat(); }
658 ListStyleUndefined = 0
661 inline void setStyle(Style style);
662 inline Style style() const
663 { return static_cast<Style>(intProperty(ListStyle)); }
665 inline void setIndent(int indent);
666 inline int indent() const
667 { return intProperty(ListIndent); }
669 inline void setNumberPrefix(const QString &numberPrefix);
670 inline QString numberPrefix() const
671 { return stringProperty(ListNumberPrefix); }
673 inline void setNumberSuffix(const QString &numberSuffix);
674 inline QString numberSuffix() const
675 { return stringProperty(ListNumberSuffix); }
678 explicit QTextListFormat(const QTextFormat &fmt);
679 friend class QTextFormat;
682 inline void QTextListFormat::setStyle(Style astyle)
683 { setProperty(ListStyle, astyle); }
685 inline void QTextListFormat::setIndent(int aindent)
686 { setProperty(ListIndent, aindent); }
688 inline void QTextListFormat::setNumberPrefix(const QString &np)
689 { setProperty(ListNumberPrefix, np); }
691 inline void QTextListFormat::setNumberSuffix(const QString &ns)
692 { setProperty(ListNumberSuffix, ns); }
694 class Q_GUI_EXPORT QTextImageFormat : public QTextCharFormat
699 bool isValid() const { return isImageFormat(); }
701 inline void setName(const QString &name);
702 inline QString name() const
703 { return stringProperty(ImageName); }
705 inline void setWidth(qreal width);
706 inline qreal width() const
707 { return doubleProperty(ImageWidth); }
709 inline void setHeight(qreal height);
710 inline qreal height() const
711 { return doubleProperty(ImageHeight); }
714 explicit QTextImageFormat(const QTextFormat &format);
715 friend class QTextFormat;
718 inline void QTextImageFormat::setName(const QString &aname)
719 { setProperty(ImageName, aname); }
721 inline void QTextImageFormat::setWidth(qreal awidth)
722 { setProperty(ImageWidth, awidth); }
724 inline void QTextImageFormat::setHeight(qreal aheight)
725 { setProperty(ImageHeight, aheight); }
727 class Q_GUI_EXPORT QTextFrameFormat : public QTextFormat
732 bool isValid() const { return isFrameFormat(); }
749 BorderStyle_DotDotDash,
756 inline void setPosition(Position f)
757 { setProperty(CssFloat, f); }
758 inline Position position() const
759 { return static_cast<Position>(intProperty(CssFloat)); }
761 inline void setBorder(qreal border);
762 inline qreal border() const
763 { return doubleProperty(FrameBorder); }
765 inline void setBorderBrush(const QBrush &brush)
766 { setProperty(FrameBorderBrush, brush); }
767 inline QBrush borderBrush() const
768 { return brushProperty(FrameBorderBrush); }
770 inline void setBorderStyle(BorderStyle style)
771 { setProperty(FrameBorderStyle, style); }
772 inline BorderStyle borderStyle() const
773 { return static_cast<BorderStyle>(intProperty(FrameBorderStyle)); }
775 void setMargin(qreal margin);
776 inline qreal margin() const
777 { return doubleProperty(FrameMargin); }
779 inline void setTopMargin(qreal margin);
780 qreal topMargin() const;
782 inline void setBottomMargin(qreal margin);
783 qreal bottomMargin() const;
785 inline void setLeftMargin(qreal margin);
786 qreal leftMargin() const;
788 inline void setRightMargin(qreal margin);
789 qreal rightMargin() const;
791 inline void setPadding(qreal padding);
792 inline qreal padding() const
793 { return doubleProperty(FramePadding); }
795 inline void setWidth(qreal width);
796 inline void setWidth(const QTextLength &length)
797 { setProperty(FrameWidth, length); }
798 inline QTextLength width() const
799 { return lengthProperty(FrameWidth); }
801 inline void setHeight(qreal height);
802 inline void setHeight(const QTextLength &height);
803 inline QTextLength height() const
804 { return lengthProperty(FrameHeight); }
806 inline void setPageBreakPolicy(PageBreakFlags flags)
807 { setProperty(PageBreakPolicy, int(flags)); }
808 inline PageBreakFlags pageBreakPolicy() const
809 { return PageBreakFlags(intProperty(PageBreakPolicy)); }
812 explicit QTextFrameFormat(const QTextFormat &fmt);
813 friend class QTextFormat;
816 inline void QTextFrameFormat::setBorder(qreal aborder)
817 { setProperty(FrameBorder, aborder); }
819 inline void QTextFrameFormat::setPadding(qreal apadding)
820 { setProperty(FramePadding, apadding); }
822 inline void QTextFrameFormat::setWidth(qreal awidth)
823 { setProperty(FrameWidth, QTextLength(QTextLength::FixedLength, awidth)); }
825 inline void QTextFrameFormat::setHeight(qreal aheight)
826 { setProperty(FrameHeight, QTextLength(QTextLength::FixedLength, aheight)); }
827 inline void QTextFrameFormat::setHeight(const QTextLength &aheight)
828 { setProperty(FrameHeight, aheight); }
830 inline void QTextFrameFormat::setTopMargin(qreal amargin)
831 { setProperty(FrameTopMargin, amargin); }
833 inline void QTextFrameFormat::setBottomMargin(qreal amargin)
834 { setProperty(FrameBottomMargin, amargin); }
836 inline void QTextFrameFormat::setLeftMargin(qreal amargin)
837 { setProperty(FrameLeftMargin, amargin); }
839 inline void QTextFrameFormat::setRightMargin(qreal amargin)
840 { setProperty(FrameRightMargin, amargin); }
842 class Q_GUI_EXPORT QTextTableFormat : public QTextFrameFormat
847 inline bool isValid() const { return isTableFormat(); }
849 inline int columns() const
850 { int cols = intProperty(TableColumns); if (cols == 0) cols = 1; return cols; }
851 inline void setColumns(int columns);
853 inline void setColumnWidthConstraints(const QVector<QTextLength> &constraints)
854 { setProperty(TableColumnWidthConstraints, constraints); }
856 inline QVector<QTextLength> columnWidthConstraints() const
857 { return lengthVectorProperty(TableColumnWidthConstraints); }
859 inline void clearColumnWidthConstraints()
860 { clearProperty(TableColumnWidthConstraints); }
862 inline qreal cellSpacing() const
863 { return doubleProperty(TableCellSpacing); }
864 inline void setCellSpacing(qreal spacing)
865 { setProperty(TableCellSpacing, spacing); }
867 inline qreal cellPadding() const
868 { return doubleProperty(TableCellPadding); }
869 inline void setCellPadding(qreal padding);
871 inline void setAlignment(Qt::Alignment alignment);
872 inline Qt::Alignment alignment() const
873 { return QFlag(intProperty(BlockAlignment)); }
875 inline void setHeaderRowCount(int count)
876 { setProperty(TableHeaderRowCount, count); }
877 inline int headerRowCount() const
878 { return intProperty(TableHeaderRowCount); }
881 explicit QTextTableFormat(const QTextFormat &fmt);
882 friend class QTextFormat;
885 inline void QTextTableFormat::setColumns(int acolumns)
889 setProperty(TableColumns, acolumns);
892 inline void QTextTableFormat::setCellPadding(qreal apadding)
893 { setProperty(TableCellPadding, apadding); }
895 inline void QTextTableFormat::setAlignment(Qt::Alignment aalignment)
896 { setProperty(BlockAlignment, int(aalignment)); }
898 class Q_GUI_EXPORT QTextTableCellFormat : public QTextCharFormat
901 QTextTableCellFormat();
903 inline bool isValid() const { return isTableCellFormat(); }
905 inline void setTopPadding(qreal padding);
906 inline qreal topPadding() const;
908 inline void setBottomPadding(qreal padding);
909 inline qreal bottomPadding() const;
911 inline void setLeftPadding(qreal padding);
912 inline qreal leftPadding() const;
914 inline void setRightPadding(qreal padding);
915 inline qreal rightPadding() const;
917 inline void setPadding(qreal padding);
920 explicit QTextTableCellFormat(const QTextFormat &fmt);
921 friend class QTextFormat;
924 inline void QTextTableCellFormat::setTopPadding(qreal padding)
926 setProperty(TableCellTopPadding, padding);
929 inline qreal QTextTableCellFormat::topPadding() const
931 return doubleProperty(TableCellTopPadding);
934 inline void QTextTableCellFormat::setBottomPadding(qreal padding)
936 setProperty(TableCellBottomPadding, padding);
939 inline qreal QTextTableCellFormat::bottomPadding() const
941 return doubleProperty(TableCellBottomPadding);
944 inline void QTextTableCellFormat::setLeftPadding(qreal padding)
946 setProperty(TableCellLeftPadding, padding);
949 inline qreal QTextTableCellFormat::leftPadding() const
951 return doubleProperty(TableCellLeftPadding);
954 inline void QTextTableCellFormat::setRightPadding(qreal padding)
956 setProperty(TableCellRightPadding, padding);
959 inline qreal QTextTableCellFormat::rightPadding() const
961 return doubleProperty(TableCellRightPadding);
964 inline void QTextTableCellFormat::setPadding(qreal padding)
966 setTopPadding(padding);
967 setBottomPadding(padding);
968 setLeftPadding(padding);
969 setRightPadding(padding);
977 #endif // QTEXTFORMAT_H