com.trolltech.qt.gui
Class QTextFormat

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.gui.QTextFormat
All Implemented Interfaces:
QtJambiInterface
Direct Known Subclasses:
QTextBlockFormat, QTextCharFormat, QTextFrameFormat, QTextListFormat

public class QTextFormat
extends QtJambiObject

The QTextFormat class provides formatting information for a QTextDocument.

A QTextFormat is a generic class used for describing the format of parts of a QTextDocument. The derived classes QTextCharFormat, QTextBlockFormat, QTextListFormat, and QTextTableFormat are usually more useful, and describe the formatting that is applied to specific parts of the document.

A format has a FormatType which specifies the kinds of thing it can format; e.g. a block of text, a list, a table, etc. A format also has various properties (some specific to particular format types), as described by the Property enum. Every property has a corresponding Property.

The format type is given by type, and the format can be tested with isCharFormat, isBlockFormat, isListFormat, isTableFormat, isFrameFormat, and isImageFormat. If the type is determined, it can be retrieved with toCharFormat, toBlockFormat, toListFormat, toTableFormat, toFrameFormat, and toImageFormat.

A format's properties can be set with the setProperty functions, and retrieved with boolProperty, intProperty, doubleProperty, and stringProperty as appropriate. All the property IDs used in the format can be retrieved with allPropertyIds(). One format can be merged into another using merge.

A format's object index can be set with setObjectIndex, and retrieved with objectIndex. These methods can be used to associate the format with a QTextObject. It is used to represent lists, frames, and tables inside the document.

See Also:
Processing Classes

Nested Class Summary
static class QTextFormat.FormatType
          Press link for info on QTextFormat.FormatType
static class QTextFormat.ObjectTypes
          Press link for info on QTextFormat.ObjectTypes
static class QTextFormat.PageBreakFlag
          Press link for info on QTextFormat.PageBreakFlag
static class QTextFormat.PageBreakFlags
          This QFlag class provides flags for the int enum.
static class QTextFormat.Property
          Press link for information on QTextFormat.Property.
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Constructor Summary
QTextFormat()
          Creates a new text format with an InvalidFormat.
QTextFormat(int type)
          Creates a new text format of the given type.
QTextFormat(QTextFormat rhs)
          Creates a new text format with the same attributes as the rhs text format.
 
Method Summary
 QBrush background()
          Returns the brush used to paint the document's background.
 boolean boolProperty(int propertyId)
          Returns the value of the property specified by propertyId.
 QBrush brushProperty(int propertyId)
          Returns the value of the property given by propertyId; if the property isn't of QVariant::Brush type, Qt::NoBrush is returned instead.
 void clearBackground()
          Clears the brush used to paint the document's background.
 void clearForeground()
          Clears the brush used to paint the document's foreground.
 void clearProperty(int propertyId)
          Clears the value of the property given by propertyId
 QColor colorProperty(int propertyId)
          Returns the value of the property given by propertyId; if the property isn't of QVariant::Color type, an invalid color is returned instead.
 double doubleProperty(int propertyId)
          Returns the value of the property specified by propertyId.
 boolean equals(java.lang.Object other)
          
 QBrush foreground()
          Returns the brush used to render foreground details, such as text, frame outlines, and table borders.
static QTextFormat fromNativePointer(QNativePointer nativePointer)
          This function returns the QTextFormat instance pointed to by nativePointer
 boolean hasProperty(int propertyId)
          Returns true if the text format has a property with the given propertyId; otherwise returns false.
 int intProperty(int propertyId)
          Returns the value of the property specified by propertyId.
 boolean isBlockFormat()
          Returns true if this text format is a BlockFormat; otherwise returns false.
 boolean isCharFormat()
          Returns true if this text format is a CharFormat; otherwise returns false.
 boolean isFrameFormat()
          Returns true if this text format is a FrameFormat; otherwise returns false.
 boolean isImageFormat()
          Returns true if this text format is an image format; otherwise returns false.
 boolean isListFormat()
          Returns true if this text format is a ListFormat; otherwise returns false.
 boolean isTableFormat()
          Returns true if this text format is a TableFormat; otherwise returns false.
 boolean isValid()
          Returns true if the format is valid (i.e. is not InvalidFormat); otherwise returns false.
 Qt.LayoutDirection layoutDirection()
          Returns the document's layout direction.
 QTextLength lengthProperty(int propertyId)
          Returns the value of the property given by propertyId.
 java.util.List<QTextLength> lengthVectorProperty(int propertyId)
          Returns the value of the property given by propertyId.
 void merge(QTextFormat other)
          Merges the other format with this format; where there are conflicts the other format takes precedence.
