Class Fox::FXList
In: rdoc-sources/FXList.rb
Parent: FXScrollArea

A List Widget displays a list of items, each with a text and optional icon. When an item‘s selected state changes, the list sends a SEL_SELECTED or SEL_DESELECTED message. A change of the current item is signified by the SEL_CHANGED message. The list sends SEL_COMMAND messages when the user clicks on an item, and SEL_CLICKED, SEL_DOUBLECLICKED, and SEL_TRIPLECLICKED when the user clicks once, twice, or thrice, respectively. When items are added, replaced, or removed, the list sends messages of the type SEL_INSERTED, SEL_REPLACED, or SEL_DELETED. In each of these cases, the index to the item, if any, is passed in the 3rd argument of the message.

Events

The following messages are sent by FXList to its target:

SEL_CHANGED:sent when the current list item changes; the message data is an Integer indicating the index of the current item.
SEL_COMMAND:sent when the current list item changes; the message data is an Integer indicating the index of the current item.
SEL_KEYPRESS:sent when a key goes down; the message data is an FXEvent instance.
SEL_KEYRELEASE:sent when a key goes up; the message data is an FXEvent instance.
SEL_LEFTBUTTONPRESS:sent when the left mouse button goes down; the message data is an FXEvent instance.
SEL_LEFTBUTTONRELEASE:sent when the left mouse button goes up; the message data is an FXEvent instance.
SEL_RIGHTBUTTONPRESS:sent when the right mouse button goes down; the message data is an FXEvent instance.
SEL_RIGHTBUTTONRELEASE:sent when the right mouse button goes up; the message data is an FXEvent instance.
SEL_CLICKED:sent when a list item is single-clicked; the message data is an Integer indicating the index of the current item.
SEL_DOUBLECLICKED:sent when a list item is double-clicked; the message data is an Integer indicating the index of the current item.
SEL_TRIPLECLICKED:sent when a list item is triple-clicked; the message data is an Integer indicating the index of the current item.
SEL_SELECTED:sent when a list item is selected; the message data is an Integer indicating the index of the selected item.
SEL_DESELECTED:sent when a list item is deselected; the message data is an Integer indicating the index of the deselected item.
SEL_REPLACED:sent when a list item is about to be replaced; the message data is an Integer indicating the index of the item to be replaced.
SEL_INSERTED:sent after a list item is inserted; the message data is an Integer indicating the index of the item that was inserted.
SEL_DELETED:sent when a list item is about to be removed; the message data is an Integer indicating the index of the item to be removed.

List styles

LIST_EXTENDEDSELECT:Extended selection mode allows for drag-selection of ranges of items
LIST_SINGLESELECT:Single selection mode allows up to one item to be selected
LIST_BROWSESELECT:Browse selection mode enforces one single item to be selected at all times
LIST_MULTIPLESELECT:Multiple selection mode is used for selection of individual items
LIST_AUTOSELECT:Automatically select under cursor
LIST_NORMAL:same as LIST_EXTENDEDSELECT

Message identifiers

ID_TIPTIMER:: ID_LOOKUPTIMER::

Methods

Attributes

anchorItem  [R]  Index of anchor item, or -1 if no anchor item [Integer]
currentItem  [RW]  Index of current item, or -1 if no current item [Integer]
cursorItem  [R]  Index of item under the cursor, or -1 if none [Integer]
font  [RW]  Text font [FXFont]
helpText  [RW]  Status line help text [String]
listStyle  [RW]  List style [Integer]
numItems  [R]  Number of items in the list [Integer]
numVisible  [RW]  Number of visible items [Integer]
selBackColor  [RW]  Selected text background color [FXColor]
selTextColor  [RW]  Selected text color [FXColor]
textColor  [RW]  Normal text color [FXColor]

Public Class methods

Public Instance methods

Append a (possibly subclassed) item to the list, e.g.

  list.appendItem(FXListItem.new("pinky"))

If notify is true, a SEL_INSERTED message is sent to the list‘s message target after the item is appended. Returns the integer index of the newly appended item.

Append a new item with given text and optional icon and user data, e.g.

  list.appendItem("pinky")

If notify is true, a SEL_INSERTED message is sent to the list‘s message target after the item is appended. Returns the integer index of the newly appended item.

Remove all items from the list If notify is true, a SEL_DELETED message is sent to the list‘s message target before each item is removed.

Deselect item. If notify is true, a SEL_DESELECTED message is sent to the list‘s message target after the item is deselected. Raises IndexError if index is out of bounds.

Disable item. Raises IndexError if index is out of bounds.

Enable item. Raises IndexError if index is out of bounds.

Extend selection from anchor item to index. If notify is true, a series of SEL_SELECTED and SEL_DESELECTED messages are sent to the list‘s message target as the selected-state of different items changes. Raises IndexError if index is out of bounds.

Extract item from list and return a reference to the item. If notify is true, a SEL_DELETED message is sent to the list‘s message target before the item is extracted from the list. Raises IndexError if index is out of bounds.

Fill list by appending items from array of strings, and return the number items added. If notify is true, a SEL_INSERTED message is sent to the list‘s message target after the item is added.

