home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / printer / prfont12.lha / dumpscreen.c < prev    next >
C/C++ Source or Header  |  1990-02-21  |  3KB  |  116 lines

  1.  
  2.  
  3. /*
  4.  * do_print : dump the window to the printer
  5.  */
  6.  
  7. #include <stdio.h>
  8. #include "defines.h"
  9.  
  10. long show = FALSE; 
  11. long density = DENSITYDEF; 
  12.  
  13. extern long screenpos;
  14. extern struct Window    *Wind ;
  15. extern struct RastPort *rp;
  16. extern struct IntuiText *prfailtxt, oktxt;
  17.  
  18. union printerIO {
  19.     struct IOStdReq ios;
  20.     struct IODRPReq iodrp;
  21.     struct IOPrtCmdReq iopc;
  22.     };
  23.  
  24. extern union printerIO *CreateExtIO();
  25. extern struct MsgPort *CreatePort();
  26.  
  27. long special_dens[7] = { SPECIAL_DENSITY1, SPECIAL_DENSITY2, 
  28.     SPECIAL_DENSITY3, SPECIAL_DENSITY4, SPECIAL_DENSITY5, 
  29.     SPECIAL_DENSITY6, SPECIAL_DENSITY7 };
  30.  
  31. do_print()
  32. {
  33. struct IntuiMessage *GetMsg();
  34. struct IntuiMessage *message;    /* the message from the IDCMP */
  35. union printerIO *request;
  36. struct MsgPort *printerPort;
  37. struct ViewPort *vp;
  38. struct Screen *sc;
  39. UWORD code;        /* important info in message */
  40. ULONG class;
  41. APTR object;
  42. int hite;
  43.  
  44.     if (show)
  45.         {
  46.  
  47.         while(1)
  48.             {
  49.             WaitPort(Wind->UserPort);
  50.                 while( (message = (struct IntuiMessage *)
  51.                     GetMsg(Wind->UserPort) ) != NULL)
  52.                     {
  53.                     code = message->Code;  /* MENUNUM */
  54.                     object = message->IAddress;  /* Gadget */
  55.                     class = message->Class;  /* IDCMP Flags */
  56.                     ReplyMsg(message);  /* Free the sender */
  57.                     switch (class)
  58.                         {
  59.                         case CLOSEWINDOW :
  60.                             done(0);   /* close gadget clicked */
  61.                             break;
  62.                         case MOUSEBUTTONS :
  63.                             if (code == SELECTUP) return;
  64.                         }
  65.                     }
  66.             }
  67.         }
  68.  
  69.     /* set up for dump rastport request */
  70.     printerPort = CreatePort("myprport",0L);
  71.     request = CreateExtIO(printerPort, sizeof(union printerIO));
  72.     if (OpenDevice("printer.device",0L,request,0L) !=0)
  73.         {
  74.         AutoRequest(Wind,&prfailtxt,0L,&oktxt,0L,0L,300L,75L);
  75.         goto cleanup;
  76.         }
  77.  
  78.     if (screenpos > Wind->Height) hite = Wind->Height-SCREENTOP;
  79.     else hite = screenpos-SCREENTOP;
  80.  
  81.     request->iodrp.io_Command = PRD_DUMPRPORT;
  82.     request->iodrp.io_RastPort = rp;
  83.     sc = Wind->WScreen;
  84.     vp = &sc->ViewPort;
  85.     request->iodrp.io_ColorMap = vp->ColorMap;
  86.     request->iodrp.io_Modes = vp->Modes;
  87.     request->iodrp.io_RastPort = rp;
  88.     request->iodrp.io_SrcX=2L;
  89.     request->iodrp.io_SrcY=SCREENTOP;
  90.     request->iodrp.io_SrcWidth=(long)Wind->Width-3;
  91.     request->iodrp.io_SrcHeight=(long) hite;
  92.     request->iodrp.io_DestCols=0L;
  93.     request->iodrp.io_DestRows=0L;
  94.     request->iodrp.io_Special=SPECIAL_ASPECT | SPECIAL_FULLCOLS;
  95.     request->iodrp.io_Special |= special_dens[density-1];
  96.     DoIO(request);
  97.     CloseDevice(request);
  98.   cleanup:
  99.     DeleteExtIO(request, sizeof(union printerIO));
  100.     DeletePort(printerPort);
  101.  
  102.     /* check for close gadget */
  103.     while( (message = (struct IntuiMessage *)
  104.         GetMsg(Wind->UserPort) ) != NULL)
  105.         {
  106.         class = message->Class;  /* IDCMP Flags */
  107.         ReplyMsg(message);  /* Free the sender */
  108.         switch (class)
  109.             {
  110.             case CLOSEWINDOW :
  111.                 done(0);   /* close gadget clicked */
  112.                 break;
  113.             }
  114.         }
  115. }
  116.