comparison lwlib/lwlib-Xm.c @ 15853:1ca5c3c9853a

(update_one_menu_entry): When creating a pulldown in an existing but empty menu item, in order to get a new functional pulldown, the menu item must be switched from an XmPushButtonGadget into a XmCascadeButtonGadget.
author Richard M. Stallman <rms@gnu.org>
date Sat, 10 Aug 1996 18:48:18 +0000
parents e1e9df8a862e
children 2cb422e2d16c
comparison
equal deleted inserted replaced
15852:8d8800822c78 15853:1ca5c3c9853a
507 507
508 if (!menu) 508 if (!menu)
509 { 509 {
510 if (contents) 510 if (contents)
511 { 511 {
512 menu = XmCreatePulldownMenu (XtParent (widget), XtName (widget), NULL, 0); 512 unsigned int old_num_children, i;
513 Widget button, parent;
514 Widget *widget_list;
515 int buttonchange;
516
517 parent = XtParent (widget);
518 widget_list = XtCompositeChildren (parent, &old_num_children);
519
520 /* Find the widget position within the parent's widget list. */
521 for (i = 0; i < old_num_children; i++)
522 if (strcmp (XtName (widget_list[i]), XtName (widget)) == 0)
523 break;
524 if (i == old_num_children)
525 abort ();
526 /* `buttonchange' indicates the parent button is being
527 exchanged with a CascadeButton. */
528 buttonchange = !XmIsCascadeButton (widget_list[i]);
529 if (buttonchange)
530 XtDestroyWidget (widget_list[i]);
531 menu = XmCreatePulldownMenu (parent, val->name, NULL, 0);
513 make_menu_in_widget (instance, menu, contents, 0); 532 make_menu_in_widget (instance, menu, contents, 0);
514 ac = 0; 533 ac = 0;
515 XtSetArg (al [ac], XmNsubMenuId, menu); ac++; 534 XtSetArg (al [ac], XmNsubMenuId, menu); ac++;
516 XtSetValues (widget, al, ac); 535 /* Non-zero values don't work reliably in
536 conjunction with Emacs' event loop */
537 XtSetArg (al [ac], XmNmappingDelay, 0); ac++;
538 /* Tell Motif to put it in the right place. */
539 XtSetArg (al [ac], XmNpositionIndex, i); ac++;
540 button = XmCreateCascadeButtonGadget (parent, val->name, al, ac);
541 xm_update_label (instance, button, val);
542
543 XtAddCallback (button, XmNcascadingCallback, xm_pull_down_callback,
544 (XtPointer)instance);
545 if (buttonchange)
546 XtManageChild (button);
517 } 547 }
518 } 548 }
519 else if (!contents) 549 else if (!contents)
520 { 550 {
521 ac = 0; 551 ac = 0;
573 if (children) 603 if (children)
574 { 604 {
575 for (i = 0, cur = val->contents; i < num_children_to_keep; i++) 605 for (i = 0, cur = val->contents; i < num_children_to_keep; i++)
576 { 606 {
577 if (!cur) 607 if (!cur)
578 abort (); 608 {
609 num_children_to_keep = i;
610 break;
611 }
579 if (children [i]->core.being_destroyed 612 if (children [i]->core.being_destroyed
580 || strcmp (XtName (children [i]), cur->name)) 613 || strcmp (XtName (children [i]), cur->name))
581 continue; 614 continue;
582 update_one_menu_entry (instance, children [i], cur, deep_p); 615 update_one_menu_entry (instance, children [i], cur, deep_p);
583 cur = cur->next; 616 cur = cur->next;