home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d5xx / d547 / powersource.lha / PowerSource / source.lzh / source / special.c < prev    next >
C/C++ Source or Header  |  1991-09-15  |  3KB  |  101 lines

  1. /*----------------------------------------------------------------------*
  2.     special.c version 3.0 - © Copyright 1991 Jaba Development
  3.  
  4.     Author : Jan van den Baard
  5.     Purpose: Some special routines.
  6.  *----------------------------------------------------------------------*/
  7. extern struct RastPort      *MainRP;
  8. extern struct Window        *MainWindow;
  9. extern struct Screen        *MainScreen;
  10. extern struct GadgetList     Gadgets;
  11. extern struct NewWindow      nw_main;
  12.  
  13. /*
  14.  * Dumps all gadget id's to the printer
  15.  * (I keep forgetting what labels I gave my gadgets....)
  16.  */
  17. void DumpID( void )
  18. {
  19.     struct MyGadget *gd;
  20.     BPTR             prtfile;
  21.  
  22.     disable_window();
  23.     buisy();
  24.     sst("Printing...");
  25.     if((prtfile = Open("PRT:",MODE_OLDFILE))) {
  26.         for(gd = Gadgets.Head; gd->Succ; gd = gd->Succ)
  27.             WriteFormat(prtfile,"%s_ID = %ld\n",&gd->GadgetLabel[0],gd->Gadget.GadgetID);
  28.         Close(prtfile);
  29.     } else {
  30.         enable_window();
  31.         ok();
  32.         Error("Can't find the printer !");
  33.         goto end;
  34.     }
  35.     enable_window();
  36.     ok();
  37. end:
  38.     refresh();
  39. }
  40.  
  41. #include <devices/printer.h>
  42.  
  43. /*
  44.  * Print the current window. Most of you will
  45.  * probably find this option bullshit but I
  46.  * think there is someone out there who finds
  47.  * it usefull.
  48.  */
  49. void HardCopy( void )
  50. {
  51.     struct  MsgPort         *PrtPort = NULL;
  52.     union PrinterIO {
  53.         struct IOStdReq      pio_StdReq;
  54.         struct IODRPReq      pio_DRPReq;
  55.         struct IOPrtCmdReq   pio_CmdReq;
  56.     } *PrtReq = NULL;
  57.     ULONG   Dev = 1L;
  58.  
  59.     sst("Printing...");
  60.  
  61.     while(read_msg(MainWindow));
  62.     ModifyIDCMP(MainWindow,SIZEVERIFY);
  63.  
  64.     if(NOT (PrtPort = CreatePort("PowerSource.PRINT",0L))) {
  65.         Error("Can't create message port !");
  66.         goto error;
  67.     }
  68.     if(NOT (PrtReq = (union PrinterIO *)CreateExtIO(PrtPort,(ULONG)sizeof(union PrinterIO)))) {
  69.         Error("Can't create printer request !");
  70.         goto error;
  71.     }
  72.     if((Dev = OpenDevice("printer.device",0,(struct IORequest *)PrtReq,0))) {
  73.         Error("Can't open the printer.device !");
  74.         goto error;
  75.     }
  76.     disable_window();
  77.     buisy();
  78.     PrtReq->pio_DRPReq.io_Command  = PRD_DUMPRPORT;
  79.     PrtReq->pio_DRPReq.io_RastPort = MainRP;
  80.     PrtReq->pio_DRPReq.io_ColorMap = MainScreen->ViewPort.ColorMap;
  81.     PrtReq->pio_DRPReq.io_Modes    = MainScreen->ViewPort.Modes;
  82.     PrtReq->pio_DRPReq.io_SrcX     = 0;
  83.     PrtReq->pio_DRPReq.io_SrcY     = 0;
  84.     PrtReq->pio_DRPReq.io_SrcWidth = MainWindow->Width;
  85.     PrtReq->pio_DRPReq.io_SrcHeight= MainWindow->Height;
  86.     PrtReq->pio_DRPReq.io_DestCols = (LONG)(22*MainWindow->Width);
  87.     PrtReq->pio_DRPReq.io_DestRows = (LONG)(22*MainWindow->Height);
  88.     PrtReq->pio_DRPReq.io_Special  = SPECIAL_MILCOLS|SPECIAL_MILROWS|SPECIAL_ASPECT;
  89.  
  90.     DoIO((struct IORequest *)PrtReq);
  91.     enable_window();
  92.     ok();
  93. error:
  94.     if(NOT Dev)     CloseDevice((struct IORequest *)PrtReq);
  95.     if(PrtReq)      DeleteExtIO((struct IORequest *)PrtReq);
  96.     if(PrtPort)     DeletePort(PrtPort);
  97.     while(read_msg(MainWindow));
  98.     ModifyIDCMP(MainWindow,nw_main.IDCMPFlags);
  99.     refresh();
  100. }
  101.