64 class QTextFormatCollection;
65 class QTextFormatPrivate;
79 #ifndef QT_NO_DATASTREAM
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; }
107 {
return lengthType == other.lengthType
108 &&
qFuzzyCompare(fixedValueOrPercentage, other.fixedValueOrPercentage); }
110 {
return lengthType != other.lengthType
111 || !
qFuzzyCompare(fixedValueOrPercentage, other.fixedValueOrPercentage); }
112 operator QVariant()
const;
116 qreal fixedValueOrPercentage;
122 : lengthType(atype), fixedValueOrPercentage(avalue) {}
124 #ifndef QT_NO_DATASTREAM
129 class Q_GUI_EXPORT QTextFormat
153 BackgroundBrush = 0x820,
154 ForegroundBrush = 0x821,
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,
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,
187 FontUnderline = 0x2005,
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,
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,
231 TableCellRowSpan = 0x4810,
232 TableCellColumnSpan = 0x4811,
234 TableCellTopPadding = 0x4812,
235 TableCellBottomPadding = 0x4813,
236 TableCellLeftPadding = 0x4814,
237 TableCellRightPadding = 0x4815,
242 ImageHeight = 0x5011,
251 FullWidthSelection = 0x06000,
254 PageBreakPolicy = 0x7000,
257 UserProperty = 0x100000
271 PageBreak_AlwaysBefore = 0x001,
272 PageBreak_AlwaysAfter = 0x010
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;
312 int propertyCount()
const;
314 inline void setObjectType(
int type);
316 {
return intProperty(ObjectType); }
322 inline bool isImageFormat()
const {
return type() == CharFormat && objectType() == ImageObject; }
323 inline bool isTableFormat()
const {
return type() == FrameFormat && objectType() == TableObject; }
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;
336 operator QVariant()
const;
344 { setProperty(BackgroundBrush, brush); }
346 {
return brushProperty(BackgroundBrush); }
348 { clearProperty(BackgroundBrush); }
351 { setProperty(ForegroundBrush, brush); }
353 {
return brushProperty(ForegroundBrush); }
355 { clearProperty(ForegroundBrush); }
361 friend class QTextFormatCollection;
362 friend class QTextCharFormat;
370 Q_DECLARE_OPERATORS_FOR_FLAGS(QTextFormat::PageBreakFlags)
372 class Q_GUI_EXPORT QTextCharFormat : public QTextFormat
526 friend class QTextFormat;
531 if (_tableCellRowSpan <= 1)
539 if (_tableCellColumnSpan <= 1)
545 class Q_GUI_EXPORT QTextBlockFormat :
public QTextFormat
550 ProportionalHeight = 1,
553 LineDistanceHeight = 4
560 inline void setAlignment(Qt::Alignment alignment);
589 inline void setIndent(
int indent);
595 inline qreal lineHeight(qreal scriptLineHeight, qreal scaling)
const;
609 {
return PageBreakFlags(
intProperty(PageBreakPolicy)); }
615 explicit QTextBlockFormat(
const QTextFormat &fmt);
616 friend class QTextFormat;
629 return(scriptLineHeight);
642 class Q_GUI_EXPORT QTextListFormat :
public QTextFormat
658 ListStyleUndefined = 0
661 inline void setStyle(Style style);
665 inline void setIndent(
int indent);
669 inline void setNumberPrefix(
const QString &numberPrefix);
673 inline void setNumberSuffix(
const QString &numberSuffix);
678 explicit QTextListFormat(
const QTextFormat &fmt);
679 friend class QTextFormat;
694 class Q_GUI_EXPORT QTextImageFormat :
public QTextCharFormat
701 inline void setName(
const QString &
name);
705 inline void setWidth(qreal
width);
709 inline void setHeight(qreal
height);
714 explicit QTextImageFormat(
const QTextFormat &
format);
715 friend class QTextFormat;
727 class Q_GUI_EXPORT QTextFrameFormat :
public QTextFormat
761 inline void setBorder(qreal
border);
775 void setMargin(qreal margin);
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);
795 inline void setWidth(qreal
width);
801 inline void setHeight(qreal
height);
802 inline void setHeight(
const QTextLength &
height);
809 {
return PageBreakFlags(
intProperty(PageBreakPolicy)); }
812 explicit QTextFrameFormat(
const QTextFormat &fmt);
813 friend class QTextFormat;
842 class Q_GUI_EXPORT QTextTableFormat :
public QTextFrameFormat
850 {
int cols =
intProperty(TableColumns);
if (cols == 0) cols = 1;
return cols; }
851 inline void setColumns(
int columns);
854 {
setProperty(TableColumnWidthConstraints, constraints); }
869 inline void setCellPadding(qreal padding);
871 inline void setAlignment(Qt::Alignment alignment);
881 explicit QTextTableFormat(
const QTextFormat &fmt);
882 friend class QTextFormat;
898 class Q_GUI_EXPORT QTextTableCellFormat :
public QTextCharFormat
901 QTextTableCellFormat();
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;
977 #endif // QTEXTFORMAT_H
void setAlignment(Qt::Alignment alignment)
GLuint GLuint GLsizei GLenum type
void setFontStrikeOut(bool strikeOut)
QString stringProperty(int propertyId) const
bool isTableCellFormat() const
QStringList anchorNames() const
void setHeight(qreal height)
void setPosition(Position f)
qreal doubleProperty(int propertyId) const
void setWidth(qreal width)
UnderlineStyle underlineStyle() const
void setPadding(qreal padding)
int tableCellRowSpan() const
void setCellPadding(qreal padding)
bool nonBreakableLines() const
QTextLength lengthProperty(int propertyId) const
int tableCellColumnSpan() const
void setTableCellRowSpan(int tableCellRowSpan)
void setPageBreakPolicy(PageBreakFlags flags)
QFont::HintingPreference fontHintingPreference() const
QBrush background() const
void setBackground(const QBrush &brush)
void setFontCapitalization(QFont::Capitalization capitalization)
QVector< QTextLength > lengthVectorProperty(int propertyId) const
void setFontStyleStrategy(QFont::StyleStrategy strategy)
VerticalAlignment verticalAlignment() const
qreal bottomMargin() const
void setWidth(const QTextLength &length)
Qt::LayoutDirection layoutDirection() const
bool fontFixedPitch() const
void setFontUnderline(bool underline)
QFont::StyleStrategy fontStyleStrategy() const
void setFontFamily(const QString &family)
void setHeaderRowCount(int count)
void setTopMargin(qreal margin)
void clearProperty(int propertyId)
bool isTableFormat() const
void setStyle(Style style)
void setBorderStyle(BorderStyle style)
void setAlignment(Qt::Alignment alignment)
void setHeight(qreal height)
void setNumberSuffix(const QString &numberSuffix)
bool isImageFormat() const
void setIndent(int indent)
void setProperty(int propertyId, const QVariant &value)
QPen penProperty(int propertyId) const
qreal bottomPadding() const
QColor colorProperty(int propertyId) const
void setRightMargin(qreal margin)
QBrush brushProperty(int propertyId) const
void setTopPadding(qreal padding)
void setTopMargin(qreal margin)
bool operator==(const Attribute &cA, const AttributeInstance< type > &cB)
This operator compares the two attributes and NOT their values.
void setLeftMargin(qreal margin)
#define QT_BEGIN_NAMESPACE
QString anchorHref() const
QString anchorName() const
void setBorderBrush(const QBrush &brush)
GLenum GLsizei GLenum format
void setNonBreakableLines(bool b)
void setFontStyleHint(QFont::StyleHint hint, QFont::StyleStrategy strategy=QFont::PreferDefault)
qreal rightPadding() const
qreal fontWordSpacing() const
bool operator==(const QTextLength &other) const
void setAnchor(bool anchor)
void setColumnWidthConstraints(const QVector< QTextLength > &constraints)
BorderStyle borderStyle() const
qreal leftPadding() const
GLenum GLsizei GLsizei height
void setPageBreakPolicy(PageBreakFlags flags)
void setTextOutline(const QPen &pen)
void setColumns(int columns)
void setForeground(const QBrush &brush)
void setPadding(qreal padding)
qreal fontPointSize() const
qreal value(qreal maximumLength) const
GLuint GLuint GLsizei count
qreal cellPadding() const
void setToolTip(const QString &tip)
void setTableCellColumnSpan(int tableCellColumnSpan)
void setUnderlineColor(const QColor &color)
void setFont(const QFont &font)
void setLeftMargin(qreal margin)
void setFontItalic(bool italic)
GLuint GLsizei GLsizei * length
QVector< QTextLength > columnWidthConstraints() const
GLint GLint GLsizei GLsizei GLsizei GLint border
void clearColumnWidthConstraints()
void setBottomPadding(qreal padding)
void setFontFixedPitch(bool fixedPitch)
QString numberPrefix() const
void setFontLetterSpacing(qreal spacing)
QBrush foreground() const
void setFontKerning(bool enable)
void setLeftPadding(qreal padding)
qreal rightMargin() const
QFont::StyleHint fontStyleHint() const
void setIndent(int indent)
void setLineHeight(qreal height, int heightType)
QTextLength width() const
void setFontOverline(bool overline)
GLsizei const GLfloat * value
void setAnchorNames(const QStringList &names)
void setBorder(qreal border)
bool isBlockFormat() const
bool isCharFormat() const
bool boolProperty(int propertyId) const
qreal fontLetterSpacing() const
QBrush borderBrush() const
GLuint const GLchar * name
int headerRowCount() const
bool fontOverline() const
bool qFuzzyCompare(const QMatrix &m1, const QMatrix &m2)
void setFontWordSpacing(qreal spacing)
GLubyte GLubyte GLubyte a
void setBottomMargin(qreal margin)
QString fontFamily() const
int lineHeightType() const
QString numberSuffix() const
bool fontStrikeOut() const
bool isListFormat() const
PageBreakFlags pageBreakPolicy() const
void setFontPointSize(qreal size)
void setCellSpacing(qreal spacing)
bool isFrameFormat() const
void setVerticalAlignment(VerticalAlignment alignment)
void setNumberPrefix(const QString &numberPrefix)
void setUnderlineStyle(UnderlineStyle style)
qreal cellSpacing() const
Position position() const
bool operator!=(const QTextLength &other) const
void setRightMargin(qreal margin)
bool fontUnderline() const
PageBreakFlags pageBreakPolicy() const
void setFontWeight(int weight)
void setAnchorName(const QString &name)
void setWidth(qreal width)
Q_GUI_EXPORT QDataStream & operator>>(QDataStream &, QTextLength &)
void setRightPadding(qreal padding)
void setObjectType(int type)
void setTextIndent(qreal aindent)
void setAnchorHref(const QString &value)
void setBottomMargin(qreal margin)
int intProperty(int propertyId) const
void setLayoutDirection(Qt::LayoutDirection direction)
bool operator!=(const QTextFormat &rhs) const
Qt::Alignment alignment() const
QFont::Capitalization fontCapitalization() const
void setFontHintingPreference(QFont::HintingPreference hintingPreference)
Q_GUI_EXPORT QDataStream & operator<<(QDataStream &, const QTextLength &)
QTextLength height() const
Qt::Alignment alignment() const
void setName(const QString &name)
QColor underlineColor() const