Search items by text, beginning from item start. If the start item is -1 the search will start at the first item in the list. Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control the search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP to control whether the search wraps at the start or end of the list. The option SEARCH_IGNORECASE causes a case-insensitive match. Finally, passing SEARCH_PREFIX causes searching for a prefix of the item name. Return -1 if no matching item is found.

Search items by associated user data, beginning from item start. Returns the integer index of the matching item, or -1 if no match is found. If the start item is -1 the search will start at the first item in the list. Flags may be SEARCH_FORWARD or SEARCH_BACKWARD to control the search direction; this can be combined with SEARCH_NOWRAP or SEARCH_WRAP to control whether the search wraps at the start or end of the list.

Return the item at the given index; returns a reference to an FXListItem instance. Raises IndexError if index is out of bounds.

Return index of item at (x, y), if any

Return item user data; this is equivalent to:

  getItem(index).data

Raises IndexError if index is out of bounds.

Return height of item at index. Raises IndexError if index is out of bounds.

Return item icon, if any. This is equivalent to:

  getItem(index).icon

Raises IndexError if index is out of bounds.

Return item text; this is equivalent to:

  getItem(index).text

Raises IndexError if index is out of bounds.

Return width of item at index. Raises IndexError if index is out of bounds.

Return item hit code: 0 no hit; 1 hit the icon; 2 hit the text

Insert a new (possibly subclassed) item at the given index, e.g.

  list.insertItem(1, FXListItem.new("blinky"))

If notify is true, a SEL_INSERTED message is sent to the list‘s message target after the item is inserted. Raises IndexError if index is out of bounds. Returns the integer index of the inserted item.

Insert item at index with given text, icon, and user data, e.g.

  list.insertItem(1, "blinky")

If notify is true, a SEL_INSERTED message is sent to the list‘s message target after the item is inserted. Raises IndexError if index is out of bounds. Returns the integer index of the inserted item.

Return true if item is current. Raises IndexError if index is out of bounds.

Return true if item is enabled; this is equivalent to:

  getItem(index).enabled?

Raises IndexError if index is out of bounds.

Return true if item is selected; this is equivalent to:

  getItem(index).selected?

Raises IndexError if index is out of bounds.

Return true if item is visible. Raises IndexError if index is out of bounds.

Deselect all items. If notify is true, a SEL_DESELECTED message is sent to the list‘s message target for all the items that were selected before killSelection was called.

Scroll to bring item into view. The argument is either a reference to an FXListItem instance, or the integer index of an item in the list. For the latter case, makeItemVisible raises IndexError if the index is out of bounds.

Move item from oldIndex to newIndex and return the new index of the item.. If notify is true and this move causes the current item to change, a SEL_CHANGED message is sent to the list‘s message target to indicate this change in the current item. Raises IndexError if either oldIndex or newIndex is out of bounds.

Prepend a (possibly subclassed) item to the list, e.g.

  list.prependItem(FXListItem.new("clyde"))

If notify is true, a SEL_INSERTED message is sent to the list‘s message target after the item is prepended. Returns the integer index of the newly prepended item (which should always be zero, by definition).

Prepend a new item with given text and optional icon and user data, e.g.

  list.prependItem("clyde")

If notify is true, a SEL_INSERTED message is sent to the list‘s message target after the item is prepended. Returns the integer index of the newly prepended item (which should always be zero, by definition).

Remove item at index from list. If notify is true, a SEL_DELETED message is sent to the list‘s message target before the item is removed. Raises IndexError if index is out of bounds.

Select item. If notify is true, a SEL_SELECTED message is sent to the list‘s message target after the item is selected. Raises IndexError if index is out of bounds.

Change current item. If notify is true, a SEL_CHANGED message is sent to the list‘s message target after the current item changes. Raises IndexError if index is out of bounds.

Replace the item at index with a (possibly subclassed) item, e.g.

  list.setItem(0, FXListItem.new("inky"))

If notify is true, a SEL_REPLACED message is sent to the list‘s message target before the item is replaced. Raises IndexError if index is out of bounds. Returns the integer index of the replaced item.

Replace the text, icon, and user data for the item at index, e.g.

  list.setItem(0, "inky")

If notify is true, a SEL_REPLACED message is sent to the list‘s message target before the item is replaced. Raises IndexError if index is out of bounds. Returns the integer index of the replaced item.

Change item user data; this is equivalent to:

  getItem(index).data = data

Raises IndexError if index is out of bounds.

Change item icon and mark the list‘s layout as dirty; this is equivalent to:

  getItem(index).icon = icon
  recalc

Raises IndexError if index is out of bounds.

Change item text and mark the list‘s layout as dirty; this is equivalent to:

  getItem(index).text = text
  recalc

Raises IndexError if index is out of bounds.

Sort items using current sort function

Toggle item selection state. If notify is true, either a SEL_SELECTED or SEL_DESELECTED message is sent to the list‘s message target to indicate the item‘s new state. Raises IndexError if index is out of bounds.

Repaint item. Raises IndexError if index is out of bounds.

[Validate]