org.gnu.gtk

Class Entry

Implemented Interfaces:
Editable
Known Direct Subclasses:
SpinButton

public class Entry
extends Widget
implements Editable

A single line text entry widget. A fairly large set of key bindings are supported by default. If the entered text is longer than the allocation of the widget, the widget will scroll so that the cursor position is visible.

Field Summary

Fields inherited from class org.gnu.glib.GObject

eventsInitialized

Constructor Summary

Entry()
Creates a new Entry widget.
Entry(Handle handle)
Create a new Widget with a handle to a native resource returned from a call to the native libraries.

Method Summary

void
addListener(EntryListener listener)
Register an object to handle spin events.
void
copyClipboard()
void
cutClipboard()
void
deleteSelection()
void
deleteText(int start, int end)
protected void
fireEntryEvent(EntryEvent event)
float
getAlignment()
Gets the value set by setAlignment(float).
String
getCharacters(int start, int end)
EntryCompletion
getCompletion()
int
getCursorPosition()
boolean
getEditable()
Class
getEventListenerClass(String signal)
EventType
getEventType(String signal)
boolean
getHasFrame()
Gets the value set by setHasFrame(boolean).
Layout
getLayout()
Gets the Layout used to display the entry.
Point
getLayoutOffsets()
Obtains the position of the Layout used to render text in the entry, in widget coordinates.
int
getMaxLength()
Returns the maximum length of the contents of the widget.
String
getText()
Retrieve the contents of the entry widget.
static Type
getType()
Retrieve the runtime type used by the GLib library.
boolean
getVisible()
Retrieves whether the contents of the entry are visible or not.
int
getWidth()
Gets the value set by setWidth(int).
protected static boolean
gtk_entry_get_activates_default(Handle entry)
protected static Handle
gtk_entry_get_completion(Handle entry)
protected static boolean
gtk_entry_get_has_frame(Handle entry)
protected static byte
gtk_entry_get_invisible_char(Handle entry)
protected static Handle
gtk_entry_get_layout(Handle entry)
protected static void
gtk_entry_get_layout_offsets(Handle entry, int[] x, int[] y)
protected static int
gtk_entry_get_max_length(Handle entry)
protected static String
gtk_entry_get_text(Handle entry)
protected static int
gtk_entry_get_type()
protected static boolean
gtk_entry_get_visibility(Handle entry)
protected static int
gtk_entry_get_width_chars(Handle entry)
protected static Handle
gtk_entry_new()
protected static void
gtk_entry_set_activates_default(Handle entry, boolean setting)
protected static void
gtk_entry_set_completion(Handle entry, Handle completion)
protected static void
gtk_entry_set_has_frame(Handle entry, boolean setting)
protected static void
gtk_entry_set_invisible_char(Handle entry, byte ch)
protected static void
gtk_entry_set_max_length(Handle entry, int max)
protected static void
gtk_entry_set_text(Handle entry, String text)
protected static void
gtk_entry_set_visibility(Handle entry, boolean visible)
protected static void
gtk_entry_set_width_chars(Handle entry, int numChars)
void
handleToggleOverwrite()
int
insertText(String text, int offset)
int
layoutIndexToTextIndex(int layoutIndex)
Converts from a position in the entry contents (returned by getText()) to a position in the entry's PangoLayout (returned by getLayout(), with text retrieved via Layout.getText()).
void
pasteClipboard()
void
removeListener(EntryListener listener)
Removes a listener
void
selectRegion(int start, int end)
Methods from Editable
void
setActivateDefaultWidget(boolean setting)
If setting is TRUE, pressing Enter in the entry will activate the default widget for the window containing the entry.
void
setAlignment(float xalign)
Sets the alignment for the contents of the entry.
void
setCompletion(EntryCompletion completion)
void
setCursorPosition(int position)
void
setEditable(boolean isEditable)
void
setHasFrame(boolean setting)
Sets whether the entry has a beveled frame around it.
void
setInvisibleChar(char character)
Sets the character to use in place of the actual text when setVisibility has been called to set text visibility to FALSE (ie this is the character used in "password mode" to show the user how many characters have been typed).
void
setMaxLength(int max)
Sets the maximum allowed length of the contents of the widget.
void
setText(String text)
Sets the text in the widget to the given value, replacing the current contents.
void
setVisible(boolean visible)
Sets whether the contents of the entry are visible or not.
void
setWidth(int number)
Changes the size request of the entry to be about the right size for number characters.
int
textIndexToLayoutIndex(int textIndex)
Converts from a position in the entry's PangoLayout (returned by getLayout()) to a position in the entry contents (returned by getText()).

Methods inherited from class org.gnu.gtk.Widget

