Eclipse Platform
Release 3.4

org.eclipse.swt.custom
Class StyledText

java.lang.Object
  extended byorg.eclipse.swt.widgets.Widget
      extended byorg.eclipse.swt.widgets.Control
          extended byorg.eclipse.swt.widgets.Scrollable
              extended byorg.eclipse.swt.widgets.Composite
                  extended byorg.eclipse.swt.widgets.Canvas
                      extended byorg.eclipse.swt.custom.StyledText
All Implemented Interfaces:
Drawable

public class StyledText
extends Canvas

A StyledText is an editable user interface object that displays lines of text. The following style attributes can be defined for the text:

In addition to text style attributes, the background color of a line may be specified.

There are two ways to use this widget when specifying text style information. You may use the API that is defined for StyledText or you may define your own LineStyleListener. If you define your own listener, you will be responsible for maintaining the text style information for the widget. IMPORTANT: You may not define your own listener and use the StyledText API. The following StyledText API is not supported if you have defined a LineStyleListener:

There are two ways to use this widget when specifying line background colors. You may use the API that is defined for StyledText or you may define your own LineBackgroundListener. If you define your own listener, you will be responsible for maintaining the line background color information for the widget. IMPORTANT: You may not define your own listener and use the StyledText API. The following StyledText API is not supported if you have defined a LineBackgroundListener:

The content implementation for this widget may also be user-defined. To do so, you must implement the StyledTextContent interface and use the StyledText API setContent(StyledTextContent) to initialize the widget.

Styles:
FULL_SELECTION, MULTI, READ_ONLY, SINGLE, WRAP
Events:
ExtendedModify, LineGetBackground, LineGetSegments, LineGetStyle, Modify, Selection, Verify, VerifyKey

IMPORTANT: This class is not intended to be subclassed.

See Also:
StyledText snippets, SWT Examples: CustomControlExample, TextEditor, Sample code and further information

Field Summary
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
StyledText(Composite parent, int style)
          Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.
 
