DVX_GUI/widgets/listView/listView.dhs

111 lines
3.7 KiB
Text

.section Widgets
.topic widget.listview
.title ListView
.toc 0 ListView
.index ListView
.index wgtListView
.index wgtListViewSetColumns
.index wgtListViewSetData
.index ListViewColT
.index ListViewSortE
.h2 ListView
A multi-column list with sortable headers. Supports single and multi-selection, column alignment, header click sorting, and drag-to-reorder. Data is provided as a flat array of strings (row-major order, one string per cell).
Header: widgets/widgetListView.h
.h3 Creation
.code
WidgetT *lv = wgtListView(parent);
ListViewColT cols[] = {
{ "Name", wgtChars(20), ListViewAlignLeftE },
{ "Size", wgtChars(10), ListViewAlignRightE }
};
wgtListViewSetColumns(lv, cols, 2);
const char *cells[] = { "file.txt", "1234", "readme.md", "5678" };
wgtListViewSetData(lv, cells, 2);
.endcode
.h3 Column Definition
.code
typedef struct {
const char *title;
int32_t width; // tagged size (wgtPixels/wgtChars/wgtPercent, 0 = auto)
ListViewAlignE align; // ListViewAlignLeftE, ListViewAlignCenterE, ListViewAlignRightE
} ListViewColT;
.endcode
.h3 Sort Direction
.code
typedef enum {
ListViewSortNoneE,
ListViewSortAscE,
ListViewSortDescE
} ListViewSortE;
.endcode
.h3 Macros
.index wgtListViewGetSelected
.index wgtListViewSetSelected
.index wgtListViewSetSort
.index wgtListViewSetHeaderClickCallback
.index wgtListViewSetMultiSelect
.index wgtListViewSelectAll
.index wgtListViewClearSelection
.index wgtListViewSetReorderable
.table
Macro Description
----- -----------
wgtListView(parent) Create a list view.
wgtListViewSetColumns(w, cols, count) Define columns from an array of ListViewColT.
wgtListViewSetData(w, cellData, rowCount) Set row data. cellData is a flat const char ** array of size rowCount * colCount.
wgtListViewGetSelected(w) Get the index of the selected row (-1 if none).
wgtListViewSetSelected(w, idx) Set the selected row by index.
wgtListViewSetSort(w, col, dir) Set the sort column and direction.
wgtListViewSetHeaderClickCallback(w, cb) Set a callback for header clicks. Signature: void (*cb)(WidgetT *w, int32_t col, ListViewSortE dir).
wgtListViewSetMultiSelect(w, multi) Enable or disable multi-selection.
wgtListViewIsItemSelected(w, idx) Check if a specific row is selected.
wgtListViewSetItemSelected(w, idx, selected) Select or deselect a specific row.
wgtListViewSelectAll(w) Select all rows.
wgtListViewClearSelection(w) Deselect all rows.
wgtListViewSetReorderable(w, reorderable) Enable drag-to-reorder of rows.
.endtable
.h3 Events
.table
Callback Description
-------- -----------
onClick Fires when a row is clicked.
onDblClick Fires when a row is double-clicked.
onChange Fires when the selection changes.
.endtable
.h3 Properties (BASIC Interface)
.table
Property Type Access Description
-------- ---- ------ -----------
ListIndex Integer Read/Write Index of the currently selected row.
.endtable
.h3 Methods (BASIC Interface)
.table
Method Description
------ -----------
SelectAll Select all rows.
ClearSelection Deselect all rows.
SetMultiSelect Enable or disable multi-selection.
SetReorderable Enable or disable drag-to-reorder.
IsItemSelected Check if a specific row is selected by index.
SetItemSelected Select or deselect a specific row by index.
.endtable
.hr