sub_arctic.lib
Class text_edit

java.lang.Object
  |
  +--sub_arctic.lib.min_interactor
        |
        +--sub_arctic.lib.base_interactor
              |
              +--sub_arctic.lib.text_display
                    |
                    +--sub_arctic.lib.text_edit

public class text_edit
extends text_display
implements text_acceptor, pressable, simple_draggable

Multi-line (but single font) text edit area. This class allows simple entry and editing of multiple lines of text.


Fields inherited from class sub_arctic.lib.text_display
_first_line, _font, _h_spacing, _metric, _selection_end_line, _selection_end_pos, _selection_start_line, _selection_start_pos, _text, _v_spacing, BOXED, NO_SELECTION, SELECT_END, xpos, ypos, ypos_cutoff
 
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
text_edit(int xv, int yv, int wv, int hv, java.lang.String contents, java.awt.Font fnt, boolean boxed)
          Full constructor with explicit size.
text_edit(int xv, int yv, java.lang.String contents)
          Constructor with computed size, default font, and default boxed status.
text_edit(int xv, int yv, java.lang.String contents, java.awt.Font fnt, boolean boxed)
          Full constructor with size determined by initial text.
 
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 on_ln, int x_pos)
          Map an x position in local coordinates into a text string position (index) on a given line.
 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.
 int find_line_of(int y_pos)
          Map y position in local coordinates into a line number.
 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.text_display
boxed, break_into_lines, draw_highlighted_lines, draw_norm_lines, draw_self_local, draw_split_line, dump_text, first_line, first_line, font, get_string, h_spacing, intrinsic_constraints, part_a, selection_end_line, selection_end_pos, selection_start_line, selection_start_pos, set_boxed, set_font, set_h_spacing, set_part_a, set_raw_part_a, set_selection, set_text, set_text, set_v_spacing, size_by_content, text, v_spacing
 
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_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_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_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

text_edit

public text_edit(int xv,
                 int yv,
                 int wv,
                 int hv,
                 java.lang.String contents,
                 java.awt.Font fnt,
                 boolean boxed)
Full constructor with explicit size. Text contents is provided by one string with lines separated by newlines or carriage returns.
Parameters:
int - xv the x position of the object.
int - yv the y position of the object.
int - wv the width of the object.
int - hv the height of the object.
String - contents the string to put into the editing area.
boolean - boxed true if this object should have a box around it.

text_edit

public text_edit(int xv,
                 int yv,
                 java.lang.String contents,
                 java.awt.Font fnt,
                 boolean boxed)
Full constructor with size determined by initial text. Text contents is provided by one string with lines separated by newlines or carriage returns.
Parameters:
int - xv the x position of the object.
int - yv the y position of the object.
String - contents the string to put into the editing area.
boolean - boxed true if this object should have a box around it.

text_edit

public text_edit(int xv,
                 int yv,
                 java.lang.String contents)
Constructor with computed size, default font, and default boxed status.
Parameters:
int - xv the x position of the object.
int - yv the y position of the object.
String - contents the string to put into the editing area.
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 new string to put where the selection is now.

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 on_ln,
                       int x_pos)
Map an x position in local coordinates into a text string position (index) on a given line.
Parameters:
int - on_ln the line to be checking.
int - x_pos the x coordinate to check (in pixels).
Returns:
int the character number

find_line_of

public int find_line_of(int y_pos)
Map y position in local coordinates into a line number. If the position is before the first line (index 0) then -1 is returned. If the position is past the last line, then one greater than the index of the last line is returned.
Parameters:
int - y_pos the y position (in pixels) to map to a line number.
Returns:
int a line number, -1, or 1+ the last line number.

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 event to be dispatched.
Object - user_info the object provided to the agent when this interactor entered the focus set.
Returns:
boolean true if this event was handled (which it always is in this case).

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 input character to be filtered.
int - modifiers the current state of the modifier keys.
Returns:
int the filtered value to enter into the object 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 event to be dispatched.
char - ch the character to be entered.
Object - user_info the object provided to the agent when this interactor entered the focus set.
Returns:
boolean true if this event was handled (which it always is in this case).

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).
Specified by:
action_char in interface text_acceptor
Parameters:
event - evt the event to be dispatched.
Object - user_info the object provided to the agent when this interactor entered the focus set.
Returns:
boolean true if this event was handled (which it always is in this case).

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 event to be dispatched.
Object - user_info the object provided to the agent when this interactor entered the focus set.
Returns:
boolean true if this event was handled (which it always is in this case).

line_kill

public boolean line_kill(event evt,
                         java.lang.Object user_info)
Accept input for a character signifying a line kill. Here we treat this the same as a delete of the current selection.
Specified by:
line_kill in interface text_acceptor
Parameters:
event - evt the event to be dispatched.
Object - user_info the object provided to the agent when this interactor entered the focus set.
Returns:
boolean true if this event was handled (which it always is in this case).

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 event to be dispatched.
int - key_code the keyboard code of this special key.
Object - user_info the object provided to the agent when this interactor entered the focus set.
Returns:
boolean true if this event was handled (which it always is in this case).

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 event to be dispatched.
Object - user_info the object provided to the agent when this interactor entered the focus set.
Returns:
boolean true if this event was handled (which it always is in this case).

press

public boolean press(event evt,
                     java.lang.Object user_info)
Accept mouse button press input to the object. Return true if event was consumed.
Specified by:
press in interface pressable
Parameters:
event - evt the event to be dispatched.
Object - user_info the object provided to pick when this object was clicked on.
Returns:
boolean true if this event was handled.

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 event to be dispatched.
Object - user_info the object provided to pick when this object was clicked on.
Returns:
boolean true if this event was handled (it is never handled by this object)

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 event to be dispatched.
Object - user_info the object provided to the agent when this interactor entered the focus set.
Returns:
boolean true if this event was handled (which it always is in this case).

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 event to be dispatched.
Object - user_info the object provided to the agent when this interactor entered the focus set.
Returns:
boolean true if this event was handled (which it always is in this case).

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 event to be dispatched.
Object - user_info the object provided to the agent when this interactor entered the focus set.
Returns:
boolean true if this event was handled (which it always is in this case).