sub_arctic.lib
Class button

java.lang.Object
  |
  +--sub_arctic.lib.min_interactor
        |
        +--sub_arctic.lib.base_interactor
              |
              +--sub_arctic.lib.multi_button
                    |
                    +--sub_arctic.lib.button
Direct Known Subclasses:
FadingButton

public class button
extends multi_button
implements inout_draggable, pressable

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  java.awt.Font _font
          Keep a hold the font for textual gables used by this object.
protected  loaded_image _picture
          Store the picture (if any) we want on this button.
protected  java.lang.String _text
          This variable holds the text we are about to render onto this button.
protected  int _x_border
          Border around text horizontally
protected  int _y_border
          Border around text vertically
 
Fields inherited from class sub_arctic.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.
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 where we expect you to position the object with constraints.
button(loaded_image img, callback_object call_obj)
          Constructor based on a loaded_image and we assume you will use constraints to position it.
button(java.lang.String label, callback_object call_obj)
          Constructor based on a textual label and we assume you will use constraints to position it.
 
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.
 void draw_label(loaded_image[] img)
          Draw either the text or the image of the object on the button.
 java.awt.Font font()
          Retrieve this object's font.
 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()
          This function computes the natural size of a button.
 loaded_image picture()
          Return the picture we are using for this button.
 void set_autosize(boolean a)
          Set the current state of the autosize variable.
 void set_font(java.awt.Font f)
          Set the font for this object.
 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 current image to display on this button.
 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 this button to display a string.
 void set_x_border(int x)
          Set the horizontal border.
 void set_y_border(int y)
          Set the vertical border.
 void style_changed()
          This function gets called to generate the images for this button based on the current style parameters.
 java.lang.String text()
          Get the text of this button.
 int x_border()
          Retrieve the horizontal border
 int y_border()
          Retrieve the vertical border
 
Methods inherited from class sub_arctic.lib.multi_button
calc_size, callback_obj, cur_state, do_callback, draw_self_local, first_callback_num, get_state_look, get_transition_look, inout_drag_enter, inout_drag_exit, inout_drag_start, last_callback_num, next_state, part_a, press, release, 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, 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_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

_x_border

protected int _x_border
Border around text horizontally

_y_border

protected int _y_border
Border around text vertically

_font

protected java.awt.Font _font
Keep a hold the font for textual gables used by this object.

_text

protected java.lang.String _text
This variable holds the text we are about to render onto this button. Note that this is not consulted once we have rendered the image the first time.

_picture

protected loaded_image _picture
Store the picture (if any) we want on this button.

_autosize

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

button

public button(loaded_image[] look,
              callback_object call_obj)
Constructor where we expect you to position the object 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. 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(int x,
              int y,
              java.lang.String label,
              callback_object call_obj)
Constructor based on a textual label. Images will be constructed using 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 and we assume you will use constraints to position it. We build the button via the style system.
Parameters:
loaded_image - img the image to draw on the button
callback_object - call_obj the callback object.

button

public button(java.lang.String label,
              callback_object call_obj)
Constructor based on a textual label and we assume you will use constraints to position it. We build the button via the style system.
Parameters:
String - label the text to draw on the button
callback_object - call_obj the callback object.
Method Detail

x_border

public int x_border()
Retrieve the horizontal border
Returns:
int the horizontal border

set_x_border

public void set_x_border(int x)
Set the horizontal border.
Parameters:
int - x new amount of horizontal border.

y_border

public int y_border()
Retrieve the vertical border
Returns:
int the vertical border

set_y_border

public void set_y_border(int y)
Set the vertical border.
Parameters:
int - y new amount of vertical border.

font

public java.awt.Font font()
Retrieve this object's font. If you haven't specified a font, you get the system default font.

set_font

public void set_font(java.awt.Font f)
Set the font for this object.
Parameters:
Font - f the new font to use on this object

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()
Get the text of this button. Note: This value might be null if you are currently displaying an image on this button. If you supplied two of your own images to make this button, both the value of text() and the value of picture() will be null, since you did not use the normal style interface to create your buttons.
Returns:
String the current text string of the button (or null)

set_text

public void set_text(java.lang.String l)
Set this button to display a string.
Parameters:
String - l the new label

picture

public loaded_image picture()
Return the picture we are using for this button. This might be null if we are currently displaying a string.
Returns:
loaded_image the image we are display on this button or null if no image has been supplied

set_picture

public void set_picture(loaded_image p)
Set the current image to display on this button. Note: that you should probably be using something on a transparent background if don't want this to interfere the style system.
Parameters:
loaded_image - p the new picture to put on this button.

style_changed

public void style_changed()
This function gets called to generate the images for this button based on the current style parameters.

draw_label

public void draw_label(loaded_image[] img)
Draw either the text or the image of the object on the button. This is here primarily to allow subclass writers to put the label somewhere other than in the middle. This is ONLY called we are not in autosize mode (since it only makes sense to put the label in one place in autosize mode).
Parameters:
loaded_image[] - img the base images to draw on

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()
This function computes the natural size of a button. This is useful 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