- Main Page
- Packages
- Classes
- Files
- Related Pages

- Class List
- Class Hierarchy
- Class Members

# smjg.libs.sdwf.control.ListBox Class Reference

The smjg.libs.sdwf.control.ListBox class interfaces a list box. More...

Inheritance diagram for smjg.libs.sdwf.control.ListBox:

List of all members.

## Public Member Functions
| this (Dialog parent, int id)
| Constructs a ListBox object to interface a given list box control.
| this (WindowBase parent, int id, Rect position)
| Constructs a list box to be created at runtime.
| this (FrameWindow parent, int id)
| Constructs a list box to be used as the client pane of a FrameWindow.
int | add (string s)
| Adds an item to the end of this list, or in its sorted position if the list box has the `LBS_SORT` style.
int | add (int index, string s)
| Inserts an item at the given position.
int | remove (int index)
| Removes the item at the given position.
int | find (string s, int startAfter=-1, bool beginsWith=false)
| Finds an item in the list box.
void | removeAll ()
| Removes all items from the list box.
string | item (int index)
| Gets text of an item in the list box.
int | findAndSelect (string s, int startAfter=-1)
| Finds an item in the list box beginning with a given string, and selects it.
Public Properties
int | length ()
| The number of items in this list box.
int | selected ()
| The zero-based index of the currently selected item.
int | selected (int index)
| The zero-based index of the currently selected item.
string | selectedItem ()
| The text of the selected item.
int | scrollPosition ()
| The zero-based index of the uppermost visible item in the list.
int | scrollPosition (int pos)
| The zero-based index of the uppermost visible item in the list.
## Protected Member Functions
| this (WindowBase parent, int id, string text, Rect position, string className="LISTBOX")
| Constructs a control to be created at runtime.

## Detailed Description

The smjg.libs.sdwf.control.ListBox class interfaces a list box.

It cannot interface a combo box of any kind. For this, use the ComboBox subclass.

Todo:
  add more features, possibly including: directory listing, owner drawing, multiple select, multi-column, horizontal scrolling/width, locales

## Constructor & Destructor Documentation

smjg.libs.sdwf.control.ListBox.this | ( | Dialog | parent,
|  | int | id |
| ) |  |  |

Constructs a ListBox object to interface a given list box control.

Parameters:

  | parent | the dialog on which the control is placed.
  | id | numeric ID of the control.

Precondition:
  The parent interface element must already have been created. ListBox objects should be constructed in an overridden Dialog.setup method, not in the constructor of a Dialog subclass.

Status:
  done

Reimplemented from smjg.libs.sdwf.control.Control.

Reimplemented in smjg.libs.sdwf.control.ComboBox.

smjg.libs.sdwf.control.ListBox.this | ( | WindowBase | parent,
|  | int | id,
|  | Rect | position |
| ) |  |  |

Constructs a list box to be created at runtime.

Parameters:

  | parent | the window or dialog on which the list box will be placed.
  | id | numeric ID that the list box will have.
  | position | the position on the parent window where the list box will be placed.

Since:
  0.4

Status:
  done

smjg.libs.sdwf.control.ListBox.this | ( | FrameWindow | parent,
|  | int | id |
| ) |  |  |

Constructs a list box to be used as the client pane of a FrameWindow.

Parameters:

  | parent | the frame window in which this list box will be framed.
  | id | numeric ID that the list box will have.

Since:
  0.4

Status:
  test

smjg.libs.sdwf.control.ListBox.this | ( | WindowBase | parent,
|  | int | id,
|  | string | text,
|  | Rect | position,
|  | string | className = `"LISTBOX"` |
| ) |  |  | `[protected]`

Constructs a control to be created at runtime.

Parameters:

  | parent | the window or dialog on which the control will be placed.
  | id | numeric ID that the control will have.
  | text | the control's caption text.
  | position | the position on the parent window where the control will be placed.
  | className | the Windows control class to which the control will belong. The default setting is for static text.

Note:
  The tab order of controls will be the order in which the interface elements are created (using either Control.create or Control.show).

Since:
  0.4

Status:
  done

Reimplemented from smjg.libs.sdwf.control.Control.

## Member Function Documentation