Method Summary
 void addBidiSegmentListener(BidiSegmentListener listener)
          Adds a bidirectional segment listener.
 void addExtendedModifyListener(ExtendedModifyListener extendedModifyListener)
          Adds an extended modify listener.
 void addLineBackgroundListener(LineBackgroundListener listener)
          Adds a line background listener.
 void addLineStyleListener(LineStyleListener listener)
          Adds a line style listener.
 void addModifyListener(ModifyListener modifyListener)
          Adds a modify listener.
 void addPaintObjectListener(PaintObjectListener listener)
          Adds a paint object listener.
 void addSelectionListener(SelectionListener listener)
          Adds a selection listener.
 void addVerifyKeyListener(VerifyKeyListener listener)
          Adds a verify key listener.
 void addVerifyListener(VerifyListener verifyListener)
          Adds a verify listener.
 void addWordMovementListener(MovementListener movementListener)
          Adds a word movement listener.
 void append(String string)
          Appends a string to the text at the end of the widget.
 Point computeSize(int wHint, int hHint, boolean changed)
          Returns the preferred size of the receiver.
 void copy()
          Copies the selected text to the DND.CLIPBOARD clipboard.
 void copy(int clipboardType)
          Copies the selected text to the specified clipboard.
 void cut()
          Moves the selected text to the clipboard.
 int getAlignment()
          Returns the alignment of the widget.
 Color getBackground()
          Returns the receiver's background color.
 int getBaseline()
          Returns the baseline, in pixels.
 int getBaseline(int offset)
          Returns the baseline at the given offset, in pixels.
 boolean getBidiColoring()
          Deprecated. use BidiSegmentListener instead.
 int getCaretOffset()
          Returns the caret position relative to the start of the text.
 int getCharCount()
          Gets the number of characters.
 StyledTextContent getContent()
          Returns the content implementation that is used for text storage.
 boolean getDoubleClickEnabled()
          Returns whether the widget implements double click mouse behavior.
 boolean getDragDetect()
          Returns true if the receiver is detecting drag gestures, and false otherwise.
 boolean getEditable()
          Returns whether the widget content can be edited.
 Color getForeground()
          Returns the foreground color that the receiver will use to draw.
 int getHorizontalIndex()
          Returns the horizontal scroll offset relative to the start of the line.
 int getHorizontalPixel()
          Returns the horizontal scroll offset relative to the start of the line.
 int getIndent()
          Returns the line indentation of the widget.
 boolean getJustify()
          Returns whether the widget justifies lines.
 int getKeyBinding(int key)
          Returns the action assigned to the key.
 String getLine(int lineIndex)
          Returns the line at the given line index without delimiters.
 int getLineAlignment(int index)
          Returns the alignment of the line at the given index.
 int getLineAtOffset(int offset)
          Returns the line at the specified offset in the text where 0 < offset < getCharCount() so that getLineAtOffset(getCharCount()) returns the line of the insert location.
 Color getLineBackground(int index)
          Returns the background color of the line at the given index.
 Bullet getLineBullet(int index)
          Returns the bullet of the line at the given index.
 int getLineCount()
          Gets the number of text lines.
 String getLineDelimiter()
          Returns the line delimiter used for entering new lines by key down or paste operation.
 int getLineHeight()
          Returns the line height.
 int getLineHeight(int offset)
          Returns the line height at the given offset.
 int getLineIndent(int index)
          Returns the indentation of the line at the given index.
 int getLineIndex(int y)
          Returns the line index for a y, relative to the client area.
 boolean getLineJustify(int index)
          Returns whether the line at the given index is justified.
 int getLinePixel(int lineIndex)
          Returns the top pixel, relative to the client area, of a given line.
 int getLineSpacing()
          Returns the line spacing of the widget.
 Point getLocationAtOffset(int offset)
          Returns the x, y location of the upper left corner of the character bounding box at the specified offset in the text.
 int getOffsetAtLine(int lineIndex)
          Returns the character offset of the first character of the given line.
 int getOffsetAtLocation(Point point)
          Returns the offset of the character at the given location relative to the first character in the document.
 int getOrientation()
          Returns the orientation of the receiver.
 int[] getRanges()
          Returns all the ranges of text that have an associated StyleRange.
 int[] getRanges(int start, int length)
          Returns the ranges of text that have an associated StyleRange.
 Point getSelection()
          Returns the selection.
 Color getSelectionBackground()
          Returns the receiver's selection background color.
 int getSelectionCount()
          Gets the number of selected characters.
 Color getSelectionForeground()
          Returns the receiver's selection foreground color.
 Point getSelectionRange()
          Returns the selection.
 String getSelectionText()
          Returns the selected text.
 int getStyle()
          Returns the receiver's style information.
 StyleRange getStyleRangeAtOffset(int offset)
          Returns the style range at the given offset.
 StyleRange[] getStyleRanges()
          Returns the styles.
 StyleRange[] getStyleRanges(boolean includeRanges)
          Returns the styles.
 StyleRange[] getStyleRanges(int start, int length)
          Returns the styles for the given text range.
 StyleRange[] getStyleRanges(int start, int length, boolean includeRanges)
          Returns the styles for the given text range.
 int getTabs()
          Returns the tab width measured in characters.
 String getText()
          Returns a copy of the widget content.
 String getText(int start, int end)
          Returns the widget content between the two offsets.
 Rectangle getTextBounds(int start, int end)
          Returns the smallest bounding rectangle that includes the characters between two offsets.
 int getTextLimit()
          Returns the maximum number of characters that the receiver is capable of holding.
 String getTextRange(int start, int length)
          Returns the widget content starting at start for length characters.
 int getTopIndex()
          Gets the top index.
 int getTopPixel()
          Gets the top pixel.
 boolean getWordWrap()
          Returns whether the widget wraps lines.
 void insert(String string)
          Inserts a string.
 void invokeAction(int action)
          Executes the action.
 void paste()
          Replaces the selection with the text on the DND.CLIPBOARD clipboard or, if there is no selection, inserts the text at the current caret offset.
 void print()
          Prints the widget's text to the default printer.
 Runnable print(Printer printer)
          Returns a runnable that will print the widget's text to the specified printer.
 Runnable print(Printer printer, StyledTextPrintOptions options)
          Returns a runnable that will print the widget's text to the specified printer.
 void redraw()
          Causes the entire bounds of the receiver to be marked as needing to be redrawn.
 void redraw(int x, int y, int width, int height, boolean all)
          Causes the rectangular area of the receiver specified by the arguments to be marked as needing to be redrawn.
 void redrawRange(int start, int length, boolean clearBackground)
          Redraws the specified text range.
 void removeBidiSegmentListener(BidiSegmentListener listener)
          Removes the specified bidirectional segment listener.
 void removeExtendedModifyListener(ExtendedModifyListener extendedModifyListener)
          Removes the specified extended modify listener.
 void removeLineBackgroundListener(LineBackgroundListener listener)
          Removes the specified line background listener.
 void removeLineStyleListener(LineStyleListener listener)
          Removes the specified line style listener.
 void removeModifyListener(ModifyListener modifyListener)
          Removes the specified modify listener.
 void removePaintObjectListener(PaintObjectListener listener)
          Removes the specified listener.
 void removeSelectionListener(SelectionListener listener)
          Removes the listener from the collection of listeners who will be notified when the user changes the receiver's selection.
 void removeVerifyKeyListener(VerifyKeyListener listener)
          Removes the specified key verify listener.
 void removeVerifyListener(VerifyListener verifyListener)
          Removes the specified verify listener.
 void removeWordMovementListener(MovementListener listener)
          Removes the specified word movement listener.
 void replaceStyleRanges(int start, int length, StyleRange[] ranges)
          Replaces the styles in the given range with new styles.
 void replaceTextRange(int start, int length, String text)
          Replaces the given text range with new text.
 void scroll(int destX, int destY, int x, int y, int width, int height, boolean all)
          Scrolls a rectangular area of the receiver by first copying the source area to the destination and then causing the area of the source which is not covered by the destination to be repainted.
 void selectAll()
          Selects all the text.
 void setAlignment(int alignment)
          Sets the alignment of the widget.
 void setBackground(Color color)
          Sets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null.
 void setBidiColoring(boolean mode)
          Deprecated. use BidiSegmentListener instead.
 void setCaret(Caret caret)
          Sets the receiver's caret.
 void setCaretOffset(int offset)
          Sets the caret offset.
 void setContent(StyledTextContent newContent)
          Sets the content implementation to use for text storage.
 void setCursor(Cursor cursor)
          Sets the receiver's cursor to the cursor specified by the argument.
 void setDoubleClickEnabled(boolean enable)
          Sets whether the widget implements double click mouse behavior.
 void setDragDetect(boolean dragDetect)
          Sets the receiver's drag detect state.
 void setEditable(boolean editable)
          Sets whether the widget content can be edited.
 void setFont(Font font)
          Sets a new font to render text with.
 void setForeground(Color color)
          Sets the receiver's foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.
 void setHorizontalIndex(int offset)
          Sets the horizontal scroll offset relative to the start of the line.
 void setHorizontalPixel(int pixel)
          Sets the horizontal pixel offset relative to the start of the line.
 void setIndent(int indent)
          Sets the line indentation of the widget.
 void setJustify(boolean justify)
          Sets whether the widget should justify lines.
 void setKeyBinding(int key, int action)
          Maps a key to an action.
 void setLineAlignment(int startLine, int lineCount, int alignment)
          Sets the alignment of the specified lines.
 void setLineBackground(int startLine, int lineCount, Color background)
          Sets the background color of the specified lines.
 void setLineBullet(int startLine, int lineCount, Bullet bullet)
          Sets the bullet of the specified lines.
 void setLineIndent(int startLine, int lineCount, int indent)
          Sets the indent of the specified lines.
 void setLineJustify(int startLine, int lineCount, boolean justify)
          Sets the justify of the specified lines.
 void setLineSpacing(int lineSpacing)
          Sets the line spacing of the widget.
 void setOrientation(int orientation)
          Sets the orientation of the receiver, which must be one of the constants SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT.
 void setSelection(int start)
          Sets the selection to the given position and scrolls it into view.
 void setSelection(int start, int end)
          Sets the selection and scrolls it into view.
 void setSelection(Point point)
          Sets the selection and scrolls it into view.
 void setSelectionBackground(Color color)
          Sets the receiver's selection background color to the color specified by the argument, or to the default system color for the control if the argument is null.
 void setSelectionForeground(Color color)
          Sets the receiver's selection foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.
 void setSelectionRange(int start, int length)
          Sets the selection.
 void setStyleRange(StyleRange range)
          Adds the specified style.
 void setStyleRanges(int[] ranges, StyleRange[] styles)
          Sets styles to be used for rendering the widget content.
 void setStyleRanges(int start, int length, int[] ranges, StyleRange[] styles)
          Clears the styles in the range specified by start and length and adds the new styles.
 void setStyleRanges(StyleRange[] ranges)
          Sets styles to be used for rendering the widget content.
 void setTabs(int tabs)
          Sets the tab width.
 void setText(String text)
          Sets the widget content.
 void setTextLimit(int limit)
          Sets the text limit to the specified number of characters.
 void setTopIndex(int topIndex)
          Sets the top index.
 void setTopPixel(int pixel)
          Sets the top pixel offset.
 void setWordWrap(boolean wrap)
          Sets whether the widget wraps lines.
 void showSelection()
          Scrolls the selection into view.
 
