Top Description Inners Fields Constructors Methods
org.eclipse.swt.graphics

public final Class TextLayout

extends Resource
Class Inheritance
Imports
java.util.*, org.eclipse.swt.*, org.eclipse.swt.internal.*, org.eclipse.swt.internal.cairo.*, org.eclipse.swt.internal.gtk.*

TextLayout is a graphic object that represents styled text.

Instances of this class provide support for drawing, cursor navigation, hit testing, text wrapping, alignment, tab expansion line breaking, etc. These are aspects required for rendering internationalized text.

Application code must explicitly invoke the TextLayout#dispose() method to release the operating system resources managed by each instance when those instances are no longer required.

Since
3.0
See Also
TextLayout, TextStyle snippets, SWT Example: CustomControlExample, StyledText tab, Sample code and further information

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
TextLayout.MetricsAdapter

Adapts necessary Pango APIs to enforce fixed line metrics (when set)

pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv long
pack-priv long
pack-priv int
pack-priv Font
pack-priv int
pack-priv int[]
pack-priv long
pack-priv static final char
pack-priv TextLayout.MetricsAdapter
pack-priv static final char
pack-priv int[]
pack-priv char[]
pack-priv long
pack-priv TextLayout.StyleItem[]
pack-priv int
pack-priv int[]
pack-priv String
pack-priv int
pack-priv int
pack-priv int
pack-priv static final char
pack-priv static final char
Inherited from org.eclipse.swt.graphics.Resource:
device

Constructor Summary

AccessConstructor and Description
public
TextLayout(Device
the device on which to allocate the text layout
device
)

Constructs a new instance of this class on the given device.

Method Summary

Modifier and TypeMethod and Description
pack-priv int
_getOffset(int offset, int movement, boolean forward)

pack-priv void
pack-priv int[]
computePolyline(int left, int top, int right, int bottom)

pack-priv void
pack-priv void
public void
draw(GC
the GC to draw
gc
,
int
the x coordinate of the top left corner of the rectangular area where the text is to be drawn
x
,
int
the y coordinate of the top left corner of the rectangular area where the text is to be drawn
y
)

Draws the receiver's text using the specified GC at the specified point.

public void
draw(GC
the GC to draw
gc
,
int
the x coordinate of the top left corner of the rectangular area where the text is to be drawn
x
,
int
the y coordinate of the top left corner of the rectangular area where the text is to be drawn
y
,
int
the offset where the selections starts, or -1 indicating no selection
selectionStart
,
int
the offset where the selections ends, or -1 indicating no selection
selectionEnd
,
Color
selection foreground, or NULL to use the system default color
selectionForeground
,
Color
selection background, or NULL to use the system default color
selectionBackground
)

Draws the receiver's text using the specified GC at the specified point.

public void
draw(GC
the GC to draw
gc
,
int
the x coordinate of the top left corner of the rectangular area where the text is to be drawn
x
,
int
the y coordinate of the top left corner of the rectangular area where the text is to be drawn
y
,
int
the offset where the selections starts, or -1 indicating no selection
selectionStart
,
int
the offset where the selections ends, or -1 indicating no selection
selectionEnd
,
Color
selection foreground, or NULL to use the system default color
selectionForeground
,
Color
selection background, or NULL to use the system default color
selectionBackground
,
int
drawing options
flags
)

Draws the receiver's text using the specified GC at the specified point.

pack-priv void
drawBorder(GC gc, int x, int y, GdkRGBA selectionColor)

pack-priv void
drawInPixels(GC gc, int x, int y)

pack-priv void
drawInPixels(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground)

pack-priv void
drawInPixels(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground, int flags)

pack-priv void
drawWithCairo(GC gc, int x, int y, int start, int end, boolean fullSelection, GdkRGBA fg, GdkRGBA bg)

pack-priv void
public int

Returns:

the alignment used to positioned text horizontally
getAlignment
()

