void do_print(Widget w) { char *printer_val; char *param_val; char cmd[255],cmd2[255]; char *c1; char backgrnd[10], grid[80]; /* don't print if in the middle of drawing/editing */ if (check_action_on()) return; if (emptyfigure_msg(print_msg) && !batch_exists) return; /* create popup panel if not already there so we have all the resources necessary (e.g. printer name etc.) */ if (!print_popup) create_print_panel(w); /* get the magnification into appres.magnification */ get_magnif(); /* update the figure size (magnification * bounding_box) */ print_update_figure_size(); printer_val = panel_get_value(printer_text); param_val = panel_get_value(param_text); /* get grid params and assemble into fig2dev parm */ get_grid_spec(grid, print_grid_minor_text, print_grid_major_text); if (batch_exists) { gen_print_cmd(cmd,batch_file,printer_val,param_val); if (system(cmd) != 0) file_msg("Error during PRINT"); /* clear the batch file and the count */ do_clear_batch(w); } else { strcpy(cmd, param_val); /* see if the user wants the filename in the param list (%f) */ if (!strstr(cur_filename,"%f")) { /* don't substitute if the filename has a %f */ while (c1=strstr(cmd,"%f")) { strcpy(cmd2, c1+2); /* save tail */ strcpy(c1, cur_filename); /* change %f to filename */ strcat(c1, cmd2); /* append tail */ } } /* make a #rrggbb string from the background color */ make_rgb_string(export_background_color, backgrnd); print_to_printer(printer_val, backgrnd, appres.magnification, print_all_layers, bound_active_layers, grid, cmd); } }
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)); }