Methods inherited from class org.eclipse.swt.widgets.Canvas
drawBackground, getCaret, getIME, setIME
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackgroundImage, getBorderWidth, getBounds, getCursor, getEnabled, getFont, getLayoutData, getLocation, getMenu, getMonitor, getParent, getRegion, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, removeControlListener, removeDragDetectListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTraverseListener, setBackgroundImage, setBounds, setBounds, setCapture, setEnabled, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setRegion, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StyledText

public StyledText(Composite parent,
                  int style)
Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

The style value is either one of the style constants defined in class SWT which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using the int "|" operator) two or more of those SWT style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.

Parameters:
parent - a widget which will be the parent of the new instance (cannot be null)
style - the style of widget to construct
Throws:
IllegalArgumentException -
SWTException -
See Also:
SWT.FULL_SELECTION, SWT.MULTI, SWT.READ_ONLY, SWT.SINGLE, SWT.WRAP, getStyle()
Method Detail

addExtendedModifyListener

public void addExtendedModifyListener(ExtendedModifyListener extendedModifyListener)
Adds an extended modify listener. An ExtendedModify event is sent by the widget when the widget text has changed.

Parameters:
extendedModifyListener - the listener
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT when listener is null

addBidiSegmentListener

public void addBidiSegmentListener(BidiSegmentListener listener)
Adds a bidirectional segment listener.

