home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume8 / xfig2.8 / part02 / print.c < prev    next >
C/C++ Source or Header  |  1990-07-02  |  3KB  |  98 lines

  1. /* 
  2.  *    FIG : Facility for Interactive Generation of figures
  3.  *
  4.  *    Copyright (c) 1985 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
  5.  *    January 1985.
  6.  *    1st revision : Aug 1985.
  7.  *
  8.  *    print.c
  9.  *
  10.  *    %W%    %G%
  11. */
  12. #include "fig.h"
  13. #include "resources.h"
  14.  
  15. /*******************  imported global variables and procedures  **************/
  16.  
  17. extern char    current_file[];
  18. extern int    print_landscape;
  19. extern int    figure_modified;
  20. extern char    *printer;
  21.  
  22. extern        put_msg();
  23. extern        wmgr_confirm();
  24.  
  25. static char prcmd[200];
  26. static char *conf_prnt =
  27.         "Figure hasn't been saved, PRINT with LEFT button, CANCEL with MIDDLE or RIGHT";
  28.  
  29. print_figure()
  30. {
  31. int    print_to_specified_printer();
  32. int    print_to_file();
  33.     if (current_file[0]==0) {
  34.         put_msg("NO FILE TO PRINT");
  35.         XBell(tool_d,50);
  36.     }
  37.     else {
  38.         if (figure_modified)    /* modified without saving, confirm print */
  39.             if (wmgr_confirm(canvas_win, conf_prnt) != -1)
  40.             return;
  41.  
  42.                 if (! strcmp("Default", printer)) {
  43.           put_msg("Print figure %s on printer %s in %s mode",
  44.             current_file,printer,print_landscape? "LANDSCAPE":"PORTRAIT");
  45.           sprintf(prcmd,"f2ps -c %s %s | lpr -J %s",
  46.               print_landscape? "-L":"-P", 
  47.               current_file,
  48.               current_file);
  49.         }
  50.                 else if (! strcmp("File", printer))
  51.                   init_msg_receiving(print_to_file, "Output file : ");
  52.                 else if (! strcmp("Specify", printer))
  53.                   init_msg_receiving(print_to_specified_printer, "Printer : ");
  54.                 else {    /* default */
  55.           put_msg("Print figure %s on printer %s in %s mode",
  56.             current_file,printer,print_landscape? "LANDSCAPE":"PORTRAIT");
  57.           sprintf(prcmd,"f2ps -c %s %s | lpr -J %s -P%s",
  58.             print_landscape? "-L":"-P", 
  59.             current_file,
  60.             current_file, 
  61.             printer);
  62.         }
  63.         if (system(prcmd)==127)
  64.             put_msg("Error in printing");
  65.     }
  66. }
  67.  
  68. print_to_file(file)
  69. char    *file;
  70. {
  71.     if (*file == 0) {
  72.         put_msg("Empty name");
  73.         return;
  74.         }
  75.     sprintf(prcmd,"f2ps -c %s %s > %s",
  76.         print_landscape? "-L":"-P",
  77.         current_file,
  78.         file);
  79.     put_msg("Print figure %s to file %s in %s mode",
  80.       current_file,file,print_landscape? "LANDSCAPE":"PORTRAIT");
  81. }
  82.  
  83. print_to_specified_printer(specified_printer)
  84. char    *specified_printer;
  85. {
  86.     if (*specified_printer == 0) {
  87.         put_msg("Empty name");
  88.         return;
  89.         }
  90.     put_msg("Print figure %s on printer %s in %s mode",
  91.       current_file,specified_printer,print_landscape? "LANDSCAPE":"PORTRAIT");
  92.     sprintf(prcmd,"f2ps -c %s %s | lpr -J %s -P%s",
  93.       print_landscape? "-L":"-P", 
  94.       current_file,
  95.       current_file, 
  96.       specified_printer);
  97. }
  98.