activate, addListener, addListener, addListener, addListener, addListener, addListener, addListener, addListener, canActivateAccel, createContext, createLayout, destroy, draw, drawArea, drawArea, findListener, finish, fireBooleanLifeCycleEvent, fireDragDestinationEvent, fireDragSourceEvent, fireExposeEvent, fireFocusEvent, fireKeyEvent, fireLifeCycleEvent, fireMouseEvent, fireMouseMotionEvent, getAccessible, getColormap, getContext, getData, getDisplay, getEventListenerClass, getEventType, getModifierStyle, getName, getParent, getParentWindow, getPointer, getRootWindow, getScreen, getSensitive, getStyle, getToplevel, getType, getWindow, grabDefault, grabFocus, gtk_drag_dest_set, gtk_drag_dest_unset, gtk_drag_finish, gtk_drag_get_data, gtk_drag_highlight, gtk_drag_source_set, gtk_drag_source_set_icon, gtk_drag_source_set_icon_pixbuf, gtk_drag_source_set_icon_stock, gtk_drag_source_unset, gtk_drag_unhighlight, gtk_widget_activate, gtk_widget_add_accelerator, gtk_widget_add_events, gtk_widget_add_mnemonic_label, gtk_widget_can_activate_accel, gtk_widget_child_focus, gtk_widget_child_notify, gtk_widget_class_path, gtk_widget_create_pango_context, gtk_widget_create_pango_layout, gtk_widget_destroy, gtk_widget_destroyed, gtk_widget_ensure_style, gtk_widget_event, gtk_widget_freeze_child_notify, gtk_widget_get_accessible, gtk_widget_get_ancestor, gtk_widget_get_child_requisition, gtk_widget_get_child_visible, gtk_widget_get_colormap, gtk_widget_get_composite_name, gtk_widget_get_default_colormap, gtk_widget_get_default_direction, gtk_widget_get_default_style, gtk_widget_get_default_visual, gtk_widget_get_direction, gtk_widget_get_display, gtk_widget_get_events, gtk_widget_get_extension_events, gtk_widget_get_modifier_style, gtk_widget_get_name, gtk_widget_get_pango_context, gtk_widget_get_parent, gtk_widget_get_parent_window, gtk_widget_get_pointer, gtk_widget_get_root_window, gtk_widget_get_screen, gtk_widget_get_sensitive, gtk_widget_get_settings, gtk_widget_get_size_request, gtk_widget_get_style, gtk_widget_get_toplevel, gtk_widget_get_type, gtk_widget_get_visual, gtk_widget_get_window, gtk_widget_grab_default, gtk_widget_grab_focus, gtk_widget_has_screen, gtk_widget_hide, gtk_widget_hide_all, gtk_widget_hide_on_delete, gtk_widget_intersect, gtk_widget_is_ancestor, gtk_widget_is_focus, gtk_widget_list_accel_closures, gtk_widget_list_mnemonic_labels, gtk_widget_map, gtk_widget_mnemonic_activate, gtk_widget_modify_base, gtk_widget_modify_bg, gtk_widget_modify_fg, gtk_widget_modify_font, gtk_widget_modify_style, gtk_widget_modify_text, gtk_widget_path, gtk_widget_pop_colormap, gtk_widget_pop_composite_child, gtk_widget_push_colormap, gtk_widget_push_composite_child, gtk_widget_queue_draw, gtk_widget_queue_draw_area, gtk_widget_queue_resize, gtk_widget_realize, gtk_widget_ref, gtk_widget_region_intersect, gtk_widget_remove_accelerator, gtk_widget_remove_mnemonic_label, gtk_widget_render_icon, gtk_widget_reparent, gtk_widget_reset_rc_styles, gtk_widget_send_expose, gtk_widget_set_accel_path, gtk_widget_set_app_paintable, gtk_widget_set_child_visible, gtk_widget_set_colormap, gtk_widget_set_composite_name, gtk_widget_set_default_colormap, gtk_widget_set_default_direction, gtk_widget_set_direction, gtk_widget_set_double_buffered, gtk_widget_set_events, gtk_widget_set_extension_events, gtk_widget_set_name, gtk_widget_set_parent, gtk_widget_set_parent_window, gtk_widget_set_redraw_on_allocate, gtk_widget_set_scroll_adjustments, gtk_widget_set_sensitive, gtk_widget_set_size_request, gtk_widget_set_state, gtk_widget_set_style, gtk_widget_shape_combine_mask, gtk_widget_show, gtk_widget_show_all, gtk_widget_show_now, gtk_widget_size_allocate, gtk_widget_size_request, gtk_widget_style_get_property, gtk_widget_thaw_child_notify, gtk_widget_translate_coordinates, gtk_widget_unmap, gtk_widget_unparent, gtk_widget_unrealize, gtk_widget_unref, handleButtonPressed, handleButtonReleased, handleDelete, handleDragDataGet, handleDragDestination, handleExpose, handleFocusIn, handleFocusOut, handleHide, handleKeyPressed, handleKeyReleased, handleMap, handleMouseEnter, handleMouseLeave, handleMouseMotion, handleNoExpose, handleRealize, handleScroll, handleShow, handleUnmap, hasFocus, hasScreen, hide, hideAll, highlight, intersect, isAncestor, makeWidget, modifyStyle, popColormap, pushColormap, realize, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, reparent, setBackgroundColor, setBaseColor, setColormap, setDoubleBuffered, setDragDestination, setDragIcon, setDragIconPixbuf, setDragIconStock, setDragSource, setFont, setForegroundColor, setMinimumSize, setName, setNoDragDestination, setNoDragSource, setSensitive, setTextColor, shapeCombineMask, show, showAll, unHighlight

