com.trolltech.qt.gui
Class QTextCharFormat

java.lang.Object
  extended by com.trolltech.qt.internal.QSignalEmitterInternal
      extended by com.trolltech.qt.QSignalEmitter
          extended by com.trolltech.qt.QtJambiObject
              extended by com.trolltech.qt.gui.QTextFormat
                  extended by com.trolltech.qt.gui.QTextCharFormat
All Implemented Interfaces:
QtJambiInterface, java.lang.Cloneable
Direct Known Subclasses:
QTextImageFormat, QTextTableCellFormat

public class QTextCharFormat
extends QTextFormat
implements java.lang.Cloneable

The QTextCharFormat class provides formatting information for characters in a QTextDocument. The character format of text in a document specifies the visual properties of the text, as well as information about its role in a hypertext document.

The font used can be set by supplying a font to the setFont() function, and each aspect of its appearance can be adjusted to give the desired effect. setFontFamily() and setFontPointSize() define the font's family (e.g. Times) and printed size; setFontWeight() and setFontItalic() provide control over the style of the font. setFontUnderline(), setFontOverline(), setFontStrikeOut(), and setFontFixedPitch() provide additional effects for text.

The color is set with setForeground(). If the text is intended to be used as an anchor (for hyperlinks), this can be enabled with setAnchor(). The setAnchorHref() and setAnchorNames() functions are used to specify the information about the hyperlink's destination and the anchor's name.

See also:
QTextFormat, QTextBlockFormat, QTextTableFormat, and QTextListFormat.


Nested Class Summary
static class QTextCharFormat.UnderlineStyle
          This enum describes the different ways drawing underlined text.
static class QTextCharFormat.VerticalAlignment
          This enum describes the ways that adjacent characters can be vertically aligned.
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QTextFormat
QTextFormat.FormatType, QTextFormat.ObjectTypes, QTextFormat.PageBreakFlag, QTextFormat.PageBreakFlags, QTextFormat.Property
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.AbstractSignal, QSignalEmitter.PrivateSignal0, QSignalEmitter.PrivateSignal1, QSignalEmitter.PrivateSignal2, QSignalEmitter.PrivateSignal3, QSignalEmitter.PrivateSignal4, QSignalEmitter.PrivateSignal5, QSignalEmitter.PrivateSignal6, QSignalEmitter.PrivateSignal7, QSignalEmitter.PrivateSignal8, QSignalEmitter.PrivateSignal9, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9
 
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal
 
Field Summary
 
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
currentSender
 
Constructor Summary
QTextCharFormat()
          Constructs a new character format object.
 
Method Summary
 java.lang.String anchorHref()
          Returns the text format's hypertext link, or an empty string if none has been set.
 java.util.List anchorNames()
          Returns the anchor names associated with this text format, or an empty string list if none has been set.
 QTextCharFormat clone()
          This method is reimplemented for internal reasons
 QFont font()
          Returns the font for this character format.
 QFont.Capitalization fontCapitalization()
          Returns the current capitalization type of the font.
 java.lang.String fontFamily()
          Returns the text format's font family.
 boolean fontFixedPitch()
          Returns true if the text format's font is fixed pitch; otherwise returns false.
 boolean fontItalic()
          Returns true if the text format's font is italic; otherwise returns false.
 boolean fontKerning()
          Returns true if the the font kerning is enabled.
 double fontLetterSpacing()
          Returns the current letter spacing percentage.
 boolean fontOverline()
          Returns true if the text format's font is overlined; otherwise returns false.
 double fontPointSize()
          Returns the font size used to display text in this format.
 boolean fontStrikeOut()
          Returns true if the text format's font is struck out (has a horizontal line drawn through it); otherwise returns false.
 QFont.StyleHint fontStyleHint()
          Returns the font style hint.
 QFont.StyleStrategy fontStyleStrategy()
          Returns the current font style strategy.
 boolean fontUnderline()
          Returns true if the text format's font is underlined; otherwise returns false.
 int fontWeight()
          Returns the text format's font weight.
 double fontWordSpacing()
          Returns the current word spacing value.
 boolean isAnchor()
          Returns true if the text is formatted as an anchor; otherwise returns false.
 void setAnchor(boolean anchor)
          If anchor is true, text with this format represents an anchor, and is formatted in the appropriate way; otherwise the text is formatted normally.
 void setAnchorHref(java.lang.String value)
          Sets the hypertext link for the text format to the given value.
 void setAnchorNames(java.util.List names)
          Sets the text format's anchor names.
 void setFont(QFont font)
          Sets the text format's font.
 void setFontCapitalization(QFont.Capitalization capitalization)
          Sets the capitalization of the text that apppears in this font to capitalization.
 void setFontFamily(java.lang.String family)
          Sets the text format's font family.
 void setFontFixedPitch(boolean fixedPitch)
          If fixedPitch is true, sets the text format's font to be fixed pitch; otherwise a non-fixed pitch font is used.
 void setFontItalic(boolean italic)
          If italic is true, sets the text format's font to be italic; otherwise the font will be non-italic.
 void setFontKerning(boolean enable)
          Enables kerning for this font if enable is true; otherwise disables it.
 void setFontLetterSpacing(double spacing)
          Sets the letter spacing of this format to the given spacing, in percent.
 void setFontOverline(boolean overline)
          If overline is true, sets the text format's font to be overlined; otherwise the font is displayed non-overlined.
 void setFontPointSize(double size)
          Sets the text format's font size.
 void setFontStrikeOut(boolean strikeOut)
          If strikeOut is true, sets the text format's font with strike-out enabled (with a horizontal line through it); otherwise it is displayed without strikeout.
 void setFontStyleHint(QFont.StyleHint hint)
          Sets the font style hint and strategy.
 void setFontStyleHint(QFont.StyleHint hint, QFont.StyleStrategy strategy)
          Sets the font style hint and strategy.
 void setFontStyleStrategy(QFont.StyleStrategy strategy)
          Sets the font style strategy.
 void setFontUnderline(boolean underline)
          If underline is true, sets the text format's font to be underlined; otherwise it is displayed non-underlined.
 void setFontWeight(int weight)
          Sets the text format's font weight to weight.
 void setFontWordSpacing(double spacing)
          Sets the word spacing of this format to the given spacing, in pixels.
 void setTextOutline(QPen pen)
          Sets the pen used to draw the outlines of characters to the given pen.
 void setToolTip(java.lang.String tip)
          Sets the tool tip for a fragment of text to the given text.
 void setUnderlineColor(QColor color)
          Sets the underline color used for the characters with this format to the color specified.
 void setUnderlineStyle(QTextCharFormat.UnderlineStyle style)
          Sets the style of underlining the text to style.
 void setVerticalAlignment(QTextCharFormat.VerticalAlignment alignment)
          Sets the vertical alignment used for the characters with this format to the alignment specified.
 QPen textOutline()
          Returns the pen used to draw the outlines of characters in this format.
 java.lang.String toolTip()
          Returns the tool tip that is displayed for a fragment of text.
 QColor underlineColor()
          Returns the color used to underline the characters with this format.
 QTextCharFormat.UnderlineStyle underlineStyle()
          Returns the style of underlining the text.
 QTextCharFormat.VerticalAlignment verticalAlignment()
          Returns the vertical alignment used for characters with this format.
 
Methods inherited from class com.trolltech.qt.gui.QTextFormat
background, boolProperty, brushProperty, clearBackground, clearForeground, clearProperty, colorProperty, doubleProperty, foreground, hasProperty, intProperty, isBlockFormat, isCharFormat, isFrameFormat, isImageFormat, isListFormat, isTableCellFormat, isTableFormat, isValid, layoutDirection, lengthProperty, lengthVectorProperty, merge, objectIndex, objectType, penProperty, properties, property, propertyCount, readFrom, setBackground, setForeground, setLayoutDirection, setObjectIndex, setObjectType, setProperty, setProperty, stringProperty, toBlockFormat, toCharFormat, toFrameFormat, toImageFormat, toListFormat, toTableCellFormat, toTableFormat, type, writeTo
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread
 
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
__qt_signalInitialization
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Constructor Detail

QTextCharFormat

public QTextCharFormat()
Constructs a new character format object.

Method Detail

anchorHref

public final java.lang.String anchorHref()
Returns the text format's hypertext link, or an empty string if none has been set.

See also:
setAnchorHref().


anchorNames

public final java.util.List anchorNames()
Returns the anchor names associated with this text format, or an empty string list if none has been set. If the anchor names are set, text with this format can be the destination of a hypertext link.

See also:
setAnchorNames().


font

public final QFont font()
Returns the font for this character format.

See also:
setFont().


fontCapitalization

public final QFont.Capitalization fontCapitalization()
Returns the current capitalization type of the font.

See also:
setFontCapitalization().


fontFamily

public final java.lang.String fontFamily()
Returns the text format's font family.

See also:
setFontFamily(), and font().


fontFixedPitch

public final boolean fontFixedPitch()
Returns true if the text format's font is fixed pitch; otherwise returns false.

See also:
setFontFixedPitch(), and font().


fontItalic

public final boolean fontItalic()
Returns true if the text format's font is italic; otherwise returns false.

See also:
setFontItalic(), and font().


fontKerning

public final boolean fontKerning()
Returns true if the the font kerning is enabled.

See also:
setFontKerning(), and font().


fontLetterSpacing

public final double fontLetterSpacing()
Returns the current letter spacing percentage.

See also:
setFontLetterSpacing().


fontOverline

public final boolean fontOverline()
Returns true if the text format's font is overlined; otherwise returns false.

See also:
setFontOverline(), and font().


fontPointSize

public final double fontPointSize()
Returns the font size used to display text in this format.

See also:
setFontPointSize(), and font().


fontStrikeOut

public final boolean fontStrikeOut()
Returns true if the text format's font is struck out (has a horizontal line drawn through it); otherwise returns false.

See also:
setFontStrikeOut(), and font().


fontStyleHint

public final QFont.StyleHint fontStyleHint()
Returns the font style hint.

See also:
setFontStyleHint(), and font().


fontStyleStrategy

public final QFont.StyleStrategy fontStyleStrategy()
Returns the current font style strategy.

See also:
setFontStyleStrategy(), and font().


fontUnderline

public final boolean fontUnderline()
Returns true if the text format's font is underlined; otherwise returns false.

See also:
setFontUnderline(), and font().


fontWeight

public final int fontWeight()
Returns the text format's font weight.

See also:
setFontWeight(), font(), and QFont::Weight .


fontWordSpacing

public final double fontWordSpacing()
Returns the current word spacing value.

See also:
setFontWordSpacing().


isAnchor

public final boolean isAnchor()
Returns true if the text is formatted as an anchor; otherwise returns false.

See also:
setAnchor(), setAnchorHref(), and setAnchorNames().


setAnchor

public final void setAnchor(boolean anchor)
If anchor is true, text with this format represents an anchor, and is formatted in the appropriate way; otherwise the text is formatted normally. (Anchors are hyperlinks which are often shown underlined and in a different color from plain text.)

The way the text is rendered is independent of whether or not the format has a valid anchor defined. Use setAnchorHref(), and optionally setAnchorNames() to create a hypertext link.

See also:
isAnchor().


setAnchorHref

public final void setAnchorHref(java.lang.String value)
Sets the hypertext link for the text format to the given value. This is typically a URL like "http://qtsoftware.com/index.html".

The anchor will be displayed with the value as its display text; if you want to display different text call setAnchorNames().

To format the text as a hypertext link use setAnchor().

See also:
anchorHref().


setAnchorNames

public final void setAnchorNames(java.util.List names)
Sets the text format's anchor names. For the anchor to work as a hyperlink, the destination must be set with setAnchorHref() and the anchor must be enabled with setAnchor().

See also:
anchorNames().


setFont

public final void setFont(QFont font)
Sets the text format's font.

See also:
font().


setFontCapitalization

public final void setFontCapitalization(QFont.Capitalization capitalization)
Sets the capitalization of the text that apppears in this font to capitalization.

A font's capitalization makes the text appear in the selected capitalization mode.

See also:
fontCapitalization().


setFontFamily

public final void setFontFamily(java.lang.String family)
Sets the text format's font family.

See also:
fontFamily(), and setFont().


setFontFixedPitch

public final void setFontFixedPitch(boolean fixedPitch)
If fixedPitch is true, sets the text format's font to be fixed pitch; otherwise a non-fixed pitch font is used.

See also:
fontFixedPitch(), and setFont().


setFontItalic

