Class TextLayout

java.lang.Object
org.eclipse.swt.graphics.Resource
org.eclipse.swt.graphics.TextLayout

public final class TextLayout extends Resource
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:
  • Field Details

    • font

      Font font
    • text

      String text
    • ascentInPoints

      int ascentInPoints
    • descentInPoints

      int descentInPoints
    • indent

      int indent
    • wrapIndent

      int wrapIndent
    • wrapWidth

      int wrapWidth
    • segments

      int[] segments
    • segmentsChars

      char[] segmentsChars
    • tabs

      int[] tabs
    • styles

    • stylesCount

      int stylesCount
    • layout

      long layout
    • context

      long context
    • attrList

      long attrList
    • selAttrList

      long selAttrList
    • invalidOffsets

      int[] invalidOffsets
    • verticalIndentInPoints

      int verticalIndentInPoints
    • metricsAdapter

    • LTR_MARK

      static final char LTR_MARK
      See Also:
    • RTL_MARK

      static final char RTL_MARK
      See Also:
    • ZWS

      static final char ZWS
      See Also:
    • ZWNBS

      static final char ZWNBS
      See Also:
  • Constructor Details

    • TextLayout

      public TextLayout(Device device)
      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

    • checkLayout

      void checkLayout()
    • computeRuns

      void computeRuns()
    • computePolyline

      int[] computePolyline(int left, int top, int right, int bottom)
    • destroy

      void destroy()
      Overrides:
      destroy in class Resource
    • draw

      public void draw(GC gc, int x, int y)
      Draws the receiver's text using the specified GC at the specified point.
      Parameters:
      gc - the GC to draw
      x - the x coordinate of the top left corner of the rectangular area where the text is to be drawn
      y - 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
    • drawInPixels

      void drawInPixels(GC gc, int x, int y)
    • 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 draw
      x - the x coordinate of the top left corner of the rectangular area where the text is to be drawn
      y - the y coordinate of the top left corner of the rectangular area where the text is to be drawn
      selectionStart - the offset where the selections starts, or -1 indicating no selection
      selectionEnd - the offset where the selections ends, or -1 indicating no selection
      selectionForeground - selection foreground, or NULL to use the system default color
      selectionBackground - 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
    • drawInPixels

      void drawInPixels(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground)
    • 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 of SWT.DELIMITER_SELECTION or SWT.FULL_SELECTION to specify the selection behavior on all lines except for the last line, and can also include SWT.LAST_LINE_SELECTION to extend the specified selection behavior to the last line.

      Parameters:
      gc - the GC to draw
      x - the x coordinate of the top left corner of the rectangular area where the text is to be drawn
      y - the y coordinate of the top left corner of the rectangular area where the text is to be drawn
      selectionStart - the offset where the selections starts, or -1 indicating no selection
      selectionEnd - the offset where the selections ends, or -1 indicating no selection
      selectionForeground - selection foreground, or NULL to use the system default color
      selectionBackground - selection background, or NULL to use the system default color
      flags - 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
    • drawInPixels

      void drawInPixels(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground, int flags)
    • drawWithCairo

      void drawWithCairo(GC gc, int x, int y, int start, int end, int yExtent, boolean fullSelection, GdkRGBA fg, GdkRGBA bg)
    • drawBorder

      void drawBorder(GC gc, int x, int y, GdkRGBA selectionColor)
    • freeRuns

      void freeRuns()
    • getAlignment

      public int getAlignment()
      Returns the receiver's horizontal text alignment, which will be one of SWT.LEFT, SWT.CENTER or SWT.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

      public Rectangle getBounds()
      Returns the bounds of the receiver. The width returned is either the width of the longest line or the width set using setWidth(int). To obtain the text bounds of a line use getLineBounds(int).
      Returns:
      the bounds of the receiver
      Throws:
      SWTException -
      • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
      See Also:
    • getBoundsInPixels

      Rectangle getBoundsInPixels(int spacingInPixels)
    • getBounds

      public Rectangle getBounds(int start, int end)
      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 offset
      end - the end offset
      Returns:
      the bounds of the character range
      Throws:
      SWTException -
      • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
    • getBoundsInPixels

      Rectangle getBoundsInPixels(int start, int end)
    • 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

      public Font 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
    • getIndentInPixels

      int getIndentInPixels()
    • 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

      public Rectangle getLineBounds(int lineIndex)
      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
    • getLineBoundsInPixels

      Rectangle getLineBoundsInPixels(int lineIndex)
    • getLineBoundsInPixels

      private Rectangle getLineBoundsInPixels(int lineIndex, long iter)
    • 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

      public FontMetrics getLineMetrics(int lineIndex)
      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

      public Point getLocation(int offset, boolean trailing)
      Returns the location for the specified character offset. The trailing argument indicates whether the offset corresponds to the leading or trailing edge of the cluster.
      Parameters:
      offset - the character offset
      trailing - the trailing flag
      Returns:
      the location of the character offset
      Throws:
      SWTException -
      • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
      See Also:
    • getLocationInPixels

      Point getLocationInPixels(int offset, boolean trailing)
    • getNextOffset

      public int getNextOffset(int offset, int movement)
      Returns the next offset for the specified offset and movement type. The movement is one of SWT.MOVEMENT_CHAR, SWT.MOVEMENT_CLUSTER, SWT.MOVEMENT_WORD, SWT.MOVEMENT_WORD_END or SWT.MOVEMENT_WORD_START.
      Parameters:
      offset - the start offset
      movement - 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

      int _getOffset(int offset, int movement, boolean forward)
    • getOffset

      public int getOffset(Point point, 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:
      point - the point
      trailing - 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
      SWTException -
      • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
      See Also:
    • getOffsetInPixels

      int getOffsetInPixels(Point point, int[] trailing)
    • 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 point
      y - the y coordinate of the point
      trailing - the trailing buffer
      Returns:
      the character offset
      Throws:
      IllegalArgumentException -
      • ERROR_INVALID_ARGUMENT - if the trailing length is less than 1
      SWTException -
      • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
      See Also:
    • getOffsetInPixels

      int getOffsetInPixels(int x, int y, int[] trailing)
    • 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 of SWT.MOVEMENT_CHAR, SWT.MOVEMENT_CLUSTER or SWT.MOVEMENT_WORD, SWT.MOVEMENT_WORD_END or SWT.MOVEMENT_WORD_START.
      Parameters:
      offset - the start offset
      movement - 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 a TextStyle.
      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
    • getSegmentsText

      String getSegmentsText()
    • 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
    • getSpacingInPixels

      int getSpacingInPixels()
    • 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
    • getScaledVerticalIndent

      private int getScaledVerticalIndent()
      Returns the scaled vertical indent.
      Returns:
      the scaled vertical indent.
      Since:
      3.109
    • getStyle

      public TextStyle getStyle(int offset)
      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

      public TextStyle[] 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
    • getTabsInPixels

      int[] getTabsInPixels()
    • getText

      public String 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
    • getWidthInPixels

      int getWidthInPixels()
    • 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
    • getWrapIndentInPixels

      int getWrapIndentInPixels()
    • isDisposed

      public boolean isDisposed()
      Returns true if the text layout has been disposed, and false 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 class Resource
      Returns:
      true when the text layout is disposed and false 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 of SWT.LEFT, SWT.RIGHT or SWT.CENTER.

      The default alignment is SWT.LEFT. Note that the receiver's width must be set in order to use SWT.RIGHT or SWT.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
      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
      SWTException -
      • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
      See Also:
    • setFixedLineMetrics

      public void setFixedLineMetrics(FontMetrics metrics)
      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.
      NOTE: Does not currently support (as in, undefined behavior) multi-line layouts, including those caused by word wrapping. StyledText uses one TextLayout per line and is only affected by word wrap restriction.
      Since:
      3.125
    • setFont

      public void setFont(Font font)
      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:
    • setIndentInPixels

      void setIndentInPixels(int indent)
    • 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 of SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT.
      Parameters:
      orientation - new orientation style
      Throws:
      SWTException -
      • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
    • 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
    • setSpacingInPixels

      void setSpacingInPixels(int spacing)
    • 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
    • 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 calling setSegments(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 in TextLayout.
      Parameters:
      segmentsChars - the segments characters
      Throws:
      SWTException -
      • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
      Since:
      3.6
      See Also:
    • setStyle

      public void setStyle(TextStyle style, int start, int end)
      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 style
      start - the start offset
      end - 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
    • setTabsInPixels

      void setTabsInPixels(int[] tabs)
    • setText

      public void setText(String text)
      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 of SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT or SWT.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
      SWTException -
      • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
      See Also:
    • setWidthInPixels

      void setWidthInPixels(int width)
    • setWidth

      void setWidth()
    • 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:
    • setWrapIndentInPixels

      void setWrapIndentInPixels(int wrapIndent)
    • isLam

      static final boolean isLam(int ch)
    • isAlef

      static final boolean isAlef(int ch)
    • toString

      public String toString()
      Returns a string containing a concise, human-readable description of the receiver.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the receiver
    • translateOffset

      int translateOffset(int offset)
    • untranslateOffset

      int untranslateOffset(int offset)
    • width

      int width()
    • 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
      SWTException -
      • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
      Since:
      3.107