wListBox

A listbox is used to select one or more of a list of strings.

Appearance:
Superclass:wControl
Styles:
StylesDescription
wLbSingleSingle-selection list.
wLbMultipleMultiple-selection list.
wLbExtendedExtended-selection list: the user can extend the selection by using SHIFT or CTRL keys together with the cursor movement keys or the mouse.
wLbNeededScrollOnly create a vertical scrollbar if needed.
wLbAlwaysScrollAlways show a vertical scrollbar.
wLbSortThe listbox contents are sorted in alphabetical order.
wLbNoSelSpecifies that the list box contains items that can be viewed but not selected.
Events:wCommandEvent
wCommandEventDescription
wEvent_ListBoxWhen an item on the list is selected or the selection changes.
wEvent_ListBoxDoubleClickWhen the listbox is double-clicked.

Consts

wLbSingle = 0
wLbMultiple = 0x00000008
wLbExtended = 0x00000800
wLbNeededScroll = 0x00200000
wLbAlwaysScroll = 2101248
wLbSort = 0x00000002
wLbNoSel = 0x00004000

Procs

proc getCount(self: wListBox): int {...}{.validate, property, inline, raises: [], tags: [].}
Returns the number of items in the control.
proc len(self: wListBox): int {...}{.validate, inline, raises: [], tags: [].}
Returns the number of items in the control.
proc getText(self: wListBox; index: int): string {...}{.validate, property, raises: [],
    tags: [].}
Returns the label of the item with the given index.
proc `[]`(self: wListBox; index: int): string {...}{.validate, inline, raises: [], tags: [].}
Returns the label of the item with the given index. Raise error if index out of bounds.
proc insert(self: wListBox; pos: int; text: string) {...}{.validate, inline, raises: [],
    tags: [].}
Inserts the given string before the specified position. Notice that the inserted item won't be sorted even the list box has wLbSort style. If pos is -1, the string is added to the end of the list.
proc insert(self: wListBox; pos: int; list: openArray[string]) {...}{.validate, inline,
    raises: [], tags: [].}
Inserts multiple strings in the same time.
proc append(self: wListBox; text: string): int {...}{.validate, inline, discardable,
    raises: [], tags: [].}
Appends the given string to the end. If the list box has the wLbSort style, the string is inserted into the list and the list is sorted. The return value is the index of the string in the list box.
proc append(self: wListBox; list: openArray[string]) {...}{.validate, inline, raises: [],
    tags: [].}
Appends multiple strings in the same time.
proc delete(self: wListBox; index: int) {...}{.validate, inline, raises: [], tags: [].}
Delete a string in the list box.
proc delete(self: wListBox; text: string) {...}{.validate, inline, raises: [], tags: [].}
Search and delete the specified string in the list box.
proc clear(self: wListBox) {...}{.validate, inline, raises: [], tags: [].}
Remove all items from a list box.
proc findText(self: wListBox; text: string): int {...}{.validate, inline, raises: [], tags: [].}
Finds an item whose label matches the given text.
proc getSelection(self: wListBox): int {...}{.validate, property, inline, raises: [], tags: [].}
Returns the index of the selected item or wNotFound(-1) if no item is selected. Don't use in multiple-selection list box.
proc getFocused(self: wListBox): int {...}{.validate, property, inline, raises: [], tags: [].}
Returns the index of current focused item.
proc setFocused(self: wListBox; index: int) {...}{.validate, property, inline, raises: [],
    tags: [].}
Sets focused item.
proc getSelections(self: wListBox): seq[int] {...}{.validate, property, raises: [], tags: [].}
Get the currently selected items.
proc select(self: wListBox; index: int = -1) {...}{.validate, raises: [], tags: [].}
Selects an item in the list box. For multiple-selection list box, -1 means select all.
proc deselect(self: wListBox; index: int = -1) {...}{.validate, raises: [], tags: [].}
Deselects an item in the list box. For multiple-selection list box, -1 means deselect all.
proc select(self: wListBox; text: string) {...}{.raises: [], tags: [].}
Searches and selects an item in the list box.
proc deselect(self: wListBox; text: string) {...}{.raises: [], tags: [].}
Searches and deselects an item in the list box.
proc setSelection(self: wListBox; index: int) {...}{.validate, property, inline, raises: [],
    tags: [].}
