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