/*----------------------------------------------------------------------*/ /* X-Windows subroutines */ /*----------------------------------------------------------------------*/ #include #include "function_exp.h" #include "graph_exp.h" #include "net_exp.h" #include "menu_exp.h" XtActionsRec actionTable[] = { {"Ok", Ok} }; /*******Function Wprintf print a formatted string to the message widget */ Wprintf() { Arg wargs[1]; XtSetArg(wargs[0], XtNstring, msgstring); XtSetValues(message, wargs, 1); } /*******Function ToggleExcl marks a menu item */ ToggleExcl(widget, menu, first_item, last_item) Widget widget; menu_struct *menu; int first_item, last_item; { Arg args[1]; Widget parent = XtParent(widget); Widget sibling; int i; for (i = first_item; i <= last_item; i++) { sibling = XtNameToWidget(parent, menu[i].name); XtSetArg(args[0], XtNsetMark, FALSE); XtSetValues(sibling, args, 1); } XtSetArg(args[0], XtNsetMark, TRUE); XtSetValues(widget, args, 1); } /*******Function Toggle marks or unmarks a menu item */ Toggle(widget) Widget widget; { Arg args[1]; Boolean type; XtSetArg(args[0], XtNsetMark, &type); XtGetValues(widget, args, 1); if (type == TRUE) XtSetArg(args[0], XtNsetMark, FALSE); else XtSetArg(args[0], XtNsetMark, TRUE); XtSetValues(widget, args, 1); } /*******Function create_pane responsible for hierarchical sub-menus */ create_pane(mgr, mgrname, name, menulist, nitems) Widget mgr; char *name, *mgrname; menu_struct *menulist; int nitems; { Arg wargs[1]; Widget menupane, pane_shell; int i, n; WidgetList buttons; buttons = (WidgetList) XtMalloc (nitems * sizeof (Widget)); pane_shell = XtCreatePopupShell ("pane_shell", transientShellWidgetClass, mgr, NULL, ZERO); XtSetArg (wargs[0], XtNattachTo, (XtArgVal) mgrname); menupane = XtCreateManagedWidget (name, XwcascadeWidgetClass, pane_shell, wargs, 1); for (i = 0; i < nitems; i++) { n = 0; if (menulist[i].size < 0) { /* Denotes a marked entry */ XtSetArg(wargs[0], XtNsetMark, TRUE); n++; } buttons[i] = XtCreateWidget(menulist[i].name, XwmenubuttonWidgetClass, menupane, wargs, n); if (strcmp (menulist[i].name, "recurrent net") == 0) recnet = buttons[i]; if (menulist[i].size <= 0) XtAddCallback (buttons[i], XtNselect, menulist[i].func, NULL); } XtManageChildren (buttons, nitems); } /*******Function GetText puts result of dialog entry into a global string variable */ void GetText(w, textwidget, call_data) Widget w; XtPointer textwidget, call_data; { Widget text = (Widget) textwidget; Arg args[1]; String str; str = XawDialogGetValueString(text); if (str[strlen(str) - 1] == ' ') str[strlen(str) - 1] = '\0'; (*function)(str); DestroyPopupPrompt(NULL, (XtPointer)textwidget, (XtPointer)NULL); } /*******Function Ok alternative to pressing "ok" dialog button--called on a */ void Ok(widget, event, params, num_params) Widget widget; XEvent *event; String *params; Cardinal *num_params; { Widget dialog = XtParent(widget); GetText(widget, (XtPointer) dialog, (XtPointer) NULL); } /*******Function QuitSelect exits the program when "quit" button is pushed. */ void QuitSelect(w, junk, garbage) Widget w; XtPointer junk, garbage; { XtDestroyWidget(w); fprintf (stderr, "\nQuitting xtdnn. . .\n\n"); exit (0); } /*******Function Syntax prints the calling syntax for this function to stdout. */ Syntax(w, call) Widget w; char *call; { XtDestroyWidget(w); fprintf (stderr, "Usage: %s [-label