public final void setFontItalic(boolean italic)
If italic is true, sets the text format's font to be italic; otherwise the font will be non-italic.

See also:
fontItalic(), and setFont().


setFontKerning

public final void setFontKerning(boolean enable)
Enables kerning for this font if enable is true; otherwise disables it.

When kerning is enabled, glyph metrics do not add up anymore, even for Latin text. In other words, the assumption that width('a') + width('b') is equal to width("ab") is not neccesairly true.

See also:
fontKerning(), and setFont().


setFontLetterSpacing

public final void setFontLetterSpacing(double spacing)
Sets the letter spacing of this format to the given spacing, in percent. A value of 100 indicates default spacing; a value of 200 doubles the amount of space a letter takes.

See also:
fontLetterSpacing().


setFontOverline

public final void setFontOverline(boolean overline)
If overline is true, sets the text format's font to be overlined; otherwise the font is displayed non-overlined.

See also:
fontOverline(), and setFont().


setFontPointSize

public final void setFontPointSize(double size)
Sets the text format's font size.

See also:
fontPointSize(), and setFont().


setFontStrikeOut

public final void setFontStrikeOut(boolean strikeOut)
If strikeOut is true, sets the text format's font with strike-out enabled (with a horizontal line through it); otherwise it is displayed without strikeout.

See also:
fontStrikeOut(), and setFont().


setFontStyleHint

public final void setFontStyleHint(QFont.StyleHint hint)
Sets the font style hint and strategy.

Qt does not support style hints on X11 since this information is not provided by the window system.

See also:
fontStyleHint(), setFont(), and QFont::setStyleHint().


setFontStyleHint

public final void setFontStyleHint(QFont.StyleHint hint,
                                   QFont.StyleStrategy strategy)
Sets the font style hint and strategy.

Qt does not support style hints on X11 since this information is not provided by the window system.

See also:
fontStyleHint(), setFont(), and QFont::setStyleHint().


setFontStyleStrategy

public final void setFontStyleStrategy(QFont.StyleStrategy strategy)
Sets the font style strategy.

See also:
fontStyleStrategy(), setFont(), and QFont::setStyleStrategy().


setFontUnderline

public final void setFontUnderline(boolean underline)
If underline is true, sets the text format's font to be underlined; otherwise it is displayed non-underlined.

See also:
fontUnderline(), and setFont().


setFontWeight

public final void setFontWeight(int weight)
Sets the text format's font weight to weight.

See also:
fontWeight(), setFont(), and QFont::Weight .


setFontWordSpacing

public final void setFontWordSpacing(double spacing)
Sets the word spacing of this format to the given spacing, in pixels.

See also:
fontWordSpacing().


setTextOutline

public final void setTextOutline(QPen pen)
Sets the pen used to draw the outlines of characters to the given pen.

See also:
textOutline().


setToolTip

public final void setToolTip(java.lang.String tip)
Sets the tool tip for a fragment of text to the given text.

See also:
toolTip().


setUnderlineColor

public final void setUnderlineColor(QColor color)
Sets the underline color used for the characters with this format to the color specified.

See also:
underlineColor().


setUnderlineStyle

public final void setUnderlineStyle(QTextCharFormat.UnderlineStyle style)
Sets the style of underlining the text to style.

See also:
underlineStyle().


setVerticalAlignment

public final void setVerticalAlignment(QTextCharFormat.VerticalAlignment alignment)
Sets the vertical alignment used for the characters with this format to the alignment specified.

See also:
verticalAlignment().


textOutline

public final QPen textOutline()
Returns the pen used to draw the outlines of characters in this format.

See also:
setTextOutline().


toolTip

public final java.lang.String toolTip()
Returns the tool tip that is displayed for a fragment of text.

See also:
setToolTip().


underlineColor

public final QColor underlineColor()
Returns the color used to underline the characters with this format.

See also:
setUnderlineColor().


underlineStyle

public final QTextCharFormat.UnderlineStyle underlineStyle()
Returns the style of underlining the text.

See also:
setUnderlineStyle().


verticalAlignment

public final QTextCharFormat.VerticalAlignment verticalAlignment()
Returns the vertical alignment used for characters with this format.

See also:
setVerticalAlignment().


clone

public QTextCharFormat clone()
This method is reimplemented for internal reasons

Overrides:
clone in class QTextFormat