| 59 UiLayout layout = UI_ARGS2LAYOUT(args); |
59 UiLayout layout = UI_ARGS2LAYOUT(args); |
| 60 |
60 |
| 61 if(args->multiselection) { |
61 if(args->multiselection) { |
| 62 XtSetArg(xargs[n], XmNselectionPolicy, XmEXTENDED_SELECT); n++; |
62 XtSetArg(xargs[n], XmNselectionPolicy, XmEXTENDED_SELECT); n++; |
| 63 } else { |
63 } else { |
| 64 //XtSetArg(xargs[n], XmNselectionPolicy, XmSINGLE_SELECT); n++; |
64 XtSetArg(xargs[n], XmNselectionPolicy, XmSINGLE_SELECT); n++; |
| 65 } |
65 } |
| 66 if(args->height > 0) { |
66 if(args->height > 0) { |
| 67 XtSetArg(xargs[n], XmNheight, args->height); n++; |
67 XtSetArg(xargs[n], XmNheight, args->height); n++; |
| 68 } |
68 } |
| 69 |
69 |
| 305 |
305 |
| 306 if(var) { |
306 if(var) { |
| 307 UiList *list = var->value; |
307 UiList *list = var->value; |
| 308 list->obj = listview; |
308 list->obj = listview; |
| 309 list->update = ui_listview_update; |
309 list->update = ui_listview_update; |
| 310 list->getselection = ui_listview_getselection; |
310 list->getselection = ui_dropdown_getselection; |
| 311 list->setselection = ui_listview_setselection; |
311 list->setselection = ui_dropdown_setselection; |
| 312 ui_listview_update(list, 0); |
312 ui_listview_update(list, 0); |
| 313 } |
313 } |
| 314 |
314 |
| 315 XtAddCallback( |
315 XtAddCallback( |
| 316 widget, |
316 widget, |
| 323 (XtCallbackProc)ui_dropdown_selection, |
323 (XtCallbackProc)ui_dropdown_selection, |
| 324 listview); |
324 listview); |
| 325 |
325 |
| 326 return widget; |
326 return widget; |
| 327 } |
327 } |
| |
328 |
| |
329 void ui_dropdown_setselection(UiList *list, UiListSelection selection) { |
| |
330 UiListView *listview = list->obj; |
| |
331 if(selection.count > 0) { |
| |
332 XtVaSetValues(listview->widget, XmNselectedPosition, selection.rows[0], NULL); |
| |
333 } else { |
| |
334 XtVaSetValues(listview->widget, XmNselectedPosition, 0, NULL); |
| |
335 } |
| |
336 } |
| |
337 |
| |
338 UiListSelection ui_dropdown_getselection(UiList *list) { |
| |
339 UiListView *listview = list->obj; |
| |
340 int pos = -1; |
| |
341 XtVaGetValues(listview->widget, XmNselectedPosition, &pos, NULL); |
| |
342 UiListSelection sel = { 0, NULL }; |
| |
343 if(pos >= 0) { |
| |
344 sel.rows = malloc(sizeof(int)); |
| |
345 sel.rows[0] = pos; |
| |
346 sel.count = 1; |
| |
347 } |
| |
348 return sel; |
| |
349 } |