Class: Fox::FXList

Inherits:
FXScrollArea show all
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

FXColorList

Instance Attribute Summary collapse

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

#height, #visual, #width

Attributes inherited from FXId

#app, #userData, #xid

Instance Method Summary collapse

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

#connect

Methods inherited from FXDrawable

#resize

Methods inherited from FXId

#create, #created?, #destroy, #detach, #runOnUiThread

Methods inherited from FXObject

#bind, #handle, #load, #save, subclasses

Constructor Details

#initialize(p, target = nil, selector = 0, opts = LIST_NORMAL, x = 0, y = 0, width = 0, height = 0) ⇒ FXList

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

#anchorItemObject (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

#currentItemObject

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

#cursorItemObject (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

#fontObject

Text font Fox::FXFont



129
130
131
# File 'rdoc-sources/FXList.rb', line 129

def font
  @font
end

#helpTextObject

Status line help text [String]



144
145
146
# File 'rdoc-sources/FXList.rb', line 144

def helpText
  @helpText
end

#listStyleObject

List style [Integer]



141
142
143
# File 'rdoc-sources/FXList.rb', line 141

def listStyle
  @listStyle
end

#numItemsObject (readonly)

Number of items in the list [Integer]



114
115
116
# File 'rdoc-sources/FXList.rb', line 114

def numItems
  @numItems
end

#numVisibleObject

Number of visible items [Integer]



117
118
119
# File 'rdoc-sources/FXList.rb', line 117

def numVisible
  @numVisible
end

#selBackColorObject

Selected text background color Fox::FXColor



135
136
137
# File 'rdoc-sources/FXList.rb', line 135

def selBackColor
  @selBackColor
end

#selTextColorObject

Selected text color Fox::FXColor



138
139
140
# File 'rdoc-sources/FXList.rb', line 138

def selTextColor
  @selTextColor
end

#textColorObject

Normal text color Fox::FXColor



132
133
134
# File 'rdoc-sources/FXList.rb', line 132

def textColor
  @textColor
end

Instance Method Details

#appendItem(text, icon = nil, data = nil, notify = false) ⇒ Object Also known as: <<

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(item, notify=false) ; end

#clearItems(notify = false) ⇒ Object

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.



269
# File 'rdoc-sources/FXList.rb', line 269

def clearItems(notify=false) ; end

#deselectItem(index, notify = false) ⇒ Object

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.



417
# File 'rdoc-sources/FXList.rb', line 417

def deselectItem(index, notify=false) ; end

#disableItem(index) ⇒ Object

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



405
# File 'rdoc-sources/FXList.rb', line 405

def disableItem(index) ; end

#eachObject

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

#enableItem(index) ⇒ Object

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



400
# File 'rdoc-sources/FXList.rb', line 400

def enableItem(index) ; end

#extendSelection(index, notify = false) ⇒ Object

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.



435
# File 'rdoc-sources/FXList.rb', line 435

def extendSelection(index, notify=false) ; end

#extractItem(index, notify = false) ⇒ Object

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.



258
# File 'rdoc-sources/FXList.rb', line 258

def extractItem(index, notify=false); end

#fillItems(strings, icon = nil, ptr = nil, notify = false) ⇒ Object

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

#findItem(text, start = -1,, flags = SEARCH_FORWARD|SEARCH_WRAP) ⇒ Object

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.



293
# File 'rdoc-sources/FXList.rb', line 293

def findItem(text, start=-1, flags=SEARCH_FORWARD|SEARCH_WRAP) ; end

#findItemByData(data, start = -1,, flags = SEARCH_FORWARD|SEARCH_WRAP) ⇒ Object

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.



303
# File 'rdoc-sources/FXList.rb', line 303

def findItemByData(data, start=-1, flags=SEARCH_FORWARD|SEARCH_WRAP); end

#firstObject

Override Enumerable#first with FXWindow#first for backwards compatibility.



110
111
112
# File 'lib/fox16/iterators.rb', line 110

def first
  getFirst
end

#getItem(index) ⇒ Object

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

#getItemAt(x, y) ⇒ Object

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



278
# File 'rdoc-sources/FXList.rb', line 278

def getItemAt(x, y) ; end

#getItemData(index) ⇒ Object

Return item user data; this is equivalent to:

getItem(index).data

Raises IndexError if index is out of bounds.



368
# File 'rdoc-sources/FXList.rb', line 368

