sub_arctic.new_lib
Class button

java.lang.Object
  |
  +--sub_arctic.lib.min_interactor
        |
        +--sub_arctic.lib.base_interactor
              |
              +--sub_arctic.new_lib.multi_button
                    |
                    +--sub_arctic.new_lib.button

public class button
extends multi_button
implements inout_draggable, pressable, composer_consts

This class implements a button in the current style. By default, buttons are not resizable, they have an intrinsic size. You can use the method set_autosize(false) if you desire the button to be resizable to any size.


Field Summary
protected  boolean _autosize
          This is the storage for the autosize variable.
protected  int _natural_height
          The natural height of a button.
protected  int _natural_width
          The natural width of a button.
protected  loaded_image _picture
          Icon associated with this button (or null if this is not an iconic button).
protected static boolean _registration_done
          Flag to arrange to execute register_resource_names() at most once.
protected  java.lang.String _text
          The text associated with the label of this button (or null if this is not a labelled button).
 
Fields inherited from class sub_arctic.new_lib.multi_button
_callback_obj, _cur_state, _in_transition, _state_looks, _transition_looks, BUTTON_ACTION_CALLBACK
 
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
button(int x, int y, loaded_image[] look, callback_object call_obj)
          Full constructor based on non-style supplied images.
button(int x, int y, loaded_image img, callback_object call_obj)
          Constructor based on a loaded_image for use as an icon within a button.
button(int x, int y, java.lang.String label, callback_object call_obj)
          Constructor based on a textual label.
button(loaded_image[] look, callback_object call_obj)
          Constructor based on non-style supplied images and a default position (presumably the object will be positioned with constraints).
button(loaded_image img, callback_object call_obj)
          Constructor based on a loaded_image for use as an icon within a button and assuming a default position (presumably this object will be positioned with constraints).
button(java.lang.String label, callback_object call_obj)
          Constructor based on a textual label and default position (presumably the object will be positioned with constraints).
 
Method Summary
 boolean autosize()
          Retrieve the current state of autosize.
 void do_action(int action_num, event evt, java.lang.Object parm)
          Perform the (only) action associated with this interactor.
protected  void init_iconic_resources(loaded_image pic)
          Create new stylized images based on an icon and autosized status.
protected  void init_label_resources(java.lang.String label)
          Create new stylized images based on a label and autosized status.
 boolean inout_drag_end(event evt, boolean ended_inside, java.lang.Object user_info)
          We need to override the end behavior of the multi-button to make sure we always end up in the right state.
 int intrinsic_constraints()
          We override the intrinsic constraint function because sometimes we have intrinsic constraints (when autosize is on) and sometimes we don't.
 java.awt.Dimension natural_size()
          Return the natural size of a button.
 loaded_image picture()
          Icon associated with this button (or null if this is not an iconic button).
static void register_resource_names()
          Register the resource names associated with this class
 void set_autosize(boolean a)
          Set the current state of the autosize variable.
 void set_intrinsic_size(int wv, int hv)
          We have to override how set_intrinsic_size works here, because sometimes we have an intrinsic size and sometimes we don't.
 void set_picture(loaded_image p)
          Set the icon image that this button is built from.
 void set_raw_h(int h)
          Trap calls to set_raw_h() which will change the height.
 void set_raw_w(int w)
          Trap calls to set_raw_w() which will change the width.
 void set_text(java.lang.String l)
          Set the text associated with the label of this button.
 java.lang.String text()
          The text associated with the label of this button (or null if this is not a labelled button).
 
Methods inherited from class sub_arctic.new_lib.multi_button
calc_size, callback_obj, cur_state, do_callback, draw_self_local, find_current_style, first_callback_num, get_state_look, get_transition_look, inout_drag_enter, inout_drag_exit, inout_drag_start, last_callback_num, new_look_configure, next_state, part_a, press, release, restyle_look_resources, set_callback_obj, set_cur_state, set_looks, set_part_a, set_raw_part_a, set_state_look, set_transition_look, state_looks, transition_looks
 
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_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, 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, remove_child, remove_child, remove_user_datum, 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_h, 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_part_b, set_raw_visible, 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

_registration_done

protected static boolean _registration_done
Flag to arrange to execute register_resource_names() at most once.

_text

protected java.lang.String _text
The text associated with the label of this button (or null if this is not a labelled button).

_picture

protected loaded_image _picture
Icon associated with this button (or null if this is not an iconic button).

_autosize

protected boolean _autosize
This is the storage for the autosize variable.

_natural_width

protected int _natural_width
The natural width of a button. This is the width the button would be if autosize were true. If this is negative, we need to calculate a new natural size (this should only be a transient condition and never visible externally).

_natural_height

protected int _natural_height
The natural height of a button. This is the height the button would be if autosize were true.
Constructor Detail

button

public button(loaded_image[] look,
              callback_object call_obj)
Constructor based on non-style supplied images and a default position (presumably the object will be positioned with constraints). The image set given here must contain either one or two images. The one at index 0 will be used for normal appearance, and the one at index 1 (if any) will be used for highlight when the button is being "depressed".
Parameters:
loaded_image[] - look the two images to display for this button.
callback_object - call_obj the object to run the callbacks on.

button

public button(int x,
              int y,
              loaded_image[] look,
              callback_object call_obj)
Full constructor based on non-style supplied images. The image set given here must contain either one or two images. The one at index 0 will be used for normal appearance, and the one at index 1 (if any) will be used for highlight when the button is being "depressed".
Parameters:
int - x the x position of the interactor.
int - y the y position of the interactor.
loaded_image[] - look the two images to display for this button.
callback_object - call_obj the object to run the callbacks on.

button

public button(java.lang.String label,
              callback_object call_obj)
