Class: Fox::FXList
- Inherits:
-
FXScrollArea
- Object
- FXObject
- FXId
- FXDrawable
- FXWindow
- FXComposite
- FXScrollArea
- Fox::FXList
- Includes:
- Enumerable
- Defined in:
- rdoc-sources/FXList.rb,
lib/fox16/iterators.rb
Overview
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 |
Direct Known Subclasses
Instance Attribute Summary (collapse)
-
- (Object) anchorItem
readonly
Index of anchor item, or -1 if no anchor item [Integer].
-
- (Object) currentItem
Index of current item, or -1 if no current item [Integer].
-
- (Object) cursorItem
readonly
Index of item under the cursor, or -1 if none [Integer].
-
- (Object) font
Text font FXFont.
-
- (Object) helpText
Status line help text [String].
-
- (Object) listStyle
List style [Integer].
-
- (Object) numItems
readonly
Number of items in the list [Integer].
-
- (Object) numVisible
Number of visible items [Integer].
-
- (Object) selBackColor
Selected text background color FXColor.
-
- (Object) selTextColor
Selected text color FXColor.
-
- (Object) textColor
Normal text color FXColor.
Attributes inherited from FXScrollArea
#contentHeight, #contentWidth, #horizontalScrollBar, #scrollStyle, #verticalScrollBar, #viewportHeight, #viewportWidth, #xPosition, #yPosition
Attributes inherited from FXWindow
#accelTable, #backColor, #defaultCursor, #dragCursor, #focus, #key, #last, #layoutHints, #next, #numChildren, #owner, #parent, #prev, #root, #selector, #shell, #target, #x, #y
Attributes inherited from FXDrawable
Attributes inherited from FXId
Instance Method Summary (collapse)
-
- (Object) appendItem(text, icon = nil, data = nil, notify = false)
Append a new item with given text and optional icon and user data, e.g.
-
- (Object) clearItems(notify = false)
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.
-
- (Object) deselectItem(index, notify = false)
Deselect item.
-
- (Object) disableItem(index)
Disable item.
-
- (Object) each
Calls block once for each item in the list, passing a reference to that item as a parameter.
-
- (Object) enableItem(index)
Enable item.
-
- (Object) extendSelection(index, notify = false)
Extend selection from anchor item to index.
-
- (Object) extractItem(index, notify = false)
Extract item from list and return a reference to the item.
-
- (Object) fillItems(strings, icon = nil, ptr = nil, notify = false)
Fill list by appending items from array of strings, and return the number items added.
-
- (Object) findItem(text, start = -1,, flags = SEARCH_FORWARD|SEARCH_WRAP)
Search items by text, beginning from item start.
-
- (Object) findItemByData(data, start = -1,, flags = SEARCH_FORWARD|SEARCH_WRAP)
Search items by associated user data, beginning from item start.
-
- (Object) first
Override Enumerable#first with FXWindow#first for backwards compatibility.
-
- (Object) getItem(index)
Return the item at the given index; returns a reference to an FXListItem instance.
-
- (Object) getItemAt(x, y)
Return index of item at (x, y), if any.
-
- (Object) getItemData(index)
Return item user data; this is equivalent to:.
-
- (Object) getItemHeight(index)
Return height of item at index.
-
- (Object) getItemIcon(index)
Return item icon, if any.
-
- (Object) getItemText(index)
Return item text; this is equivalent to:.
-
- (Object) getItemWidth(index)
Return width of item at index.
-
- (Object) hitItem(index, x, y)
Return item hit code: 0 no hit; 1 hit the icon; 2 hit the text.
-
- (FXList) initialize(p, target = nil, selector = 0, opts = LIST_NORMAL, x = 0, y = 0, width = 0, height = 0)
constructor
Construct a list with initially no items in it.
-
- (Object) insertItem(index, text, icon = nil, data = nil, notify = false)
Insert item at index with given text, icon, and user data, e.g.
-
- (Boolean) itemCurrent?(index)
Return true if item is current.
-
- (Boolean) itemEnabled?(index)
Return true if item is enabled; this is equivalent to:.
-
- (Boolean) itemSelected?(index)
Return true if item is selected; this is equivalent to:.
-
- (Boolean) itemVisible?(index)
Return true if item is visible.
-
- (Object) killSelection(notify = false)
Deselect all items.
-
- (Object) makeItemVisible(itemOrIndex)
Scroll to bring item into view.
-
- (Object) moveItem(newIndex, oldIndex, notify = false)
Move item from oldIndex to newIndex and return the new index of the item..
-
- (Object) prependItem(text, icon = nil, data = nil, notify = false)
Prepend a new item with given text and optional icon and user data, e.g.
-
- (Object) removeItem(index, notify = false)
Remove item at index from list.
-
- (Object) selectItem(index, notify = false)
Select item.
-
- (Object) setCurrentItem(index, notify = false)
Change current item.
-
- (Object) setItem(index, text, icon = nil, data = nil, notify = false)
Replace the text, icon, and user data for the item at index, e.g.
-
- (Object) setItemData(index, data)
Change item user data; this is equivalent to:.
-
- (Object) setItemIcon(index, icon, owned = false)
Change item icon and mark the list's layout as dirty; this is equivalent to:.
-
- (Object) setItemText(index, text)
Change item text and mark the list's layout as dirty; this is equivalent to:.
-
- (Object) sortItems
Sort items using current sort function.
-
- (Object) toggleItem(index, notify = false)
Toggle item selection state.
-
- (Object) updateItem(index)
Repaint item.
Methods inherited from FXScrollArea
#horizontalScrollable?, #position, #scrollCorner, #setPosition, #verticalScrollable?
Methods inherited from FXComposite
#maxChildHeight, #maxChildWidth
Methods inherited from FXWindow
#acceptDrop, #acquireClipboard, #acquireSelection, #active?, #addHotKey, #after?, after?, #before?, before?, #beginDrag, #canFocus?, #changeFocus, #childAtIndex, #childOf?, #children, #clearDragRectangle, #clearShape, colorType, colorTypeName, commonAncestor, #composeContext, #composite?, #contains?, #containsChild?, #create, #createComposeContext, #cursorPosition, #default?, #defaultHeight, #defaultWidth, deleteType, deleteTypeName, #destroy, #destroyComposeContext, #detach, #didAccept, #disable, #doesSaveUnder?, #dragging?, #dropDisable, #dropEnable, #dropEnabled?, #dropFinished, #dropTarget?, #each_child, #each_child_recursive, #enable, #enabled?, #endDrag, #forceRefresh, #getChildAt, #getDNDData, #getHeightForWidth, #getWidthForHeight, #grab, #grabKeyboard, #grabbed?, #grabbedKeyboard?, #handleDrag, #hasClipboard?, #hasFocus?, #hasSelection?, #height, #height=, #hide, imageType, #inFocusChain?, #indexOfChild, #initial?, #inquireDNDAction, #inquireDNDTypes, #killFocus, #layout, #linkAfter, #linkBefore, #lower, #move, octetType, octetTypeName, #offeredDNDType?, #position, #raiseWindow, #recalc, #releaseClipboard, #releaseSelection, #remHotKey, #removeChild, #repaint, #reparent, #resize, #scroll, #setCursorPosition, #setDNDData, #setDefault, #setDragRectangle, #setFocus, #setInitial, #setShape, #shell?, #show, #shown?, stringType, textType, textTypeName, #tr, #translateCoordinatesFrom, #translateCoordinatesTo, #underCursor?, #ungrab, #ungrabKeyboard, #update, urilistType, urilistTypeName, utf16Type, utf16TypeName, utf8Type, utf8TypeName, #visible=, #width, #width=
Methods included from Responder2
Methods inherited from FXDrawable
Methods inherited from FXId
#create, #created?, #destroy, #detach
Methods inherited from FXObject
#bind, #handle, #load, #save, subclasses
Constructor Details
- (FXList) initialize(p, target = nil, selector = 0, opts = LIST_NORMAL, x = 0, y = 0, width = 0, height = 0)
Construct a list with initially no items in it.
147 148 |
# File 'rdoc-sources/FXList.rb', line 147 def initialize(p, target=nil, selector=0, opts=LIST_NORMAL, x=0, y=0, width=0, height=0) # :yields: theList end |
Instance Attribute Details
- (Object) anchorItem (readonly)
Index of anchor item, or -1 if no anchor item [Integer]
123 124 125 |
# File 'rdoc-sources/FXList.rb', line 123 def anchorItem @anchorItem end |
- (Object) currentItem
Index of current item, or -1 if no current item [Integer]
120 121 122 |
# File 'rdoc-sources/FXList.rb', line 120 def currentItem @currentItem end |
- (Object) cursorItem (readonly)
Index of item under the cursor, or -1 if none [Integer]
126 127 128 |
# File 'rdoc-sources/FXList.rb', line 126 def cursorItem @cursorItem end |
- (Object) font
Text font Fox::FXFont
129 130 131 |
# File 'rdoc-sources/FXList.rb', line 129 def font @font end |
- (Object) helpText
Status line help text [String]
144 145 146 |
# File 'rdoc-sources/FXList.rb', line 144 def helpText @helpText end |
- (Object) listStyle
List style [Integer]
141 142 143 |
# File 'rdoc-sources/FXList.rb', line 141 def listStyle @listStyle end |
- (Object) numItems (readonly)
Number of items in the list [Integer]
114 115 116 |
# File 'rdoc-sources/FXList.rb', line 114 def numItems @numItems end |
- (Object) numVisible
Number of visible items [Integer]
117 118 119 |
# File 'rdoc-sources/FXList.rb', line 117 def numVisible @numVisible end |
- (Object) selBackColor
Selected text background color Fox::FXColor
135 136 137 |
# File 'rdoc-sources/FXList.rb', line 135 def selBackColor @selBackColor end |
- (Object) selTextColor
Selected text color Fox::FXColor
138 139 140 |
# File 'rdoc-sources/FXList.rb', line 138 def selTextColor @selTextColor end |
- (Object) textColor
Normal text color Fox::FXColor
132 133 134 |
# File 'rdoc-sources/FXList.rb', line 132 def textColor @textColor end |
Instance Method Details
- (Object) appendItem(text, icon = nil, data = nil, notify = false)
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.
209 |
# File 'rdoc-sources/FXList.rb', line 209 def appendItem(text, icon=nil, data=nil, notify=false) ; end |
- (Object) clearItems(notify = false)
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.
267 |
# File 'rdoc-sources/FXList.rb', line 267 def clearItems(notify=false) ; end |
- (Object) deselectItem(index, notify = false)
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.
415 |
# File 'rdoc-sources/FXList.rb', line 415 def deselectItem(index, notify=false) ; end |
- (Object) disableItem(index)
Disable item. Raises IndexError if index is out of bounds.
403 |
# File 'rdoc-sources/FXList.rb', line 403 def disableItem(index) ; end |
- (Object) each
Calls block once for each item in the list, passing a reference to that item as a parameter.
118 119 120 121 122 123 |
# File 'lib/fox16/iterators.rb', line 118 def each # :yields: aListItem 0.upto(numItems - 1) do |i| yield getItem(i) end self end |
- (Object) enableItem(index)
Enable item. Raises IndexError if index is out of bounds.
398 |
# File 'rdoc-sources/FXList.rb', line 398 def enableItem(index) ; end |
- (Object) extendSelection(index, notify = false)
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.
433 |
# File 'rdoc-sources/FXList.rb', line 433 def extendSelection(index, notify=false) ; end |
- (Object) extractItem(index, notify = false)
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.
256 |
# File 'rdoc-sources/FXList.rb', line 256 def extractItem(index, notify=false); end |
- (Object) fillItems(strings, icon = nil, ptr = nil, notify = false)
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.
180 |
# File 'rdoc-sources/FXList.rb', line 180 def fillItems(strings, icon=nil, ptr=nil, notify=false); end |
- (Object) findItem(text, start = -1,, flags = SEARCH_FORWARD|SEARCH_WRAP)
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.
291 |
# File 'rdoc-sources/FXList.rb', line 291 def findItem(text, start=-1, flags=SEARCH_FORWARD|SEARCH_WRAP) ; end |
- (Object) findItemByData(data, start = -1,, flags = SEARCH_FORWARD|SEARCH_WRAP)
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.
301 |
# File 'rdoc-sources/FXList.rb', line 301 def findItemByData(data, start=-1, flags=SEARCH_FORWARD|SEARCH_WRAP); end |
- (Object) first
Override Enumerable#first with FXWindow#first for backwards compatibility.
110 111 112 |
# File 'lib/fox16/iterators.rb', line 110 def first getFirst end |
- (Object) getItem(index)
Return the item at the given index; returns a reference to an FXListItem instance. Raises IndexError if index is out of bounds.
152 |
# File 'rdoc-sources/FXList.rb', line 152 def getItem(index) ; end |
- (Object) getItemAt(x, y)
Return index of item at (x, y), if any
276 |
# File 'rdoc-sources/FXList.rb', line 276 def getItemAt(x, y) ; end |
- (Object) getItemData(index)
Return item user data; this is equivalent to:
getItem(index).data
Raises IndexError if index is out of bounds.
366 |
# File 'rdoc-sources/FXList.rb', line 366 def getItemData(index) ; end |
- (Object) getItemHeight(index)
Return height of item at index. Raises IndexError if index is out of bounds.
273 |
# File 'rdoc-sources/FXList.rb', line 273 def getItemHeight(index) ; end |
- (Object) getItemIcon(index)
Return item icon, if any. This is equivalent to:
getItem(index).icon
Raises IndexError if index is out of bounds.
348 |
# File 'rdoc-sources/FXList.rb', line 348 def getItemIcon(index) ; end |
- (Object) getItemText(index)
Return item text; this is equivalent to:
getItem(index).text
Raises IndexError if index is out of bounds.
329 |
# File 'rdoc-sources/FXList.rb', line 329 def getItemText(index) ; end |
- (Object) getItemWidth(index)
Return width of item at index. Raises IndexError if index is out of bounds.
270 |
# File 'rdoc-sources/FXList.rb', line 270 def getItemWidth(index) ; end |
- (Object) hitItem(index, x, y)
Return item hit code: 0 no hit; 1 hit the icon; 2 hit the text
279 |
# File 'rdoc-sources/FXList.rb', line 279 def hitItem(index, x, y) ; end |
- (Object) insertItem(index, text, icon = nil, data = nil, notify = false)
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.
190 |
# File 'rdoc-sources/FXList.rb', line 190 def insertItem(index, text, icon=nil, data=nil, notify=false) ; end |
- (Boolean) itemCurrent?(index)
Return true if item is current. Raises IndexError if index is out of bounds.
378 |
# File 'rdoc-sources/FXList.rb', line 378 def itemCurrent?(index) ; end |
- (Boolean) itemEnabled?(index)
Return true if item is enabled; this is equivalent to:
getItem(index).enabled?
Raises IndexError if index is out of bounds.
390 |
# File 'rdoc-sources/FXList.rb', line 390 def itemEnabled?(index) ; end |
- (Boolean) itemSelected?(index)
Return true if item is selected; this is equivalent to:
getItem(index).selected?
Raises IndexError if index is out of bounds.
375 |
# File 'rdoc-sources/FXList.rb', line 375 def itemSelected?(index) ; end |
- (Boolean) itemVisible?(index)
Return true if item is visible. Raises IndexError if index is out of bounds.
381 |
# File 'rdoc-sources/FXList.rb', line 381 def itemVisible?(index) ; end |
- (Object) killSelection(notify = false)
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.
438 |
# File 'rdoc-sources/FXList.rb', line 438 def killSelection(notify=false) ; end |
- (Object) makeItemVisible(itemOrIndex)
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.
309 |
# File 'rdoc-sources/FXList.rb', line 309 def makeItemVisible(itemOrIndex) ; end |
- (Object) moveItem(newIndex, oldIndex, notify = false)
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.
248 |
# File 'rdoc-sources/FXList.rb', line 248 def moveItem(newIndex, oldIndex, notify=false); end |
- (Object) prependItem(text, icon = nil, data = nil, notify = false)
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).
228 |
# File 'rdoc-sources/FXList.rb', line 228 def prependItem(text, icon=nil, data=nil, notify=false) ; end |
- (Object) removeItem(index, notify = false)
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.
262 |
# File 'rdoc-sources/FXList.rb', line 262 def removeItem(index, notify=false) ; end |
- (Object) selectItem(index, notify = false)
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.
409 |
# File 'rdoc-sources/FXList.rb', line 409 def selectItem(index, notify=false) ; end |
- (Object) setCurrentItem(index, notify = false)
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.
427 |
# File 'rdoc-sources/FXList.rb', line 427 def setCurrentItem(index, notify=false) ; end |
- (Object) setItem(index, text, icon = nil, data = nil, notify = false)
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.
162 |
# File 'rdoc-sources/FXList.rb', line 162 def setItem(index, text, icon=nil, data=nil, notify=false) ; end |
- (Object) setItemData(index, data)
Change item user data; this is equivalent to:
getItem(index).data = data
Raises IndexError if index is out of bounds.
357 |
# File 'rdoc-sources/FXList.rb', line 357 def setItemData(index, data) ; end |
- (Object) setItemIcon(index, icon, owned = false)
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.
339 |
# File 'rdoc-sources/FXList.rb', line 339 def setItemIcon(index, icon, owned=false) ; end |
- (Object) setItemText(index, text)
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.
320 |
# File 'rdoc-sources/FXList.rb', line 320 def setItemText(index, text) ; end |
- (Object) sortItems
Sort items using current sort function
441 |
# File 'rdoc-sources/FXList.rb', line 441 def sortItems() ; end |
- (Object) toggleItem(index, notify = false)
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.
421 |
# File 'rdoc-sources/FXList.rb', line 421 def toggleItem(index, notify=false) ; end |
- (Object) updateItem(index)
Repaint item. Raises IndexError if index is out of bounds.
393 |
# File 'rdoc-sources/FXList.rb', line 393 def updateItem(index) ; end |