void undo(void) { /* turn off Compose key LED */ setCompLED(0); switch (last_action) { case F_ADD: undo_add(); break; case F_DELETE: undo_delete(); break; case F_MOVE: undo_move(); break; case F_EDIT: undo_change(); break; case F_GLUE: undo_glue(); break; case F_BREAK: undo_break(); break; case F_LOAD: undo_load(); break; case F_SCALE: undo_scale(); break; case F_ADD_POINT: undo_addpoint(); break; case F_DELETE_POINT: undo_deletepoint(); break; case F_ADD_ARROW_HEAD: undo_add_arrowhead(); break; case F_DELETE_ARROW_HEAD: undo_delete_arrowhead(); break; case F_CONVERT: undo_convert(); break; case F_OPEN_CLOSE: undo_open_close(); break; case F_JOIN: case F_SPLIT: undo_join_split(); break; default: put_msg("Nothing to UNDO"); return; } put_msg("Undo complete"); }
void launch_about(Widget w, XtPointer closure, XtPointer call_data) { DeclareArgs(10); Widget form, icon, ok; Position x, y; char info[400]; /* turn off Compose key LED */ setCompLED(0); /* don't make more than one */ if (!help_popup) { /* get the position of the help button */ XtTranslateCoords(w, (Position) 0, (Position) 0, &x, &y); FirstArg(XtNx, x); NextArg(XtNy, y); help_popup = XtCreatePopupShell("About Xfig",transientShellWidgetClass, tool, Args, ArgCount); XtOverrideTranslations(help_popup, XtParseTranslationTable(about_translations)); XtAppAddActions(tool_app, about_actions, XtNumber(about_actions)); FirstArg(XtNborderWidth, 0); form = XtCreateManagedWidget("help_form", formWidgetClass, help_popup, Args, ArgCount); /* put the xfig icon in a label and another label saying which version this is */ FirstArg(XtNbitmap, fig_icon); NextArg(XtNinternalHeight, 0); NextArg(XtNinternalWidth, 0); NextArg(XtNborderWidth, 0); icon = XtCreateManagedWidget("xfig_icon", labelWidgetClass, form, Args, ArgCount); /* make up some information */ strcpy(info,xfig_version); strcat(info,"\n Parts Copyright \251 1989-2013 by Brian V. Smith ([email protected])"); strcat(info,"\n Parts Copyright \251 1991 by Paul King"); strcat(info,"\n Copyright \251 1985-1988 by Supoj Sutanthavibul"); strcat(info,"\n See source files and man pages for other copyrights"); FirstArg(XtNlabel, info); NextArg(XtNfromHoriz, icon); NextArg(XtNhorizDistance, 20); NextArg(XtNborderWidth, 0); XtCreateManagedWidget("xfig_icon", labelWidgetClass, form, Args, ArgCount); FirstArg(XtNlabel, " Ok "); NextArg(XtNwidth, 50); NextArg(XtNheight, 30); NextArg(XtNfromVert, icon); NextArg(XtNvertDistance, 20); ok = XtCreateManagedWidget("help_ok", commandWidgetClass, form, Args, ArgCount); XtAddCallback(ok, XtNcallback, help_ok, (XtPointer) NULL); } XtPopup(help_popup,XtGrabNone); (void) XSetWMProtocols(tool_d, XtWindow(help_popup), &wm_delete_window, 1); }
void pan_origin(void) { /* turn off Compose key LED */ setCompLED(0); if (zoomxoff == 0 && zoomyoff == 0) return; if (zoomyoff != 0) { zoomyoff = 0; setup_sideruler(); redisplay_sideruler(); } if (zoomxoff != 0) { zoomxoff = 0; reset_topruler(); redisplay_topruler(); } setup_grid(); }
void launch_viewer(char *filename, char *message, char *viewer) { /* turn off Compose key LED */ setCompLED(0); /* first check if the file is installed */ if (!check_docfile(filename)){ if (errno == ENOENT) { file_msg("%s is not installed, please install package xfig-doc.",filename); } else { file_msg("System error: %s on file %s",strerror(errno),filename); } beep(); return; } /* now replace the %f in the browser command with the filename and add the "&" */ browsecommand = build_command(viewer, filename); put_msg(message); system(browsecommand); free(browsecommand); }
void popup_print_panel(Widget w) { char buf[30]; /* turn off Compose key LED */ setCompLED(0); set_temp_cursor(wait_cursor); if (print_popup) { /* the print popup already exists, but the magnification may have been changed in the export popup */ sprintf(buf,"%.1f",appres.magnification); FirstArg(XtNstring, buf); SetValues(print_mag_text); /* also the figure size (magnification * bounding_box) */ print_update_figure_size(); /* now set the color and name in the background button */ set_but_col(print_background_panel, export_background_color); /* and the background color menu */ XtDestroyWidget(background_menu); background_menu = make_color_popup_menu(print_background_panel, "Background Color", background_select, NO_TRANSP, INCL_BACKG); } else { create_print_panel(w); } XtPopup(print_popup, XtGrabNone); /* now that the popup is realized, put in the name of the first printer */ if (printer_names[0] != NULL) { FirstArg(XtNlabel, printer_names[0]); SetValues(printer_menu_button); } /* insure that the most recent colormap is installed */ set_cmap(XtWindow(print_popup)); (void) XSetWMProtocols(tool_d, XtWindow(print_popup), &wm_delete_window, 1); reset_cursor(); }
void spell_check(void) { char filename[PATH_MAX]; char *cmd; char str[300]; FILE *fp; int len, i; Boolean done = FALSE; static int lines = 0; /* turn off Compose key LED */ setCompLED(0); put_msg("Spell checking..."); /* free any strings from the previous spelling */ for (i=0; i<lines; i++) { free(miss_word_list[i]); miss_word_list[i] = 0; } lines = 0; sprintf(filename, "%s/xfig-spell.%d", TMPDIR, (int)getpid()); fp = fopen(filename, "w"); if (fp == NULL) { file_msg("Can't open temporary file: %s: %s\n", filename, strerror(errno)); } else { /* locate all text objects and write them to file fp */ write_text_from_compound(fp, &objects); fclose(fp); /* replace the %f in the spellcheckcommand with the filename to check */ cmd = build_command(appres.spellcheckcommand, filename); /* "spell %f", "ispell -l < %f | sort -u" or equivalent */ fp = popen(cmd, "r"); if (fp != NULL) { while (fgets(str, sizeof(str), fp) != NULL) { len = strlen(str); if (str[len - 1] == '\n') str[len - 1] = '\0'; /* save the word in the list */ miss_word_list[lines] = my_strdup(str); lines++; if (lines >= MAX_MISSPELLED_WORDS) break; } if (pclose(fp) == 0) done = TRUE; } unlink(filename); /* put up the panel to show the results */ popup_spell_check_panel(miss_word_list, lines); if (!done) show_spell_msg("Can't exec \"%s\": %s", cmd, strerror(errno)); else if (lines == 0) show_spell_msg("No misspelled words found"); else if (lines >= MAX_MISSPELLED_WORDS) show_spell_msg("%d (limit) misspelled words found. There may be more.", lines); else show_spell_msg("%d misspelled words found", lines); /* free command string allocated by build_command() */ free(cmd); } if (!done) { show_spell_msg("Spell check: Internal error"); beep(); } /* make recheck button sensitive */ XtSetSensitive(recheck_button, True); }
void popup_search_panel(void) { static Boolean actions_added = False; Widget below = None; Widget form, label, dismiss_button; int rx,ry; /* turn off Compose key LED */ setCompLED(0); /* don't paste if in the middle of drawing/editing */ if (check_action_on()) return; /* don't make another one if one already exists */ if (search_panel) { return; } put_msg("Search & Replace"); get_pointer_root_xy(&rx, &ry); FirstArg(XtNx, (Position) rx); NextArg(XtNy, (Position) ry); NextArg(XtNcolormap, tool_cm); NextArg(XtNtitle, "Xfig: Search & Replace"); search_panel = XtCreatePopupShell("search_panel", transientShellWidgetClass, tool, Args, ArgCount); XtOverrideTranslations(search_panel, XtParseTranslationTable(search_panel_translations)); if (!actions_added) { XtAppAddActions(tool_app, search_actions, XtNumber(search_actions)); actions_added = True; } form = XtCreateManagedWidget("form", formWidgetClass, search_panel, NULL, 0) ; FirstArg(XtNlabel, " Search for:"); NextArg(XtNborderWidth, 0); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); label = XtCreateManagedWidget("search_lab", labelWidgetClass, form, Args, ArgCount); FirstArg(XtNfromHoriz, label); NextArg(XtNeditType, XawtextEdit); NextArg(XtNwidth, 200); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); search_text_widget = XtCreateManagedWidget("search_text", asciiTextWidgetClass, form, Args, ArgCount); XtOverrideTranslations(search_text_widget, XtParseTranslationTable(search_text_translations)); /* search button */ FirstArg(XtNlabel, "Search "); NextArg(XtNfromHoriz, search_text_widget); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); search_button = XtCreateManagedWidget("search", commandWidgetClass, form, Args, ArgCount); XtAddCallback(search_button, XtNcallback, (XtCallbackProc) search_and_replace_text, (XtPointer) NULL); (void) CreateCheckbutton("Case sensitive", "case_sensitive", form, NULL, search_button, MANAGE, SMALL_CHK, &case_sensitive, 0, 0); below = label; FirstArg(XtNfromVert, below); NextArg(XtNvertDistance, 6); NextArg(XtNborderWidth, 0); NextArg(XtNlabel, "Replace with:"); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); replace_text_label = XtCreateManagedWidget("replace_lab", labelWidgetClass, form, Args, ArgCount); FirstArg(XtNfromVert, below); NextArg(XtNvertDistance, 6); NextArg(XtNfromHoriz, replace_text_label); NextArg(XtNeditType, XawtextEdit); NextArg(XtNwidth, 200); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); replace_text_widget = XtCreateManagedWidget("replace_text", asciiTextWidgetClass, form, Args, ArgCount); XtOverrideTranslations(replace_text_widget, XtParseTranslationTable(replace_text_translations)); FirstArg(XtNfromVert, below); NextArg(XtNfromHoriz, replace_text_widget); NextArg(XtNlabel, "Replace"); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); do_replace_button = XtCreateManagedWidget("do_replace", commandWidgetClass, form, Args, ArgCount); XtAddCallback(do_replace_button, XtNcallback, (XtCallbackProc) do_replace, (XtPointer) NULL); FirstArg(XtNfromVert, below); NextArg(XtNfromHoriz, do_replace_button); NextArg(XtNlabel, "UPDATE settings"); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); do_update_button = XtCreateManagedWidget("dismiss", commandWidgetClass, form, Args, ArgCount); XtAddCallback(do_update_button, XtNcallback, (XtCallbackProc) do_update, (XtPointer) NULL); below = replace_text_widget; /* make a label to report if no match for search */ FirstArg(XtNlabel, "Enter search string and press \"Search\""); NextArg(XtNfromVert, below); NextArg(XtNjustify, XtJustifyLeft); NextArg(XtNwidth, SEARCH_WIDTH); NextArg(XtNheight, 20); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainTop); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); search_msg_win = XtCreateManagedWidget("search_msg_win", labelWidgetClass, form, Args, ArgCount); below = search_msg_win; /* make a text window to hold search results */ FirstArg(XtNwidth, SEARCH_WIDTH); NextArg(XtNfromVert, below); NextArg(XtNheight, 200); NextArg(XtNeditType, XawtextRead); NextArg(XtNdisplayCaret, False); NextArg(XtNscrollHorizontal, XawtextScrollWhenNeeded); NextArg(XtNscrollVertical, XawtextScrollAlways); NextArg(XtNtop, XtChainTop); NextArg(XtNbottom, XtChainBottom); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); search_results_win = XtCreateManagedWidget("search_results_win", asciiTextWidgetClass, form, Args, ArgCount); XtOverrideTranslations(search_results_win, XtParseTranslationTable(search_results_translations)); below = search_results_win; /* make a dismiss button */ FirstArg(XtNfromVert, below); NextArg(XtNlabel, "Dismiss"); NextArg(XtNtop, XtChainBottom); NextArg(XtNbottom, XtChainBottom); NextArg(XtNleft, XtChainLeft); NextArg(XtNright, XtChainLeft); dismiss_button = XtCreateManagedWidget("dismiss", commandWidgetClass, form, Args, ArgCount); XtAddCallback(dismiss_button, XtNcallback, (XtCallbackProc) search_panel_dismiss, (XtPointer) NULL); /* make update/replace buttons insensitive to start */ XtSetSensitive(replace_text_label, False); XtSetSensitive(do_replace_button, False); XtSetSensitive(do_update_button, False); XtPopup(search_panel, XtGrabNone); XSetWMProtocols(tool_d, XtWindow(search_panel), &wm_delete_window, 1); set_cmap(XtWindow(search_panel)); }