Sets the selection to the given index. The same as select().
proc setSelections(self: wListBox; text: string) {...}{.validate, property, inline,
    raises: [], tags: [].}
Searches and sets the selection to the given text. The same as select().
proc setSelections(self: wListBox; list: openArray[int]) {...}{.validate, property, inline,
    raises: [], tags: [].}
Sets the selections.
proc setSelections(self: wListBox; list: openArray[string]) {...}{.validate, property,
    inline, raises: [], tags: [].}
Searches and sets the selections.
proc isSelected(self: wListBox; n: int): bool {...}{.validate, inline, raises: [], tags: [].}
Determines whether an item is selected.
proc setText(self: wListBox; index: int; text: string) {...}{.validate, property, raises: [],
    tags: [].}
Sets the label for the given item.
proc setFirstItem(self: wListBox; index: int) {...}{.validate, property, inline, raises: [],
    tags: [].}
Set the specified item to be the first visible item.
proc getTopItem(self: wListBox): int {...}{.validate, property, inline, raises: [], tags: [].}
Return the index of the topmost visible item.
proc hitTest(self: wListBox; x, y: int): int {...}{.validate, inline, raises: [], tags: [].}
Returns the item located at point, or wNotFound(-1) if there is no item located at point.
proc hitTest(self: wListBox; pos: wPoint): int {...}{.validate, inline, raises: [], tags: [].}
Returns the item located at point, or wNotFound(-1) if there is no item located at point.
proc getCountPerPage(self: wListBox): int {...}{.validate, property, raises: [], tags: [].}
Return the number of items that can fit vertically in the visible area of the listbox.
proc ensureVisible(self: wListBox; index: int) {...}{.validate, property, raises: [], tags: [].}
Ensure that the item with the given index is currently shown.
proc isSorted(self: wListBox): bool {...}{.validate, inline, raises: [], tags: [].}
Return true if the listbox has wLbSort style.
proc setData(self: wListBox; index: int; data: int) {...}{.validate, property, inline,
    raises: [], tags: [].}
Associates application-defined data with this item.
proc getData(self: wListBox; index: int): int {...}{.validate, property, raises: [], tags: [].}
Gets the application-defined data associated with this item.
proc getRect(self: wListBox; index: int): wRect {...}{.validate, property, raises: [], tags: [].}
Returns the rectangle representing the item's size and position, in physical coordinates.
proc final(self: wListBox) {...}{.raises: [], tags: [].}
Default finalizer for wListBox.
proc init(self: wListBox; parent: wWindow; id = wDefaultID; pos = wDefaultPoint;
         size = wDefaultSize; choices: openArray[string] = [];
         style: wStyle = wLbSingle) {...}{.validate, raises: [], tags: [].}
Initializer.
proc ListBox(parent: wWindow; id = wDefaultID; pos = wDefaultPoint; size = wDefaultSize;
            choices: openArray[string] = []; style: wStyle = wLbSingle): wListBox {...}{.
    inline, discardable, raises: [], tags: [].}
Constructor, creating and showing a list box.

Methods

method getDefaultSize(self: wListBox): wSize {...}{.raises: [], tags: [].}
Returns the default size for the control.
method getBestSize(self: wListBox): wSize {...}{.raises: [], tags: [].}
Returns the best acceptable minimal size for the control.

Iterators

iterator items(self: wListBox): string {...}{.validate, inline, raises: [], tags: [].}
Iterate each item in this list box. Iterates over each item in this list box. Yields (index, [index]) pairs.
iterator getSelections(self: wListBox): int {...}{.validate, raises: [], tags: [].}
Iterates over each index of the selected items.
iterator selections(self: wListBox): int {...}{.validate, inline, raises: [], tags: [].}
Iterates over each index of the selected items.