ui/motif/toolbar.c

changeset 153
ee49d1852a5f
parent 117
38c53b8a6139
child 157
0b33b9396851
equal deleted inserted replaced
152:62921b370c60 153:ee49d1852a5f
147 } 147 }
148 148
149 void ui_toolbar_combobox( 149 void ui_toolbar_combobox(
150 char *name, 150 char *name,
151 UiList *list, 151 UiList *list,
152 ui_model_getvalue_f getvalue, 152 ui_getvaluefunc getvalue,
153 ui_callback f, 153 ui_callback f,
154 void *udata) 154 void *udata)
155 { 155 {
156 UiToolbarComboBox *cb = malloc(sizeof(UiToolbarComboBox)); 156 UiToolbarComboBox *cb = malloc(sizeof(UiToolbarComboBox));
157 cb->item.add_to = (ui_toolbar_add_f)add_toolbar_combobox; 157 cb->item.add_to = (ui_toolbar_add_f)add_toolbar_combobox;
173 } 173 }
174 174
175 void ui_toolbar_combobox_nv( 175 void ui_toolbar_combobox_nv(
176 char *name, 176 char *name,
177 char *listname, 177 char *listname,
178 ui_model_getvalue_f getvalue, 178 ui_getvaluefunc getvalue,
179 ui_callback f, 179 ui_callback f,
180 void *udata) 180 void *udata)
181 { 181 {
182 UiToolbarComboBoxNV *cb = malloc(sizeof(UiToolbarComboBoxNV)); 182 UiToolbarComboBoxNV *cb = malloc(sizeof(UiToolbarComboBoxNV));
183 cb->item.add_to = (ui_toolbar_add_f)add_toolbar_combobox_nv; 183 cb->item.add_to = (ui_toolbar_add_f)add_toolbar_combobox_nv;
332 void add_toolitem_st_toggle_widget(Widget parent, UiStToolItem *item, UiObject *obj) { 332 void add_toolitem_st_toggle_widget(Widget parent, UiStToolItem *item, UiObject *obj) {
333 333
334 } 334 }
335 335
336 void add_toolbar_combobox(Widget tb, UiToolbarComboBox *item, UiObject *obj) { 336 void add_toolbar_combobox(Widget tb, UiToolbarComboBox *item, UiObject *obj) {
337 UiListPtr *listptr = ucx_mempool_malloc(
338 obj->ctx->mempool,
339 sizeof(UiListPtr));
340 UiListView *listview = ucx_mempool_malloc( 337 UiListView *listview = ucx_mempool_malloc(
341 obj->ctx->mempool, 338 obj->ctx->mempool,
342 sizeof(UiListView)); 339 sizeof(UiListView));
343 listptr->list = item->list; 340
341 UiVar *var = ucx_mempool_malloc(obj->ctx->mempool, sizeof(UiVar));
342 var->value = item->list;
343 var->type = UI_VAR_SPECIAL;
344 344
345 Arg args[8]; 345 Arg args[8];
346 XtSetArg(args[0], XmNshadowThickness, 1); 346 XtSetArg(args[0], XmNshadowThickness, 1);
347 XtSetArg(args[1], XmNindicatorOn, XmINDICATOR_NONE); 347 XtSetArg(args[1], XmNindicatorOn, XmINDICATOR_NONE);
348 XtSetArg(args[2], XmNtraversalOn, FALSE); 348 XtSetArg(args[2], XmNtraversalOn, FALSE);
349 XtSetArg(args[3], XmNwidth, 120); 349 XtSetArg(args[3], XmNwidth, 120);
350 Widget combobox = XmCreateDropDownList(tb, "toolbar_combobox", args, 4); 350 Widget combobox = XmCreateDropDownList(tb, "toolbar_combobox", args, 4);
351 XtManageChild(combobox); 351 XtManageChild(combobox);
352 listview->widget = combobox; 352 listview->widget = combobox;
353 listview->list = listptr; 353 listview->list = var;
354 listview->getvalue = item->getvalue; 354 listview->getvalue = item->getvalue;
355 355
356 ui_listview_update(NULL, listview); 356 ui_listview_update(NULL, listview);
357
358 listptr->list->observers = ui_add_observer(
359 listptr->list->observers,
360 (ui_callback)ui_listview_update,
361 listview);
362 357
363 if(item->callback) { 358 if(item->callback) {
364 // TODO: 359 // TODO:
365 360
366 } 361 }

mercurial