home *** CD-ROM | disk | FTP | other *** search
- /*
- * FIG : Facility for Interactive Generation of figures
- *
- * Copyright (c) 1985 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
- * January 1985.
- * 1st revision : Aug 1985.
- *
- * print.c
- *
- * %W% %G%
- */
- #include "fig.h"
- #include "resources.h"
-
- /******************* imported global variables and procedures **************/
-
- extern char current_file[];
- extern int print_landscape;
- extern int figure_modified;
- extern char *printer;
-
- extern put_msg();
- extern wmgr_confirm();
-
- static char prcmd[200];
- static char *conf_prnt =
- "Figure hasn't been saved, PRINT with LEFT button, CANCEL with MIDDLE or RIGHT";
-
- print_figure()
- {
- int print_to_specified_printer();
- int print_to_file();
- if (current_file[0]==0) {
- put_msg("NO FILE TO PRINT");
- XBell(tool_d,50);
- }
- else {
- if (figure_modified) /* modified without saving, confirm print */
- if (wmgr_confirm(canvas_win, conf_prnt) != -1)
- return;
-
- if (! strcmp("Default", printer)) {
- put_msg("Print figure %s on printer %s in %s mode",
- current_file,printer,print_landscape? "LANDSCAPE":"PORTRAIT");
- sprintf(prcmd,"f2ps -c %s %s | lpr -J %s",
- print_landscape? "-L":"-P",
- current_file,
- current_file);
- }
- else if (! strcmp("File", printer))
- init_msg_receiving(print_to_file, "Output file : ");
- else if (! strcmp("Specify", printer))
- init_msg_receiving(print_to_specified_printer, "Printer : ");
- else { /* default */
- put_msg("Print figure %s on printer %s in %s mode",
- current_file,printer,print_landscape? "LANDSCAPE":"PORTRAIT");
- sprintf(prcmd,"f2ps -c %s %s | lpr -J %s -P%s",
- print_landscape? "-L":"-P",
- current_file,
- current_file,
- printer);
- }
- if (system(prcmd)==127)
- put_msg("Error in printing");
- }
- }
-
- print_to_file(file)
- char *file;
- {
- if (*file == 0) {
- put_msg("Empty name");
- return;
- }
- sprintf(prcmd,"f2ps -c %s %s > %s",
- print_landscape? "-L":"-P",
- current_file,
- file);
- put_msg("Print figure %s to file %s in %s mode",
- current_file,file,print_landscape? "LANDSCAPE":"PORTRAIT");
- }
-
- print_to_specified_printer(specified_printer)
- char *specified_printer;
- {
- if (*specified_printer == 0) {
- put_msg("Empty name");
- return;
- }
- put_msg("Print figure %s on printer %s in %s mode",
- current_file,specified_printer,print_landscape? "LANDSCAPE":"PORTRAIT");
- sprintf(prcmd,"f2ps -c %s %s | lpr -J %s -P%s",
- print_landscape? "-L":"-P",
- current_file,
- current_file,
- specified_printer);
- }
-