Skip to main content

Table<T> class

Namespace: Arlecchino.Widgets.Lists · Assembly: Arlecchino

Rows in aligned columns, with a heading and optional sorting, over a list box that does the selecting and the scrolling. Sorting reorders a copy, leaving Table.Rows untouched.

public sealed class Table<T> : IArlecchinoInteractiveWidget, IArlecchinoWidget, IArlecchinoFocusable

Implements IArlecchinoInteractiveWidget, IArlecchinoWidget, IArlecchinoFocusable

Constructors

MemberSummary
Table(ArlecchinoKeymap)Creates the table.

Properties

MemberSummary
ColumnsThe columns, left to right.
IsFocusedWhether the table has focus, which decides how strongly the selection is drawn.
ItemStyleColors a whole row. Ignored for the selected one.
OnActivateWhat confirming a row does. Returning a route navigates.
RowsWhat to show. Assigning re-applies the current sort.
SelectedIndexIndex of the selected row within the sorted order, not within what was assigned.
SelectedRowThe selected row, or the type's default when the table is empty.
SortedColumnIndex of the column being sorted by, or -1 when the rows are in their original order.
SortsDescendingWhich way the sort runs.

Methods

MemberSummary
Draw(SurfaceRegion)Works out the column widths for the space available, then draws the heading on the first row and the rows below it. The table fills whatever it is given, so nothing is left underneath it.
Handle(KeyPress)Moves the selection or confirms it. Sorting is not bound to a key; call Table.SortBy.
HandleMouse(MouseEvent)Scrolls and selects. Clicks on the heading are not routed here.
SortBy(int)Sorts by a column, or flips the direction when it is already the one being sorted by. Columns without a comparison, and indexes outside the table, are ignored.

Constructors in detail

Table(ArlecchinoKeymap)

Obsolete

Constructors of types with required members are not supported in this version of your compiler.

public Table(ArlecchinoKeymap keymap);

Creates the table.

Parameters

NameTypeDescription
keymapArlecchinoKeymapKeys to obey, so the table follows the application's bindings.

Properties in detail

Columns

public IReadOnlyList<TableColumn<T>> Columns { get; init; }

The columns, left to right.

Type IReadOnlyList<T><TableColumn<T>>

IsFocused

public bool IsFocused { get; set; }

Whether the table has focus, which decides how strongly the selection is drawn.

Type bool

ItemStyle

public Func<T, IArlecchinoColor> ItemStyle { get; init; }

Colors a whole row. Ignored for the selected one.

Type Func<T, TResult><T, IArlecchinoColor>

OnActivate

public Func<T, ViewRoute> OnActivate { get; init; }

What confirming a row does. Returning a route navigates.

Type Func<T, TResult><T, ViewRoute>

Rows

public IReadOnlyList<T> Rows { get; set; }

What to show. Assigning re-applies the current sort.

Type IReadOnlyList<T><T>

SelectedIndex

public int SelectedIndex { get; set; }

Index of the selected row within the sorted order, not within what was assigned.

Type int

SelectedRow

public T SelectedRow { get; }

The selected row, or the type's default when the table is empty.

Type T

SortedColumn

public int SortedColumn { get; }

Index of the column being sorted by, or -1 when the rows are in their original order.

Type int

SortsDescending

public bool SortsDescending { get; }

Which way the sort runs.

Type bool

Methods in detail

Draw(SurfaceRegion)

public SurfaceRegion Draw(SurfaceRegion region);

Works out the column widths for the space available, then draws the heading on the first row and the rows below it. The table fills whatever it is given, so nothing is left underneath it.

Parameters

NameTypeDescription
regionSurfaceRegionWhere to draw, heading included.

Returns SurfaceRegion — An empty region: the table uses every row it is handed.

Handle(KeyPress)

public FocusResult Handle(KeyPress key);

Moves the selection or confirms it. Sorting is not bound to a key; call Table.SortBy.

Parameters

NameTypeDescription
keyKeyPressThe key that was pressed.

Returns FocusResult — What became of the key.

HandleMouse(MouseEvent)

public FocusResult HandleMouse(MouseEvent mouse);

Scrolls and selects. Clicks on the heading are not routed here.

Parameters

NameTypeDescription
mouseMouseEventThe event that arrived.

Returns FocusResult — What became of the event.

SortBy(int)

public void SortBy(int column);

Sorts by a column, or flips the direction when it is already the one being sorted by. Columns without a comparison, and indexes outside the table, are ignored.

Parameters

NameTypeDescription
columnintIndex of the column to sort by.