def getItemData(index) ; end

#getItemHeight(index) ⇒ Object

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



275
# File 'rdoc-sources/FXList.rb', line 275

def getItemHeight(index) ; end

#getItemIcon(index) ⇒ Object

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

getItem(index).icon

Raises IndexError if index is out of bounds.



350
# File 'rdoc-sources/FXList.rb', line 350

def getItemIcon(index) ; end

#getItemText(index) ⇒ Object

Return item text; this is equivalent to:

getItem(index).text

Raises IndexError if index is out of bounds.



331
# File 'rdoc-sources/FXList.rb', line 331

def getItemText(index) ; end

#getItemWidth(index) ⇒ Object

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



272
# File 'rdoc-sources/FXList.rb', line 272

def getItemWidth(index) ; end

#hitItem(index, x, y) ⇒ Object

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



281
# File 'rdoc-sources/FXList.rb', line 281

def hitItem(index, x, y) ; end

#insertItem(index, text, icon = nil, data = nil, notify = false) ⇒ Object

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, item, notify=false) ; end

#itemCurrent?(index) ⇒ Boolean

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

Returns:

  • (Boolean)


380
# File 'rdoc-sources/FXList.rb', line 380

def itemCurrent?(index) ; end

#itemEnabled?(index) ⇒ Boolean

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

getItem(index).enabled?

Raises IndexError if index is out of bounds.

Returns:

  • (Boolean)


392
# File 'rdoc-sources/FXList.rb', line 392

def itemEnabled?(index) ; end

#itemSelected?(index) ⇒ Boolean

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

getItem(index).selected?

Raises IndexError if index is out of bounds.

Returns:

  • (Boolean)


377
# File 'rdoc-sources/FXList.rb', line 377

def itemSelected?(index) ; end

#itemVisible?(index) ⇒ Boolean

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

Returns:

  • (Boolean)


383
# File 'rdoc-sources/FXList.rb', line 383

def itemVisible?(index) ; end

#killSelection(notify = false) ⇒ Object

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.



440
# File 'rdoc-sources/FXList.rb', line 440

def killSelection(notify=false) ; end

#makeItemVisible(itemOrIndex) ⇒ Object

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.



311
# File 'rdoc-sources/FXList.rb', line 311

def makeItemVisible(itemOrIndex) ; end

#moveItem(newIndex, oldIndex, notify = false) ⇒ Object

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.



250
# File 'rdoc-sources/FXList.rb', line 250

def moveItem(newIndex, oldIndex, notify=false); end

#prependItem(text, icon = nil, data = nil, notify = false) ⇒ Object

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).



230
# File 'rdoc-sources/FXList.rb', line 230

def prependItem(item, notify=false) ; end

#removeItem(index, notify = false) ⇒ Object

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.



264
# File 'rdoc-sources/FXList.rb', line 264

def removeItem(index, notify=false) ; end

#selectItem(index, notify = false) ⇒ Object

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.



411
# File 'rdoc-sources/FXList.rb', line 411

def selectItem(index, notify=false) ; end

#setCurrentItem(index, notify = false) ⇒ Object

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.



429
# File 'rdoc-sources/FXList.rb', line 429

def setCurrentItem(index, notify=false) ; end

#setItem(index, text, icon = nil, data = nil, notify = false) ⇒ Object

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, item, notify=false) ; end

#setItemData(index, data) ⇒ Object

Change item user data; this is equivalent to:

getItem(index).data = data

Raises IndexError if index is out of bounds.



359
# File 'rdoc-sources/FXList.rb', line 359

def setItemData(index, data) ; end

#setItemIcon(index, icon, owned = false) ⇒ Object

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.



341
# File 'rdoc-sources/FXList.rb', line 341

def setItemIcon(index, icon, owned=false) ; end

#setItemText(index, text) ⇒ Object

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.



322
# File 'rdoc-sources/FXList.rb', line 322

def setItemText(index, text) ; end

#sortItemsObject

Sort items using current sort function



443
# File 'rdoc-sources/FXList.rb', line 443

def sortItems() ; end

#toggleItem(index, notify = false) ⇒ Object

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.



423
# File 'rdoc-sources/FXList.rb', line 423

def toggleItem(index, notify=false) ; end

#updateItem(index) ⇒ Object

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



395
# File 'rdoc-sources/FXList.rb', line 395

def updateItem(index) ; end