Methods inherited from class org.gnu.gtk.GtkObject

destroy, getFlags, getType, gtk_object_destroy, gtk_object_get_type, gtk_object_sink, setFlags, sink

Methods inherited from class org.gnu.glib.GObject

addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addListener, equals, freezeNotify, getBooleanProperty, getData, getData, getDoubleProperty, getEventListenerClass, getEventType, getFloatProperty, getGObjectFromHandle, getHandle, getIntFromHandle, getIntProperty, getJavaObjectProperty, getLongProperty, getNullHandle, getPixbufProperty, getProperty, getStringFromHandle, getStringProperty, hasProperty, hashCode, instantiateJGObjectFromGType, notify, removeEventHandler, removeListener, retrieveGObject, setBooleanProperty, setData, setData, setDoubleProperty, setFloatProperty, setHandle, setIntProperty, setJavaObjectProperty, setLongProperty, setPixbufProperty, setProperty, setStringProperty, thawNotify

Constructor Details

Entry

public Entry()
Creates a new Entry widget.


Entry

public Entry(Handle handle)
Create a new Widget with a handle to a native resource returned from a call to the native libraries.

Parameters:
handle - The handle that represents a pointer to a native resource.

Method Details

addListener

public void addListener(EntryListener listener)
Register an object to handle spin events.

See Also:
EntryListener


copyClipboard

public void copyClipboard()
Specified by:
copyClipboard in interface Editable


cutClipboard

public void cutClipboard()
Specified by:
cutClipboard in interface Editable


deleteSelection

public void deleteSelection()
Specified by:
deleteSelection in interface Editable


deleteText

public void deleteText(int start,
                       int end)
Specified by:
deleteText in interface Editable


fireEntryEvent

protected void fireEntryEvent(EntryEvent event)


getAlignment

public float getAlignment()


getCharacters

public String getCharacters(int start,
                            int end)
Specified by:
getCharacters in interface Editable


getCompletion

public EntryCompletion getCompletion()


getCursorPosition

public int getCursorPosition()
Specified by:
getCursorPosition in interface Editable


getEditable

public boolean getEditable()
Specified by:
getEditable in interface Editable


getEventListenerClass

public Class getEventListenerClass(String signal)
Overrides:
getEventListenerClass in interface Widget


getEventType

public EventType getEventType(String signal)
Overrides:
getEventType in interface Widget


getHasFrame

public boolean getHasFrame()


getLayout

public Layout getLayout()
Gets the Layout used to display the entry. This layout is useful to convert text positions to pixel positions in combination with getLayoutOffsets.

Returns:
The PangoLayout for this entry


getLayoutOffsets

public Point getLayoutOffsets()
Obtains the position of the Layout used to render text in the entry, in widget coordinates. Useful if you want to line up the text in the entry with some other text, e.g. when using the entry to implement editable cells in a sheet widget.

Returns:
A Point identifying the x and y offset of the layout.


getMaxLength

public int getMaxLength()
Returns the maximum length of the contents of the widget.


getText

public String getText()
Retrieve the contents of the entry widget.

Returns:
the text of the widget


getType

public static Type getType()
Retrieve the runtime type used by the GLib library.
Overrides:
getType in interface Widget


getVisible

public boolean getVisible()
Retrieves whether the contents of the entry are visible or not.


getWidth

public int getWidth()

Returns:
Number of chars to request space for, or negative if unset.


gtk_entry_get_activates_default

protected static final boolean gtk_entry_get_activates_default(Handle entry)


gtk_entry_get_completion

protected static final Handle gtk_entry_get_completion(Handle entry)


gtk_entry_get_has_frame

protected static final boolean gtk_entry_get_has_frame(Handle entry)


gtk_entry_get_invisible_char

protected static final byte gtk_entry_get_invisible_char(Handle entry)


gtk_entry_get_layout

protected static final Handle gtk_entry_get_layout(Handle entry)


gtk_entry_get_layout_offsets

protected static final void gtk_entry_get_layout_offsets(Handle entry,
                                                         int[] x,
                                                         int[] y)