Returns the receiver's horizontal text alignment, which will be one of SWT.LEFT, SWT.CENTER or SWT.RIGHT.

public int

Returns:

the ascent
getAscent
()

Returns the ascent of the receiver.

public Rectangle

Returns:

the bounds of the receiver
getBounds
()

Returns the bounds of the receiver.

public Rectangle

Returns:

the bounds of the character range
getBounds
(int
the start offset
start
,
int
the end offset
end
)

Returns the bounds for the specified range of characters.

pack-priv Rectangle
getBoundsInPixels(int spacingInPixels)

pack-priv Rectangle
getBoundsInPixels(int start, int end)

public int

Returns:

the descent
getDescent
()

Returns the descent of the receiver.

public Font

Returns:

the receiver's font
getFont
()

Returns the default font currently being used by the receiver to draw and measure text.

public int

Returns:

the receiver's indent
getIndent
()

Returns the receiver's indent.

pack-priv int
public boolean

Returns:

the receiver's justification
getJustify
()

Returns the receiver's justification.

public int

Returns:

the embedding level
getLevel
(int
the character offset
offset
)

Returns the embedding level for the specified character offset.

public Rectangle

Returns:

the line bounds
getLineBounds
(int
the line index
lineIndex
)

Returns the bounds of the line for the specified line index.

pack-priv Rectangle
getLineBoundsInPixels(int lineIndex)

private Rectangle
getLineBoundsInPixels(int lineIndex, long iter)

public int

Returns:

the line count
getLineCount
()

Returns the receiver's line count.

public int

Returns:

the line index
getLineIndex
(int
the character offset
offset
)

Returns the index of the line that contains the specified character offset.

public FontMetrics

Returns:

the font metrics
getLineMetrics
(int
the line index
lineIndex
)

Returns the font metrics for the specified line index.

public int[]

Returns:

the line offsets
getLineOffsets
()

Returns the line offsets.

public Point

Returns:

the location of the character offset
getLocation
(int
the character offset
offset
,
boolean
the trailing flag
trailing
)

Returns the location for the specified character offset.

pack-priv Point
getLocationInPixels(int offset, boolean trailing)

public int

Returns:

the next offset
getNextOffset
(int
the start offset
offset
,
int
the movement type
movement
)

Returns the next offset for the specified offset and movement type.

public int

Returns:

the character offset
getOffset
(Point
the point
point
,
int[]
the trailing buffer
trailing
)

Returns the character offset for the specified point.

public int

Returns:

the character offset
getOffset
(int
the x coordinate of the point
x
,
int
the y coordinate of the point
y
,
int[]
the trailing buffer
trailing
)

Returns the character offset for the specified point.

pack-priv int
getOffsetInPixels(Point point, int[] trailing)

pack-priv int
getOffsetInPixels(int x, int y, int[] trailing)

public int

Returns:

the orientation style
getOrientation
()

Returns the orientation of the receiver.

public int

Returns:

the previous offset
getPreviousOffset
(int
the start offset
offset
,
int
the movement type
movement
)

Returns the previous offset for the specified offset and movement type.

public int[]

Returns:

the ranges, an array of offsets representing the start and end of each text style.
getRanges
()

Gets the ranges of text that are associated with a TextStyle.

private int

Returns:

the scaled vertical indent.
getScaledVerticalIndent
()

Returns the scaled vertical indent.

public int[]

Returns:

the text segments offsets
getSegments
()

Returns the text segments offsets of the receiver.

public char[]

Returns:

the segments characters
getSegmentsChars
()

Returns the segments characters of the receiver.

pack-priv String
public int

Returns:

the line spacing
getSpacing
()

Returns the line spacing of the receiver.

pack-priv int
public TextStyle

Returns:

the style or null if not set
getStyle
(int
the text offset
offset
)

Gets the style of the receiver at the specified character offset.

public TextStyle[]

Returns:

the styles
getStyles
()

Gets all styles of the receiver.

public int[]

Returns:

the tab list
getTabs
()

Returns the tab list of the receiver.

pack-priv int[]
public String

Returns:

the receiver's text
getText
()

Gets the receiver's text, which will be an empty string if it has never been set.

public int

Returns:

the text direction value
getTextDirection
()

Returns the text direction of the receiver.

public int

Returns:

the vertical indent
getVerticalIndent
()

Returns the vertical indent of the receiver.

public int

Returns:

the width
getWidth
()

Returns the width of the receiver.

pack-priv int
public int

Returns:

the receiver's wrap indent
getWrapIndent
()

Returns the receiver's wrap indent.

pack-priv int
pack-priv static final boolean
isAlef(int ch)

public boolean

Returns:

true when the text layout is disposed and false otherwise
isDisposed
()

Implements abstract org.eclipse.swt.graphics.Resource.isDisposed.

Returns true if the text layout has been disposed, and false otherwise.
pack-priv static final boolean
isLam(int ch)

public void
setAlignment(int
the new alignment
alignment
)

Sets the text alignment for the receiver.

public void
setAscent(int
the new ascent
ascent
)

Sets the ascent of the receiver.

public void
setDefaultTabWidth(int
in number of characters
tabLength
)

Sets Default Tab Width in terms if number of space characters.

public void
setDescent(int
the new descent
descent
)

Sets the descent of the receiver.

public void
setFixedLineMetrics(FontMetrics metrics)

Forces line heights in receiver to obey provided value.

public void
setFont(Font
the new font for the receiver, or null to indicate a default font
font
)

Sets the default font which will be used by the receiver to draw and measure text.

public void
setIndent(int
new indent
indent
)

Sets the indent of the receiver.

pack-priv void
setIndentInPixels(int indent)

public void
setJustify(boolean
new justify
justify
)

Sets the justification of the receiver.

public void
setOrientation(int
new orientation style
orientation
)

Sets the orientation of the receiver, which must be one of SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT.

public void
setSegments(int[]
the text segments offset
segments
)

Sets the offsets of the receiver's text segments.

public void
setSegmentsChars(char[]
the segments characters
segmentsChars
)

Sets the characters to be used in the segments boundaries.

public void
setSpacing(int
the new line spacing
spacing
)

Sets the line spacing of the receiver.

pack-priv void
setSpacingInPixels(int spacing)

public void
setStyle(TextStyle
the style
style
,
int
the start offset
start
,
int
the end offset
end
)

Sets the style of the receiver for the specified range.

public void
setTabs(int[]
the new tab list
tabs
)

Sets the receiver's tab list.

pack-priv void
setTabsInPixels(int[] tabs)

public void
setText(String
the new text
text
)

Sets the receiver's text.

public void
setTextDirection(int
the new text direction
textDirection
)

Sets the text direction of the receiver, which must be one of SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT or SWT.AUTO_TEXT_DIRECTION.

public void
setVerticalIndent(int
the new vertical indent
verticalIndent
)

Sets the vertical indent of the receiver.

public void
setWidth(int
the new width
width
)

Sets the line width of the receiver, which determines how text should be wrapped and aligned.

pack-priv void
pack-priv void
setWidthInPixels(int width)

public void
setWrapIndent(int
new wrap indent
wrapIndent
)

Sets the wrap indent of the receiver.

pack-priv void
setWrapIndentInPixels(int wrapIndent)

public String

Returns:

a string representation of the receiver
toString
()

Overrides java.lang.Object.toString.

Returns a string containing a concise, human-readable description of the receiver.
pack-priv int
translateOffset(int offset)

pack-priv int
untranslateOffset(int offset)

pack-priv int
Inherited from org.eclipse.swt.graphics.Resource:
disposegetDeviceignoreNonDisposedinitinitNonDisposeTrackingsetNonDisposeHandler