Constructor based on a textual label and default position (presumably the object will be positioned with constraints). Images will be constructed using the current from the style system.
Parameters:
String - label the text to draw on the button.
callback_object - call_obj the callback object.

button

public button(int x,
              int y,
              java.lang.String label,
              callback_object call_obj)
Constructor based on a textual label. Images will be constructed using the current from the style system.
Parameters:
int - x the x position of the interactor.
int - y the y position of the interactor.
String - label the text to draw on the button.
callback_object - call_obj the callback object.

button

public button(loaded_image img,
              callback_object call_obj)
Constructor based on a loaded_image for use as an icon within a button and assuming a default position (presumably this object will be positioned with constraints). The complete buttom images are constructed using the current style from the style system.
Parameters:
loaded_image - img the image to draw on the button
callback_object - call_obj the callback object.

button

public button(int x,
              int y,
              loaded_image img,
              callback_object call_obj)
Constructor based on a loaded_image for use as an icon within a button. The complete buttom images are constructed using the current style from the style system.
Parameters:
int - x the x position of the interactor.
int - y the y position of the interactor.
loaded_image - img the image to draw on the button
callback_object - call_obj the callback object.
Method Detail

register_resource_names

public static void register_resource_names()
Register the resource names associated with this class

init_label_resources

protected void init_label_resources(java.lang.String label)
Create new stylized images based on a label and autosized status. If there are already existing look images which were created by the style system, we will try to reuse the style that they were created with for these new images. If not, we use the current style from the style system.
Parameters:
String - label label string to create button images from.

init_iconic_resources

protected void init_iconic_resources(loaded_image pic)
Create new stylized images based on an icon and autosized status. If there are already existing look images which were created by the style system, we will try to reuse the style that they were created with for these new images. If not, we use the current style from the style system.
Parameters:
loaded_image - pic user supplied icon to create button images from

do_action

public void do_action(int action_num,
                      event evt,
                      java.lang.Object parm)
Perform the (only) action associated with this interactor. For this interactor, we just invoke the callback.
Parameters:
int - action_num which action type this is (the interpretation of this value is subclass dependent. 0 is always interpreted as the primary or default action of this interactor.
event - evt the event which "caused" the action.
Object - parm additional information to serve as a parameter to the action (the exact type of this information is determined by the subclass).
Overrides:
do_action in class multi_button
See Also:
multi_button.do_callback(sub_arctic.input.event)

text

public java.lang.String text()
The text associated with the label of this button (or null if this is not a labelled button).
Returns:
String the current text string of the button (or null)

set_text

public void set_text(java.lang.String l)
Set the text associated with the label of this button. This has the effect of turning the button into a labelled button (even if it wasn't one before). If possible the same style used to previously construct the button will be used. If no current style for the button can be found (for example, if non-style produced images had previously been provided for the look of this button) then the current style from the style system will be used.
Parameters:
String - l the new label

picture

public loaded_image picture()
Icon associated with this button (or null if this is not an iconic button).
Returns:
loaded_image the icon image this button is built from or null if this is not an iconic image.

set_picture

public void set_picture(loaded_image p)
Set the icon image that this button is built from. This has the effect of turning this button into an iconic button (even if it wasn't one before). If possible the same style used to previously construct the button will be used. If no current style for the button can be found (for example, if non-style produced images had previously been provided for the look of this button) then the current style from the style system will be used.
Parameters:
loaded_image - p the new picture to put on this button.

inout_drag_end

public boolean inout_drag_end(event evt,
                              boolean ended_inside,
                              java.lang.Object user_info)
We need to override the end behavior of the multi-button to make sure we always end up in the right state.
Specified by:
inout_drag_end in interface inout_draggable
Parameters:
event - evt the event to be dispatched.
boolean - ended_inside true if the drag ended inside the object.
Object - user_info the object passed to the inout_drag agent when this object came into the focus set.
Returns:
boolean true if this event has been handled.
Overrides:
inout_drag_end in class multi_button

autosize

public boolean autosize()
Retrieve the current state of autosize.
Returns:
boolean true if the object is autosized (and thus not resizable)

set_autosize

public void set_autosize(boolean a)
Set the current state of the autosize variable. If you change the state from non-autosized (false) to autosized (true) the button will immediately autosize itself. If you change the state to non-autosized from autosized, no immediate redraw is requested and the object will continue at its current size unless that is changed.

intrinsic_constraints

public int intrinsic_constraints()
We override the intrinsic constraint function because sometimes we have intrinsic constraints (when autosize is on) and sometimes we don't.
Returns:
int a constant representing what (if any) our intrinsic constraints are.
Overrides:
intrinsic_constraints in class multi_button

natural_size

public java.awt.Dimension natural_size()
Return the natural size of a button. This is useful, for example, when you want to walk down a list (or more likely, column) of buttons and find out which of them has the largest natural size and then set all of them to that size.
Returns:
Dimension the size (in pixels) of this button at its natural size

set_intrinsic_size

public void set_intrinsic_size(int wv,
                               int hv)
We have to override how set_intrinsic_size works here, because sometimes we have an intrinsic size and sometimes we don't. Multi-button (our parent) calls this code to tell the button that it can't be resized, but we know that it can in some cases...
Parameters:
int - wv the intrinsic width value
int - hv the intrinsic height value
Overrides:
set_intrinsic_size in class base_interactor

set_raw_w

public void set_raw_w(int w)
Trap calls to set_raw_w() which will change the width. If we are not autosizing, we want to recalculate the images.
Parameters:
int - w the new width value
Overrides:
set_raw_w in class base_interactor

set_raw_h

public void set_raw_h(int h)
Trap calls to set_raw_h() which will change the height. If we are not autosizing, we want to recalculate the images.
Parameters:
int - h the new height value
Overrides:
set_raw_h in class base_interactor