home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / misc / volume06 / kirond.raw < prev    next >
Encoding:
Internet Message Format  |  1991-08-27  |  65.2 KB

  1. From decwrl!ucbvax!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!allbery Mon May  1 23:18:43 PDT 1989
  2. Article 864 of comp.sources.misc:
  3. Path: decwrl!ucbvax!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!allbery
  4. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5. Newsgroups: comp.sources.misc
  6. Subject: v06i095: KironDraw v2.4B
  7. Keywords: comp.sources.unix, shareware, suntools, graphics
  8. Message-ID: <53487@uunet.UU.NET>
  9. Date: 30 Apr 89 22:02:18 GMT
  10. Sender: allbery@uunet.UU.NET
  11. Reply-To: kiron@db9.cs.concordia.ca
  12. Lines: 2093
  13. Approved: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  14.  
  15. Posting-number: Volume 6, Issue 95
  16. Submitted-by: kiron@db9.cs.concordia.ca
  17. Archive-name: kirondraw
  18.  
  19. [An earlier version of this program was released as "sundraw"; it has been
  20. renamed to avoid confusion with the program recently released by Sun.  ++bsa]
  21.  
  22. # This is a shell archive.  Remove anything before this line, then
  23. # unpack it by saving it in a file and typing "sh file".  (Files
  24. # unpacked will be owned by you and have default permissions.)
  25. #
  26. # This archive contains:
  27. # README kirondraw.c kirondraw.l
  28.  
  29. echo x - README
  30. cat > "README" << '//E*O*F README//'
  31. KironDraw Version 2.4B
  32. ======================
  33.  
  34.     This program is essentially a bitmap graphic editor for Sun workstation
  35. running suntools. Included in this archive are the source code and the manual page.
  36. To create the executable code type :
  37.  
  38.     cc kirondraw.c -lcgi -lsuntool -lsunwindow -lpixrect -lm -fswitch -pipe -O -o KironDraw
  39.  
  40. This program is shareware... if you see a use for it, please send $5 to 
  41.  
  42.          Kiron Bondale
  43.          4195 Beaconsfield Avenue
  44.          Montreal, Quebec
  45.          Canada
  46.          H4A 2H4
  47.  
  48. Registering the program will ensure that you get free upgrades regularly.
  49. (and believe me, upgrades will be MANY!!!!!)
  50. //E*O*F README//
  51.  
  52. echo x - kirondraw.c
  53. cat > "kirondraw.c" << '//E*O*F kirondraw.c//'
  54. /*************************************************************************/
  55. /* KironDraw V 2. B                             */
  56. /* by : Kiron D. Bondale                          */
  57. /* logfile :                                 */
  58. /* (from Version 2 onwards... I am royally lazy at such things!!!      */
  59. /* 2.1B - all icons and images are part of the program             */
  60. /* 2.2B - improved error checking for loading rasters/scripts         */
  61. /* 2.3B - Flipping/inversion/resizing of clipboard contents                */
  62. /* 2.4B - icon for program was changed... I made a boo-boo         */
  63. /*************************************************************************/
  64.  
  65. #include <cgipw.h>
  66. #include <suntool/sunview.h>
  67. #include <suntool/canvas.h>
  68. #include <suntool/panel.h>
  69. #include <suntool/scrollbar.h>
  70. #include <suntool/textsw.h>
  71. #include <pixrect/pixrect_hs.h>
  72. #include <strings.h>
  73. #include <math.h>
  74. #include <stdio.h>
  75. #include <sys/param.h>
  76.  
  77. /* Remove the following line if a Printronix printer is not used... */
  78. #define PRINTRONIX 1
  79.  
  80. #define MAXPRINWID 1000
  81. #define NROWS 720
  82. #define NCOLS 560
  83. #define NORMALW 640
  84. #define NORMALH 544
  85. #define SWIDTH 1088
  86. #define SHEIGHT 1000
  87. #define LINE_LEN 72
  88. #define BLOCK_SIZE 512
  89. #define SRC_SIZE 2*BLOCK_SIZE
  90.  
  91. char            src_buf[SRC_SIZE];
  92. char            scan_line[LINE_LEN];
  93.  
  94.  
  95. static short    icon_image[] = {
  96.     0x0000,0x0000,0x0000,0x009C,0x0000,0x0000,0x0000,0x0122,
  97.         0x0000,0x0000,0x0000,0x0261,0x0000,0x0000,0x0000,0x0791,
  98.         0xFFFF,0xFFFF,0xFFFF,0xF989,0xFFFF,0xFFFF,0xFFFF,0xFA46,
  99.         0xC000,0x0000,0x0000,0x1E26,0xC000,0x0000,0x0000,0x1B1A,
  100.         0xC000,0x0000,0x0000,0x149A,0xC000,0x0000,0x0220,0x296E,
  101.         0xC03E,0x0000,0x0440,0x5262,0xC041,0x0000,0x1100,0xA4A2,
  102.         0xC080,0x8000,0x0881,0x498A,0xC100,0x4000,0x0222,0x928A,
  103.         0xC200,0x2000,0x0445,0x2622,0xC200,0x2003,0x000A,0x4A22,
  104.         0xC200,0x2004,0x0014,0x988A,0xC200,0x200C,0x0029,0x388A,
  105.         0xC200,0x2010,0x0052,0x5A22,0xC100,0x4000,0x00A4,0x9A22,
  106.         0xC080,0x8020,0x0149,0x188A,0xC041,0x0040,0x0292,0x188A,
  107.         0xC03E,0x0020,0x0524,0x1A22,0xC000,0x0020,0x0A48,0x1A22,
  108.         0xC000,0x0020,0x1490,0x188A,0xC000,0x0040,0x2920,0x188A,
  109.         0xC000,0x0100,0x5240,0x1A22,0xC000,0x0200,0xA480,0x1A22,
  110.         0xC000,0x3401,0x4900,0x188A,0xC000,0x4002,0x9200,0x188A,
  111.         0xC000,0x8005,0x2400,0x1A22,0xC000,0x000A,0x4800,0x1A22,
  112.         0xC003,0x0034,0x9000,0x188A,0xC000,0x0029,0x2000,0x188A,
  113.         0xC000,0x0052,0x4000,0x1A22,0xC000,0x00E4,0x8000,0x1A22,
  114.         0xC000,0x0129,0x0000,0x188A,0xC000,0x0112,0x0000,0x188A,
  115.         0xC000,0x020C,0x0000,0x1A22,0xC000,0x0218,0x0000,0x1A22,
  116.         0xC000,0x0660,0x0000,0x188A,0xC000,0x0780,0x0000,0x188A,
  117.         0xC000,0x0E00,0x0000,0x1A22,0xC000,0x0C00,0x0000,0x1A22,
  118.         0xC000,0x0300,0x0000,0x188A,0xC000,0x00C0,0x0000,0x188A,
  119.         0xC000,0x0030,0x0000,0x1A22,0xC000,0x000C,0x0000,0x1A22,
  120.         0xC000,0x0003,0x0000,0x188A,0xC000,0x0000,0xC000,0x188A,
  121.         0xC000,0x0000,0x3000,0x1A22,0xC000,0x0000,0x0800,0x1A22,
  122.         0x4440,0x0001,0xC000,0x008A,0x4805,0x0C51,0x250C,0x448A,
  123.         0x50C6,0x9269,0x2682,0x4422,0x7044,0x1249,0x240E,0x5424,
  124.         0x4844,0x1249,0x2412,0x5488,0x4444,0x0C49,0xC40A,0x2890,
  125.         0x0000,0x0000,0x0000,0x0020,0x0000,0x0000,0x0000,0x0240,
  126.         0xC000,0x0000,0x0000,0x1880,0xC000,0x0000,0x0000,0x1900,
  127.         0xFFFF,0xFFFF,0xFFFF,0xFA00,0xFFFF,0xFFFF,0xFFFF,0xFC00
  128. };
  129.  
  130. static short    points_dat[] = {
  131.     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03E0, 0x03E0, 0x03E0,
  132.     0x03E0, 0x03E0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
  133. };
  134. mpr_static(sued_point, 16, 16, 1, points_dat);
  135.  
  136. static short    line_dat[] = {
  137.     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7FFE, 0x7FFE,
  138.     0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
  139. };
  140. mpr_static(sued_line, 16, 16, 1, line_dat);
  141.  
  142. static short    box_dat[] = {
  143.     0x0000, 0x7FFE, 0x7FFE, 0x6006, 0x6006, 0x6006, 0x6006, 0x6006,
  144.     0x6006, 0x6006, 0x6006, 0x6006, 0x6006, 0x7FFE, 0x7FFE, 0x0000
  145. };
  146. mpr_static(sued_box, 16, 16, 1, box_dat);
  147.  
  148. static short    circle_dat[] = {
  149.     0x03E0, 0x0FF8, 0x1C1C, 0x380E, 0x3006, 0x6003, 0x6003, 0x6003,
  150.     0x6003, 0x6003, 0x3006, 0x380E, 0x1C1C, 0x0FF8, 0x03E0, 0x0000
  151. };
  152. mpr_static(sued_circle, 16, 16, 1, circle_dat);
  153.  
  154. static short    datflow_dat[] = {
  155.     0x0000, 0x0000, 0x0000, 0xFFFE, 0xFFFE, 0x8000, 0x8000, 0x8000,
  156.     0x8000, 0x8000, 0xFFFE, 0xFFFE, 0x0000, 0x0000, 0x0000, 0x0000
  157. };
  158. mpr_static(sued_data, 16, 16, 1, datflow_dat);
  159.  
  160. static short    some_dat[] = {
  161.     0x0000, 0x0000, 0x0000, 0x0000, 0x1FFE, 0x1FFE, 0x3006, 0x3006,
  162.     0x600C, 0x600C, 0x7FFC, 0x7FFC, 0x0000, 0x0000, 0x0000, 0x0000
  163. };
  164. mpr_static(sued_some, 16, 16, 1, some_dat);
  165.  
  166. static short    text_dat[] = {
  167.     0x0000, 0x0000, 0x0000, 0x0000, 0x6200, 0x920C, 0x1392, 0x7250,
  168.     0x9252, 0x7B8C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
  169. };
  170. mpr_static(sued_text, 16, 16, 1, text_dat);
  171.  
  172. static short    ellipse_dat[] = {
  173.     0x0000, 0x0000, 0x0000, 0x0FF0, 0x3FFC, 0x700E, 0xC003, 0x8001,
  174.     0xC003, 0x700E, 0x3FFC, 0x0FF0, 0x0000, 0x0000, 0x0000, 0x0000
  175. };
  176. mpr_static(sued_ellipse, 16, 16, 1, ellipse_dat);
  177.  
  178. static short    condi_dat[] = {
  179.     0x0000, 0x0000, 0x0180, 0x07E0, 0x0E70, 0x381C, 0x700E, 0xC003,
  180.     0x700E, 0x381C, 0x0E70, 0x07E0, 0x0180, 0x0000, 0x0000, 0x0000
  181. };
  182. mpr_static(sued_condi, 16, 16, 1, condi_dat);
  183.  
  184. static short    io_dat[] = {
  185.     0x0000, 0x0000, 0x0000, 0x7FFE, 0x7FFE, 0x6006, 0x6006, 0x7E06,
  186.     0x7F86, 0x01E6, 0x0066, 0x0066, 0x007E, 0x007E, 0x0000, 0x0000
  187. };
  188. mpr_static(sued_io, 16, 16, 1, io_dat);
  189.  
  190. static short    eraser_dat[] = {
  191.     0x0000, 0x0000, 0x0000, 0x0000, 0x0FFC, 0x100C, 0x2014, 0x2014,
  192.     0x7FE4, 0x4028, 0x4028, 0x4030, 0x7FE0, 0x0000, 0x0000, 0x0000
  193. };
  194. mpr_static(sued_eraser, 16, 16, 1, eraser_dat);
  195.  
  196. static short    cut_dat[] = {
  197.     0x7E41, 0x8041, 0x8041, 0x8041, 0x8041, 0x8041, 0x7E3E, 0x0000,
  198.     0x0FF8, 0x0080, 0x0080, 0x0080, 0x0080, 0x0080, 0x0080, 0x0000
  199. };
  200. mpr_static(sued_cut, 16, 16, 1, cut_dat);
  201.  
  202. static short    copy_dat[] = {
  203.     0x7C78, 0x8084, 0x8084, 0x8084, 0x8084, 0x8084, 0x7C78, 0x0000,
  204.     0xF882, 0x8444, 0x8428, 0xF810, 0x8010, 0x8010, 0x8010, 0x8010
  205. };
  206. mpr_static(sued_copy, 16, 16, 1, copy_dat);
  207.  
  208. static short    paste_dat[] = {
  209.     0xF25F, 0x8A44, 0x8A44, 0x8A44, 0xF244, 0x8244, 0x8244, 0x8244,
  210.     0x8244, 0x8244, 0x83C4, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
  211. };
  212. mpr_static(sued_paste, 16, 16, 1, paste_dat);
  213.  
  214. static short    invert_dat[] = {
  215.     0x0000, 0x7F80, 0x7F80, 0x7F80, 0x7FB8, 0x7F88, 0x7F9C, 0x0008,
  216.     0x0000, 0x03FC, 0x0204, 0x0204, 0x0204, 0x0204, 0x03FC, 0x0000
  217. };
  218. mpr_static(sued_invert, 16, 16, 1, invert_dat);
  219.  
  220. static short    fliph_dat[] = {
  221.     0x0000, 0x4002, 0x781E, 0x0810, 0x0810, 0x0810, 0x0890, 0x0BD0,
  222.     0x0890, 0x0810, 0x0810, 0x0810, 0x781E, 0x4002, 0x0000, 0x0000
  223. };
  224. mpr_static(sued_fliph, 16, 16, 1, fliph_dat);
  225.  
  226. static short    flipv_dat[] = {
  227.     0x0000, 0x300C, 0x1008, 0x1008, 0x1FF8, 0x0000, 0x0100, 0x0100,
  228.     0x0380, 0x0100, 0x0000, 0x1FF8, 0x1008, 0x1008, 0x300C, 0x0000
  229. };
  230. mpr_static(sued_flipv, 16, 16, 1, flipv_dat);
  231.  
  232. static short    enlarge_dat[] = {
  233.     0x0000, 0x7E10, 0x4220, 0x4278, 0x4224, 0x4214, 0x7E04, 0x0004,
  234.     0x0018, 0x0020, 0x0E40, 0x0A00, 0x0E00, 0x0000, 0x0000, 0x0000
  235. };
  236. mpr_static(sued_enlarge, 16, 16, 1, enlarge_dat);
  237.  
  238. static short    reduce_dat[] = {
  239.     0x0000, 0x7E00, 0x4200, 0x4260, 0x4210, 0x4210, 0x7E08, 0x0008,
  240.     0x0050, 0x0060, 0x0E70, 0x0A00, 0x0E00, 0x0000, 0x0000, 0x0000
  241. };
  242. mpr_static(sued_reduce, 16, 16, 1, reduce_dat);
  243.  
  244. DEFINE_ICON_FROM_IMAGE(hello_icon, icon_image);
  245.  
  246. int             pattern1[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  247.                 pattern2[16] = {0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0},
  248.                 pattern3[16] = {1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0},
  249.                 pattern4[16] = {1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1};
  250.  
  251. Pixwin         *pw, *pw2;
  252. Ccgiwin         vpw, vpw2;
  253. Ccoor           bottom, first, second, line[8];
  254. Ccoorlist       lines;
  255. int             x1, ya, x2, y2, x3, y3, x4, y4, i, newwid, newhei, arrow, ClipWidth, ClipHeight, grid, name, name2, temp1, temp2, tool, size, savetype, loadtype, printtype, scriptype, pastetype, patterntype, linewid, linetype;
  256. Panel_item      fname_item, tname_item;
  257. Window          frame, panel, canvas, frame2, canvas2, frame3;
  258. Textsw          textsw;
  259. char            intext[25], pathname[99], scriptext[80];
  260.  
  261. struct pixrect *pr1, *pr, *pr6, *pr3, *pr4;
  262.  
  263. void
  264. push()
  265. {
  266.     pw_batch_on(pw);
  267.     pw_read(pr1, 0, 0, SWIDTH, SHEIGHT, PIX_SRC, pw, 0, 0);
  268.     pw_batch_off(pw);
  269. }
  270.  
  271. int
  272. checkraster(testfile)
  273.     char            testfile[80];
  274. {
  275.     int             socket[2];
  276.     char            label[80], label2[20];
  277.     FILE           *fp;
  278.     pipe(socket);
  279.     if (!fork()) {
  280.         close(socket[0]);
  281.         close(1);
  282.         dup(socket[1]);
  283.         close(socket[1]);
  284.         execlp("file", "file", testfile, 0);
  285.         exit(1);
  286.     }
  287.     fp = fdopen(socket[0], "r");
  288.     fscanf(fp, "%s %s", label, label2);
  289.     fclose(fp);
  290.     if (strcmp(label2, "rasterfile,") == 0)
  291.         return (0);
  292.     else
  293.         return (1);
  294. }
  295.  
  296. int
  297. checkascii(testfile)
  298.     char            testfile[80];
  299. {
  300.     int             socket[2];
  301.     char            label[80], label2[20];
  302.     FILE           *fp;
  303.     pipe(socket);
  304.     if (!fork()) {
  305.         close(socket[0]);
  306.         close(1);
  307.         dup(socket[1]);
  308.         close(socket[1]);
  309.         execlp("file", "file", testfile, 0);
  310.         exit(1);
  311.     }
  312.     fp = fdopen(socket[0], "r");
  313.     fscanf(fp, "%s %s", label, label2);
  314.     fclose(fp);
  315.     if (strcmp(label2, "ascii") == 0)
  316.         return (0);
  317.     else
  318.         return (1);
  319. }
  320.  
  321. void
  322. pop()
  323. {
  324.     pw_batch_on(pw);
  325.     pw_read(pr, 0, 0, SWIDTH, SHEIGHT, PIX_SRC, pw, 0, 0);
  326.     pw_batch_off(pw);
  327. }
  328.  
  329. void
  330. refr(canvas, width, height)
  331.     Canvas          canvas;
  332.     int             width, height;
  333. {
  334.     pw_batch_on(pw);
  335.     pw_write(pw, 0, 0, width, height, PIX_SRC, pr, 0, 0);
  336.     pw_batch_off(pw);
  337. }
  338.  
  339. void
  340. test(window, event)
  341.     Window          window;
  342.     Event          *event;
  343. {
  344.     int             temp, radi;
  345.     switch (tool) {
  346.     case 0:        /* line */
  347.         switch (event_id(event)) {
  348.         case MS_LEFT:
  349.             {
  350.                 if (event_is_down(event)) {
  351.                     push();
  352.                     temp = 1;
  353.                     x1 = event_x(event);
  354.                     ya = event_y(event);
  355.                     x1 = x1 - x1 % grid;
  356.                     ya = ya - ya % grid;
  357.                     x2 = x1;
  358.                     y2 = ya;
  359.                 }
  360.                 if (event_is_up(event)) {
  361.                     pw_vector(pw, x1, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  362.                     line[0].x = x1;
  363.                     line[0].y = ya;
  364.                     line[1].x = x2;
  365.                     line[1].y = y2;
  366.                     lines.n = 2;
  367.                     lines.ptlist = line;
  368.                     cgipw_polyline(&vpw, &lines);
  369.                     if (scriptype == 1) {
  370.                         sprintf(scriptext, "l %d,%d,%d,%d\n", x1, ya, x2, y2);
  371.                         textsw_insert(textsw, scriptext, strlen(scriptext));
  372.                     }
  373.                     if ((arrow == 1) || (arrow == 3)) {
  374.                         bottom.x = x1;
  375.                         bottom.y = ya;
  376.                         radi = 2;
  377.                         cgipw_circle(&vpw, &bottom, radi);
  378.                     }
  379.                     if ((arrow == 2) || (arrow == 3)) {
  380.                         bottom.x = x2;
  381.                         bottom.y = y2;
  382.                         radi = 2;
  383.                         cgipw_circle(&vpw, &bottom, radi);
  384.                     }
  385.                     pop();
  386.                 }
  387.             }
  388.             break;
  389.         case LOC_DRAG:
  390.             {
  391.                 if (temp != 1)
  392.                     pw_vector(pw, x1, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  393.                 temp = 0;
  394.                 x2 = event_x(event);
  395.                 y2 = event_y(event);
  396.                 x2 = x2 - x2 % grid;
  397.                 y2 = y2 - y2 % grid;
  398.                 pw_vector(pw, x1, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  399.             }
  400.         }
  401.         break;
  402.     case 1:{        /* point */
  403.             switch (event_id(event)) {
  404.             case MS_LEFT:
  405.                 {
  406.                     if (event_is_down(event))
  407.                         push();
  408.                     x3 = event_x(event);
  409.                     y3 = event_y(event);
  410.                     x4 = x3;
  411.                     y4 = y3;
  412.                     line[0].x = x3 - x3 % grid;
  413.                     line[0].y = y3 - y3 % grid;
  414.                     line[1].x = x4 - x4 % grid;
  415.                     line[1].y = y4 - y4 % grid;
  416.                     lines.n = 2;
  417.                     lines.ptlist = line;
  418.                     cgipw_polyline(&vpw, &lines);
  419.                     if (scriptype == 1) {
  420.                         sprintf(scriptext, "p %d,%d\n", x3, y3);
  421.                         textsw_insert(textsw, scriptext, strlen(scriptext));
  422.                     }
  423.                     pop();
  424.                 }
  425.                 break;
  426.             case LOC_DRAG:
  427.                 {
  428.                     x3 = x4;
  429.                     y3 = y4;
  430.                     x4 = event_x(event);
  431.                     y4 = event_y(event);
  432.                     line[0].x = x3 - x3 % grid;
  433.                     line[0].y = y3 - y3 % grid;
  434.                     line[1].x = x4 - x4 % grid;
  435.                     line[1].y = y4 - y4 % grid;
  436.                     lines.n = 2;
  437.                     lines.ptlist = line;
  438.                     cgipw_polyline(&vpw, &lines);
  439.                     if (scriptype == 1) {
  440.                         sprintf(scriptext, "p %d,%d\n", x3, y3);
  441.                         textsw_insert(textsw, scriptext, strlen(scriptext));
  442.                     }
  443.                 }
  444.             }
  445.         }
  446.         break;
  447.     case 2:        /* rectangle */
  448.         switch (event_id(event)) {
  449.         case MS_LEFT:
  450.             {
  451.                 if (event_is_down(event)) {
  452.                     push();
  453.                     temp = 1;
  454.                     x1 = event_x(event);
  455.                     ya = event_y(event);
  456.                     x1 = x1 - x1 % grid;
  457.                     ya = ya - ya % grid;
  458.                     x2 = x1;
  459.                     y2 = ya;
  460.                 }
  461.                 if (event_is_up(event)) {
  462.                     x2 = event_x(event);
  463.                     y2 = event_y(event);
  464.                     x2 = x2 - x2 % grid;
  465.                     y2 = y2 - y2 % grid;
  466.                     pw_vector(pw, x1, ya, x2, ya, PIX_SRC ^ PIX_DST, 1);
  467.                     pw_vector(pw, x2, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  468.                     pw_vector(pw, x2, y2, x1, y2, PIX_SRC ^ PIX_DST, 1);
  469.                     pw_vector(pw, x1, y2, x1, ya, PIX_SRC ^ PIX_DST, 1);
  470.                     first.x = x1;
  471.                     first.y = ya;
  472.                     second.x = x2;
  473.                     second.y = y2;
  474.                     cgipw_rectangle(&vpw, &first, &second);
  475.                     if (scriptype == 1) {
  476.                         sprintf(scriptext, "r %d,%d,%d,%d\n", x1, ya, x2, y2);
  477.                         textsw_insert(textsw, scriptext, strlen(scriptext));
  478.                     }
  479.                     pop();
  480.                 }
  481.             }
  482.             break;
  483.         case LOC_DRAG:
  484.             {
  485.                 if (temp != 1) {
  486.                     pw_vector(pw, x1, ya, x2, ya, PIX_SRC ^ PIX_DST, 1);
  487.                     pw_vector(pw, x2, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  488.                     pw_vector(pw, x2, y2, x1, y2, PIX_SRC ^ PIX_DST, 1);
  489.                     pw_vector(pw, x1, y2, x1, ya, PIX_SRC ^ PIX_DST, 1);
  490.                 }
  491.                 temp = 0;
  492.                 x2 = event_x(event);
  493.                 y2 = event_y(event);
  494.                 x2 = x2 - x2 % grid;
  495.                 y2 = y2 - y2 % grid;
  496.                 pw_vector(pw, x1, ya, x2, ya, PIX_SRC ^ PIX_DST, 1);
  497.                 pw_vector(pw, x2, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  498.                 pw_vector(pw, x2, y2, x1, y2, PIX_SRC ^ PIX_DST, 1);
  499.                 pw_vector(pw, x1, y2, x1, ya, PIX_SRC ^ PIX_DST, 1);
  500.             }
  501.         }
  502.         break;
  503.     case 3:        /* circle */
  504.         switch (event_id(event)) {
  505.         case MS_LEFT:
  506.             {
  507.                 if (event_is_down(event)) {
  508.                     push();
  509.                     temp = 1;
  510.                     x1 = event_x(event);
  511.                     ya = event_y(event);
  512.                     x1 = x1 - x1 % grid;
  513.                     ya = ya - ya % grid;
  514.                     x2 = x1;
  515.                     y2 = ya;
  516.                 }
  517.                 if (event_is_up(event)) {
  518.                     pw_vector(pw, x1, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  519.                     pw_vector(pw, x1, ya, x1, ya, PIX_SRC ^ PIX_DST, 1);
  520.                     radi = (int) sqrt((double) ((x2 - x1) * (x2 - x1) + (y2 - ya) * (y2 - ya)));
  521.                     bottom.x = x1;
  522.                     bottom.y = ya;
  523.                     cgipw_circle(&vpw, &bottom, radi);
  524.                     if (scriptype == 1) {
  525.                         sprintf(scriptext, "c %d,%d,%d\n", x1, ya, radi);
  526.                         textsw_insert(textsw, scriptext, strlen(scriptext));
  527.                     }
  528.                     pop();
  529.                 }
  530.             }
  531.             break;
  532.         case LOC_DRAG:
  533.             {
  534.                 if (temp != 1)
  535.                     pw_vector(pw, x1, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  536.                 temp = 0;
  537.                 x2 = event_x(event);
  538.                 y2 = event_y(event);
  539.                 x2 = x2 - x2 % grid;
  540.                 y2 = y2 - y2 % grid;
  541.                 pw_vector(pw, x1, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  542.             }
  543.         }
  544.         break;
  545.     case 4:{        /* text tool */
  546.             if (event_id(event) == MS_LEFT) {
  547.                 if (event_is_up(event)) {
  548.                     pw_text(pw, x3, y3, PIX_SRC | PIX_DST, NULL, intext);
  549.                     if (scriptype == 1) {
  550.                         sprintf(scriptext, "T %d,%d %s\n", x3, y3, intext);
  551.                         textsw_insert(textsw, scriptext, strlen(scriptext));
  552.                     }
  553.                     pop();
  554.                 }
  555.                 if (event_is_down(event)) {
  556.                     push();
  557.                     x3 = event_x(event);
  558.                     y3 = event_y(event);
  559.                     x3 = x3 - x3 % grid;
  560.                     y3 = y3 - y3 % grid;
  561.                     strcpy(intext, panel_get_value(tname_item));
  562.                     pw_text(pw, x3, y3, PIX_SRC ^ PIX_DST, NULL, intext);
  563.                 }
  564.             }
  565.             if (event_id(event) == LOC_DRAG) {
  566.                 pw_text(pw, x3, y3, PIX_SRC ^ PIX_DST, NULL, intext);
  567.                 x3 = event_x(event);
  568.                 y3 = event_y(event);
  569.                 x3 = x3 - x3 % grid;
  570.                 y3 = y3 - y3 % grid;
  571.                 pw_text(pw, x3, y3, PIX_SRC ^ PIX_DST, NULL, intext);
  572.             }
  573.         }
  574.         break;
  575.     case 5:{        /* eraser */
  576.             i = (int) size / 2;
  577.             switch (event_id(event)) {
  578.             case MS_LEFT:
  579.                 {
  580.                     if (event_is_down(event)) {
  581.                         push();
  582.                         x4 = event_x(event) - i;
  583.                         y4 = event_y(event) - i;
  584.                         pw_writebackground(pw, x4, y4, size, size, PIX_SRC);
  585.                         pw_vector(pw, x4, y4, x4 + size, y4, PIX_SRC ^ PIX_DST, 1);
  586.                         pw_vector(pw, x4 + size, y4, x4 + size, y4 + size, PIX_SRC ^ PIX_DST, 1);
  587.                         pw_vector(pw, x4 + size, y4 + size, x4, y4 + size, PIX_SRC ^ PIX_DST, 1);
  588.                         pw_vector(pw, x4, y4 + size, x4, y4, PIX_SRC ^ PIX_DST, 1);
  589.                         if (scriptype == 1) {
  590.                             sprintf(scriptext, "E %d,%d\n", x4, y4);
  591.                             textsw_insert(textsw, scriptext, strlen(scriptext));
  592.                         }
  593.                     }
  594.                     if (event_is_up(event)) {
  595.                         pw_writebackground(pw, x4, y4, size, size, PIX_SRC);
  596.                         pw_vector(pw, x4, y4, x4 + size, y4, PIX_NOT(PIX_SRC) & PIX_DST, 1);
  597.                         pw_vector(pw, x4 + size, y4, x4 + size, y4 + size, PIX_NOT(PIX_SRC) & PIX_DST, 1);
  598.                         pw_vector(pw, x4 + size, y4 + size, x4, y4 + size, PIX_NOT(PIX_SRC) & PIX_DST, 1);
  599.                         pw_vector(pw, x4, y4 + size, x4, y4, PIX_NOT(PIX_SRC) & PIX_DST, 1);
  600.                         if (scriptype == 1) {
  601.                             sprintf(scriptext, "E %d,%d\n", x4, y4);
  602.                             textsw_insert(textsw, scriptext, strlen(scriptext));
  603.                         }
  604.                         pop();
  605.                     }
  606.                 }
  607.                 break;
  608.             case MS_RIGHT:
  609.                 push();
  610.                 pw_writebackground(pw, x4, y4, size, size, PIX_SRC);
  611.                 break;
  612.             case MS_MIDDLE:
  613.                 push();
  614.                 pw_writebackground(pw, x4, y4, size, size, PIX_SRC);
  615.                 break;
  616.             case LOC_DRAG:
  617.                 {
  618.                     pw_writebackground(pw, x4, y4, size, size, PIX_SRC);
  619.                     pw_vector(pw, x4, y4, x4 + size, y4, PIX_NOT(PIX_SRC) & PIX_DST, 1);
  620.                     pw_vector(pw, x4 + size, y4, x4 + size, y4 + size, PIX_NOT(PIX_SRC) & PIX_DST, 1);
  621.                     pw_vector(pw, x4 + size, y4 + size, x4, y4 + size, PIX_NOT(PIX_SRC) & PIX_DST, 1);
  622.                     pw_vector(pw, x4, y4 + size, x4, y4, PIX_NOT(PIX_SRC) & PIX_DST, 1);
  623.                     x4 = event_x(event) - i;
  624.                     y4 = event_y(event) - i;
  625.                     if (scriptype == 1) {
  626.                         sprintf(scriptext, "E %d,%d\n", x4, y4);
  627.                         textsw_insert(textsw, scriptext, strlen(scriptext));
  628.                     }
  629.                     pw_writebackground(pw, x4, y4, size, size, PIX_SRC);
  630.                     pw_vector(pw, x4, y4, x4 + size, y4, PIX_SRC ^ PIX_DST, 1);
  631.                     pw_vector(pw, x4 + size, y4, x4 + size, y4 + size, PIX_SRC ^ PIX_DST, 1);
  632.                     pw_vector(pw, x4 + size, y4 + size, x4, y4 + size, PIX_SRC ^ PIX_DST, 1);
  633.                     pw_vector(pw, x4, y4 + size, x4, y4, PIX_SRC ^ PIX_DST, 1);
  634.                 }
  635.             }
  636.         }
  637.         break;
  638.     case 6:        /* ellipse */
  639.         switch (event_id(event)) {
  640.         case MS_LEFT:
  641.             {
  642.                 if (event_is_down(event)) {
  643.                     push();
  644.                     temp = 1;
  645.                     x1 = event_x(event);
  646.                     ya = event_y(event);
  647.                     x1 = x1 - x1 % grid;
  648.                     ya = ya - ya % grid;
  649.                     x2 = x1;
  650.                     y2 = ya;
  651.                 }
  652.                 if (event_is_up(event)) {
  653.                     pw_vector(pw, x1, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  654.                     pw_vector(pw, x1, ya, x1, ya, PIX_SRC ^ PIX_DST, 1);
  655.                     bottom.x = x1;
  656.                     bottom.y = ya;
  657.                     cgipw_ellipse(&vpw, &bottom, (x2 - x1), (y2 - ya));
  658.                     if (scriptype == 1) {
  659.                         sprintf(scriptext, "e %d,%d,%d,%d\n", x1, ya, x2 - x1, y2 - ya);
  660.                         textsw_insert(textsw, scriptext, strlen(scriptext));
  661.                     }
  662.                     pop();
  663.                 }
  664.             }
  665.             break;
  666.         case LOC_DRAG:
  667.             {
  668.                 if (temp != 1)
  669.                     pw_vector(pw, x1, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  670.                 temp = 0;
  671.                 x2 = event_x(event);
  672.                 y2 = event_y(event);
  673.                 x2 = x2 - x2 % grid;
  674.                 y2 = y2 - y2 % grid;
  675.                 pw_vector(pw, x1, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  676.             }
  677.         }
  678.         break;
  679.     case 7:{        /* dataflow tool */
  680.             switch (event_id(event)) {
  681.             case MS_LEFT:
  682.                 {
  683.                     if (event_is_down(event)) {
  684.                         push();
  685.                         temp = 1;
  686.                         x1 = event_x(event);
  687.                         ya = event_y(event);
  688.                         x1 = x1 - x1 % grid;
  689.                         ya = ya - ya % grid;
  690.                         x2 = x1;
  691.                         y2 = ya;
  692.                     }
  693.                     if (event_is_up(event)) {
  694.                         pw_vector(pw, x1, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  695.                         pw_vector(pw, x1, ya, x1, ya, PIX_SRC ^ PIX_DST, 1);
  696.                         line[0].x = x2;
  697.                         line[0].y = ya;
  698.                         line[1].x = x1;
  699.                         line[1].y = ya;
  700.                         line[2].x = x1;
  701.                         line[2].y = y2;
  702.                         line[3].x = x2;
  703.                         line[3].y = y2;
  704.                         lines.n = 4;
  705.                         lines.ptlist = line;
  706.                         cgipw_polyline(&vpw, &lines);
  707.                         if (scriptype == 1) {
  708.                             sprintf(scriptext, "d %d,%d,%d,%d\n", x1, ya, x2, y2);
  709.                             textsw_insert(textsw, scriptext, strlen(scriptext));
  710.                         }
  711.                         pop();
  712.                     }
  713.                 }
  714.                 break;
  715.             case LOC_DRAG:
  716.                 {
  717.                     if (temp != 1)
  718.                         pw_vector(pw, x1, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  719.                     temp = 0;
  720.                     x2 = event_x(event);
  721.                     y2 = event_y(event);
  722.                     x2 = x2 - x2 % grid;
  723.                     y2 = y2 - y2 % grid;
  724.                     pw_vector(pw, x1, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  725.                 }
  726.             }
  727.         } break;
  728.     case 8:{        /* conditional tool */
  729.             switch (event_id(event)) {
  730.             case MS_LEFT:
  731.                 {
  732.                     if (event_is_down(event)) {
  733.                         push();
  734.                         temp = 1;
  735.                         x1 = event_x(event);
  736.                         ya = event_y(event);
  737.                         x1 = x1 - x1 % grid;
  738.                         ya = ya - ya % grid;
  739.                         x2 = x1;
  740.                         y2 = ya;
  741.                     }
  742.                     if (event_is_up(event)) {
  743.                         pw_vector(pw, x1, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  744.                         pw_vector(pw, x1, ya, x1, ya, PIX_SRC ^ PIX_DST, 1);
  745.                         temp1 = (int) ((x2 - x1) / 2);
  746.                         temp2 = (int) ((y2 - ya) / 2);
  747.                         line[0].x = x1 + temp1;
  748.                         line[0].y = ya;
  749.                         line[1].x = x1;
  750.                         line[1].y = ya + temp2;
  751.                         line[2].x = x1 + temp1;
  752.                         line[2].y = y2;
  753.                         line[3].x = x2;
  754.                         line[3].y = ya + temp2;
  755.                         line[4].x = x1 + temp1;
  756.                         line[4].y = ya;
  757.                         lines.n = 5;
  758.                         lines.ptlist = line;
  759.                         cgipw_polyline(&vpw, &lines);
  760.                         if (scriptype == 1) {
  761.                             sprintf(scriptext, "C %d,%d,%d,%d\n", x1, ya, x2, y2);
  762.                             textsw_insert(textsw, scriptext, strlen(scriptext));
  763.                         }
  764.                         pop();
  765.                     }
  766.                 }
  767.                 break;
  768.             case LOC_DRAG:
  769.                 {
  770.                     if (temp != 1)
  771.                         pw_vector(pw, x1, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  772.                     temp = 0;
  773.                     x2 = event_x(event);
  774.                     y2 = event_y(event);
  775.                     x2 = x2 - x2 % grid;
  776.                     y2 = y2 - y2 % grid;
  777.                     pw_vector(pw, x1, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  778.                 }
  779.             }
  780.         }
  781.         break;
  782.     case 9:{        /* Printout tool */
  783.             switch (event_id(event)) {
  784.             case MS_LEFT:
  785.                 {
  786.                     if (event_is_down(event)) {
  787.                         push();
  788.                         temp = 1;
  789.                         x1 = event_x(event);
  790.                         ya = event_y(event);
  791.                         x1 = x1 - x1 % grid;
  792.                         ya = ya - ya % grid;
  793.                         x2 = x1;
  794.                         y2 = ya;
  795.                     }
  796.                     if (event_is_up(event)) {
  797.                         pw_vector(pw, x1, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  798.                         pw_vector(pw, x1, ya, x1, ya, PIX_SRC ^ PIX_DST, 1);
  799.                         temp1 = (int) ((x2 - x1) / 3);
  800.                         temp2 = (int) ((y2 - ya) / 3);
  801.                         line[0].x = x1;
  802.                         line[0].y = ya;
  803.                         line[1].x = x2;
  804.                         line[1].y = ya;
  805.                         line[2].x = x2;
  806.                         line[2].y = y2;
  807.                         line[3].x = x2 - temp1;
  808.                         line[3].y = y2;
  809.                         line[4].x = x1 + temp1;
  810.                         line[4].y = ya + temp2;
  811.                         line[5].x = x1;
  812.                         line[5].y = ya + temp2;
  813.                         line[6].x = x1;
  814.                         line[6].y = ya;
  815.                         lines.n = 7;
  816.                         lines.ptlist = line;
  817.                         cgipw_polyline(&vpw, &lines);
  818.                         if (scriptype == 1) {
  819.                             sprintf(scriptext, "P %d,%d,%d,%d\n", x1, ya, x2, y2);
  820.                             textsw_insert(textsw, scriptext, strlen(scriptext));
  821.                         }
  822.                         pop();
  823.                     }
  824.                 }
  825.                 break;
  826.             case LOC_DRAG:
  827.                 {
  828.                     if (temp != 1)
  829.                         pw_vector(pw, x1, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  830.                     temp = 0;
  831.                     x2 = event_x(event);
  832.                     y2 = event_y(event);
  833.                     x2 = x2 - x2 % grid;
  834.                     y2 = y2 - y2 % grid;
  835.                     pw_vector(pw, x1, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  836.                 }
  837.             }
  838.         }
  839.         break;
  840.     case 10:{        /* IO */
  841.             switch (event_id(event)) {
  842.             case MS_LEFT:
  843.                 {
  844.                     if (event_is_down(event)) {
  845.                         push();
  846.                         temp = 1;
  847.                         x1 = event_x(event);
  848.                         ya = event_y(event);
  849.                         x1 = x1 - x1 % grid;
  850.                         ya = ya - ya % grid;
  851.                         x2 = x1;
  852.                         y2 = ya;
  853.                     }
  854.                     if (event_is_up(event)) {
  855.                         pw_vector(pw, x1, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  856.                         pw_vector(pw, x1, ya, x1, ya, PIX_SRC ^ PIX_DST, 1);
  857.                         temp1 = (int) ((x2 - x1) / 3);
  858.                         line[0].x = x1;
  859.                         line[0].y = y2;
  860.                         line[1].x = x1 + temp1;
  861.                         line[1].y = ya;
  862.                         line[2].x = x2;
  863.                         line[2].y = ya;
  864.                         line[3].x = x2 - temp1;
  865.                         line[3].y = y2;
  866.                         line[4].x = x1;
  867.                         line[4].y = y2;
  868.                         lines.n = 5;
  869.                         lines.ptlist = line;
  870.                         cgipw_polyline(&vpw, &lines);
  871.                         if (scriptype == 1) {
  872.                             sprintf(scriptext, "i %d,%d,%d,%d\n", x1, ya, x2, y2);
  873.                             textsw_insert(textsw, scriptext, strlen(scriptext));
  874.                         }
  875.                         pop();
  876.                     }
  877.                 }
  878.                 break;
  879.             case LOC_DRAG:
  880.                 {
  881.                     if (temp != 1)
  882.                         pw_vector(pw, x1, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  883.                     temp = 0;
  884.                     x2 = event_x(event);
  885.                     y2 = event_y(event);
  886.                     x2 = x2 - x2 % grid;
  887.                     y2 = y2 - y2 % grid;
  888.                     pw_vector(pw, x1, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  889.                 }
  890.             }
  891.         }
  892.         break;
  893.     case 11:{
  894.             /* copy */
  895.             switch (event_id(event)) {
  896.             case MS_LEFT:
  897.                 {
  898.                     if (event_is_down(event)) {
  899.                         push();
  900.                         temp = 1;
  901.                         x1 = event_x(event);
  902.                         ya = event_y(event);
  903.                         x2 = x1;
  904.                         y2 = ya;
  905.                     }
  906.                     if (event_is_up(event)) {
  907.                         pw_vector(pw, x1, ya, x2, ya, PIX_SRC ^ PIX_DST, 1);
  908.                         pw_vector(pw, x2, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  909.                         pw_vector(pw, x2, y2, x1, y2, PIX_SRC ^ PIX_DST, 1);
  910.                         pw_vector(pw, x1, y2, x1, ya, PIX_SRC ^ PIX_DST, 1);
  911.                         pw_read(pr6, 0, 0, (x2 - x1), (y2 - ya), PIX_SRC, pw, x1, ya);
  912.                         ClipWidth = x2 - x1;
  913.                         ClipHeight = y2 - ya;
  914.                     }
  915.                 }
  916.                 break;
  917.             case LOC_DRAG:
  918.                 {
  919.                     if (temp != 1) {
  920.                         pw_vector(pw, x1, ya, x2, ya, PIX_SRC ^ PIX_DST, 1);
  921.                         pw_vector(pw, x2, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  922.                         pw_vector(pw, x2, y2, x1, y2, PIX_SRC ^ PIX_DST, 1);
  923.                         pw_vector(pw, x1, y2, x1, ya, PIX_SRC ^ PIX_DST, 1);
  924.                     }
  925.                     temp = 0;
  926.                     x2 = event_x(event);
  927.                     y2 = event_y(event);
  928.                     pw_vector(pw, x1, ya, x2, ya, PIX_SRC ^ PIX_DST, 1);
  929.                     pw_vector(pw, x2, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  930.                     pw_vector(pw, x2, y2, x1, y2, PIX_SRC ^ PIX_DST, 1);
  931.                     pw_vector(pw, x1, y2, x1, ya, PIX_SRC ^ PIX_DST, 1);
  932.                 }
  933.             }
  934.         }
  935.         break;
  936.     case 12:{
  937.             /* cut */
  938.             switch (event_id(event)) {
  939.             case MS_LEFT:
  940.                 {
  941.                     if (event_is_down(event)) {
  942.                         push();
  943.                         temp = 1;
  944.                         x1 = event_x(event);
  945.                         ya = event_y(event);
  946.                         x2 = x1;
  947.                         y2 = ya;
  948.                     }
  949.                     if (event_is_up(event)) {
  950.                         pw_vector(pw, x1, ya, x2, ya, PIX_SRC ^ PIX_DST, 1);
  951.                         pw_vector(pw, x2, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  952.                         pw_vector(pw, x2, y2, x1, y2, PIX_SRC ^ PIX_DST, 1);
  953.                         pw_vector(pw, x1, y2, x1, ya, PIX_SRC ^ PIX_DST, 1);
  954.                         pw_read(pr6, 0, 0, (x2 - x1), (y2 - ya), PIX_SRC, pw, x1, ya);
  955.                         ClipWidth = x2 - x1;
  956.                         ClipHeight = y2 - ya;
  957.                         pw_writebackground(pw, x1, ya, (x2 - x1), (y2 - ya), PIX_SRC);
  958.                         pop();
  959.                     }
  960.                 }
  961.                 break;
  962.             case LOC_DRAG:
  963.                 {
  964.                     if (temp != 1) {
  965.                         pw_vector(pw, x1, ya, x2, ya, PIX_SRC ^ PIX_DST, 1);
  966.                         pw_vector(pw, x2, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  967.                         pw_vector(pw, x2, y2, x1, y2, PIX_SRC ^ PIX_DST, 1);
  968.                         pw_vector(pw, x1, y2, x1, ya, PIX_SRC ^ PIX_DST, 1);
  969.                     }
  970.                     temp = 0;
  971.                     x2 = event_x(event);
  972.                     y2 = event_y(event);
  973.                     pw_vector(pw, x1, ya, x2, ya, PIX_SRC ^ PIX_DST, 1);
  974.                     pw_vector(pw, x2, ya, x2, y2, PIX_SRC ^ PIX_DST, 1);
  975.                     pw_vector(pw, x2, y2, x1, y2, PIX_SRC ^ PIX_DST, 1);
  976.                     pw_vector(pw, x1, y2, x1, ya, PIX_SRC ^ PIX_DST, 1);
  977.                 }
  978.             }
  979.         }
  980.         break;
  981.     case 13:{        /* paste */
  982.             if (event_id(event) == MS_LEFT) {
  983.                 if (event_is_down(event)) {
  984.                     push();
  985.                     x3 = event_x(event);
  986.                     y3 = event_y(event);
  987.                     pw_write(pw, x3 - (int) ClipWidth / 2, y3 - (int) ClipHeight / 2, ClipWidth, ClipHeight, PIX_SRC ^ PIX_DST, pr6, 0, 0);
  988.                 }
  989.                 if (event_is_up(event)) {
  990.                     if (pastetype == 0)
  991.                         pw_write(pw, x3 - (int) ClipWidth / 2, y3 - (int) ClipHeight / 2, ClipWidth, ClipHeight, PIX_SRC | PIX_DST, pr6, 0, 0);
  992.                     else
  993.                         pw_write(pw, x3 - (int) ClipWidth / 2, y3 - (int) ClipHeight / 2, ClipWidth, ClipHeight, PIX_SRC, pr6, 0, 0);
  994.                     pop();
  995.                 }
  996.             }
  997.             if (event_id(event) == LOC_DRAG) {
  998.                 pw_write(pw, x3 - (int) ClipWidth / 2, y3 - (int) ClipHeight / 2, ClipWidth, ClipHeight, PIX_SRC ^ PIX_DST, pr6, 0, 0);
  999.                 x3 = event_x(event);
  1000.                 y3 = event_y(event);
  1001.                 pw_write(pw, x3 - (int) ClipWidth / 2, y3 - (int) ClipHeight / 2, ClipWidth, ClipHeight, PIX_SRC ^ PIX_DST, pr6, 0, 0);
  1002.             }
  1003.         }
  1004.     }
  1005. }
  1006.  
  1007. void
  1008. which2(item, value, event)
  1009.     Panel_item      item;
  1010.     unsigned int    value;
  1011.     Event          *event;
  1012. {
  1013.     patterntype = value;
  1014.     if (scriptype == 1) {
  1015.         sprintf(scriptext, "F %d\n", patterntype);
  1016.         textsw_insert(textsw, scriptext, strlen(scriptext));
  1017.     }
  1018.     if (value > 1) {
  1019.         switch (value) {
  1020.         case 2:
  1021.             hatch_index(2);
  1022.             break;
  1023.         case 3:
  1024.             hatch_index(3);
  1025.             break;
  1026.         case 4:
  1027.             hatch_index(4);
  1028.             break;
  1029.         case 5:
  1030.             hatch_index(5);
  1031.             break;
  1032.         }
  1033.         cgipw_interior_style(&vpw, HATCH, ON);
  1034.     }
  1035.     if (value == 0)
  1036.         cgipw_interior_style(&vpw, HOLLOW, ON);
  1037.     if (value == 1)
  1038.         cgipw_interior_style(&vpw, SOLIDI, ON);
  1039. }
  1040.  
  1041. void
  1042. which3(item, value, event)
  1043.     Panel_item      item;
  1044.     unsigned int    value;
  1045.     Event          *event;
  1046. {
  1047.     linetype = value;
  1048.     if (scriptype == 1) {
  1049.         sprintf(scriptext, "t %d\n", linetype);
  1050.         textsw_insert(textsw, scriptext, strlen(scriptext));
  1051.     }
  1052.     switch (value) {
  1053.     case 0:{
  1054.             cgipw_line_type(&vpw, SOLID);
  1055.             cgipw_perimeter_type(&vpw, SOLID);
  1056.         } break;
  1057.     case 1:{
  1058.             cgipw_line_type(&vpw, DOTTED);
  1059.             cgipw_perimeter_type(&vpw, DOTTED);
  1060.         } break;
  1061.     case 2:{
  1062.             cgipw_line_type(&vpw, DASHED);
  1063.             cgipw_perimeter_type(&vpw, DASHED);
  1064.         } break;
  1065.     }
  1066. }
  1067.  
  1068. void
  1069. which4(item, value, event)
  1070.     Panel_item      item;
  1071.     unsigned int    value;
  1072.     Event          *event;
  1073. {
  1074.     Cfloat          some;
  1075.     linewid = value;
  1076.     if (scriptype == 1) {
  1077.         sprintf(scriptext, "w %d\n", linewid);
  1078.         textsw_insert(textsw, scriptext, strlen(scriptext));
  1079.     }
  1080.     some = (int) value / 4;
  1081.     cgipw_line_width(&vpw, some);
  1082.     cgipw_perimeter_width(&vpw, some);
  1083. }
  1084.  
  1085. void
  1086. which6(item, value, event)
  1087.     Panel_item      item;
  1088.     unsigned int    value;
  1089.     Event          *event;
  1090. {
  1091.     loadtype = value;
  1092. }
  1093.  
  1094. void
  1095. which(item, value, event)
  1096.     Panel_item      item;
  1097.     unsigned int    value;
  1098.     Event          *event;
  1099. {
  1100.     tool = value;
  1101. }
  1102.  
  1103. void
  1104. arrowtyp(item, value, event)
  1105.     Panel_item      item;
  1106.     unsigned int    value;
  1107.     Event          *event;
  1108. {
  1109.     arrow = value;
  1110.     if (scriptype == 1) {
  1111.         sprintf(scriptext, "A %d\n", arrow);
  1112.         textsw_insert(textsw, scriptext, strlen(scriptext));
  1113.     }
  1114. }
  1115.  
  1116. #ifdef PRINTRONIX
  1117.  
  1118. void
  1119. Change(item, value, event)
  1120.     Panel_item      item;
  1121.     unsigned int    value;
  1122.     Event          *event;
  1123. {
  1124.     printtype = value;
  1125. }
  1126.  
  1127. #endif
  1128.  
  1129. void
  1130. puttype(item, value, event)
  1131.     Panel_item      item;
  1132.     unsigned int    value;
  1133.     Event          *event;
  1134. {
  1135.     pastetype = value;
  1136. }
  1137.  
  1138. void
  1139. Scrip(item, value, event)
  1140.     Panel_item      item;
  1141.     unsigned int    value;
  1142.     Event          *event;
  1143. {
  1144.     scriptype = value;
  1145.     if (scriptype == 1) {
  1146.         sprintf(scriptext, "%d,%d\n", window_get(canvas, WIN_WIDTH), window_get(canvas, WIN_HEIGHT));
  1147.         textsw_insert(textsw, scriptext, strlen(scriptext));
  1148.         sprintf(scriptext, "A %d\nw %d\nt %d\ns %d\nF %d\n", arrow, linewid, linetype, size, patterntype);
  1149.         textsw_insert(textsw, scriptext, strlen(scriptext));
  1150.     }
  1151. }
  1152.  
  1153.  
  1154.  
  1155. void
  1156. eraser(item, value, event)
  1157.     Panel_item      item;
  1158.     unsigned int    value;
  1159.     Event          *event;
  1160. {
  1161.     size = value;
  1162.     if (scriptype == 1) {
  1163.         sprintf(scriptext, "s %d\n", size);
  1164.         textsw_insert(textsw, scriptext, strlen(scriptext));
  1165.     }
  1166. }
  1167.  
  1168. void
  1169. GRID(item, value, event)
  1170.     Panel_item      item;
  1171.     unsigned int    value;
  1172.     Event          *event;
  1173. {
  1174.     grid = value * 10;
  1175.     if (grid == 0)
  1176.         grid = 1;
  1177. }
  1178.  
  1179. void
  1180. undo()
  1181. {
  1182.     Textsw_index    first, last_plus_one;
  1183.     pw_batch_on(pw);
  1184.     pw_write(pw, 0, 0, SWIDTH, SHEIGHT, PIX_SRC, pr1, 0, 0);
  1185.     pop();
  1186.     pw_batch_off(pw);
  1187.     if (scriptype == 1) {
  1188.         first = (int) window_get(textsw, TEXTSW_INSERTION_POINT) - strlen(scriptext);
  1189.         last_plus_one = (int) window_get(textsw, TEXTSW_INSERTION_POINT);
  1190.         textsw_erase(textsw, first, last_plus_one);
  1191.     }
  1192. }
  1193.  
  1194. void
  1195. inve()
  1196. {
  1197.     pr_rop(pr6, 0, 0, ClipWidth, ClipHeight, PIX_NOT(PIX_DST), pr6, 0, 0);
  1198. }
  1199.  
  1200. void
  1201. fliphoriz()
  1202. {
  1203.     int             i, j, k, l, temp;
  1204.     for (i = 1; i <= ClipWidth / 2; i++) {
  1205.         for (j = 1; j <= ClipHeight; j++) {
  1206.             k = (int) pr_get(pr6, i, j);
  1207.             l = (int) pr_get(pr6, ClipWidth - i, j);
  1208.             temp = k;
  1209.             k = l;
  1210.             l = temp;
  1211.             pr_put(pr6, i, j, k);
  1212.             pr_put(pr6, ClipWidth - i, j, l);
  1213.         }
  1214.     }
  1215. }
  1216.  
  1217. void
  1218. flipvert()
  1219. {
  1220.     int             i, j, k, l, temp;
  1221.     for (i = 1; i <= ClipHeight / 2; i++) {
  1222.         for (j = 1; j <= ClipWidth; j++) {
  1223.             k = (int) pr_get(pr6, j, i);
  1224.             l = (int) pr_get(pr6, j, ClipHeight - i);
  1225.             temp = k;
  1226.             k = l;
  1227.             l = temp;
  1228.             pr_put(pr6, j, i, k);
  1229.             pr_put(pr6, j, ClipHeight - i, l);
  1230.         }
  1231.     }
  1232. }
  1233.  
  1234. void
  1235. enlarge()
  1236. {
  1237.     struct pixrect *pr7;
  1238.     int             i, j, k, l, m;
  1239.     pr7 = mem_create(ClipWidth * 2, ClipHeight * 2, 1);
  1240.     for (i = 1; i < ClipWidth; i++) {
  1241.         for (j = 1; j < ClipHeight; j++) {
  1242.             k = (int) pr_get(pr6, i, j);
  1243.             l = (i - 1) * 2 + 1;
  1244.             m = (j - 1) * 2 + 1;
  1245.             pr_put(pr7, l, m, k);
  1246.             pr_put(pr7, l + 1, m, k);
  1247.             pr_put(pr7, l + 1, m + 1, k);
  1248.             pr_put(pr7, l, m + 1, k);
  1249.         }
  1250.     }
  1251.     ClipHeight     *= 2;
  1252.     ClipWidth      *= 2;
  1253.     pr_rop(pr6, 0, 0, ClipWidth, ClipHeight, PIX_SRC, pr7, 0, 0);
  1254.     pr_destroy(pr7);
  1255. }
  1256.  
  1257. void 
  1258. reduce()
  1259. {
  1260.     struct pixrect *pr7;
  1261.     int             i, j, k, l, m;
  1262.     pr7 = mem_create(ClipWidth * 2, ClipHeight * 2, 1);
  1263.     for (i = 1; i <= ClipWidth / 2; i++) {
  1264.         for (j = 1; j <= ClipHeight / 2; j++) {
  1265.             l = (i - 1) * 2 + 1;
  1266.             m = (j - 1) * 2 + 1;
  1267.             k = (int) pr_get(pr6, l, m) + (int) pr_get(pr6, l + 1, m) + (int) pr_get(pr6, l, m + 1) + (int) pr_get(pr6, l + 1, m + 1);
  1268.             if (k > 0)
  1269.                 k = 1;
  1270.             else
  1271.                 k = 0;
  1272.             pr_put(pr7, i, j, k);
  1273.         }
  1274.     }
  1275.     ClipHeight / = 2;
  1276.     ClipWidth / = 2;
  1277.     pr_rop(pr6, 0, 0, ClipWidth, ClipHeight, PIX_SRC, pr7, 0, 0);
  1278.     pr_destroy(pr7);
  1279.  
  1280. }
  1281.  
  1282. static void
  1283. quit()
  1284. {
  1285.     textsw_reset(textsw, 0, 0);
  1286.     window_destroy(frame);
  1287.     window_destroy(frame2);
  1288.     window_destroy(frame3);
  1289.     pr_destroy(pr);
  1290.     pr_destroy(pr6);
  1291.     pr_destroy(pr1);
  1292.     pr_destroy(pr3);
  1293.     close_cgi_pw(&vpw);
  1294.     close_cgi_pw(&vpw2);
  1295.     close_pw_cgi();
  1296. }
  1297.  
  1298. unpack_bits(source, dest, len)
  1299.     char           *(*source), *(*dest);
  1300. int             len;
  1301. {
  1302.     char           *d, count, ch;
  1303.  
  1304.     for (d = (*dest); (*dest) - d < len;)
  1305.         if ((count = *(*source)++) < 0) {
  1306.             ch = *(*source)++;
  1307.             for (count = 1 - count; count > 0; count--)
  1308.                 *(*dest)++ = ch;
  1309.         } else
  1310.             for (count += 1; count > 0; count--)
  1311.                 *(*dest)++ = *(*source)++;
  1312. }
  1313.  
  1314. display_line(row, line, length, screen)
  1315.     char            line[LINE_LEN];
  1316. int             row, length;
  1317. struct pixrect *screen;
  1318. {
  1319.     int             i, j, col;
  1320.     char            ich;
  1321.     /* loop over bytes per line */
  1322.     for (col = 0, i = 0; i < length; i++) {
  1323.         ich = line[i];
  1324.         /* loop over 8 bits per byte */
  1325.         for (j = col + 7; j >= col; j--) {
  1326.             pr_put(screen, j, row, (ich & 1));
  1327.             ich = ich >> 1;
  1328.         }
  1329.         col += 8;
  1330.     }
  1331. }
  1332.  
  1333.  
  1334. static void
  1335. load()
  1336. {
  1337.     char            frame_label[80], real[80], real2[85];
  1338.     FILE           *fil9, *fil2, *fil3;
  1339.     struct pixrect *picture;
  1340.     int             row;
  1341.     char            ch, *src, *dest;
  1342.     struct pixrect *pic;
  1343.     struct rasterfile rh;
  1344.  
  1345.     sprintf(frame_label, "KironDraw : %s", panel_get_value(fname_item));
  1346.     sprintf(real, "%s", panel_get_value(fname_item));
  1347.     sprintf(real2, "%sinfo", panel_get_value(fname_item));
  1348.     window_set(frame, FRAME_LABEL, frame_label, 0);
  1349.     pw_writebackground(pw, 0, 0, SWIDTH, SHEIGHT, PIX_SRC);
  1350.     if (checkraster(real) == 0) {
  1351.         if (loadtype == 0) {
  1352.             fil9 = fopen(real, "rb");
  1353.             if (fil9 == NULL) {
  1354.                 window_set(canvas, WIN_WIDTH, NORMALW, WIN_HEIGHT, NORMALH, 0);
  1355.                 window_fit(frame);
  1356.             } else {
  1357.                 pr_load_header(fil9, &rh);
  1358.                 newwid = rh.ras_width;
  1359.                 newhei = rh.ras_height;
  1360.                 window_set(canvas, WIN_WIDTH, rh.ras_width, WIN_HEIGHT, rh.ras_height, 0);
  1361.                 window_fit(frame);
  1362.                 fclose(fil9);
  1363.             }
  1364.             fil3 = fopen(real, "rb");
  1365.             if (fil3 != NULL) {
  1366.                 pic = mem_create(window_get(canvas, WIN_WIDTH), window_get(canvas, WIN_HEIGHT), 1);
  1367.                 pic = pr_load(fil3, NULL);
  1368.                 pw_write(pw, 0, 0, newwid, newhei, PIX_SRC, pic, 0, 0);
  1369.                 pop();
  1370.                 pr_destroy(pic);
  1371.                 fclose(fil3);
  1372.             }
  1373.         } else if (loadtype == 1) {
  1374.             newhei = NROWS;
  1375.             newwid = NCOLS;
  1376.             window_set(canvas, WIN_WIDTH, newwid, WIN_HEIGHT, newhei, 0);
  1377.             window_fit(frame);
  1378.             fil2 = fopen(real, "rb");
  1379.             if (fil2 != NULL) {
  1380.                 fseek(fil2, 512L, 0);
  1381.                 fread(src_buf, SRC_SIZE, 1, fil2);
  1382.                 src = src_buf;
  1383.                 picture = mem_create(NCOLS, NROWS, 1);
  1384.                 for (row = 0; row < NROWS; row++) {
  1385.                     dest = scan_line;
  1386.                     unpack_bits(&src, &dest, LINE_LEN);
  1387.                     if (src > src_buf + SRC_SIZE - BLOCK_SIZE) {
  1388.                         memcpy(src_buf, src_buf + SRC_SIZE - BLOCK_SIZE, BLOCK_SIZE);
  1389.                         fread(src_buf + BLOCK_SIZE, SRC_SIZE - BLOCK_SIZE, 1, fil2);
  1390.                         src -= SRC_SIZE - BLOCK_SIZE;
  1391.                     }
  1392.                     display_line(row, scan_line, LINE_LEN, picture);
  1393.                 }
  1394.                 fclose(fil2);
  1395.                 pw_batch_on(pw);
  1396.                 pw_write(pw, 0, 0, NCOLS, NROWS, PIX_SRC, picture, 0, 0);
  1397.                 pw_batch_off(pw);
  1398.                 pop();
  1399.             }
  1400.         }
  1401.     }
  1402. }
  1403.  
  1404. static void
  1405. clearwin()
  1406. {
  1407.     window_set(canvas, WIN_WIDTH, NORMALW, WIN_HEIGHT, NORMALH, 0);
  1408.     window_fit(frame);
  1409.     pw_batch_on(pw);
  1410.     pw_writebackground(pw, 0, 0, SWIDTH, SHEIGHT, PIX_SRC);
  1411.     pw_read(pr, 0, 0, SWIDTH, SHEIGHT, PIX_SRC, pw, 0, 0);
  1412.     pw_batch_off(pw);
  1413.     textsw_reset(textsw, 0, 0);
  1414. }
  1415.  
  1416. static void
  1417. sasc()
  1418. {
  1419.     char            real[80], real2[80];
  1420.     FILE           *fil;
  1421.     sprintf(real, "%s.script", panel_get_value(fname_item));
  1422.     sprintf(real2, "rm %s.script", panel_get_value(fname_item));
  1423.     fil = fopen(real, "r");
  1424.     if (fil != NULL)
  1425.         system(real2);
  1426.     sprintf(scriptext, "#D\nz\n");
  1427.     textsw_insert(textsw, scriptext, strlen(scriptext));
  1428.     textsw_store_file(textsw, real, 0, 0);
  1429. }
  1430.  
  1431. static void
  1432. save()
  1433. {
  1434.     char            frame_label[80], real[80], real2[85];
  1435.     FILE           *fil;
  1436.     struct pixrect *pic;
  1437.     sprintf(frame_label, "KironDraw : %s", panel_get_value(fname_item));
  1438.     sprintf(real, "%s", panel_get_value(fname_item));
  1439.     window_set(frame, FRAME_LABEL, frame_label, 0);
  1440.     if (savetype == 0) {
  1441.         sprintf(real2, "%sinfo", panel_get_value(fname_item));
  1442.         fil = fopen(real, "wb");
  1443.         pic = mem_create(window_get(canvas, WIN_WIDTH), window_get(canvas, WIN_HEIGHT), 1);
  1444.         pw_read(pic, 0, 0, window_get(canvas, WIN_WIDTH), window_get(canvas, WIN_HEIGHT), PIX_SRC, pw, 0, 0);
  1445.         pr_dump(pic, fil, NULL, RT_STANDARD, TRUE);
  1446.         pr_destroy(pic);
  1447.         fclose(fil);
  1448.     }
  1449. }
  1450.  
  1451. #ifdef PRINTRONIX
  1452. static void
  1453. print()
  1454. {
  1455.     FILE           *fil;
  1456.     char            real2[80];
  1457.     struct pixrect *pic;
  1458.     fil = fopen("/usr/tmp/KironDrawtemp", "wb");
  1459.     pic = mem_create(window_get(canvas, WIN_WIDTH), window_get(canvas, WIN_HEIGHT), 1);
  1460.     pw_read(pic, 0, 0, window_get(canvas, WIN_WIDTH), window_get(canvas, WIN_HEIGHT), PIX_SRC, pw, 0, 0);
  1461.     pr_dump(pic, fil, NULL, RT_STANDARD, TRUE);
  1462.     pr_destroy(pic);
  1463.     fclose(fil);
  1464.     if ((int) window_get(canvas, WIN_WIDTH) > MAXPRINWID) {
  1465.         if (printtype == 0)
  1466.             system("rotate < /usr/tmp/KironDrawtemp | printronix | lpr -l");
  1467.         else {
  1468.             sprintf(real2, "rotate < /usr/tmp/KironDrawtemp  | printronix > %s", panel_get_value(fname_item));
  1469.             system(real2);
  1470.         }
  1471.     } else {
  1472.         if (printtype == 0)
  1473.             system("printronix < /usr/tmp/KironDrawtemp | lpr -l");
  1474.         else {
  1475.             sprintf(real2, "printronix < /usr/tmp/KironDrawtemp > %s", panel_get_value(fname_item));
  1476.         }
  1477.         system(real2);
  1478.     }
  1479.     system("rm /usr/tmp/KironDrawtemp");
  1480. }
  1481. #endif
  1482.  
  1483. static void
  1484. excs()
  1485. {
  1486.     char            filename[80];
  1487.     FILE           *fil;
  1488.     Cfloat          some;
  1489.     int             exar, exes;
  1490.     int             width, height, ax1, ax2, radi;
  1491.     char            type, type2;
  1492.     char            writext[80], *label2;
  1493.     sprintf(filename, "%s.script", panel_get_value(fname_item));
  1494.     if (checkascii(filename) == 0) {
  1495.         window_set(textsw, TEXTSW_FILE, filename, 0);
  1496.         window_set(textsw, TEXTSW_INSERTION_POINT, window_get(textsw, TEXTSW_LENGTH), 0);
  1497.         fil = fopen(filename, "r");
  1498.         if (fil != NULL) {
  1499.             pw_writebackground(pw2, 0, 0, SWIDTH, SHEIGHT, PIX_SRC);
  1500.             fscanf(fil, "%d,%d\n", &width, &height);
  1501.             fscanf(fil, "%c%c", &type, &type2);
  1502.             exar = 0;
  1503.             exes = 1;
  1504.             cgipw_line_type(&vpw2, SOLID);
  1505.             cgipw_perimeter_type(&vpw2, SOLID);
  1506.             cgipw_interior_style(&vpw2, HOLLOW, ON);
  1507.             cgipw_line_width(&vpw2, 1);
  1508.             cgipw_perimeter_width(&vpw2, 1);
  1509.             do {
  1510.                 switch (type) {
  1511.                 case 'l':{    /* line script     */
  1512.                         fscanf(fil, "%d,%d,%d,%d\n", &line[0].x, &line[0].y, &line[1].x, &line[1].y);
  1513.                         lines.n = 2;
  1514.                         lines.ptlist = line;
  1515.                         cgipw_polyline(&vpw2, &lines);
  1516.                         if ((exar == 1) || (exar == 3)) {
  1517.                             first.x = line[0].x;
  1518.                             first.y = line[0].y;
  1519.                             radi = 2;
  1520.                             cgipw_circle(&vpw2, &first, radi);
  1521.                         }
  1522.                         if ((exar == 2) || (exar == 3)) {
  1523.                             first.x = line[1].x;
  1524.                             first.y = line[1].y;
  1525.                             radi = 2;
  1526.                             cgipw_circle(&vpw2, &first, radi);
  1527.                         }
  1528.                         fscanf(fil, "%c%c", &type, &type2);
  1529.                     }
  1530.                     break;
  1531.                 case 'r':{    /* rectangle script     */
  1532.                         fscanf(fil, "%d,%d,%d,%d\n", &first.x, &first.y, &second.x, &second.y);
  1533.                         cgipw_rectangle(&vpw2, &first, &second);
  1534.                         fscanf(fil, "%c%c", &type, &type2);
  1535.                     }
  1536.                     break;
  1537.                 case 'c':{    /* circle script     */
  1538.                         fscanf(fil, "%d,%d,%d\n", &first.x, &first.y, &ax1);
  1539.                         cgipw_circle(&vpw2, &first, ax1);
  1540.                         fscanf(fil, "%c%c", &type, &type2);
  1541.                     }
  1542.                     break;
  1543.                 case 'e':{    /* ellipse script     */
  1544.                         fscanf(fil, "%d,%d,%d,%d\n", &first.x, &first.y, &ax1, &ax2);
  1545.                         cgipw_ellipse(&vpw2, &first, ax1, ax2);
  1546.                         fscanf(fil, "%c%c", &type, &type2);
  1547.                     }
  1548.                     break;
  1549.                 case 'd':{    /* dataflow tool script     */
  1550.                         fscanf(fil, "%d,%d,%d,%d\n", &first.x, &first.y, &second.x, &second.y);
  1551.                         line[0].x = second.x;
  1552.                         line[0].y = first.y;
  1553.                         line[1].x = first.x;
  1554.                         line[1].y = first.y;
  1555.                         line[2].x = first.x;
  1556.                         line[2].y = second.y;
  1557.                         line[3].x = second.x;
  1558.                         line[3].y = second.y;
  1559.                         lines.n = 4;
  1560.                         lines.ptlist = line;
  1561.                         cgipw_polyline(&vpw2, &lines);
  1562.                         fscanf(fil, "%c%c", &type, &type2);
  1563.                     }
  1564.                     break;
  1565.                 case 'C':{    /* conditional tool     */
  1566.                         fscanf(fil, "%d,%d,%d,%d\n", &first.x, &first.y, &second.x, &second.y);
  1567.                         temp1 = (int) ((second.x - first.x) / 2);
  1568.                         temp2 = (int) ((second.y - first.y) / 2);
  1569.                         line[0].x = first.x + temp1;
  1570.                         line[0].y = first.y;
  1571.                         line[1].x = first.x;
  1572.                         line[1].y = first.y + temp2;
  1573.                         line[2].x = first.x + temp1;
  1574.                         line[2].y = second.y;
  1575.                         line[3].x = second.x;
  1576.                         line[3].y = first.y + temp2;
  1577.                         line[4].x = first.x + temp1;
  1578.                         line[4].y = first.y;
  1579.                         lines.n = 5;
  1580.                         lines.ptlist = line;
  1581.                         cgipw_polyline(&vpw2, &lines);
  1582.                         fscanf(fil, "%c%c", &type, &type2);
  1583.                     }
  1584.                     break;
  1585.                 case 'i':{    /* IO tool         */
  1586.                         fscanf(fil, "%d,%d,%d,%d\n", &first.x, &first.y, &second.x, &second.y);
  1587.                         temp1 = (int) ((second.x - first.x) / 3);
  1588.                         line[0].x = first.x;
  1589.                         line[0].y = second.y;
  1590.                         line[1].x = first.x + temp1;
  1591.                         line[1].y = first.y;
  1592.                         line[2].x = second.x;
  1593.                         line[2].y = first.y;
  1594.                         line[3].x = second.x - temp1;
  1595.                         line[3].y = second.y;
  1596.                         line[4].x = first.x;
  1597.                         line[4].y = second.y;
  1598.                         lines.n = 5;
  1599.                         lines.ptlist = line;
  1600.                         cgipw_polyline(&vpw2, &lines);
  1601.                         fscanf(fil, "%c%c", &type, &type2);
  1602.                     }
  1603.                     break;
  1604.                 case 'p':{    /* Point tool      */
  1605.                         fscanf(fil, "%d,%d\n", &line[0].x, &line[0].y);
  1606.                         fscanf(fil, "%c ", &type);
  1607.                         while (type == 'p') {
  1608.                             fscanf(fil, "%d,%d\n", &line[1].x, &line[1].y);
  1609.                             lines.n = 2;
  1610.                             lines.ptlist = line;
  1611.                             cgipw_polyline(&vpw2, &lines);
  1612.                             line[0].x = line[1].x;
  1613.                             line[0].y = line[1].y;
  1614.                             fscanf(fil, "%c%c", &type, &type2);
  1615.                         }
  1616.                     }
  1617.                     break;
  1618.                 case 'E':{    /* Eraser tool     */
  1619.                         do {
  1620.                             fscanf(fil, "%d,%d\n", &ax1, &ax2);
  1621.                             pw_writebackground(pw2, ax1, ax2, exes, exes, PIX_SRC);
  1622.                             fscanf(fil, "%c%c", &type, &type2);
  1623.                         } while (type == 'E');
  1624.                     }
  1625.                     break;
  1626.                 case 'P':{    /* Printout tool     */
  1627.                         fscanf(fil, "%d,%d,%d,%d\n", &first.x, &first.y, &second.x, &second.y);
  1628.                         temp1 = (int) ((second.x - first.x) / 3);
  1629.                         temp2 = (int) ((second.y - first.y) / 2);
  1630.                         line[0].x = first.x;
  1631.                         line[0].y = first.y;
  1632.                         line[1].x = second.x;
  1633.                         line[1].y = first.y;
  1634.                         line[2].x = second.x;
  1635.                         line[2].y = second.y;
  1636.                         line[3].x = second.x - temp1;
  1637.                         line[3].y = second.y;
  1638.                         line[4].x = first.x + temp1;
  1639.                         line[4].y = first.y + temp2;
  1640.                         line[5].x = first.x;
  1641.                         line[5].y = first.y + temp2;
  1642.                         line[6].x = first.x;
  1643.                         line[6].y = first.y;
  1644.                         lines.n = 7;
  1645.                         lines.ptlist = line;
  1646.                         cgipw_polyline(&vpw2, &lines);
  1647.                         fscanf(fil, "%c%c", &type, &type2);
  1648.                     }
  1649.                     break;
  1650.                 case 'F':{    /* Fill Pattern     */
  1651.                         fscanf(fil, "%d\n", &ax1);
  1652.                         if (ax1 > 1) {
  1653.                             switch (ax1) {
  1654.                             case 2:
  1655.                                 hatch_index(2);
  1656.                                 break;
  1657.                             case 3:
  1658.                                 hatch_index(3);
  1659.                                 break;
  1660.                             case 4:
  1661.                                 hatch_index(4);
  1662.                                 break;
  1663.                             case 5:
  1664.                                 hatch_index(5);
  1665.                                 break;
  1666.                             }
  1667.                             cgipw_interior_style(&vpw2, HATCH, ON);
  1668.                         }
  1669.                         if (ax1 == 0)
  1670.                             cgipw_interior_style(&vpw2, HOLLOW, ON);
  1671.                         if (ax1 == 1)
  1672.                             cgipw_interior_style(&vpw2, SOLIDI, ON);
  1673.                         fscanf(fil, "%c%c", &type, &type2);
  1674.                     }
  1675.                     break;
  1676.                 case 'T':{    /* text tool     */
  1677.                         fscanf(fil, "%d,%d ", &ax1, &ax2, &type2);
  1678.                         label2 = fgets(writext, 80, fil);
  1679.                         pw_text(pw2, ax1, ax2, PIX_SRC | PIX_DST, NULL, label2);
  1680.                         fscanf(fil, "\n");
  1681.                         fscanf(fil, "%c%c", &type, &type2);
  1682.                     }
  1683.                     break;
  1684.                 case 't':{    /* line type      */
  1685.                         fscanf(fil, "%d\n", &ax1);
  1686.                         switch (ax1) {
  1687.                         case 0:{
  1688.                                 cgipw_line_type(&vpw2, SOLID);
  1689.                                 cgipw_perimeter_type(&vpw2, SOLID);
  1690.                             } break;
  1691.                         case 1:{
  1692.                                 cgipw_line_type(&vpw2, DOTTED);
  1693.                                 cgipw_perimeter_type(&vpw2, DOTTED);
  1694.                             } break;
  1695.                         case 2:{
  1696.                                 cgipw_line_type(&vpw2, DASHED);
  1697.                                 cgipw_perimeter_type(&vpw2, DASHED);
  1698.                             } break;
  1699.                         }
  1700.                         fscanf(fil, "%c%c", &type, &type2);
  1701.                     }
  1702.                     break;
  1703.                 case 'w':{    /* line width     */
  1704.                         fscanf(fil, "%d\n", &ax1);
  1705.                         some = (int) ax1 / 4;
  1706.                         cgipw_line_width(&vpw2, some);
  1707.                         cgipw_perimeter_width(&vpw2, some);
  1708.                         fscanf(fil, "%c%c", &type, &type2);
  1709.                     }
  1710.                     break;
  1711.                 case 's':{    /* eraser width     */
  1712.                         fscanf(fil, "%d\n", &ax1);
  1713.                         exes = ax1;
  1714.                         fscanf(fil, "%c%c", &type, &type2);
  1715.                     }
  1716.                     break;
  1717.                 case 'A':{    /* arrows         */
  1718.                         fscanf(fil, "%d\n", &ax1);
  1719.                         exar = ax1;
  1720.                         fscanf(fil, "%c%c", &type, &type2);
  1721.                     }
  1722.                     break;
  1723.                 case '#':{    /* command lines */
  1724.                         switch (type2) {
  1725.                         case 'N':{
  1726.                                 fscanf(fil, "\n");
  1727.                                 pw_writebackground(pw2, 0, 0, SWIDTH, SHEIGHT, PIX_SRC);
  1728.                                 fscanf(fil, "%c%c", &type, &type2);
  1729.                             }
  1730.                             break;
  1731.                         case 'D':{
  1732.                                 fscanf(fil, "\n");
  1733.                                 window_set(canvas, WIN_WIDTH, width, WIN_HEIGHT, height, 0);
  1734.                                 window_fit(frame);
  1735.                                 push();
  1736.                                 pw_batch_on(pw2);
  1737.                                 pw_read(pr4, 0, 0, SWIDTH, SHEIGHT, PIX_SRC, pw2, 0, 0);
  1738.                                 pw_write(pw, 0, 0, SWIDTH, SHEIGHT, PIX_SRC, pr4, 0, 0);
  1739.                                 pw_batch_off(pw2);
  1740.                                 pop();
  1741.                                 fscanf(fil, "%c%c", &type, &type2);
  1742.                             }
  1743.                         case 'P':{
  1744.                                 fscanf(fil, "\n");
  1745.                                 pw_batch_on(pw2);
  1746.                                 pw_read(pr6, 0, 0, width, height, PIX_SRC, pw2, 0, 0);
  1747.                                 ClipWidth = width;
  1748.                                 ClipHeight = height;
  1749.                                 pw_batch_off(pw2);
  1750.                                 fscanf(fil, "%c%c", &type, &type2);
  1751.                             }
  1752.                         }
  1753.                     }
  1754.                 }
  1755.             } while (type != 'z');
  1756.         }
  1757.         fclose(fil);
  1758.     }
  1759. }
  1760.  
  1761. main(argc, argv)
  1762.     int             argc;
  1763.     char          **argv;
  1764. {
  1765.     frame = window_create(NULL, FRAME, FRAME_NO_CONFIRM, TRUE, FRAME_ICON, &hello_icon, FRAME_LABEL, "KironDraw Version 2.4b by Kiron D. Bondale / last update 9/04/89", 0);
  1766.     frame2 = window_create(NULL, FRAME, FRAME_NO_CONFIRM, TRUE, FRAME_ICON, &hello_icon, WIN_ROWS, 15, FRAME_LABEL, "KironDraw Tools - KironDraw Version 2.4b by Kiron D. Bondale / last update 9/04/89", 0);
  1767.     frame3 = window_create(NULL, FRAME, FRAME_NO_CONFIRM, TRUE, 0);
  1768.     panel = window_create(frame2, PANEL, WIN_ROWS, 7, 0);
  1769.     textsw = window_create(frame2, TEXTSW, WIN_ROWS, 8, 0);
  1770.     fname_item = panel_create_item(panel, PANEL_TEXT, PANEL_LABEL_STRING, "Filename : ", PANEL_VALUE_DISPLAY_LENGTH, 23, PANEL_VALUE_STORED_LENGTH, 80, 0);
  1771.     tname_item = panel_create_item(panel, PANEL_TEXT, PANEL_LABEL_STRING, "Text: ", PANEL_VALUE_DISPLAY_LENGTH, 35, PANEL_VALUE_STORED_LENGTH, 35, 0);
  1772.     panel_create_item(panel, PANEL_BUTTON, PANEL_LABEL_IMAGE, panel_button_image(panel, "New", 4, 0), PANEL_NOTIFY_PROC, clearwin, 0);
  1773.     panel_create_item(panel, PANEL_BUTTON, PANEL_LABEL_IMAGE, panel_button_image(panel, "Load", 5, 0), PANEL_NOTIFY_PROC, load, 0);
  1774.     panel_create_item(panel, PANEL_BUTTON, PANEL_LABEL_IMAGE, panel_button_image(panel, "Save", 5, 0), PANEL_NOTIFY_PROC, save, 0);
  1775.     panel_create_item(panel, PANEL_BUTTON, PANEL_LABEL_IMAGE, panel_button_image(panel, "Undo", 5, 0), PANEL_NOTIFY_PROC, undo, 0);
  1776. #ifdef PRINTRONIX
  1777.     panel_create_item(panel, PANEL_BUTTON, PANEL_LABEL_IMAGE, panel_button_image(panel, "Print", 6, 0), PANEL_NOTIFY_PROC, print, 0);
  1778. #endif
  1779.     panel_create_item(panel, PANEL_BUTTON, PANEL_LABEL_IMAGE, panel_button_image(panel, "Quit", 5, 0), PANEL_NOTIFY_PROC, quit, 0);
  1780.     panel_create_item(panel, PANEL_BUTTON, PANEL_LABEL_IMAGE, panel_button_image(panel, "Execute Script", 11, 0), PANEL_NOTIFY_PROC, excs, 0);
  1781.     panel_create_item(panel, PANEL_BUTTON, PANEL_LABEL_IMAGE, panel_button_image(panel, "Save Script", 11, 0), PANEL_NOTIFY_PROC, sasc, 0);
  1782.     panel_create_item(panel, PANEL_CYCLE, PANEL_LABEL_STRING, "Load type ", PANEL_CHOICE_STRINGS, "Sun RasterFiles", "MacPaint", 0, PANEL_NOTIFY_PROC, which6, 0);
  1783.     panel_create_item(panel, PANEL_SLIDER, PANEL_LABEL_STRING, "Eraser size ", PANEL_VALUE, 1, PANEL_MIN_VALUE, 1, PANEL_MAX_VALUE, 100, PANEL_SLIDER_WIDTH, 100, PANEL_NOTIFY_PROC, eraser, 0);
  1784.     panel_create_item(panel, PANEL_CHOICE, PANEL_CHOICE_IMAGES, &sued_line, &sued_point, &sued_box, &sued_circle, &sued_text, &sued_eraser, &sued_ellipse, &sued_data, &sued_condi, &sued_io, &sued_some, &sued_copy, &sued_cut, &sued_paste, 0, PANEL_MENU_CHOICE
  1785. _STRINGS, "Line", "Point", "Rect", "Circle", "Text", "Erase", "Ellipse", "Dataflow", "Conditional", "Printout", "I/O", "Copy", "Cut", "Paste", 0, PANEL_NOTIFY_PROC, which, PANEL_FEEDBACK, PANEL_INVERTED, PANEL_NOMARK_IMAGES, 0, 0);
  1786. #ifdef PRINTRONIX
  1787.     panel_create_item(panel, PANEL_CYCLE, PANEL_LABEL_STRING, "Print type ", PANEL_CHOICE_STRINGS, "To Printer", "To File", 0, PANEL_NOTIFY_PROC, Change, 0);
  1788. #endif
  1789.     panel_create_item(panel, PANEL_CYCLE, PANEL_LABEL_STRING, "Scripting ", PANEL_CHOICE_STRINGS, "No", "Yes", 0, PANEL_NOTIFY_PROC, Scrip, 0);
  1790.     panel_create_item(panel, PANEL_CYCLE, PANEL_LABEL_STRING, "Grid size ", PANEL_CHOICE_STRINGS, "0", "1", "2", "3", "4", "5", "6", 0, PANEL_NOTIFY_PROC, GRID, 0);
  1791.     panel_create_item(panel, PANEL_CYCLE, PANEL_LABEL_STRING, "Patterns ", PANEL_CHOICE_STRINGS, "Hollow", "Solid", "White", "25% grey", "50% grey", "75% grey", 0, PANEL_NOTIFY_PROC, which2, 0);
  1792.     panel_create_item(panel, PANEL_CYCLE, PANEL_LABEL_STRING, "Line Styles ", PANEL_CHOICE_STRINGS, "Solid", "Dotted", "Dashed", 0, PANEL_NOTIFY_PROC, which3, 0);
  1793.     panel_create_item(panel, PANEL_CYCLE, PANEL_LABEL_STRING, "Arrows ", PANEL_CHOICE_STRINGS, "None", "Beginning", "End", "Both", 0, PANEL_NOTIFY_PROC, arrowtyp, 0);
  1794.     panel_create_item(panel, PANEL_SLIDER, PANEL_LABEL_STRING, "Line width ", PANEL_VALUE, 1, PANEL_MIN_VALUE, 1, PANEL_MAX_VALUE, 20, PANEL_SLIDER_WIDTH, 50, PANEL_NOTIFY_PROC, which4, 0);
  1795.     panel_create_item(panel, PANEL_CYCLE, PANEL_LABEL_STRING, "Put Type ", PANEL_CHOICE_STRINGS, "transparent", "solid", 0, PANEL_NOTIFY_PROC, puttype, 0);
  1796.     panel_create_item(panel, PANEL_MESSAGE, PANEL_LABEL_STRING, "Clipboard Operations", 0);
  1797.     panel_create_item(panel, PANEL_BUTTON, PANEL_LABEL_IMAGE, &sued_invert, PANEL_NOTIFY_PROC, inve, 0);
  1798.     panel_create_item(panel, PANEL_BUTTON, PANEL_LABEL_IMAGE, &sued_fliph, PANEL_NOTIFY_PROC, fliphoriz, 0);
  1799.     panel_create_item(panel, PANEL_BUTTON, PANEL_LABEL_IMAGE, &sued_flipv, PANEL_NOTIFY_PROC, flipvert, 0);
  1800.     panel_create_item(panel, PANEL_BUTTON, PANEL_LABEL_IMAGE, &sued_enlarge, PANEL_NOTIFY_PROC, enlarge, 0);
  1801.     panel_create_item(panel, PANEL_BUTTON, PANEL_LABEL_IMAGE, &sued_reduce, PANEL_NOTIFY_PROC, reduce, 0);
  1802.     canvas2 = window_create(frame3, CANVAS, 0);
  1803.     pw2 = canvas_pixwin(canvas2);
  1804.     canvas = window_create(frame, CANVAS, 0);
  1805.     pw = canvas_pixwin(canvas);
  1806.     open_pw_cgi();
  1807.     open_cgi_pw(pw, &vpw, &name);
  1808.     open_cgi_pw(pw2, &vpw2, &name2);
  1809.     pattern_table(2, 4, 4, pattern1);
  1810.     pattern_table(3, 4, 4, pattern2);
  1811.     pattern_table(4, 4, 4, pattern3);
  1812.     pattern_table(5, 4, 4, pattern4);
  1813.     pr1 = mem_create(SWIDTH, SHEIGHT, 1);
  1814.     pr = mem_create(SWIDTH, SHEIGHT, 1);
  1815.     pr6 = mem_create(SWIDTH, SHEIGHT, 1);
  1816.     pr3 = mem_create(SWIDTH, SHEIGHT, 1);
  1817.     pr4 = mem_create(SWIDTH, SHEIGHT, 1);
  1818.     pastetype = 0;
  1819.     linetype = 0;
  1820.     linewid = 1;
  1821.     patterntype = 0;
  1822.     size = 1;
  1823.     grid = 1;
  1824.     window_set(canvas, CANVAS_RESIZE_PROC, refr, CANVAS_FAST_MONO, TRUE, WIN_CONSUME_PICK_EVENT, LOC_DRAG, WIN_CONSUME_PICK_EVENT, LOC_TRAJECTORY, WIN_CONSUME_PICK_EVENT, WIN_IN_TRANSIT_EVENTS, WIN_EVENT_PROC, test, 0);
  1825.     getwd(pathname);
  1826.     panel_set_value(fname_item, pathname);
  1827.     window_set(frame2, WIN_SHOW, TRUE, 0);
  1828.     window_main_loop(frame);
  1829.     exit(0);
  1830. }
  1831. //E*O*F kirondraw.c//
  1832.  
  1833. echo x - kirondraw.l
  1834. cat > "kirondraw.l" << '//E*O*F kirondraw.l//'
  1835. .TH KIRONDRAW 1 "9 April 1989"
  1836. .SH NAME
  1837. KironDraw \- bitmap graphic editor for the SunView environment (Version 2.4b)
  1838. .SH SYNOPSIS
  1839. \fBKironDraw\fP
  1840. .SH DESCRIPTION
  1841. .br
  1842. .br
  1843. .SH Introduction
  1844. .br
  1845. .br
  1846. KironDraw supports the following :
  1847. .br
  1848.     Drawing Tools, Attribute modifiers, Bitmap tools, IO functions, scripting tools, and Clipboard tools.
  1849. .br
  1850. .br
  1851. .SH Human Interface
  1852. .br
  1853. .br
  1854.     When invoked with the "KironDraw" command, the following two windows will appear :  a canvas window which is used for drawing, and a tool window which is used for accessing KironDraw's functions.
  1855. .br
  1856.     All input to KironDraw is accomplished by means of the left-button on the mouse, and the keyboard.
  1857. .br
  1858. .br
  1859. .SH Drawing Tools
  1860. .br
  1861. .br
  1862.     The drawing tools may be selected from the Tool Panel by clicking one of the drawing tool pictograms.  The following tools are available : Line, Point, Rectangle, Circle, Text, Ellipse, Eraser, Data source, IO, Conditional.    
  1863. .br
  1864.     The Line tool is used to draw straight lines.  To use it, click at the starting point of the line, and drag to the end point.  Once the button is released, the line is drawn.
  1865. .br
  1866.     The Point tool is used for freehand drawing of curves or other intricate figures.  To use it, click at the starting point of the figure, and drag around the canvas.  
  1867. .br
  1868.     The Rectangle tool is used to draw rectangles.  To use it, click at the top-left-hand corner of the rectangle, and drag to the lower-right-hand corner.  Once the button is released, the rectangle is drawn.
  1869. .br
  1870.     The Circle tool is used to draw circles.  To use it, click at the center of the circle you wish drawn, and drag to a point on the outer rim of the circle.  Once the button is released, the circle is drawn.
  1871. .br
  1872.     The Text tool is used to place text on the canvas.  To use it, first type some text in the text item of the panel, click the text tool pictogram and click on the canvas.  The placed text may then be dragged around the canvas. When you are satisfied as to
  1873.  the positioning of the text, release the button.
  1874. .br
  1875.     The Ellipse tool is used in an identical fashion to the circle tool.
  1876. .br
  1877.     The Eraser tool is used to remove pixels from the canvas. Usage consists of clicking at the starting position on the canvas, and dragging the eraser around to erase objects.
  1878. .br
  1879.     The Data source, IO, and Conditional tools are used in an identical fashion to the rectangle tool.
  1880. .br
  1881. .br
  1882. .SH Attribute Modifiers
  1883. .br
  1884. .br
  1885.     Attribute modifiers may be selected from the Tool Panel by clicking one of the following items :
  1886. .br
  1887.     Grid size, Line width, Line type, Fill type, Eraser size, Paste type, and Arrows.  Modifiers are used by clicking on their selection fields to change their types.
  1888. .br
  1889.     Grid size is a modifier that is used to align shapes to an "invisible grid" on the canvas.  A grid size of zero signifies that shapes may be placed anywhere on the canvas, and may have any dimension.  A larger grid size will constrain objects to certain 
  1890. positions and sizes.  It is useful for creating congruent shapes, or lining shapes up.  All drawing tools are affected by grid size.
  1891. .br
  1892.     Line width is a modifier that changes the width of lines used by all drawing tools.  The default line width is one pixel.  Line widths may vary from one to twenty pixels.
  1893. .br
  1894.     Line type is a modifier that changes the type of lines used by all drawing tools.  The default line type is solid.  Line types can solid, dotted, or dashed.
  1895. .br
  1896.     Fill type is a modifier that changes the interior of certain drawn shapes.  The affected tools are the rectangle tool, the circle tool, and the ellipse tool.  The default fill type is hollow.  Fill types can be hollow, white, black, 25% grey, 50% grey, o
  1897. r 75% grey.
  1898. .br
  1899.     Eraser size is a modifier that affects the eraser size only.  The default eraser size is one pixel by  one pixel.  Eraser sizes can vary from one pixel squared to one hundred pixels squared.
  1900. .br
  1901.     Put type is a modifier that decides how a cut or copied bitmap will be saved.  Default is transparent.  Selecting solid will delete the rectangle below the placed bitmap, selecting transparent will show what is under the placed bitmap.
  1902. .br
  1903.     Arrows is a modifier that affects the line tool only.  The default arrow type is no arrows.  Arrow types can be no arrows, arrow at beginning, arrow at end, or arrow at beginning and end.
  1904. .br
  1905. .br
  1906. .SH Bitmap tools
  1907. .br
  1908. .br
  1909.     Bitmap tools may be selected from the Tool Panel by clicking the Cut, Copy, or Paste pictograms, or by clicking the Undo button.  Bitmap tools are tools that operate on regions of the canvas.
  1910. .br
  1911.     The Cut tool is used to remove a rectangular region of the canvas and maintain it on a "clipboard" for future use by the Paste tool.  It is used in a similar manner to the Rectangle tool.
  1912. .br
  1913.     The Copy tool is  identical to the Cut tool,  except that the original region is not removed.
  1914. .br
  1915.     The Paste tool is used to place the clipboard contents onto the canvas.  It is used by selecting the Paste tool, and clicking on the canvas.  The clipboard contents will appear on the canvas and can be dragged around the canvas.  Once the button is relea
  1916. sed, the image will be "pasted" onto the canvas.  Pasting the clipboard contents does not remove the contents from the clipboard, hence it is possible to duplicate intricate shapes many times instead of re-drawing them every time.
  1917. .br
  1918.     The Undo tool simply undoes the previous operation.  
  1919. .br
  1920. .br
  1921. .SH IO tools
  1922. .br
  1923. .br
  1924.     IO tools are used for saving, loading, and printing KironDraw files.  They are the Load, Save, New, Quit, and Print buttons.  Modifiers for these are Print type, and Load type.
  1925. .br
  1926.     The Load tool is used to load a KironDraw file.  Clicking on the Load button will cause the file specified by the Filename field and the current Load type to be loaded.  The loaded file's name will become the canvas frame's new label.
  1927. .br
  1928.     The Save tool is used to save a KironDraw file.  Clicking on the Save button will cause the file specified by the Filename field to be saved.  The saved file's name will become the canvas frame's new label.
  1929. .br
  1930.     The New tool is used to clear the canvas.  Clicking the New button will delete the contents of the canvas and blank the canvas's frame label.
  1931. .br
  1932.     The Quit tool is used to quit KironDraw.  When clicked, KironDraw will terminate.
  1933. .br
  1934.     The Print tool is used to print an image.  When clicked, the current image will be dumped to the current Print type.  Presently the Print command only works with Printronix printers...
  1935. .br
  1936.     The Print type modifier is used to change the print destination.  The default Print type is the printer.  Print types can be printer, or a file.  If the Print type is file, then the file specified by the Filename field will contain the image.  This file 
  1937. can then be integrated with other text files for eventual printing.  Presently the Print command only works with Printronix printers...
  1938. .br
  1939.     The Load type modifier is used to change the type of file that is loaded when the Load button is clicked.  The default Load type is Sun Rasterfile.  Load types can be Sun Rasterfile, or MacPaint file.  If the Load type is MacPaint file, then a previously
  1940.  saved MacPaint binary file is loaded when the Load button is clicked.
  1941. .br
  1942. .br
  1943. .SH Scripting tools
  1944. .br
  1945. .br
  1946.     "Scripting" is the act of creating a text file that contains graphic commands for creating a KironDraw document... it's usefulness is in permitting the creation or edition of images without being at a Sun station.  Presently it is only possible to load s
  1947. cripts into KironDraw : This is accomplished by creating a script file (in vi or whatever) with the name : xxxxxxx.script where xxxxxxx can be any filename, specifying this name in the filename prompt in KironDraw (without the .script extension) and then 
  1948. clicking "execute script".
  1949. .br
  1950.     Script files are composed of the following :
  1951. .br
  1952. .br
  1953.     Header
  1954. .br
  1955.     Rules
  1956. .br
  1957.     Command Lines
  1958. .br
  1959. Header : Presently, all that is in the header is width, height
  1960. .br
  1961. Rules : Any or all of the following
  1962. .br
  1963.     l x1,y1,x2,y2    -    draws a line from x1,y1 to x2,y2
  1964. .br
  1965. .br
  1966.     r x1,y1,x2,y2    -    draws a rectangle from x1,y1 (top left) to x2,y2(lower right)
  1967. .br
  1968. .br
  1969.     c x1,y1,radius  -    draws a circle with at center x1,y1
  1970. .br
  1971. .br
  1972.     e x1,y1,m1,m2    -    draws an ellipse at center x1,y1 with major axis m1, minor axis m2...(note m1 > m2)
  1973. .br
  1974. .br
  1975.     d x1,y1,x2,y2     -    draws a datasink similar to rectangle
  1976. .br
  1977. .br
  1978.     C x1,y1,x2,y2    -    draws a conditional box, similar to rectangle
  1979. .br
  1980. .br
  1981.     i x1,y1,x2,y2    -    draws an IO box, similar to rectangle
  1982. .br
  1983. .br
  1984.     p x1,y1    
  1985. .br
  1986.     p x2,y2
  1987. .br
  1988.      ...
  1989. .br
  1990.     p xn,yn        -    draws lines between p1 - pn
  1991. .br
  1992. .br
  1993.     E x1,y1
  1994. .br
  1995.     E x2,y2
  1996. .br
  1997.      ...
  1998. .br
  1999.     E xn,yn        -    erases squares with topleft corner xa,ya with sides as current eraser size.
  2000. .br
  2001. .br
  2002.     P x1,y1,x2,y2    -    draws a printout tool, similar to rectangle
  2003. .br
  2004. .br
  2005.     F x        -    defines the fill pattern for shapes, x defined as one of these :
  2006. .br
  2007.                     0    hollow
  2008.                     1    black
  2009.                     2    white
  2010.                     3    25% grey
  2011.                     4    50% grey
  2012.                     5    75% grey
  2013. .br
  2014. .br
  2015.     T x1,y1 <some string>  - draws text defined by <some string> at x1,y1
  2016. .br
  2017. .br
  2018.     t x        -    changes the line type : x defined as
  2019.                     0    solid
  2020.                     1    dotted
  2021.                     2    dashed
  2022. .br
  2023. .br
  2024.     w x        -    changes the line width
  2025. .br
  2026. .br
  2027.     s x        -    changes the eraser width
  2028. .br
  2029. .br
  2030.     A x        -    changes the arrow type : x defined as
  2031.                     0    none
  2032.                     1    beginning
  2033.                     2    end
  2034.                     3    at both ends
  2035. .br
  2036. .br
  2037. Command Lines
  2038. .br
  2039. Command lines start with a # and are immediately followed by :
  2040. .br
  2041. N    -    clear the screen
  2042. .br
  2043. D    -    dump current script image to screen
  2044. .br
  2045. P    -    dump current script image to clipboard
  2046. .br
  2047. .br
  2048.     REMEMBER THOUGH, ALL SPACES WHERE SHOWN IN THE RULES AND COMMAND LANGUAGE ARE IMPORTANT... NOT FOLLOWING THE LANGUAGE SYNTAX WILL CAUSE TROUBLE.
  2049. .br
  2050.     Luckily, scripts file need not only be made by hand... it is possible to create a script automatically by selecting the scripting choice item, and then using KironDraw as usual.  What will happen however that is different from normal use, is that script 
  2051. code will be generated for you by KironDraw.  Giving a filename in the File field and clicking the Save Script button will save the script for future use.
  2052. .br
  2053. .br
  2054. .SH Clipboard Tools
  2055. .br
  2056. .br
  2057.     The Clipboard tools modify the contents of the clipboard and are the following : Invert, Flip Horizontal, Flip Vertical, Enlarge, Reduce.
  2058. .br
  2059.     Invert will invert the contents of the clipboard (ie. black -> white, white -> black)
  2060. .br
  2061.     Flip Horizontal will flip the contents of the clipboard in the horizontal direction.
  2062. .br
  2063.     Flip Vertical will flip the contents of the clipboard in the vertical direction.
  2064. .br
  2065.     Enlarge will enlarge the contents of the clipboard by 200%.  It can be used many times to enlarge the contents 200,400,800...%.
  2066. .br
  2067.     Reduce will reduce the contents of the clipboard by 50%.  It can be used many times to reduce the contents 50,25,12.5...%.
  2068. .br
  2069. .br
  2070. .SH GLOSSARY
  2071. .br
  2072.     Clicking : The act of pressing the left mouse button.
  2073.     Dragging : The act of moving the mouse while the left mouse button is depressed.
  2074. .br
  2075. .br
  2076. .SH VARIOUS
  2077. .br
  2078.     KironDraw windows can be closed, re-sized, and moved like any other SunView program windows.
  2079. .br
  2080. .br
  2081. .SH WARNING
  2082.     Please do not print diagrams with MANY dark areas since you might find yourself buying a new printer ribbon.
  2083. .br
  2084. .br
  2085. .SH BUGS
  2086.     Screen redraws for large canvas sizes are slow, please be patient.
  2087. .br
  2088.     The program is optimized for use on Suns with Math Coprocessors,but will work on ALL machines equipped with mice.
  2089. .br
  2090. .br
  2091. .SH NOTES
  2092. .br
  2093.     Depending on drawing sizes, image files can take up from 10 to 180K on disk.  KironDraw will not warn you if your quota is exceeded,so please make sure you have enough disk space before you save a file.
  2094. .br
  2095.     KironDraw makes no file backups;  saving to a file that already exists will overwrite the previous contents of the file.
  2096. .br
  2097.     A new version of KironDraw will be posted every few days, so  if you see any modifications to the program, please read this MAN page under the section UPDATES.
  2098. .br
  2099.     For any questions concerning KironDraw usage, please contact Kiron Bondale.
  2100. .br
  2101. .br
  2102. .SH AUTHOR
  2103. Kiron D. Bondale
  2104. (kiron@sunkisd.cs.concordia.ca)
  2105. //E*O*F kirondraw.l//
  2106.  
  2107. exit 0
  2108.  
  2109.  
  2110.