A BidiSegmentEvent is sent whenever a line of text is measured or rendered. The user can specify text ranges in the line that should be treated as if they had a different direction than the surrounding text. This may be used when adjacent segments of right-to-left text should not be reordered relative to each other. E.g., Multiple Java string literals in a right-to-left language should generally remain in logical order to each other, that is, the way they are stored.

Parameters:
listener - the listener
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT when listener is null
Since:
2.0
See Also:
BidiSegmentEvent

addLineBackgroundListener

public void addLineBackgroundListener(LineBackgroundListener listener)
Adds a line background listener. A LineGetBackground event is sent by the widget to determine the background color for a line.

Parameters:
listener - the listener
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT when listener is null

addLineStyleListener

public void addLineStyleListener(LineStyleListener listener)
Adds a line style listener. A LineGetStyle event is sent by the widget to determine the styles for a line.

Parameters:
listener - the listener
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT when listener is null

addModifyListener

public void addModifyListener(ModifyListener modifyListener)
Adds a modify listener. A Modify event is sent by the widget when the widget text has changed.

Parameters:
modifyListener - the listener
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT when listener is null

addPaintObjectListener

public void addPaintObjectListener(PaintObjectListener listener)
Adds a paint object listener. A paint object event is sent by the widget when an object needs to be drawn.