static QNativePointer nativePointerArray(QTextFormat[] array)
          This function returns a QNativePointer that is pointing to the specified QTextFormat array.
 int objectIndex()
          Returns the index of the format object, or -1 if the format object is invalid.
 int objectType()
          Returns the text format's object type.
 QPen penProperty(int propertyId)
          Returns the value of the property given by propertyId; if the property isn't of QVariant::Pen type, Qt::NoPen is returned instead.
 java.util.SortedMap<java.lang.Integer,java.lang.Object> properties()
          Returns a map with all properties of this text format.
 java.lang.Object property(int propertyId)
          Returns the property specified by the given propertyId.
 int propertyCount()
          Returns the number of properties stored in the format.
 void readFrom(QDataStream arg__1)
          Reads a QTextFormat from arg__1.
 void setBackground(QBrush brush)
          Sets the brush use to paint the document's background to the brush specified.
 void setForeground(QBrush brush)
          Sets the foreground brush to the specified brush.
 void setLayoutDirection(Qt.LayoutDirection direction)
          Sets the document's layout direction to the specified direction.
 void setObjectIndex(int object)
          Sets the format object's object object.
 void setObjectType(int type)
          Sets the text format's object type.
 void setProperty(int propertyId, java.util.List<QTextLength> lengths)
          Sets the value of the property given by propertyId to lengths.
 void setProperty(int propertyId, java.lang.Object value)
          Sets the property specified by the propertyId to the given value.
 java.lang.String stringProperty(int propertyId)
          Returns the value of the property given by propertyId; if the property isn't of QVariant::String type, an empty string is returned instead.
 QTextBlockFormat toBlockFormat()
          Returns this format as a block format.
 QTextCharFormat toCharFormat()
          Returns this format as a character format.
 QTextFrameFormat toFrameFormat()
          Returns this format as a frame format.
 QTextImageFormat toImageFormat()
          Returns this format as an image format.
 QTextListFormat toListFormat()
          Returns this format as a list format.
 QTextTableFormat toTableFormat()
          Returns this format as a table format.
 int type()
          Returns the type of this format.
 void writeTo(QDataStream arg__1)
          Writes thisQTextFormat to arg__1.
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Constructor Detail

QTextFormat

public QTextFormat(QTextFormat rhs)

Creates a new text format with the same attributes as the rhs text format.


QTextFormat

public QTextFormat()

Creates a new text format with an InvalidFormat.

See Also:
FormatType

QTextFormat

public QTextFormat(int type)

Creates a new text format of the given type.

See Also:
FormatType
Method Detail

background

public final QBrush background()

Returns the brush used to paint the document's background.

See Also:
setBackground, clearBackground, foreground

boolProperty

public final boolean boolProperty(int propertyId)

Returns the value of the property specified by propertyId. If the property isn't of QTextFormat::Bool type, false is returned instead.

See Also:
setProperty, intProperty, doubleProperty, stringProperty, colorProperty, lengthProperty, lengthVectorProperty, Property

brushProperty

public final QBrush brushProperty(int propertyId)

Returns the value of the property given by propertyId; if the property isn't of QVariant::Brush type, Qt::NoBrush is returned instead.

See Also:
setProperty, boolProperty, intProperty, doubleProperty, stringProperty, lengthProperty, lengthVectorProperty, Property

clearBackground

public final void clearBackground()

Clears the brush used to paint the document's background. The default brush will be used.

See Also:
background, setBackground, clearForeground

clearForeground

public final void clearForeground()

Clears the brush used to paint the document's foreground. The default brush will be used.

See Also:
foreground, setForeground, clearBackground

clearProperty

public final void clearProperty(int propertyId)

Clears the value of the property given by propertyId


colorProperty

public final QColor colorProperty(int propertyId)

Returns the value of the property given by propertyId; if the property isn't of QVariant::Color type, an invalid color is returned instead.

See Also:
setProperty, boolProperty, intProperty, doubleProperty, stringProperty, lengthProperty, lengthVectorProperty, Property

doubleProperty

public final double doubleProperty(int propertyId)

Returns the value of the property specified by propertyId. If the property isn't of QVariant::Double type, 0 is returned instead.

See Also:
setProperty, boolProperty, intProperty, stringProperty, colorProperty, lengthProperty, lengthVectorProperty, Property

foreground

public final QBrush foreground()

Returns the brush used to render foreground details, such as text, frame outlines, and table borders.

See Also:
setForeground, clearForeground, background

hasProperty

public final boolean hasProperty(int propertyId)

Returns true if the text format has a property with the given propertyId; otherwise returns false.

See Also:
properties, Property

intProperty

public final int intProperty(int propertyId)

Returns the value of the property specified by propertyId. If the property is not of QTextFormat::Integer type, 0 is returned instead.

See Also:
setProperty, boolProperty, doubleProperty, stringProperty, colorProperty, lengthProperty, lengthVectorProperty, Property

isBlockFormat

public final boolean isBlockFormat()

Returns true if this text format is a BlockFormat; otherwise returns false.


isCharFormat

public final boolean isCharFormat()

Returns true if this text format is a CharFormat; otherwise returns false.


isFrameFormat

public final boolean isFrameFormat()

