public class StyledText extends Canvas
In addition to text style attributes, the background color of a line may be specified.
There are two ways to use this widget when specifying text style information. You may use the API that is defined for StyledText or you may define your own LineStyleListener. If you define your own listener, you will be responsible for maintaining the text style information for the widget. IMPORTANT: You may not define your own listener and use the StyledText API. The following StyledText API is not supported if you have defined a LineStyleListener:
There are two ways to use this widget when specifying line background colors. You may use the API that is defined for StyledText or you may define your own LineBackgroundListener. If you define your own listener, you will be responsible for maintaining the line background color information for the widget. IMPORTANT: You may not define your own listener and use the StyledText API. The following StyledText API is not supported if you have defined a LineBackgroundListener:
The content implementation for this widget may also be user-defined. To do so, you must implement the StyledTextContent interface and use the StyledText API setContent(StyledTextContent) to initialize the widget.
IMPORTANT: This class is not intended to be subclassed.
Modifier and Type | Class and Description |
---|---|
(package private) static class |
StyledText.Printing
The Printing class implements printing of a range of text.
|
(package private) class |
StyledText.RTFWriter
The
RTFWriter class is used to write widget content as
rich text. |
(package private) class |
StyledText.TextWriter
The
TextWriter class is used to write widget content to
a string. |
Modifier and Type | Field and Description |
---|---|
(package private) int |
accCaretOffset |
(package private) int |
alignment |
(package private) int |
alignmentMargin |
(package private) boolean |
alwaysShowScroll |
(package private) int |
autoScrollDirection |
(package private) int |
autoScrollDistance |
(package private) Color |
background |
(package private) static int |
BIDI_CARET_WIDTH |
(package private) boolean |
bidiColoring |
(package private) boolean |
blockSelection |
(package private) int |
blockXAnchor |
(package private) int |
blockXLocation |
(package private) int |
blockYAnchor |
(package private) int |
blockYLocation |
(package private) int |
bottomMargin |
(package private) int |
caretAlignment |
(package private) int |
caretDirection |
(package private) int |
caretOffset |
(package private) int |
caretWidth |
(package private) int |
clickCount |
(package private) int |
clientAreaHeight |
(package private) int |
clientAreaWidth |
(package private) Clipboard |
clipboard |
(package private) Point |
clipboardSelection |
(package private) int |
columnX |
(package private) StyledTextContent |
content |
(package private) Cursor |
cursor |
(package private) static int |
DEFAULT_HEIGHT |
(package private) static int |
DEFAULT_WIDTH |
(package private) Caret |
defaultCaret |
(package private) boolean |
doubleClickEnabled |
(package private) Point |
doubleClickSelection |
(package private) boolean |
dragDetect |
(package private) boolean |
editable |
(package private) boolean |
fixedLineHeight |
(package private) Color |
foreground |
(package private) static int |
H_SCROLL_RATE |
(package private) int |
horizontalScrollOffset |
(package private) int |
ignoreResize |
(package private) IME |
ime |
(package private) int |
indent |
(package private) static boolean |
IS_GTK |
(package private) static boolean |
IS_MAC |
(package private) static boolean |
IS_MOTIF |
(package private) boolean |
justify |
(package private) java.util.Hashtable |
keyActionMap |
(package private) int |
lastCharCount |
(package private) int |
lastLineBottom |
(package private) int |
lastTextChangeNewCharCount |
(package private) int |
lastTextChangeNewLineCount |
(package private) int |
lastTextChangeReplaceCharCount |
(package private) int |
lastTextChangeReplaceLineCount |
(package private) int |
lastTextChangeStart |
(package private) Image |
leftCaretBitmap |
(package private) int |
leftMargin |
(package private) int |
lineSpacing |
(package private) Listener |
listener |
(package private) Color |
marginColor |
(package private) int |
newOrientation |
(package private) static int |
OFFSET_LEADING |
(package private) boolean |
overwrite |
(package private) static java.lang.String |
PlatformLineDelimiter |
(package private) static int |
PREVIOUS_OFFSET_TRAILING |
(package private) StyledTextRenderer |
renderer |
(package private) Image |
rightCaretBitmap |
(package private) int |
rightMargin |
(package private) Point |
selection |
(package private) int |
selectionAnchor |
(package private) Color |
selectionBackground |
(package private) Color |
selectionForeground |
(package private) static char |
TAB |
(package private) int |
tabLength |
(package private) int[] |
tabs |
(package private) TextChangeListener |
textChangeListener |
(package private) int |
textLimit |
(package private) int |
topIndex |
(package private) int |
topIndexY |
(package private) int |
topMargin |
(package private) boolean |
updateCaretDirection |
(package private) static int |
V_SCROLL_RATE |
(package private) int |
verticalScrollOffset |
(package private) boolean |
wordWrap |
(package private) int |
wrapIndent |
Constructor and Description |
---|
StyledText(Composite parent,
int style)
Constructs a new instance of this class given its parent
and a style value describing its behavior and appearance.
|
Modifier and Type | Method and Description |
---|---|
(package private) char |
_findMnemonic(java.lang.String string) |
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(java.lang.String string)
Appends a string to the text at the end of the widget.
|
(package private) void |
calculateScrollBars()
Calculates the scroll bars
|
(package private) void |
calculateTopIndex(int delta)
Calculates the top index based on the current vertical scroll offset.
|
(package private) boolean |
checkDragDetect(Event event) |
(package private) static int |
checkStyle(int style)
Hides the scroll bars if widget is created in single line mode.
|
(package private) void |
claimBottomFreeSpace()
Scrolls down the text to use new space made available by a resize or by
deleted lines.
|
(package private) void |
claimRightFreeSpace()
Scrolls text to the right to use new space made available by a resize.
|
(package private) void |
clearBlockSelection(boolean reset,
boolean sendEvent) |
(package private) void |
clearSelection(boolean sendEvent)
Removes the widget selection.
|
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.
|
(package private) boolean |
copySelection(int type) |
(package private) void |
createCaretBitmaps()
Create the bitmaps to use for the caret in bidi mode.
|
(package private) void |
createKeyBindings()
Creates default key bindings.
|
void |
cut()
Moves the selected text to the clipboard.
|
(package private) void |
doAutoScroll(Event event)
A mouse move event has occurred.
|
(package private) void |
doAutoScroll(int direction,
int distance)
Initiates autoscrolling.
|
(package private) void |
doBackspace()
Deletes the previous character.
|
(package private) void |
doBlockColumn(boolean next) |
(package private) void |
doBlockLineHorizontal(boolean end) |
(package private) void |
doBlockLineVertical(boolean up) |
(package private) void |
doBlockSelection(boolean sendEvent) |
(package private) void |
doBlockWord(boolean next) |
(package private) void |
doContent(char key)
Replaces the selection with the character or insert the character at the
current caret position if no selection exists.
|
(package private) void |
doContentEnd()
Moves the caret after the last character of the widget content.
|
(package private) void |
doContentStart()
Moves the caret in front of the first character of the widget content.
|
(package private) void |
doCursorNext()
Moves the caret to the end of the selection if a selection exists.
|
(package private) void |
doCursorPrevious()
Moves the caret to the start of the selection if a selection exists.
|
(package private) void |
doDelete()
Deletes the next character.
|
(package private) void |
doDeleteWordNext()
Deletes the next word.
|
(package private) void |
doDeleteWordPrevious()
Deletes the previous word.
|
(package private) void |
doLineDown(boolean select)
Moves the caret one line down and to the same character offset relative
to the beginning of the line.
|
(package private) void |
doLineEnd()
Moves the caret to the end of the line.
|
(package private) void |
doLineStart()
Moves the caret to the beginning of the line.
|
(package private) void |
doLineUp(boolean select)
Moves the caret one line up and to the same character offset relative
to the beginning of the line.
|
(package private) void |
doMouseLinkCursor() |
(package private) void |
doMouseLinkCursor(int x,
int y) |
(package private) void |
doMouseLocationChange(int x,
int y,
boolean select)
Moves the caret to the specified location.
|
(package private) void |
doMouseSelection()
Updates the selection based on the caret position
|
(package private) int |
doMouseWordSelect(int x,
int newCaretOffset,
int line)
Returns the offset of the word at the specified offset.
|
(package private) void |
doPageDown(boolean select,
int height)
Scrolls one page down so that the last line (truncated or whole)
of the current page becomes the fully visible top line.
|
(package private) void |
doPageEnd()
Moves the cursor to the end of the last fully visible line.
|
(package private) void |
doPageStart()
Moves the cursor to the beginning of the first fully visible line.
|
(package private) void |
doPageUp(boolean select,
int height)
Scrolls one page up so that the first line (truncated or whole)
of the current page becomes the fully visible last line.
|
(package private) void |
doSelection(int direction)
Updates the selection to extend to the current caret position.
|
(package private) void |
doSelectionCursorNext()
Moves the caret to the next character or to the beginning of the
next line if the cursor is at the end of a line.
|
(package private) void |
doSelectionCursorPrevious()
Moves the caret to the previous character or to the end of the previous
line if the cursor is at the beginning of a line.
|
(package private) void |
doSelectionLineDown()
Moves the caret one line down and to the same character offset relative
to the beginning of the line.
|
(package private) void |
doSelectionLineUp()
Moves the caret one line up and to the same character offset relative
to the beginning of the line.
|
(package private) void |
doSelectionPageDown(int pixels)
Scrolls one page down so that the last line (truncated or whole)
of the current page becomes the fully visible top line.
|
(package private) void |
doSelectionPageUp(int pixels)
Scrolls one page up so that the first line (truncated or whole)
of the current page becomes the fully visible last line.
|
(package private) void |
doSelectionWordNext()
Moves the caret to the end of the next word .
|
(package private) void |
doSelectionWordPrevious()
Moves the caret to the start of the previous word.
|
(package private) void |
doVisualNext()
Moves the caret one character to the right.
|
(package private) void |
doVisualPrevious()
Moves the caret one character to the left.
|
(package private) void |
doWordNext()
Moves the caret to the end of the next word.
|
(package private) void |
doWordPrevious()
Moves the caret to the start of the previous word.
|
(package private) void |
endAutoScroll()
Ends the autoscroll process.
|
int |
getAlignment()
Returns the alignment of the widget.
|
boolean |
getAlwaysShowScrollBars()
Returns the Always Show Scrollbars flag.
|
(package private) java.lang.String |
getAssociatedLabel() |
(package private) int |
getAvailableHeightAbove(int height) |
(package private) int |
getAvailableHeightBellow(int height) |
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.
|
(package private) StyledTextEvent |
getBidiSegments(int lineOffset,
java.lang.String line) |
(package private) int[] |
getBidiSegmentsCompatibility(java.lang.String line,
int lineOffset) |
boolean |
getBlockSelection()
Returns whether the widget is in block selection mode.
|
Rectangle |
getBlockSelectionBounds()
Returns the block selection bounds.
|
(package private) Rectangle |
getBlockSelectionPosition() |
(package private) Rectangle |
getBlockSelectionRectangle() |
(package private) java.lang.String |
getBlockSelectionText(java.lang.String delimiter) |
(package private) int |
getBottomIndex()
Returns the index of the last fully visible line.
|
int |
getBottomMargin()
Returns the bottom margin.
|
(package private) Rectangle |
getBoundsAtOffset(int offset) |
(package private) int |
getCaretDirection() |
(package private) int |
getCaretLine() |
int |
getCaretOffset()
Returns the caret position relative to the start of the text.
|
(package private) int |
getCaretWidth()
Returns the caret width.
|
int |
getCharCount()
Gets the number of characters.
|
(package private) java.lang.Object |
getClipboardContent(int clipboardType) |
(package private) int |
getClusterNext(int offset,
int lineIndex) |
(package private) int |
getClusterPrevious(int offset,
int lineIndex) |
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.
|
(package private) int |
getHorizontalIncrement()
Returns the horizontal scroll increment.
|
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.
|
java.lang.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.
|
(package private) StyledTextEvent |
getLineBackgroundData(int lineOffset,
java.lang.String line)
Returns the line background data for the given line or null if
there is none.
|
Bullet |
getLineBullet(int index)
Returns the bullet of the line at the given index.
|
int |
getLineCount()
Gets the number of text lines.
|
(package private) int |
getLineCountWhole()
Returns the number of lines that can be completely displayed in the
widget client area.
|
java.lang.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.
|
(package private) StyledTextEvent |
getLineStyleData(int lineOffset,
java.lang.String line)
Returns the line style data for the given line or null if there is
none.
|
int[] |
getLineTabStops(int index)
Returns the tab stops of the line at the given
index . |
int |
getLineWrapIndent(int index)
Returns the wrap indentation of the line at the given
index . |
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.
|
(package private) java.lang.String |
getModelDelimitedText(java.lang.String text)
Returns a string that uses only the line delimiter specified by the
StyledTextContent implementation.
|
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.
|
(package private) int |
getOffsetAtPoint(int x,
int y,
int[] alignment) |
(package private) int |
getOffsetAtPoint(int x,
int y,
int[] trailing,
boolean inTextOnly) |
(package private) int |
getOffsetAtPoint(int x,
int y,
int lineIndex,
int[] alignment) |
int |
getOrientation()
Returns the orientation of the receiver.
|
(package private) int |
getPartialBottomIndex()
Returns the index of the last partially visible line.
|
(package private) int |
getPartialTopIndex()
Returns the index of the first partially visible line.
|
(package private) java.lang.String |
getPlatformDelimitedText(StyledText.TextWriter writer)
Returns the content in the specified range using the platform line
delimiter to separate lines.
|
(package private) Point |
getPointAtOffset(int offset)
Returns the location of the given offset.
|
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.
|
java.lang.String |
getSelectionText()
Returns the selected text.
|
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.
|
int[] |
getTabStops()
Returns the tab list of the receiver.
|
java.lang.String |
getText()
Returns a copy of the widget content.
|
java.lang.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.
|
java.lang.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.
|
(package private) int |
getVerticalIncrement()
Returns the vertical scroll increment.
|
(package private) int |
getVerticalScrollOffset() |
(package private) int |
getVisualLineIndex(TextLayout layout,
int offsetInLine) |
(package private) int |
getWordNext(int offset,
int movement) |
(package private) int |
getWordNext(int offset,
int movement,
boolean ignoreListener) |
(package private) int |
getWordPrevious(int offset,
int movement) |
(package private) int |
getWordPrevious(int offset,
int movement,
boolean ignoreListener) |
boolean |
getWordWrap()
Returns whether the widget wraps lines.
|
int |
getWrapIndent()
Returns the wrap indentation of the widget.
|
(package private) int |
getWrapWidth() |
(package private) void |
handleCompositionChanged(Event event) |
(package private) void |
handleCompositionOffset(Event event) |
(package private) void |
handleCompositionSelection(Event event) |
(package private) void |
handleDispose(Event event)
Frees resources.
|
(package private) void |
handleHorizontalScroll(Event event)
Scrolls the widget horizontally.
|
(package private) void |
handleKey(Event event)
If an action has been registered for the key stroke execute the action.
|
(package private) void |
handleKeyDown(Event event)
If a VerifyKey listener exists, verify that the key that was entered
should be processed.
|
(package private) void |
handleKeyUp(Event event)
Update the Selection Clipboard.
|
(package private) void |
handleMenuDetect(Event event)
Update the event location for focus-based context menu triggers.
|
(package private) void |
handleMouseDown(Event event)
Updates the caret location and selection if mouse button 1 has been
pressed.
|
(package private) void |
handleMouseMove(Event event)
Updates the caret location and selection if mouse button 1 is pressed
during the mouse move.
|
(package private) void |
handleMouseUp(Event event)
Autoscrolling ends when the mouse button is released.
|
(package private) void |
handlePaint(Event event)
Renders the invalidated area specified in the paint event.
|
(package private) void |
handleResize(Event event)
Recalculates the scroll bars.
|
(package private) void |
handleTextChanged(TextChangedEvent event)
Updates the caret position and selection and the scroll bars to reflect
the content change.
|
(package private) void |
handleTextChanging(TextChangingEvent event)
Updates the screen to reflect a pending content change.
|
(package private) void |
handleTextSet(TextChangedEvent event)
Called when the widget content is set programmatically, overwriting
the old content.
|
(package private) void |
handleTraverse(Event event)
Called when a traversal key is pressed.
|
(package private) void |
handleVerticalScroll(Event event)
Scrolls the widget vertically.
|
(package private) void |
initializeAccessible()
Add accessibility support for the widget.
|
void |
insert(java.lang.String string)
Inserts a string.
|
(package private) void |
insertBlockSelectionText(char key,
int action) |
(package private) int |
insertBlockSelectionText(java.lang.String text,
boolean fillWithSpaces) |
(package private) void |
installDefaultContent()
Creates content change listeners and set the default content model.
|
(package private) void |
installListeners()
Adds event listeners
|
(package private) void |
internalRedrawRange(int start,
int length) |
void |
invokeAction(int action)
Executes the action.
|
(package private) boolean |
invokeBlockAction(int action)
Returns true if an action should not be performed when block
selection in active
|
(package private) boolean |
isBidi()
Temporary until SWT provides this
|
(package private) boolean |
isBidiCaret() |
(package private) boolean |
isFixedLineHeight() |
(package private) boolean |
isLineDelimiter(int offset)
Returns whether the given offset is inside a multi byte line delimiter.
|
(package private) boolean |
isMirrored()
Returns whether the widget is mirrored (right oriented/right to left
writing order).
|
(package private) boolean |
isSingleLine()
Returns whether the widget can have only one line.
|
(package private) void |
modifyContent(Event event,
boolean updateCaret)
Sends the specified verify event, replace/insert text as defined by
the event and send a modify event.
|
(package private) void |
paintObject(GC gc,
int x,
int y,
int ascent,
int descent,
StyleRange style,
Bullet bullet,
int bulletIndex) |
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.
|
java.lang.Runnable |
print(Printer printer)
Returns a runnable that will print the widget's text
to the specified printer.
|
java.lang.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.
|
(package private) void |
redrawLines(int startLine,
int lineCount,
boolean bottomChanged) |
(package private) void |
redrawLinesBullet(int[] redrawLines) |
(package private) void |
redrawMargins(int oldHeight,
int oldWidth) |
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,
java.lang.String text)
Replaces the given text range with new text.
|
(package private) void |
reset()
Resets the caret position, selection and scroll offsets.
|
(package private) void |
resetCache(int firstLine,
int count) |
(package private) void |
resetSelection()
Resets the selection.
|
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.
|
(package private) boolean |
scrollHorizontal(int pixels,
boolean adjustScrollBar)
Scrolls the widget horizontally.
|
(package private) void |
scrollText(int srcY,
int destY) |
(package private) boolean |
scrollVertical(int pixels,
boolean adjustScrollBar)
Scrolls the widget vertically.
|
void |
selectAll()
Selects all the text.
|
(package private) void |
sendAccessibleTextCaretMoved() |
(package private) void |
sendAccessibleTextChanged(int start,
int newCharCount,
int replaceCharCount) |
(package private) void |
sendKeyEvent(Event event)
Replaces/inserts text as defined by the event.
|
(package private) StyledTextEvent |
sendLineEvent(int eventType,
int lineOffset,
java.lang.String line)
Returns a StyledTextEvent that can be used to request data such
as styles and background color for a line.
|
(package private) void |
sendSelectionEvent()
Sends the specified selection event.
|
(package private) int |
sendTextEvent(int left,
int right,
int lineIndex,
java.lang.String text,
boolean fillWithSpaces) |
(package private) int |
sendWordBoundaryEvent(int eventType,
int movement,
int offset,
int newOffset,
java.lang.String lineText,
int lineOffset) |
(package private) void |
setAlignment() |
void |
setAlignment(int alignment)
Sets the alignment of the widget.
|
void |
setAlwaysShowScrollBars(boolean show)
Set the Always Show Scrollbars flag.
|
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.
|
(package private) void |
setBlockSelectionLocation(int x,
int y,
boolean sendEvent) |
(package private) void |
setBlockSelectionLocation(int anchorX,
int anchorY,
int x,
int y,
boolean sendEvent) |
(package private) void |
setBlockSelectionOffset(int offset,
boolean sendEvent) |
(package private) void |
setBlockSelectionOffset(int anchorOffset,
int offset,
boolean sendEvent) |
void |
setBottomMargin(int bottomMargin)
Sets the bottom margin.
|
void |
setCaret(Caret caret)
Sets the receiver's caret.
|
(package private) void |
setCaretLocation()
Moves the Caret to the current caret offset.
|
(package private) void |
setCaretLocation(Point location,
int direction) |
void |
setCaretOffset(int offset)
Sets the caret offset.
|
(package private) void |
setCaretOffset(int offset,
int alignment) |
(package private) void |
setClipboardContent(int start,
int length,
int clipboardType)
Copies the specified text range to the clipboard.
|
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 |
setLineTabStops(int startLine,
int lineCount,
int[] tabStops)
Sets the tab stops of the specified lines.
|
void |
setLineWrapIndent(int startLine,
int lineCount,
int wrapIndent)
Sets the wrap indent of the specified lines.
|
void |
setMarginColor(Color color)
Sets the color of the margins.
|
void |
setMargins(int leftMargin,
int topMargin,
int rightMargin,
int bottomMargin)
Sets the margins.
|
(package private) void |
setMouseWordSelectionAnchor()
Flips selection anchor based on word selection direction.
|
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.
|
(package private) void |
setScrollBar(ScrollBar bar,
int clientArea,
int maximum,
int margin) |
(package private) void |
setScrollBars(boolean vertical)
Adjusts the maximum and the page size of the scroll bars to
reflect content width/length changes.
|
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.
|
(package private) void |
setSelection(int start,
int length,
boolean sendEvent,
boolean doBlock)
Sets the selection.
|
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. |
(package private) void |
setStyleRanges(int start,
int length,
int[] ranges,
StyleRange[] styles,
boolean reset) |
void |
setStyleRanges(StyleRange[] ranges)
Sets styles to be used for rendering the widget content.
|
void |
setTabs(int tabs)
Sets the tab width.
|
void |
setTabStops(int[] tabs)
Sets the receiver's tab list.
|
void |
setText(java.lang.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.
|
(package private) void |
setVariableLineHeight() |
void |
setWordWrap(boolean wrap)
Sets whether the widget wraps lines.
|
void |
setWrapIndent(int wrapIndent)
Sets the wrap line indentation of the widget.
|
(package private) void |
showCaret()
Sets the caret location and scrolls the caret offset into view.
|
(package private) boolean |
showLocation(Rectangle rect,
boolean scrollPage) |
void |
showSelection()
Scrolls the selection into view.
|
(package private) java.lang.String |
stripMnemonic(java.lang.String string) |
(package private) void |
updateCaretVisibility() |
(package private) void |
updateSelection(int startOffset,
int replacedLength,
int newLength)
Updates the selection and caret position depending on the text change.
|
drawBackground, getCaret, getIME, setIME
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackgroundImage, getBorderWidth, getBounds, getCursor, getEnabled, getFont, getLayoutData, getLocation, getMenu, getMonitor, getParent, getRegion, getShell, getSize, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, setBackgroundImage, setBounds, setBounds, setCapture, setEnabled, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setRegion, setSize, setSize, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString
static final char TAB
static final java.lang.String PlatformLineDelimiter
static final int BIDI_CARET_WIDTH
static final int DEFAULT_WIDTH
static final int DEFAULT_HEIGHT
static final int V_SCROLL_RATE
static final int H_SCROLL_RATE
static final int PREVIOUS_OFFSET_TRAILING
static final int OFFSET_LEADING
Color selectionBackground
Color selectionForeground
StyledTextContent content
StyledTextRenderer renderer
Listener listener
TextChangeListener textChangeListener
int verticalScrollOffset
int horizontalScrollOffset
boolean alwaysShowScroll
int ignoreResize
int topIndex
int topIndexY
int clientAreaHeight
int clientAreaWidth
int tabLength
int[] tabs
int leftMargin
int topMargin
int rightMargin
int bottomMargin
Color marginColor
int columnX
int caretOffset
int caretAlignment
Point selection
Point clipboardSelection
int selectionAnchor
Point doubleClickSelection
boolean editable
boolean wordWrap
boolean doubleClickEnabled
boolean overwrite
int textLimit
java.util.Hashtable keyActionMap
Color background
Color foreground
Clipboard clipboard
int clickCount
int autoScrollDirection
int autoScrollDistance
int lastTextChangeStart
int lastTextChangeNewLineCount
int lastTextChangeNewCharCount
int lastTextChangeReplaceLineCount
int lastTextChangeReplaceCharCount
int lastCharCount
int lastLineBottom
boolean bidiColoring
Image leftCaretBitmap
Image rightCaretBitmap
int caretDirection
int caretWidth
Caret defaultCaret
boolean updateCaretDirection
boolean fixedLineHeight
boolean dragDetect
IME ime
Cursor cursor
int alignment
boolean justify
int indent
int wrapIndent
int lineSpacing
int alignmentMargin
int newOrientation
int accCaretOffset
boolean blockSelection
int blockXAnchor
int blockYAnchor
int blockXLocation
int blockYLocation
static final boolean IS_MAC
static final boolean IS_GTK
static final boolean IS_MOTIF
public StyledText(Composite parent, int style)
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.
parent
- a widget which will be the parent of the new instance (cannot be null)style
- the style of widget to constructjava.lang.IllegalArgumentException
- SWTException
- SWT.FULL_SELECTION
,
SWT.MULTI
,
SWT.READ_ONLY
,
SWT.SINGLE
,
SWT.WRAP
,
Widget.getStyle()
public void addExtendedModifyListener(ExtendedModifyListener extendedModifyListener)
extendedModifyListener
- the listenerSWTException
- java.lang.IllegalArgumentException
- public void addBidiSegmentListener(BidiSegmentListener 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.
listener
- the listenerSWTException
- java.lang.IllegalArgumentException
- BidiSegmentEvent
public void addCaretListener(CaretListener listener)
listener
- the listenerSWTException
- java.lang.IllegalArgumentException
- public void addLineBackgroundListener(LineBackgroundListener listener)
listener
- the listenerSWTException
- java.lang.IllegalArgumentException
- public void addLineStyleListener(LineStyleListener listener)
listener
- the listenerSWTException
- java.lang.IllegalArgumentException
- public void addModifyListener(ModifyListener modifyListener)
modifyListener
- the listenerSWTException
- java.lang.IllegalArgumentException
- public void addPaintObjectListener(PaintObjectListener listener)
listener
- the listenerSWTException
- java.lang.IllegalArgumentException
- PaintObjectListener
,
PaintObjectEvent
public void addSelectionListener(SelectionListener listener)
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.
listener
- the listener which should be notified when the user changes the receiver's selectionjava.lang.IllegalArgumentException
- SWTException
- SelectionListener
,
removeSelectionListener(org.eclipse.swt.events.SelectionListener)
,
SelectionEvent
public void addVerifyKeyListener(VerifyKeyListener listener)
listener
- the listenerSWTException
- java.lang.IllegalArgumentException
- public void addVerifyListener(VerifyListener verifyListener)
verifyListener
- the listenerSWTException
- java.lang.IllegalArgumentException
- public void addWordMovementListener(MovementListener movementListener)
movementListener
- the listenerSWTException
- java.lang.IllegalArgumentException
- MovementEvent
,
MovementListener
,
removeWordMovementListener(org.eclipse.swt.custom.MovementListener)
public void append(java.lang.String string)
string
- the string to be appendedSWTException
- java.lang.IllegalArgumentException
- replaceTextRange(int,int,String)
void calculateScrollBars()
void calculateTopIndex(int delta)
static int checkStyle(int style)
void claimBottomFreeSpace()
void claimRightFreeSpace()
void clearBlockSelection(boolean reset, boolean sendEvent)
void clearSelection(boolean sendEvent)
sendEvent
- a Selection event is sent when set to true and when the selection is actually reset.public Point computeSize(int wHint, int hHint, boolean changed)
Control
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.
computeSize
in class Composite
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
otherwiseLayout
,
Control.getBorderWidth()
,
Control.getBounds()
,
Control.getSize()
,
Control.pack(boolean)
,
"computeTrim, getClientArea for controls that implement them"public void copy()
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.
SWTException
- public void copy(int clipboardType)
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.
clipboardType
- indicates the type of clipboardSWTException
- boolean copySelection(int type)
public int getAlignment()
SWTException
- getLineAlignment(int)
public boolean getAlwaysShowScrollBars()
SWTException
- int getAvailableHeightAbove(int height)
int getAvailableHeightBellow(int height)
public Color getMarginColor()
SWTException
- java.lang.String getModelDelimitedText(java.lang.String text)
Returns only the first line if the widget has the SWT.SINGLE style.
text
- the text that may have line delimiters that don't
match the model line delimiter. Possible line delimiters
are CR ('\r'), LF ('\n'), CR/LF ("\r\n")boolean checkDragDetect(Event event)
void createKeyBindings()
void createCaretBitmaps()
public void cut()
SWTException
- void doAutoScroll(Event event)
void doAutoScroll(int direction, int distance)
direction
- SWT.UP, SWT.DOWN, SWT.COLUMN_NEXT, SWT.COLUMN_PREVIOUSvoid doBackspace()
void doBlockColumn(boolean next)
void doBlockWord(boolean next)
void doBlockLineVertical(boolean up)
void doBlockLineHorizontal(boolean end)
void doBlockSelection(boolean sendEvent)
void doContent(char key)
If a carriage return was typed replace it with the line break character used by the widget on this platform.
key
- the character typed by the uservoid doContentEnd()
void doContentStart()
void doCursorPrevious()
doSelectionCursorPrevious()
void doCursorNext()
doSelectionCursorNext()
void doDelete()
void doDeleteWordNext()
void doDeleteWordPrevious()
void doLineDown(boolean select)
void doLineEnd()
void doLineStart()
void doLineUp(boolean select)
void doMouseLinkCursor()
void doMouseLinkCursor(int x, int y)
void doMouseLocationChange(int x, int y, boolean select)
x
- x location of the new caret positiony
- y location of the new caret positionselect
- the location change is a selection operation.
include the line delimiter in the selectionvoid doMouseSelection()
int doMouseWordSelect(int x, int newCaretOffset, int line)
x
- mouse x locationnewCaretOffset
- caret offset of the mouse cursor locationline
- line index of the mouse cursor locationvoid doPageDown(boolean select, int height)
The caret is scrolled the same number of lines so that its location relative to the top line remains the same. The exception is the end of the text where a full page scroll is not possible. In this case the caret is moved after the last character.
select
- whether or not to select the pagevoid doPageEnd()
void doPageStart()
void doPageUp(boolean select, int height)
void doSelection(int direction)
void doSelectionCursorNext()
void doSelectionCursorPrevious()
void doSelectionLineDown()
void doSelectionLineUp()
void doSelectionPageDown(int pixels)
The caret is scrolled the same number of lines so that its location relative to the top line remains the same. The exception is the end of the text where a full page scroll is not possible. In this case the caret is moved after the last character.
Adjusts the selection according to the caret change. This can either add to or subtract from the old selection, depending on the previous selection direction.void doSelectionPageUp(int pixels)
The caret is scrolled the same number of lines so that its location relative to the top line remains the same. The exception is the beginning of the text where a full page scroll is not possible. In this case the caret is moved in front of the first character.
Adjusts the selection according to the caret change. This can either add to or subtract from the old selection, depending on the previous selection direction.
void doSelectionWordNext()
void doSelectionWordPrevious()
void doVisualPrevious()
void doVisualNext()
void doWordNext()
void doWordPrevious()
void endAutoScroll()
public Color getBackground()
Control
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.
getBackground
in class Control
public int getBaseline()
SWTException
- getBaseline(int)
public int getBaseline(int offset)
offset
- the offsetSWTException
- java.lang.IllegalArgumentException
- public boolean getBidiColoring()
SWTException
- public boolean getBlockSelection()
SWTException
- Rectangle getBlockSelectionPosition()
public Rectangle getBlockSelectionBounds()
SWTException
- Rectangle getBlockSelectionRectangle()
java.lang.String getBlockSelectionText(java.lang.String delimiter)
int getBottomIndex()
public int getBottomMargin()
SWTException
- Rectangle getBoundsAtOffset(int offset)
public int getCaretOffset()
SWTException
- int getCaretWidth()
java.lang.Object getClipboardContent(int clipboardType)
int getClusterNext(int offset, int lineIndex)
int getClusterPrevious(int offset, int lineIndex)
public StyledTextContent getContent()
SWTException
- public boolean getDragDetect()
Control
true
if the receiver is detecting
drag gestures, and false
otherwise.getDragDetect
in class Control
public boolean getDoubleClickEnabled()
SWTException
- public boolean getEditable()
SWTException
- public Color getForeground()
Control
getForeground
in class Control
int getHorizontalIncrement()
public int getHorizontalIndex()
SWTException
- public int getHorizontalPixel()
SWTException
- public int getIndent()
SWTException
- getLineIndent(int)
public boolean getJustify()
SWTException
- getLineJustify(int)
public int getKeyBinding(int key)
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.SWTException
- public int getCharCount()
SWTException
- public java.lang.String getLine(int lineIndex)
lineIndex
- index of the line to return.SWTException
- java.lang.IllegalArgumentException
- public int getLineAlignment(int index)
index
- the index of the lineSWTException
- java.lang.IllegalArgumentException
- getAlignment()
public int getLineAtOffset(int offset)
offset
- offset relative to the start of the content.
0 <= offset <= getCharCount()SWTException
- java.lang.IllegalArgumentException
- public Color getLineBackground(int index)
index
- the index of the lineSWTException
- java.lang.IllegalArgumentException
- public Bullet getLineBullet(int index)
index
- the index of the lineSWTException
- java.lang.IllegalArgumentException
- StyledTextEvent getLineBackgroundData(int lineOffset, java.lang.String line)
lineOffset
- offset of the line start relative to the start
of the content.line
- line to get line background data forpublic int getLineCount()
SWTException
- int getLineCountWhole()
public java.lang.String getLineDelimiter()
SWTException
- public int getLineHeight()
Note: this API should not be used if a StyleRange attribute causes lines to have different heights (i.e. different fonts, rise, etc).
SWTException
- getLineHeight(int)
public int getLineHeight(int offset)
offset
- the offsetSWTException
- java.lang.IllegalArgumentException
- public int getLineIndent(int index)
index
- the index of the lineSWTException
- java.lang.IllegalArgumentException
- getIndent()
public boolean getLineJustify(int index)
index
- the index of the lineSWTException
- java.lang.IllegalArgumentException
- getJustify()
public int getLineSpacing()
SWTException
- StyledTextEvent getLineStyleData(int lineOffset, java.lang.String line)
If there is a LineStyleListener but it does not set any styles, the StyledTextEvent.styles field will be initialized to an empty array.
lineOffset
- offset of the line start relative to the start of
the content.line
- line to get line styles forpublic int getLinePixel(int lineIndex)
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.public int getLineIndex(int y)
y
- the y-coordinate pixelpublic int[] getLineTabStops(int index)
index
.index
- the index of the lineSWTException
- java.lang.IllegalArgumentException
- getTabStops()
public int getLineWrapIndent(int index)
index
.index
- the index of the lineSWTException
- java.lang.IllegalArgumentException
- getWrapIndent()
public int getLeftMargin()
SWTException
- public Point getLocationAtOffset(int offset)
offset
- offset relative to the start of the content.
0 <= offset <= getCharCount()SWTException
- java.lang.IllegalArgumentException
- public int getOffsetAtLine(int lineIndex)
lineIndex
- index of the line, 0 based relative to the first
line in the content. 0 <= lineIndex < getLineCount(), except
lineIndex may always be 0SWTException
- java.lang.IllegalArgumentException
- public int getOffsetAtLocation(Point point)
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.
point
- the origin of character bounding box relative to
the origin of the widget client area.SWTException
- java.lang.IllegalArgumentException
- int getOffsetAtPoint(int x, int y, int[] alignment)
int getOffsetAtPoint(int x, int y, int lineIndex, int[] alignment)
int getOffsetAtPoint(int x, int y, int[] trailing, boolean inTextOnly)
public int getOrientation()
getOrientation
in class Control
SWTException
- int getPartialBottomIndex()
int getPartialTopIndex()
java.lang.String getPlatformDelimitedText(StyledText.TextWriter writer)
writer
- the TextWriter to write line text intopublic int[] getRanges()
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)
.
SWTException
- getStyleRanges(boolean)
public int[] getRanges(int start, int length)
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)
.
start
- the start offset of the style ranges to returnlength
- the number of style ranges to returnSWTException
- java.lang.IllegalArgumentException
- getStyleRanges(int, int, boolean)
public int getRightMargin()
SWTException
- public Point getSelection()
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
SWTException
- getSelectionRange()
public Point getSelectionRange()
SWTException
- public int[] getSelectionRanges()
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.
SWTException
- public Color getSelectionBackground()
SWTException
- public int getSelectionCount()
SWTException
- public Color getSelectionForeground()
SWTException
- public java.lang.String getSelectionText()
SWTException
- StyledTextEvent getBidiSegments(int lineOffset, java.lang.String line)
int[] getBidiSegmentsCompatibility(java.lang.String line, int lineOffset)
public StyleRange getStyleRangeAtOffset(int 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.
offset
- the offset to return the style for.
0 <= offset < getCharCount() must be true.SWTException
- java.lang.IllegalArgumentException
- public StyleRange[] getStyleRanges()
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.
SWTException
- getStyleRanges(boolean)
public StyleRange[] getStyleRanges(boolean includeRanges)
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.
includeRanges
- whether the start and length field of the StyleRanges should be set.SWTException
- getRanges(int, int)
,
setStyleRanges(int[], StyleRange[])
public StyleRange[] getStyleRanges(int start, int length)
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.
start
- the start offset of the style ranges to returnlength
- the number of style ranges to returnStyleRange
will have a starting offset >= start
and the last returned StyleRange
will have an ending
offset <= start + length - 1SWTException
- java.lang.IllegalArgumentException
- getStyleRanges(int, int, boolean)
public StyleRange[] getStyleRanges(int start, int length, boolean includeRanges)
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.
start
- the start offset of the style ranges to returnlength
- the number of style ranges to returnincludeRanges
- whether the start and length field of the StyleRanges should be set.StyleRange
will have a starting offset >= start
and the last returned StyleRange
will have an ending
offset <= start + length - 1SWTException
- java.lang.IllegalArgumentException
- getRanges(int, int)
,
setStyleRanges(int[], StyleRange[])
public int getTabs()
SWTException
- getTabStops()
public int[] getTabStops()
SWTException
- public java.lang.String getText()
SWTException
- public java.lang.String getText(int start, int end)
start
- offset of the first character in the returned Stringend
- offset of the last character in the returned StringSWTException
- java.lang.IllegalArgumentException
- getTextRange(int,int)
public Rectangle getTextBounds(int start, int end)
start
- offset of the first character included in the bounding boxend
- offset of the last character included in the bounding boxSWTException
- java.lang.IllegalArgumentException
- public java.lang.String getTextRange(int start, int length)
start
- offset of the first character in the returned Stringlength
- number of characters to returnSWTException
- java.lang.IllegalArgumentException
- public int getTextLimit()
SWTException
- public int getTopIndex()
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.
SWTException
- public int getTopMargin()
SWTException
- public int getTopPixel()
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.
SWTException
- int getVerticalIncrement()
int getVerticalScrollOffset()
int getVisualLineIndex(TextLayout layout, int offsetInLine)
int getCaretDirection()
int getCaretLine()
int getWrapWidth()
int getWordNext(int offset, int movement)
int getWordNext(int offset, int movement, boolean ignoreListener)
int getWordPrevious(int offset, int movement)
int getWordPrevious(int offset, int movement, boolean ignoreListener)
public boolean getWordWrap()
public int getWrapIndent()
SWTException
- getLineWrapIndent(int)
Point getPointAtOffset(int offset)
NOTE: Does not return correct values for true italic fonts (vs. slanted fonts).
public void insert(java.lang.String string)
string
- the stringSWTException
- java.lang.IllegalArgumentException
- replaceTextRange(int,int,String)
int insertBlockSelectionText(java.lang.String text, boolean fillWithSpaces)
void insertBlockSelectionText(char key, int action)
void installDefaultContent()
void installListeners()
void internalRedrawRange(int start, int length)
void handleCompositionOffset(Event event)
void handleCompositionSelection(Event event)
void handleCompositionChanged(Event event)
void handleDispose(Event event)
void handleHorizontalScroll(Event event)
void handleKey(Event event)
event
- keyboard eventvoid handleKeyDown(Event event)
event
- keyboard eventvoid handleKeyUp(Event event)
event
- keyboard eventvoid handleMenuDetect(Event event)
event
- menu detect eventvoid handleMouseDown(Event event)
void handleMouseMove(Event event)
void handleMouseUp(Event event)
void handlePaint(Event event)
event
- paint eventvoid handleResize(Event event)
event
- resize eventvoid handleTextChanged(TextChangedEvent event)
void handleTextChanging(TextChangingEvent event)
event
- .start the start offset of the changeevent
- .newText text that is going to be inserted or empty String
if no text will be insertedevent
- .replaceCharCount length of text that is going to be replacedevent
- .newCharCount length of text that is going to be insertedevent
- .replaceLineCount number of lines that are going to be replacedevent
- .newLineCount number of new lines that are going to be insertedvoid handleTextSet(TextChangedEvent event)
event
- text change event.void handleTraverse(Event event)
event
- the eventvoid handleVerticalScroll(Event event)
void initializeAccessible()
java.lang.String getAssociatedLabel()
java.lang.String stripMnemonic(java.lang.String string)
char _findMnemonic(java.lang.String string)
public void invokeAction(int action)
action
- one of the actions defined in ST.javaboolean invokeBlockAction(int action)
boolean isBidi()
boolean isBidiCaret()
boolean isFixedLineHeight()
boolean isLineDelimiter(int offset)
boolean isMirrored()
boolean isSingleLine()
void modifyContent(Event event, boolean updateCaret)
event
- the text change event.
updateCaret
- whether or not he caret should be set behind
the new textvoid paintObject(GC gc, int x, int y, int ascent, int descent, StyleRange style, Bullet bullet, int bulletIndex)
public void paste()
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.SWTException
- public void print()
SWTException
- public java.lang.Runnable print(Printer printer)
The runnable may be run in a non-UI thread.
printer
- the printer to print toRunnable
for printing the receiver's textSWTException
- java.lang.IllegalArgumentException
- public java.lang.Runnable print(Printer printer, StyledTextPrintOptions options)
The runnable may be run in a non-UI thread.
printer
- the printer to print tooptions
- print options to use during printingRunnable
for printing the receiver's textSWTException
- java.lang.IllegalArgumentException
- public void redraw()
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.
redraw
in class Control
SWTException
- Control.update()
public void redraw(int x, int y, int width, int height, boolean all)
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.
redraw
in class Control
x
- the x coordinate of the area to drawy
- the y coordinate of the area to drawwidth
- the width of the area to drawheight
- the height of the area to drawall
- true
if children should redraw, and false
otherwiseSWTException
- Control.update()
void redrawLines(int startLine, int lineCount, boolean bottomChanged)
void redrawLinesBullet(int[] redrawLines)
void redrawMargins(int oldHeight, int oldWidth)
public void redrawRange(int start, int length, boolean clearBackground)
start
- offset of the first character to redrawlength
- number of characters to redrawclearBackground
- 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.SWTException
- java.lang.IllegalArgumentException
- public void removeBidiSegmentListener(BidiSegmentListener listener)
listener
- the listener which should no longer be notifiedSWTException
- java.lang.IllegalArgumentException
- public void removeCaretListener(CaretListener listener)
listener
- the listener which should no longer be notifiedSWTException
- java.lang.IllegalArgumentException
- public void removeExtendedModifyListener(ExtendedModifyListener extendedModifyListener)
extendedModifyListener
- the listener which should no longer be notifiedSWTException
- java.lang.IllegalArgumentException
- public void removeLineBackgroundListener(LineBackgroundListener listener)
listener
- the listener which should no longer be notifiedSWTException
- java.lang.IllegalArgumentException
- public void removeLineStyleListener(LineStyleListener listener)
listener
- the listener which should no longer be notifiedSWTException
- java.lang.IllegalArgumentException
- public void removeModifyListener(ModifyListener modifyListener)
modifyListener
- the listener which should no longer be notifiedSWTException
- java.lang.IllegalArgumentException
- public void removePaintObjectListener(PaintObjectListener listener)
listener
- the listener which should no longer be notifiedSWTException
- java.lang.IllegalArgumentException
- public void removeSelectionListener(SelectionListener listener)
listener
- the listener which should no longer be notifiedjava.lang.IllegalArgumentException
- SWTException
- SelectionListener
,
addSelectionListener(org.eclipse.swt.events.SelectionListener)
public void removeVerifyListener(VerifyListener verifyListener)
verifyListener
- the listener which should no longer be notifiedSWTException
- java.lang.IllegalArgumentException
- public void removeVerifyKeyListener(VerifyKeyListener listener)
listener
- the listener which should no longer be notifiedSWTException
- java.lang.IllegalArgumentException
- public void removeWordMovementListener(MovementListener listener)
listener
- the listener which should no longer be notifiedSWTException
- java.lang.IllegalArgumentException
- MovementEvent
,
MovementListener
,
addWordMovementListener(org.eclipse.swt.custom.MovementListener)
public void replaceStyleRanges(int start, int length, StyleRange[] ranges)
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.
start
- offset of first character where styles will be deletedlength
- length of the range to delete styles inranges
- 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.SWTException
- java.lang.IllegalArgumentException
- setStyleRanges(int, int, int[], StyleRange[])
public void replaceTextRange(int start, int length, java.lang.String text)
NOTE: During the replace operation the current selection is changed as follows:
start
- offset of first character to replacelength
- number of characters to replace. Use 0 to insert texttext
- new text. May be empty to delete text.SWTException
- java.lang.IllegalArgumentException
- void reset()
void resetCache(int firstLine, int count)
void resetSelection()
public void scroll(int destX, int destY, int x, int y, int width, int height, boolean all)
Canvas
scroll
in class Canvas
destX
- the x coordinate of the destinationdestY
- the y coordinate of the destinationx
- the x coordinate of the sourcey
- the y coordinate of the sourcewidth
- the width of the areaheight
- the height of the areaall
- true
if children should be scrolled, and false
otherwiseboolean scrollHorizontal(int pixels, boolean adjustScrollBar)
pixels
- number of pixels to scroll, > 0 = scroll left,
< 0 scroll rightadjustScrollBar
- true= the scroll thumb will be moved to reflect the new scroll offset.
false = the scroll thumb will not be movedboolean scrollVertical(int pixels, boolean adjustScrollBar)
pixel
- the new vertical scroll offsetadjustScrollBar
- true= the scroll thumb will be moved to reflect the new scroll offset.
false = the scroll thumb will not be movedvoid scrollText(int srcY, int destY)
void sendAccessibleTextCaretMoved()
void sendAccessibleTextChanged(int start, int newCharCount, int replaceCharCount)
public void selectAll()
SWTException
- void sendKeyEvent(Event event)
event
- the text change event.
StyledTextEvent sendLineEvent(int eventType, int lineOffset, java.lang.String line)
The specified line may be a visual (wrapped) line if in word wrap mode. The returned object will always be for a logical (unwrapped) line.
lineOffset
- offset of the line. This may be the offset of
a visual line if the widget is in word wrap mode.line
- line text. This may be the text of a visual line if
the widget is in word wrap mode.void sendSelectionEvent()
int sendTextEvent(int left, int right, int lineIndex, java.lang.String text, boolean fillWithSpaces)
int sendWordBoundaryEvent(int eventType, int movement, int offset, int newOffset, java.lang.String lineText, int lineOffset)
void setAlignment()
public void setAlignment(int alignment)
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.
alignment
- the new alignmentSWTException
- setLineAlignment(int, int, int)
public void setAlwaysShowScrollBars(boolean show)
show
- true to show the scrollbars even when not required, false to show scrollbars only when requiredSWTException
- public void setBackground(Color color)
Control
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.
setBackground
in class Control
color
- the new color (or null)Control.setBackground(Color)
public void setBlockSelection(boolean blockSelection)
blockSelection
- true=enable block selection, false=disable block selectionpublic void setBlockSelectionBounds(Rectangle rect)
rect
- the new bounds for the block selectionSWTException
- java.lang.IllegalArgumentException
- setBlockSelectionBounds(int, int, int, int)
public void setBlockSelectionBounds(int x, int y, int width, int height)
x
- the new x coordinate for the block selectiony
- the new y coordinate for the block selectionwidth
- the new width for the block selectionheight
- the new height for the block selectionSWTException
- void setBlockSelectionLocation(int x, int y, boolean sendEvent)
void setBlockSelectionLocation(int anchorX, int anchorY, int x, int y, boolean sendEvent)
void setBlockSelectionOffset(int offset, boolean sendEvent)
void setBlockSelectionOffset(int anchorOffset, int offset, boolean sendEvent)
public void setCaret(Caret caret)
setCaret
in class Canvas
caret
- the new caret for the receiverSWTException
- public void setBidiColoring(boolean mode)
mode
- the new coloring modeSWTException
- public void setBottomMargin(int bottomMargin)
bottomMargin
- the bottom margin.SWTException
- void setCaretLocation()
void setCaretLocation(Point location, int direction)
public void setCaretOffset(int offset)
offset
- caret offset, relative to the first character in the text.SWTException
- java.lang.IllegalArgumentException
- void setCaretOffset(int offset, int alignment)
void setClipboardContent(int start, int length, int clipboardType) throws SWTError
start
- start index of the textlength
- length of text to place in clipboardSWTError,
- see Clipboard.setContentsSWTError
Clipboard.setContents(java.lang.Object[], org.eclipse.swt.dnd.Transfer[])
public void setContent(StyledTextContent newContent)
newContent
- StyledTextContent implementation to use for text storage.SWTException
- java.lang.IllegalArgumentException
- public void setCursor(Cursor cursor)
setCursor
in class Control
cursor
- the new cursor (or null)Control.setCursor(Cursor)
public void setDoubleClickEnabled(boolean enable)
enable
- if true double clicking a word selects the word, if false
double clicks have the same effect as regular mouse clicks.SWTException
- public void setDragDetect(boolean dragDetect)
Control
true
, the receiver will detect drag gestures,
otherwise these gestures will be ignored.setDragDetect
in class Control
dragDetect
- the new drag detect statepublic void setEditable(boolean editable)
editable
- if true content can be edited, if false content can not be
editedSWTException
- public void setFont(Font font)
NOTE: Italic fonts are not supported unless they have no overhang and the same baseline as regular fonts.
setFont
in class Canvas
font
- new fontSWTException
- public void setForeground(Color color)
Control
Note: This operation is a hint and may be overridden by the platform.
setForeground
in class Control
color
- the new color (or null)public void setHorizontalIndex(int offset)
NOTE: The horizontal index is reset to 0 when new text is set in the widget.
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.SWTException
- public void setHorizontalPixel(int pixel)
NOTE: The horizontal pixel offset is reset to 0 when new text is set in the widget.
pixel
- horizontal pixel offset relative to the start
of the line.SWTException
- public void setIndent(int indent)
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.
indent
- the new indentSWTException
- setLineIndent(int, int, int)
public void setJustify(boolean justify)
justify
- whether lines should be justifiedSWTException
- setLineJustify(int, int, boolean)
public void setKeyBinding(int key, int action)
One action can be associated with N keys. However, each key can only have one action (key:action is N:1 relation).
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.SWTException
- public void setLeftMargin(int leftMargin)
leftMargin
- the left margin.SWTException
- public void setLineAlignment(int startLine, int lineCount, int alignment)
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.
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.
startLine
- first line the alignment is applied to, 0 basedlineCount
- number of lines the alignment applies to.alignment
- line alignmentSWTException
- java.lang.IllegalArgumentException
- setAlignment(int)
public void setLineBackground(int startLine, int lineCount, Color background)
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.
startLine
- first line the color is applied to, 0 basedlineCount
- number of lines the color applies to.background
- line background colorSWTException
- java.lang.IllegalArgumentException
- public void setLineBullet(int startLine, int lineCount, Bullet bullet)
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.
startLine
- first line the bullet is applied to, 0 basedlineCount
- number of lines the bullet applies to.bullet
- line bulletSWTException
- java.lang.IllegalArgumentException
- void setVariableLineHeight()
public void setLineIndent(int startLine, int lineCount, int indent)
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.
startLine
- first line the indent is applied to, 0 basedlineCount
- number of lines the indent applies to.indent
- line indentSWTException
- java.lang.IllegalArgumentException
- setIndent(int)
public void setLineJustify(int startLine, int lineCount, boolean justify)
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.
startLine
- first line the justify is applied to, 0 basedlineCount
- number of lines the justify applies to.justify
- true if lines should be justifiedSWTException
- java.lang.IllegalArgumentException
- setJustify(boolean)
public void setLineSpacing(int lineSpacing)
lineSpacing
- the line spacingSWTException
- public void setLineTabStops(int startLine, int lineCount, int[] tabStops)
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.
startLine
- first line the justify is applied to, 0 basedlineCount
- number of lines the justify applies to.tabStops
- tab stopsSWTException
- java.lang.IllegalArgumentException
- setTabStops(int[])
public void setLineWrapIndent(int startLine, int lineCount, int wrapIndent)
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.
startLine
- first line the wrap indent is applied to, 0 basedlineCount
- number of lines the wrap indent applies to.wrapIndent
- line wrap indentSWTException
- java.lang.IllegalArgumentException
- setWrapIndent(int)
public void setMarginColor(Color color)
color
- the new color (or null)java.lang.IllegalArgumentException
- SWTException
- public void setMargins(int leftMargin, int topMargin, int rightMargin, int bottomMargin)
leftMargin
- the left margin.topMargin
- the top margin.rightMargin
- the right margin.bottomMargin
- the bottom margin.SWTException
- void setMouseWordSelectionAnchor()
public void setOrientation(int orientation)
SWT.LEFT_TO_RIGHT
or SWT.RIGHT_TO_LEFT
.setOrientation
in class Control
orientation
- new orientation styleSWTException
- public void setRightMargin(int rightMargin)
rightMargin
- the right margin.SWTException
- void setScrollBar(ScrollBar bar, int clientArea, int maximum, int margin)
void setScrollBars(boolean vertical)
vertical
- indicates if the vertical scrollbar also needs to be setpublic void setSelection(int start)
start
- new caret positionSWTException
- java.lang.IllegalArgumentException
- setSelection(int,int)
public void setSelection(Point point)
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
point
- x=selection start offset, y=selection end offset
The caret will be placed at the selection start when x > y.SWTException
- java.lang.IllegalArgumentException
- setSelection(int,int)
public void setSelectionBackground(Color color)
color
- the new color (or null)java.lang.IllegalArgumentException
- SWTException
- public void setSelectionForeground(Color color)
Note that this is a HINT. Some platforms do not allow the application to change the selection foreground color.
color
- the new color (or null)java.lang.IllegalArgumentException
- SWTException
- public void setSelection(int start, int end)
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
start
- selection start offset. The caret will be placed at the
selection start when start > end.end
- selection end offsetSWTException
- java.lang.IllegalArgumentException
- setSelectionRange(int,int)
void setSelection(int start, int length, boolean sendEvent, boolean doBlock)
The new selection may not be visible. Call showSelection to scroll the selection into view.
start
- offset of the first selected character, start >= 0 must be true.length
- number of characters to select, 0 <= start + length
<= getCharCount() must be true.
A negative length places the caret at the selection start.sendEvent
- a Selection event is sent when set to true and when
the selection is reset.public void setSelectionRange(int start, int length)
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.
start
- offset of the first selected characterlength
- number of characters to selectSWTException
- java.lang.IllegalArgumentException
- public void setStyleRange(StyleRange range)
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.
range
- StyleRange object containing the style information.
Overwrites the old style in the given range. May be null to delete
all styles.SWTException
- java.lang.IllegalArgumentException
- public void setStyleRanges(int start, int length, int[] ranges, StyleRange[] styles)
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.
start
- offset of first character where styles will be deletedlength
- length of the range to delete styles inranges
- 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.SWTException
- java.lang.IllegalArgumentException
- public void setStyleRanges(int[] ranges, StyleRange[] styles)
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.
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.SWTException
- java.lang.IllegalArgumentException
- void setStyleRanges(int start, int length, int[] ranges, StyleRange[] styles, boolean reset)
public void setStyleRanges(StyleRange[] ranges)
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.
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.SWTException
- java.lang.IllegalArgumentException
- setStyleRanges(int[], StyleRange[])
public void setTabs(int tabs)
tabs
- tab width measured in characters.SWTException
- setTabStops(int[])
public void setTabStops(int[] tabs)
tabs
- the new tab list (or null)SWTException
- java.lang.IllegalArgumentException
- getTabStops()
public void setText(java.lang.String text)
Note: Only a single line of text should be set when the SWT.SINGLE style is used.
text
- new widget content. Replaces existing content. Line styles
that were set using StyledText API are discarded. The
current selection is also discarded.SWTException
- java.lang.IllegalArgumentException
- public void setTextLimit(int limit)
The text limit specifies the amount of text that the user can type into the widget.
limit
- the new text limit.SWTException
- java.lang.IllegalArgumentException
- public void setTopIndex(int topIndex)
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.
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.SWTException
- public void setTopMargin(int topMargin)
topMargin
- the top margin.SWTException
- public void setTopPixel(int pixel)
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.
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.SWTException
- public void setWordWrap(boolean wrap)
This overrides the creation style bit SWT.WRAP.
wrap
- true=widget wraps lines, false=widget does not wrap linespublic void setWrapIndent(int wrapIndent)
It is the amount of blank space, in pixels, at the beginning of each wrapped line. When a line wraps in several lines all the lines but the first one is indented by this amount.
wrapIndent
- the new wrap indentSWTException
- setLineWrapIndent(int, int, int)
boolean showLocation(Rectangle rect, boolean scrollPage)
void showCaret()
public void showSelection()
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).
SWTException
- void updateCaretVisibility()
void updateSelection(int startOffset, int replacedLength, int newLength)
If the selection intersects with the replaced text, the selection is reset and the caret moved to the end of the new text. If the selection is behind the replaced text it is moved so that the same text remains selected. If the selection is before the replaced text it is left unchanged.
startOffset
- offset of the text changereplacedLength
- length of text being replacednewLength
- length of new text