<<<<<<<<<<<<<<<<<

motif_list(motif) Motif motif_list(motif)

NAME

motif_list - select items from a group of choices

DESCRIPTION

A List is a widget that allows a user to select one or more items from a group of choices.

For a more complete description of this Motif widget, consult "OSF/Motif Programmer's Reference."

SUPERCLASS

motif_primitive

INSTANCE VARIABLES

position is the position to be used for added an item to the list at a given position.

browse_action is executed when the select mouse button is pressed and released. If the resource automaticSelection is True , the action is executed when the button is pressed. For each subsequent item entered while the select button is held down, the action is executed when the pointer moves into the item.

default_action is executed when an item is double clicked.

extended_selection_action is executed when items are selected using the extended selection mode.

multiple_selection_action is executed when items are selected using the multiple selection mode.

single_selection_action is executed when items are selected using the single selection mode.

MESSAGES

If the list widget underlying the object has not yet been created when one of the messages that manipulates the widget's internal list is sent, a create! message is sent to the object. Be aware that all actions and some resources must be set before widget creation.

add_item: items adds items to the list at position. Position 1 is the first element. Position 0 is the end of the list.

add_item_unselected: items adds items to the list at position. Position 1 is the first element. Position 0 is the end of the list.

delete_item: items deletes the specified items from the list.

delete_all_items! deletes all the items in the list. This is the most efficient and preferred way to delete all items in a list. This message does the following:

1) Gets the current list 2) Unmanages the list 3) Frees all members of the list 4) Sets the itemCount to 0. 5) Manages the list

WARNING: If you set itemCount to 0 in your script, you will delete the items, but the strings will not be freed.

delete_position: positions deletes items from the list at specified positions.

deselect_all_items! unhighlights and removes all items from the selected list.

deselect_item: items unhighlights and removes the specified items from the list.

deselect_position: positions unhighlights and removes the items at the specified positions from the list.

items? returns as strings the items in the list. The number of items is the value of the items resource.

keyboard_iten_to_position? returns the item position of the item that the cursor is in.

keyboard_iten_to_position! moves the cursor to the item at position.

position_bounds? returns the bounding box (x, y, width, height) of the item at the current position.

position_selected? returns 1 if the current position is selected.

Otherwise returns 0, for false.

replace_items_unselected: old_value new_value takes value pairs and replaces the first value from each pair with the second value, unselecting any selected item.

replace_items: old_value new_value takes value pairs and replaces the first value from each pair with the second value.

replace_items_position_unselected: values replaces items in the list starting at position with the given new values.

replace_positions: position new_value takes position/value pairs and replaces the values at the respective positions.

select_item: items highlights and adds the specified items to the list. It invokes the selection action for the current mode.

select_position: positions highlights and adds the items at the specified positions to the list. It invokes the selection action for the current mode.

selected_items? returns as strings the selected items in the list. The number of items is the value of the selectedItems resource.

set_bottom_item: items makes the items last visible item in the list.

set_bottom_position: position makes the items at the given positions the last visible items in the list.

set_horizontal_position: position sets the value resource of the ScrollBar to the visible portion of the list. This is equivalent to moving the ScrollBar to the specified position.

set_top_item: items makes the specified existing items the first visible in the list.

set_top_position: positions makes the items at the specified positions the first visible in the list.

update_selected_list! updates the XmNselectedItems resource.

y_to_position: y updates position to the item at the given y coordinate.

notify_on! Allows select_position and select_item to invoke the selection callback.

notify_off! Stops select_position and select_item from invoking the selection callback.

@ resource selects resource for a subsequent set or query.

: value sets the current resource to value. Since most resources have mixed case, you should enclose any resource name in quotes. Resource names are the Motif names with the XmN prefix removed. Some resources can only be set before the widget is created. For efficiency, set as many resources as you can before creation.

scalar_value? returns the value of the current resource whose type is integer.

string_value? returns the value of the current resource whose type is string.

pointer_value? returns the value of the current resource whose type is a pointer of any kind.

create! creates an instance of the widget. Any resources that have been specified prior to the create! will be set. An id? message also sends a create!.

on! realizes the widget. Realizing a widget creates its windows and displays it when it is managed.

EXAMPLE

/* Demonstrate a list */ /* In scripts/motif/list.scr */

<motifinit

<colors

