|
|
|
|
org.eclipse.swt.custom
Class StyledText
java.lang.Object
org.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
org.eclipse.swt.widgets.Canvas
org.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:
- foreground color
- background color
- font style (bold, italic, bold-italic, regular)
- underline
- strikeout
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:
- getStyleRangeAtOffset(int)
- getStyleRanges()
- replaceStyleRanges(int,int,StyleRange[])
- setStyleRange(StyleRange)
- setStyleRanges(StyleRange[])
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:
- getLineBackground(int)
- setLineBackground(int,int,Color)
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
-
Restriction:
- This class is not intended to be subclassed by clients.
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
|
addCaretListener
(
CaretListener listener)
Adds a caret 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.
|
boolean
|
getBlockSelection
()
Returns whether the widget is in block selection mode. |
Rectangle
|
getBlockSelectionBounds
()
Returns the block selection bounds. |
int
|
getBottomMargin
()
Returns the bottom margin. |
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. |
int
|
getLeftMargin
()
Returns the left margin. |
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. |
Color
|
getMarginColor
()
Returns the color of the margins. |
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. |
int
|
getRightMargin
()
Returns the right margin. |
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. |
int[]
|
getSelectionRanges
()
Returns the ranges of text that are inside the block selection rectangle. |
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
|
getTopMargin
()
Returns the top margin. |
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
|
removeCaretListener
(
CaretListener listener)
Removes the specified caret 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
|
setBlockSelection
(boolean blockSelection)
Sets the block selection mode. |
void
|
setBlockSelectionBounds
(int x,
int y,
int width,
int height)
Sets the block selection bounds. |
void
|
setBlockSelectionBounds
(
Rectangle rect)
Sets the block selection bounds. |
void
|
setBottomMargin
(int bottomMargin)
Sets the bottom margin. |
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
|
setLeftMargin
(int leftMargin)
Sets the left margin. |
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
|
setMarginColor
(
Color color)
Sets the color of the margins. |
void
|
setMargins
(int leftMargin,
int topMargin,
int rightMargin,
int bottomMargin)
Sets the margins. |
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
|
setRightMargin
(int rightMargin)
Sets the right margin. |
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
|
setTopMargin
(int topMargin)
Sets the top margin. |
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.
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.
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
|
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
-
- ERROR_NULL_ARGUMENT - if the parent is null
-
SWTException
-
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
-
See Also:
-
SWT.FULL_SELECTION ,
SWT.MULTI ,
SWT.READ_ONLY ,
SWT.SINGLE ,
SWT.WRAP ,
getStyle()
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
addCaretListener
public void addCaretListener(
CaretListener listener)
- Adds a caret listener. CaretEvent is sent when the caret offset changes.
-
-
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.5
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
-
-
Parameters:
-
wHint - the width hint (can be SWT.DEFAULT ) -
hHint - the height hint (can be SWT.DEFAULT ) -
changed - true if the control's contents have changed, and false otherwise
-
Returns:
- the preferred size of the control.
-
See Also:
-
Layout ,
Control.getBorderWidth() ,
Control.getBounds() ,
Control.getSize() ,
Control.pack(boolean) ,
"computeTrim, getClientArea for controls that implement them"
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)
getMarginColor
public
Color getMarginColor()
- Returns the color of the margins.
-
-
Returns:
- the color of the margins.
-
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.5
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.
Note: This operation is a hint and may be overridden by the platform.
For example, on some versions of Windows the background of a TabFolder,
is a gradient rather than a solid 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
getBlockSelection
public boolean getBlockSelection()
- Returns whether the widget is in block selection mode.
-
-
Returns:
- true if widget is in block selection mode, 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
-
Since:
- 3.5
getBlockSelectionBounds
public
Rectangle getBlockSelectionBounds()
- Returns the block selection bounds. The bounds is
relative to the upper left corner of the document.
-
-
Returns:
- the block selection bounds
-
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.5
getBottomMargin
public int getBottomMargin()
- Returns the bottom margin.
-
-
Returns:
- the bottom margin.
-
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.5
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 alignment of the line at the given index.
-
-
Parameters:
-
index - the index of the line
-
Returns:
- the line 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
-
IllegalArgumentException
-
- ERROR_INVALID_ARGUMENT when the index is invalid
-
Since:
- 3.2
-
See Also:
-
getAlignment()
getLineAtOffset
public 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.
-
-
Parameters:
-
offset - offset relative to the start of the content.
0 <= offset <= getCharCount()
-
Returns:
- line at the specified offset in 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
-
IllegalArgumentException
-
- ERROR_INVALID_RANGE when the offset is outside the valid range (< 0 or > getCharCount())
getLineBackground
public
Color getLineBackground(int index)
- Returns the background color of the line at the given index.
Returns null if a LineBackgroundListener has been set or if no background
color has been specified for the line. Should not be called if a
LineBackgroundListener has been set since the listener maintains the
line background colors.
-
-
Parameters:
-
index - the index of the line
-
Returns:
- the background color of the line at the given index.
-
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_ARGUMENT when the index is invalid
getLineBullet
public
Bullet getLineBullet(int index)
- Returns the bullet of the line at the given index.
-
-
Parameters:
-
index - the index of the line
-
Returns:
- the line bullet
-
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_ARGUMENT when the index is invalid
-
Since:
- 3.2
getLineCount
public int getLineCount()
- Gets the number of text lines.
-
-
Returns:
- the number of lines 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
getLineDelimiter
public
String getLineDelimiter()
- Returns the line delimiter used for entering new lines by key down
or paste operation.
-
-
Returns:
- line delimiter used for entering new lines by key down
or paste operation.
-
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
getLineHeight
public int getLineHeight()
- Returns the line height.
Note: this API should not be used if a StyleRange attribute causes lines to
have different heights (i.e. different fonts, rise, etc).
-
-
Returns:
- line height in pixel.
-
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
-
See Also:
-
getLineHeight(int)
getLineHeight
public int getLineHeight(int offset)
- Returns the line height at the given offset.
-
-
Parameters:
-
offset - the offset
-
Returns:
- line height in pixels
-
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
getLineIndent
public int getLineIndent(int index)
- Returns the indentation of the line at the given index.
-
-
Parameters:
-
index - the index of the line
-
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
-
IllegalArgumentException
-
- ERROR_INVALID_ARGUMENT when the index is invalid
-
Since:
- 3.2
-
See Also:
-
getIndent()
getLineJustify
public boolean getLineJustify(int index)
- Returns whether the line at the given index is justified.
-
-
Parameters:
-
index - the index of the line
-
Returns:
- whether the line is 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
-
IllegalArgumentException
-
- ERROR_INVALID_ARGUMENT when the index is invalid
-
Since:
- 3.2
-
See Also:
-
getJustify()
getLineSpacing
public int getLineSpacing()
- Returns the line spacing of the widget.
-
-
Returns:
- the line spacing
-
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
getLinePixel
public int getLinePixel(int lineIndex)
- Returns the top pixel, relative to the client area, of a given line.
Clamps out of ranges index.
-
-
Parameters:
-
lineIndex - the line index, the max value is lineCount. If
lineIndex == lineCount it returns the bottom pixel of the last line.
It means this function can be used to retrieve the bottom pixel of any line.
-
Returns:
- the top pixel of a given line index
-
Since:
- 3.2
getLineIndex
public int getLineIndex(int y)
- Returns the line index for a y, relative to the client area.
The line index returned is always in the range 0..lineCount - 1.
-
-
Parameters:
-
y - the y-coordinate pixel
-
Returns:
- the line index for a given y-coordinate pixel
-
Since:
- 3.2
getLeftMargin
public int getLeftMargin()
- Returns the left margin.
-
-
Returns:
- the left margin.
-
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.5
getLocationAtOffset
public
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. The point is
relative to the upper left corner of the widget client area.
-
-
Parameters:
-
offset - offset relative to the start of the content.
0 <= offset <= getCharCount()
-
Returns:
- x, y location of the upper left corner of the character
bounding box at the specified offset in 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
-
IllegalArgumentException
-
- ERROR_INVALID_RANGE when the offset is outside the valid range (< 0 or > getCharCount())
getOffsetAtLine
public int getOffsetAtLine(int lineIndex)
- Returns the character offset of the first character of the given line.
-
-
Parameters:
-
lineIndex - index of the line, 0 based relative to the first
line in the content. 0 <= lineIndex < getLineCount(), except
lineIndex may always be 0
-
Returns:
- offset offset of the first character of the line, relative to
the beginning of the document. The first character of the document is
at offset 0.
When there are not any lines, getOffsetAtLine(0) is a valid call that
answers 0.
-
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:
- 2.0
getOffsetAtLocation
public int getOffsetAtLocation(
Point point)
- Returns the offset of the character at the given location relative
to the first character in the document.
The return value reflects the character offset that the caret will
be placed at if a mouse click occurred at the specified location.
If the x coordinate of the location is beyond the center of a character
the returned offset will be behind the character.
-
-
Parameters:
-
point - the origin of character bounding box relative to
the origin of the widget client area.
-
Returns:
- offset of the character at the given location relative
to the first character in the document.
-
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 point is null
- ERROR_INVALID_ARGUMENT when there is no character at the specified location
getOrientation
public int getOrientation()
- Returns the orientation of the receiver.
-
-
Returns:
- the orientation style
-
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:
- 2.1.2
getRanges
public int[] getRanges()
- Returns all the ranges of text that have an associated StyleRange.
Returns an empty array if a LineStyleListener has been set.
Should not be called if a LineStyleListener has been set since the
listener maintains the styles.
The ranges array contains start and length pairs. Each pair refers to
the corresponding style in the styles array. For example, the pair
that starts at ranges[n] with length ranges[n+1] uses the style
at styles[n/2] returned by getStyleRanges(int, int, boolean) .
-
-
Returns:
- the ranges or an empty array if a LineStyleListener 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
-
Since:
- 3.2
-
See Also:
-
getStyleRanges(boolean)
getRanges
public int[] getRanges(int start,
int length)
- Returns the ranges of text that have an associated StyleRange.
Returns an empty array if a LineStyleListener has been set.
Should not be called if a LineStyleListener has been set since the
listener maintains the styles.
The ranges array contains start and length pairs. Each pair refers to
the corresponding style in the styles array. For example, the pair
that starts at ranges[n] with length ranges[n+1] uses the style
at styles[n/2] returned by getStyleRanges(int, int, boolean) .
-
-
Parameters:
-
start - the start offset of the style ranges to return -
length - the number of style ranges to return
-
Returns:
- the ranges or an empty array if a LineStyleListener 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
-
IllegalArgumentException
-
- ERROR_INVALID_RANGE if start or length are outside the widget content
-
Since:
- 3.2
-
See Also:
-
getStyleRanges(int, int, boolean)
getRightMargin
public int getRightMargin()
- Returns the right margin.
-
-
Returns:
- the right margin.
-
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.5
getSelection
public
Point getSelection()
- Returns the selection.
Text selections are specified in terms of caret positions. In a text
widget that contains N characters, there are N+1 caret positions,
ranging from 0..N
-
-
Returns:
- start and end of the selection, x is the offset of the first
selected character, y is the offset after the last selected character.
The selection values returned are visual (i.e., x will always always be
<= y). To determine if a selection is right-to-left (RtoL) vs. left-to-right
(LtoR), compare the caretOffset to the start and end of the selection
(e.g., caretOffset == start of selection implies that the selection is RtoL).
-
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
-
See Also:
-
getSelectionRange()
getSelectionRange
public
Point getSelectionRange()
- Returns the selection.
-
-
Returns:
- start and length of the selection, x is the offset of the
first selected character, relative to the first character of the
widget content. y is the length of the selection.
The selection values returned are visual (i.e., length will always always be
positive). To determine if a selection is right-to-left (RtoL) vs. left-to-right
(LtoR), compare the caretOffset to the start and end of the selection
(e.g., caretOffset == start of selection implies that the selection is RtoL).
-
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
getSelectionRanges
public int[] getSelectionRanges()
- Returns the ranges of text that are inside the block selection rectangle.
The ranges array contains start and length pairs. When the receiver is not
in block selection mode the return arrays contains the start and length of
the regular selection.
-
-
Returns:
- the ranges array
-
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.5
getSelectionBackground
public
Color getSelectionBackground()
- Returns the receiver's selection background color.
-
-
Returns:
- the selection background color
-
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:
- 2.1
getSelectionCount
public int getSelectionCount()
- Gets the number of selected characters.
-
-
Returns:
- the number of selected characters.
-
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
getSelectionForeground
public
Color getSelectionForeground()
- Returns the receiver's selection foreground color.
-
-
Returns:
- the selection foreground color
-
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:
- 2.1
getSelectionText
public
String getSelectionText()
- Returns the selected text.
-
-
Returns:
- selected text, or an empty String if there is no selection.
-
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
getStyle
public int getStyle()
-
Description copied from class:
Widget
- Returns the receiver's style information.
Note that the value which is returned by this method may
not match the value which was provided to the constructor
when the receiver was created. This can occur when the underlying
operating system does not support a particular combination of
requested styles. For example, if the platform widget used to
implement a particular SWT widget always has scroll bars, the
result of calling this method would always have the
SWT.H_SCROLL and SWT.V_SCROLL bits set.
-
-
Overrides:
-
getStyle
in class
Widget
-
-
Returns:
- the style bits
getStyleRangeAtOffset
public
StyleRange getStyleRangeAtOffset(int offset)
- Returns the style range at the given offset.
Returns null if a LineStyleListener has been set or if a style is not set
for the offset.
Should not be called if a LineStyleListener has been set since the
listener maintains the styles.
-
-
Parameters:
-
offset - the offset to return the style for.
0 <= offset < getCharCount() must be true.
-
Returns:
- a StyleRange with start == offset and length == 1, indicating
the style at the given offset. null if a LineStyleListener has been set
or if a style is not set for the given offset.
-
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_ARGUMENT when the offset is invalid
getStyleRanges
public
StyleRange[] getStyleRanges()
- Returns the styles.
Returns an empty array if a LineStyleListener has been set.
Should not be called if a LineStyleListener has been set since the
listener maintains the styles.
Note: Because a StyleRange includes the start and length, the
same instance cannot occur multiple times in the array of styles.
If the same style attributes, such as font and color, occur in
multiple StyleRanges, getStyleRanges(boolean)
can be used to get the styles without the ranges.
-
-
Returns:
- the styles or an empty array if a LineStyleListener 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
-
See Also:
-
getStyleRanges(boolean)
getStyleRanges
public
StyleRange[] getStyleRanges(boolean includeRanges)
- Returns the styles.
Returns an empty array if a LineStyleListener has been set.
Should not be called if a LineStyleListener has been set since the
listener maintains the styles.
Note: When includeRanges is true, the start and length
fields of each StyleRange will be valid, however the StyleRange
objects may need to be cloned. When includeRanges is
false, getRanges(int, int) can be used to get the
associated ranges.
-
-
Parameters:
-
includeRanges - whether the start and length field of the StyleRanges should be set.
-
Returns:
- the styles or an empty array if a LineStyleListener 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
-
Since:
- 3.2
-
See Also:
-
getRanges(int, int) ,
setStyleRanges(int[], StyleRange[])
getStyleRanges
public
StyleRange[] getStyleRanges(int start,
int length)
- Returns the styles for the given text range.
Returns an empty array if a LineStyleListener has been set.
Should not be called if a LineStyleListener has been set since the
listener maintains the styles.
Note: Because the StyleRange includes the start and length, the
same instance cannot occur multiple times in the array of styles.
If the same style attributes, such as font and color, occur in
multiple StyleRanges, getStyleRanges(int, int, boolean)
can be used to get the styles without the ranges.
-
-
Parameters:
-
start - the start offset of the style ranges to return -
length - the number of style ranges to return
-
Returns:
- the styles or an empty array if a LineStyleListener has
been set. The returned styles will reflect the given range. The first
returned
StyleRange will have a starting offset >= start
and the last returned StyleRange will have an ending
offset <= start + length - 1
-
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 start and/or end are outside the widget content
-
Since:
- 3.0
-
See Also:
-
getStyleRanges(int, int, boolean)
getStyleRanges
public
StyleRange[] getStyleRanges(int start,
int length,
boolean includeRanges)
- Returns the styles for the given text range.
Returns an empty array if a LineStyleListener has been set.
Should not be called if a LineStyleListener has been set since the
listener maintains the styles.
Note: When includeRanges is true, the start and length
fields of each StyleRange will be valid, however the StyleRange
objects may need to be cloned. When includeRanges is
false, getRanges(int, int) can be used to get the
associated ranges.
-
-
Parameters:
-
start - the start offset of the style ranges to return -
length - the number of style ranges to return -
includeRanges - whether the start and length field of the StyleRanges should be set.
-
Returns:
- the styles or an empty array if a LineStyleListener has
been set. The returned styles will reflect the given range. The first
returned
StyleRange will have a starting offset >= start
and the last returned StyleRange will have an ending
offset <= start + length - 1
-
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 start and/or end are outside the widget content
-
Since:
- 3.2
-
See Also:
-
getRanges(int, int) ,
setStyleRanges(int[], StyleRange[])
getTabs
public int getTabs()
- Returns the tab width measured in characters.
-
-
Returns:
- tab width measured in characters
-
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
getText
public
String getText()
- Returns a copy of the widget content.
-
-
Returns:
- copy of the widget content
-
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
getText
public
String getText(int start,
int end)
- Returns the widget content between the two offsets.
-
-
Parameters:
-
start - offset of the first character in the returned String -
end - offset of the last character in the returned String
-
Returns:
- widget content starting at start and ending at end
-
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 start and/or end are outside the widget content
-
See Also:
-
getTextRange(int,int)
getTextBounds
public
Rectangle getTextBounds(int start,
int end)
- Returns the smallest bounding rectangle that includes the characters between two offsets.
-
-
Parameters:
-
start - offset of the first character included in the bounding box -
end - offset of the last character included in the bounding box
-
Returns:
- bounding box of the text between start and end
-
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 start and/or end are outside the widget content
-
Since:
- 3.1
getTextRange
public
String getTextRange(int start,
int length)
- Returns the widget content starting at start for length characters.
-
-
Parameters:
-
start - offset of the first character in the returned String -
length - number of characters to return
-
Returns:
- widget content starting at start and extending length characters.
-
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 start and/or length are outside the widget content
getTextLimit
public int getTextLimit()
- Returns the maximum number of characters that the receiver is capable of holding.
-
-
Returns:
- the text limit
-
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
getTopIndex
public int getTopIndex()
- Gets the top index.
The top index is the index of the fully visible line that is currently
at the top of the widget or the topmost partially visible line if no line is fully visible.
The top index changes when the widget is scrolled. Indexing is zero based.
-
-
Returns:
- the index of the top line
-
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
getTopMargin
public int getTopMargin()
- Returns the top margin.
-
-
Returns:
- the top margin.
-
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.5
getTopPixel
public int getTopPixel()
- Gets the top pixel.
The top pixel is the pixel position of the line that is
currently at the top of the widget. The text widget can be scrolled by pixels
by dragging the scroll thumb so that a partial line may be displayed at the top
the widget. The top pixel changes when the widget is scrolled. The top pixel
does not include the widget trimming.
-
-
Returns:
- pixel position of the top line
-
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
getWordWrap
public boolean getWordWrap()
- Returns whether the widget wraps lines.
-
-
Returns:
- true if widget wraps lines, false otherwise
-
Since:
- 2.0
insert
public void insert(
String string)
- Inserts a string. The old selection is replaced with the new text.
-
-
Parameters:
-
string - the string
-
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 string is null
-
See Also:
-
replaceTextRange(int,int,String)
invokeAction
public void invokeAction(int action)
- Executes the action.
-
-
Parameters:
-
action - one of the actions defined in ST.java
paste
public 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. If the widget has the SWT.SINGLE style and the
clipboard text contains more than one line, only the first line without
line delimiters is inserted 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
print
public void print()
- Prints the widget's text to the default printer.
-
-
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
print
public
Runnable print(
Printer printer)
- Returns a runnable that will print the widget's text
to the specified printer.
The runnable may be run in a non-UI thread.
-
-
Parameters:
-
printer - the printer to print to
-
Returns:
- a
Runnable for printing the receiver's 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
-
IllegalArgumentException
-
- ERROR_NULL_ARGUMENT when printer is null
print
public
Runnable print(
Printer printer,
StyledTextPrintOptions options)
- Returns a runnable that will print the widget's text
to the specified printer.
The runnable may be run in a non-UI thread.
-
-
Parameters:
-
printer - the printer to print to -
options - print options to use during printing
-
Returns:
- a
Runnable for printing the receiver's 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
-
IllegalArgumentException
-
- ERROR_NULL_ARGUMENT when printer or options is null
-
Since:
- 2.1
redraw
public void redraw()
- Causes the entire bounds of the receiver to be marked
as needing to be redrawn. The next time a paint request
is processed, the control will be completely painted.
Recalculates the content width for all lines in the bounds.
When a LineStyleListener is used a redraw call
is the only notification to the widget that styles have changed
and that the content width may have changed.
-
-
Overrides:
-
redraw
in class
Control
-
-
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
-
See Also:
-
Control.update()
redraw
public 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.
The next time a paint request is processed, that area of
the receiver will be painted. If the
all flag
is true , any children of the receiver which
intersect with the specified area will also paint their
intersecting areas. If the all flag is
false , the children will not be painted.
Marks the content width of all lines in the specified rectangle
as unknown. Recalculates the content width of all visible lines.
When a LineStyleListener is used a redraw call
is the only notification to the widget that styles have changed
and that the content width may have changed.
-
-
Overrides:
-
redraw
in class
Control
-
-
Parameters:
-
x - the x coordinate of the area to draw -
y - the y coordinate of the area to draw -
width - the width of the area to draw -
height - the height of the area to draw -
all - true if children should redraw, and 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
-
See Also:
-
Control.update()
redrawRange
public void redrawRange(int start,
int length,
boolean clearBackground)
- Redraws the specified text range.
-
-
Parameters:
-
start - offset of the first character to redraw -
length - number of characters to redraw -
clearBackground - true if the background should be cleared as
part of the redraw operation. If true, the entire redraw range will
be cleared before anything is redrawn. If the redraw range includes
the last character of a line (i.e., the entire line is redrawn) the
line is cleared all the way to the right border of the widget.
The redraw operation will be faster and smoother if clearBackground
is set to false. Whether or not the flag can be set to false depends
on the type of change that has taken place. If font styles or
background colors for the redraw range have changed, clearBackground
should be set to true. If only foreground colors have changed for
the redraw range, clearBackground can be set to false.
-
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 start and/or end are outside the widget content
removeBidiSegmentListener
public void removeBidiSegmentListener(
BidiSegmentListener listener)
- Removes the specified bidirectional segment listener.
-
-
Parameters:
-
listener - the listener which should no longer be notified
-
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
removeCaretListener
public void removeCaretListener(
CaretListener listener)
- Removes the specified caret listener.
-
-
Parameters:
-
listener - the listener which should no longer be notified
-
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.5
removeExtendedModifyListener
public void removeExtendedModifyListener(
ExtendedModifyListener extendedModifyListener)
- Removes the specified extended modify listener.
-
-
Parameters:
-
extendedModifyListener - the listener which should no longer be notified
-
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
removeLineBackgroundListener
public void removeLineBackgroundListener(
LineBackgroundListener listener)
- Removes the specified line background listener.
-
-
Parameters:
-
listener - the listener which should no longer be notified
-
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
removeLineStyleListener
public void removeLineStyleListener(
LineStyleListener listener)
- Removes the specified line style listener.
-
-
Parameters:
-
listener - the listener which should no longer be notified
-
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
removeModifyListener
public void removeModifyListener(
ModifyListener modifyListener)
- Removes the specified modify listener.
-
-
Parameters:
-
modifyListener - the listener which should no longer be notified
-
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
removePaintObjectListener
public void removePaintObjectListener(
PaintObjectListener listener)
- Removes the specified listener.
-
-
Parameters:
-
listener - the listener which should no longer be notified
-
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
removeSelectionListener
public void removeSelectionListener(
SelectionListener listener)
- Removes the listener from the collection of listeners who will
be notified when the user changes the receiver's selection.
-
-
Parameters:
-
listener - the listener which should no longer be notified
-
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 ,
addSelectionListener(org.eclipse.swt.events.SelectionListener)
removeVerifyListener
public void removeVerifyListener(
VerifyListener verifyListener)
- Removes the specified verify listener.
-
-
Parameters:
-
verifyListener - the listener which should no longer be notified
-
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
removeVerifyKeyListener
public void removeVerifyKeyListener(
VerifyKeyListener listener)
- Removes the specified key verify listener.
-
-
Parameters:
-
listener - the listener which should no longer be notified
-
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
removeWordMovementListener
public void removeWordMovementListener(
MovementListener listener)
- Removes the specified word movement listener.
-
-
Parameters:
-
listener - the listener which should no longer be notified
-
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 ,
addWordMovementListener(org.eclipse.swt.custom.MovementListener)
replaceStyleRanges
public void replaceStyleRanges(int start,
int length,
StyleRange[] ranges)
- Replaces the styles in the given range with new styles. This method
effectively deletes the styles in the given range and then adds the
the new styles.
Note: Because a StyleRange includes the start and length, the
same instance cannot occur multiple times in the array of styles.
If the same style attributes, such as font and color, occur in
multiple StyleRanges, setStyleRanges(int, int, int[], StyleRange[])
can be used to share styles and reduce memory usage.
Should not be called if a LineStyleListener has been set since the
listener maintains the styles.
-
-
Parameters:
-
start - offset of first character where styles will be deleted -
length - length of the range to delete styles in -
ranges - StyleRange objects containing the new style information.
The ranges should not overlap and should be within the specified start
and length. The style rendering is undefined if the ranges do overlap
or are ill-defined. Must not be null.
-
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 either start or end is outside the valid range (0 <= offset <= getCharCount())
- ERROR_NULL_ARGUMENT when ranges is null
-
Since:
- 2.0
-
See Also:
-
setStyleRanges(int, int, int[], StyleRange[])
replaceTextRange
public void replaceTextRange(int start,
int length,
String text)
- Replaces the given text range with new text.
If the widget has the SWT.SINGLE style and "text" contains more than
one line, only the first line is rendered but the text is stored
unchanged. A subsequent call to getText will return the same text
that was set. Note that only a single line of text should be set when
the SWT.SINGLE style is used.
NOTE: During the replace operation the current selection is
changed as follows:
- selection before replaced text: selection unchanged
- selection after replaced text: adjust the selection so that same text
remains selected
- selection intersects replaced text: selection is cleared and caret
is placed after inserted text
-
-
Parameters:
-
start - offset of first character to replace -
length - number of characters to replace. Use 0 to insert text -
text - new text. May be empty to delete 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
-
IllegalArgumentException
-
- ERROR_INVALID_RANGE when either start or end is outside the valid range (0 <= offset <= getCharCount())
- ERROR_INVALID_ARGUMENT when either start or end is inside a multi byte line delimiter.
Splitting a line delimiter for example by inserting text in between the CR and LF and deleting part of a line delimiter is not supported
- ERROR_NULL_ARGUMENT when string is null
scroll
public void scroll(int destX,
int destY,
int x,
int y,
int width,
int height,
boolean all)
-
Description copied from class:
Canvas
- 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. Children that intersect the rectangle are
optionally moved during the operation. In addition, outstanding
paint events are flushed before the source area is copied to
ensure that the contents of the canvas are drawn correctly.
-
-
Overrides:
-
scroll
in class
Canvas
-
-
Parameters:
-
destX - the x coordinate of the destination -
destY - the y coordinate of the destination -
x - the x coordinate of the source -
y - the y coordinate of the source -
width - the width of the area -
height - the height of the area -
all - true if children should be scrolled, and false otherwise
selectAll
public void selectAll()
- Selects all 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
setAlignment
public void setAlignment(int alignment)
- Sets the alignment of the widget. The argument should be one of
SWT.LEFT ,
SWT.CENTER or SWT.RIGHT . The alignment applies for all lines.
Note that if SWT.MULTI is set, then SWT.WRAP must also be set
in order to stabilize the right edge before setting alignment.
-
-
Parameters:
-
alignment - the new 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:
-
setLineAlignment(int, int, int)
setBackground
public void setBackground(
Color color)
-
Description copied from class:
Control
- 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.
Note: This operation is a hint and may be overridden by the platform.
For example, on Windows the background of a Button cannot be changed.
-
-
Overrides:
-
setBackground
in class
Control
-
-
Parameters:
-
color - the new color (or null) -
See Also:
-
Control.setBackground(Color)
setBlockSelection
public void setBlockSelection(boolean blockSelection)
- Sets the block selection mode.
-
-
Parameters:
-
blockSelection - true=enable block selection, false=disable block selection -
Since:
- 3.5
setBlockSelectionBounds
public void setBlockSelectionBounds(
Rectangle rect)
- Sets the block selection bounds. The bounds is
relative to the upper left corner of the document.
-
-
Parameters:
-
rect - the new bounds for the block selection
-
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 point is null
-
Since:
- 3.5
-
See Also:
-
setBlockSelectionBounds(int, int, int, int)
setBlockSelectionBounds
public void setBlockSelectionBounds(int x,
int y,
int width,
int height)
- Sets the block selection bounds. The bounds is
relative to the upper left corner of the document.
-
-
Parameters:
-
x - the new x coordinate for the block selection -
y - the new y coordinate for the block selection -
width - the new width for the block selection -
height - the new height for the block selection
-
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.5
setCaret
public void setCaret(
Caret caret)
- Sets the receiver's caret. Set the caret's height and location.
-
-
Overrides:
-
setCaret
in class
Canvas
-
-
Parameters:
-
caret - the new caret for the receiver
-
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
setBidiColoring
public void setBidiColoring(boolean mode)
-
Deprecated. use BidiSegmentListener instead.
- Sets the BIDI coloring mode. When true the BIDI text display
algorithm is applied to segments of text that are the same
color.
-
-
Parameters:
-
mode - the new 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
setBottomMargin
public void setBottomMargin(int bottomMargin)
- Sets the bottom margin.
-
-
Parameters:
-
bottomMargin - the bottom margin.
-
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.5
setCaretOffset
public void setCaretOffset(int offset)
- Sets the caret offset.
-
-
Parameters:
-
offset - caret offset, relative to the first character in 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
-
IllegalArgumentException
-
- ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a
multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
setContent
public void setContent(
StyledTextContent newContent)
- Sets the content implementation to use for text storage.
-
-
Parameters:
-
newContent - StyledTextContent implementation to use for text storage.
-
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
setCursor
public void setCursor(
Cursor cursor)
- Sets the receiver's cursor to the cursor specified by the
argument. Overridden to handle the null case since the
StyledText widget uses an ibeam as its default cursor.
-
-
Overrides:
-
setCursor
in class
Control
-
-
Parameters:
-
cursor - the new cursor (or null) -
See Also:
-
Control.setCursor(Cursor)
setDoubleClickEnabled
public void setDoubleClickEnabled(boolean enable)
- Sets whether the widget implements double click mouse behavior.
-
-
Parameters:
-
enable - if true double clicking a word selects the word, if false
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
setDragDetect
public void setDragDetect(boolean dragDetect)
-
Description copied from class:
Control
- Sets the receiver's drag detect state. If the argument is
true , the receiver will detect drag gestures,
otherwise these gestures will be ignored.
-
-
Overrides:
-
setDragDetect
in class
Control
-
-
Parameters:
-
dragDetect - the new drag detect state
setEditable
public void setEditable(boolean editable)
- Sets whether the widget content can be edited.
-
-
Parameters:
-
editable - if true content can be edited, if false content can not be
edited
-
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
setFont
public void setFont(
Font font)
- Sets a new font to render text with.
NOTE: Italic fonts are not supported unless they have no overhang
and the same baseline as regular fonts.
-
-
Overrides:
-
setFont
in class
Canvas
-
-
Parameters:
-
font - new font
-
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
setForeground
public void setForeground(
Color color)
-
Description copied from class:
Control
- 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.
Note: This operation is a hint and may be overridden by the platform.
-
-
Overrides:
-
setForeground
in class
Control
-
-
Parameters:
-
color - the new color (or null)
setHorizontalIndex
public void setHorizontalIndex(int offset)
- Sets the horizontal scroll offset relative to the start of the line.
Do nothing if there is no text set.
NOTE: The horizontal index is reset to 0 when new text is set in the
widget.
-
-
Parameters:
-
offset - horizontal scroll offset relative to the start
of the line, measured in character increments starting at 0, if
equal to 0 the content is not scrolled, 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
setHorizontalPixel
public void setHorizontalPixel(int pixel)
- Sets the horizontal pixel offset relative to the start of the line.
Do nothing if there is no text set.
NOTE: The horizontal pixel offset is reset to 0 when new text
is set in the widget.
-
-
Parameters:
-
pixel - horizontal pixel offset relative to the start
of the line.
-
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:
- 2.0
setIndent
public void setIndent(int indent)
- Sets the line indentation of the widget.
It is the amount of blank space, in pixels, at the beginning of each line.
When a line wraps in several lines only the first one is indented.
-
-
Parameters:
-
indent - the new indent
-
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:
-
setLineIndent(int, int, int)
setJustify
public void setJustify(boolean justify)
- Sets whether the widget should justify lines.
-
-
Parameters:
-
justify - whether lines should be 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:
-
setLineJustify(int, int, boolean)
setKeyBinding
public void setKeyBinding(int key,
int action)
- Maps a key to an action.
One action can be associated with N keys. However, each key can only
have one action (key:action is N:1 relation).
-
-
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. -
action - one of the predefined actions defined in ST.java.
Use SWT.NULL to remove a key binding.
-
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
setLeftMargin
public void setLeftMargin(int leftMargin)
- Sets the left margin.
-
-
Parameters:
-
leftMargin - the left margin.
-
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.5
setLineAlignment
public void setLineAlignment(int startLine,
int lineCount,
int alignment)
- Sets the alignment of the specified lines. The argument should be one of
SWT.LEFT ,
SWT.CENTER or SWT.RIGHT .
Note that if SWT.MULTI is set, then SWT.WRAP must also be set
in order to stabilize the right edge before setting alignment.
Should not be called if a LineStyleListener has been set since the listener
maintains the line attributes.
All line attributes are maintained relative to the line text, not the
line index that is specified in this method call.
During text changes, when entire lines are inserted or removed, the line
attributes that are associated with the lines after the change
will "move" with their respective text. An entire line is defined as
extending from the first character on a line to the last and including the
line delimiter.
When two lines are joined by deleting a line delimiter, the top line
attributes take precedence and the attributes of the bottom line are deleted.
For all other text changes line attributes will remain unchanged.
-
-
Parameters:
-
startLine - first line the alignment is applied to, 0 based -
lineCount - number of lines the alignment applies to. -
alignment - line 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
-
IllegalArgumentException
-
- ERROR_INVALID_ARGUMENT when the specified line range is invalid
-
Since:
- 3.2
-
See Also:
-
setAlignment(int)
setLineBackground
public void setLineBackground(int startLine,
int lineCount,
Color background)
- Sets the background color of the specified lines.
The background color is drawn for the width of the widget. All
line background colors are discarded when setText is called.
The text background color if defined in a StyleRange overlays the
line background color.
Should not be called if a LineBackgroundListener has been set since the
listener maintains the line backgrounds.
All line attributes are maintained relative to the line text, not the
line index that is specified in this method call.
During text changes, when entire lines are inserted or removed, the line
attributes that are associated with the lines after the change
will "move" with their respective text. An entire line is defined as
extending from the first character on a line to the last and including the
line delimiter.
When two lines are joined by deleting a line delimiter, the top line
attributes take precedence and the attributes of the bottom line are deleted.
For all other text changes line attributes will remain unchanged.
-
-
Parameters:
-
startLine - first line the color is applied to, 0 based -
lineCount - number of lines the color applies to. -
background - line background color
-
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_ARGUMENT when the specified line range is invalid
setLineBullet
public void setLineBullet(int startLine,
int lineCount,
Bullet bullet)
- Sets the bullet of the specified lines.
Should not be called if a LineStyleListener has been set since the listener
maintains the line attributes.
All line attributes are maintained relative to the line text, not the
line index that is specified in this method call.
During text changes, when entire lines are inserted or removed, the line
attributes that are associated with the lines after the change
will "move" with their respective text. An entire line is defined as
extending from the first character on a line to the last and including the
line delimiter.
When two lines are joined by deleting a line delimiter, the top line
attributes take precedence and the attributes of the bottom line are deleted.
For all other text changes line attributes will remain unchanged.
-
-
Parameters:
-
startLine - first line the bullet is applied to, 0 based -
lineCount - number of lines the bullet applies to. -
bullet - line bullet
-
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_ARGUMENT when the specified line range is invalid
-
Since:
- 3.2
setLineIndent
public void setLineIndent(int startLine,
int lineCount,
int indent)
- Sets the indent of the specified lines.
Should not be called if a LineStyleListener has been set since the listener
maintains the line attributes.
All line attributes are maintained relative to the line text, not the
line index that is specified in this method call.
During text changes, when entire lines are inserted or removed, the line
attributes that are associated with the lines after the change
will "move" with their respective text. An entire line is defined as
extending from the first character on a line to the last and including the
line delimiter.
When two lines are joined by deleting a line delimiter, the top line
attributes take precedence and the attributes of the bottom line are deleted.
For all other text changes line attributes will remain unchanged.
-
-
Parameters:
-
startLine - first line the indent is applied to, 0 based -
lineCount - number of lines the indent applies to. -
indent - line indent
-
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_ARGUMENT when the specified line range is invalid
-
Since:
- 3.2
-
See Also:
-
setIndent(int)
setLineJustify
public void setLineJustify(int startLine,
int lineCount,
boolean justify)
- Sets the justify of the specified lines.
Should not be called if a LineStyleListener has been set since the listener
maintains the line attributes.
All line attributes are maintained relative to the line text, not the
line index that is specified in this method call.
During text changes, when entire lines are inserted or removed, the line
attributes that are associated with the lines after the change
will "move" with their respective text. An entire line is defined as
extending from the first character on a line to the last and including the
line delimiter.
When two lines are joined by deleting a line delimiter, the top line
attributes take precedence and the attributes of the bottom line are deleted.
For all other text changes line attributes will remain unchanged.
-
-
Parameters:
-
startLine - first line the justify is applied to, 0 based -
lineCount - number of lines the justify applies to. -
justify - true if lines should be 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
-
IllegalArgumentException
-
- ERROR_INVALID_ARGUMENT when the specified line range is invalid
-
Since:
- 3.2
-
See Also:
-
setJustify(boolean)
setLineSpacing
public void setLineSpacing(int lineSpacing)
- Sets the line spacing of the widget. The line spacing applies for all lines.
-
-
Parameters:
-
lineSpacing - the line spacing
-
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
setMarginColor
public void setMarginColor(
Color color)
- Sets the color of the margins.
-
-
Parameters:
-
color - the new color (or null)
-
Throws:
-
IllegalArgumentException
-
- ERROR_INVALID_ARGUMENT - if the argument has been disposed
-
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.5
setMargins
public void setMargins(int leftMargin,
int topMargin,
int rightMargin,
int bottomMargin)
- Sets the margins.
-
-
Parameters:
-
leftMargin - the left margin. -
topMargin - the top margin. -
rightMargin - the right margin. -
bottomMargin - the bottom margin.
-
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.5
setOrientation
public 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 .
-
-
Parameters:
-
orientation - new orientation style
-
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:
- 2.1.2
setRightMargin
public void setRightMargin(int rightMargin)
- Sets the right margin.
-
-
Parameters:
-
rightMargin - the right margin.
-
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.5
setSelection
public void setSelection(int start)
- Sets the selection to the given position and scrolls it into view. Equivalent to setSelection(start,start).
-
-
Parameters:
-
start - new caret position
-
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_ARGUMENT when either the start or the end of the selection range is inside a
multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
-
See Also:
-
setSelection(int,int)
setSelection
public void setSelection(
Point point)
- Sets the selection and scrolls it into view.
Indexing is zero based. Text selections are specified in terms of
caret positions. In a text widget that contains N characters, there are
N+1 caret positions, ranging from 0..N
-
-
Parameters:
-
point - x=selection start offset, y=selection end offset
The caret will be placed at the selection start when x > y.
-
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 point is null
- ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a
multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
-
See Also:
-
setSelection(int,int)
setSelectionBackground
public 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.
-
-
Parameters:
-
color - the new color (or null)
-
Throws:
-
IllegalArgumentException
-
- ERROR_INVALID_ARGUMENT - if the argument has been disposed
-
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:
- 2.1
setSelectionForeground
public 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.
Note that this is a HINT. Some platforms do not allow the application
to change the selection foreground color.
-
-
Parameters:
-
color - the new color (or null)
-
Throws:
-
IllegalArgumentException
-
- ERROR_INVALID_ARGUMENT - if the argument has been disposed
-
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:
- 2.1
setSelection
public void setSelection(int start,
int end)
- Sets the selection and scrolls it into view.
Indexing is zero based. Text selections are specified in terms of
caret positions. In a text widget that contains N characters, there are
N+1 caret positions, ranging from 0..N
-
-
Parameters:
-
start - selection start offset. The caret will be placed at the
selection start when start > end. -
end - selection end offset
-
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_ARGUMENT when either the start or the end of the selection range is inside a
multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
-
See Also:
-
setSelectionRange(int,int)
setSelectionRange
public void setSelectionRange(int start,
int length)
- Sets the selection.
The new selection may not be visible. Call showSelection to scroll the selection
into view. A negative length places the caret at the visual start of the selection.
-
-
Parameters:
-
start - offset of the first selected character -
length - number of characters to select
-
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_ARGUMENT when either the start or the end of the selection range is inside a
multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
setStyleRange
public void setStyleRange(
StyleRange range)
- Adds the specified style.
The new style overwrites existing styles for the specified range.
Existing style ranges are adjusted if they partially overlap with
the new style. To clear an individual style, call setStyleRange
with a StyleRange that has null attributes.
Should not be called if a LineStyleListener has been set since the
listener maintains the styles.
-
-
Parameters:
-
range - StyleRange object containing the style information.
Overwrites the old style in the given range. May be null to delete
all styles.
-
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 style range is outside the valid range (> getCharCount())
setStyleRanges
public 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.
The ranges array contains start and length pairs. Each pair refers to
the corresponding style in the styles array. For example, the pair
that starts at ranges[n] with length ranges[n+1] uses the style
at styles[n/2]. The range fields within each StyleRange are ignored.
If ranges or styles is null, the specified range is cleared.
Note: It is expected that the same instance of a StyleRange will occur
multiple times within the styles array, reducing memory usage.
Should not be called if a LineStyleListener has been set since the
listener maintains the styles.
-
-
Parameters:
-
start - offset of first character where styles will be deleted -
length - length of the range to delete styles in -
ranges - the array of ranges. The ranges must not overlap and must be in order. -
styles - the array of StyleRanges. The range fields within the StyleRange are unused.
-
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 an element in the styles array is null
- ERROR_INVALID_RANGE when the number of ranges and style do not match (ranges.length * 2 == styles.length)
- ERROR_INVALID_RANGE when a range is outside the valid range (> getCharCount() or less than zero)
- ERROR_INVALID_RANGE when a range overlaps
-
Since:
- 3.2
setStyleRanges
public void setStyleRanges(int[] ranges,
StyleRange[] styles)
- Sets styles to be used for rendering the widget content.
All styles in the widget will be replaced with the given set of ranges and styles.
The ranges array contains start and length pairs. Each pair refers to
the corresponding style in the styles array. For example, the pair
that starts at ranges[n] with length ranges[n+1] uses the style
at styles[n/2]. The range fields within each StyleRange are ignored.
If either argument is null, the styles are cleared.
Note: It is expected that the same instance of a StyleRange will occur
multiple times within the styles array, reducing memory usage.
Should not be called if a LineStyleListener has been set since the
listener maintains the styles.
-
-
Parameters:
-
ranges - the array of ranges. The ranges must not overlap and must be in order. -
styles - the array of StyleRanges. The range fields within the StyleRange are unused.
-
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 an element in the styles array is null
- ERROR_INVALID_RANGE when the number of ranges and style do not match (ranges.length * 2 == styles.length)
- ERROR_INVALID_RANGE when a range is outside the valid range (> getCharCount() or less than zero)
- ERROR_INVALID_RANGE when a range overlaps
-
Since:
- 3.2
setStyleRanges
public void setStyleRanges(
StyleRange[] ranges)
- Sets styles to be used for rendering the widget content. All styles
in the widget will be replaced with the given set of styles.
Note: Because a StyleRange includes the start and length, the
same instance cannot occur multiple times in the array of styles.
If the same style attributes, such as font and color, occur in
multiple StyleRanges, setStyleRanges(int[], StyleRange[])
can be used to share styles and reduce memory usage.
Should not be called if a LineStyleListener has been set since the
listener maintains the styles.
-
-
Parameters:
-
ranges - StyleRange objects containing the style information.
The ranges should not overlap. The style rendering is undefined if
the ranges do overlap. Must not be null. The styles need to be in order.
-
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 the list of ranges is null
- ERROR_INVALID_RANGE when the last of the style ranges is outside the valid range (> getCharCount())
-
See Also:
-
setStyleRanges(int[], StyleRange[])
setTabs
public void setTabs(int tabs)
- Sets the tab width.
-
-
Parameters:
-
tabs - tab width measured in characters.
-
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
setText
public void setText(
String text)
- Sets the widget content.
If the widget has the SWT.SINGLE style and "text" contains more than
one line, only the first line is rendered but the text is stored
unchanged. A subsequent call to getText will return the same text
that was set.
Note: Only a single line of text should be set when the SWT.SINGLE
style is used.
-
-
Parameters:
-
text - new widget content. Replaces existing content. Line styles
that were set using StyledText API are discarded. The
current selection is also discarded.
-
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 string is null
setTextLimit
public void setTextLimit(int limit)
- Sets the text limit to the specified number of characters.
The text limit specifies the amount of text that
the user can type into the widget.
-
-
Parameters:
-
limit - the new text limit.
-
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_CANNOT_BE_ZERO when limit is 0
setTopIndex
public void setTopIndex(int topIndex)
- Sets the top index. Do nothing if there is no text set.
The top index is the index of the line that is currently at the top
of the widget. The top index changes when the widget is scrolled.
Indexing starts from zero.
Note: The top index is reset to 0 when new text is set in the widget.
-
-
Parameters:
-
topIndex - new top index. Must be between 0 and
getLineCount() - fully visible lines per page. If no lines are fully
visible the maximum value is getLineCount() - 1. An out of range
index will be adjusted accordingly.
-
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
setTopMargin
public void setTopMargin(int topMargin)
- Sets the top margin.
-
-
Parameters:
-
topMargin - the top margin.
-
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.5
setTopPixel
public void setTopPixel(int pixel)
- Sets the top pixel offset. Do nothing if there is no text set.
The top pixel offset is the vertical pixel offset of the widget. The
widget is scrolled so that the given pixel position is at the top.
The top index is adjusted to the corresponding top line.
Note: The top pixel is reset to 0 when new text is set in the widget.
-
-
Parameters:
-
pixel - new top pixel offset. Must be between 0 and
(getLineCount() - visible lines per page) / getLineHeight()). An out
of range offset will be adjusted accordingly.
-
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:
- 2.0
setWordWrap
public void setWordWrap(boolean wrap)
- Sets whether the widget wraps lines.
This overrides the creation style bit SWT.WRAP.
-
-
Parameters:
-
wrap - true=widget wraps lines, false=widget does not wrap lines -
Since:
- 2.0
showSelection
public void showSelection()
- Scrolls the selection into view.
The end of the selection will be scrolled into view.
Note that if a right-to-left selection exists, the end of the selection is
the visual beginning of the selection (i.e., where the caret is located).
-
-
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
Guidelines for using Eclipse APIs.
Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.
|
|
|