Parameters:
listener - the listener
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT when listener is null
Since:
3.2
See Also:
PaintObjectListener, PaintObjectEvent

addSelectionListener

public void addSelectionListener(SelectionListener listener)
Adds a selection listener. A Selection event is sent by the widget when the user changes the selection.

When widgetSelected is called, the event x and y fields contain the start and end caret indices of the selection. widgetDefaultSelected is not called for StyledTexts.

Parameters:
listener - the listener which should be notified when the user changes the receiver's selection
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
See Also:
SelectionListener, removeSelectionListener(org.eclipse.swt.events.SelectionListener), SelectionEvent

addVerifyKeyListener

public void addVerifyKeyListener(VerifyKeyListener listener)
Adds a verify key listener. A VerifyKey event is sent by the widget when a key is pressed. The widget ignores the key press if the listener sets the doit field of the event to false.

Parameters:
listener - the listener
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT when listener is null

addVerifyListener

public void addVerifyListener(VerifyListener verifyListener)
Adds a verify listener. A Verify event is sent by the widget when the widget text is about to change. The listener can set the event text and the doit field to change the text that is set in the widget or to force the widget to ignore the text change.

Parameters:
verifyListener - the listener
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT when listener is null

addWordMovementListener

public void addWordMovementListener(MovementListener movementListener)
Adds a word movement listener. A movement event is sent when the boundary of a word is needed. For example, this occurs during word next and word previous actions.

Parameters:
movementListener - the listener
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT when listener is null
Since:
3.3
See Also:
MovementEvent, MovementListener, removeWordMovementListener(org.eclipse.swt.custom.MovementListener)

append

public void append(String string)
Appends a string to the text at the end of the widget.

Parameters:
string - the string to be appended
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT when listener is null
See Also:
replaceTextRange(int,int,String)

computeSize

public Point computeSize(int wHint,
                         int hHint,
                         boolean changed)
Description copied from class: Control
Returns the preferred size of the receiver.

The preferred size of a control is the size that it would best be displayed at. The width hint and height hint arguments allow the caller to ask a control questions such as "Given a particular width, how high does the control need to be to show all of the contents?" To indicate that the caller does not wish to constrain a particular dimension, the constant SWT.DEFAULT is passed for the hint.

If the changed flag is true, it indicates that the receiver's contents have changed, therefore any caches that a layout manager containing the control may have been keeping need to be flushed. When the control is resized, the changed flag will be false, so layout manager caches can be retained.

Overrides:
computeSize in class Composite

copy

public void copy()
Copies the selected text to the DND.CLIPBOARD clipboard.

The text will be put on the clipboard in plain text format and RTF format. The DND.CLIPBOARD clipboard is used for data that is transferred by keyboard accelerator (such as Ctrl+C/Ctrl+V) or by menu action.

Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

copy

public void copy(int clipboardType)
Copies the selected text to the specified clipboard. The text will be put in the clipboard in plain text format and RTF format.

The clipboardType is one of the clipboard constants defined in class DND. The DND.CLIPBOARD clipboard is used for data that is transferred by keyboard accelerator (such as Ctrl+C/Ctrl+V) or by menu action. The DND.SELECTION_CLIPBOARD clipboard is used for data that is transferred by selecting text and pasting with the middle mouse button.

Parameters:
clipboardType - indicates the type of clipboard
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
Since:
3.1

getAlignment

public int getAlignment()
Returns the alignment of the widget.

Returns:
the alignment
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
Since:
3.2
See Also:
getLineAlignment(int)

cut

public void cut()
Moves the selected text to the clipboard. The text will be put in the clipboard in plain text format and RTF format.

Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getBackground

public Color getBackground()
Description copied from class: Control
Returns the receiver's background color.