gtk_entry_get_max_length

protected static final int gtk_entry_get_max_length(Handle entry)


gtk_entry_get_text

protected static final String gtk_entry_get_text(Handle entry)


gtk_entry_get_type

protected static final int gtk_entry_get_type()


gtk_entry_get_visibility

protected static final boolean gtk_entry_get_visibility(Handle entry)


gtk_entry_get_width_chars

protected static final int gtk_entry_get_width_chars(Handle entry)


gtk_entry_new

protected static final Handle gtk_entry_new()


gtk_entry_set_activates_default

protected static final void gtk_entry_set_activates_default(Handle entry,
                                                            boolean setting)


gtk_entry_set_completion

protected static final void gtk_entry_set_completion(Handle entry,
                                                     Handle completion)


gtk_entry_set_has_frame

protected static final void gtk_entry_set_has_frame(Handle entry,
                                                    boolean setting)


gtk_entry_set_invisible_char

protected static final void gtk_entry_set_invisible_char(Handle entry,
                                                         byte ch)


gtk_entry_set_max_length

protected static final void gtk_entry_set_max_length(Handle entry,
                                                     int max)


gtk_entry_set_text

protected static final void gtk_entry_set_text(Handle entry,
                                               String text)


gtk_entry_set_visibility

protected static final void gtk_entry_set_visibility(Handle entry,
                                                     boolean visible)


gtk_entry_set_width_chars

protected static final void gtk_entry_set_width_chars(Handle entry,
                                                      int numChars)


handleToggleOverwrite

public void handleToggleOverwrite()


insertText

public int insertText(String text,
                      int offset)
Specified by:
insertText in interface Editable


layoutIndexToTextIndex

public int layoutIndexToTextIndex(int layoutIndex)
Converts from a position in the entry contents (returned by getText()) to a position in the entry's PangoLayout (returned by getLayout(), with text retrieved via Layout.getText()).


pasteClipboard

public void pasteClipboard()
Specified by:
pasteClipboard in interface Editable


removeListener

public void removeListener(EntryListener listener)
Removes a listener

See Also:
addListener(EntryListener)


selectRegion

public void selectRegion(int start,
                         int end)
Methods from Editable
Specified by:
selectRegion in interface Editable


setActivateDefaultWidget

public void setActivateDefaultWidget(boolean setting)
If setting is TRUE, pressing Enter in the entry will activate the default widget for the window containing the entry. This usually means that the dialog box containing the entry will be closed, since the default widget is usually one of the dialog buttons.

Parameters:
setting - TRUE to activate window's default widget on Enter keypress


setAlignment

public void setAlignment(float xalign)
Sets the alignment for the contents of the entry. This controls the horizontal positioning of the contents when the displayed text is shorter than the width of the entry.

Parameters:
xalign - The horizontal alignment, from 0 (left) to 1 (right). Reversed for RTL layouts.


setCompletion

public void setCompletion(EntryCompletion completion)


setCursorPosition

public void setCursorPosition(int position)
Specified by:
setCursorPosition in interface Editable


setEditable

public void setEditable(boolean isEditable)
Specified by:
setEditable in interface Editable


setHasFrame

public void setHasFrame(boolean setting)
Sets whether the entry has a beveled frame around it.


setInvisibleChar

public void setInvisibleChar(char character)
Sets the character to use in place of the actual text when setVisibility has been called to set text visibility to FALSE (ie this is the character used in "password mode" to show the user how many characters have been typed). The default invisible char is an asterisk ('*'). If you set the invisible char to 0, then the user will get no feedback at all; there will be no text on the screen as they type.


setMaxLength

public void setMaxLength(int max)
Sets the maximum allowed length of the contents of the widget. If the current contents are longer than the given length, then they will be truncated to fit.

Parameters:
max - The maximum length of the entry, or 0 for no maximum. (other than the maximum length of entries.) The value passed in will be clamped to the range 0-65536.


setText

public void setText(String text)
Sets the text in the widget to the given value, replacing the current contents.

Parameters:
text - The new text.


setVisible

public void setVisible(boolean visible)
Sets whether the contents of the entry are visible or not. When visibility is set to FALSE, characters are displayed as the invisible char, and will also appear that way when the text in the entry widget is copied elsewhere.

The default invisible char is the asterisk '*', but it can be changed with setInvisibleChar().


setWidth

public void setWidth(int number)
Changes the size request of the entry to be about the right size for number characters. Note that it changes the size request, the size can still be affected by how you pack the widget into containers. If n_chars is -1, the size reverts to the default entry size.

Parameters:
number - Width in Characters


textIndexToLayoutIndex

public int textIndexToLayoutIndex(int textIndex)
Converts from a position in the entry's PangoLayout (returned by getLayout()) to a position in the entry contents (returned by getText()).