--- a/ui/win32/list.c Sat Dec 13 12:51:57 2025 +0100 +++ b/ui/win32/list.c Sat Dec 13 12:52:38 2025 +0100 @@ -166,18 +166,30 @@ UiList *list = listview->var->value; list->obj = listview; list->update = ui_listview_update; - list->getselection = ui_listview_getselection; - list->setselection = ui_listview_setselection; + list->getselection = ui_listview_getselection_impl; + list->setselection = ui_listview_setselection_impl; ui_listview_update(list, -1); + } else if (!table && args->static_elements && args->static_nelm > 0) { + char **static_elements = args->static_elements; + size_t static_nelm = args->static_nelm; + LVITEM item; + item.mask = LVIF_TEXT; + item.iSubItem = 0; + for (int i=0;i<static_nelm;i++) { + item.iItem = i; + item.pszText = static_elements[i]; + ListView_InsertItem(hwnd, &item); + } + listview->getvalue = strmodel_getvalue; + listview->getvaluedata = NULL; } return (W32Widget*)listview; } -static UiListSelection listview_get_selection(UiListView *listview) { +static UiListSelection listview_get_selection2(HWND hwnd) { UiListSelection sel = { 0, NULL }; - HWND hwnd = listview->widget.hwnd; CX_ARRAY_DECLARE(int, indices); cx_array_initialize(indices, 8); @@ -195,6 +207,11 @@ return sel; } +static UiListSelection listview_get_selection(UiListView *listview) { + HWND hwnd = listview->widget.hwnd; + return listview_get_selection2(hwnd); +} + // listview class event proc int ui_listview_eventproc(W32Widget *widget, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { UiListView *listview = (UiListView*)widget; @@ -327,12 +344,12 @@ } } -UiListSelection ui_listview_getselection(UiList *list) { +UiListSelection ui_listview_getselection_impl(UiList *list) { UiListView *listview = (UiListView*)list->obj; return listview_get_selection(listview); } -void ui_listview_setselection(UiList *list, UiListSelection selection) { +void ui_listview_setselection_impl(UiList *list, UiListSelection selection) { } @@ -346,6 +363,20 @@ return listview_create(obj, args, TRUE); } +void ui_listview_select(UIWIDGET listview, int index) { + +} + +int ui_listview_selection(UIWIDGET listview) { + W32Widget *w = (W32Widget*)listview; + UiListSelection sel = listview_get_selection2(w->hwnd); + int index = -1; + if (sel.count > 0) { + index = sel.rows[0]; + } + free(sel.rows); + return index; +} /* ------------------------------------ DropDown ------------------------------------*/ @@ -383,13 +414,20 @@ UiList *list = dropdown->var->value; list->obj = dropdown; list->update = ui_dropdown_update; - list->getselection = ui_dropdown_getselection; - list->setselection = ui_dropdown_setselection; + list->getselection = ui_dropdown_getselection_impl; + list->setselection = ui_dropdown_setselection_impl; ui_dropdown_update(list, -1); + } else if (args->static_elements && args->static_nelm > 0) { + char **static_elements = args->static_elements; + size_t static_nelm = args->static_nelm; + for (int i=0;i<static_nelm;i++) { + SendMessage(hwnd, CB_ADDSTRING, 0, (LPARAM)static_elements[i]); + } + dropdown->getvalue = strmodel_getvalue; + dropdown->getvaluedata = NULL; } - return (W32Widget*)dropdown; } @@ -437,7 +475,7 @@ } } -UiListSelection ui_dropdown_getselection(UiList *list) { +UiListSelection ui_dropdown_getselection_impl(UiList *list) { UiListSelection sel = { 0, NULL }; UiListView *listview = (UiListView*)list->obj; int index = (int)SendMessage(listview->widget.hwnd, CB_GETCURSEL, 0, 0); @@ -449,7 +487,15 @@ return sel; } -void ui_dropdown_setselection(UiList *list, UiListSelection selection) { +void ui_dropdown_setselection_impl(UiList *list, UiListSelection selection) { UiListView *listview = (UiListView*)list->obj; SendMessage(listview->widget.hwnd, CB_SETCURSEL, 0, 0); } + +void ui_dropdown_select(UIWIDGET dropdown, int index) { + SendMessage(dropdown->hwnd, CB_SETCURSEL, 0, 0); +} + +int ui_dropdown_selection(UIWIDGET dropdown) { + return SendMessage(dropdown->hwnd, CB_GETCURSEL, 0, 0); +}