|
|||||||||
| Home >> All >> org >> eclipse >> swt >> [ widgets overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.eclipse.swt.widgets
Class Text

java.lang.Objectorg.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Text
- All Implemented Interfaces:
- org.eclipse.swt.graphics.Drawable
- public class Text
- extends Scrollable
Instances of this class are selectable user interface objects that allow the user to enter and modify text.
- Styles:
- CENTER, LEFT, MULTI, PASSWORD, SINGLE, RIGHT, READ_ONLY, WRAP
- Events:
- DefaultSelection, Modify, Verify
Note: Only one of the styles MULTI and SINGLE may be specified.
IMPORTANT: This class is not intended to be subclassed.
| Field Summary | |
(package private) long |
bufferHandle
|
static java.lang.String |
DELIMITER
The delimiter used by multi-line text widgets. |
(package private) boolean |
doubleClick
|
(package private) static int |
INNER_BORDER
|
(package private) static int |
ITER_SIZEOF
|
(package private) int |
lastEventTime
|
static int |
LIMIT
The maximum number of characters that can be entered into a text widget. |
(package private) int |
tabs
|
| Fields inherited from class org.eclipse.swt.widgets.Scrollable |
horizontalBar, scrolledHandle, verticalBar |
| Fields inherited from class org.eclipse.swt.widgets.Control |
accessible, cursor, drawCount, enableWindow, fixedHandle, font, layoutData, menu, parent, redrawWindow, toolTipText |
| Fields inherited from class org.eclipse.swt.widgets.Widget |
ACTIVATE, BUTTON_PRESS_EVENT, BUTTON_RELEASE_EVENT, CANVAS, CHANGED, CLICKED, COMMIT, CONFIGURE_EVENT, data, DEFAULT_HEIGHT, DEFAULT_WIDTH, DELETE_EVENT, DELETE_RANGE, DELETE_TEXT, DISABLED, display, DISPOSED, ENTER_NOTIFY_EVENT, EVENT, EVENT_AFTER, eventTable, EXPOSE_EVENT, FOCUS, FOCUS_IN_EVENT, FOCUS_OUT_EVENT, handle, HANDLE, HIDE, INSERT_TEXT, KEY_PRESS_EVENT, KEY_RELEASE_EVENT, KEYED_DATA, LEAVE_NOTIFY_EVENT, MAP_EVENT, MENU, MNEMONIC_ACTIVATE, MOTION_NOTIFY_EVENT, OBSCURED, POPUP_MENU, PREEDIT_CHANGED, REALIZE, ROW_ACTIVATED, SCROLL_CHILD, SELECT, SHOW, SHOW_HELP, SIZE_ALLOCATE, state, style, STYLE_SET, SWITCH_PAGE, TEST_COLLAPSE_ROW, TEST_EXPAND_ROW, TOGGLED, UNMAP_EVENT, UNREALIZE, VALUE_CHANGED, VISIBILITY_NOTIFY_EVENT, WINDOW_STATE_EVENT |
| Constructor Summary | |
Text(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 |
addModifyListener(org.eclipse.swt.events.ModifyListener listener)
Adds the listener to the collection of listeners who will be notified when the receiver's text is modified, by sending it one of the messages defined in the ModifyListener
interface. |
void |
addSelectionListener(org.eclipse.swt.events.SelectionListener listener)
Adds the listener to the collection of listeners who will be notified when the control is selected, by sending it one of the messages defined in the SelectionListener
interface. |
void |
addVerifyListener(org.eclipse.swt.events.VerifyListener listener)
Adds the listener to the collection of listeners who will be notified when the receiver's text is verified, by sending it one of the messages defined in the VerifyListener
interface. |
void |
append(java.lang.String string)
Appends a string. |
(package private) static int |
checkStyle(int style)
|
void |
clearSelection()
Clears the selection. |
org.eclipse.swt.graphics.Point |
computeSize(int wHint,
int hHint,
boolean changed)
Returns the preferred size of the receiver. |
void |
copy()
Copies the selected text. |
(package private) void |
createHandle(int index)
|
(package private) void |
createWidget(int index)
|
void |
cut()
Cuts the selected text. |
(package private) void |
deregister()
|
(package private) boolean |
filterKey(int keyval,
long event)
|
(package private) org.eclipse.swt.internal.gtk.GdkColor |
getBackgroundColor()
|
int |
getCaretLineNumber()
Gets the line number of the caret. |
org.eclipse.swt.graphics.Point |
getCaretLocation()
Gets the location the caret. |
int |
getCaretPosition()
Gets the position of the caret. |
int |
getCharCount()
Gets the number of characters. |
boolean |
getDoubleClickEnabled()
Gets the double click enabled flag. |
char |
getEchoChar()
Gets the echo character. |
boolean |
getEditable()
Gets the editable state. |
(package private) org.eclipse.swt.internal.gtk.GdkColor |
getForegroundColor()
|
int |
getLineCount()
Gets the number of lines. |
java.lang.String |
getLineDelimiter()
Gets the line delimiter. |
int |
getLineHeight()
Gets the height of a line. |
int |
getOrientation()
Returns the orientation of the receiver. |
org.eclipse.swt.graphics.Point |
getSelection()
Gets the position of the selected text. |
int |
getSelectionCount()
Gets the number of selected characters. |
java.lang.String |
getSelectionText()
Gets the selected text. |
int |
getTabs()
Gets the number of tabs. |
(package private) int |
getTabWidth(int tabs)
|
java.lang.String |
getText()
Gets the widget text. |
java.lang.String |
getText(int start,
int end)
Gets a range of text. |
int |
getTextLimit()
Returns the maximum number of characters that the receiver is capable of holding. |
int |
getTopIndex()
Returns the zero-relative index of the line which is currently at the top of the receiver. |
int |
getTopPixel()
Gets the top pixel. |
(package private) int |
gtk_activate(int widget)
|
(package private) long |
gtk_button_press_event(long widget,
long event)
|
(package private) long |
gtk_changed(long widget)
|
(package private) long |
gtk_commit(long imContext,
long text)
|
(package private) long |
gtk_delete_range(long widget,
long iter1,
long iter2)
|
(package private) long |
gtk_delete_text(long widget,
long start_pos,
long end_pos)
|
(package private) long |
gtk_event_after(long widget,
long gdkEvent)
|
(package private) long |
gtk_insert_text(long widget,
long new_text,
long new_text_length,
long position)
|
(package private) long |
gtk_popup_menu(long widget)
|
(package private) void |
hookEvents()
|
(package private) long |
imContext()
|
void |
insert(java.lang.String string)
Inserts a string. |
(package private) long |
paintWindow()
|
void |
paste()
Pastes text from clipboard. |
(package private) void |
register()
|
void |
removeModifyListener(org.eclipse.swt.events.ModifyListener listener)
Removes the listener from the collection of listeners who will be notified when the receiver's text is modified. |
void |
removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)
Removes the listener from the collection of listeners who will be notified when the control is selected. |
void |
removeVerifyListener(org.eclipse.swt.events.VerifyListener listener)
Removes the listener from the collection of listeners who will be notified when the control is verified. |
void |
selectAll()
Selects all the text in the receiver. |
(package private) void |
setBackgroundColor(org.eclipse.swt.internal.gtk.GdkColor color)
|
(package private) void |
setCursor(long cursor)
|
void |
setDoubleClickEnabled(boolean doubleClick)
Sets the double click enabled flag. |
void |
setEchoChar(char echo)
Sets the echo character. |
void |
setEditable(boolean editable)
Sets the editable state. |
(package private) void |
setFontDescription(long font)
|
(package private) void |
setForegroundColor(org.eclipse.swt.internal.gtk.GdkColor color)
|
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. |
void |
setSelection(int start,
int end)
Sets the selection. |
void |
setSelection(org.eclipse.swt.graphics.Point selection)
Sets the selection. |
void |
setTabs(int tabs)
Sets the number of tabs. |
(package private) void |
setTabStops(int tabs)
|
void |
setText(java.lang.String string)
Sets the contents of the receiver to the given string. |
void |
setTextLimit(int limit)
Sets the maximum number of characters that the receiver is capable of holding to be the argument. |
void |
setTopIndex(int index)
Sets the zero-relative index of the line which is currently at the top of the receiver. |
void |
showSelection()
Shows the selection. |
(package private) boolean |
translateTraversal(org.eclipse.swt.internal.gtk.GdkEventKey keyEvent)
|
(package private) int |
traversalCode(int key,
org.eclipse.swt.internal.gtk.GdkEventKey event)
|
(package private) java.lang.String |
verifyText(java.lang.String string,
int start,
int end)
|
| Methods inherited from class org.eclipse.swt.widgets.Scrollable |
clientHandle, computeTrim, createScrollBar, getBorderWidth, getClientArea, getHorizontalBar, getVerticalBar, hScrollBarWidth, releaseHandle, releaseWidget, resizeHandle, setOrientation, topHandle, vScrollBarWidth |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
bufferHandle
long bufferHandle
tabs
int tabs
lastEventTime
int lastEventTime
doubleClick
boolean doubleClick
INNER_BORDER
static final int INNER_BORDER
- See Also:
- Constant Field Values
ITER_SIZEOF
static final int ITER_SIZEOF
LIMIT
public static final int LIMIT
- The maximum number of characters that can be entered
into a text widget.
DELIMITER
public static final java.lang.String DELIMITER
- The delimiter used by multi-line text widgets. When text
is queried and from the widget, it will be delimited using
this delimiter.
| Constructor Detail |
Text
public Text(Composite parent, int style)
- Constructs a new instance of this class given its parent
and a style value describing its behavior and appearance.
The style value is either one of the style constants defined in class
SWTwhich is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using theint"|" operator) two or more of thoseSWTstyle constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.
| Method Detail |
checkStyle
static int checkStyle(int style)
createHandle
void createHandle(int index)
- Overrides:
createHandlein classWidget
createWidget
void createWidget(int index)
- Overrides:
createWidgetin classScrollable
addModifyListener
public void addModifyListener(org.eclipse.swt.events.ModifyListener listener)
- Adds the listener to the collection of listeners who will
be notified when the receiver's text is modified, by sending
it one of the messages defined in the
ModifyListenerinterface.
addSelectionListener
public void addSelectionListener(org.eclipse.swt.events.SelectionListener listener)
- Adds the listener to the collection of listeners who will
be notified when the control is selected, by sending
it one of the messages defined in the
SelectionListenerinterface.widgetSelectedis not called for texts.widgetDefaultSelectedis typically called when ENTER is pressed in a single-line text.
addVerifyListener
public void addVerifyListener(org.eclipse.swt.events.VerifyListener listener)
- Adds the listener to the collection of listeners who will
be notified when the receiver's text is verified, by sending
it one of the messages defined in the
VerifyListenerinterface.
append
public void append(java.lang.String string)
- Appends a string.
The new text is appended to the text at the end of the widget.
clearSelection
public void clearSelection()
- Clears the selection.
computeSize
public org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint, boolean changed)
- Description copied from class:
Control - Returns the preferred size of the receiver.
The preferred size of a control is the size that it would best be displayed at. The width hint and height hint arguments allow the caller to ask a control questions such as "Given a particular width, how high does the control need to be to show all of the contents?" To indicate that the caller does not wish to constrain a particular dimension, the constant
SWT.DEFAULTis 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 befalse, so layout manager caches can be retained.- Overrides:
computeSizein classControl
copy
public void copy()
- Copies the selected text.
The current selection is copied to the clipboard.
cut
public void cut()
- Cuts the selected text.
The current selection is first copied to the clipboard and then deleted from the widget.
deregister
void deregister()
- Overrides:
deregisterin classScrollable
filterKey
boolean filterKey(int keyval,
long event)
getBackgroundColor
org.eclipse.swt.internal.gtk.GdkColor getBackgroundColor()
- Overrides:
getBackgroundColorin classControl
getCaretLineNumber
public int getCaretLineNumber()
- Gets the line number of the caret.
The line number of the caret is returned.
getCaretLocation
public org.eclipse.swt.graphics.Point getCaretLocation()
- Gets the location the caret.
The location of the caret is returned.
getCaretPosition
public int getCaretPosition()
- Gets the position of the caret.
The character position of the caret is returned.
getCharCount
public int getCharCount()
- Gets the number of characters.
getDoubleClickEnabled
public boolean getDoubleClickEnabled()
- Gets the double click enabled flag.
The double click flag enables or disables the default action of the text widget when the user double clicks.
getEchoChar
public char getEchoChar()
- Gets the echo character.
The echo character is the character that is displayed when the user enters text or the text is changed by the programmer.
getEditable
public boolean getEditable()
- Gets the editable state.
getForegroundColor
org.eclipse.swt.internal.gtk.GdkColor getForegroundColor()
- Overrides:
getForegroundColorin classControl
getLineCount
public int getLineCount()
- Gets the number of lines.
getLineDelimiter
public java.lang.String getLineDelimiter()
- Gets the line delimiter.
getLineHeight
public int getLineHeight()
- Gets the height of a line.
getOrientation
public int getOrientation()
- Returns the orientation of the receiver.
- Since:
- 2.1.2
getSelection
public org.eclipse.swt.graphics.Point getSelection()
- Gets the position of the selected text.
Indexing is zero based. The range of a selection is from 0..N where N is the number of characters in the widget.
getSelectionCount
public int getSelectionCount()
- Gets the number of selected characters.
getSelectionText
public java.lang.String getSelectionText()
- Gets the selected text.
getTabs
public int getTabs()
- Gets the number of tabs.
Tab stop spacing is specified in terms of the space (' ') character. The width of a single tab stop is the pixel width of the spaces.
getTabWidth
int getTabWidth(int tabs)
getText
public java.lang.String getText()
- Gets the widget text.
The text for a text widget is the characters in the widget.
getText
public java.lang.String getText(int start, int end)
- Gets a range of text. Returns an empty string if the
start of the range is greater than the end.
Indexing is zero based. The range of a selection is from 0..N-1 where N is the number of characters in the widget.
getTextLimit
public int getTextLimit()
- Returns the maximum number of characters that the receiver is capable of holding.
If this has not been changed by
setTextLimit(), it will be the constantText.LIMIT.
getTopIndex
public int getTopIndex()
- Returns the zero-relative index of the line which is currently
at the top of the receiver.
This index can change when lines are scrolled or new lines are added or removed.
getTopPixel
public int getTopPixel()
- Gets the top pixel.
The top pixel is the pixel position of the line that is currently at the top of the widget. On some platforms, a text widget can be scrolled by pixels instead of lines so that a partial line is displayed at the top of the widget.
The top pixel changes when the widget is scrolled. The top pixel does not include the widget trimming.
gtk_activate
int gtk_activate(int widget)
gtk_button_press_event
long gtk_button_press_event(long widget,
long event)
- Overrides:
gtk_button_press_eventin classControl
gtk_changed
long gtk_changed(long widget)
- Overrides:
gtk_changedin classWidget
gtk_commit
long gtk_commit(long imContext,
long text)
- Overrides:
gtk_commitin classControl
gtk_delete_range
long gtk_delete_range(long widget,
long iter1,
long iter2)
- Overrides:
gtk_delete_rangein classWidget
gtk_delete_text
long gtk_delete_text(long widget,
long start_pos,
long end_pos)
- Overrides:
gtk_delete_textin classWidget
gtk_event_after
long gtk_event_after(long widget,
long gdkEvent)
- Overrides:
gtk_event_afterin classControl
gtk_insert_text
long gtk_insert_text(long widget,
long new_text,
long new_text_length,
long position)
- Overrides:
gtk_insert_textin classWidget
gtk_popup_menu
long gtk_popup_menu(long widget)
- Overrides:
gtk_popup_menuin classControl
hookEvents
void hookEvents()
- Overrides:
hookEventsin classControl
imContext
long imContext()
insert
public void insert(java.lang.String string)
- Inserts a string.
The old selection is replaced with the new text.
paintWindow
long paintWindow()
- Overrides:
paintWindowin classControl
paste
public void paste()
- Pastes text from clipboard.
The selected text is deleted from the widget and new text inserted from the clipboard.
register
void register()
- Overrides:
registerin classScrollable
removeModifyListener
public void removeModifyListener(org.eclipse.swt.events.ModifyListener listener)
- Removes the listener from the collection of listeners who will
be notified when the receiver's text is modified.
removeSelectionListener
public void removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)
- Removes the listener from the collection of listeners who will
be notified when the control is selected.
removeVerifyListener
public void removeVerifyListener(org.eclipse.swt.events.VerifyListener listener)
- Removes the listener from the collection of listeners who will
be notified when the control is verified.
selectAll
public void selectAll()
- Selects all the text in the receiver.
setBackgroundColor
void setBackgroundColor(org.eclipse.swt.internal.gtk.GdkColor color)
- Overrides:
setBackgroundColorin classControl
setCursor
void setCursor(long cursor)
setDoubleClickEnabled
public void setDoubleClickEnabled(boolean doubleClick)
- Sets the double click enabled flag.
The double click flag enables or disables the default action of the text widget when the user double clicks.
setEchoChar
public void setEchoChar(char echo)
- Sets the echo character.
The echo character is the character that is displayed when the user enters text or the text is changed by the programmer. Setting the echo character to '\0' clears the echo character and redraws the original text. If for any reason the echo character is invalid, the default echo character for the platform is used.
setEditable
public void setEditable(boolean editable)
- Sets the editable state.
setFontDescription
void setFontDescription(long font)
- Overrides:
setFontDescriptionin classControl
setForegroundColor
void setForegroundColor(org.eclipse.swt.internal.gtk.GdkColor color)
- Overrides:
setForegroundColorin classControl
setOrientation
public void setOrientation(int orientation)
- Sets the orientation of the receiver, which must be one
of the constants
SWT.LEFT_TO_RIGHTorSWT.RIGHT_TO_LEFT.- Since:
- 2.1.2
setSelection
public void setSelection(int start)
- Sets the selection.
Indexing is zero based. The range of a selection is from 0..N where N is the number of characters in the widget.
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. This differs from other functions that address character position such as getText () that use the regular array indexing rules.
setSelection
public void setSelection(int start,
int end)
- Sets the selection.
Indexing is zero based. The range of a selection is from 0..N where N is the number of characters in the widget.
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. This differs from other functions that address character position such as getText () that use the usual array indexing rules.
setSelection
public void setSelection(org.eclipse.swt.graphics.Point selection)
- Sets the selection.
Indexing is zero based. The range of a selection is from 0..N where N is the number of characters in the widget.
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. This differs from other functions that address character position such as getText () that use the usual array indexing rules.
setTabs
public void setTabs(int tabs)
- Sets the number of tabs.
Tab stop spacing is specified in terms of the space (' ') character. The width of a single tab stop is the pixel width of the spaces.
setTabStops
void setTabStops(int tabs)
setText
public void setText(java.lang.String string)
- Sets the contents of the receiver to the given string. If the receiver has style
SINGLE and the argument contains multiple lines of text, the result of this
operation is undefined and may vary from platform to platform.
setTextLimit
public void setTextLimit(int limit)
- Sets the maximum number of characters that the receiver
is capable of holding to be the argument.
Instead of trying to set the text limit to zero, consider creating a read-only text widget.
To reset this value to the default, use
setTextLimit(Text.LIMIT).
setTopIndex
public void setTopIndex(int index)
- Sets the zero-relative index of the line which is currently
at the top of the receiver. This index can change when lines
are scrolled or new lines are added and removed.
showSelection
public void showSelection()
- Shows the selection.
If the selection is already showing in the receiver, this method simply returns. Otherwise, lines are scrolled until the selection is visible.
translateTraversal
boolean translateTraversal(org.eclipse.swt.internal.gtk.GdkEventKey keyEvent)
- Overrides:
translateTraversalin classControl
traversalCode
int traversalCode(int key,
org.eclipse.swt.internal.gtk.GdkEventKey event)
- Overrides:
traversalCodein classControl
verifyText
java.lang.String verifyText(java.lang.String string, int start, int end)
|
|||||||||
| Home >> All >> org >> eclipse >> swt >> [ widgets overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC