This class draws a listbox. It is based on the Lframe class so scrollbars are supported. This class
also supports the following additional attributes:
- :text - an Array of Strings or Symbols. Each item
in the Array appears on a separate line in the
listbox.
- :value - a Fixnum or Array of Fixnum where each
Fixnum is an index in the listbox :text attribute that is selected.
- :vertical_spacing - the number of
pixels to introduce between each line or item in the listbox. It allows you
to space the items out a little.
- :otype -
- :single - the default, a single item can be selected, selecting any item
automatically deselects all other items.
- :multiple - many items can be selected using the ctrl or shift keys.
- :extended - many items can be selected only when using the ctrl/shift key.
Without the ctrl/shift key, selecting an item will automatically deselect
all other items.
active_item,
active_item=,
add_item,
clear,
default_border,
del_item,
deselect,
each_index,
each_index_reverse,
each_item,
each_item_reverse,
get_item,
hscroll_position=,
include_objects,
ipadx,
is_selected?,
item_count,
nearest,
nitems,
on_down_key,
on_end_key,
on_home_key,
on_key_release,
on_left_key,
on_mouse_ldn,
on_mouse_rdn,
on_pagedown_key,
on_pageup_key,
on_right_key,
on_scroll,
on_up_key,
otype,
paint_focus,
paint_focus?,
paint_focus_remove,
paint_normal,
pixel_height,
pixel_height_total,
pixel_width,
pixel_width_total,
scroll_distance,
scroll_distance_alignment,
see,
select,
set_focus,
text=,
update_item,
valid_attribute?,
value,
value=,
vertical_spacing,
vertical_spacing=,
vscroll_position=,
Defines any needed instance variables.
Returns the symbol to use as the default border for this object. Returns
:sunken as the default.
Returns true because listboxes gets a focus, this is needed because the Lframe class does not paint a focus by default.
Paints the focus indicator. The focus for the listbox object underlines the
current or active item in the listbox.
This should undo or remove the focus painted by paint_focus.
Draws the listbox using the font and color of the listbox. Selected items
(in the :value attribute) are drawn using the fg_highlight and bg_highlight
colors.
The scrollbars use this value for determining the alignment when dragging
the scroller button. The default is the height of a single line of text for
vertical scrollbars and super for horizontal scrollbars. It keeps the top
line fully visible at all times.
The scrollbars use this value for determining the scrolling distance when
pushing one of the buttons in the scrollbar. The default is the height of a
single line of text for vertical scrollbars and super for horizontal
scrollbars.
Sets the horizontal scroll position. Scrolls the text in the listbox.
Allows you to scroll the text in the listbox left or right. The on_scroll event automatically calls this as
the horizontal scroller button is moved. This repaints the listbox to
reflect the change.
Sets the vertical scroll position. Scrolls the text in the listbox. Allows
you to scroll the text in the listbox up or down. The on_scroll event automatically calls this as
the vertical scroller button is moved. This repaints the listbox to reflect
the change.
Triggered whenever the scroller is moved in one of the scrollbars. Repaints
the listbox to reflect the new position when needed.
Selects the item in the list closed to the mouse when the left button is
clicked.
Remembers the item closest to the mouse when the right mouse button is
clicked so it can be used by any popup menus.
Makes sure the first item in the list is visible and is the active item.
Calls see(0) and sets the active_item
to 0.
Makes sure the last item in the list is visible and is the active item.
Calls see(-1) and sets the active_item
to -1.
Scrolls the listbox to the left scroll_distance pixels, ctrl-left scrolls
to first character. Ignored if there is no horizontal scrollbar.
Scroll the list to the right scroll_distance pixels, ctrl-right scrolls
so that the last character is visible. Ignored if there is no horizontal
scrollbar.
Up moves the active item or focus indicator up one line, shift-up scrolls
up one page and moves the focus indicator, ctrl-up scrolls up to and moves
the focus indicator to the first item in the list.
Down moves the active item or focus indicator down one line, shift-up
scrolls down one page and moves the focus indicator, ctrl-up scrolls down
such that the last item in the list is visible and moves the focus
indicator to the last item in the listbox.
The spacebar toggles selecting/deselecting the active item or focus
indicator (where the cursor is).
Changes the text in the listbox. This updates the scrollbars and clears
selected items (:value attribute). Also repaints the listbox.
Returns the :otype attribute. The default is :single if the :otype
attribute has not been specified.
Yields each selected item in the listbox. Calls yield(item, idx).
Yields each selected item in reverse order. See each_item for more details.
Iterates over each selected value. Yields the index of each selected value
(indexes in the :value attribute) in the listbox.
Iterates over each selected value in reverse order. Yields the index of
each selected value (indexes in the :value attribute) in the listbox.
Returns the :value attribute. When otype == :single, this returns a single
Fixnum of the selected item. When otype == :multiple or :extended, this
returns an array of Fixnums. Returns nil if there are no selected items.
Sets the value attribute, highlights the values.
- new_value - can be a integer (index of the selected item) or an Array of values (Array of
indexes) if the :otype is :extended or :multiple.
Calls the Lobject version of clear rather than
the Lframe version of clear.
Adds text to the listbox at index.
- index - the index within the :text Array to insert
the text, -1 inserts at the end of the list.
- text - a String or Symbol to add to the listbox.
- dont_paint - set to true when you are adding multiple items and don’t
want a repaint after each line is added and then call on_paint_client
yourself when you are done. The default is to repaint every time a new item
is added.
Deletes the item at index from the listbox.
- index - the index of the item you want to delete. Use index = -1 to deleted
from the end of the list.
- dont_paint - set to true when you are deleting multiple items and
don’t want a repaint after each line is deleted and then call
on_paint_client yourself when you are done. The default is to repaint every
time an item is deleted.
Changes the text associated with the item in the listbox at index.
- index - the index within the :text Array to update
with text, -1 changed that last item in the list.
- text - a String or Symbol used to replace the item in the listbox at
index.
- dont_paint - set to true when you are updating multiple items and
don’t want a repaint after each line is updated and then call
on_paint_client yourself when you are done. The default is to repaint every
time an item is updated.
Sets the active, current item, or focus indicator. This item will always be
visible because is shows when the listbox has the focus by drawing a line
under the item. If the item at new_index is not visible, the listbox is
automatically scrolled and repainted so you can see the item.
Returns the index of the currently selected or active item in the listbox.
Returns the item (the text from the :text Array)
at index from the list. If index is nil, then returns the selected item(s)
from the :value attribute, if there are no selected items and the
otype==:single, then the active_item
(item under the cursor) is returned.
- index - the index of the item you want to retrieve, use -1 to the last item
in the listbox.
- dont_return_active_item - when true, the active_item is never returned. The default
is nil and will return the active item when :otype = :single and there is
no selected item. Ignored when :otype is :multiple or :extended.
Returns the index of the item nearest the ly pixel position where ly is a
screen relative pixel position (the :y element of the Levent object, i.e. levent[:y]).
- ly - a screen relative pixel position. Generally, this is the :y element of
the Levent object during any mouse related event.
Makes sure the item at index is visible. If the item at index is not
visible, the listbox is scrolled and repainted such that the item at index
is visible.
- index - the index of the item in the listbox you want to make sure is
visible.
- force_repaint - for internal use only.
Returns true if index is selected or highlighted.
- index - the index in the :text Array you want to
know about.
Selects or highlight the item at index.
- index - an Fixnum when :otype=>:single, otherwise index can be a Fixnum
or an Array of Fixnums where each Fixnum is the
index of an item in the :text array to select. These items will be
repainted using the fg_highlight and bg_highlight color. These items are
added to the :value attribute.
- levent - for internal use only.
- dont_paint - for internal use only.
Unselects or un-highlights the item at index.
- index - an Fixnum when :otype=>:single, otherwise index can be a Fixnum
or an Array of Fixnums where each Fixnum is the
index of an item in the :text array to deselect. These items will be
repainted using the fg and bg color to eliminated the highlighting. These
items are removed
from the :value attribute.
This is the vertical spacing in pixels between each item in the list. The
default is 0.
Sets the vertical spacing in pixels between each item in the list. This
will repaints the listbox using the new value.
The default is 3 so the text does not hug the left and right border.
Returns the pixel width of the text in the object. This should take into
consideration the font, size, and style of the object and its parents. This
is used to calculate width of the object when needed.
Returns the pixel height of the text in the object. This should take into
consideration the font, size, and style of the object and its parents. This
is used to calculate height of the object when needed.
Returns the total pixel width needed by the text currently in the listbox.
Returns the total pixel height needed by the text currently in the listbox.
Returns the number of items (Strings or Symbols) currently in the listbox
(in the :text Array).
Thank you for taking the time to visit this web page. I trust you found the information contained in this page useful.
Please email any questions, concerns, or issues with this web site to webmaster@sevasoftware.com.
Please remember Seva Software when your company would benefit from an experienced database architect and software engineer.