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