示例#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
void
QueryEditor::fill_menu()
{
  int position = 0;
  // Create push buttons for each scope.
  xList<UAS_SearchScope *> &scope_list = search_scope_mgr().scope_list();
  List_Iterator<UAS_SearchScope *> s (scope_list);
  bool old_read_only = TRUE;

  for (; s != NULL; s++)
    {
      // Add a separator when they change from read only to changable. 
      if (old_read_only != s.item()->read_only())
	{
	  DECLM (WXmSeparator, sep1, f_scope_option.SubMenuId(), "separator");
          sep1.PositionIndex (position++);
	  old_read_only = FALSE;
	}
      DECLM (WXmPushButton, scope,f_scope_option.SubMenuId(),s.item()->name());
      scope.UserData (s.item());
      scope.PositionIndex (position++);
    }

  // Do not want first item (Current Section)

#ifdef __osf__
#if 1
  Widget w = f_scope_option.SubMenuId();
  WComposite temp_composite(w);
  WXmPushButton(temp_composite.Children()[0]).Unmanage();
#else
  int i = 0;
  Widget w = f_scope_option.SubMenuId();;
  Arg args[1];
  WidgetList wl;
  
  XtSetArg(args[i], XmNchildren, &wl); i++;
  XtGetValues(w, args, i);
  XtUnmanageChild(wl[0]);
#endif
#else
  WXmPushButton(WComposite(f_scope_option.SubMenuId()).Children()[0]).Unmanage();
#endif

  f_scope_option.
      MenuHistory (WComposite(f_scope_option.SubMenuId()).Children()[1]);
  
  //UAS_SearchScope::request ((UAS_Receiver<ScopeCreated> *) this);
  //UAS_SearchScope::request ((UAS_Receiver<ScopeDeleted> *) this);
  //UAS_SearchScope::request ((UAS_Receiver<ScopeRenamed> *) this);
//
  //search_scope_mgr().option_menu(this);
}
示例#3
0
void
QueryEditor::update_option_menu()
{
  WidgetList kids = WComposite(f_scope_option.SubMenuId()).Children();
  int num_kids = WComposite(f_scope_option.SubMenuId()).NumChildren();

  // destroy all toggle buttons in menu
  for (int i = 0; i < num_kids; i++)
  {
    XtUnmanageChild (kids[i]);
    XtDestroyWidget (kids[i]);
  }

  fill_menu();
}
示例#4
0
void
QueryEditor::receive (ScopeRenamed &msg, void* /*client_data*/)
{
  ON_DEBUG (puts ("QueryEdit: handling rename 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();
  for (int i = 0; i < num_kids; i++)
    {
      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 ("QueryEdit: widget #%d is the button\n", i));

  // Now find the new insertion position in the list.
  int position = 0;
  xList<UAS_SearchScope *> &scope_list = search_scope_mgr().scope_list();
  List_Iterator<UAS_SearchScope *> s (scope_list);

  // find the new position in the list
  for (; s != NULL; s++)
    {
      if (s.item() == msg.f_search_scope)
	continue;
      position++;
      if (s.item()->read_only())
	continue;
      ON_DEBUG (printf ("QueryEdit: strcmp <%s>\n", s.item()->name()));
      if (strcmp (msg.f_search_scope->name(), s.item()->name()) < 0)
	break;
    }

  ON_DEBUG (printf ("QueryEdit: Rename position = %d\n", position));
  WXmPushButton scope_btn (kids[i]);
  scope_btn.LabelString (msg.f_search_scope->name());
  scope_btn.PositionIndex (position);
}
示例#5
0
QueryGroupView::QueryGroupView (QueryGroup *group, Widget parent)
: f_query_group (group),
  f_term_view_list (NULL)
{
  f_restraint = WRestraint (WComposite (parent), "group_view", WAutoManage);
  f_form = WXmForm (f_restraint, "group_form");

  QueryTermView *view = NULL;
  QueryTerm *term;

  for (term= group->term_list(); term != NULL; term = term->next())
    view = new QueryTermView (term, this, view, NULL);

  f_form.Realize();  // This statement is extremely critical.  02/03/93 DJB 
  f_form.Manage();

  // Need special event handler for top level group to catch
  // resizes of window and resize the query view.
  // NOTE: It's just about time to move this to another method. 
  if (XtClass (XtParent (f_restraint)) == xmDrawingAreaWidgetClass)
    {
      // Let's see what the parent's size is now:
      ON_DEBUG(printf ("Drawing area is width: %d, height: %d\n",
		       WCore(f_restraint.Parent()).Width(),
		       WCore(f_restraint.Parent()).Height()));
      // We need to grow the drawing area if it is smaller than the
      // restraint widget, since we don't deal with horizontal scrolling.
      Dimension restraint_width = f_restraint.Width();
      Dimension da_width = WCore(f_restraint.Parent()).Width();
      
      if (da_width < restraint_width)
	{
	  // Can't resize the drawing area because the ^$&(*% Motif
	  // pane widget will not allow the horizontal resize.  So,
	  // instead calculate the size increase and do it on the shell. 
	  Dimension increase = restraint_width - da_width;
	  // Find the shell widget. 
	  Widget w = f_restraint.Parent();
	  while (!XtIsShell (w))
	    w = XtParent(w);
	  WTopLevelShell shell (w);

	  ON_DEBUG(printf ("** Resizing shell by = %d\n", increase));

	  // Change state if needed. 
	  Boolean allow_resize = shell.AllowShellResize();
	  if (!allow_resize)
	    shell.AllowShellResize (True);
	  // Change the width. 
	  shell.MinWidth (shell.Width() + increase);
	  shell.Width (shell.Width() + increase);
	  // Restore state if needed. 
	  if (!allow_resize)
	    shell.AllowShellResize (False);
	}
      else if (da_width > restraint_width)
	{
	  f_restraint.Width (WCore(f_restraint.Parent()).Width());
	}
      
      XtAddEventHandler (XtParent (f_restraint), StructureNotifyMask, False,
			 (XtEventHandler) &QueryGroupView::resize,
			 (Widget) f_restraint);
      // Store the min width in UserData...
      f_restraint.UserData ((XtPointer)(size_t) f_restraint.Width());
    }
  // Make sure the restraint widget isn't too narrow.
  else
    {
      f_restraint.Width (WCore(f_restraint.Parent()).Width());
    }
}