Exemplo n.º 1
0
void
LibraryNotify::receive (UAS_CollectionRetrievedMsg &message, void *client_data)
{
  ON_DEBUG (printf ("Got Library Notify message!\n"));
  UAS_Pointer<UAS_Common> lib(message.fCol->root());
  search_scope_mgr().insert (lib);
}
Exemplo n.º 2
0
void
ScopeMenu::receive (ScopeRenamed &msg, void *client_data)
{
  ON_DEBUG (puts ("ScopeMenu: handling rename message"));
  // First find renamed button in our list.
  Arg args[2];
  int n;
  Cardinal num_kids;
  WidgetList kids;

  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 (XmIsPushButtonGadget (kids[i]) &&
	  msg.f_search_scope ==
	  ((UAS_SearchScope *) WXmPushButtonGadget (kids[i]).UserData()))
	break;
    }

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

  // Now find the new insertion position in the list.
  int position = 0, old_position = i;
  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 != 0; s++)
    {
      if (s.item() == msg.f_search_scope)
	continue;
      position++;
      if (s.item()->read_only())
	continue;
      ON_DEBUG (printf ("ScopeMenu: strcmp <%s>\n", s.item()->name()));
      if (strcmp (msg.f_search_scope->name(), s.item()->name()) < 0)
	break;
    }

  if (s == NULL)
    position++;

  ON_DEBUG (printf ("ScopeMenu: Rename position = %d, old = %d\n",
		    position, old_position));
  WXmPushButtonGadget scope_btn (kids[i]);
  scope_btn.LabelString (msg.f_search_scope->name());
  if (position != old_position)
    scope_btn.PositionIndex (position);
}
Exemplo n.º 3
0
void
QueryEditor::receive (ScopeCreated &msg, void* /*client_data*/)
{
  int position = 0;
  const char *scope_name = msg.f_search_scope->name();
  xList<UAS_SearchScope *> &scope_list = search_scope_mgr().scope_list();
  List_Iterator<UAS_SearchScope *> s (scope_list);
  bool need_sep = TRUE;

  if (msg.f_search_scope->read_only())
  {
    // insert read-only scopes at the start; reserve position 0
    // for "Current Section" scope and position 1 for
    // the "All Libraries" scope
    position = 2;
    need_sep = FALSE;
  }
  else
  {
    // Scan the current menu to find the correct insertion position. 
    UAS_SearchScope *scope;
    for (; s != NULL; s++, position++)
    {
      scope = s.item();
      if (scope->read_only() != need_sep)
      {
        position++;  // skip separator
        need_sep = FALSE;
      }
      if (scope->read_only())
	continue;
      // Find the first item that the new entry belongs after.
      ON_DEBUG (printf ("Scope Edit strcmp to <%s>\n", s.item()->name()));
      if (strcmp (scope_name, scope->name()) < 0)
	break;
    }
  }

  ON_DEBUG (printf ("Final SE position = %d\n", position));

  // Add a separator if this is the first user-defined entry. 
  if (need_sep == TRUE)
  {
    DECLM (WXmSeparator, separator, f_scope_option.SubMenuId(), "separator");
    separator.PositionIndex (position);
    position++;
  }

  // Create the new toggle button. 
  DECLM (WXmPushButton, scope, f_scope_option.SubMenuId(), scope_name);
  scope.PositionIndex (position);
  scope.UserData (msg.f_search_scope);
}
Exemplo n.º 4
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);
}
Exemplo n.º 5
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);
}
Exemplo n.º 6
0
void
ScopeMenu::receive (UpdateMenu &msg, void *client_data)
{
  xList<UAS_SearchScope *> &scope_list = search_scope_mgr().scope_list();
  List_Iterator<UAS_SearchScope *> s (scope_list);

  int n;
  Arg args[2];
  WidgetList kids;
  Cardinal num_kids;

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

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

  // select current scope
  if(f_use_current_section)
    f_current_scope = s.item();
  else
  {
    s++;
    f_current_scope = s.item();
  }
  fill_menu();
  XtUnmanageChild(XtParent(f_option_menu));
  XtManageChild(XtParent(f_option_menu));
  XtUnmanageChild(f_option_menu);
  XtManageChild(f_option_menu);
}
Exemplo n.º 7
0
void
ScopeMenu::receive (ScopeCreated &msg, void *client_data)
{
  int position = 0;
  const char *scope_name = msg.f_search_scope->name();
  xList<UAS_SearchScope *> &scope_list = search_scope_mgr().scope_list();
  List_Iterator<UAS_SearchScope *> s (scope_list);
  bool need_sep = TRUE;

  int n;
  Arg args[2];
  WidgetList kids;
  Cardinal num_kids;

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

  UAS_SearchScope *scope;

  if (msg.f_search_scope->read_only())
  {
    // insert read-only scopes at the start; reserve position 0
    // for "Current Section" scope and position 1 for
    // the "All Libraries" scope
    position = 2;
    need_sep = FALSE;
  }
  else
  {
    // Scan the current menu to find the correct insertion position. 
    for (; s != 0; s++, position++)
    {
      scope = s.item();
      if (need_sep != scope->read_only())
      {
        position++;  // skip separator
        need_sep = FALSE;
      }
      if (scope->read_only())
	continue;
      // Find the first item that the new entry belongs after.
      ON_DEBUG (printf ("Scope strcmp to <%s>\n", scope->name()));
      if (strcmp (scope_name, scope->name()) < 0)
	break;
    }
  }

  ON_DEBUG (printf ("Final position = %d\n", position));

  // Add a separator if this is the first user-defined entry. 
  if (need_sep == TRUE)
  {
    DECLM (WXmSeparator, separator, f_pull_menu, "separator");
    separator.PositionIndex (position);
    position++;
  }

  // Create the new toggle button. 
  DECLM (WXmPushButtonGadget, scope_btn, f_pull_menu, scope_name);
  scope_btn.PositionIndex (position);
  scope_btn.UserData (msg.f_search_scope);
  WCallback *cb = SET_CALLBACK(scope_btn,Activate,set_scope);
  SET_CALLBACK_D(scope_btn,Destroy,destroy_scope,cb);
}
Exemplo n.º 8
0
void
ScopeMenu::fill_menu()
{
  int position = 0;
  Wait_Cursor bob;

  // Create toggle 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;

  // Set the current scope to the first entry
  //  (Current Section or Information Library) 
  f_current_scope = s.item();

  ON_DEBUG(cerr << "Scope Popup" << endl);

  int first = TRUE;
  for (; s != 0; s++)
    {
      
      // in case we are not using Current Section
      if (f_current_scope == NULL)
	f_current_scope = s.item();

      ON_DEBUG(cerr << "\t" << f_current_scope->name() << endl);
//    ON_DEBUG(f_current_scope->dump_items());

      // Add a separator when they change from read only to changable. 
      if (old_read_only != s.item()->read_only())
	{
	  DECLM (WXmSeparator, sep1, f_pull_menu, "separator");
          sep1.PositionIndex (position++);
	  old_read_only = FALSE;
	}
      DECLM (WXmPushButtonGadget, scope, f_pull_menu, s.item()->name());
      if (first && !f_use_current_section)
	{
	  first = FALSE;
	  scope.Unmanage();
	  // Reset current scope so that it is set to Library on next pass.
	  f_current_scope = NULL;
	}
      scope.UserData (s.item());
      scope.PositionIndex (position++);

      WCallback *cb = SET_CALLBACK(scope,Activate,set_scope);
      SET_CALLBACK_D (scope,Destroy,destroy_scope,cb);
      if (f_current_scope == s.item())
	{
	  Arg args[1];
	  int n = 0;
	  XtSetArg(args[n], XmNmenuHistory, (Widget)scope); n++;
	  XtSetValues(f_option_menu, args, n);
	}
    }

  //UAS_SearchScope::request ((UAS_Receiver<ScopeCreated> *) this);
  //UAS_SearchScope::request ((UAS_Receiver<ScopeDeleted> *) this);
  //UAS_SearchScope::request ((UAS_Receiver<ScopeRenamed> *) this);
}
Exemplo n.º 9
0
void
LibraryNotify::receive (UAS_LibraryDestroyedMsg &message, void *client_data)
{
  ON_DEBUG (printf ("Got Library Notify message!\n"));
  search_scope_mgr().remove (message.fLib);
}
Exemplo n.º 10
0
// /////////////////////////////////////////////////////////////////////////
// scope - activate search scope dialog
// /////////////////////////////////////////////////////////////////////////
void
QueryEditor::scope()
{
  search_scope_mgr().display();
}
Exemplo n.º 11
0
void
QueryEditor::create_ui()
{
  Wait_Cursor bob;

  XmStringLocalized mtfstring;
  String	    string;
  KeySym	    mnemonic;

  f_shell = WTopLevelShell(window_system().toplevel(), WPopup, "query_editor");
  window_system().register_shell (&f_shell);

  string = CATGETS(Set_QueryEditor, 1, "Dtinfo: Query Editor");
  XtVaSetValues((Widget)f_shell, XmNtitle, string, NULL);

  // Main form and menu bar. 
  WXmForm form                      (f_shell,    "form"                );
  WXmMenuBar menu_bar               (form,       "menu_bar"            );

  WXmPulldownMenu scope_menu        (form,       "scope_menu");
  Arg args[1];
  int n = 0;
  XtSetArg(args[n], XmNsubMenuId, (Widget) scope_menu); n++;
  f_scope_option = WXmOptionMenu    (form,       "scope_option", AM, args, n);

  mtfstring = CATGETS(Set_AgentLabel, 212, "Scope Name");
  XtVaSetValues(f_scope_option, XmNlabelString, (XmString)mtfstring, NULL);

  // Menu definitions.   how about using AddPushButton (name, obj, fun)??
  WXmCascadeButton edit_cascade     (menu_bar,   "edit",             AM);
  WXmPulldownMenu edit_menu         (menu_bar,   "edit_menu"           );
  f_cut_btn = WXmPushButton         (edit_menu,  "cut",              AM);
  f_copy_btn = WXmPushButton        (edit_menu,  "copy",             AM);
  f_paste_btn = WXmPushButton       (edit_menu,  "paste",            AM);
  f_paste_btn = WXmPushButton       (edit_menu,  "new_term",         AM);
  WXmSeparator group_sep            (edit_menu,  "group_sep",        AM);
  f_group_btn = WXmPushButton       (edit_menu,  "group",            AM);
  f_ungroup_btn = WXmPushButton     (edit_menu,  "ungroup",          AM);
  WXmSeparator undo_sep             (edit_menu,  "undo_sep",         AM);
  f_undo_btn = WXmPushButton        (edit_menu,  "undo",             AM);
  f_redo_btn = WXmPushButton        (edit_menu,  "redo",             AM);

  mtfstring =  CATGETS(Set_AgentLabel, 16, "Edit");
  mnemonic  = *CATGETS(Set_AgentLabel, 17, "E");
  XtVaSetValues(edit_cascade, XmNlabelString, (XmString)mtfstring,
			      XmNmnemonic, mnemonic, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 224, "Cut");
  XtVaSetValues(f_cut_btn, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 18, "Copy");
  XtVaSetValues(f_copy_btn, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 225, "Paste");
  XtVaSetValues(f_paste_btn, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 226, "Group");
  XtVaSetValues(f_group_btn, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 227, "Ungroup");
  XtVaSetValues(f_ungroup_btn, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 228, "Undo");
  XtVaSetValues(f_undo_btn, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 229, "Redo");
  XtVaSetValues(f_redo_btn, XmNlabelString, (XmString)mtfstring, NULL);

  // Button area at the bottom 
  WXmForm hform                     (form,       "hform"               );
  f_hist_prev = WXmArrowButton      (hform,      "hist_prev",        AM);
  f_hist_next = WXmArrowButton      (hform,      "hist_next",        AM);
  WXmLabel history                  (hform,      "history",          AM);
  f_search_btn = WXmPushButton      (form,       "search",           AM);
  WXmPushButton cancel              (form,       "cancel",           AM);
  WXmPushButton clear               (form,       "clear",            AM);
  WXmPushButton scope		    (form,	 "scope",	     AM);
  WXmPushButton help                (form,       "help",             AM);
  WXmSeparator separator            (form,       "separator",        AM);

  mtfstring =  CATGETS(Set_AgentLabel, 92, "History");
  XtVaSetValues(history, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 102, "Search");
  XtVaSetValues(f_search_btn, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 231, "Clear All");
  XtVaSetValues(clear, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 46, "Scope Editor");
  XtVaSetValues(scope, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 12, "Close");
  XtVaSetValues(cancel, XmNlabelString, (XmString)mtfstring, NULL);
  mtfstring =  CATGETS(Set_AgentLabel, 48, "Help");
  XtVaSetValues(help, XmNlabelString, (XmString)mtfstring, NULL);

  help_agent().add_activate_help (help, "query_editor_help");

  // Main "work" area 
  WXmPanedWindow pane               (form,       "pane"                );
  WXmForm qform                     (pane,       "qform"               );
  WXmLabel qlabel                   (qform,      "qlabel",           AM);

  mtfstring =  CATGETS(Set_AgentLabel, 230, "Query");
  XtVaSetValues(qlabel, XmNlabelString, (XmString)mtfstring, NULL);
  
  f_query_text = WXmScrolledText    (qform,      "qtext",            AM);
//  f_query_text.SetEditable(False);
  f_query_area = WXmScrolledWindow  (pane,       "query_area",       AM);
  XtUnmanageChild (f_query_area.HorizontalScrollBar());

  edit_cascade.SubMenuId (edit_menu);

  // Callbacks
  ON_ACTIVATE (f_search_btn, search_activate);
  ON_ACTIVATE (cancel, cancel);
  ON_ACTIVATE (clear, clear);
  ON_ACTIVATE (scope, scope);

//  f_query_text.SetFocusCallback (this,
//			    (WWL_FUN) &QueryEditor::modify_verify);
//  f_query_text.SetModifyVerifyCallback (this,
//			    (WWL_FUN) &QueryEditor::modify_verify);

  // Set minimum sizes.
  qform.Manage();
  pane.Manage();
  //  hform.Manage();
  form.DefaultButton (f_search_btn);
  form.ShadowThickness (0);

  form.InitialFocus (pane);
  pane.InitialFocus (f_query_area);
  qform.PaneMinimum (f_query_text.Height());
  form.Manage();

  f_shell.Realize();
  f_shell.MinWidth (f_shell.Width());
  f_shell.MinHeight (f_shell.Height());
  ON_DEBUG(printf ("Query for height = %d\n", qform.Height()));
  //cerr << "Query for height = " << qform.Height() << endl;

//#ifndef UseFJMTF
#if 1
  // Swap the entries in the pane around.  Have to do this now
  // to get initial sizes right.
  qform.PositionIndex (1);
#endif

  fill_menu();

  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);
}