|
Eclipse Platform Release 3.1 |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
org.eclipse.swt.widgets.Canvas
org.eclipse.swt.custom.StyledText
A StyledText is an editable user interface object that displays lines of text. The following style attributes can be defined for the text:
In addition to text style attributes, the background color of a line may be specified.
There are two ways to use this widget when specifying text style information. You may use the API that is defined for StyledText or you may define your own LineStyleListener. If you define your own listener, you will be responsible for maintaining the text style information for the widget. IMPORTANT: You may not define your own listener and use the StyledText API. The following StyledText API is not supported if you have defined a LineStyleListener:
There are two ways to use this widget when specifying line background colors. You may use the API that is defined for StyledText or you may define your own LineBackgroundListener. If you define your own listener, you will be responsible for maintaining the line background color information for the widget. IMPORTANT: You may not define your own listener and use the StyledText API. The following StyledText API is not supported if you have defined a LineBackgroundListener:
The content implementation for this widget may also be user-defined. To do so, you must implement the StyledTextContent interface and use the StyledText API setContent(StyledTextContent) to initialize the widget.
IMPORTANT: This class is not intended to be subclassed.
Field Summary |
---|
Fields inherited from class org.eclipse.swt.widgets.Control |
---|
handle |
Constructor Summary | |
---|---|
StyledText(Composite parent,
int style)
Constructs a new instance of this class given its parent and a style value describing its behavior and appearance. |
Method Summary | |
---|---|
void |
addBidiSegmentListener(BidiSegmentListener listener)
Adds a bidirectional segment listener. |
void |
addExtendedModifyListener(ExtendedModifyListener extendedModifyListener)
Adds an extended modify listener. |
void |
addLineBackgroundListener(LineBackgroundListener listener)
Adds a line background listener. |
void |
addLineStyleListener(LineStyleListener listener)
Adds a line style listener. |
void |
addModifyListener(ModifyListener modifyListener)
Adds a modify listener. |
void |
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 |
append(String string)
Appends a string to the text at the end of the widget. |
Point |
computeSize(int wHint,
int hHint,
boolean changed)
Returns the preferred size of the receiver. |
void |
copy()
Copies the selected text to the DND.CLIPBOARD clipboard.
|
void |
copy(int clipboardType)
Copies the selected text to the specified clipboard. |
void |
cut()
Moves the selected text to the clipboard. |
Color |
getBackground()
Returns the receiver's background color. |
int |
getBaseline()
Returns the baseline, in pixels. |
boolean |
getBidiColoring()
Deprecated. use BidiSegmentListener instead. |
int |
getCaretOffset()
Returns the caret position relative to the start of the text. |
int |
getCharCount()
Gets the number of characters. |
StyledTextContent |
getContent()
Returns the content implementation that is used for text storage or null if no user defined content implementation has been set. |
boolean |
getDoubleClickEnabled()
Returns whether the widget implements double click mouse behavior. |
boolean |
getEditable()
Returns whether the widget content can be edited. |
Color |
getForeground()
Returns the foreground color that the receiver will use to draw. |
int |
getHorizontalIndex()
Returns the horizontal scroll offset relative to the start of the line. |
int |
getHorizontalPixel()
Returns the horizontal scroll offset relative to the start of the line. |
int |
getKeyBinding(int key)
Returns the action assigned to the key. |
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. |
int |
getLineCount()
Gets the number of text lines. |
String |
getLineDelimiter()
Returns the line delimiter used for entering new lines by key down or paste operation. |
int |
getLineHeight()
Returns the line height. |
Point |
getLocationAtOffset(int offset)
Returns the x, y location of the upper left corner of the character bounding box at the specified offset in the text. |
int |
getOffsetAtLine(int lineIndex)
Returns the character offset of the first character of the given line. |
int |
getOffsetAtLocation(Point point)
Returns the offset of the character at the given location relative to the first character in the document. |
int |
getOrientation()
Return the orientation of the receiver. |
Point |
getSelection()
Returns the selection. |
Color |
getSelectionBackground()
Returns the receiver's selection background color. |
int |
getSelectionCount()
Gets the number of selected characters. |
Color |
getSelectionForeground()
Returns the receiver's selection foreground color. |
Point |
getSelectionRange()
Returns the selection. |
String |
getSelectionText()
Returns the selected text. |
int |
getStyle()
Returns the receiver's style information. |
StyleRange |
getStyleRangeAtOffset(int offset)
Returns the style range at the given offset. |
StyleRange[] |
getStyleRanges()
Returns the styles. |
StyleRange[] |
getStyleRanges(int start,
int length)
Returns the styles for the given text range. |
int |
getTabs()
Returns the tab width measured in characters. |
String |
getText()
Returns a copy of the widget content. |
String |
getText(int start,
int end)
Returns the widget content between the two offsets. |
Rectangle |
getTextBounds(int start,
int end)
Returns the smallest bounding rectangle that includes the characters between two offsets. |
int |
getTextLimit()
Returns the maximum number of characters that the receiver is capable of holding. |
String |
getTextRange(int start,
int length)
Returns the widget content starting at start for length characters. |
int |
getTopIndex()
Gets the top index. |
int |
getTopPixel()
Gets the top pixel. |
boolean |
getWordWrap()
Returns whether the widget wraps lines. |
void |
insert(String string)
Inserts a string. |
void |
invokeAction(int action)
Executes the action. |
void |
paste()
Replaces the selection with the text on the DND.CLIPBOARD
clipboard or, if there is no selection, inserts the text at the current
caret offset. |
void |
print()
Prints the widget's text to the default printer. |
Runnable |
print(Printer printer)
Returns a runnable that will print the widget's text to the specified printer. |
Runnable |
print(Printer printer,
StyledTextPrintOptions options)
Returns a runnable that will print the widget's text to the specified printer. |
void |
redraw()
Causes the entire bounds of the receiver to be marked as needing to be redrawn. |
void |
redraw(int x,
int y,
int width,
int height,
boolean all)
Causes the rectangular area of the receiver specified by the arguments to be marked as needing to be redrawn. |
void |
redrawRange(int start,
int length,
boolean clearBackground)
Redraws the specified text range. |
void |
removeBidiSegmentListener(BidiSegmentListener listener)
Removes the specified bidirectional segment listener. |
void |
removeExtendedModifyListener(ExtendedModifyListener extendedModifyListener)
Removes the specified extended modify listener. |
void |
removeLineBackgroundListener(LineBackgroundListener listener)
Removes the specified line background listener. |
void |
removeLineStyleListener(LineStyleListener listener)
Removes the specified line style listener. |
void |
removeModifyListener(ModifyListener modifyListener)
Removes the specified modify listener. |
void |
removeSelectionListener(SelectionListener listener)
Removes the specified selection listener. |
void |
removeVerifyKeyListener(VerifyKeyListener listener)
Removes the specified key verify listener. |
void |
removeVerifyListener(VerifyListener verifyListener)
Removes the specified verify listener. |
void |
replaceStyleRanges(int start,
int length,
StyleRange[] ranges)
Replaces the styles in the given range with new styles. |
void |
replaceTextRange(int start,
int length,
String text)
Replaces the given text range with new text. |
void |
selectAll()
Selects all the text. |
void |
setBackground(Color color)
Sets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null. |
void |
setBidiColoring(boolean mode)
Deprecated. use BidiSegmentListener instead. |
void |
setCaret(Caret caret)
Sets the receiver's caret. |
void |
setCaretOffset(int offset)
Sets the caret offset. |
void |
setContent(StyledTextContent newContent)
Sets the content implementation to use for text storage. |
void |
setCursor(Cursor cursor)
Sets the receiver's cursor to the cursor specified by the argument. |
void |
setDoubleClickEnabled(boolean enable)
Sets whether the widget implements double click mouse behavior. |
void |
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 |
setKeyBinding(int key,
int action)
Maps a key to an action. |
void |
setLineBackground(int startLine,
int lineCount,
Color background)
Sets the background color of the specified lines. |
void |
setOrientation(int orientation)
Sets the orientation of the receiver, which must be one of the constants SWT.LEFT_TO_RIGHT or SWT.RIGHT_TO_LEFT .
|
void |
setSelection(int start)
Sets the selection to the given position and scrolls it into view. |
void |
setSelection(int start,
int end)
Sets the selection and scrolls it into view. |
void |
setSelection(Point point)
Sets the selection and scrolls it into view. |
void |
setSelectionBackground(Color color)
Sets the receiver's selection background color to the color specified by the argument, or to the default system color for the control if the argument is null. |
void |
setSelectionForeground(Color color)
Sets the receiver's selection foreground color to the color specified by the argument, or to the default system color for the control if the argument is null. |
void |
setSelectionRange(int start,
int length)
Sets the selection. |
void |
setStyleRange(StyleRange range)
Adds the specified style. |
void |
setStyleRanges(StyleRange[] ranges)
Sets styles to be used for rendering the widget content. |
void |
setTabs(int tabs)
Sets the tab width. |
void |
setText(String text)
Sets the widget content. |
void |
setTextLimit(int limit)
Sets the text limit to the specified number of characters. |
void |
setTopIndex(int topIndex)
Sets the top index. |
void |
setTopPixel(int pixel)
Sets the top pixel offset. |
void |
setWordWrap(boolean wrap)
Sets whether the widget wraps lines. |
void |
showSelection()
/** Scrolls the selection into view. |
Methods inherited from class org.eclipse.swt.widgets.Canvas |
---|
getCaret, scroll |
Methods inherited from class org.eclipse.swt.widgets.Composite |
---|
changed, checkSubclass, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setFocus, setLayout, setLayoutDeferred, setTabList |
Methods inherited from class org.eclipse.swt.widgets.Scrollable |
---|
computeTrim, getClientArea, getHorizontalBar, getVerticalBar |
Methods inherited from class org.eclipse.swt.widgets.Widget |
---|
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
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 construct
IllegalArgumentException
- SWTException
- SWT.FULL_SELECTION
,
SWT.MULTI
,
SWT.READ_ONLY
,
SWT.SINGLE
,
SWT.WRAP
,
getStyle()
Method Detail |
public void addExtendedModifyListener(ExtendedModifyListener extendedModifyListener)
extendedModifyListener
- the listener
SWTException
- IllegalArgumentException
- public void setKeyBinding(int key, int action)
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 addBidiSegmentListener(BidiSegmentListener listener)
listener
- the listener
SWTException
- IllegalArgumentException
- BidiSegmentEvent
public void addLineBackgroundListener(LineBackgroundListener listener)
listener
- the listener
SWTException
- IllegalArgumentException
- public void addLineStyleListener(LineStyleListener listener)
listener
- the listener
SWTException
- IllegalArgumentException
- public void addModifyListener(ModifyListener modifyListener)
modifyListener
- the listener
SWTException
- IllegalArgumentException
- public void addSelectionListener(SelectionListener listener)
When widgetSelected
is called, the event x amd y fields contain
the start and end caret indices of the selection.
widgetDefaultSelected
is not called for StyledTexts.
listener
- the listener
SWTException
- IllegalArgumentException
- public void addVerifyKeyListener(VerifyKeyListener listener)
listener
- the listener
SWTException
- IllegalArgumentException
- public void addVerifyListener(VerifyListener verifyListener)
verifyListener
- the listener
SWTException
- IllegalArgumentException
- public void append(String string)
string
- the string to be appended
SWTException
- IllegalArgumentException
- replaceTextRange(int,int,String)
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
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 clipboard
SWTException
- public void cut()
SWTException
- public Color getBackground()
Control
getBackground
in class Control
public int getBaseline()
SWTException
- public boolean getBidiColoring()
SWTException
- public int getCaretOffset()
SWTException
- public StyledTextContent getContent()
SWTException
- public boolean getDoubleClickEnabled()
SWTException
- public boolean getEditable()
SWTException
- public Color getForeground()
Control
getForeground
in class Control
public int getHorizontalIndex()
SWTException
- public int getHorizontalPixel()
SWTException
- 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 Color getLineBackground(int index)
index
- the index of the line
SWTException
- IllegalArgumentException
- public int getLineCount()
SWTException
- public int getLineAtOffset(int offset)
offset
- offset relative to the start of the content.
0 <= offset <= getCharCount()
SWTException
- IllegalArgumentException
- public String getLineDelimiter()
SWTException
- public int getLineHeight()
SWTException
- public Point getLocationAtOffset(int offset)
offset
- offset relative to the start of the content.
0 <= offset <= getCharCount()
SWTException
- 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 0
SWTException
- IllegalArgumentException
- public int getOffsetAtLocation(Point point)
point
- the origin of character bounding box relative to
the origin of the widget client area.
SWTException
- IllegalArgumentException
- public int getOrientation()
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 Color getSelectionBackground()
SWTException
- public int getSelectionCount()
SWTException
- public Color getSelectionForeground()
SWTException
- public String getSelectionText()
SWTException
- public int getStyle()
Widget
Note that the value which is returned by this method may
not match the value which was provided to the constructor
when the receiver was created. This can occur when the underlying
operating system does not support a particular combination of
requested styles. For example, if the platform widget used to
implement a particular SWT widget always has scroll bars, the
result of calling this method would always have the
SWT.H_SCROLL
and SWT.V_SCROLL
bits set.
getStyle
in class Widget
public StyleRange getStyleRangeAtOffset(int offset)
offset
- the offset to return the style for.
0 <= offset < getCharCount() must be true.
SWTException
- IllegalArgumentException
- public StyleRange[] getStyleRanges()
SWTException
- public StyleRange[] getStyleRanges(int start, int length)
start
- the start offset of the style ranges to returnlength
- the number of style ranges to return
StyleRange
will have a starting offset >= start
and the last returned StyleRange
will have an ending
offset <= start + length - 1
SWTException
- IllegalArgumentException
- public int getTabs()
SWTException
- public String getText()
SWTException
- public String getText(int start, int end)
start
- offset of the first character in the returned Stringend
- offset of the last character in the returned String
SWTException
- 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 box
SWTException
- IllegalArgumentException
- public String getTextRange(int start, int length)
start
- offset of the first character in the returned Stringlength
- number of characters to return
SWTException
- IllegalArgumentException
- public int getTextLimit()
SWTException
- public int getTopIndex()
SWTException
- public int getTopPixel()
SWTException
- public boolean getWordWrap()
public void insert(String string)
string
- the string
SWTException
- IllegalArgumentException
- replaceTextRange(int,int,String)
public void invokeAction(int action)
action
- one of the actions defined in ST.javapublic 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 Runnable print(Printer printer)
The runnable may be run in a non-UI thread.
printer
- the printer to print to
SWTException
- IllegalArgumentException
- public 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 printing
SWTException
- 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
otherwise
SWTException
- Control.update()
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
- IllegalArgumentException
- public void removeBidiSegmentListener(BidiSegmentListener listener)
listener
- the listener
SWTException
- IllegalArgumentException
- public void removeExtendedModifyListener(ExtendedModifyListener extendedModifyListener)
extendedModifyListener
- the listener
SWTException
- IllegalArgumentException
- public void removeLineBackgroundListener(LineBackgroundListener listener)
listener
- the listener
SWTException
- IllegalArgumentException
- public void removeLineStyleListener(LineStyleListener listener)
listener
- the listener
SWTException
- IllegalArgumentException
- public void removeModifyListener(ModifyListener modifyListener)
modifyListener
- the listener
SWTException
- IllegalArgumentException
- public void removeSelectionListener(SelectionListener listener)
listener
- the listener
SWTException
- IllegalArgumentException
- public void removeVerifyListener(VerifyListener verifyListener)
verifyListener
- the listener
SWTException
- IllegalArgumentException
- public void removeVerifyKeyListener(VerifyKeyListener listener)
listener
- the listener
SWTException
- IllegalArgumentException
- public void replaceStyleRanges(int start, int length, StyleRange[] ranges)
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
- IllegalArgumentException
- public void replaceTextRange(int start, int length, 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
- IllegalArgumentException
- public void selectAll()
SWTException
- public void setWordWrap(boolean wrap)
wrap
- true=widget wraps lines, false=widget does not wrap linespublic void setCaret(Caret caret)
setCaret
in class Canvas
caret
- the new caret for the receiver
SWTException
- public void setBackground(Color color)
Control
setBackground
in class Control
color
- the new color (or null)Control.setBackground(org.eclipse.swt.graphics.Color)
public void setBidiColoring(boolean mode)
mode
- the new coloring mode
SWTException
- public void setCaretOffset(int offset)
offset
- caret offset, relative to the first character in the text.
SWTException
- IllegalArgumentException
- public void setContent(StyledTextContent newContent)
newContent
- StyledTextContent implementation to use for text storage.
SWTException
- IllegalArgumentException
- public void setCursor(Cursor cursor)
setCursor
in class Control
cursor
- the new cursor (or null)Control.setCursor(org.eclipse.swt.graphics.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 setEditable(boolean editable)
editable
- if true content can be edited, if false content can not be
edited
SWTException
- 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 font
SWTException
- public void setForeground(Color color)
Control
setForeground
in class Control
color
- the new color (or null)Control.setForeground(org.eclipse.swt.graphics.Color)
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 setLineBackground(int startLine, int lineCount, Color background)
Line background colors 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 background colors 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 background takes precedence and the color of the bottom line is deleted. For all other text changes line background colors will remain unchanged.
startLine
- first line the color is applied to, 0 basedlineCount
- number of lines the color applies to.background
- line background color
SWTException
- IllegalArgumentException
- public void setOrientation(int orientation)
SWT.LEFT_TO_RIGHT
or SWT.RIGHT_TO_LEFT
.
orientation
- new orientation style
SWTException
- public void setSelection(int start)
start
- new caret position
SWTException
- 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
- IllegalArgumentException
- setSelection(int,int)
public void setSelectionBackground(Color color)
color
- the new color (or null)
IllegalArgumentException
- SWTException
- public void setSelectionForeground(Color color)
color
- the new color (or null)
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 offset
SWTException
- IllegalArgumentException
- setSelectionRange(int,int)
public void setSelectionRange(int start, int length)
start
- offset of the first selected characterlength
- number of characters to select
SWTException
- IllegalArgumentException
- public void setStyleRange(StyleRange range)
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
- IllegalArgumentException
- public void setStyleRanges(StyleRange[] ranges)
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
- IllegalArgumentException
- public void setTabs(int tabs)
tabs
- tab width measured in characters.
SWTException
- public void setText(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
- 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
- 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 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 showSelection()
SWTException
-
|
Eclipse Platform Release 3.1 |
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp. and others 2000, 2005. All rights reserved.