# HG changeset patch # User Olaf Wintermann # Date 1765625861 -3600 # Node ID 287b20e2a5648b79a3277f0e07d5153fe13be382 # Parent 61b811c4705f0cd72ee8cfd7d9d8e09909654411 add support for static elements in the listview/dropdown (Win32) diff -r 61b811c4705f -r 287b20e2a564 application/main.c --- a/application/main.c Sat Dec 13 12:19:55 2025 +0100 +++ b/application/main.c Sat Dec 13 12:37:41 2025 +0100 @@ -1254,7 +1254,14 @@ //UiModel *model = ui_model(obj->ctx, UI_STRING, "Name", UI_STRING, "Email", -1); //ui_table(obj, .fill = TRUE, .varname = "persons", .model = model, .getvalue = person_getvalue, .onselection = list_onselection); //ui_model_free(obj->ctx, model); - ui_dropdown(obj, .varname = "persons", .getvalue = person_getvalue, .onactivate = list_onselection, .hexpand = TRUE, .hfill = TRUE); + //ui_dropdown(obj, .varname = "persons", .getvalue = person_getvalue, .onactivate = list_onselection, .hexpand = TRUE, .hfill = TRUE); + char *list[] = { + "test 1", + "test 2", + "test 3", + "test 4" + }; + ui_dropdown(obj, .static_elements = list, .static_nelm = 4); ui_button(obj, .label = "Test 1"); ui_newline(obj); diff -r 61b811c4705f -r 287b20e2a564 ui/common/properties.c --- a/ui/common/properties.c Sat Dec 13 12:19:55 2025 +0100 +++ b/ui/common/properties.c Sat Dec 13 12:37:41 2025 +0100 @@ -234,7 +234,7 @@ // try creating the parent int err = ui_mkdir(parent); if(err) { - fprintf(stderr, "Error: Cannot create directory %s: %s\n", strerror(errno)); + fprintf(stderr, "Error: Cannot create directory %s: %s\n", parent, strerror(errno)); free(parent); free(dir); return; @@ -290,7 +290,7 @@ int ret = 0; CxMapIterator i = cxMapIterator(application_properties); cx_foreach(CxMapEntry *, entry, i) { - fprintf(file, "%.*s = %s\n", (int)entry->key->len, entry->key->data, entry->value); + fprintf(file, "%.*s = %s\n", (int)entry->key->len, (char*)entry->key->data, (char*)entry->value); } cxMapRehash(application_properties); diff -r 61b811c4705f -r 287b20e2a564 ui/win32/list.c --- a/ui/win32/list.c Sat Dec 13 12:19:55 2025 +0100 +++ b/ui/win32/list.c Sat Dec 13 12:37:41 2025 +0100 @@ -170,6 +170,19 @@ list->setselection = ui_listview_setselection; 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;igetvalue = strmodel_getvalue; + listview->getvaluedata = NULL; } return (W32Widget*)listview; @@ -387,9 +400,16 @@ list->setselection = ui_dropdown_setselection; 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;igetvalue = strmodel_getvalue; + dropdown->getvaluedata = NULL; } - return (W32Widget*)dropdown; } diff -r 61b811c4705f -r 287b20e2a564 ui/win32/window.c --- a/ui/win32/window.c Sat Dec 13 12:19:55 2025 +0100 +++ b/ui/win32/window.c Sat Dec 13 12:37:41 2025 +0100 @@ -111,11 +111,11 @@ } UiObject *ui_window(const char *title) { - return create_window(title, window_data, FALSE); + return create_window(title, FALSE); } UiObject *ui_simple_window(const char *title) { - return create_window(title, window_data, TRUE); + return create_window(title, TRUE); } int ui_window_widget_event(W32Widget *widget, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {