Class TextLayout
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.
-
Constructor Summary
ConstructorDescriptionTextLayout
(Device device) Constructs a new instance of this class on the given device. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Draws the receiver's text using the specified GC at the specified point.void
draw
(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground) Draws the receiver's text using the specified GC at the specified point.void
draw
(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground, int flags) Draws the receiver's text using the specified GC at the specified point.int
Returns the receiver's horizontal text alignment, which will be one ofSWT.LEFT
,SWT.CENTER
orSWT.RIGHT
.int
Returns the ascent of the receiver.Returns the bounds of the receiver.getBounds
(int start, int end) Returns the bounds for the specified range of characters.int
Returns the descent of the receiver.getFont()
Returns the default font currently being used by the receiver to draw and measure text.int
Returns the receiver's indent.boolean
Returns the receiver's justification.int
getLevel
(int offset) Returns the embedding level for the specified character offset.getLineBounds
(int lineIndex) Returns the bounds of the line for the specified line index.int
Returns the receiver's line count.int
getLineIndex
(int offset) Returns the index of the line that contains the specified character offset.getLineMetrics
(int lineIndex) Returns the font metrics for the specified line index.int[]
Returns the line offsets.getLocation
(int offset, boolean trailing) Returns the location for the specified character offset.int
getNextOffset
(int offset, int movement) Returns the next offset for the specified offset and movement type.int
getOffset
(int x, int y, int[] trailing) Returns the character offset for the specified point.int
Returns the character offset for the specified point.int
Returns the orientation of the receiver.int
getPreviousOffset
(int offset, int movement) Returns the previous offset for the specified offset and movement type.int[]
Gets the ranges of text that are associated with aTextStyle
.int[]
Returns the text segments offsets of the receiver.char[]
Returns the segments characters of the receiver.int
Returns the line spacing of the receiver.getStyle
(int offset) Gets the style of the receiver at the specified character offset.Gets all styles of the receiver.int[]
getTabs()
Returns the tab list of the receiver.getText()
Gets the receiver's text, which will be an empty string if it has never been set.int
Returns the text direction of the receiver.int
Returns the vertical indent of the receiver.int
getWidth()
Returns the width of the receiver.int
Returns the receiver's wrap indent.boolean
Returnstrue
if the text layout has been disposed, andfalse
otherwise.void
setAlignment
(int alignment) Sets the text alignment for the receiver.void
setAscent
(int ascent) Sets the ascent of the receiver.void
setDefaultTabWidth
(int tabLength) Sets Default Tab Width in terms if number of space characters.void
setDescent
(int descent) Sets the descent of the receiver.void
setFixedLineMetrics
(FontMetrics metrics) Forces line heights in receiver to obey provided value.void
Sets the default font which will be used by the receiver to draw and measure text.void
setIndent
(int indent) Sets the indent of the receiver.void
setJustify
(boolean justify) Sets the justification of the receiver.void
setOrientation
(int orientation) Sets the orientation of the receiver, which must be one ofSWT.LEFT_TO_RIGHT
orSWT.RIGHT_TO_LEFT
.void
setSegments
(int[] segments) Sets the offsets of the receiver's text segments.void
setSegmentsChars
(char[] segmentsChars) Sets the characters to be used in the segments boundaries.void
setSpacing
(int spacing) Sets the line spacing of the receiver.void
Sets the style of the receiver for the specified range.void
setTabs
(int[] tabs) Sets the receiver's tab list.void
Sets the receiver's text.void
setTextDirection
(int textDirection) Sets the text direction of the receiver, which must be one ofSWT.LEFT_TO_RIGHT
,SWT.RIGHT_TO_LEFT
orSWT.AUTO_TEXT_DIRECTION
.void
setVerticalIndent
(int verticalIndent) Sets the vertical indent of the receiver.void
setWidth
(int width) Sets the line width of the receiver, which determines how text should be wrapped and aligned.void
setWrapIndent
(int wrapIndent) Sets the wrap indent of the receiver.toString()
Returns a string containing a concise, human-readable description of the receiver.Methods inherited from class org.eclipse.swt.graphics.Resource
dispose, getDevice, setNonDisposeHandler
-
Constructor Details
-
TextLayout
Constructs a new instance of this class on the given device.You must dispose the text layout when it is no longer required.
- Parameters:
device
- the device on which to allocate the text layout- Throws:
IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if device is null and there is no current device
- See Also:
-
-
Method Details
-
draw
Draws the receiver's text using the specified GC at the specified point.- Parameters:
gc
- the GC to drawx
- the x coordinate of the top left corner of the rectangular area where the text is to be drawny
- the y coordinate of the top left corner of the rectangular area where the text is to be drawn- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the gc is null
-
draw
public void draw(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground) Draws the receiver's text using the specified GC at the specified point.- Parameters:
gc
- the GC to drawx
- the x coordinate of the top left corner of the rectangular area where the text is to be drawny
- the y coordinate of the top left corner of the rectangular area where the text is to be drawnselectionStart
- the offset where the selections starts, or -1 indicating no selectionselectionEnd
- the offset where the selections ends, or -1 indicating no selectionselectionForeground
- selection foreground, or NULL to use the system default colorselectionBackground
- selection background, or NULL to use the system default color- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the gc is null
-
draw
public void draw(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground, int flags) Draws the receiver's text using the specified GC at the specified point.The parameter
flags
can include one ofSWT.DELIMITER_SELECTION
orSWT.FULL_SELECTION
to specify the selection behavior on all lines except for the last line, and can also includeSWT.LAST_LINE_SELECTION
to extend the specified selection behavior to the last line.- Parameters:
gc
- the GC to drawx
- the x coordinate of the top left corner of the rectangular area where the text is to be drawny
- the y coordinate of the top left corner of the rectangular area where the text is to be drawnselectionStart
- the offset where the selections starts, or -1 indicating no selectionselectionEnd
- the offset where the selections ends, or -1 indicating no selectionselectionForeground
- selection foreground, or NULL to use the system default colorselectionBackground
- selection background, or NULL to use the system default colorflags
- drawing options- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the gc is null
- Since:
- 3.3
-
getAlignment
public int getAlignment()Returns the receiver's horizontal text alignment, which will be one ofSWT.LEFT
,SWT.CENTER
orSWT.RIGHT
.- Returns:
- the alignment used to positioned text horizontally
- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
getAscent
public int getAscent()Returns the ascent of the receiver.- Returns:
- the ascent
- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- See Also:
-
getBounds
Returns the bounds of the receiver. The width returned is either the width of the longest line or the width set usingsetWidth(int)
. To obtain the text bounds of a line usegetLineBounds(int)
.- Returns:
- the bounds of the receiver
- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- See Also:
-
getBounds
Returns the bounds for the specified range of characters. The bounds is the smallest rectangle that encompasses all characters in the range. The start and end offsets are inclusive and will be clamped if out of range.- Parameters:
start
- the start offsetend
- the end offset- Returns:
- the bounds of the character range
- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
getDescent
public int getDescent()Returns the descent of the receiver.- Returns:
- the descent
- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- See Also:
-
getFont
Returns the default font currently being used by the receiver to draw and measure text.- Returns:
- the receiver's font
- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
getIndent
public int getIndent()Returns the receiver's indent.- Returns:
- the receiver's indent
- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.2
-
getJustify
public boolean getJustify()Returns the receiver's justification.- Returns:
- the receiver's justification
- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.2
-
getLevel
public int getLevel(int offset) Returns the embedding level for the specified character offset. The embedding level is usually used to determine the directionality of a character in bidirectional text.- Parameters:
offset
- the character offset- Returns:
- the embedding level
- Throws:
IllegalArgumentException
-- ERROR_INVALID_ARGUMENT - if the character offset is out of range
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
getLineBounds
Returns the bounds of the line for the specified line index.- Parameters:
lineIndex
- the line index- Returns:
- the line bounds
- Throws:
IllegalArgumentException
-- ERROR_INVALID_ARGUMENT - if the line index is out of range
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
getLineCount
public int getLineCount()Returns the receiver's line count. This includes lines caused by wrapping.- Returns:
- the line count
- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
getLineIndex
public int getLineIndex(int offset) Returns the index of the line that contains the specified character offset.- Parameters:
offset
- the character offset- Returns:
- the line index
- Throws:
IllegalArgumentException
-- ERROR_INVALID_ARGUMENT - if the character offset is out of range
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
getLineMetrics
Returns the font metrics for the specified line index.- Parameters:
lineIndex
- the line index- Returns:
- the font metrics
- Throws:
IllegalArgumentException
-- ERROR_INVALID_ARGUMENT - if the line index is out of range
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
getLineOffsets
public int[] getLineOffsets()Returns the line offsets. Each value in the array is the offset for the first character in a line except for the last value, which contains the length of the text.- Returns:
- the line offsets
- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
getLocation
Returns the location for the specified character offset. Thetrailing
argument indicates whether the offset corresponds to the leading or trailing edge of the cluster.- Parameters:
offset
- the character offsettrailing
- the trailing flag- Returns:
- the location of the character offset
- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- See Also:
-
getNextOffset
public int getNextOffset(int offset, int movement) Returns the next offset for the specified offset and movement type. The movement is one ofSWT.MOVEMENT_CHAR
,SWT.MOVEMENT_CLUSTER
,SWT.MOVEMENT_WORD
,SWT.MOVEMENT_WORD_END
orSWT.MOVEMENT_WORD_START
.- Parameters:
offset
- the start offsetmovement
- the movement type- Returns:
- the next offset
- Throws:
IllegalArgumentException
-- ERROR_INVALID_ARGUMENT - if the offset is out of range
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- See Also:
-
getOffset
Returns the character offset for the specified point. For a typical character, the trailing argument will be filled in to indicate whether the point is closer to the leading edge (0) or the trailing edge (1). When the point is over a cluster composed of multiple characters, the trailing argument will be filled with the position of the character in the cluster that is closest to the point.- Parameters:
point
- the pointtrailing
- the trailing buffer- Returns:
- the character offset
- Throws:
IllegalArgumentException
-- ERROR_INVALID_ARGUMENT - if the trailing length is less than
1
- ERROR_NULL_ARGUMENT - if the point is null
- ERROR_INVALID_ARGUMENT - if the trailing length is less than
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- See Also:
-
getOffset
public int getOffset(int x, int y, int[] trailing) Returns the character offset for the specified point. For a typical character, the trailing argument will be filled in to indicate whether the point is closer to the leading edge (0) or the trailing edge (1). When the point is over a cluster composed of multiple characters, the trailing argument will be filled with the position of the character in the cluster that is closest to the point.- Parameters:
x
- the x coordinate of the pointy
- the y coordinate of the pointtrailing
- the trailing buffer- Returns:
- the character offset
- Throws:
IllegalArgumentException
-- ERROR_INVALID_ARGUMENT - if the trailing length is less than
1
- ERROR_INVALID_ARGUMENT - if the trailing length is less than
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- See Also:
-
getOrientation
public int getOrientation()Returns the orientation of the receiver.- Returns:
- the orientation style
- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
getPreviousOffset
public int getPreviousOffset(int offset, int movement) Returns the previous offset for the specified offset and movement type. The movement is one ofSWT.MOVEMENT_CHAR
,SWT.MOVEMENT_CLUSTER
orSWT.MOVEMENT_WORD
,SWT.MOVEMENT_WORD_END
orSWT.MOVEMENT_WORD_START
.- Parameters:
offset
- the start offsetmovement
- the movement type- Returns:
- the previous offset
- Throws:
IllegalArgumentException
-- ERROR_INVALID_ARGUMENT - if the offset is out of range
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- See Also:
-
getRanges
public int[] getRanges()Gets the ranges of text that are associated with aTextStyle
.- Returns:
- the ranges, an array of offsets representing the start and end of each text style.
- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.2
- See Also:
-
getSegments
public int[] getSegments()Returns the text segments offsets of the receiver.- Returns:
- the text segments offsets
- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
getSegmentsChars
public char[] getSegmentsChars()Returns the segments characters of the receiver.- Returns:
- the segments characters
- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.6
-
getSpacing
public int getSpacing()Returns the line spacing of the receiver.- Returns:
- the line spacing
- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
getVerticalIndent
public int getVerticalIndent()Returns the vertical indent of the receiver.- Returns:
- the vertical indent
- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.109
-
getStyle
Gets the style of the receiver at the specified character offset.- Parameters:
offset
- the text offset- Returns:
- the style or
null
if not set - Throws:
IllegalArgumentException
-- ERROR_INVALID_ARGUMENT - if the character offset is out of range
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
getStyles
Gets all styles of the receiver.- Returns:
- the styles
- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.2
- See Also:
-
getTabs
public int[] getTabs()Returns the tab list of the receiver.- Returns:
- the tab list
- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
getText
Gets the receiver's text, which will be an empty string if it has never been set.- Returns:
- the receiver's text
- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
getTextDirection
public int getTextDirection()Returns the text direction of the receiver.- Returns:
- the text direction value
- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.103
-
getWidth
public int getWidth()Returns the width of the receiver.- Returns:
- the width
- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
getWrapIndent
public int getWrapIndent()Returns the receiver's wrap indent.- Returns:
- the receiver's wrap indent
- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.6
-
isDisposed
public boolean isDisposed()Returnstrue
if the text layout has been disposed, andfalse
otherwise.This method gets the dispose state for the text layout. When a text layout has been disposed, it is an error to invoke any other method (except
Resource.dispose()
) using the text layout.- Specified by:
isDisposed
in classResource
- Returns:
true
when the text layout is disposed andfalse
otherwise
-
setAlignment
public void setAlignment(int alignment) Sets the text alignment for the receiver. The alignment controls how a line of text is positioned horizontally. The argument should be one ofSWT.LEFT
,SWT.RIGHT
orSWT.CENTER
.The default alignment is
SWT.LEFT
. Note that the receiver's width must be set in order to useSWT.RIGHT
orSWT.CENTER
alignment.- Parameters:
alignment
- the new alignment- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- See Also:
-
setAscent
public void setAscent(int ascent) Sets the ascent of the receiver. The ascent is distance in points from the baseline to the top of the line and it is applied to all lines. The default value is-1
which means that the ascent is calculated from the line fonts.- Parameters:
ascent
- the new ascent- Throws:
IllegalArgumentException
-- ERROR_INVALID_ARGUMENT - if the ascent is less than
-1
- ERROR_INVALID_ARGUMENT - if the ascent is less than
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- See Also:
-
setDescent
public void setDescent(int descent) Sets the descent of the receiver. The descent is distance in points from the baseline to the bottom of the line and it is applied to all lines. The default value is-1
which means that the descent is calculated from the line fonts.- Parameters:
descent
- the new descent- Throws:
IllegalArgumentException
-- ERROR_INVALID_ARGUMENT - if the descent is less than
-1
- ERROR_INVALID_ARGUMENT - if the descent is less than
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- See Also:
-
setFixedLineMetrics
Forces line heights in receiver to obey provided value. This is useful with texts that contain glyphs from different scripts, such as mixing latin glyphs with hieroglyphs or emojis.Text lines with different metrics will be forced to fit. This means painting text in such a way that its baseline is where specified by given 'metrics'. This can sometimes introduce small visual artifacs, such as taller lines overpainting or being clipped by content above and below.
The possible ways to set FontMetrics include:- Obtaining 'FontMetrics' via
GC.getFontMetrics()
. Note that this will only obtain metrics for currently selected font and will not account for font fallbacks (for example, with a latin font selected, painting hieroglyphs usually involves a fallback font). - Obtaining 'FontMetrics' via a temporary 'TextLayout'. This would
involve setting a desired text sample to 'TextLayout', then measuring
it with
getLineMetrics(int)
. This approach will also take fallback fonts into account.
- Since:
- 3.125
- Obtaining 'FontMetrics' via
-
setFont
Sets the default font which will be used by the receiver to draw and measure text. If the argument is null, then a default font appropriate for the platform will be used instead. Note that a text style can override the default font.- Parameters:
font
- the new font for the receiver, or null to indicate a default font- Throws:
IllegalArgumentException
-- ERROR_INVALID_ARGUMENT - if the font has been disposed
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
setIndent
public void setIndent(int indent) Sets the indent of the receiver. This indent is applied to the first line of each paragraph.- Parameters:
indent
- new indent- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.2
- See Also:
-
setJustify
public void setJustify(boolean justify) Sets the justification of the receiver. Note that the receiver's width must be set in order to use justification.- Parameters:
justify
- new justify- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.2
-
setOrientation
public void setOrientation(int orientation) Sets the orientation of the receiver, which must be one ofSWT.LEFT_TO_RIGHT
orSWT.RIGHT_TO_LEFT
.- Parameters:
orientation
- new orientation style- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
setSegments
public void setSegments(int[] segments) Sets the offsets of the receiver's text segments. Text segments are used to override the default behavior of the bidirectional algorithm. Bidirectional reordering can happen within a text segment but not between two adjacent segments.Each text segment is determined by two consecutive offsets in the
segments
arrays. The first element of the array should always be zero and the last one should always be equals to length of the text.When segments characters are set, the segments are the offsets where the characters are inserted in the text.
- Parameters:
segments
- the text segments offset- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- See Also:
-
setSegmentsChars
public void setSegmentsChars(char[] segmentsChars) Sets the characters to be used in the segments boundaries. The segments are set by callingsetSegments(int[])
. The application can use this API to insert Unicode Control Characters in the text to control the display of the text and bidi reordering. The characters are not accessible by any other API inTextLayout
.- Parameters:
segmentsChars
- the segments characters- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.6
- See Also:
-
setSpacing
public void setSpacing(int spacing) Sets the line spacing of the receiver. The line spacing is the space left between lines.- Parameters:
spacing
- the new line spacing- Throws:
IllegalArgumentException
-- ERROR_INVALID_ARGUMENT - if the spacing is negative
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
setVerticalIndent
public void setVerticalIndent(int verticalIndent) Sets the vertical indent of the receiver. The vertical indent is the space left before the first line.- Parameters:
verticalIndent
- the new vertical indent- Throws:
IllegalArgumentException
-- ERROR_INVALID_ARGUMENT - if the vertical indent is negative
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.109
-
setStyle
Sets the style of the receiver for the specified range. Styles previously set for that range will be overwritten. The start and end offsets are inclusive and will be clamped if out of range.- Parameters:
style
- the stylestart
- the start offsetend
- the end offset- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
setTabs
public void setTabs(int[] tabs) Sets the receiver's tab list. Each value in the tab list specifies the space in points from the origin of the text layout to the respective tab stop. The last tab stop width is repeated continuously.- Parameters:
tabs
- the new tab list- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
setText
Sets the receiver's text.Note: Setting the text also clears all the styles. This method returns without doing anything if the new text is the same as the current text.
- Parameters:
text
- the new text- Throws:
IllegalArgumentException
-- ERROR_NULL_ARGUMENT - if the text is null
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
setTextDirection
public void setTextDirection(int textDirection) Sets the text direction of the receiver, which must be one ofSWT.LEFT_TO_RIGHT
,SWT.RIGHT_TO_LEFT
orSWT.AUTO_TEXT_DIRECTION
.Warning: This API is currently only implemented on Windows. It doesn't set the base text direction on GTK and Cocoa.
- Parameters:
textDirection
- the new text direction- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.103
-
setWidth
public void setWidth(int width) Sets the line width of the receiver, which determines how text should be wrapped and aligned. The default value is-1
which means wrapping is disabled.- Parameters:
width
- the new width- Throws:
IllegalArgumentException
-- ERROR_INVALID_ARGUMENT - if the width is
0
or less than-1
- ERROR_INVALID_ARGUMENT - if the width is
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- See Also:
-
setWrapIndent
public void setWrapIndent(int wrapIndent) Sets the wrap indent of the receiver. This indent is applied to all lines in the paragraph except the first line.- Parameters:
wrapIndent
- new wrap indent- Throws:
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.6
- See Also:
-
toString
Returns a string containing a concise, human-readable description of the receiver. -
setDefaultTabWidth
public void setDefaultTabWidth(int tabLength) Sets Default Tab Width in terms if number of space characters.- Parameters:
tabLength
- in number of characters- Throws:
IllegalArgumentException
-- ERROR_INVALID_ARGUMENT - if the tabLength is less than
0
- ERROR_INVALID_ARGUMENT - if the tabLength is less than
SWTException
-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.107
- Restriction:
- This method is not intended to be referenced by clients. DO NOT USE This might be removed in 4.8
-