sub_arctic.lib
Class oneline_text_edit

java.lang.Object
  |
  +--sub_arctic.lib.min_interactor
        |
        +--sub_arctic.lib.base_interactor
              |
              +--sub_arctic.lib.oneline_text_display
                    |
                    +--sub_arctic.lib.oneline_text_edit

public class oneline_text_edit
extends oneline_text_display
implements text_acceptor, pressable, simple_draggable

Single line text edit box. This class allows entry and editing of a single line of text. The text is maintained with a selection or entry point. Selection positions in strings refer to the spaces before the characters (numbered from 0). So for example a selection from 0 to 0 places the cursor before the first character (the character at index 0) while a selection from 1 to 2 selects the second character (the character at index 1).


Fields inherited from class sub_arctic.lib.oneline_text_display
_colors, _end_of_selection, _font, _h_spacing, _metric, _start_of_selection, _text, _v_spacing, _x_adjust, BOXED, have_focus, NO_SELECTION, SELECT_END
 
Fields inherited from class sub_arctic.lib.base_interactor
_child_index, _child_list, _clip_bounds, _constraint_flags, _enabled_constraint, _flags, _h, _h_constraint, _parent, _part_a_constraint, _part_b_constraint, _user_data, _visible_constraint, _w, _w_constraint, _x, _x_constraint, _y, _y_constraint, default_child_hint
 
Constructor Summary
oneline_text_edit(int xv, int yv, int wv, java.lang.String init_str, java.awt.Font fnt, boolean boxed)
          Full constructor with explicit width
oneline_text_edit(int xv, int yv, java.lang.String init_str)
          Constructor with default font and boxed status
oneline_text_edit(int xv, int yv, java.lang.String init_str, java.awt.Font fnt, boolean boxed)
          Full constructor where width is determined by initial string
oneline_text_edit(java.lang.String init_str)
          Constructor with default font and boxed status; we also assume you are going to set the x and y coordinate by other means.
 
