home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / other / cled122s / source / printer.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-14  |  13.8 KB  |  364 lines

  1. #include "define.h"
  2. #include <obdefs.h>                /* OBJECT DEFINTIONS              */
  3. #include <gemdefs.h>               /* GEM DEFINITIONS                */
  4. #include <osbind.h>                /* BIOS/GEMDOS/XBIOS FUNCTIONS    */
  5. #include <vdibind.h>               /* VDI DECLERATIONS AND BINDINGS  */
  6. #include <aesbind.h>               /* BINDINGS FOR AES               */
  7. #include <stdio.h>                 /* STANDARD I/O ROUTINES          */
  8. #include "cled.h"
  9. #include "rpcfg.h"
  10.  
  11. int space[48]= {32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32
  12. };
  13. int graph[3] = {45,0,0};               /* Size of graphic and one blank column */
  14. int leftb[8] = {6,0,255,0,0,0,0,0};    /* Size 6, vertical bar, far left */
  15. int rightb[8]= {6,0,0,0,0,0,0,255};    /* Size 6, vertical bar, far right */
  16. int nline[2] = {10,13};                /* New line */
  17.  
  18. extern char data[3][40];               /* storage for graphic data         */
  19. extern char songs[16][47];             /* storage for songs & labels       */
  20.  
  21.  
  22. extern struct COMMAND print_codes[11];     /* Array to hold printer commands */
  23. extern char print_name[80];                /* Printers name */ 
  24. extern int coloura,quality;                 /* Have we got colour, nlq? 0=No */
  25.  
  26. /****************************************************************************
  27. SUBROUTINE  : print_setup            VERSION  : 1.1
  28. AUTHOR      : ROBERT ALLEY           DATE     : 02/07/90
  29. DESCRIPTION : Do a dialog box to get printer setup info.
  30. LOGIC USED  : STEP 1.   Get address of dialog, pass side1 and side2 as well
  31.                         as their lengths for ftexts, get dialogs centred 
  32.                         co-ords, set aside space for dialog, draw it.  While
  33.                         value returned is less than the exit values : set 
  34.                         colour or style based on return.  Unset both exit 
  35.                         buttons.  Free the memory allocated.  Return the
  36.                         exit status.
  37. RETURNS     : val          I        Exit status (DOPRINT or NOPRINT).
  38. PARAMETERS  : colour       *I       Pointer to colour to print in.
  39.               style        *I       Pointer to print style to use.
  40.               side1,side2  *CH      Side labels
  41. VARIABLES   : dialog       *OBJECT  Dialog to form
  42.               val          I        Value returned from dialog
  43.               cx,cy,cw,ch  I        Co-ords of centered dialog box.
  44. NOTES       : Form_dial changed (zeros before cx,cy etc. instead of after)
  45.               to fix non-removal bug.
  46. USAGE       : print_steup(&colour,&style);
  47. ****************************************************************************/
  48. print_setup(colour,style,side1,side2)
  49. int *style,*colour;
  50. char *side1,*side2;
  51. {
  52.    OBJECT *dialog;
  53.    int val=0;
  54.    int cx, cy, cw, ch;
  55.  
  56.    rsrc_gaddr(0, PRINT, (OTYPE) &dialog);
  57.    print_name[40]=0;
  58.    ((TEDINFO *)dialog[PRNTNAME].ob_spec)->te_ptext=print_name;
  59.    ((TEDINFO *)dialog[PRNTNAME].ob_spec)->te_txtlen =strlen(print_name);
  60.    if (coloura==0) {
  61.       objc_change(dialog,CBLACK,0,0,0,0,0,DISABLED,0);
  62.       objc_change(dialog,CBLUE,0,0,0,0,0,DISABLED,0);
  63.       objc_change(dialog,CRED,0,0,0,0,0,DISABLED,0);
  64.    }
  65.    else {
  66.       objc_change(dialog,CBLACK,0,0,0,0,0,SELECTED,0);
  67.       objc_change(dialog,CBLUE,0,0,0,0,0,NORMAL,0);
  68.       objc_change(dialog,CRED,0,0,0,0,0,NORMAL,0);
  69.       *colour=CBLACK;
  70.    }
  71.    if (quality==0) {
  72.       objc_change(dialog,NLQ,0,0,0,0,0,DISABLED,0);
  73.       objc_change(dialog,DRAFT,0,0,0,0,0,DISABLED,0);
  74.    }
  75.    else {
  76.       objc_change(dialog,NLQ,0,0,0,0,0,SELECTED,0);
  77.       objc_change(dialog,DRAFT,0,0,0,0,0,NORMAL,0);
  78.       *style=NLQ;
  79.    }
  80.    ((TEDINFO *)dialog[SIDE1].ob_spec)->te_ptext = side1;
  81.    ((TEDINFO *)dialog[SIDE1].ob_spec)->te_txtlen = 9;
  82.    ((TEDINFO *)dialog[SIDE2].ob_spec)->te_ptext = side2;
  83.    ((TEDINFO *)dialog[SIDE2].ob_spec)->te_txtlen = 9;
  84.    form_center(dialog, &cx, &cy, &cw, &ch);
  85.    form_dial(FMD_START, 0,0,0,0,cx, cy, cw, ch);
  86.    objc_draw(dialog, 0, 10, cx, cy, cw, ch);
  87.    while (val < DOPRINT) {
  88.       val=form_do(dialog, 0);
  89.       if ((val==NLQ)||(val==DRAFT))
  90.          *style=val;
  91.       if ((val >=CBLUE)&&(val <=CBLACK))
  92.          *colour=val;
  93.   }
  94.    objc_change(dialog,NOPRINT,0,0,0,0,0,0,1);
  95.    objc_change(dialog,DOPRINT,0,0,0,0,0,0,1);
  96.    form_dial(FMD_FINISH, 0,0,0,0,cx, cy, cw, ch);
  97.    return val;
  98. }
  99.  
  100. /****************************************************************************
  101. SUBROUTINE  : print                  VERSION  : 1.0
  102. AUTHOR      : ROBERT ALLEY           DATE     : ??/??/89
  103. DESCRIPTION : Print string on printer.
  104. LOGIC USED  : STEP 1.   Loop from 0 to length, print corresponding char.
  105. PARAMETERS  : string       C81  String to be printed
  106.               length       I    Numbers of characters to print.
  107. VARIABLES   : loop         I    Loop counter.
  108.               out          I    Current character being printed.
  109. USAGE       : print(string,length);
  110. ****************************************************************************/
  111. print (string,length)
  112.  
  113. int string[81];
  114. int  length;
  115. {
  116.    int loop;
  117.    int out;
  118.  
  119.    for (loop = 0;loop < length; loop++) {
  120.       out = string[loop];
  121.       Cprnout(out);
  122.    }
  123. }
  124.  
  125. /****************************************************************************
  126. SUBROUTINE  : printc                 VERSION  : 1.0
  127. AUTHOR      : ROBERT ALLEY           DATE     : 11/07/90
  128. DESCRIPTION : Print a command on the printer.
  129. LOGIC USED  : STEP 1.   Loop from 0 to length, print corresponding char.
  130. PARAMETERS  : string       C81  String to be printed
  131.               length       I    Numbers of characters to print.
  132. VARIABLES   : loop         I    Loop counter.
  133.               out          I    Current character being printed.
  134. USAGE       : print(string,length);
  135. ****************************************************************************/
  136. printc (command,var)
  137.  
  138. struct COMMAND command;
  139. int var;
  140.  
  141. {
  142.    int loop;
  143.    int out;
  144.    
  145.    for (loop = 0;loop < command.length; loop++) {
  146.       out=*command.list++;
  147.       if (out==0x80) Cprnout(var);
  148.       else Cprnout(out);
  149.    }
  150. }
  151. /***************************************************************************
  152. SUBROUTINE  : print_label            VERSION  : 1.2
  153. AUTHOR      : ROBERT ALLEY           DATE     : 02/07/90
  154. DESCRIPTION : Print the cassette label on the line printer.
  155. LOGIC USED  : STEP 1.   While printer not ready, check its status, if
  156.                         not ready, ask user if they want to quit.  If they
  157.                         do return.  While status is print, get printer set 
  158.                         up info, if they said print, print.  Ask if they want
  159.                         to do another.
  160. VARIABLES   : colour       I        Colour to print in.
  161.               style        I        Style to print in.
  162.               status       I        Status of print (1=do print,  any 
  163.                                      other = dont)
  164.               side1,side2  CH       Headings for the two sides
  165.               label        CH       Current heading being printed
  166.               loop,outloop I        loop counters
  167. REQD. SUBPG.: print_setup
  168.               print
  169. USAGE       : print_label();
  170. ****************************************************************************/
  171. print_label()
  172. {
  173.    static int colour=CBLACK;
  174.    static int style=NLQ;
  175.    static char side1[9]="SIDE 1",side2[9]="SIDE 2";
  176.    char label[19];   
  177.    int status=1;
  178.    int loop,outloop,abort;
  179.    long printred=0L;
  180.  
  181.    while (printred==0L) {
  182.       printred=Bcostat(0);
  183.       if (printred==0L) {
  184.          abort=form_alert(1,"[1][Printer Not Ready|Check power, online,|connections etc.][Retry|Abort]");
  185.          if (abort==2) return(0);
  186.       }
  187.    }
  188.    while (status==1) {
  189.       status=print_setup(&colour,&style,side1,side2);
  190.       if (status==DOPRINT) {
  191.             if (coloura==1) {
  192.                switch (colour) {
  193.                    case CBLACK :
  194.                                 printc(print_codes[0],0);
  195.                                 break;
  196.                    case CBLUE  :
  197.                                 printc(print_codes[2],0);
  198.                                 break;
  199.                    case CRED   :
  200.                                 printc(print_codes[1],0);
  201.                                 break;
  202.                }
  203.             }
  204.             if (quality==1) {
  205.                switch (style) {
  206.                    case NLQ    :
  207.                                printc(print_codes[5],0);
  208.                                break;
  209.                    case DRAFT  :
  210.                                printc(print_codes[6],0);
  211.                                break;
  212.                }
  213.             }
  214.             printc(print_codes[4],0);
  215.             printc(print_codes[7],0);
  216.             printc(print_codes[3],23);
  217.             print(space,48);
  218.             printc(print_codes[8],0);
  219.             print(nline,2);
  220.             printc(print_codes[9],0);
  221.             print(leftb,8);
  222.             print(space,46);
  223.             printc(print_codes[9],0);
  224.             print(rightb,8);
  225.             print(nline,2);
  226.             for(outloop=0; outloop<3;outloop++) {
  227.                printc(print_codes[9],0);
  228.                print(leftb,8);
  229.                if (outloop==1) {
  230.                   sprintf(label,"     %8.8s     ",side1);
  231.                   for (loop=0;loop<18; Cprnout( (int)label[loop++] ));
  232.                }
  233.                else 
  234.                   print(space,18);
  235.                printc(print_codes[9],0);
  236.                print(graph,3);
  237.                for(loop=0; loop<40; loop++)
  238.                   Cprnout(data[outloop][loop]);
  239.                Cprnout(0); Cprnout(0); Cprnout(0); Cprnout(0);
  240.                if (outloop==1) {
  241.                   sprintf(label,"    %8.8s       ",side2);
  242.                   for (loop=0;loop<19; Cprnout( (int)label[loop++] ));
  243.                }
  244.                else
  245.                   print(space,19);
  246.                printc(print_codes[9],0);
  247.                print(rightb,8);
  248.                print(nline,2);
  249.             }
  250.             printc(print_codes[9],0);
  251.             print(leftb,8);
  252.             print(space,46);
  253.             printc(print_codes[9],0);
  254.             print(rightb,8);
  255.             Cprnout(13);
  256.             printc(print_codes[7],0);
  257.             print(space,48);
  258.             printc(print_codes[8],0);
  259.             print(nline,2);
  260.             printc(print_codes[3],16);
  261.  
  262.             for (loop=0;loop<13;loop++) {           /* print songs */
  263.                printc(print_codes[9],0);
  264.                print(leftb,8);
  265.                print(space,22);
  266.                printc(print_codes[10],0);
  267.                print(space,23);
  268.                printc(print_codes[9],0);
  269.                print(rightb,8);
  270.                print(nline,2);
  271.                printc(print_codes[9],0);
  272.                print(leftb,8);
  273.                for (outloop=0;outloop<22;outloop++)
  274.                   Cprnout(songs[loop][outloop]);
  275.                printc(print_codes[10],0);
  276.                for (outloop=23;outloop<46;outloop++)
  277.                   Cprnout(songs[loop][outloop]);
  278.                printc(print_codes[9],0);
  279.                print(rightb,8);
  280.                print(nline,2);
  281.             }
  282.                                                 /* print bot of songs */
  283.             printc(print_codes[9],0);
  284.             print(leftb,8);
  285.             print(space,46);
  286.             printc(print_codes[9],0);
  287.             print(rightb,8);
  288.             Cprnout(13);
  289.             printc(print_codes[7],0);
  290.             print(space,48);
  291.             printc(print_codes[8],0);
  292.             print(nline,2);
  293.               
  294.             printc(print_codes[3],23);
  295.                                                 /* print top of spine */
  296.             printc(print_codes[9],0);
  297.             print(leftb,8);
  298.             print(space,46);
  299.             printc(print_codes[9],0);
  300.             print(rightb,8);
  301.             print(nline,2);
  302.                                                  /* print spine */
  303.             printc(print_codes[9],0);
  304.             print(leftb,8);
  305.             for (outloop=0;outloop<46;outloop++)
  306.                Cprnout(songs[14][outloop]);
  307.             printc(print_codes[9],0);
  308.             print(rightb,8);
  309.             print(nline,2);
  310.  
  311.             printc(print_codes[9],0);
  312.             print(leftb,8);
  313.             print(space,46);
  314.             printc(print_codes[9],0);
  315.             print(rightb,8);
  316.             print(nline,2);
  317.             
  318.             printc(print_codes[9],0);
  319.             print(leftb,8);
  320.             for (outloop=0;outloop<46;outloop++)
  321.                Cprnout(songs[15][outloop]);
  322.             printc(print_codes[9],0);
  323.             print(rightb,8);
  324.             print(nline,2);
  325.  
  326.                                /* print bot of spine */
  327.             printc(print_codes[9],0);
  328.             print(leftb,8);
  329.             print(space,46);
  330.             printc(print_codes[9],0);
  331.             print(rightb,8);
  332.             Cprnout(13);
  333.             printc(print_codes[7],0);
  334.             print(space,48);
  335.             printc(print_codes[8],0);
  336.             print(nline,2);
  337.  
  338.             for(loop=0;loop<4;loop++) {           /* print tail */
  339.                printc(print_codes[9],0);
  340.                print(leftb,8);
  341.                print(space,46);
  342.                printc(print_codes[9],0);
  343.                print(rightb,8);
  344.                print(nline,2);
  345.             }
  346.  
  347.                                  /* print bot of label */
  348.             printc(print_codes[9],0);
  349.             print(leftb,8);
  350.             print(space,46);
  351.             printc(print_codes[9],0);
  352.             print(rightb,8);
  353.             Cprnout(13);
  354.             printc(print_codes[7],0);
  355.             print(space,48);
  356.             printc(print_codes[8],0);
  357.             print(nline,2);
  358.  
  359.             status=form_alert(2,"[0][Print again][Yes|No]");
  360.       }
  361.    }
  362. }
  363.  
  364.