1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the QtGui module of the Qt Toolkit.
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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
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 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
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 FontLetterSpacingType = 0x2033,
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 swap(QTextFormat &other)
295 { qSwap(d, other.d); qSwap(format_type, other.format_type); }
297 void merge(const QTextFormat &other);
299 inline bool isValid() const { return type() != InvalidFormat; }
303 int objectIndex() const;
304 void setObjectIndex(int object);
306 QVariant property(int propertyId) const;
307 void setProperty(int propertyId, const QVariant &value);
308 void clearProperty(int propertyId);
309 bool hasProperty(int propertyId) const;
311 bool boolProperty(int propertyId) const;
312 int intProperty(int propertyId) const;
313 qreal doubleProperty(int propertyId) const;
314 QString stringProperty(int propertyId) const;
315 QColor colorProperty(int propertyId) const;
316 QPen penProperty(int propertyId) const;
317 QBrush brushProperty(int propertyId) const;
318 QTextLength lengthProperty(int propertyId) const;
319 QVector<QTextLength> lengthVectorProperty(int propertyId) const;
321 void setProperty(int propertyId, const QVector<QTextLength> &lengths);
323 QMap<int, QVariant> properties() const;
324 int propertyCount() const;
326 inline void setObjectType(int type);
327 inline int objectType() const
328 { return intProperty(ObjectType); }
330 inline bool isCharFormat() const { return type() == CharFormat; }
331 inline bool isBlockFormat() const { return type() == BlockFormat; }
332 inline bool isListFormat() const { return type() == ListFormat; }
333 inline bool isFrameFormat() const { return type() == FrameFormat; }
334 inline bool isImageFormat() const { return type() == CharFormat && objectType() == ImageObject; }
335 inline bool isTableFormat() const { return type() == FrameFormat && objectType() == TableObject; }
336 inline bool isTableCellFormat() const { return type() == CharFormat && objectType() == TableCellObject; }
338 QTextBlockFormat toBlockFormat() const;
339 QTextCharFormat toCharFormat() const;
340 QTextListFormat toListFormat() const;
341 QTextTableFormat toTableFormat() const;
342 QTextFrameFormat toFrameFormat() const;
343 QTextImageFormat toImageFormat() const;
344 QTextTableCellFormat toTableCellFormat() const;
346 bool operator==(const QTextFormat &rhs) const;
347 inline bool operator!=(const QTextFormat &rhs) const { return !operator==(rhs); }
348 operator QVariant() const;
350 inline void setLayoutDirection(Qt::LayoutDirection direction)
351 { setProperty(QTextFormat::LayoutDirection, direction); }
352 inline Qt::LayoutDirection layoutDirection() const
353 { return Qt::LayoutDirection(intProperty(QTextFormat::LayoutDirection)); }
355 inline void setBackground(const QBrush &brush)
356 { setProperty(BackgroundBrush, brush); }
357 inline QBrush background() const
358 { return brushProperty(BackgroundBrush); }
359 inline void clearBackground()
360 { clearProperty(BackgroundBrush); }
362 inline void setForeground(const QBrush &brush)
363 { setProperty(ForegroundBrush, brush); }
364 inline QBrush foreground() const
365 { return brushProperty(ForegroundBrush); }
366 inline void clearForeground()
367 { clearProperty(ForegroundBrush); }
370 QSharedDataPointer<QTextFormatPrivate> d;
373 friend class QTextFormatCollection;
374 friend class QTextCharFormat;
375 friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextFormat &);
376 friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextFormat &);
379 Q_DECLARE_SHARED(QTextFormat)
381 inline void QTextFormat::setObjectType(int atype)
382 { setProperty(ObjectType, atype); }
384 Q_DECLARE_OPERATORS_FOR_FLAGS(QTextFormat::PageBreakFlags)
386 class Q_GUI_EXPORT QTextCharFormat : public QTextFormat
389 enum VerticalAlignment {
398 enum UnderlineStyle { // keep in sync with Qt::PenStyle!
411 bool isValid() const { return isCharFormat(); }
412 void setFont(const QFont &font);
415 inline void setFontFamily(const QString &family)
416 { setProperty(FontFamily, family); }
417 inline QString fontFamily() const
418 { return stringProperty(FontFamily); }
420 inline void setFontPointSize(qreal size)
421 { setProperty(FontPointSize, size); }
422 inline qreal fontPointSize() const
423 { return doubleProperty(FontPointSize); }
425 inline void setFontWeight(int weight)
426 { if (weight == QFont::Normal) weight = 0; setProperty(FontWeight, weight); }
427 inline int fontWeight() const
428 { int weight = intProperty(FontWeight); if (weight == 0) weight = QFont::Normal; return weight; }
429 inline void setFontItalic(bool italic)
430 { setProperty(FontItalic, italic); }
431 inline bool fontItalic() const
432 { return boolProperty(FontItalic); }
433 inline void setFontCapitalization(QFont::Capitalization capitalization)
434 { setProperty(FontCapitalization, capitalization); }
435 inline QFont::Capitalization fontCapitalization() const
436 { return static_cast<QFont::Capitalization>(intProperty(FontCapitalization)); }
437 inline void setFontLetterSpacingType(QFont::SpacingType letterSpacingType)
438 { setProperty(FontLetterSpacingType, letterSpacingType); }
439 inline QFont::SpacingType fontLetterSpacingType() const
440 { return static_cast<QFont::SpacingType>(intProperty(FontLetterSpacingType)); }
441 inline void setFontLetterSpacing(qreal spacing)
442 { setProperty(FontLetterSpacing, spacing); }
443 inline qreal fontLetterSpacing() const
444 { return doubleProperty(FontLetterSpacing); }
445 inline void setFontWordSpacing(qreal spacing)
446 { setProperty(FontWordSpacing, spacing); }
447 inline qreal fontWordSpacing() const
448 { return doubleProperty(FontWordSpacing); }
450 inline void setFontUnderline(bool underline)
451 { setProperty(TextUnderlineStyle, underline ? SingleUnderline : NoUnderline); }
452 bool fontUnderline() const;
454 inline void setFontOverline(bool overline)
455 { setProperty(FontOverline, overline); }
456 inline bool fontOverline() const
457 { return boolProperty(FontOverline); }
459 inline void setFontStrikeOut(bool strikeOut)
460 { setProperty(FontStrikeOut, strikeOut); }
461 inline bool fontStrikeOut() const
462 { return boolProperty(FontStrikeOut); }
464 inline void setUnderlineColor(const QColor &color)
465 { setProperty(TextUnderlineColor, color); }
466 inline QColor underlineColor() const
467 { return colorProperty(TextUnderlineColor); }
469 inline void setFontFixedPitch(bool fixedPitch)
470 { setProperty(FontFixedPitch, fixedPitch); }
471 inline bool fontFixedPitch() const
472 { return boolProperty(FontFixedPitch); }
474 inline void setFontStretch(int factor)
475 { setProperty(FontStretch, factor); }
476 inline int fontStretch() const
477 { return intProperty(FontStretch); }
479 inline void setFontStyleHint(QFont::StyleHint hint, QFont::StyleStrategy strategy = QFont::PreferDefault)
480 { setProperty(FontStyleHint, hint); setProperty(FontStyleStrategy, strategy); }
481 inline void setFontStyleStrategy(QFont::StyleStrategy strategy)
482 { setProperty(FontStyleStrategy, strategy); }
483 QFont::StyleHint fontStyleHint() const
484 { return static_cast<QFont::StyleHint>(intProperty(FontStyleHint)); }
485 QFont::StyleStrategy fontStyleStrategy() const
486 { return static_cast<QFont::StyleStrategy>(intProperty(FontStyleStrategy)); }
488 inline void setFontHintingPreference(QFont::HintingPreference hintingPreference)
490 setProperty(FontHintingPreference, hintingPreference);
493 inline QFont::HintingPreference fontHintingPreference() const
495 return static_cast<QFont::HintingPreference>(intProperty(FontHintingPreference));
498 inline void setFontKerning(bool enable)
499 { setProperty(FontKerning, enable); }
500 inline bool fontKerning() const
501 { return boolProperty(FontKerning); }
503 void setUnderlineStyle(UnderlineStyle style);
504 inline UnderlineStyle underlineStyle() const
505 { return static_cast<UnderlineStyle>(intProperty(TextUnderlineStyle)); }
507 inline void setVerticalAlignment(VerticalAlignment alignment)
508 { setProperty(TextVerticalAlignment, alignment); }
509 inline VerticalAlignment verticalAlignment() const
510 { return static_cast<VerticalAlignment>(intProperty(TextVerticalAlignment)); }
512 inline void setTextOutline(const QPen &pen)
513 { setProperty(TextOutline, pen); }
514 inline QPen textOutline() const
515 { return penProperty(TextOutline); }
517 inline void setToolTip(const QString &tip)
518 { setProperty(TextToolTip, tip); }
519 inline QString toolTip() const
520 { return stringProperty(TextToolTip); }
522 inline void setAnchor(bool anchor)
523 { setProperty(IsAnchor, anchor); }
524 inline bool isAnchor() const
525 { return boolProperty(IsAnchor); }
527 inline void setAnchorHref(const QString &value)
528 { setProperty(AnchorHref, value); }
529 inline QString anchorHref() const
530 { return stringProperty(AnchorHref); }
532 inline void setAnchorName(const QString &name)
533 { setAnchorNames(QStringList(name)); }
534 QString anchorName() const;
536 inline void setAnchorNames(const QStringList &names)
537 { setProperty(AnchorName, names); }
538 QStringList anchorNames() const;
540 inline void setTableCellRowSpan(int tableCellRowSpan);
541 inline int tableCellRowSpan() const
542 { int s = intProperty(TableCellRowSpan); if (s == 0) s = 1; return s; }
543 inline void setTableCellColumnSpan(int tableCellColumnSpan);
544 inline int tableCellColumnSpan() const
545 { int s = intProperty(TableCellColumnSpan); if (s == 0) s = 1; return s; }
548 explicit QTextCharFormat(const QTextFormat &fmt);
549 friend class QTextFormat;
552 Q_DECLARE_SHARED(QTextCharFormat)
554 inline void QTextCharFormat::setTableCellRowSpan(int _tableCellRowSpan)
556 if (_tableCellRowSpan <= 1)
557 clearProperty(TableCellRowSpan); // the getter will return 1 here.
559 setProperty(TableCellRowSpan, _tableCellRowSpan);
562 inline void QTextCharFormat::setTableCellColumnSpan(int _tableCellColumnSpan)
564 if (_tableCellColumnSpan <= 1)
565 clearProperty(TableCellColumnSpan); // the getter will return 1 here.
567 setProperty(TableCellColumnSpan, _tableCellColumnSpan);
570 class Q_GUI_EXPORT QTextBlockFormat : public QTextFormat
573 enum LineHeightTypes {
575 ProportionalHeight = 1,
578 LineDistanceHeight = 4
583 bool isValid() const { return isBlockFormat(); }
585 inline void setAlignment(Qt::Alignment alignment);
586 inline Qt::Alignment alignment() const
587 { int a = intProperty(BlockAlignment); if (a == 0) a = Qt::AlignLeft; return QFlag(a); }
589 inline void setTopMargin(qreal margin)
590 { setProperty(BlockTopMargin, margin); }
591 inline qreal topMargin() const
592 { return doubleProperty(BlockTopMargin); }
594 inline void setBottomMargin(qreal margin)
595 { setProperty(BlockBottomMargin, margin); }
596 inline qreal bottomMargin() const
597 { return doubleProperty(BlockBottomMargin); }
599 inline void setLeftMargin(qreal margin)
600 { setProperty(BlockLeftMargin, margin); }
601 inline qreal leftMargin() const
602 { return doubleProperty(BlockLeftMargin); }
604 inline void setRightMargin(qreal margin)
605 { setProperty(BlockRightMargin, margin); }
606 inline qreal rightMargin() const
607 { return doubleProperty(BlockRightMargin); }
609 inline void setTextIndent(qreal aindent)
610 { setProperty(TextIndent, aindent); }
611 inline qreal textIndent() const
612 { return doubleProperty(TextIndent); }
614 inline void setIndent(int indent);
615 inline int indent() const
616 { return intProperty(BlockIndent); }
618 inline void setLineHeight(qreal height, int heightType)
619 { setProperty(LineHeight, height); setProperty(LineHeightType, heightType); }
620 inline qreal lineHeight(qreal scriptLineHeight, qreal scaling) const;
621 inline qreal lineHeight() const
622 { return doubleProperty(LineHeight); }
623 inline int lineHeightType() const
624 { return intProperty(LineHeightType); }
626 inline void setNonBreakableLines(bool b)
627 { setProperty(BlockNonBreakableLines, b); }
628 inline bool nonBreakableLines() const
629 { return boolProperty(BlockNonBreakableLines); }
631 inline void setPageBreakPolicy(PageBreakFlags flags)
632 { setProperty(PageBreakPolicy, int(flags)); }
633 inline PageBreakFlags pageBreakPolicy() const
634 { return PageBreakFlags(intProperty(PageBreakPolicy)); }
636 void setTabPositions(const QList<QTextOption::Tab> &tabs);
637 QList<QTextOption::Tab> tabPositions() const;
640 explicit QTextBlockFormat(const QTextFormat &fmt);
641 friend class QTextFormat;
644 Q_DECLARE_SHARED(QTextBlockFormat)
646 inline void QTextBlockFormat::setAlignment(Qt::Alignment aalignment)
647 { setProperty(BlockAlignment, int(aalignment)); }
649 inline void QTextBlockFormat::setIndent(int aindent)
650 { setProperty(BlockIndent, aindent); }
652 inline qreal QTextBlockFormat::lineHeight(qreal scriptLineHeight, qreal scaling = 1.0) const
654 switch(intProperty(LineHeightType)) {
656 return(scriptLineHeight);
657 case ProportionalHeight:
658 return(scriptLineHeight * doubleProperty(LineHeight) / 100.0);
660 return(doubleProperty(LineHeight) * scaling);
662 return(qMax(scriptLineHeight, doubleProperty(LineHeight) * scaling));
663 case LineDistanceHeight:
664 return(scriptLineHeight + doubleProperty(LineHeight) * scaling);
669 class Q_GUI_EXPORT QTextListFormat : public QTextFormat
674 bool isValid() const { return isListFormat(); }
685 ListStyleUndefined = 0
688 inline void setStyle(Style style);
689 inline Style style() const
690 { return static_cast<Style>(intProperty(ListStyle)); }
692 inline void setIndent(int indent);
693 inline int indent() const
694 { return intProperty(ListIndent); }
696 inline void setNumberPrefix(const QString &numberPrefix);
697 inline QString numberPrefix() const
698 { return stringProperty(ListNumberPrefix); }
700 inline void setNumberSuffix(const QString &numberSuffix);
701 inline QString numberSuffix() const
702 { return stringProperty(ListNumberSuffix); }
705 explicit QTextListFormat(const QTextFormat &fmt);
706 friend class QTextFormat;
709 Q_DECLARE_SHARED(QTextListFormat)
711 inline void QTextListFormat::setStyle(Style astyle)
712 { setProperty(ListStyle, astyle); }
714 inline void QTextListFormat::setIndent(int aindent)
715 { setProperty(ListIndent, aindent); }
717 inline void QTextListFormat::setNumberPrefix(const QString &np)
718 { setProperty(ListNumberPrefix, np); }
720 inline void QTextListFormat::setNumberSuffix(const QString &ns)
721 { setProperty(ListNumberSuffix, ns); }
723 class Q_GUI_EXPORT QTextImageFormat : public QTextCharFormat
728 bool isValid() const { return isImageFormat(); }
730 inline void setName(const QString &name);
731 inline QString name() const
732 { return stringProperty(ImageName); }
734 inline void setWidth(qreal width);
735 inline qreal width() const
736 { return doubleProperty(ImageWidth); }
738 inline void setHeight(qreal height);
739 inline qreal height() const
740 { return doubleProperty(ImageHeight); }
743 explicit QTextImageFormat(const QTextFormat &format);
744 friend class QTextFormat;
747 Q_DECLARE_SHARED(QTextImageFormat)
749 inline void QTextImageFormat::setName(const QString &aname)
750 { setProperty(ImageName, aname); }
752 inline void QTextImageFormat::setWidth(qreal awidth)
753 { setProperty(ImageWidth, awidth); }
755 inline void QTextImageFormat::setHeight(qreal aheight)
756 { setProperty(ImageHeight, aheight); }
758 class Q_GUI_EXPORT QTextFrameFormat : public QTextFormat
763 bool isValid() const { return isFrameFormat(); }
780 BorderStyle_DotDotDash,
787 inline void setPosition(Position f)
788 { setProperty(CssFloat, f); }
789 inline Position position() const
790 { return static_cast<Position>(intProperty(CssFloat)); }
792 inline void setBorder(qreal border);
793 inline qreal border() const
794 { return doubleProperty(FrameBorder); }
796 inline void setBorderBrush(const QBrush &brush)
797 { setProperty(FrameBorderBrush, brush); }
798 inline QBrush borderBrush() const
799 { return brushProperty(FrameBorderBrush); }
801 inline void setBorderStyle(BorderStyle style)
802 { setProperty(FrameBorderStyle, style); }
803 inline BorderStyle borderStyle() const
804 { return static_cast<BorderStyle>(intProperty(FrameBorderStyle)); }
806 void setMargin(qreal margin);
807 inline qreal margin() const
808 { return doubleProperty(FrameMargin); }
810 inline void setTopMargin(qreal margin);
811 qreal topMargin() const;
813 inline void setBottomMargin(qreal margin);
814 qreal bottomMargin() const;
816 inline void setLeftMargin(qreal margin);
817 qreal leftMargin() const;
819 inline void setRightMargin(qreal margin);
820 qreal rightMargin() const;
822 inline void setPadding(qreal padding);
823 inline qreal padding() const
824 { return doubleProperty(FramePadding); }
826 inline void setWidth(qreal width);
827 inline void setWidth(const QTextLength &length)
828 { setProperty(FrameWidth, length); }
829 inline QTextLength width() const
830 { return lengthProperty(FrameWidth); }
832 inline void setHeight(qreal height);
833 inline void setHeight(const QTextLength &height);
834 inline QTextLength height() const
835 { return lengthProperty(FrameHeight); }
837 inline void setPageBreakPolicy(PageBreakFlags flags)
838 { setProperty(PageBreakPolicy, int(flags)); }
839 inline PageBreakFlags pageBreakPolicy() const
840 { return PageBreakFlags(intProperty(PageBreakPolicy)); }
843 explicit QTextFrameFormat(const QTextFormat &fmt);
844 friend class QTextFormat;
847 Q_DECLARE_SHARED(QTextFrameFormat)
849 inline void QTextFrameFormat::setBorder(qreal aborder)
850 { setProperty(FrameBorder, aborder); }
852 inline void QTextFrameFormat::setPadding(qreal apadding)
853 { setProperty(FramePadding, apadding); }
855 inline void QTextFrameFormat::setWidth(qreal awidth)
856 { setProperty(FrameWidth, QTextLength(QTextLength::FixedLength, awidth)); }
858 inline void QTextFrameFormat::setHeight(qreal aheight)
859 { setProperty(FrameHeight, QTextLength(QTextLength::FixedLength, aheight)); }
860 inline void QTextFrameFormat::setHeight(const QTextLength &aheight)
861 { setProperty(FrameHeight, aheight); }
863 inline void QTextFrameFormat::setTopMargin(qreal amargin)
864 { setProperty(FrameTopMargin, amargin); }
866 inline void QTextFrameFormat::setBottomMargin(qreal amargin)
867 { setProperty(FrameBottomMargin, amargin); }
869 inline void QTextFrameFormat::setLeftMargin(qreal amargin)
870 { setProperty(FrameLeftMargin, amargin); }
872 inline void QTextFrameFormat::setRightMargin(qreal amargin)
873 { setProperty(FrameRightMargin, amargin); }
875 class Q_GUI_EXPORT QTextTableFormat : public QTextFrameFormat
880 inline bool isValid() const { return isTableFormat(); }
882 inline int columns() const
883 { int cols = intProperty(TableColumns); if (cols == 0) cols = 1; return cols; }
884 inline void setColumns(int columns);
886 inline void setColumnWidthConstraints(const QVector<QTextLength> &constraints)
887 { setProperty(TableColumnWidthConstraints, constraints); }
889 inline QVector<QTextLength> columnWidthConstraints() const
890 { return lengthVectorProperty(TableColumnWidthConstraints); }
892 inline void clearColumnWidthConstraints()
893 { clearProperty(TableColumnWidthConstraints); }
895 inline qreal cellSpacing() const
896 { return doubleProperty(TableCellSpacing); }
897 inline void setCellSpacing(qreal spacing)
898 { setProperty(TableCellSpacing, spacing); }
900 inline qreal cellPadding() const
901 { return doubleProperty(TableCellPadding); }
902 inline void setCellPadding(qreal padding);
904 inline void setAlignment(Qt::Alignment alignment);
905 inline Qt::Alignment alignment() const
906 { return QFlag(intProperty(BlockAlignment)); }
908 inline void setHeaderRowCount(int count)
909 { setProperty(TableHeaderRowCount, count); }
910 inline int headerRowCount() const
911 { return intProperty(TableHeaderRowCount); }
914 explicit QTextTableFormat(const QTextFormat &fmt);
915 friend class QTextFormat;
918 Q_DECLARE_SHARED(QTextTableFormat)
920 inline void QTextTableFormat::setColumns(int acolumns)
924 setProperty(TableColumns, acolumns);
927 inline void QTextTableFormat::setCellPadding(qreal apadding)
928 { setProperty(TableCellPadding, apadding); }
930 inline void QTextTableFormat::setAlignment(Qt::Alignment aalignment)
931 { setProperty(BlockAlignment, int(aalignment)); }
933 class Q_GUI_EXPORT QTextTableCellFormat : public QTextCharFormat
936 QTextTableCellFormat();
938 inline bool isValid() const { return isTableCellFormat(); }
940 inline void setTopPadding(qreal padding);
941 inline qreal topPadding() const;
943 inline void setBottomPadding(qreal padding);
944 inline qreal bottomPadding() const;
946 inline void setLeftPadding(qreal padding);
947 inline qreal leftPadding() const;
949 inline void setRightPadding(qreal padding);
950 inline qreal rightPadding() const;
952 inline void setPadding(qreal padding);
955 explicit QTextTableCellFormat(const QTextFormat &fmt);
956 friend class QTextFormat;
959 Q_DECLARE_SHARED(QTextTableCellFormat)
961 inline void QTextTableCellFormat::setTopPadding(qreal padding)
963 setProperty(TableCellTopPadding, padding);
966 inline qreal QTextTableCellFormat::topPadding() const
968 return doubleProperty(TableCellTopPadding);
971 inline void QTextTableCellFormat::setBottomPadding(qreal padding)
973 setProperty(TableCellBottomPadding, padding);
976 inline qreal QTextTableCellFormat::bottomPadding() const
978 return doubleProperty(TableCellBottomPadding);
981 inline void QTextTableCellFormat::setLeftPadding(qreal padding)
983 setProperty(TableCellLeftPadding, padding);
986 inline qreal QTextTableCellFormat::leftPadding() const
988 return doubleProperty(TableCellLeftPadding);
991 inline void QTextTableCellFormat::setRightPadding(qreal padding)
993 setProperty(TableCellRightPadding, padding);
996 inline qreal QTextTableCellFormat::rightPadding() const
998 return doubleProperty(TableCellRightPadding);
1001 inline void QTextTableCellFormat::setPadding(qreal padding)
1003 setTopPadding(padding);
1004 setBottomPadding(padding);
1005 setLeftPadding(padding);
1006 setRightPadding(padding);
1014 #endif // QTEXTFORMAT_H