Method Summary
 boolean action_char(event evt, char ch, java.lang.Object user_info)
          Accept input for a character that has been classified as a closure action (by returning CLOSURE_ACTION_CHAR from char_filter).
 int char_filter(int input_char, int modifiers)
          Pre-filter a character before providing it is actually provided as input.
 int char_pos_of(int xpos)
          Map an x position in local coordinates into a text string position.
 void delete_a_char()
          Delete the character before the current selection (backing the selection up one character).
 boolean delete_char(event evt, java.lang.Object user_info)
          Accept input for a character signifying a delete.
 boolean drag_end(event evt, java.lang.Object user_info)
          Accept input corresponding to the end of a drag.
 boolean drag_feedback(event evt, java.lang.Object user_info)
          Accept a movement during a drag.
 boolean drag_start(event evt, java.lang.Object user_info)
          Accept the start of a drag to the object.
 boolean end_text_entry(event evt, java.lang.Object user_info)
          Dispatch input indicating that text input is over (e.g.
 boolean line_kill(event evt, java.lang.Object user_info)
          Accept input for a character signifying a line kill.
 boolean new_char(event evt, char ch, java.lang.Object user_info)
          Accept input for a single character.
 boolean press(event evt, java.lang.Object user_info)
          Accept mouse button press input to the object.
 boolean release(event evt, java.lang.Object user_info)
          Companion method to press() needed to finish pressable.
 void replace_selection(java.lang.String with_str)
          Replace the area of the current selection with the given string.
 boolean special_key(event evt, int key_code, java.lang.Object user_info)
          Accept input for a key press signifying a special key (corresponding to KEY_ACTION events).
 boolean start_text_entry(event evt, java.lang.Object user_info)
          Accept input that signifies that object is new text focus and will receive subsequent text input.
 
Methods inherited from class sub_arctic.lib.oneline_text_display
boxed, colors, draw_self_local, end_of_selection, ensure_inside, font, h_spacing, intrinsic_constraints, set_boxed, set_colors, set_font, set_h_spacing, set_selection, set_text, set_v_spacing, start_of_selection, text, v_spacing, x_adjust
 
Methods inherited from class sub_arctic.lib.base_interactor
active_constraints, add_child, add_user_datum, attach_dependent, bound, callback_obj, child_index, child, clear_child_list, clear_constraint_flag_bit, clear_flag_bit, configure, constraint_flag_is_set, constraint_flag_string, constraint_on, custom_fun1, custom_fun2, damage_fixed, damage_from_child, damage_self, damage_self, damage_self, damage_self, damage_self, detach_dependent, do_action, do_action, do_callback, do_callback, drag_feature_point, draw_children, draw_self, enabled_constraint, enabled, enter_local_coordinates, eval_enabled, eval_h, eval_part_a, eval_part_b, eval_visible, eval_w, eval_x, eval_y, eval, exit_local_coords, feature_point_enabled, feature_point, filter_pt, find_child, first_callback_num, fixed_children, flag_is_set, flag_string, focus_set_enter, focus_set_exit, get_awt_component, get_external_constraint, get_part, get_top_level, get_value, global_to_local, global_to_local, h_constraint, h, handle_cycle, inform_ood, insert_child, inside_bounds, into_local, into_local, into_parent, into_parent, is_constrained, last_callback_num, local_to_global, local_to_global, mark_all_ood, mark_enabled_ood, mark_h_ood, mark_ood, mark_part_a_ood, mark_part_b_ood, mark_reparented_ood, mark_visible_ood, mark_w_ood, mark_x_ood, mark_y_ood, marked_ood, move_child_downward, move_child_downward, move_child_to_bottom, move_child_to_bottom, move_child_to_top, move_child_to_top, move_child_upward, move_child_upward, move_downward, move_to_bottom, move_to_top, move_upward, new_look_configure, next_sibling, num_actions, num_children, num_feature_points, ood_inform_all, parent, part_a_constraint, part_a, part_b_constraint, part_b, pick_within_children, pick, picked_by, pos, prev_sibling, register_resource_names, remove_child, remove_child, remove_user_datum, restyle_look_resources, restyle, set_callback_obj, set_child_index, set_child, set_constraint_flag_bit, set_constraint_flag_bit, set_constraint, set_constraint, set_enabled_constraint, set_enabled_constraint, set_enabled_constraint, set_enabled, set_flag_bit, set_flag_bit, set_h_constraint, set_h_constraint, set_h_constraint, set_h, set_intrinsic_h, set_intrinsic_size, set_intrinsic_w, set_parent, set_part_a_constraint, set_part_a_constraint, set_part_a_constraint, set_part_a, set_part_b_constraint, set_part_b_constraint, set_part_b_constraint, set_part_b, set_pos, set_pos, set_raw_enabled, set_raw_h, set_raw_part_a, set_raw_part_b, set_raw_visible, set_raw_w, set_raw_x, set_raw_y, set_size, set_style_lock, set_user_info, set_visible_constraint, set_visible_constraint, set_visible_constraint, set_visible, set_w_constraint, set_w_constraint, set_w_constraint, set_w, set_x_constraint, set_x_constraint, set_x_constraint, set_x, set_y_constraint, set_y_constraint, set_y_constraint, set_y, setup_for_children, setup_for_children, setup_for_fixed_children, size, style_change_local, style_change, supports_children, tag_str, toString, traverse_and_collect_children, traverse_and_collect_parent, traverse_and_collect, trivial_reject, trivial_reject, user_data, user_info, value_ood, visible_constraint, visible, w_constraint, w, x_constraint, x_into_local, x_into_parent, x, y_constraint, y_into_local, y_into_parent, y
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

oneline_text_edit

public oneline_text_edit(int xv,
                         int yv,
                         int wv,
                         java.lang.String init_str,
                         java.awt.Font fnt,
                         boolean boxed)
Full constructor with explicit width
Parameters:
int - xv x coordinate of this interactor.
int - yv y coordinate of this interactor.
int - wv width of this interactor.
String - init_str the initial string.
Font - fnt the font to use for this interactor.
boolean - boxed true if you want this interactor to have a box around it.

oneline_text_edit

public oneline_text_edit(int xv,
                         int yv,
                         java.lang.String init_str,
                         java.awt.Font fnt,
                         boolean boxed)
Full constructor where width is determined by initial string
Parameters:
int - xv x coordinate of this interactor.
int - yv y coordinate of this interactor.
String - init_str the initial string.
Font - fnt the font to use for this interactor.
boolean - boxed true if you want this interactor to have a box around it.

oneline_text_edit

public oneline_text_edit(int xv,
                         int yv,
                         java.lang.String init_str)
Constructor with default font and boxed status
Parameters:
int - xv x coordinate of this interactor.
int - yv y coordinate of this interactor.
String - init_str the initial string.
Font - fnt the font to use for this interactor.
boolean - boxed true if you want this interactor to have a box around it.

oneline_text_edit

public oneline_text_edit(java.lang.String init_str)
Constructor with default font and boxed status; we also assume you are going to set the x and y coordinate by other means.
Parameters:
int - xv x coordinate of this interactor.
int - yv y coordinate of this interactor.
String - init_str the initial string.
Font - fnt the font to use for this interactor.
boolean - boxed true if you want this interactor to have a box around it.
Method Detail

replace_selection

public void replace_selection(java.lang.String with_str)
Replace the area of the current selection with the given string. The selection is set to a single point after the new text. Since the the replacement string can be empty, this can be used to delete the selection.
Parameters:
String - with_str the string to replace with.

delete_a_char

public void delete_a_char()
Delete the character before the current selection (backing the selection up one character). If there is no selection or the selection starts at the beginning of the string, nothing happens.

char_pos_of

public int char_pos_of(int xpos)
Map an x position in local coordinates into a text string position.
Parameters:
int - xpos the x position to transform (in pixels).
Returns:
int the position of the point in the string (in characters)

start_text_entry

public boolean start_text_entry(event evt,
                                java.lang.Object user_info)
Accept input that signifies that object is new text focus and will receive subsequent text input. Returns true if the object accepts the focus.
Specified by:
start_text_entry in interface text_acceptor
Parameters:
event - evt the start of the text entry event.
Object - user_info the object passed to the agent when we went into the focus set.
Returns:
boolean true if we consumed the event, which we always do.

char_filter

public int char_filter(int input_char,
                       int modifiers)
Pre-filter a character before providing it is actually provided as input. This routine gets called to allow the object to modify the character before it is passed to new_char(). Input to the method is the ordinal value of the input character in question along with the modifier mask associated with it. Output should either be the ordinal value of a character or a specific negative value signifying one of several special actions.

This routine can be used by subclasses to do a translation (e.g. to all lower case) or to filter out unwanted characters (e.g. everything except decimal digits). Filtering is done by returning the special value DISCARD_CHAR (= -1), which signifies that the character is not to be passed to new_char(). Translation is done by returning the ordinal value of the translated character. In addition, the value CLOSURE_ACTION_CHAR can be returned to indicate that the action_char() method should be invoked instead of new_char(). This is typically done for end of line characters that signify completion of an entry. All modifications to the character are considered local to this object and do not change how the character might be delivered to another object.

This routine is not called for cursor movement or other special keys (which are dispatched with special_key()), or characters classified as edit keys (e.g. to delete a character or line). The text input dispatch agent class (text_agent) provides several standard filters that can be called for common operations.

Specified by:
char_filter in interface text_acceptor
Parameters:
int - input_char the char that was hit.
int - modifiers state of the modifier keys.
Returns:
int the character to insert or a special value (DISCARD_CHAR or CLOSURE_ACTION_CHAR).

new_char

public boolean new_char(event evt,
                        char ch,
                        java.lang.Object user_info)
Accept input for a single character. Returns true if the object consumes the character.
Specified by:
new_char in interface text_acceptor
Parameters:
event - evt the input event (normally a keypress) .
Object - user_info the object passed to the agent when this object entered the focus set.

action_char

public boolean action_char(event evt,
                           char ch,
                           java.lang.Object user_info)
Accept input for a character that has been classified as a closure action (by returning CLOSURE_ACTION_CHAR from char_filter). Returns true if the object consumes the character.
Specified by:
action_char in interface text_acceptor
Parameters:
event - evt the input event (normally a keypress).
char - ch the action character in question.
Object - user_info the object passed to the agent when this object entered the focus set.

delete_char

public boolean delete_char(event evt,
                           java.lang.Object user_info)
Accept input for a character signifying a delete. Returns true if the object consumes the input.
Specified by:
delete_char in interface text_acceptor
Parameters:
event - evt the input event (normally a keypress).
Object - user_info the object passed to the agent when this object entered the focus set.

line_kill

public boolean line_kill(event evt,
                         java.lang.Object user_info)
Accept input for a character signifying a line kill. Returns true if the object consumes the input. Currently a ^U ('\025') is treated as a line kill. This behavior can be changed via the text input dispatch agent. (Unfortunately, AWT does not currently provide a way to determine the user's edit character preferences, so this is the best we can do.)
Specified by:
line_kill in interface text_acceptor
Parameters:
event - evt the input event (normally a keypress).
Object - user_info the object passed to the agent when this object entered the focus set.

special_key

public boolean special_key(event evt,
                           int key_code,
                           java.lang.Object user_info)
Accept input for a key press signifying a special key (corresponding to KEY_ACTION events). Values passed here are from the key field of the events. These include: DOWN, END, F1, ..., F12, HOME, LEFT, PGDN, PGUP, RIGHT, and UP. Returns true if the object consumes the event.
Specified by:
special_key in interface text_acceptor
Parameters:
event - evt the input event (normally a key_action event).
int - key_code the special key in question.
Object - user_info the object passed to the agent when this object entered the focus set.

end_text_entry

public boolean end_text_entry(event evt,
                              java.lang.Object user_info)
Dispatch input indicating that text input is over (e.g. the text focus has moved elsewhere. Returns true if the object consumes the input.
Specified by:
end_text_entry in interface text_acceptor
Parameters:
event - evt the input event.
Object - user_info the object passed to the agent when this object entered the focus set.

press

public boolean press(event evt,
                     java.lang.Object user_info)
Accept mouse button press input to the object. Return true is event was consumed.
Specified by:
press in interface pressable
Parameters:
event - evt the input event.
Object - user_info the object passed to the agent when this object entered the focus set.

release

public boolean release(event evt,
                       java.lang.Object user_info)
Companion method to press() needed to finish pressable. Here we never consume the event.
Specified by:
release in interface pressable
Parameters:
event - evt the input event.
Object - user_info the object passed to the agent when this object entered the focus set.

drag_start

public boolean drag_start(event evt,
                          java.lang.Object user_info)
Accept the start of a drag to the object.
Specified by:
drag_start in interface simple_draggable
Parameters:
event - evt the input event.
Object - user_info the object passed to the agent when this object entered the focus set.

drag_feedback

public boolean drag_feedback(event evt,
                             java.lang.Object user_info)
Accept a movement during a drag.
Specified by:
drag_feedback in interface simple_draggable
Parameters:
event - evt the input event.
Object - user_info the object passed to the agent when this object entered the focus set.

drag_end

public boolean drag_end(event evt,
                        java.lang.Object user_info)
Accept input corresponding to the end of a drag.
Specified by:
drag_end in interface simple_draggable
Parameters:
event - evt the input event.
Object - user_info the object passed to the agent when this object entered the focus set.