motif application=`List Example';

motif_form new: aForm parent=motif; motif_pulldown_menu new: pulldown parent=aForm; motif_option_menu new: someOptions parent=aForm @ `labelString' : `List Operations' @ `subMenuId' : [pulldown id?] create! ; motif_list new: alist parent=aForm browse_selection_action=`browse' multiple_selection_action=`multiple' single_selection_action=`single' @ `topAttachment' : XmATTACH_WIDGET @ `topWidget' : [someOptions id?] @ `visibleItemCount' : 8 @ `selectionPolicy' : XmMULTIPLE_SELECT add_item: (`one', `two', `three', `four', `five', `six', `seven', `eight', `nine') create! ;

actions new: browse tick_actions=`!browse'; actions new: multiple tick_actions=`!multiple'; actions new: single tick_actions=`!single';

motif_push_button new: button1 parent=pulldown @ `labelString' : `three to top' activate_action=three_to_top create! ; actions new: three_to_top tick_actions+ `alist set_top_item:`three';' ; motif_push_button new: button2 parent=pulldown @ `labelString' : `seven to bottom' activate_action=seven_to_bottom create! ; actions new: seven_to_bottom tick_actions+ `alist set_bottom_item:`seven';' ; motif_push_button new: button3 parent=pulldown @ `labelString' : `add ten to end' activate_action=add_ten_to_end create! ;

actions new: add_ten_to_end tick_actions+ `alist add_item:`ten';' ; motif_push_button new: button4 parent=pulldown @ `labelString' : `add ten to start' activate_action=add_ten_to_start create! ; actions new: add_ten_to_start tick_actions+ `alist position=1 add_item:`ten' position=0;' ; motif_push_button new: button5 parent=pulldown @ `labelString' : `add ten to start (unselected)' activate_action=add_ten_to_start_unselected create! ; actions new: add_ten_to_start_unselected tick_actions+ `alist position=1 add_item_unselected:`ten' position=0;' ; motif_push_button new: button6 parent=pulldown @ `labelString' : `position 7 to top' activate_action=position_7_to_top create! ; actions new: position_7_to_top tick_actions+ `alist set_top_position : 7;' ; motif_push_button new: button7 parent=pulldown @ `labelString' : `position 1 to top' activate_action=position_1_to_top create! ; actions new: position_1_to_top tick_actions+ `alist set_top_position : 1;' ; motif_push_button new: button8 parent=pulldown @ `labelString' : `print items' activate_action=print_items create! ; actions new: print_items tick_actions+ `alist print: items;' ; motif_push_button new: button9 parent=pulldown @ `labelString' : `print selected items' activate_action=print_selected_items create! ;

actions new: print_selected_items tick_actions+ `alist print: selected_items;' ; motif_push_button new: button11 parent=pulldown @ `labelString' : `select ten' activate_action=print_select_ten create! ; actions new: print_select_ten tick_actions+ `alist select_item : `ten';' ; motif_push_button new: button12 parent=pulldown @ `labelString' : `delete selected items' activate_action=delete_selected_items create! ; actions new: delete_selected_items tick_actions+ `alist delete_item: [alist selected_items?];' ; motif_push_button new: button13 parent=pulldown @ `labelString' : `delete all items' activate_action=delete_all_items create! ; actions new: delete_all_items tick_actions+ `alist delete_all_items!;' ;

motif_push_button new: button14 parent=pulldown @ `labelString' : `replace six with thirty-three' activate_action=three_to_thirtythree create! ; actions new: three_to_thirtythree tick_actions+ `alist replace_items_unselected: (`six', `thirty-three');' ;

motif_push_button new: button15 parent=pulldown @ `labelString' : `replace 1st two items with 4 and 5' activate_action=replace_first_two create! ; actions new: replace_first_two tick_actions+ `alist position=1 replace_items_position_unselected: (`4', `5');' ;

motif_push_button new: button16 parent=pulldown @ `labelString' : `replace positions 3 and 5' activate_action=replace_positions create! ; actions new: replace_positions tick_actions+ `alist replace_positions: (3, `THREE', 5, `FIVE');' ;

motif_push_button new: button18 parent=pulldown @ `labelString' : `y (100) to pos' activate_action= y_to_pos create! ; actions new: y_to_pos tick_actions+ `alist print: position y_to_position: 100 print: position;' ;

motif_push_button new: button19 parent=pulldown @ `labelString' : ` keyboard to position 1' activate_action= k_to_pos create! ; actions new: k_to_pos tick_actions+ `!keyboard to position 1' tick_actions+ `alist position= 1 keyboard_item_to_position! print: keyboard_item_position ;' ;

motif_separator new: aseparator parent=pulldown create! ; motif_push_button new: button10 parent=pulldown @ `labelString' : `Exit Application' activate_action=exit create! ; actions new: exit tick_actions+ `parser exit!;'; ; motif on! start!;

SEE ALSO

motif, motif_primitive


Please send comments and suggestions to
consult@rpi.edu