示例#1
0
void
QueryEditor::receive (ScopeDeleted &msg, void* /*client_data*/)
{
  // find the associated button and nuke it
  ON_DEBUG (puts ("QueryEdit: handling delete message"));
  // First find renamed button in our list.
  WidgetList kids = WComposite(f_scope_option.SubMenuId()).Children();
  int num_kids = WComposite(f_scope_option.SubMenuId()).NumChildren();
  int separator_pos = -1;
  for (int i = 0; i < num_kids; i++)
    {
      if (XmIsSeparator (kids[i]))
	separator_pos = i + 1;
      if (msg.f_search_scope ==
	  ((UAS_SearchScope *) WXmPushButton (kids[i]).UserData()))
	break;
    }

  // It had better be in the list! 
  Xassert (i != num_kids);
  ON_DEBUG (printf ("  widget #%d is the button\n", i));

  // if it is selected, select first w/ callback called
  if (kids[i] == f_scope_option.MenuHistory())
    f_scope_option.MenuHistory (kids[1]);
  XtDestroyWidget (kids[i]);

  ON_DEBUG (printf ("QueryEditor: sep pos = %d, kids = %d (%d)\n",
		    separator_pos, num_kids, num_kids - 1));
  if (separator_pos == num_kids - 1)
    {
      ON_DEBUG (puts ("   destroying separator"));
      XtDestroyWidget (kids[separator_pos-1]);
    }
}
示例#2
0
文件: ScopeMenu.C 项目: juddy/edcde
void
ScopeMenu::receive (ScopeDeleted &msg, void *client_data)
{
  // find the associated button and nuke it
  ON_DEBUG (puts ("ScopeMenu: handling delete message"));
  // First find renamed button in our list.
  Arg args[2];
  int n, theKid;
  Cardinal num_kids;
  WidgetList kids;
  int separator_pos = -1;
  Widget selected;

  n = 0;
  XtSetArg(args[n], XmNmenuHistory, &selected); n++;
  XtGetValues(f_option_menu, args, n);

  n = 0;
  XtSetArg(args[n], XmNnumChildren, &num_kids); n++;
  XtSetArg(args[n], XmNchildren, &kids); n++;
  XtGetValues(f_pull_menu, args, n);

  unsigned int i;
  for (i = 0; i < num_kids; i++)
    {
      if (XmIsSeparator (kids[i]))
      {
	separator_pos = i + 1;
        continue;
      }
      if (XmIsPushButtonGadget (kids[i]) &&
	  msg.f_search_scope ==
	  ((UAS_SearchScope *) WXmPushButtonGadget (kids[i]).UserData()))
	break;
    }

  // It had better be in the list! 
  theKid = i;
  Xassert (theKid != (int) num_kids);
  ON_DEBUG (printf ("widget #%d is the button\n", theKid));

  // if it is selected, select first w/ callback called
  if (kids[theKid] == selected)
    {
      n = 0;
      if (XtIsManaged (kids[0]))
	  XtSetArg(args[n], XmNmenuHistory, kids[0]);
      else
	  XtSetArg(args[n], XmNmenuHistory, kids[1]);
      n++;
      XtSetValues(f_option_menu, args, n);
    }

  XtUnmanageChild (kids[theKid]);
  XtDestroyWidget (kids[theKid]);

  // Get rid of the separator if no user scopes remain.
  ON_DEBUG (printf ("ScopeMenu: sep pos = %d, num_kids = %d (%d)\n",
		    separator_pos, num_kids, num_kids -1 -2));
  // - 1 for deleted widget
  if (separator_pos == (int) (num_kids - 1))
    {
      ON_DEBUG (puts ("   destroying separator"));
      XtDestroyWidget (kids[separator_pos-1]);
    }
}