ui/motif/menu.c

branch
newapi
changeset 421
3b969399f962
parent 420
28a5920bebe0
equal deleted inserted replaced
420:28a5920bebe0 421:3b969399f962
214 ls->index = i; 214 ls->index = i;
215 ls->oldcount = 0; 215 ls->oldcount = 0;
216 ls->getvalue = il->getvalue; 216 ls->getvalue = il->getvalue;
217 ls->callback = il->callback; 217 ls->callback = il->callback;
218 ls->userdata = il->userdata; 218 ls->userdata = il->userdata;
219 ls->addseparator = TRUE; 219 ls->addseparator = il->addseparator;
220 220
221 ls->var = uic_create_var(ui_global_context(), il->varname, UI_VAR_LIST); //uic_widget_var(obj->ctx, obj->ctx, NULL, il->varname, UI_VAR_LIST); 221 ls->var = uic_create_var(ui_global_context(), il->varname, UI_VAR_LIST); //uic_widget_var(obj->ctx, obj->ctx, NULL, il->varname, UI_VAR_LIST);
222 UiList *list = ls->var->value; 222 UiList *list = ls->var->value;
223 223
224 UiObserver *observer = ui_observer_new((ui_callback)ui_update_menuitem_list, ls); 224 UiObserver *observer = ui_observer_new((ui_callback)ui_update_menuitem_list, ls);
258 } 258 }
259 259
260 void* elm = ui_list_first(ls); 260 void* elm = ui_list_first(ls);
261 int i = 0; 261 int i = 0;
262 if(elm && list->addseparator) { 262 if(elm && list->addseparator) {
263 Widget s = XmCreateSeparatorGadget(list->menu, "menuseparator", NULL, 0); 263 XtSetArg(args[0], XmNpositionIndex, list->index);
264 Widget s = XmCreateSeparatorGadget(list->menu, "menuseparator", args, 1);
264 XtManageChild(s); 265 XtManageChild(s);
265 i++; 266 i++;
266 } 267 }
267 268
268 ui_getvaluefunc getvalue = list->getvalue; 269 ui_getvaluefunc getvalue = list->getvalue;
270 int pos = list->index;
269 while(elm) { 271 while(elm) {
270 n = 0; 272 n = 0;
271 char *label = (char*) (getvalue ? getvalue(elm, 0) : elm); 273 char *label = (char*) (getvalue ? getvalue(elm, 0) : elm);
272 if(label) { 274 if(label) {
273 s = XmStringCreateLocalized(label); 275 s = XmStringCreateLocalized(label);
274 XtSetArg(args[n], XmNlabelString, s); n++; 276 XtSetArg(args[n], XmNlabelString, s); n++;
275 } 277 }
276 278 XtSetArg(args[n], XmNpositionIndex, pos+i); n++;
279
277 Widget mitem = XtCreateManagedWidget( 280 Widget mitem = XtCreateManagedWidget(
278 "menubutton", 281 "menubutton",
279 xmPushButtonWidgetClass, 282 xmPushButtonWidgetClass,
280 list->menu, 283 list->menu,
281 args, 284 args,

mercurial