Returns true if this text format is a FrameFormat; otherwise returns false.


isImageFormat

public final boolean isImageFormat()

Returns true if this text format is an image format; otherwise returns false.


isListFormat

public final boolean isListFormat()

Returns true if this text format is a ListFormat; otherwise returns false.


isTableFormat

public final boolean isTableFormat()

Returns true if this text format is a TableFormat; otherwise returns false.


isValid

public boolean isValid()

Returns true if the format is valid (i.e. is not InvalidFormat); otherwise returns false.


layoutDirection

public final Qt.LayoutDirection layoutDirection()

Returns the document's layout direction.

See Also:
setLayoutDirection

lengthProperty

public final QTextLength lengthProperty(int propertyId)

Returns the value of the property given by propertyId.

See Also:
setProperty, boolProperty, intProperty, doubleProperty, stringProperty, colorProperty, lengthVectorProperty, Property

lengthVectorProperty

public final java.util.List<QTextLength> lengthVectorProperty(int propertyId)

Returns the value of the property given by propertyId. If the property isn't of QTextFormat::LengthVector type, an empty length vector is returned instead.

See Also:
setProperty, boolProperty, intProperty, doubleProperty, stringProperty, colorProperty, lengthProperty, Property

merge

public final void merge(QTextFormat other)

Merges the other format with this format; where there are conflicts the other format takes precedence.


objectIndex

public final int objectIndex()

Returns the index of the format object, or -1 if the format object is invalid.

See Also:
setObjectIndex

objectType

public final int objectType()

Returns the text format's object type. See ObjectTypes.

See Also:
setObjectType

writeTo

public final void writeTo(QDataStream arg__1)
Writes thisQTextFormat to arg__1.


readFrom

public final void readFrom(QDataStream arg__1)
Reads a QTextFormat from arg__1.


penProperty

public final QPen penProperty(int propertyId)

Returns the value of the property given by propertyId; if the property isn't of QVariant::Pen type, Qt::NoPen is returned instead.

See Also:
setProperty, boolProperty, intProperty, doubleProperty, stringProperty, lengthProperty, lengthVectorProperty, Property

properties

public final java.util.SortedMap<java.lang.Integer,java.lang.Object> properties()

Returns a map with all properties of this text format.


property

public final java.lang.Object property(int propertyId)

Returns the property specified by the given propertyId.

See Also:
setProperty

propertyCount

public final int propertyCount()

Returns the number of properties stored in the format.


setBackground

public final void setBackground(QBrush brush)

Sets the brush use to paint the document's background to the brush specified.

See Also:
background, clearBackground, setForeground

setForeground

public final void setForeground(QBrush brush)

Sets the foreground brush to the specified brush. The foreground brush is mostly used to render text.

See Also:
foreground, clearForeground, setBackground

setLayoutDirection

public final void setLayoutDirection(Qt.LayoutDirection direction)

Sets the document's layout direction to the specified direction.

See Also:
layoutDirection

setObjectIndex

public final void setObjectIndex(int object)

Sets the format object's object object.

See Also:
objectIndex

setObjectType

public final void setObjectType(int type)

Sets the text format's object type. See ObjectTypes.

See Also:
objectType

setProperty

public final void setProperty(int propertyId,
                              java.util.List<QTextLength> lengths)

Sets the value of the property given by propertyId to lengths.

See Also:
lengthVectorProperty, Property

setProperty

public final void setProperty(int propertyId,
                              java.lang.Object value)

Sets the property specified by the propertyId to the given value.

See Also:
property

stringProperty

public final java.lang.String stringProperty(int propertyId)

Returns the value of the property given by propertyId; if the property isn't of QVariant::String type, an empty string is returned instead.

See Also:
setProperty, boolProperty, intProperty, doubleProperty, colorProperty, lengthProperty, lengthVectorProperty, Property

toBlockFormat

public final QTextBlockFormat toBlockFormat()

Returns this format as a block format.


toCharFormat

public final QTextCharFormat toCharFormat()

Returns this format as a character format.


toFrameFormat

public final QTextFrameFormat toFrameFormat()

Returns this format as a frame format.


toImageFormat

public final QTextImageFormat toImageFormat()

Returns this format as an image format.


toListFormat

public final QTextListFormat toListFormat()

Returns this format as a list format.


toTableFormat

public final QTextTableFormat toTableFormat()

Returns this format as a table format.


type

public final int type()

Returns the type of this format.

See Also:
ObjectTypes

fromNativePointer

public static QTextFormat fromNativePointer(QNativePointer nativePointer)
This function returns the QTextFormat instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

nativePointerArray

public static QNativePointer nativePointerArray(QTextFormat[] array)
This function returns a QNativePointer that is pointing to the specified QTextFormat array.

Parameters:
array - the array that the returned pointer will point to.
Returns:
a QNativePointer that is pointing to the specified array.

equals

public boolean equals(java.lang.Object other)

Overrides:
equals in class java.lang.Object