home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 633.lha / WB_Printer / WBPrinter.h < prev    next >
C/C++ Source or Header  |  1992-04-20  |  5KB  |  203 lines

  1. /*
  2.  * WBPrinter - Put a printer icon on the workbench screen
  3.  * 
  4.  *
  5.  * Copyright (c) 1992, Mike Ruble
  6.  *
  7.  * Permission is hereby granted to distribute this program for any purposes
  8.  * whatsoever, so long as this notice, including the above copyright, is
  9.  * included with the distribution.
  10.  *
  11.  * 04/10/92 Written by Mike Ruble using SAS (Lattice) C 5.10b
  12.  *
  13.  */
  14.  
  15. #include <dos.h>
  16. #include <exec/types.h>
  17. #include <exec/memory.h>
  18. #include <exec/tasks.h>
  19. #include <dos/dos.h>
  20. #include <dos/dosextens.h>
  21. #include <dos/dostags.h>
  22. #include <libraries/gadtools.h>
  23. #include <libraries/asl.h>
  24. #include <intuition/intuition.h>
  25. #include <intuition/intuitionbase.h>
  26. #include <intuition/gadgetclass.h>
  27. #include <workbench/startup.h>
  28. #include <workbench/workbench.h>
  29. #include <proto/exec.h>
  30. #include <proto/timer.h>
  31. #include <proto/dos.h>
  32. #include <proto/intuition.h>
  33. #include <proto/wb.h>
  34. #include <proto/gadtools.h>
  35. #include <proto/icon.h>
  36. #include <proto/asl.h>
  37. #include <stdio.h>
  38. #include <string.h>
  39. #include <stdlib.h>
  40.  
  41.  
  42. #define GD_LPI_Gad                             0
  43. #define GD_Quality_Gad                         1
  44. #define GD_Pitch_Gad                           2
  45. #define GD_L_Marg_Gad                          3
  46. #define GD_R_Marg_Gad                          4
  47. #define GD_Pref_Gad                            5
  48. #define GD_Skip_Perf_Gad                       6
  49. #define GD_Page_Eject_Gad                      7
  50. #define GD_Spool_Gad                           8
  51. #define GD_Next_Gad                            9
  52. #define GD_Cancel_Gad                          10
  53. #define GD_Job_List_Gad                        11
  54. #define GD_Quit_Gad                            12
  55.  
  56. struct FileNode
  57. {
  58.    struct Node  nn_Node;
  59.    char        *nn_SpooledName;
  60. };
  61.  
  62. struct PrinterPrefs
  63. {
  64.    BYTE  pp_LinesPerInch;
  65.    BOOL  pp_SkipPerf;
  66.    BYTE  pp_PrintQuality;
  67.    BYTE  pp_PrintPitch;
  68.    UWORD pp_LeftMargin;
  69.    UWORD pp_RightMargin;
  70.    BOOL  pp_EjectPage;
  71. };
  72.  
  73. struct PrtMsg
  74. {
  75.    struct Message  pm_Message;
  76.    WORD            pm_Command;
  77. };
  78.  
  79. #define PRINTS_READY    (0x0001)
  80. #define CANCEL_PRINT    (0x0010)
  81. #define CANCEL_AND_DIE  (0x1111)
  82.  
  83. #define MEMORY_TYPE     (MEMF_PUBLIC | MEMF_CLEAR)
  84.  
  85. #define PRINT_FILE      (0x01)
  86. #define PRINTING_FILE   (0x10)
  87.  
  88.  
  89. struct ProcMsg                          /* startup message sent to child */
  90. {
  91.    struct Message msg;
  92.    void  *global_data;                  /* global data reg (A4)         */
  93. };
  94.  
  95.  
  96. /********** Libraries **********/
  97. struct Library       *GadToolsBase  = NULL;
  98. struct IntuitionBase *IntuitionBase = NULL;
  99. struct Library       *IconBase      = NULL;
  100. struct Library       *WorkbenchBase = NULL;
  101. struct Library       *GfxBase       = NULL;
  102. struct Library       *AslBase       = NULL;
  103.  
  104.  
  105. /********** AppWindow globals **********/
  106. struct Window        *Wnd        = 0l;
  107. struct Screen        *Scr        = 0l;
  108. APTR                  VisualInfo = 0l;
  109. struct Gadget        *GList      = 0l;
  110. struct Gadget        *Gadgets[13];
  111.  
  112. ULONG  window_top;
  113. ULONG  window_left;
  114.  
  115. UBYTE         *LPI_GadLabels[] = {
  116.     "6 Lines Per Inch",
  117.     "8 Lines Per Inch",
  118.     0l };
  119.  
  120. UBYTE         *Quality_GadLabels[] = {
  121.     "Draft Quality",
  122.     "Letter Quality",
  123.     0l };
  124.  
  125. UBYTE         *Pitch_GadLabels[] = {
  126.     "10-Pica  Pitch",
  127.     "12-Elite Pitch",
  128.     "15-Fine  Pitch",
  129.     0l };
  130.  
  131. struct TagItem    WindowTags[] = {
  132.     WA_Left,          119,
  133.     WA_Top,           49,
  134.     WA_Width,         375,
  135.     WA_Height,        146,
  136.     WA_IDCMP,         IDCMP_GADGETDOWN|IDCMP_GADGETUP|IDCMP_CLOSEWINDOW,
  137.     WA_Flags,         WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
  138.     WA_Gadgets,       0l,
  139.     WA_Title,         &"WBPrinter Preferences",
  140.     WA_CustomScreen,  0l,
  141.     TAG_DONE };
  142.  
  143.  
  144. /********** AppIcon globals **********/
  145. struct MsgPort       *AppPort;
  146. struct AppIcon       *Appicon;
  147. struct DiskObject    *icon;
  148.  
  149.  
  150. /********** Printer globals **********/
  151. struct List               *Print_Q;
  152. struct SignalSemaphore    *print_q_semaphore;
  153. struct PrinterPrefs        PrtPrefs;
  154.  
  155. char *PrinterSetup[9] =
  156. {
  157.    "\x1b[1z",    /* Six LPI     */
  158.    "\x1b[0z",    /* Eight LPI   */
  159.    "\x1b[0q",    /* Don't skip  */
  160.    "\x1b[nq",    /* Skip Perf   */
  161.    "\x1b[1\"z",  /* Draft Qual  */
  162.    "\x1b[2\"z",  /* Letter Qual */
  163.    "\x1b[0w",    /* Pica        */
  164.    "\x1b[2w",    /* Elite       */
  165.    "\x1b[4w"     /* Fine        */
  166. };
  167.  
  168. #define LPI   0
  169. #define SKIP  2
  170. #define QUAL  4
  171. #define PITCH 6
  172.  
  173.  
  174. /********** Misc. **********/
  175. char                       Name_Buffer[255];
  176. char                       FilePrefix[] = "PrintFile.";
  177. char                      *spooldir;
  178. ULONG                      filecount = 0;
  179. struct Preferences        *prefs;
  180. struct ProcMsg            *start_msg;
  181.  
  182.  
  183. /********** Declarations for CBACK **********/
  184. /* extern BPTR _Backstdout; */       /* standard output when run in background */
  185. /* long BackGroundIO = 0;   */       /* Flag to tell it we don't want to do I/O*/
  186. /* long stack = 4000;       */       /* Amount of stack space our task needs   */
  187. /* char *procname = "WBPrinter"; */  /* The name of the task to create         */
  188. /*long priority = 20;       */      /* The priority to run us at              */
  189.  
  190.  
  191. /********** Function definitions **********/
  192. void Do_MainFunc(void);
  193. void SetUp(void);
  194. void Tell_Print_Task(WORD);
  195. void Clear_Print_Q(void);
  196. void done(int);
  197. int  Do_AppWindow(void);
  198. int  Make_AppWindow(void);
  199. void Remove_AppWindow(void);
  200. void StartPrintTask(void);
  201. __saveds void PrintFiles(void);
  202.  
  203.