int smjg.libs.sdwf.control.ListBox.add | ( | string | s | ) |

Adds an item to the end of this list, or in its sorted position if the list box has the `LBS_SORT` style.

Parameters:

  | s | text of item to add.

Returns:
  zero-based index of added item.

Status:
  done

Reimplemented in smjg.libs.sdwf.control.ComboBox.

int smjg.libs.sdwf.control.ListBox.add | ( | int | index,
|  | string | s |
| ) |  |  |

Inserts an item at the given position.

Unlike the `add(string)` form, this method ignores the `LBS.SORT` style.

Parameters:

  | index | zero-based index at which to add item, or -1 to add to the end of the list.
  | s | text of item to add.

Returns:
  zero-based index at which the item was actually added.

Status:
  done

Reimplemented in smjg.libs.sdwf.control.ComboBox.

int smjg.libs.sdwf.control.ListBox.remove | ( | int | index | ) |

Removes the item at the given position.

Parameters:

  | index | zero-based index of item to remove from the list.

Returns:
  number of items remaining in the list.

Status:
  done

Reimplemented in smjg.libs.sdwf.control.ComboBox.

int smjg.libs.sdwf.control.ListBox.find | ( | string | s,
|  | int | startAfter = `-1`,
|  | bool | beginsWith = `false` |
| ) |  |  |

Finds an item in the list box.

Parameters:

  | s | string to match.
  | startAfter | zero-based index of item after which to start the search, or -1 to start at the beginning.
  | beginsWith | whether to look for an item merely beginning with `s`, as opposed to an exact match.

Returns:
  zero-based index of item found.

Return values:

  | -1 | if no matching item was found.

Since:
  0.3

Status:
  test

Reimplemented in smjg.libs.sdwf.control.ComboBox.

void smjg.libs.sdwf.control.ListBox.removeAll | ( |  | ) |

Removes all items from the list box.

Status:
  test

Reimplemented in smjg.libs.sdwf.control.ComboBox.

string smjg.libs.sdwf.control.ListBox.item | ( | int | index | ) |

Gets text of an item in the list box.

Parameters:

  | index | zero-based index of item to inspect.

Returns:
  the text of the requested item.

Status:
  done

Reimplemented in smjg.libs.sdwf.control.ComboBox.

int smjg.libs.sdwf.control.ListBox.findAndSelect | ( | string | s,
|  | int | startAfter = `-1` |
| ) |  |  |

Finds an item in the list box beginning with a given string, and selects it.

Parameters:

  | s | string to match.
  | startAfter | zero-based index of item after which to start the search, or -1 to start at the beginning.

Returns:
  zero-based index of item found.

Return values:

  | -1 | if no matching item was found.

Since:
  0.3

Status:
  test

Reimplemented in smjg.libs.sdwf.control.ComboBox.

int smjg.libs.sdwf.control.ListBox.length | ( |  | ) |

The number of items in this list box.

Status:
  test

Reimplemented in smjg.libs.sdwf.control.ComboBox.

int smjg.libs.sdwf.control.ListBox.selected | ( |  | ) |

The zero-based index of the currently selected item.

A value of -1 denotes that no item is selected.

Reimplemented in smjg.libs.sdwf.control.ComboBox.

int smjg.libs.sdwf.control.ListBox.selected | ( | int | index | ) |

The zero-based index of the currently selected item.

A value of -1 denotes that no item is selected.

Reimplemented in smjg.libs.sdwf.control.ComboBox.

string smjg.libs.sdwf.control.ListBox.selectedItem | ( |  | ) |

The text of the selected item.

This method is syntactic sugar for item(selected).

Returns:
  the text of the selected item in the list.

int smjg.libs.sdwf.control.ListBox.scrollPosition | ( |  | ) |

The zero-based index of the uppermost visible item in the list.

Reimplemented in smjg.libs.sdwf.control.ComboBox.

int smjg.libs.sdwf.control.ListBox.scrollPosition | ( | int | pos | ) |

The zero-based index of the uppermost visible item in the list.

If set to an index that would scroll the list beyond the last item, it scrolls to the end of the list.

Reimplemented in smjg.libs.sdwf.control.ComboBox.

The documentation for this class was generated from the following file:

- control.d