void BindResidualProg() { char tmpstr[TEMPSTRINGLEN]; Cardinal n = 0; static Arg dialogArgs [] = { {XtNlabel, (XtArgVal) ""}, {XtNvalue, (XtArgVal) ""} }; if (exitFlag == True) StartSimilix(); if (shellFlag == True) XtDestroyWidget(dialogShell); dialogShell = CreateShell(); n = 0; XtSetArg(dialogArgs[n], XtNlabel, "Bind residual program --- Input the name of bound variable:"); n++; XtSetArg(dialogArgs[n], XtNvalue, VARNAME); n++; dialog[15] = XtCreateManagedWidget("Var15", dialogWidgetClass, dialogShell, dialogArgs, XtNumber(dialogArgs)); XtVaSetValues(dialog[15], XtNfont, font1Struct, NULL); XawDialogAddButton(dialog[15], "OK", BindResProgOK, NULL); XawDialogAddButton(dialog[15], "Cancel", BindResProgCancel, NULL); XtPopup(dialogShell, XtGrabNone); shellFlag = True; }
void ShowResidualProg() { char tmpstr[TEMPSTRINGLEN]; static Arg arglist [] = { {XtNlabel, (XtArgVal) ""}, {XtNvalue, (XtArgVal) ""}, }; Cardinal n = 0; if (exitFlag == True) StartSimilix(); if (shellFlag == True) XtDestroyWidget(dialogShell); dialogShell = CreateShell(); n = 0; XtSetArg(arglist[n], XtNlabel, "Show residual program --- Input the name of residual program:"); n++; XtSetArg(arglist[n], XtNvalue, RESNAME); n++; dialog[11] = XtCreateManagedWidget("Res11", dialogWidgetClass, dialogShell, arglist, XtNumber(arglist)); XtVaSetValues(dialog[11], XtNfont, font1Struct, NULL); XawDialogAddButton(dialog[11], "OK", ShowResProgOK, NULL); XawDialogAddButton(dialog[11], "Cancel", ShowResProgCancel, NULL); XawDialogAddButton(dialog[11], "Help", ShowResProgHelp, NULL); XtPopup(dialogShell, XtGrabNone); shellFlag = True; }
/******************************************************************************* Name: QuitCallback Description: Called when Quit is selected form File menu Arguments: w - menu item that was selected client_data - entry number on menu call_data - not used Returns: None *******************************************************************************/ void QuitCallback( Widget w, XtPointer client_data, XtPointer call_data) { Widget confirmshell, confirm; confirmshell = XtCreatePopupShell("Confirmation", topLevelShellWidgetClass, toplevel, NULL, 0); XtSetArg(args[0], XtNlabel, "Quit XCLIPS.\nAre you sure?"); XtSetArg(args[1], XtNicon, clips_logo); confirm = XtCreateManagedWidget("confirm", dialogWidgetClass, confirmshell, args, 2); XawDialogAddButton(confirm, "Quit", Quit, (XtPointer) confirm); XawDialogAddButton(confirm, "Restart", Restart, (XtPointer) confirm); XawDialogAddButton(confirm, "Cancel", CancelPopupSelect, (XtPointer) confirm); XtPopup(confirmshell, XtGrabNonexclusive); }
static void quit_prompt (Widget button, XtPointer client_data, XtPointer call_data) { Widget parent, dialog; Arg args[10]; Position x, y; if (quit_popup == NULL) { parent = XtParent (button); XtTranslateCoords (button, (Position) 0, (Position) 0, &x, &y); XtSetArg (args[0], XtNx, x); XtSetArg (args[1], XtNy, y); quit_popup = XtCreatePopupShell ("prompt", transientShellWidgetClass, parent, args, TWO); XtAddCallback (quit_popup, XtNdestroyCallback, quit_prompt_destroyed, (XtPointer) 0); XtSetArg (args[0], XtNlabel, "quit?"); dialog = XtCreateManagedWidget ("quit", dialogWidgetClass, quit_popup, args, ONE); XawDialogAddButton (dialog, "quit", quit_action, (XtPointer) dialog); XawDialogAddButton (dialog, "abort command", destroy_popup_prompt, (XtPointer) dialog); } confirmAction = quit_action; XtPopup (quit_popup, XtGrabNone); }
void ExitSimu() { char tmpstr[TEMPSTRINGLEN]; Position x, y; Dimension width, height; Cardinal n = 0; Arg args[5]; if (shellFlag == True) XtDestroyWidget(dialogShell); dialogShell = CreateShell(); XtSetArg(dialog0Args[0], XtNlabel, "Quit the Simu system?"); dialog0 = XtCreateManagedWidget("dialog0", dialogWidgetClass, dialogShell, dialog0Args, XtNumber(dialog0Args)); XtVaSetValues(dialog0, XtNfont, font1Struct, NULL); XawDialogAddButton(dialog0, "OK", ExitSimuOK, NULL); XawDialogAddButton(dialog0, "Cancel", CancelDialog, dialog0); XawDialogAddButton(dialog0, "Help", ExitSimuHelp, NULL); XtRealizeWidget(dialogShell); Popup(dialogShell, XtGrabNone); /* XtPopup(dialogShell, XtGrabNone); */ shellFlag = True; }
void continue_prompt (int interrupt_seen) { Widget dialog; Arg args[10]; Position x, y; char msg[256]; if (continue_popup != NULL) XtDestroyWidget (continue_popup); XtTranslateCoords (breakpointButton, (Position) 0, (Position) 0, &x, &y); XtSetArg (args[0], XtNx, x); XtSetArg (args[1], XtNy, y); continue_popup = XtCreatePopupShell ("prompt", transientShellWidgetClass, breakpointButton, args, TWO); XtAddCallback (continue_popup, XtNdestroyCallback, continue_prompt_destroyed, (XtPointer) 0); if (interrupt_seen) sprintf (msg, "execution interrupt at 0x%08x", PC); else sprintf (msg, "breakpoint encountered at 0x%08x", PC); XtSetArg (args[0], XtNlabel, msg); dialog = XtCreateManagedWidget ("continue", dialogWidgetClass, continue_popup, args, ONE); XawDialogAddButton (dialog, "continue", continue_action, (XtPointer) dialog); XawDialogAddButton (dialog, "abort command", destroy_popup_prompt, (XtPointer) dialog); confirmAction = continue_action; XtPopup (continue_popup, XtGrabNone); }
void MakeSearchWidget(ManpageGlobals * man_globals, Widget parent) { Widget dialog, command, text, cancel; Arg arglist[2]; Cardinal num_args = 0; XtSetArg(arglist[0], XtNtransientFor, parent); man_globals->search_widget = XtCreatePopupShell(SEARCHNAME, transientShellWidgetClass, parent, arglist, 1); if (resources.clear_search_string) { XtSetArg(arglist[0], XtNvalue, ""); num_args++; } dialog = XtCreateManagedWidget(DIALOG, dialogWidgetClass, man_globals->search_widget, arglist, num_args); if ((text = XtNameToWidget(dialog, "value")) == (Widget) NULL) PopupWarning(NULL, "Could not find text widget in MakeSearchWidget."); else XtSetKeyboardFocus(dialog, text); XawDialogAddButton(dialog, MANUALSEARCH, NULL, NULL); XawDialogAddButton(dialog, APROPOSSEARCH, NULL, NULL); XawDialogAddButton(dialog, CANCEL, NULL, NULL); /* * This is a bit gross, but it get the cancel button underneath the * others, and forms them up to the right size.. */ if (((command = XtNameToWidget(dialog, MANUALSEARCH)) == (Widget) NULL) || ((cancel = XtNameToWidget(dialog, CANCEL)) == (Widget) NULL)) PopupWarning(NULL, "Could not find manual search widget in MakeSearchWidget."); else { static const char *half_size[] = { MANUALSEARCH, APROPOSSEARCH, NULL }; static const char *full_size[] = { "label", "value", CANCEL, NULL }; num_args = 0; XtSetArg(arglist[num_args], XtNfromVert, command); num_args++; XtSetArg(arglist[num_args], XtNfromHoriz, NULL); num_args++; XtSetValues(cancel, arglist, num_args); FormUpWidgets(dialog, full_size, half_size); } }
static void MakePrompt(Widget centerw, const char *prompt, MakePromptFunc func, const char *def) { static Arg dialogArgs[] = { {XtNlabel, 0}, {XtNvalue, 0}, }; Arg valueArgs[1]; Arg centerArgs[2]; Position source_x, source_y; Position dest_x, dest_y; Dimension center_width, center_height; Dimension prompt_width, prompt_height; Widget valueWidget; CancelAction ((Widget)NULL, (XEvent *) 0, (String *) 0, (Cardinal *) 0); promptShell = XtCreatePopupShell ("promptShell", transientShellWidgetClass, toplevel, NULL, (Cardinal) 0); dialogArgs[0].value = (XtArgVal)prompt; dialogArgs[1].value = (XtArgVal)def; promptDialog = XtCreateManagedWidget( "promptDialog", dialogWidgetClass, promptShell, dialogArgs, XtNumber (dialogArgs)); XawDialogAddButton(promptDialog, "accept", NULL, (XtPointer) 0); XawDialogAddButton(promptDialog, "cancel", NULL, (XtPointer) 0); valueWidget = XtNameToWidget (promptDialog, "value"); if (valueWidget) { XtSetArg (valueArgs[0], (String)XtNresizable, TRUE); XtSetValues (valueWidget, valueArgs, 1); /* * as resizable isn't set until just above, the * default value will be displayed incorrectly. * rectify the situation by resetting the values */ XtSetValues (promptDialog, dialogArgs, XtNumber (dialogArgs)); } XtSetKeyboardFocus (promptDialog, valueWidget); XtSetKeyboardFocus (toplevel, valueWidget); XtRealizeWidget (promptShell); /* * place the widget in the center of the "parent" */ XtSetArg (centerArgs[0], XtNwidth, ¢er_width); XtSetArg (centerArgs[1], XtNheight, ¢er_height); XtGetValues (centerw, centerArgs, 2); XtSetArg (centerArgs[0], XtNwidth, &prompt_width); XtSetArg (centerArgs[1], XtNheight, &prompt_height); XtGetValues (promptShell, centerArgs, 2); source_x = (center_width - prompt_width) / 2; source_y = (center_height - prompt_height) / 3; XtTranslateCoords (centerw, source_x, source_y, &dest_x, &dest_y); XtSetArg (centerArgs[0], XtNx, dest_x); XtSetArg (centerArgs[1], XtNy, dest_y); XtSetValues (promptShell, centerArgs, 2); XtMapWidget(promptShell); promptfunction = func; }
static void CreateLoadPopup () { load_popup = XtCreatePopupShell ("load-popup", transientShellWidgetClass, MyRootWidget, NoArgs); StartArgs; SetArg (XtNlabel, "Load from"); SetArg (XtNvalue, ""); load_dialog = XtCreateManagedWidget ("load-dialog", dialogWidgetClass, load_popup, UseArgs); XawDialogAddButton (load_dialog, "Yes", DoLoad, NULL); XawDialogAddButton (load_dialog, "Cancel", CancelLoad, NULL); XtRealizeWidget (load_popup); };
static void CreateCheckPopup () { check_popup = XtCreatePopupShell ("check-popup", transientShellWidgetClass, MyRootWidget, NoArgs); StartArgs; SetArg (XtNlabel, "Save changes to layout rules"); check_dialog = XtCreateManagedWidget ("check-dialog", dialogWidgetClass, check_popup, UseArgs); XawDialogAddButton (check_dialog, "Yes", (XtCallbackProc) DoSaveLayoutRules, NULL); XawDialogAddButton (check_dialog, "No", (XtCallbackProc) DontSaveLayoutRules, NULL); XawDialogAddButton (check_dialog, "Cancel", (XtCallbackProc) CancelFinalExit, NULL); XtRealizeWidget (check_popup); };
Dialog CreateDialog(Widget top_widget, String name, unsigned long options) { int i; Dialog popup; popup = (Dialog) XtMalloc(sizeof(_Dialog)); if (popup) { if (firstTime) { XtAddActions(actions_table, XtNumber(actions_table)); firstTime = False; } popup->top_widget = top_widget; popup->shell_widget = XtCreatePopupShell(name, transientShellWidgetClass, top_widget, NULL, 0); popup->dialog_widget = XtCreateManagedWidget("dialog", dialogWidgetClass, popup->shell_widget, NULL, 0); for (i = 0; i < XtNumber(dialog_buttons); i++) if (options & dialog_buttons[i].flag) XawDialogAddButton(popup->dialog_widget, dialog_buttons[i].name, SetSelected, dialog_buttons[i].name); popup->options = options; return popup; } else return NULL; }
static void CreateSavePopup () { save_popup = XtCreatePopupShell ("save-popup", transientShellWidgetClass, MyRootWidget, NoArgs); StartArgs; SetArg (XtNlabel, "Save changes in"); SetArg (XtNvalue, ""); save_dialog = XtCreateManagedWidget ("save-dialog", dialogWidgetClass, save_popup, UseArgs); XawDialogAddButton (save_dialog, "Yes", (XtCallbackProc) DoSave, NULL); XawDialogAddButton (save_dialog, "No", (XtCallbackProc) DontSave, NULL); XawDialogAddButton (save_dialog, "Cancel", (XtCallbackProc) CancelSave, NULL); XtRealizeWidget (save_popup); }
static void Create_Light_Dialog() { Arg args[3]; int n; n = 0; XtSetArg(args[n], XtNtitle, "Intensity"); n++; XtSetArg(args[n], XtNallowShellResize, TRUE); n++; light_shell = XtCreatePopupShell("lightShell", transientShellWidgetClass, main_window.shell, args, n); n = 0; XtSetArg(args[n], XtNlabel, "Light Intensity"); n++; XtSetArg(args[n], XtNvalue, ""); n++; light_dialog = XtCreateManagedWidget("lightDialog", dialogWidgetClass, light_shell, args, n); XawDialogAddButton(light_dialog, "Done", Light_Intensity_Callback, NULL); XawDialogAddButton(light_dialog, "Cancel", Cancel_Light_Callback, (XtPointer)light_shell); XtOverrideTranslations(XtNameToWidget(light_dialog, "value"), XtParseTranslationTable(":<Key>Return: Light_Action()")); XtVaSetValues(XtNameToWidget(light_dialog, "label"), XtNborderWidth, 0, NULL); #if ( USE_ROUNDED_BUTTONS == 1 ) XtVaSetValues(XtNameToWidget(light_dialog, "Done"), XtNshapeStyle, XmuShapeRoundedRectangle, XtNcornerRoundPercent, 30, XtNhighlightThickness, 2, NULL); XtVaSetValues(XtNameToWidget(light_dialog, "Cancel"), XtNshapeStyle, XmuShapeRoundedRectangle, XtNcornerRoundPercent, 30, XtNhighlightThickness, 2, NULL); #endif XtRealizeWidget(light_shell); }
static void breakpoint_prompt (Widget button, XtPointer client_data, XtPointer call_data) { Widget parent, dialog; Arg args[10]; Position x, y; if (bkpt_popup == NULL) { parent = XtParent (button); XtTranslateCoords (button, (Position) 0, (Position) 0, &x, &y); XtSetArg (args[0], XtNx, x); XtSetArg (args[1], XtNy, y); bkpt_popup = XtCreatePopupShell ("popup", transientShellWidgetClass, parent, args, TWO); if (breakpoint_addr == NULL) breakpoint_addr = str_copy (""); XtSetArg (args[0], XtNlabel, "address:"); XtSetArg (args[1], XtNvalue, breakpoint_addr); dialog = XtCreateManagedWidget ("dialog", dialogWidgetClass, bkpt_popup, args, TWO); XtAddCallback (bkpt_popup, XtNdestroyCallback, breakpoint_prompt_destroyed, (XtPointer) 0); XawDialogAddButton (dialog, "add", add_breakpoint_action, (XtPointer) dialog); XawDialogAddButton (dialog, "delete", delete_breakpoint_action, (XtPointer) dialog); XawDialogAddButton (dialog, "list", list_breakpoint_action, (XtPointer) dialog); XawDialogAddButton (dialog, "abort command", destroy_popup_prompt, (XtPointer) dialog); } confirmAction = add_breakpoint_action; XtPopup (bkpt_popup, XtGrabNone); }
static void load_prompt (Widget button, XtPointer client_data, XtPointer call_data) { Widget parent, dialog; Arg args[10]; Position x, y; if (load_popup == NULL) { parent = XtParent (button); XtTranslateCoords (button, (Position) 0, (Position) 0, &x, &y); XtSetArg (args[0], XtNx, x); XtSetArg (args[1], XtNy, y); load_popup = XtCreatePopupShell ("popup", transientShellWidgetClass, parent, args, TWO); XtAddCallback (load_popup, XtNdestroyCallback, load_prompt_destroyed, (XtPointer) 0); if (program_file_name == NULL) { program_file_name = str_copy (""); command_line = program_file_name; } XtSetArg (args[0], XtNlabel, "input filename:"); XtSetArg (args[1], XtNvalue, program_file_name); dialog = XtCreateManagedWidget ("dialog", dialogWidgetClass, load_popup, args, TWO); XawDialogAddButton (dialog, "assembly file", read_assm_file_action, (XtPointer) dialog); XawDialogAddButton (dialog, "abort command", destroy_popup_prompt, (XtPointer) dialog); } confirmAction = read_assm_file_action; XtPopup (load_popup, XtGrabNone); }
/******************************************************************************* Name: ClipsSave Description: Prompts for file name to execute CLIPS' bsave, save-facts, or save functions Arguments: None Returns: None *******************************************************************************/ static void ClipsSave() { Widget popup, file_dialog; popup = XtCreatePopupShell("File", topLevelShellWidgetClass, toplevel, NULL, 0); XtSetArg(args[0], XtNlabel, "Enter file name:"); XtSetArg(args[1], XtNvalue, ""); XtSetArg(args[2], XtNicon, clips_logo); file_dialog = XtCreateManagedWidget("file_dialog", dialogWidgetClass, popup, args, 3); XawDialogAddButton(file_dialog, "Save", IntSave, (XtPointer)NULL); XawDialogAddButton(file_dialog, "Cancel", CancelPopupSelect, (XtPointer)file_dialog); XtPopup(popup, XtGrabNonexclusive); }
static void saveChanges (Widget w, XtPointer client_data, XtPointer callData __attribute__((unused))) { Widget dialog; XtAppContext app; XEvent event; ViewData *view = client_data; if (! gridHasChanged) return; saveChangesPopup = XtVaCreatePopupShell( "popup", transientShellWidgetClass, XtShell(theView.canvas), XtNinput, True, NULL); dialog = XtVaCreateManagedWidget( "save", dialogWidgetClass, saveChangesPopup, XtNlabel, "Save changes to grid?", XtNvalue, view->fileName, NULL); XawDialogAddButton(dialog, "Save", doSave, view); XawDialogAddButton(dialog, "Discard", doDiscard, view); /* This gets called outside the main application loop, so we need a mini-loop of our own. Callbacks on buttons destroy dialog, so that is the exit condition. */ XtPopup(saveChangesPopup, XtGrabNonexclusive); app = XtWidgetToApplicationContext(w); while (saveChangesPopup != NULL) { XtAppNextEvent(app, &event); XtDispatchEvent(&event); } }
/* void ** Create_Deletion_Dialog() ** Creates the dialog for object deletion. */ static void Create_Deletion_Dialog() { Widget deletion_dialog; Arg args[5]; int n; n = 0; XtSetArg(args[n], XtNtitle, "Delete"); n++; deletion_shell = XtCreatePopupShell("deleteShell", transientShellWidgetClass, current_window->shell, args, n); n = 0; XtSetArg(args[n], XtNlabel, "Confirm Deletion!"); n++; deletion_dialog = XtCreateManagedWidget("deleteDialog", dialogWidgetClass, deletion_shell, args, n); XawDialogAddButton(deletion_dialog, "Confirm", Do_Delete, NULL); XawDialogAddButton(deletion_dialog, "Cancel", Cancel_Delete, NULL); XtVaSetValues(XtNameToWidget(deletion_dialog, "label"), XtNborderWidth, 0, NULL); #if ( USE_ROUNDED_BUTTONS == 1 ) XtVaSetValues(XtNameToWidget(deletion_dialog, "Confirm"), XtNshapeStyle, XmuShapeRoundedRectangle, XtNcornerRoundPercent, 30, XtNhighlightThickness, 2, NULL); XtVaSetValues(XtNameToWidget(deletion_dialog, "Cancel"), XtNshapeStyle, XmuShapeRoundedRectangle, XtNcornerRoundPercent, 30, XtNhighlightThickness, 2, NULL); #endif XtRealizeWidget(deletion_shell); }
static int AddMode(void) { if (addshell == NULL) { Widget dialog; addshell = XtCreatePopupShell("addMode", transientShellWidgetClass, toplevel, NULL, 0); dialog = XtVaCreateManagedWidget("dialog", dialogWidgetClass, addshell, XtNvalue, NULL, NULL, 0); XawDialogAddButton(dialog, "yes", PopdownAdd, (XtPointer)True); XawDialogAddButton(dialog, "no", PopdownAdd, (XtPointer)False); XtRealizeWidget(addshell); XSetWMProtocols(DPY, XtWindow(addshell), &wm_delete_window, 1); } asking_add = 1; XtPopup(addshell, XtGrabExclusive); while (asking_add) XtAppProcessEvent(XtWidgetToApplicationContext(addshell), XtIMAll); return (do_add); }
void PopupWarning(ManpageGlobals * man_globals, char * string) { int n; Arg wargs[3]; Dimension topX, topY; char buffer[BUFSIZ]; Boolean hasPosition; snprintf( buffer, sizeof(buffer), "Xman Warning: %s", string); hasPosition = FALSE; if (top) { n=0; XtSetArg(wargs[n], XtNx, &topX); n++; XtSetArg(wargs[n], XtNy, &topY); n++; XtGetValues(top, wargs, n); hasPosition = TRUE; } if (man_globals != NULL) ChangeLabel(man_globals->label, buffer); if (man_globals->label == NULL) { n=0; if (hasPosition) { XtSetArg(wargs[n], XtNx, topX); n++; XtSetArg(wargs[n], XtNy, topY); n++; } XtSetArg(wargs[n], XtNtransientFor, top); n++; warnShell = XtCreatePopupShell("warnShell", transientShellWidgetClass, initial_widget, wargs, n); XtSetArg(wargs[0], XtNlabel, buffer); warnDialog = XtCreateManagedWidget("warnDialog", dialogWidgetClass, warnShell, wargs, 1); XawDialogAddButton(warnDialog, "dismiss", PopdownWarning, (XtPointer)warnShell); XtRealizeWidget(warnShell); Popup(warnShell, XtGrabNone); } }
static void do_alert(char *fmt, ...) { char msg[132]; va_list args; va_start(args, fmt); vsprintf(msg, fmt, args); { Widget shell, dialog; shell = XtVaCreatePopupShell("shell", transientShellWidgetClass, event_log, XtNtitle, "Alert", NULL); dialog = XtVaCreateManagedWidget("dialog", dialogWidgetClass, shell, XtNlabel, msg, NULL); XawDialogAddButton(dialog, "dismiss", do_popdown, shell); XtPopup(shell, XtGrabExclusive); } va_end(args); } /* do_alert */
static void TestCallback(Widget w, XtPointer call_data, XtPointer client_data) { if (testshell == NULL) { Widget dialog; testshell = XtCreatePopupShell("test", transientShellWidgetClass, toplevel, NULL, 0); dialog = XtVaCreateManagedWidget("dialog", dialogWidgetClass, testshell, XtNvalue, NULL, NULL, 0); XawDialogAddButton(dialog, "stop", StopTestCallback, NULL); XtRealizeWidget(testshell); XSetWMProtocols(DPY, XtWindow(testshell), &wm_delete_window, 1); } XtPopup(testshell, XtGrabExclusive); XSync(XtDisplay(toplevel), False); timeout = XtAppAddTimeOut(XtWidgetToApplicationContext(w), /* the timeout probably shoud be converted to a resource */ 4000, TestTimeout, (XtPointer)w); ApplyCallback(w, call_data, client_data); }
int main(int argc, char *argv[]) { Arg args[4]; Cardinal n; XtAppContext xtcontext; Widget parent; XtSetLanguageProc(NULL, NULL, NULL); top = XtAppInitialize( &xtcontext, "XClipboard", table, XtNumber(table), &argc, argv, fallback_resources, NULL, 0); XtGetApplicationResources(top, (XtPointer)&userOptions, resources, XtNumber(resources), NULL, 0); XtAppAddActions (xtcontext, xclipboard_actions, XtNumber (xclipboard_actions)); /* CLIPBOARD_MANAGER is a non-standard mechanism */ ManagerAtom = XInternAtom(XtDisplay(top), "CLIPBOARD_MANAGER", False); ClipboardAtom = XA_CLIPBOARD(XtDisplay(top)); if (XGetSelectionOwner(XtDisplay(top), ManagerAtom)) XtError("another clipboard is already running\n"); parent = XtCreateManagedWidget("form", formWidgetClass, top, NULL, ZERO); (void) XtCreateManagedWidget("quit", Command, parent, NULL, ZERO); (void) XtCreateManagedWidget("delete", Command, parent, NULL, ZERO); (void) XtCreateManagedWidget("new", Command, parent, NULL, ZERO); (void) XtCreateManagedWidget("save", Command, parent, NULL, ZERO); nextButton = XtCreateManagedWidget("next", Command, parent, NULL, ZERO); prevButton = XtCreateManagedWidget("prev", Command, parent, NULL, ZERO); indexLabel = XtCreateManagedWidget("index", Label, parent, NULL, ZERO); n=0; XtSetArg(args[n], XtNtype, XawAsciiString); n++; XtSetArg(args[n], XtNeditType, XawtextEdit); n++; if (userOptions.wrap) { XtSetArg(args[n], XtNwrap, XawtextWrapWord); n++; XtSetArg(args[n], XtNscrollHorizontal, False); n++; } text = XtCreateManagedWidget( "text", Text, parent, args, n); currentClip = NewClip (text, (ClipPtr) 0); set_button_state (); fileDialogShell = XtCreatePopupShell("fileDialogShell", transientShellWidgetClass, top, NULL, ZERO); fileDialog = XtCreateManagedWidget ("fileDialog", dialogWidgetClass, fileDialogShell, NULL, ZERO); XawDialogAddButton(fileDialog, "accept", NULL, NULL); XawDialogAddButton(fileDialog, "cancel", NULL, NULL); failDialogShell = XtCreatePopupShell("failDialogShell", transientShellWidgetClass, top, NULL, ZERO); failDialog = XtCreateManagedWidget ("failDialog", dialogWidgetClass, failDialogShell, NULL, ZERO); XawDialogAddButton (failDialog, "continue", NULL, NULL); XtRealizeWidget(top); XtRealizeWidget(fileDialogShell); XtRealizeWidget(failDialogShell); XtOwnSelection(top, ManagerAtom, CurrentTime, RefuseSelection, LoseManager, NULL); if (XGetSelectionOwner (XtDisplay(top), ClipboardAtom)) { LoseSelection (top, &ClipboardAtom); } else { XtOwnSelection(top, ClipboardAtom, CurrentTime, ConvertSelection, LoseSelection, NULL); } wm_delete_window = XInternAtom(XtDisplay(top), "WM_DELETE_WINDOW", False); wm_protocols = XInternAtom(XtDisplay(top), "WM_PROTOCOLS", False); (void) XSetWMProtocols(XtDisplay(top), XtWindow(top), &wm_delete_window,1); (void) XSetWMProtocols(XtDisplay(top), XtWindow(fileDialogShell), &wm_delete_window,1); (void) XSetWMProtocols(XtDisplay(top), XtWindow(failDialogShell), &wm_delete_window,1); XtAppMainLoop(xtcontext); exit(0); }
/******************************************************************************* Name: FileSelect Description: Pops up window in center of the Dialog Window for file selection by user Arguments: None Returns: None Contrubuting Programmers: Albert Leigh - MacDonnell Douglas Stan Smith - Barrios some guy upstairs ******************************************************************************/ void FileSelect() { Widget file_form, file_dialog, view; /*XDefineCursor(XtDisplay(toplevel),toplevel,XC_watch);*/ file = XtCreatePopupShell("File", topLevelShellWidgetClass, toplevel, NULL, 0); file_form = XtCreateManagedWidget("file_form", formWidgetClass, file, NULL, 0); XtSetArg(args[0], XtNforceBars, True); XtSetArg(args[1], XtNbottom, XtChainBottom); XtSetArg(args[2], XtNheight,150); XtSetArg(args[3], XtNallowHoriz,True); XtSetArg(args[4],XtNallowVert,True); view = XtCreateManagedWidget("view", viewportWidgetClass, file_form, args, 5); /* =============================================================== * * Create the Select/Cancel dialog box in the file selection * * dialog box. * * =============================================================== */ XtSetArg(args[0], XtNresizable, True); XtSetArg(args[1], XtNlabel, "Enter File Name"); XtSetArg(args[2], XtNvalue, ""); XtSetArg(args[3], XtNfromVert, view); XtSetArg(args[4], XtNicon, clips_logo); XtSetArg(args[5], XtNleft, XtChainLeft); XtSetArg(args[6], XtNright, XtChainRight); XtSetArg(args[7], XtNtop, XtChainBottom); XtSetArg(args[8], XtNbottom, XtChainBottom); file_dialog = XtCreateManagedWidget("file_dialog", dialogWidgetClass, file_form, args, 9); XawDialogAddButton(file_dialog, "SELECT", MenuFunc, (XtPointer) file_dialog); XawDialogAddButton(file_dialog, "CANCEL", CancelPopupSelect, (XtPointer) file_form); XtSetArg(args[0], XtNfromHoriz, file_dialog); XtSetArg(args[1], XtNfromVert, view); /* =============================================================== * * Get the path of the current dirrectory * * =============================================================== */ if(getwd(path) == NULL) printf("Error getting current working directory '%s'\n", path); if(path[strlen(path) - 1] != '/') strcat(path, "/"); /* =============================================================== * * Create the file dialog list box * * =============================================================== */ XtSetArg(args[0], XtNdefaultColumns, 4); XtSetArg(args[1], XtNlist, GetDirectory()); XtSetArg(args[2], XtNforceColumns, False); XtSetArg(args[3], XtNverticalList, True); XtSetArg(args[4], XtNinternalWidth, 10); file_list = XtCreateManagedWidget("file_dialog", listWidgetClass, view, args, 5); XtAddCallback(file_list, XtNcallback, FileToDialog, (XtPointer) file_dialog); XtPopup(file, XtGrabNonexclusive); /*XDefineCursor(XtDisplay(toplevel),toplevel,None);*/ }
/******************************************************************************* Name DisplayMatchedList Description : Called when there are more than one matches for completion command *******************************************************************************/ DisplayMatchedList( Widget w, struct symbolMatch *matches) { Widget matchShell,matchForm,matchViewport, matchDialog,matchList,cancel; int n; if(GetMatchList(matches) == 0) return(0); matchShell = XtCreatePopupShell("Matches", topLevelShellWidgetClass, toplevel, NULL, 0); matchForm = XtCreateManagedWidget( "manager_form", formWidgetClass, matchShell, NULL,0); XtSetArg(args[0],XtNallowHoriz, True); XtSetArg(args[1],XtNallowVert, True); matchViewport = XtCreateManagedWidget("manager_viewport",viewportWidgetClass, matchForm,NULL, 2); n = 0; XtSetArg(args[n],XtNlist,item_list);n++; matchList = XtCreateManagedWidget("manager_list", listWidgetClass, matchViewport, args,n); n = 0; XtSetArg(args[n], XtNresizable, True);n++; XtSetArg(args[n],XtNlabel,"");n++; XtSetArg(args[n], XtNvalue, "");n++; XtSetArg(args[n], XtNfromVert, matchViewport);n++; XtSetArg(args[n], XtNicon, clips_logo);n++; XtSetArg(args[n], XtNleft, XtChainLeft);n++; XtSetArg(args[n], XtNright, XtChainRight);n++; XtSetArg(args[n], XtNtop, XtChainBottom);n++; XtSetArg(args[n], XtNbottom, XtChainBottom);n++; /* ============================================================= */ /* If the current active window is clips dialog box then pass */ /* the appropriate function to handle the match for the clips */ /* dialog; else the funcTion handling the match for the text */ /* editor is passed as the callback function. */ /* ============================================================= */ if(w == dialog_text) { matchDialog = XtCreateManagedWidget("match_dialog", dialogWidgetClass, matchForm, args, n); XawDialogAddButton(matchDialog, "SELECT",printMatch, (XtPointer)completionString); } else { matchDialog = XtCreateManagedWidget("match_editor", dialogWidgetClass, matchForm, args, n); XawDialogAddButton(matchDialog, "SELECT",printMatchForTextEdit,(XtPointer)w); } XawDialogAddButton(matchDialog, "CANCEL", CancelPopupSelect, (XtPointer) matchForm); XtAddCallback(matchList, XtNcallback, FileToDialog, (XtPointer) matchDialog); XtPopup(matchShell,XtGrabNonexclusive); }