sub_arctic.lib
Class press_label

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

public class press_label
extends label
implements pressable, does_callback

This is just a little object which makes labels have a callback and keep track of their state. Its useful in things like menus and what not when someone else needs to stay informed of state changes. This object sends a callback to its callback object with a boolean as the info indicating its new state.

This object allows its width to be anything the parent (or anyone else) wishes (unlike more traditional labels).


Field Summary
protected  boolean _active
          Keep track of the active state.
protected  callback_object _callback_obj
          The object to whom we are sending our callback.
static int LABEL_ACTION_CALLBACK
          Callback number constant for callbeack when we are pressed.
 
Fields inherited from class sub_arctic.lib.label
_above_spacing, _autosize, _below_spacing, _draw_colors, _opaque
 
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
press_label(java.lang.String s, java.awt.Font f, boolean opacity, callback_object obj)
          Construct a new press_label.
 
Method Summary
 boolean active()
          Return whether the object is active or not.
 callback_object callback_obj()
          Access the current callback object.
 int first_callback_num()
          First valid callback number
 int intrinsic_constraints()
          Fake out our superclass with a new implementation of intrinsic constraints which returns only a height constraint.
 void invert_active()
          Make the active state the opposite of what it is now.
 int last_callback_num()
          Last valid callback number
 boolean press(event evt, java.lang.Object user_info)
          Respond to the press method from the agent.
 boolean release(event evt, java.lang.Object user_info)
          Respond to the release method from the agent.
 void set_active(boolean b)
          Set the active state to either true or false.
 void set_callback_obj(callback_object cb_obj)
          Set the object we are making callbacks to.
 int string_width()
          Respond to questions about how wide our string is.
 
Methods inherited from class sub_arctic.lib.label
above_spacing, autosize, below_spacing, calculate_size, draw_colors, draw_self_local, natural_size, opaque, set_above_spacing, set_autosize, set_below_spacing, set_draw_colors, set_font, set_intrinsic_h, set_opaque, set_text
 
Methods inherited from class sub_arctic.lib.oneline_text_display
boxed, colors, end_of_selection, ensure_inside, font, h_spacing, set_boxed, set_colors, set_h_spacing, set_selection, 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, 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, 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, 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_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_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
 

Field Detail

_active

protected boolean _active
Keep track of the active state.

_callback_obj

protected callback_object _callback_obj
The object to whom we are sending our callback.

LABEL_ACTION_CALLBACK

public static final int LABEL_ACTION_CALLBACK
Callback number constant for callbeack when we are pressed.
Constructor Detail

press_label

public press_label(java.lang.String s,
                   java.awt.Font f,
                   boolean opacity,
                   callback_object obj)
Construct a new press_label.
Parameters:
String - s the string to display in the label.
boolean - opacity true if the object should be opaque (paint its background).
callback_object - obj the object to send the callback's to.
Method Detail

active

public boolean active()
Return whether the object is active or not.
Returns:
int true if the object is active

invert_active

public void invert_active()
Make the active state the opposite of what it is now.

set_active

public void set_active(boolean b)
Set the active state to either true or false.
Parameters:
boolean - b the new active state

callback_obj

public callback_object callback_obj()
Access the current callback object.
Specified by:
callback_obj in interface does_callback
Returns:
callback_object the object to whom we are sending callbacks.
Overrides:
callback_obj in class base_interactor

set_callback_obj

public void set_callback_obj(callback_object cb_obj)
Set the object we are making callbacks to.
Specified by:
set_callback_obj in interface does_callback
Parameters:
callback_obj - cb_obj the object we will make callbacks to.
Overrides:
set_callback_obj in class base_interactor

first_callback_num

public int first_callback_num()
First valid callback number
Specified by:
first_callback_num in interface does_callback
Overrides:
first_callback_num in class base_interactor

last_callback_num

public int last_callback_num()
Last valid callback number
Specified by:
last_callback_num in interface does_callback
Overrides:
last_callback_num in class base_interactor

press

public boolean press(event evt,
                     java.lang.Object user_info)
Respond to the press method from the agent. This object generates its callback on the press not on a matched pair of press and release.
Specified by:
press in interface pressable
Parameters:
event - evt the press event (usually mouse down).
Object - user_info the object passed the pick_collector at pick-time.
Returns:
boolean true if we consumed the event

release

public boolean release(event evt,
                       java.lang.Object user_info)
Respond to the release method from the agent.
Specified by:
release in interface pressable
Parameters:
event - evt the press event (usually mouse up).
Object - user_info the object passed the pick_collector at pick-time.
Returns:
boolean true if we consumed the event

string_width

public int string_width()
Respond to questions about how wide our string is.
Returns:
int the number of pixels wide the string is (plus twice the horizontal spacing to take into account the borders on left and right).

intrinsic_constraints

public int intrinsic_constraints()
Fake out our superclass with a new implementation of intrinsic constraints which returns only a height constraint. We don't have a intrinsic width because we are going to be flexible about putting ourselves in any width requested by the parent.
Returns:
int the constant for an intrinsic constraint on width
Overrides:
intrinsic_constraints in class label