Overrides:
getBackground in class Control
Returns:
the background color

getBaseline

public int getBaseline()
Returns the baseline, in pixels. Note: this API should not be used if a StyleRange attribute causes lines to have different heights (i.e. different fonts, rise, etc).

Returns:
baseline the baseline
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
Since:
3.0
See Also:
getBaseline(int)

getBaseline

public int getBaseline(int offset)
Returns the baseline at the given offset, in pixels.

Parameters:
offset - the offset
Returns:
baseline the baseline
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
IllegalArgumentException -
  • ERROR_INVALID_RANGE when the offset is outside the valid range (< 0 or > getCharCount())
Since:
3.2

getBidiColoring

public boolean getBidiColoring()
Deprecated. use BidiSegmentListener instead.

Gets the BIDI coloring mode. When true the BIDI text display algorithm is applied to segments of text that are the same color.

Returns:
the current coloring mode
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getCaretOffset

public int getCaretOffset()
Returns the caret position relative to the start of the text.

Returns:
the caret position relative to the start of the text.
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getContent

public StyledTextContent getContent()
Returns the content implementation that is used for text storage.

Returns:
content the user defined content implementation that is used for text storage or the default content implementation if no user defined content implementation has been set.
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getDragDetect

public boolean getDragDetect()
Description copied from class: Control
Returns true if the receiver is detecting drag gestures, and false otherwise.

Overrides:
getDragDetect in class Control
Returns:
the receiver's drag detect state

getDoubleClickEnabled

public boolean getDoubleClickEnabled()
Returns whether the widget implements double click mouse behavior.

Returns:
true if double clicking a word selects the word, false if double clicks have the same effect as regular mouse clicks
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getEditable

public boolean getEditable()
Returns whether the widget content can be edited.

Returns:
true if content can be edited, false otherwise
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getForeground

public Color getForeground()
Description copied from class: Control
Returns the foreground color that the receiver will use to draw.

Overrides:
getForeground in class Control
Returns:
the receiver's foreground color

getHorizontalIndex

public int getHorizontalIndex()
Returns the horizontal scroll offset relative to the start of the line.

Returns:
horizontal scroll offset relative to the start of the line, measured in character increments starting at 0, if > 0 the content is scrolled
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getHorizontalPixel

public int getHorizontalPixel()
Returns the horizontal scroll offset relative to the start of the line.

Returns:
the horizontal scroll offset relative to the start of the line, measured in pixel starting at 0, if > 0 the content is scrolled.
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getIndent

public int getIndent()
Returns the line indentation of the widget.

Returns:
the line indentation
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
Since:
3.2
See Also:
getLineIndent(int)

getJustify

public boolean getJustify()
Returns whether the widget justifies lines.

Returns:
whether lines are justified
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
Since:
3.2
See Also:
getLineJustify(int)

getKeyBinding

public int getKeyBinding(int key)
Returns the action assigned to the key. Returns SWT.NULL if there is no action associated with the key.

Parameters:
key - a key code defined in SWT.java or a character. Optionally ORd with a state mask. Preferred state masks are one or more of SWT.MOD1, SWT.MOD2, SWT.MOD3, since these masks account for modifier platform differences. However, there may be cases where using the specific state masks (i.e., SWT.CTRL, SWT.SHIFT, SWT.ALT, SWT.COMMAND) makes sense.
Returns:
one of the predefined actions defined in ST.java or SWT.NULL if there is no action associated with the key.
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getCharCount

public int getCharCount()
Gets the number of characters.

Returns:
number of characters in the widget
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getLine

public String getLine(int lineIndex)
Returns the line at the given line index without delimiters. Index 0 is the first line of the content. When there are not any lines, getLine(0) is a valid call that answers an empty string.

Parameters:
lineIndex - index of the line to return.
Returns:
the line text without delimiters
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
IllegalArgumentException -
  • ERROR_INVALID_RANGE when the line index is outside the valid range (< 0 or >= getLineCount())
Since:
3.4

getLineAlignment

public int getLineAlignment(int index)
Returns the ali