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 {...}{.inline, raises: [], tags: [].}
Returns the number of items in the control.
proc len(self: wListBox): int {...}{.inline, raises: [], tags: [].}
Returns the number of items in the control.
proc getText(self: wListBox; index: int): string {...}{.raises: [], tags: [].}
Returns the label of the item with the given index.
proc `[]`(self: wListBox; index: int): string {...}{.inline, raises: [IndexDefect], 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) {...}{.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]) {...}{.inline, raises: [],
    tags: [].}
Inserts multiple strings in the same time.
proc append(self: wListBox; text: string): int {...}{.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]) {...}{.inline, raises: [], tags: [].}
Appends multiple strings in the same time.
proc delete(self: wListBox; index: int) {...}{.inline, raises: [], tags: [].}
Delete a string in the list box.
proc delete(self: wListBox; text: string) {...}{.inline, raises: [], tags: [].}
Search and delete the specified string in the list box.
proc clear(self: wListBox) {...}{.inline, raises: [], tags: [].}
Remove all items from a list box.
proc findText(self: wListBox; text: string): int {...}{.inline, raises: [], tags: [].}
Finds an item whose label matches the given text.
proc getSelection(self: wListBox): int {...}{.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 {...}{.inline, raises: [], tags: [].}
Returns the index of current focused item.
proc setFocused(self: wListBox; index: int) {...}{.inline, raises: [], tags: [].}
Sets focused item.
proc getSelections(self: wListBox): seq[int] {...}{.raises: [], tags: [].}
Get the currently selected items.
proc select(self: wListBox; index: int = -1) {...}{.raises: [], tags: [].}
Selects an item in the list box. For multiple-selection list box, -1 means select all.
proc selectAll(self: wListBox) {...}{.inline, raises: [], tags: [].}
Selects all items.
proc deselect(self: wListBox; index: int = -1) {...}{.raises: [], tags: [].}
Deselects an item in the list box. For multiple-selection list box, -1 means deselect all.
proc deselectAll(self: wListBox) {...}{.inline, raises: [], tags: [].}
Deselects all items.
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) {...}{.inline, raises: [], tags: [].}
Sets the selection to the given index. The same as select().
proc setSelections(self: wListBox; text: string) {...}{.inline, raises: [], tags: [].}
Searches and sets the selection to the given text. The same as select().
proc setSelections(self: wListBox; list: openArray[int]) {...}{.inline, raises: [], tags: [].}
Sets the selections.
proc setSelections(self: wListBox; list: openArray[string]) {...}{.inline, raises: [],
    tags: [].}
Searches and sets the selections.
proc isSelected(self: wListBox; n: int): bool {...}{.inline, raises: [], tags: [].}
Determines whether an item is selected.
proc setText(self: wListBox; index: int; text: string) {...}{.raises: [], tags: [].}
Sets the label for the given item.
proc setFirstItem(self: wListBox; index: int) {...}{.inline, raises: [], tags: [].}
Set the specified item to be the first visible item.
proc getTopItem(self: wListBox): int {...}{.inline, raises: [], tags: [].}
Return the index of the topmost visible item.
proc hitTest(self: wListBox; x, y: int): int {...}{.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 {...}{.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 {...}{.raises: [Exception], tags: [RootEffect].}
Return the number of items that can fit vertically in the visible area of the listbox.
proc ensureVisible(self: wListBox; index: int) {...}{.raises: [Exception],
    tags: [RootEffect].}
Ensure that the item with the given index is currently shown.
proc isSorted(self: wListBox): bool {...}{.inline, raises: [], tags: [].}
Return true if the listbox has wLbSort style.
proc setData(self: wListBox; index: int; data: int) {...}{.inline, raises: [], tags: [].}
Associates application-defined data with this item.
proc getData(self: wListBox; index: int): int {...}{.raises: [], tags: [].}
Gets the application-defined data associated with this item.
proc getRect(self: wListBox; index: int): wRect {...}{.raises: [], tags: [].}
Returns the rectangle representing the item's size and position, in physical coordinates.
proc init(self: wListBox; parent: wWindow; id = wDefaultID; pos = wDefaultPoint;
         size = wDefaultSize; choices: openArray[string] = [];
         style: wStyle = wLbSingle) {...}{.raises: [wNilAccess, wWindowError, wCursorError,
    wBrushError, Exception, IndexDefect, wFontError], tags: [RootEffect].}
Initializes a list box.
proc ListBox(parent: wWindow; id = wDefaultID; pos = wDefaultPoint; size = wDefaultSize;
            choices: openArray[string] = []; style: wStyle = wLbSingle): wListBox {...}{.
    inline, discardable, raises: [wNilAccess, wWindowError, wCursorError, wBrushError,
                               Exception, IndexDefect, wFontError],
    tags: [RootEffect].}
Constructor.
proc init(self: wListBox; hWnd: HWND) {...}{.raises: [wWindowError, wCursorError,
    IndexDefect, wFontError, Exception], tags: [RootEffect].}
Initializes a list box by subclassing a system handle. Used internally.
proc ListBox(hWnd: HWND): wListBox {...}{.inline, discardable, raises: [wWindowError,
    wCursorError, IndexDefect, wFontError, Exception], tags: [RootEffect].}
Constructor.

Methods

method getDefaultSize(self: wListBox): wSize {...}{.inline, raises: [], tags: [].}
Returns the default size for the control.
method getBestSize(self: wListBox): wSize {...}{.inline, raises: [], tags: [].}
Returns the best acceptable minimal size for the control.
method release(self: wListBox) {...}{.raises: [], tags: [RootEffect].}
Release all the resources during destroying. Used internally.

Iterators

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