- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qtextformat.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtGui module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QTEXTFORMAT_H
    00043 #define QTEXTFORMAT_H
    00044
    00045 #include <QtGui/qcolor.h>
    00046 #include <QtGui/qfont.h>
    00047 #include <QtCore/qshareddata.h>
    00048 #include <QtCore/qvector.h>
    00049 #include <QtCore/qvariant.h>
    00050 #include <QtGui/qpen.h>
    00051 #include <QtGui/qbrush.h>
    00052 #include <QtGui/qtextoption.h>
    00053
    00054 QT_BEGIN_HEADER
    00055
    00056 QT_BEGIN_NAMESPACE
    00057
    00058 QT_MODULE(Gui)
    00059
    00060 class QString;
    00061 class QVariant;
    00062 class QFont;
    00063
    00064 class QTextFormatCollection;
    00065 class QTextFormatPrivate;
    00066 class QTextBlockFormat;
    00067 class QTextCharFormat;
    00068 class QTextListFormat;
    00069 class QTextTableFormat;
    00070 class QTextFrameFormat;
    00071 class QTextImageFormat;
    00072 class QTextTableCellFormat;
    00073 class QTextFormat;
    00074 class QTextObject;
    00075 class QTextCursor;
    00076 class QTextDocument;
    00077 class QTextLength;
    00078
    00079 #ifndef QT_NO_DATASTREAM
    00080 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextLength &);
    00081 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextLength &);
    00082 #endif
    00083
    00084 class Q_GUI_EXPORT QTextLength
    00085 {
    00086 public:
    00087     enum Type { VariableLength = 0, FixedLength, PercentageLength };
    00088
    00089     inline QTextLength() : lengthType(VariableLength), fixedValueOrPercentage(0) {}
    00090
    00091     inline explicit QTextLength(Type type, qreal value);
    00092
    00093     inline Type type() const { return lengthType; }
    00094     inline qreal value(qreal maximumLength) const
    00095     {
    00096         switch (lengthType) {
    00097             case FixedLength: return fixedValueOrPercentage;
    00098             case VariableLength: return maximumLength;
    00099             case PercentageLength: return fixedValueOrPercentage * maximumLength / qreal(100);
    00100         }
    00101         return -1;
    00102     }
    00103
    00104     inline qreal rawValue() const { return fixedValueOrPercentage; }
    00105
    00106     inline bool operator==(const QTextLength &other) const
    00107     { return lengthType == other.lengthType
    00108              && qFuzzyCompare(fixedValueOrPercentage, other.fixedValueOrPercentage); }
    00109     inline bool operator!=(const QTextLength &other) const
    00110     { return lengthType != other.lengthType
    00111              || !qFuzzyCompare(fixedValueOrPercentage, other.fixedValueOrPercentage); }
    00112     operator QVariant() const;
    00113
    00114 private:
    00115     Type lengthType;
    00116     qreal fixedValueOrPercentage;
    00117     friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextLength &);
    00118     friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextLength &);
    00119 };
    00120
    00121 inline QTextLength::QTextLength(Type atype, qreal avalue)
    00122     : lengthType(atype), fixedValueOrPercentage(avalue) {}
    00123
    00124 #ifndef QT_NO_DATASTREAM
    00125 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextFormat &);
    00126 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextFormat &);
    00127 #endif
    00128
    00129 class Q_GUI_EXPORT QTextFormat
    00130 {
    00131     Q_GADGET
    00132     Q_ENUMS(FormatType Property ObjectTypes)
    00133 public:
    00134     enum FormatType {
    00135         InvalidFormat = -1,
    00136         BlockFormat = 1,
    00137         CharFormat = 2,
    00138         ListFormat = 3,
    00139         TableFormat = 4,
    00140         FrameFormat = 5,
    00141
    00142         UserFormat = 100
    00143     };
    00144
    00145     enum Property {
    00146         ObjectIndex = 0x0,
    00147
    00148         // paragraph and char
    00149         CssFloat = 0x0800,
    00150         LayoutDirection = 0x0801,
    00151
    00152         OutlinePen = 0x810,
    00153         BackgroundBrush = 0x820,
    00154         ForegroundBrush = 0x821,
    00155         // Internal to qtextlayout.cpp: ObjectSelectionBrush = 0x822
    00156         BackgroundImageUrl = 0x823,
    00157
    00158         // paragraph
    00159         BlockAlignment = 0x1010,
    00160         BlockTopMargin = 0x1030,
    00161         BlockBottomMargin = 0x1031,
    00162         BlockLeftMargin = 0x1032,
    00163         BlockRightMargin = 0x1033,
    00164         TextIndent = 0x1034,
    00165         TabPositions = 0x1035,
    00166         BlockIndent = 0x1040,
    00167         BlockNonBreakableLines = 0x1050,
    00168         BlockTrailingHorizontalRulerWidth = 0x1060,
    00169
    00170         // character properties
    00171         FirstFontProperty = 0x1FE0,
    00172         FontCapitalization = FirstFontProperty,
    00173         FontLetterSpacing = 0x1FE1,
    00174         FontWordSpacing = 0x1FE2,
    00175         FontStyleHint = 0x1FE3,
    00176         FontStyleStrategy = 0x1FE4,
    00177         FontKerning = 0x1FE5,
    00178         FontFamily = 0x2000,
    00179         FontPointSize = 0x2001,
    00180         FontSizeAdjustment = 0x2002,
    00181         FontSizeIncrement = FontSizeAdjustment, // old name, compat
    00182         FontWeight = 0x2003,
    00183         FontItalic = 0x2004,
    00184         FontUnderline = 0x2005, // deprecated, use TextUnderlineStyle instead
    00185         FontOverline = 0x2006,
    00186         FontStrikeOut = 0x2007,
    00187         FontFixedPitch = 0x2008,
    00188         FontPixelSize = 0x2009,
    00189         LastFontProperty = FontPixelSize,
    00190
    00191         TextUnderlineColor = 0x2010,
    00192         TextVerticalAlignment = 0x2021,
    00193         TextOutline = 0x2022,
    00194         TextUnderlineStyle = 0x2023,
    00195         TextToolTip = 0x2024,
    00196
    00197         IsAnchor = 0x2030,
    00198         AnchorHref = 0x2031,
    00199         AnchorName = 0x2032,
    00200         ObjectType = 0x2f00,
    00201
    00202         // list properties
    00203         ListStyle = 0x3000,
    00204         ListIndent = 0x3001,
    00205
    00206         // table and frame properties
    00207         FrameBorder = 0x4000,
    00208         FrameMargin = 0x4001,
    00209         FramePadding = 0x4002,
    00210         FrameWidth = 0x4003,
    00211         FrameHeight = 0x4004,
    00212         FrameTopMargin    = 0x4005,
    00213         FrameBottomMargin = 0x4006,
    00214         FrameLeftMargin   = 0x4007,
    00215         FrameRightMargin  = 0x4008,
    00216         FrameBorderBrush = 0x4009,
    00217         FrameBorderStyle = 0x4010,
    00218
    00219         TableColumns = 0x4100,
    00220         TableColumnWidthConstraints = 0x4101,
    00221         TableCellSpacing = 0x4102,
    00222         TableCellPadding = 0x4103,
    00223         TableHeaderRowCount = 0x4104,
    00224
    00225         // table cell properties
    00226         TableCellRowSpan = 0x4810,
    00227         TableCellColumnSpan = 0x4811,
    00228
    00229         TableCellTopPadding = 0x4812,
    00230         TableCellBottomPadding = 0x4813,
    00231         TableCellLeftPadding = 0x4814,
    00232         TableCellRightPadding = 0x4815,
    00233
    00234         // image properties
    00235         ImageName = 0x5000,
    00236         ImageWidth = 0x5010,
    00237         ImageHeight = 0x5011,
    00238
    00239         // internal
    00240         /*
    00241            SuppressText = 0x5012,
    00242            SuppressBackground = 0x513
    00243         */
    00244
    00245         // selection properties
    00246         FullWidthSelection = 0x06000,
    00247
    00248         // page break properties
    00249         PageBreakPolicy = 0x7000,
    00250
    00251         // --
    00252         UserProperty = 0x100000
    00253     };
    00254
    00255     enum ObjectTypes {
    00256         NoObject,
    00257         ImageObject,
    00258         TableObject,
    00259         TableCellObject,
    00260
    00261         UserObject = 0x1000
    00262     };
    00263
    00264     enum PageBreakFlag {
    00265         PageBreak_Auto = 0,
    00266         PageBreak_AlwaysBefore = 0x001,
    00267         PageBreak_AlwaysAfter  = 0x010
    00268         // PageBreak_AlwaysInside = 0x100
    00269     };
    00270     Q_DECLARE_FLAGS(PageBreakFlags, PageBreakFlag)
    00271
    00272     QTextFormat();
    00273
    00274     explicit QTextFormat(int type);
    00275
    00276     QTextFormat(const QTextFormat &rhs);
    00277     QTextFormat &operator=(const QTextFormat &rhs);
    00278     ~QTextFormat();
    00279
    00280     void merge(const QTextFormat &other);
    00281
    00282     inline bool isValid() const { return type() != InvalidFormat; }
    00283
    00284     int type() const;
    00285
    00286     int objectIndex() const;
    00287     void setObjectIndex(int object);
    00288
    00289     QVariant property(int propertyId) const;
    00290     void setProperty(int propertyId, const QVariant &value);
    00291     void clearProperty(int propertyId);
    00292     bool hasProperty(int propertyId) const;
    00293
    00294     bool boolProperty(int propertyId) const;
    00295     int intProperty(int propertyId) const;
    00296     qreal doubleProperty(int propertyId) const;
    00297     QString stringProperty(int propertyId) const;
    00298     QColor colorProperty(int propertyId) const;
    00299     QPen penProperty(int propertyId) const;
    00300     QBrush brushProperty(int propertyId) const;
    00301     QTextLength lengthProperty(int propertyId) const;
    00302     QVector<QTextLength> lengthVectorProperty(int propertyId) const;
    00303
    00304     void setProperty(int propertyId, const QVector<QTextLength> &lengths);
    00305
    00306     QMap<int, QVariant> properties() const;
    00307     int propertyCount() const;
    00308
    00309     inline void setObjectType(int type);
    00310     inline int objectType() const
    00311     { return intProperty(ObjectType); }
    00312
    00313     inline bool isCharFormat() const { return type() == CharFormat; }
    00314     inline bool isBlockFormat() const { return type() == BlockFormat; }
    00315     inline bool isListFormat() const { return type() == ListFormat; }
    00316     inline bool isFrameFormat() const { return type() == FrameFormat; }
    00317     inline bool isImageFormat() const { return type() == CharFormat && objectType() == ImageObject; }
    00318     inline bool isTableFormat() const { return type() == FrameFormat && objectType() == TableObject; }
    00319     inline bool isTableCellFormat() const { return type() == CharFormat && objectType() == TableCellObject; }
    00320
    00321     QTextBlockFormat toBlockFormat() const;
    00322     QTextCharFormat toCharFormat() const;
    00323     QTextListFormat toListFormat() const;
    00324     QTextTableFormat toTableFormat() const;
    00325     QTextFrameFormat toFrameFormat() const;
    00326     QTextImageFormat toImageFormat() const;
    00327     QTextTableCellFormat toTableCellFormat() const;
    00328
    00329     bool operator==(const QTextFormat &rhs) const;
    00330     inline bool operator!=(const QTextFormat &rhs) const { return !operator==(rhs); }
    00331     operator QVariant() const;
    00332
    00333     inline void setLayoutDirection(Qt::LayoutDirection direction)
    00334         { setProperty(QTextFormat::LayoutDirection, direction); }
    00335     inline Qt::LayoutDirection layoutDirection() const
    00336         { return Qt::LayoutDirection(intProperty(QTextFormat::LayoutDirection)); }
    00337
    00338     inline void setBackground(const QBrush &brush)
    00339     { setProperty(BackgroundBrush, brush); }
    00340     inline QBrush background() const
    00341     { return brushProperty(BackgroundBrush); }
    00342     inline void clearBackground()
    00343     { clearProperty(BackgroundBrush); }
    00344
    00345     inline void setForeground(const QBrush &brush)
    00346     { setProperty(ForegroundBrush, brush); }
    00347     inline QBrush foreground() const
    00348     { return brushProperty(ForegroundBrush); }
    00349     inline void clearForeground()
    00350     { clearProperty(ForegroundBrush); }
    00351
    00352 private:
    00353     QSharedDataPointer<QTextFormatPrivate> d;
    00354     qint32 format_type;
    00355
    00356     friend class QTextFormatCollection;
    00357     friend class QTextCharFormat;
    00358     friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTextFormat &);
    00359     friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTextFormat &);
    00360 };
    00361
    00362 inline void QTextFormat::setObjectType(int atype)
    00363 { setProperty(ObjectType, atype); }
    00364
    00365 Q_DECLARE_OPERATORS_FOR_FLAGS(QTextFormat::PageBreakFlags)
    00366
    00367 class Q_GUI_EXPORT QTextCharFormat : public QTextFormat
    00368 {
    00369 public:
    00370     enum VerticalAlignment {
    00371         AlignNormal = 0,
    00372         AlignSuperScript,
    00373         AlignSubScript,
    00374         AlignMiddle,
    00375         AlignTop,
    00376         AlignBottom
    00377     };
    00378     enum UnderlineStyle { // keep in sync with Qt::PenStyle!
    00379         NoUnderline,
    00380         SingleUnderline,
    00381         DashUnderline,
    00382         DotLine,
    00383         DashDotLine,
    00384         DashDotDotLine,
    00385         WaveUnderline,
    00386         SpellCheckUnderline
    00387     };
    00388
    00389     QTextCharFormat();
    00390
    00391     bool isValid() const { return isCharFormat(); }
    00392     void setFont(const QFont &font);
    00393     QFont font() const;
    00394
    00395     inline void setFontFamily(const QString &family)
    00396     { setProperty(FontFamily, family); }
    00397     inline QString fontFamily() const
    00398     { return stringProperty(FontFamily); }
    00399
    00400     inline void setFontPointSize(qreal size)
    00401     { setProperty(FontPointSize, size); }
    00402     inline qreal fontPointSize() const
    00403     { return doubleProperty(FontPointSize); }
    00404
    00405     inline void setFontWeight(int weight)
    00406     { if (weight == QFont::Normal) weight = 0; setProperty(FontWeight, weight); }
    00407     inline int fontWeight() const
    00408     { int weight = intProperty(FontWeight); if (weight == 0) weight = QFont::Normal; return weight; }
    00409     inline void setFontItalic(bool italic)
    00410     { setProperty(FontItalic, italic); }
    00411     inline bool fontItalic() const
    00412     { return boolProperty(FontItalic); }
    00413     inline void setFontCapitalization(QFont::Capitalization capitalization)
    00414     { setProperty(FontCapitalization, capitalization); }
    00415     inline QFont::Capitalization fontCapitalization() const
    00416     { return static_cast<QFont::Capitalization>(intProperty(FontCapitalization)); }
    00417     inline void setFontLetterSpacing(qreal spacing)
    00418     { setProperty(FontLetterSpacing, spacing); }
    00419     inline qreal fontLetterSpacing() const
    00420     { return doubleProperty(FontLetterSpacing); }
    00421     inline void setFontWordSpacing(qreal spacing)
    00422     { setProperty(FontWordSpacing, spacing); }
    00423     inline qreal fontWordSpacing() const
    00424     { return doubleProperty(FontWordSpacing); }
    00425
    00426     inline void setFontUnderline(bool underline)
    00427     { setProperty(TextUnderlineStyle, underline ? SingleUnderline : NoUnderline); }
    00428     bool fontUnderline() const;
    00429
    00430     inline void setFontOverline(bool overline)
    00431     { setProperty(FontOverline, overline); }
    00432     inline bool fontOverline() const
    00433     { return boolProperty(FontOverline); }
    00434
    00435     inline void setFontStrikeOut(bool strikeOut)
    00436     { setProperty(FontStrikeOut, strikeOut); }
    00437     inline bool fontStrikeOut() const
    00438     { return boolProperty(FontStrikeOut); }
    00439
    00440     inline void setUnderlineColor(const QColor &color)
    00441     { setProperty(TextUnderlineColor, color); }
    00442     inline QColor underlineColor() const
    00443     { return colorProperty(TextUnderlineColor); }
    00444
    00445     inline void setFontFixedPitch(bool fixedPitch)
    00446     { setProperty(FontFixedPitch, fixedPitch); }
    00447     inline bool fontFixedPitch() const
    00448     { return boolProperty(FontFixedPitch); }
    00449
    00450     inline void setFontStyleHint(QFont::StyleHint hint, QFont::StyleStrategy strategy = QFont::PreferDefault)
    00451     { setProperty(FontStyleHint, hint); setProperty(FontStyleStrategy, strategy); }
    00452     inline void setFontStyleStrategy(QFont::StyleStrategy strategy)
    00453     { setProperty(FontStyleStrategy, strategy); }
    00454     QFont::StyleHint fontStyleHint() const
    00455     { return static_cast<QFont::StyleHint>(intProperty(FontStyleHint)); }
    00456     QFont::StyleStrategy fontStyleStrategy() const
    00457     { return static_cast<QFont::StyleStrategy>(intProperty(FontStyleStrategy)); }
    00458
    00459     inline void setFontKerning(bool enable)
    00460     { setProperty(FontKerning, enable); }
    00461     inline bool fontKerning() const
    00462     { return boolProperty(FontKerning); }
    00463
    00464     void setUnderlineStyle(UnderlineStyle style);
    00465     inline UnderlineStyle underlineStyle() const
    00466     { return static_cast<UnderlineStyle>(intProperty(TextUnderlineStyle)); }
    00467
    00468     inline void setVerticalAlignment(VerticalAlignment alignment)
    00469     { setProperty(TextVerticalAlignment, alignment); }
    00470     inline VerticalAlignment verticalAlignment() const
    00471     { return static_cast<VerticalAlignment>(intProperty(TextVerticalAlignment)); }
    00472
    00473     inline void setTextOutline(const QPen &pen)
    00474     { setProperty(TextOutline, pen); }
    00475     inline QPen textOutline() const
    00476     { return penProperty(TextOutline); }
    00477
    00478     inline void setToolTip(const QString &tip)
    00479     { setProperty(TextToolTip, tip); }
    00480     inline QString toolTip() const
    00481     { return stringProperty(TextToolTip); }
    00482
    00483     inline void setAnchor(bool anchor)
    00484     { setProperty(IsAnchor, anchor); }
    00485     inline bool isAnchor() const
    00486     { return boolProperty(IsAnchor); }
    00487
    00488     inline void setAnchorHref(const QString &value)
    00489     { setProperty(AnchorHref, value); }
    00490     inline QString anchorHref() const
    00491     { return stringProperty(AnchorHref); }
    00492
    00493     inline void setAnchorName(const QString &name)
    00494     { setAnchorNames(QStringList(name)); }
    00495     QString anchorName() const;
    00496
    00497     inline void setAnchorNames(const QStringList &names)
    00498     { setProperty(AnchorName, names); }
    00499     QStringList anchorNames() const;
    00500
    00501     inline void setTableCellRowSpan(int tableCellRowSpan);
    00502     inline int tableCellRowSpan() const
    00503     { int s = intProperty(TableCellRowSpan); if (s == 0) s = 1; return s; }
    00504     inline void setTableCellColumnSpan(int tableCellColumnSpan);
    00505     inline int tableCellColumnSpan() const
    00506     { int s = intProperty(TableCellColumnSpan); if (s == 0) s = 1; return s; }
    00507
    00508 protected:
    00509     explicit QTextCharFormat(const QTextFormat &fmt);
    00510     friend class QTextFormat;
    00511 };
    00512
    00513 inline void QTextCharFormat::setTableCellRowSpan(int _tableCellRowSpan)
    00514 {
    00515     if (_tableCellRowSpan <= 1)
    00516         clearProperty(TableCellRowSpan); // the getter will return 1 here.
    00517     else
    00518         setProperty(TableCellRowSpan, _tableCellRowSpan);
    00519 }
    00520
    00521 inline void QTextCharFormat::setTableCellColumnSpan(int _tableCellColumnSpan)
    00522 {
    00523     if (_tableCellColumnSpan <= 1)
    00524         clearProperty(TableCellColumnSpan); // the getter will return 1 here.
    00525     else
    00526         setProperty(TableCellColumnSpan, _tableCellColumnSpan);
    00527 }
    00528
    00529 class Q_GUI_EXPORT QTextBlockFormat : public QTextFormat
    00530 {
    00531 public:
    00532     QTextBlockFormat();
    00533
    00534     bool isValid() const { return isBlockFormat(); }
    00535
    00536     inline void setAlignment(Qt::Alignment alignment);
    00537     inline Qt::Alignment alignment() const
    00538     { int a = intProperty(BlockAlignment); if (a == 0) a = Qt::AlignLeft; return QFlag(a); }
    00539
    00540     inline void setTopMargin(qreal margin)
    00541     { setProperty(BlockTopMargin, margin); }
    00542     inline qreal topMargin() const
    00543     { return doubleProperty(BlockTopMargin); }
    00544
    00545     inline void setBottomMargin(qreal margin)
    00546     { setProperty(BlockBottomMargin, margin); }
    00547     inline qreal bottomMargin() const
    00548     { return doubleProperty(BlockBottomMargin); }
    00549
    00550     inline void setLeftMargin(qreal margin)
    00551     { setProperty(BlockLeftMargin, margin); }
    00552     inline qreal leftMargin() const
    00553     { return doubleProperty(BlockLeftMargin); }
    00554
    00555     inline void setRightMargin(qreal margin)
    00556     { setProperty(BlockRightMargin, margin); }
    00557     inline qreal rightMargin() const
    00558     { return doubleProperty(BlockRightMargin); }
    00559
    00560     inline void setTextIndent(qreal aindent)
    00561     { setProperty(TextIndent, aindent); }
    00562     inline qreal textIndent() const
    00563     { return doubleProperty(TextIndent); }
    00564
    00565     inline void setIndent(int indent);
    00566     inline int indent() const
    00567     { return intProperty(BlockIndent); }
    00568
    00569     inline void setNonBreakableLines(bool b)
    00570     { setProperty(BlockNonBreakableLines, b); }
    00571     inline bool nonBreakableLines() const
    00572     { return boolProperty(BlockNonBreakableLines); }
    00573
    00574     inline void setPageBreakPolicy(PageBreakFlags flags)
    00575     { setProperty(PageBreakPolicy, int(flags)); }
    00576     inline PageBreakFlags pageBreakPolicy() const
    00577     { return PageBreakFlags(intProperty(PageBreakPolicy)); }
    00578
    00579     void setTabPositions(const QList<QTextOption::Tab> &tabs);
    00580     QList<QTextOption::Tab> tabPositions() const;
    00581
    00582 protected:
    00583     explicit QTextBlockFormat(const QTextFormat &fmt);
    00584     friend class QTextFormat;
    00585 };
    00586
    00587 inline void QTextBlockFormat::setAlignment(Qt::Alignment aalignment)
    00588 { setProperty(BlockAlignment, int(aalignment)); }
    00589
    00590 inline void QTextBlockFormat::setIndent(int aindent)
    00591 { setProperty(BlockIndent, aindent); }
    00592
    00593 class Q_GUI_EXPORT QTextListFormat : public QTextFormat
    00594 {
    00595 public:
    00596     QTextListFormat();
    00597
    00598     bool isValid() const { return isListFormat(); }
    00599
    00600     enum Style {
    00601         ListDisc = -1,
    00602         ListCircle = -2,
    00603         ListSquare = -3,
    00604         ListDecimal = -4,
    00605         ListLowerAlpha = -5,
    00606         ListUpperAlpha = -6,
    00607         ListLowerRoman = -7,
    00608         ListUpperRoman = -8,
    00609         ListStyleUndefined = 0
    00610     };
    00611
    00612     inline void setStyle(Style style);
    00613     inline Style style() const
    00614     { return static_cast<Style>(intProperty(ListStyle)); }
    00615
    00616     inline void setIndent(int indent);
    00617     inline int indent() const
    00618     { return intProperty(ListIndent); }
    00619
    00620 protected:
    00621     explicit QTextListFormat(const QTextFormat &fmt);
    00622     friend class QTextFormat;
    00623 };
    00624
    00625 inline void QTextListFormat::setStyle(Style astyle)
    00626 { setProperty(ListStyle, astyle); }
    00627
    00628 inline void QTextListFormat::setIndent(int aindent)
    00629 { setProperty(ListIndent, aindent); }
    00630
    00631 class Q_GUI_EXPORT QTextImageFormat : public QTextCharFormat
    00632 {
    00633 public:
    00634     QTextImageFormat();
    00635
    00636     bool isValid() const { return isImageFormat(); }
    00637
    00638     inline void setName(const QString &name);
    00639     inline QString name() const
    00640     { return stringProperty(ImageName); }
    00641
    00642     inline void setWidth(qreal width);
    00643     inline qreal width() const
    00644     { return doubleProperty(ImageWidth); }
    00645
    00646     inline void setHeight(qreal height);
    00647     inline qreal height() const
    00648     { return doubleProperty(ImageHeight); }
    00649
    00650 protected:
    00651     explicit QTextImageFormat(const QTextFormat &format);
    00652     friend class QTextFormat;
    00653 };
    00654
    00655 inline void QTextImageFormat::setName(const QString &aname)
    00656 { setProperty(ImageName, aname); }
    00657
    00658 inline void QTextImageFormat::setWidth(qreal awidth)
    00659 { setProperty(ImageWidth, awidth); }
    00660
    00661 inline void QTextImageFormat::setHeight(qreal aheight)
    00662 { setProperty(ImageHeight, aheight); }
    00663
    00664 class Q_GUI_EXPORT QTextFrameFormat : public QTextFormat
    00665 {
    00666 public:
    00667     QTextFrameFormat();
    00668
    00669     bool isValid() const { return isFrameFormat(); }
    00670
    00671     enum Position {
    00672         InFlow,
    00673         FloatLeft,
    00674         FloatRight
    00675         // ######
    00676 //        Absolute
    00677     };
    00678
    00679     enum BorderStyle {
    00680         BorderStyle_None,
    00681         BorderStyle_Dotted,
    00682         BorderStyle_Dashed,
    00683         BorderStyle_Solid,
    00684         BorderStyle_Double,
    00685         BorderStyle_DotDash,
    00686         BorderStyle_DotDotDash,
    00687         BorderStyle_Groove,
    00688         BorderStyle_Ridge,
    00689         BorderStyle_Inset,
    00690         BorderStyle_Outset
    00691     };
    00692
    00693     inline void setPosition(Position f)
    00694     { setProperty(CssFloat, f); }
    00695     inline Position position() const
    00696     { return static_cast<Position>(intProperty(CssFloat)); }
    00697
    00698     inline void setBorder(qreal border);
    00699     inline qreal border() const
    00700     { return doubleProperty(FrameBorder); }
    00701
    00702     inline void setBorderBrush(const QBrush &brush)
    00703     { setProperty(FrameBorderBrush, brush); }
    00704     inline QBrush borderBrush() const
    00705     { return brushProperty(FrameBorderBrush); }
    00706
    00707     inline void setBorderStyle(BorderStyle style)
    00708     { setProperty(FrameBorderStyle, style); }
    00709     inline BorderStyle borderStyle() const
    00710     { return static_cast<BorderStyle>(intProperty(FrameBorderStyle)); }
    00711
    00712     void setMargin(qreal margin);
    00713     inline qreal margin() const
    00714     { return doubleProperty(FrameMargin); }
    00715
    00716     inline void setTopMargin(qreal margin);
    00717     qreal topMargin() const;
    00718
    00719     inline void setBottomMargin(qreal margin);
    00720     qreal bottomMargin() const;
    00721
    00722     inline void setLeftMargin(qreal margin);
    00723     qreal leftMargin() const;
    00724
    00725     inline void setRightMargin(qreal margin);
    00726     qreal rightMargin() const;
    00727
    00728     inline void setPadding(qreal padding);
    00729     inline qreal padding() const
    00730     { return doubleProperty(FramePadding); }
    00731
    00732     inline void setWidth(qreal width);
    00733     inline void setWidth(const QTextLength &length)
    00734     { setProperty(FrameWidth, length); }
    00735     inline QTextLength width() const
    00736     { return lengthProperty(FrameWidth); }
    00737
    00738     inline void setHeight(qreal height);
    00739     inline void setHeight(const QTextLength &height);
    00740     inline QTextLength height() const
    00741     { return lengthProperty(FrameHeight); }
    00742
    00743     inline void setPageBreakPolicy(PageBreakFlags flags)
    00744     { setProperty(PageBreakPolicy, int(flags)); }
    00745     inline PageBreakFlags pageBreakPolicy() const
    00746     { return PageBreakFlags(intProperty(PageBreakPolicy)); }
    00747
    00748 protected:
    00749     explicit QTextFrameFormat(const QTextFormat &fmt);
    00750     friend class QTextFormat;
    00751 };
    00752
    00753 inline void QTextFrameFormat::setBorder(qreal aborder)
    00754 { setProperty(FrameBorder, aborder); }
    00755
    00756 inline void QTextFrameFormat::setPadding(qreal apadding)
    00757 { setProperty(FramePadding, apadding); }
    00758
    00759 inline void QTextFrameFormat::setWidth(qreal awidth)
    00760 { setProperty(FrameWidth, QTextLength(QTextLength::FixedLength, awidth)); }
    00761
    00762 inline void QTextFrameFormat::setHeight(qreal aheight)
    00763 { setProperty(FrameHeight, QTextLength(QTextLength::FixedLength, aheight)); }
    00764 inline void QTextFrameFormat::setHeight(const QTextLength &aheight)
    00765 { setProperty(FrameHeight, aheight); }
    00766
    00767 inline void QTextFrameFormat::setTopMargin(qreal amargin)
    00768 { setProperty(FrameTopMargin, amargin); }
    00769
    00770 inline void QTextFrameFormat::setBottomMargin(qreal amargin)
    00771 { setProperty(FrameBottomMargin, amargin); }
    00772
    00773 inline void QTextFrameFormat::setLeftMargin(qreal amargin)
    00774 { setProperty(FrameLeftMargin, amargin); }
    00775
    00776 inline void QTextFrameFormat::setRightMargin(qreal amargin)
    00777 { setProperty(FrameRightMargin, amargin); }
    00778
    00779 class Q_GUI_EXPORT QTextTableFormat : public QTextFrameFormat
    00780 {
    00781 public:
    00782     QTextTableFormat();
    00783
    00784     inline bool isValid() const { return isTableFormat(); }
    00785
    00786     inline int columns() const
    00787     { int cols = intProperty(TableColumns); if (cols == 0) cols = 1; return cols; }
    00788     inline void setColumns(int columns);
    00789
    00790     inline void setColumnWidthConstraints(const QVector<QTextLength> &constraints)
    00791     { setProperty(TableColumnWidthConstraints, constraints); }
    00792
    00793     inline QVector<QTextLength> columnWidthConstraints() const
    00794     { return lengthVectorProperty(TableColumnWidthConstraints); }
    00795
    00796     inline void clearColumnWidthConstraints()
    00797     { clearProperty(TableColumnWidthConstraints); }
    00798
    00799     inline qreal cellSpacing() const
    00800     { return doubleProperty(TableCellSpacing); }
    00801     inline void setCellSpacing(qreal spacing)
    00802     { setProperty(TableCellSpacing, spacing); }
    00803
    00804     inline qreal cellPadding() const
    00805     { return doubleProperty(TableCellPadding); }
    00806     inline void setCellPadding(qreal padding);
    00807
    00808     inline void setAlignment(Qt::Alignment alignment);
    00809     inline Qt::Alignment alignment() const
    00810     { return QFlag(intProperty(BlockAlignment)); }
    00811
    00812     inline void setHeaderRowCount(int count)
    00813     { setProperty(TableHeaderRowCount, count); }
    00814     inline int headerRowCount() const
    00815     { return intProperty(TableHeaderRowCount); }
    00816
    00817 protected:
    00818     explicit QTextTableFormat(const QTextFormat &fmt);
    00819     friend class QTextFormat;
    00820 };
    00821
    00822 inline void QTextTableFormat::setColumns(int acolumns)
    00823 {
    00824     if (acolumns == 1)
    00825         acolumns = 0;
    00826     setProperty(TableColumns, acolumns);
    00827 }
    00828
    00829 inline void QTextTableFormat::setCellPadding(qreal apadding)
    00830 { setProperty(TableCellPadding, apadding); }
    00831
    00832 inline void QTextTableFormat::setAlignment(Qt::Alignment aalignment)
    00833 { setProperty(BlockAlignment, int(aalignment)); }
    00834
    00835 class Q_GUI_EXPORT QTextTableCellFormat : public QTextCharFormat
    00836 {
    00837 public:
    00838     QTextTableCellFormat();
    00839
    00840     inline bool isValid() const { return isTableCellFormat(); }
    00841
    00842     inline void setTopPadding(qreal padding);
    00843     inline qreal topPadding() const;
    00844
    00845     inline void setBottomPadding(qreal padding);
    00846     inline qreal bottomPadding() const;
    00847
    00848     inline void setLeftPadding(qreal padding);
    00849     inline qreal leftPadding() const;
    00850
    00851     inline void setRightPadding(qreal padding);
    00852     inline qreal rightPadding() const;
    00853
    00854     inline void setPadding(qreal padding);
    00855
    00856 protected:
    00857     explicit QTextTableCellFormat(const QTextFormat &fmt);
    00858     friend class QTextFormat;
    00859 };
    00860
    00861 inline void QTextTableCellFormat::setTopPadding(qreal padding)
    00862 {
    00863     setProperty(TableCellTopPadding, padding);
    00864 }
    00865
    00866 inline qreal QTextTableCellFormat::topPadding() const
    00867 {
    00868     return doubleProperty(TableCellTopPadding);
    00869 }
    00870
    00871 inline void QTextTableCellFormat::setBottomPadding(qreal padding)
    00872 {
    00873     setProperty(TableCellBottomPadding, padding);
    00874 }
    00875
    00876 inline qreal QTextTableCellFormat::bottomPadding() const
    00877 {
    00878     return doubleProperty(TableCellBottomPadding);
    00879 }
    00880
    00881 inline void QTextTableCellFormat::setLeftPadding(qreal padding)
    00882 {
    00883     setProperty(TableCellLeftPadding, padding);
    00884 }
    00885
    00886 inline qreal QTextTableCellFormat::leftPadding() const
    00887 {
    00888     return doubleProperty(TableCellLeftPadding);
    00889 }
    00890
    00891 inline void QTextTableCellFormat::setRightPadding(qreal padding)
    00892 {
    00893     setProperty(TableCellRightPadding, padding);
    00894 }
    00895
    00896 inline qreal QTextTableCellFormat::rightPadding() const
    00897 {
    00898     return doubleProperty(TableCellRightPadding);
    00899 }
    00900
    00901 inline void QTextTableCellFormat::setPadding(qreal padding)
    00902 {
    00903     setTopPadding(padding);
    00904     setBottomPadding(padding);
    00905     setLeftPadding(padding);
    00906     setRightPadding(padding);
    00907 }
    00908
    00909
    00910 QT_END_NAMESPACE
    00911
    00912 QT_END_HEADER
    00913
    00914 #endif // QTEXTFORMAT_H