home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3515 < prev    next >
Internet Message Format  |  1991-06-19  |  41KB

  1. From: gunnar@falcon.ericsson.se (Was a Sunny day)
  2. Newsgroups: alt.sources
  3. Subject: Scantool part 4(5)  (shar)
  4. Message-ID: <1991Jun18.124909.11256@ericsson.se>
  5. Date: 18 Jun 91 12:49:09 GMT
  6.  
  7. #!/bin/sh
  8. # this is scan.04 (part 4 of a multipart archive)
  9. # do not concatenate these parts, unpack them in order with /bin/sh
  10. # file scan_extern.h continued
  11. #
  12. if test ! -r _shar_seq_.tmp; then
  13.     echo 'Please unpack part 1 first!'
  14.     exit 1
  15. fi
  16. (read Scheck
  17.  if test "$Scheck" != 4; then
  18.     echo Please unpack part "$Scheck" next!
  19.     exit 1
  20.  else
  21.     exit 0
  22.  fi
  23. ) < _shar_seq_.tmp || exit 1
  24. if test ! -f _shar_wnt_.tmp; then
  25.     echo 'x - still skipping scan_extern.h'
  26. else
  27. echo 'x - continuing file scan_extern.h'
  28. sed 's/^X//' << 'SHAR_EOF' >> 'scan_extern.h' &&
  29. X */
  30. X
  31. extern char finalimage[] ; /* Name of uncompressed image file. */
  32. extern char line[] ;
  33. extern char picname[] ;    /* Name of file for raster image. */
  34. extern char progname[] ;   /* This programs name. */
  35. extern char temphead[] ;   /* Temporary filename for header file. */
  36. extern char tempimage[] ;  /* Temporary filename for saved scanned data. */
  37. X
  38. extern int finished ;      /* Indicates if we have finished uncompressing. */
  39. extern int fwidth ;        /* Final width of rasterfile. */
  40. extern int height ;        /* Height in scan lines of raster file image. */
  41. extern int rc ;            /* Current character from scanned file. */
  42. extern int rcount ;        /* Bit position count within read character. */
  43. extern int wc ;            /* Current char to write to final image file. */
  44. extern int wcount ;        /* Bit position count within write character. */
  45. extern int width ;         /* Width in pixels of rasterfile image. */
  46. X
  47. extern struct code *whites[] ;  /* White initial starting pointers. */
  48. extern struct code *blacks[] ;  /* Black initial starting pointers. */
  49. X
  50. extern FILE *rd ;          /* File descriptor for input files. */
  51. extern FILE *wd ;          /* File descriptor for final image. */
  52. SHAR_EOF
  53. echo 'File scan_extern.h is complete' &&
  54. chmod 0644 scan_extern.h ||
  55. echo 'restore of scan_extern.h failed'
  56. Wc_c="`wc -c < 'scan_extern.h'`"
  57. test 1744 -eq "$Wc_c" ||
  58.     echo 'scan_extern.h: original size 1744, current size' "$Wc_c"
  59. rm -f _shar_wnt_.tmp
  60. fi
  61. # ============= scantool.1 ==============
  62. if test -f 'scantool.1' -a X"$1" != X"-c"; then
  63.     echo 'x - skipping scantool.1 (File already exists)'
  64.     rm -f _shar_wnt_.tmp
  65. else
  66. > _shar_wnt_.tmp
  67. echo 'x - extracting scantool.1 (Text)'
  68. sed 's/^X//' << 'SHAR_EOF' > 'scantool.1' &&
  69. .\" @(#)scantool.1 1.3 90/04/04
  70. .TH SCANTOOL 1L "2 April 1990"
  71. .SH NAME
  72. scantool \- a program to scan images using a Microtek MS300A scanner.
  73. .SH SYNOPSIS
  74. .B "scantool
  75. [
  76. .B -v
  77. ]
  78. [
  79. .B \-Wi
  80. ]
  81. [
  82. .B \-Wp
  83. .I x y
  84. ]
  85. [
  86. .B \-WP
  87. .I x y
  88. ]
  89. .SH DESCRIPTION
  90. .I Scantool
  91. allows the user to scan in documents using a Microtek
  92. MS300A scanner, and turn the resulting image into a Sun rasterfile.
  93. This program uses either SunView or XView graphics. These graphics
  94. routines are fairly trivial, and have been isolated into a single
  95. file, so it would be relatively easy to write a set of graphics
  96. routines for another graphics system.
  97. .LP
  98. When you run scantool, a window is displayed. There is a black bar
  99. at the top with containing six headings. Hitting a mouse button when
  100. the cursor is above one of those six headings, will display a popup
  101. menu. These options are explained in more detail below, and also by
  102. selecting entries from the Help popup menu.
  103. .LP
  104. There are also four box toggle switches. Each toggle has two settings.
  105. There are toggles for setting the line mode,
  106. data transfer method, serial port and baud rate.
  107. .LP
  108. There are three buttons. The Scan button initiates a scan. Should you
  109. wish to cancel a scan once it has been started, then you should press 
  110. the Canel button.
  111. .LP
  112. The Show button allows you to display the scanned rasterfile images in 
  113. a separate window.
  114. .SS "Display mode."
  115. .LP
  116. The scanner can handle input from the image sensor in
  117. two modes: Line Art mode and Halftone mode. Line Art
  118. mode produces an all black-and-white image, while
  119. Halftone mode results in an image that appears to contain
  120. varying shades of gray.
  121. .LP
  122. In Line Art mode, the amount of light falling on the
  123. sensor is compared against a "threshold" determined by
  124. the Brightness and Contrast controls. Whenever it falls
  125. below the threshold, a black dot is sent to the Sun; when
  126. it exceeds the threshold a white dot is sent. This mode
  127. is normally used for material in which everything is
  128. either black or white.
  129. .LP
  130. Halftone mode is used to detect and reproduce finer
  131. differences in shading. In this mode the dots sent to
  132. the Sun are organised into squares, or "grains", of
  133. uniform size. By varying the ratio of black and white
  134. dots in the grains, different degrees of shading, or
  135. "gray levels", are achieved.
  136. .SS "Data transfer."
  137. .LP
  138. In order to reduce the amount of time needed to
  139. transmit a scanned image to the computer, the
  140. MS-300A can compress image data using a one-
  141. dimensional coding scheme based on CCITT
  142. Recommendation T.4 (modified Huffman code). By default the scanner
  143. will send compressed data to the computer.
  144. .SS " Serial connection."
  145. .LP
  146. The scanner connects to the computer using an RS232 connection.
  147. This is currently setup to allow you to select between the RS232
  148. A and B ports.  The baud rate can also be toggled between 9600
  149. and 1920 baud.
  150. .SS "Brightness."
  151. .LP
  152. There are 14 Brightness levels to choose from. The
  153. effect of this control depends on whether the image
  154. is scanned in Line Art or Halftone mode.
  155. .LP
  156. In Line Art mode, the higher the Brightness setting
  157. the darker a spot must be in order for the scanner to
  158. consider it "black". Lower settings can therefore be
  159. used to get a sharper image if the original is too
  160. light or blurry, while higher settings can be used to
  161. prevent slightly shaded areas from coming out black
  162. in the scanned image.
  163. .LP
  164. In Halftone mode, the Brightness setting affects
  165. shading in all areas of the scanned image, both dark
  166. and light. The higher the value selected, the lighter
  167. the overall image; the lower the setting, the darker image.
  168. .SS "Contrast."
  169. .LP
  170. The Contrast control also has 14 different settings.
  171. The effect of this control in Line Art mode is identical
  172. to that of the Brightness control. In Halftone mode, a
  173. higher Contrast setting causes all but the darkest areas
  174. of the original document to come out lighter in the
  175. scanned image. Too high a setting can result in "glare
  176. spots" of pure white; too low a setting can make the
  177. image almost uniformly gray.
  178. .SS "Grain."
  179. .LP
  180. All the grains in any one halftone image are the same
  181. size (see the Mode help). It is desirable, however, to
  182. use different grain sizes for different kinds of images.
  183. The Grain control makes it possible to do this. Six
  184. different grain sizes are available: 2, 3, 4, 5, 6, and
  185. 8 dots square.
  186. .LP
  187. When smaller grain sizes (i.e. higher settings) are
  188. used, fine details in the original document are captured
  189. more clearly, but the smaller number of dot positions in
  190. the grains limits the scanner's "palette" of gray levels.
  191. A Grain setting of 11, for instance produces grains that
  192. are 2 dots high by 2 dots wide. With only 4 dot positions
  193. to fill, only 5 distinct gray levels are possible, from
  194. all white to all black.
  195. .SS "Resolution."
  196. .LP
  197. The Resolution control determines the degree of
  198. reduction of the scanned image relative to the original.
  199. Since the dots that make up the scanned image cannot be
  200. reduced in size, reduction is achieved by deleting dots
  201. at selected intervals when transmitting the image to
  202. the Sun, resulting in an effective resolution of less
  203. than the scanner's maximum of 300 dots per inch.
  204. .LP
  205. There are 16 possible Resolution settings, providing
  206. scaling operations from 25% to 100%.
  207. .SS "Setting the picture name."
  208. .LP
  209. There are various options that can be set via the Set popup menu.
  210. One of these is the picture name. This is the name of the file on 
  211. the Sun that the scanned picture will be saved in. The default is 
  212. a file called "Noname.rf".
  213. .SS "Setting the scaning frame."
  214. .LP
  215. The frame is the area to be scanned. Scantool allows
  216. you to scan an area as small as 1/8" x 1/8", or as large
  217. as 8.5" x 11". Using the Set Scanning Frame function in
  218. the Set menu, you can adjust the size and location of
  219. the frame in order to scan any part of the document that
  220. you feed into the scanner.
  221. .SS "Initiating a scan."
  222. .LP
  223. When you click the Scan button, scantool checks
  224. to see if the scanner is on line, i.e. powered up,
  225. properly connected and ready to receive commands.
  226. .LP
  227. If everything checks out OK, the current settings
  228. will be transmitted to the scanner, and the rollers
  229. will begin to turn. Actual scanning will begin after
  230. a document is detected by the paper sensor, which is
  231. located in the middle of the feed slot just below
  232. the top rollers.
  233. .SH OPTIONS
  234. .TP
  235. .B \-v
  236. Print the version number of this release of the scantool program.
  237. .TP
  238. .B \-Wi
  239. Start the
  240. .B scantool
  241. program up in iconic form.
  242. .TP
  243. .BI \-Wp " x y"
  244. Start the open window position at
  245. .I x y
  246. .TP 
  247. .BI \-WP " x y"
  248. Start the icon position at
  249. .I x y
  250. .SH FILES
  251. .TP
  252. /usr/local/lib/scantool/scantool.help
  253. .SH AUTHOR
  254. Rich Burridge,        Domain: richb@Aus.Sun.COM
  255. .nf
  256. PHONE: +61 2 413 2666   Path: {uunet,mcvax,ukc}!munnari!sunaus.oz!richb
  257. .fi
  258. SHAR_EOF
  259. chmod 0644 scantool.1 ||
  260. echo 'restore of scantool.1 failed'
  261. Wc_c="`wc -c < 'scantool.1'`"
  262. test 6726 -eq "$Wc_c" ||
  263.     echo 'scantool.1: original size 6726, current size' "$Wc_c"
  264. rm -f _shar_wnt_.tmp
  265. fi
  266. # ============= scantool.c ==============
  267. if test -f 'scantool.c' -a X"$1" != X"-c"; then
  268.     echo 'x - skipping scantool.c (File already exists)'
  269.     rm -f _shar_wnt_.tmp
  270. else
  271. > _shar_wnt_.tmp
  272. echo 'x - extracting scantool.c (Text)'
  273. sed 's/^X//' << 'SHAR_EOF' > 'scantool.c' &&
  274. X
  275. /*  @(#)scantool.c 1.4 90/04/04
  276. X *
  277. X *  Main routine for scantool, which will read a scanned image
  278. X *  from a Microtek MS-300A scanner and convert it to a Sun rasterfile.
  279. X *
  280. X *  Copyright (c) Rich Burridge.
  281. X *                Sun Microsystems, Australia - All rights reserved.
  282. X *
  283. X *  Permission is given to distribute these sources, as long as the
  284. X *  copyright messages are not removed, and no monies are exchanged.
  285. X *
  286. X *  No responsibility is taken for any errors or inaccuracies inherent
  287. X *  either to the comments or the code of this program, but if
  288. X *  reported to me, then an attempt will be made to fix them.
  289. X */
  290. X
  291. #include <stdio.h>
  292. #include <strings.h>
  293. #include "scantool.h"
  294. X
  295. char *br_strs[] = {     /* Brightness menu item strings. */
  296. X       "1   -24% Darker",
  297. X       "2   -20% Darker",
  298. X       "3   -16% Darker",
  299. X       "4   -12% Darker",
  300. X       "5   -8%  Darker",
  301. X       "6   -4%  Darker",
  302. X       "7   No adjustment",
  303. X       "8   +4%  Lighter",
  304. X       "9   +8%  Lighter",
  305. X       "10  +12% Lighter",
  306. X       "11  +16% Lighter",
  307. X       "12  +20% Lighter",
  308. X       "13  +24% Lighter",
  309. X       "14  +28% Lighter",
  310. X       NULL
  311. } ;
  312. X
  313. char *con_strs[] = {    /* Contrast menu item strings. */
  314. X       "1   -24% Lower",
  315. X       "2   -20% Lower",
  316. X       "3   -16% Lower",
  317. X       "4   -12% Lower",
  318. X       "5   -8%  Lower",
  319. X       "6   -4%  Lower",
  320. X       "7   No adjustment",
  321. X       "8   +4%  Higher",
  322. X       "9   +8%  Higher",
  323. X       "10  +12% Higher",
  324. X       "11  +16% Higher",
  325. X       "12  +20% Higher",
  326. X       "13  +24% Higher",
  327. X       "14  +28% Higher",
  328. X       NULL
  329. } ;
  330. X
  331. char *gr_strs[] = {      /* Grain menu item strings. */
  332. X       "0   Grain Size: 8x8   Gray Levels: 33",
  333. X       "1   Grain Size: 8x8   Gray Levels: 33",
  334. X       "2   Grain Size: 8x8   Gray Levels: 33",
  335. X       "3   Grain Size: 8x8   Gray Levels: 33",
  336. X       "4   Grain Size: 6x6   Gray Levels: 37",
  337. X       "5   Grain Size: 5x5   Gray Levels: 26",
  338. X       "6   Grain Size: 5x5   Gray Levels: 18",
  339. X       "7   Grain Size: 4x4   Gray Levels: 17",
  340. X       "8   Grain Size: 4x4   Gray Levels: 17",
  341. X       "9   Grain Size: 4x4   Gray Levels: 17",
  342. X       "10  Grain Size: 3x3   Gray Levels: 10",
  343. X       "11  Grain Size: 2x2   Gray Levels: 5",
  344. X       NULL
  345. } ;
  346. X
  347. char *help_strs[] = {   /* Help menu item strings. */
  348. X       "Brightness",
  349. X       "Contrast",
  350. X       "Frame",
  351. X       "Grain",
  352. X       "Mode",
  353. X       "Resolution",
  354. X       "Scan",
  355. X       "Compress",
  356. X       "Port",
  357. X       "Speed",
  358. X       "Picture",
  359. X       NULL
  360. } ;
  361. X
  362. char *res_strs[] = {     /* Resolution menu item strings. */
  363. X       "0   300 dpi  Scale: Full size",
  364. X       "1   285 dpi  Scale: 95%",
  365. X       "2   270 dpi  Scale: 90%",
  366. X       "3   255 dpi  Scale: 85%",
  367. X       "4   240 dpi  Scale: 80%",
  368. X       "5   225 dpi  Scale: 75%",
  369. X       "6   210 dpi  Scale: 70%",
  370. X       "7   200 dpi  Scale: 66%",
  371. X       "8   180 dpi  Scale: 60%",
  372. X       "9   165 dpi  Scale: 55%",
  373. X       "10  150 dpi  Scale: 50%",
  374. X       "11  135 dpi  Scale: 45%",
  375. X       "12  120 dpi  Scale: 40%",
  376. X       "13  100 dpi  Scale: 33%",
  377. X       "14   90 dpi  Scale: 30%",
  378. X       "15   75 dpi  Scale: 25%",
  379. X       NULL
  380. } ;
  381. X
  382. char *set_strs[] = {      /* Set menu item strings. */
  383. X       "Picture Name",
  384. X       "Default Settings",
  385. X       "Clear Scanning Frame",
  386. X       "New Scanning Frame",
  387. X       "Show Current Settings",
  388. X       NULL
  389. } ;
  390. X
  391. char helpname[MAXLINE] ;      /* Current help file to display. */
  392. char last_message[MAXLINE] ;  /* Last message that was make_displayed. */
  393. char old_picname[MAXLINE] ;   /* Previous picture name. */
  394. char output[MAXLINE] ;        /* Panel_set string to be output. */
  395. char picname[MAXLINE] ;       /* Name of file for raster image. */
  396. char progname[MAXLINE] ;      /* Name of this program. */
  397. X
  398. int ops[MAXOPS] ;             /* Rasterop functions. */
  399. X
  400. int switches[4] =
  401. X      {
  402. X        0,                    /* Mode (Line Art). */
  403. X        1,                    /* Data Transfer (Compressed). */
  404. X        0,                    /* Serial Port (A). */
  405. X        1                     /* Baud Rate (19200). */
  406. X      } ;
  407. X
  408. int framevals[4] =            /* Initial frame in 1/8th inch intervals. */
  409. X      {
  410. X        16,                   /* X1. */
  411. X        16,                   /* Y1. */
  412. X        48,                   /* X2. */
  413. X        48,                   /* Y2. */
  414. X     } ;
  415. X
  416. int butx ;                    /* Top left X position of popup button. */
  417. int buty ;                    /* Top left Y position of popup button. */
  418. int cur_ch ;                  /* Last keyboard character pressed. */
  419. int curx ;                    /* Current X position of the mouse. */
  420. int cury ;                    /* Current Y position of the mouse. */
  421. int font_width ;              /* Width of a single character. */
  422. int nohelp = 0 ;              /* Indicates if a help file was found. */
  423. int pid ;                     /* Process id of the child scan process. */
  424. int scanning = 0 ;            /* Set if we are in the middle of a scan. */
  425. int showing = 0 ;             /* Set if we are in the middle of a show. */
  426. int type ;                    /* Current pseudo event type. */
  427. int width ;                   /* Width in pixels of scantool window. */
  428. X
  429. /* Cyclic switches. */
  430. int brightness ;              /* Brightness value. */
  431. int contrast ;                /* Contrast value. */
  432. int grain ;                   /* Grain value. */
  433. int resolution ;              /* Resolution value. */
  434. X
  435. enum draw_type drawstate ;    /* Current action if a redraw is needed. */
  436. X
  437. FILE *hfd ;                   /* File descriptor for help file. */
  438. X
  439. X
  440. main(argc, argv)
  441. int argc ;
  442. char *argv[] ;
  443. {
  444. X  STRCPY(progname, argv[0]) ;      /* Save program name. */
  445. X  get_options(argc, argv) ;        /* Extract command line options. */
  446. X  init_ws_type() ;                 /* Setup pseudo rasterop functions. */
  447. X  drawstate = DO_NOTHING ;         /* No popups currently displayed. */
  448. X  if ((hfd = fopen(HELPNAME, "r")) == NULL)
  449. X    {
  450. X      FPRINTF(stderr, "Help file %s not found\r\n", HELPNAME) ;
  451. X      nohelp = 1 ;
  452. X    }
  453. X
  454. X  STRCPY(picname, "/home1/falcon/gunnar/scan.rf") ;
  455. X  set_defaults() ;                /* Set scanner settings to default. */
  456. X  make_frames(argc, argv) ;  /* Create main scantool frame and show window. */
  457. X  make_subframes() ;         /* Create canvases for each window. */
  458. X  init_fonts() ;             /* Open fonts used by scantool. */
  459. X  make_menus() ;             /* Create scantool menubar pulldown menus. */
  460. X  start_tool() ;             /* Fit window and wait for events. */
  461. }
  462. SHAR_EOF
  463. chmod 0644 scantool.c ||
  464. echo 'restore of scantool.c failed'
  465. Wc_c="`wc -c < 'scantool.c'`"
  466. test 6453 -eq "$Wc_c" ||
  467.     echo 'scantool.c: original size 6453, current size' "$Wc_c"
  468. rm -f _shar_wnt_.tmp
  469. fi
  470. # ============= scantool.h ==============
  471. if test -f 'scantool.h' -a X"$1" != X"-c"; then
  472.     echo 'x - skipping scantool.h (File already exists)'
  473.     rm -f _shar_wnt_.tmp
  474. else
  475. > _shar_wnt_.tmp
  476. echo 'x - extracting scantool.h (Text)'
  477. sed 's/^X//' << 'SHAR_EOF' > 'scantool.h' &&
  478. X
  479. /*  @(#)scantool.h 1.4 90/04/04
  480. X *
  481. X *  Definitions used by scantool.
  482. X *
  483. X *  Copyright (c) Rich Burridge.
  484. X *                Sun Microsystems, Australia - All rights reserved.
  485. X *
  486. X *  Permission is given to distribute these sources, as long as the
  487. X *  copyright messages are not removed, and no monies are exchanged.
  488. X *
  489. X *  No responsibility is taken for any errors or inaccuracies inherent
  490. X *  either to the comments or the code of this program, but if
  491. X *  reported to me, then an attempt will be made to fix them.
  492. X */
  493. X
  494. #define  CLOSE       (void) close      /* To make lint happy. */
  495. #define  EXECL       (void) execl
  496. #define  FGETS       (void) fgets
  497. #define  FPRINTF     (void) fprintf
  498. #define  KILL        (void) kill
  499. #define  READ        (void) read
  500. #define  SPRINTF     (void) sprintf
  501. #define  STRCPY      (void) strcpy
  502. #define  STRNCAT     (void) strncat
  503. #define  STRNCPY     (void) strncpy
  504. X
  505. #define  BUTTON_HEIGHT  28        /* Height of a command button in pixels. */
  506. #define  BUTTON_WIDTH   64        /* Width of a command button in pixels. */
  507. #define  EQUAL          !strcmp   /* For character comparisons. */
  508. #define  FONT_HEIGHT    14        /* Dimensions of the character fonts used. */
  509. #define  FRAMEGAP       LINEGAP / 2       /* Scanning frame interval. */
  510. X
  511. #ifndef  HELPNAME
  512. #define  HELPNAME       "scantool.help"   /* Name of scantool help file. */
  513. #endif /*HELPNAME*/
  514. X
  515. #define  INC            argc-- ; argv++ ;
  516. #define  LINEGAP        10      /* Gap between lines in scanning frame. */
  517. #define  MAXCURSORS     4       /* Maximum number of cursors used. */
  518. #define  MAXFONTS       2       /* Maximum number of fonts used. */
  519. #define  MAXIMAGES      5       /* Maximum number of graphics images. */
  520. #define  MAXLINE        80      /* Length of character strings. */
  521. #define  MAXMENUS       6       /* Maximum number of popup menus. */
  522. #define  MAXOPS         6       /* Number of pseudo rasterop functions. */
  523. #define  MBAR_HEIGHT    20      /* Height of the top menu bar. */
  524. #define  MBAR_WIDTH     100     /* Width of a portion of the top menu bar. */
  525. #define  OFF            0       /* Used to define toggle switch positions. */
  526. #define  ON             1
  527. #define  SCAN_FRAME_X   26      /* Initial start position of scanning frame. */
  528. #define  SCAN_FRAME_Y   47
  529. #define  SCAN_HEIGHT    506     /* Height of the scantool window. */
  530. #define  SCAN_WIDTH     600     /* Width of the scantool window. */
  531. #define  SWITCH_HEIGHT  90      /* Height of a toggle box switch. */
  532. X
  533. #define  X1             0       /* Coordinate values within framevals. */
  534. #define  Y1             1
  535. #define  X2             2
  536. #define  Y2             3
  537. X
  538. #define  OK             1       /* Text button states. */
  539. #define  CANCEL         0
  540. X
  541. #define  BACKSPACE      8       /* Used for filename construction. */
  542. #define  DEL            127
  543. #define  LINEFEED       13
  544. #define  RETURN         10
  545. X
  546. /* Pseudo events generated by scantool. */
  547. #define  LEFT_DOWN         0    /* Left mouse button was depressed. */
  548. #define  LEFT_UP           1    /* Left mouse button was debounced. */
  549. #define  MIDDLE_DOWN       2    /* Middle mouse button was depressed. */
  550. #define  MIDDLE_UP         3    /* Middle mouse button was debounced. */
  551. #define  RIGHT_DOWN        4    /* Right mouse button was depressed. */
  552. #define  RIGHT_UP          5    /* Right mouse button was debounced. */
  553. #define  KEYBOARD          6    /* A keyboard key has been pressed. */
  554. #define  REPAINT           7    /* Scantool canvas needs repainting. */
  555. #define  MOUSE_MOVE        8    /* The mouse is being moved. */
  556. #define  MOUSE_DRAG        9    /* The mouse is being dragged. */
  557. #define  IGNORE            10   /* Not interested in this event. */
  558. X
  559. /* Abbreviations for box switch values. */
  560. #define  MODE              switches[0]
  561. #define  DATA_TRANSFER     switches[1]
  562. #define  SERIAL_PORT       switches[2]
  563. #define  BAUD_RATE         switches[3]
  564. X
  565. #define  SET_PICTURE      1     /* Values for the Set menu commands. */
  566. #define  SET_DEFAULTS     2
  567. #define  SET_CLEAR_FRAME  3
  568. #define  SET_NEW_FRAME    4
  569. #define  SET_CURRENT      5
  570. X
  571. /* Cursor types used by scantool. */
  572. enum cur_type { FRAME_CUR, HELP_CUR, HOUR_CUR, MAIN_CUR } ;
  573. X
  574. /* States that the drawing canvas can be in. */
  575. enum draw_type { DO_NOTHING, DO_PICNAME, DO_MESSAGE, DO_HELP, DO_SETTINGS } ;
  576. X
  577. enum font_type { BFONT, NFONT } ;          /* Fonts used by scantool. */
  578. X
  579. /* Various images types used by scantool. */
  580. enum image_type { B_NORMAL, B_INVERT, S_NORMAL, S_INVERT,
  581. X                  M_NORMAL, M_INVERT, EXCLAIM_IMAGE } ;
  582. X
  583. /* Menus used by scantool. */
  584. enum menu_type { BRIGHTNESS_M, CONTRAST_M, GRAIN_M, HELP_M,
  585. X                 RESOLUTION_M, SET_M, WINDOW_M } ;
  586. X
  587. /* Pseudo rasterop functions. */
  588. enum op_type { GSET, GCLR, GXOR, GSRC, GOR, GNOT } ;
  589. X
  590. enum sten_type { STEN_OFF, STEN_ON, STEN_INV } ;   /* Text stencil types. */
  591. X
  592. #ifndef LINT_CAST
  593. #ifdef lint
  594. #define LINT_CAST(arg)  (arg ? 0 : 0)
  595. #else
  596. #define LINT_CAST(arg)  (arg)
  597. #endif lint
  598. #endif LINT_CAST
  599. SHAR_EOF
  600. chmod 0644 scantool.h ||
  601. echo 'restore of scantool.h failed'
  602. Wc_c="`wc -c < 'scantool.h'`"
  603. test 4982 -eq "$Wc_c" ||
  604.     echo 'scantool.h: original size 4982, current size' "$Wc_c"
  605. rm -f _shar_wnt_.tmp
  606. fi
  607. # ============= scantool.help ==============
  608. if test -f 'scantool.help' -a X"$1" != X"-c"; then
  609.     echo 'x - skipping scantool.help (File already exists)'
  610.     rm -f _shar_wnt_.tmp
  611. else
  612. > _shar_wnt_.tmp
  613. echo 'x - extracting scantool.help (Text)'
  614. sed 's/^X//' << 'SHAR_EOF' > 'scantool.help' &&
  615. %brightness%
  616. X                   BRIGHTNESS.
  617. X
  618. X  There are 14 Brightness levels to choose from. The
  619. effect of this control depends on whether the image
  620. is scanned in Line Art or Halftone mode.
  621. X
  622. X  In Line Art mode, the higher the Brightness setting
  623. the darker a spot must be in order for the scanner to
  624. consider it "black". Lower settings can therefore be
  625. used to get a sharper image if the original is too
  626. light or blurry, while higher settings can be used to
  627. prevent slightly shaded areas from coming out black
  628. in the scanned image.
  629. X
  630. X  In Halftone mode, the Brightness setting affects
  631. shading in all areas of the scanned image, both dark
  632. and light. The higher the value selected, the lighter
  633. the overall image; the lower the setting, the darker
  634. image.
  635. %%
  636. X
  637. %compress%
  638. X                 COMPRESS.
  639. X
  640. X  In order to reduce the amount of time needed to
  641. transmit a scanned image to the Sun computer, the
  642. MS-300A can compress image data using a one-
  643. dimensional coding scheme based on CCITT
  644. Recommendation T.4 (modified Huffman code).
  645. %%
  646. X
  647. %contrast%
  648. X                    CONTRAST.
  649. X
  650. X  The Contrast control also has 14 different settings.
  651. The effect of this control in Line Art mode is identical
  652. to that of the Brightness control. In Halftone mode, a
  653. higher Contrast setting causes all but the darkest areas
  654. of the original document to come out lighter in the
  655. scanned image. Too high a setting can result in "glare
  656. spots" of pure white; too low a setting can make the
  657. image almost uniformly gray.
  658. %%
  659. X
  660. %frame%
  661. X               SET SCANNING FRAME.
  662. X
  663. X  The frame is the area to be scanned. Scan Tool allows
  664. you to scan an area as small as 1/8" x 1/8", or as large
  665. as 8.5" x 11". Using the Set Scanning Frame function in
  666. the Set menu, you can adjust the size and location of
  667. the frame in order to scan any part of the document that
  668. you feed into the scanner.
  669. %%
  670. X
  671. %grain%
  672. X                        GRAIN.
  673. X
  674. X  All the grains in any one halftone image are the same
  675. size (see the Mode help). It is desirable, however, to
  676. use different grain sizes for different kinds of images.
  677. The Grain control makes it possible to do this. Six
  678. different grain sizes are available: 2, 3, 4, 5, 6, and
  679. 8 dots square.
  680. X
  681. X  When smaller grain sizes (i.e. higher settings) are
  682. used, fine details in the original document are captured
  683. more clearly, but the smaller number of dot positions in
  684. the grains limits the scanner's "palette" of gray levels.
  685. A Grain setting of 11, for instance produces grains that
  686. are 2 dots high by 2 dots wide. With only 4 dot positions
  687. to fill, only 5 distinct gray levels are possible, from
  688. all white to all black.
  689. %%
  690. X
  691. %mode%
  692. X                       MODE.
  693. X
  694. X  The scanner can handle input from the image sensor in
  695. two modes: Line Art mode and Halftone mode. Line Art
  696. mode produces an all black-and-white image, while
  697. Halftone mode results in an image that appears to contain
  698. varying shades of gray.
  699. X
  700. X  In Line Art mode, the amount of light falling on the
  701. sensor is compared against a "threshold" determined by
  702. the Brightness and Contrast controls. Whenever it falls
  703. below the threshold, a black dot is sent to the Sun; when
  704. it exceeds the threshold a white dot is sent. This mode
  705. is normally used for material in which everything is
  706. either black or white.
  707. X
  708. X  Halftone mode is used to detect and reproduce finer
  709. differences in shading. In this mode the dots sent to
  710. the Sun are organised into squares, or "grains", of
  711. uniform size. By varying the ratio of black and white
  712. dots in the grains, different degrees of shading, or
  713. "gray levels", are achieved.
  714. %%
  715. X
  716. %picture%
  717. X                  PICTURE NAME.
  718. X
  719. X  This is the name of the file on the Sun that the
  720. scanned picture will be saved in. The default is a
  721. file called "Noname.rf".
  722. %%
  723. X
  724. %port%
  725. X                         PORT.
  726. X
  727. X  This is the RS232 port that is used to connect to
  728. the scanner. Connect the MS300-A to the Sun as shown
  729. below:
  730. X
  731. X         MS-300A                           SUN
  732. X      ------------                     ----------
  733. X    Pin No.    Name      Direction     Pin No.    Name
  734. X   ---------  ------  --------------  ---------  ------
  735. X       2       TXD    Scanner to Sun      3       RXD
  736. X       3       RXD    Sun to scanner      2       TXD
  737. X       7       GND        ---             7       GND
  738. %%
  739. X
  740. %resolution%
  741. X                    RESOLUTION.
  742. X
  743. X  The Resolution control determines the degree of
  744. reduction of the scanned image relative to the original.
  745. Since the dots that make up the scanned image cannot be
  746. reduced in size, reduction is achieved by deleting dots
  747. at selected intervals when transmitting the image to
  748. the Sun, resulting in an effective resolution of less
  749. than the scanner's maximum of 300 dots per inch.
  750. X
  751. X  There are 16 possible Resolution settings, providing
  752. scaling operations from 25% to 100%.
  753. %%
  754. X
  755. %scan%
  756. X                     SCAN.
  757. X
  758. X  When you click the Scan button, scantool checks
  759. to see if the scanner is on line, i.e. powered up,
  760. properly connected and ready to receive commands.
  761. X
  762. X  If everything checks out OK, the current settings
  763. will be transmitted to the scanner, and the rollers
  764. will begin to turn. Actual scanning will begin after
  765. a document is detected by the paper sensor, which is
  766. located in the middle of the feed slot just below
  767. the top rollers.
  768. %%
  769. X
  770. %speed%
  771. X                     SPEED.
  772. X
  773. X  Two speed settings between the scanner and the
  774. Sun are available, either 9600 or 19200 baud.
  775. %%
  776. SHAR_EOF
  777. chmod 0644 scantool.help ||
  778. echo 'restore of scantool.help failed'
  779. Wc_c="`wc -c < 'scantool.help'`"
  780. test 5356 -eq "$Wc_c" ||
  781.     echo 'scantool.help: original size 5356, current size' "$Wc_c"
  782. rm -f _shar_wnt_.tmp
  783. fi
  784. # ============= scantool.icon ==============
  785. if test -f 'scantool.icon' -a X"$1" != X"-c"; then
  786.     echo 'x - skipping scantool.icon (File already exists)'
  787.     rm -f _shar_wnt_.tmp
  788. else
  789. > _shar_wnt_.tmp
  790. echo 'x - extracting scantool.icon (Text)'
  791. sed 's/^X//' << 'SHAR_EOF' > 'scantool.icon' &&
  792. /* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16
  793. X */
  794. X    0xFFFF,0xFFFF,0xFFFF,0xFFFF,0x8000,0x0000,0x0000,0x0001,
  795. X    0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  796. X    0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  797. X    0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  798. X    0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  799. X    0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  800. X    0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  801. X    0x83E0,0x0000,0x0000,0x0001,0x8630,0x0000,0x0000,0x0001,
  802. X    0x8630,0x0000,0x0000,0x0001,0x8301,0xF0F0,0xBC00,0x0001,
  803. X    0x81C3,0x1998,0xE600,0x0001,0x8063,0x0018,0xC600,0x0001,
  804. X    0x8033,0x00F8,0xC600,0x0001,0x8633,0x0198,0xC600,0x0001,
  805. X    0x8633,0x1998,0xC600,0x0001,0x83E1,0xF0FC,0xC600,0x0001,
  806. X    0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  807. X    0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  808. X    0x8FFF,0xFFFF,0xFFFF,0xFFF1,0x8000,0x0000,0x0000,0x0001,
  809. X    0x8000,0x0000,0x0000,0x0001,0x8FFF,0xFFFF,0xFFFF,0xFFF1,
  810. X    0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  811. X    0x8FFF,0xFFFF,0xFFFF,0xFFF1,0x8000,0x0000,0x0000,0x0001,
  812. X    0x8000,0x0000,0x0000,0x0001,0x8FFF,0xFFFF,0xFFFF,0xFFF1,
  813. X    0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  814. X    0x8FFF,0xFFFF,0xFFFF,0xFFF1,0x8000,0x0000,0x0000,0x0001,
  815. X    0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  816. X    0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  817. X    0x8FF0,0x0000,0x7800,0x0001,0x8180,0x0000,0x1800,0x0001,
  818. X    0x8180,0x0000,0x1800,0x0001,0x8181,0xF0F8,0x1800,0x0001,
  819. X    0x8183,0x198C,0x1800,0x0001,0x8183,0x198C,0x1800,0x0001,
  820. X    0x8183,0x198C,0x1800,0x0001,0x8183,0x198C,0x1800,0x0001,
  821. X    0x8183,0x198C,0x1800,0x0001,0x8181,0xF0F8,0x1800,0x0001,
  822. X    0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  823. X    0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  824. X    0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  825. X    0x8000,0x0000,0x0000,0x0001,0xFFFF,0xFFFF,0xFFFF,0xFFFF
  826. SHAR_EOF
  827. chmod 0644 scantool.icon ||
  828. echo 'restore of scantool.icon failed'
  829. Wc_c="`wc -c < 'scantool.icon'`"
  830. test 1933 -eq "$Wc_c" ||
  831.     echo 'scantool.icon: original size 1933, current size' "$Wc_c"
  832. rm -f _shar_wnt_.tmp
  833. fi
  834. # ============= scantool_extern.h ==============
  835. if test -f 'scantool_extern.h' -a X"$1" != X"-c"; then
  836.     echo 'x - skipping scantool_extern.h (File already exists)'
  837.     rm -f _shar_wnt_.tmp
  838. else
  839. > _shar_wnt_.tmp
  840. echo 'x - extracting scantool_extern.h (Text)'
  841. sed 's/^X//' << 'SHAR_EOF' > 'scantool_extern.h' &&
  842. X
  843. /*  @(#)scantool_extern.h 1.4 90/04/04
  844. X *
  845. X *  External variables used by the scantool routines.
  846. X *
  847. X *  Copyright (c) Rich Burridge.
  848. X *                Sun Microsystems, Australia - All rights reserved.
  849. X *
  850. X *  Permission is given to distribute these sources, as long as the
  851. X *  copyright messages are not removed, and no monies are exchanged.
  852. X *
  853. X *  No responsibility is taken for any errors or inaccuracies inherent
  854. X *  either to the comments or the code of this program, but if
  855. X *  reported to me, then an attempt will be made to fix them.
  856. X */
  857. X
  858. extern char *br_strs[] ;       /* Brightness menu item strings. */
  859. extern char *con_strs[] ;      /* Contrast menu item strings. */
  860. extern char *gr_strs[] ;       /* Grain menu item strings. */
  861. extern char helpname[] ;       /* Current help file to display. */
  862. extern char *help_strs[] ;     /* Help menu item strings. */
  863. extern char last_message[] ;   /* Last make_displayed message. */
  864. extern char old_picname[] ;    /* Previous picture name. */
  865. extern char output[] ;         /* Panel_set string to be output. */
  866. extern char picname[] ;        /* Name of file for raster image. */
  867. extern char progname[] ;       /* This programs name. */
  868. extern char *res_strs[] ;      /* Resolution menu item strings. */
  869. extern char *set_strs[] ;      /* Set menu item strings. */
  870. X
  871. extern int brightness ;   /* Brightness value. */
  872. extern int butx ;         /* Top left X position of popup button. */
  873. extern int buty ;         /* Top left Y position of popup button. */
  874. extern int contrast ;     /* Contrast value. */
  875. extern int cur_ch ;       /* Last keyboard character pressed. */
  876. extern int curx ;         /* Current X position of the mouse. */
  877. extern int cury ;         /* Current Y position of the mouse. */
  878. extern int font_width ;   /* Width of a single character. */
  879. extern int framevals[] ;  /* Initial frame in 1/8th inch intervals. */
  880. extern int grain ;        /* Grain value. */
  881. extern int nohelp ;       /* Indicates if a help file was found. */
  882. extern int ops[] ;        /* Pseudo rasterop functions. */
  883. extern int pid ;          /* Process id of the child scan process. */
  884. extern int resolution ;   /* Resolution value. */
  885. extern int scanning ;     /* Set if we are in the middle of a scan. */
  886. extern int showing ;      /* Set if we are in the middle of a show. */
  887. extern int switches[] ;
  888. extern int type ;         /* Current pseudo event type. */
  889. extern int width ;        /* Width in pixels of scantool window. */
  890. X
  891. extern FILE *hfd ;        /* File descriptor for help file. */
  892. X
  893. extern enum draw_type drawstate ;  /* Current redraw action. */
  894. X
  895. SHAR_EOF
  896. chmod 0644 scantool_extern.h ||
  897. echo 'restore of scantool_extern.h failed'
  898. Wc_c="`wc -c < 'scantool_extern.h'`"
  899. test 2593 -eq "$Wc_c" ||
  900.     echo 'scantool_extern.h: original size 2593, current size' "$Wc_c"
  901. rm -f _shar_wnt_.tmp
  902. fi
  903. # ============= sunview.c ==============
  904. if test -f 'sunview.c' -a X"$1" != X"-c"; then
  905.     echo 'x - skipping sunview.c (File already exists)'
  906.     rm -f _shar_wnt_.tmp
  907. else
  908. > _shar_wnt_.tmp
  909. echo 'x - extracting sunview.c (Text)'
  910. sed 's/^X//' << 'SHAR_EOF' > 'sunview.c' &&
  911. /*  @(#)sunview.c 1.4 90/04/04
  912. X *
  913. X *  SunView dependent graphics routines used by scantool.
  914. X *
  915. X *  Copyright (c) Rich Burridge.
  916. X *                Sun Microsystems, Australia - All rights reserved.
  917. X *
  918. X *  Permission is given to distribute these sources, as long as the
  919. X *  copyright messages are not removed, and no monies are exchanged.
  920. X *
  921. X *  No responsibility is taken for any errors or inaccuracies inherent
  922. X *  either to the comments or the code of this program, but if
  923. X *  reported to me, then an attempt will be made to fix them.
  924. X */
  925. X
  926. #include <stdio.h>
  927. #include <sys/fcntl.h>
  928. #include <sys/wait.h>
  929. #include <sys/time.h>
  930. #include <sys/resource.h>
  931. #include "scantool.h"
  932. #include "images.h"
  933. #include "scantool_extern.h"
  934. #include <suntool/sunview.h>
  935. #include <suntool/canvas.h>
  936. X
  937. #define  MENU_SET                       (void) menu_set
  938. #define  NOTIFY_DISPATCH                (void) notify_dispatch
  939. #define  NOTIFY_INTERPOSE_DESTROY_FUNC  (void) notify_interpose_destroy_func
  940. #define  NOTIFY_INTERPOSE_EVENT_FUNC    (void) notify_interpose_event_func
  941. #define  NOTIFY_SET_WAIT3_FUNC          (void) notify_set_wait3_func
  942. #define  PR_DESTROY                     (void) pr_destroy
  943. #define  PW_REPLROP                     (void) pw_replrop
  944. #define  PW_ROP                         (void) pw_rop
  945. #define  PW_TEXT                        (void) pw_text
  946. #define  PW_TTEXT                       (void) pw_ttext
  947. #define  PW_VECTOR                      (void) pw_vector
  948. #define  PW_WRITEBACKGROUND             (void) pw_writebackground
  949. #define  WINDOW_READ_EVENT              (void) window_read_event
  950. #define  WINDOW_SET                     (void) window_set
  951. X
  952. /* Fonts used by scantool. */
  953. #define  BOLD_FONT      "/usr/lib/fonts/fixedwidthfonts/screen.b.14"
  954. #define  NORMAL_FONT    "/usr/lib/fonts/fixedwidthfonts/screen.r.14"
  955. X
  956. struct pixfont *open_font() ;
  957. void repaint_show_canvas() ;
  958. X
  959. Canvas canvas, show_canvas ;
  960. Cursor cursor[MAXCURSORS] ;
  961. Event *cur_event ;
  962. Frame base_frame, show_frame ;
  963. Icon scantool_icon ;
  964. Menu menus[MAXMENUS] ;
  965. Notify_value destroy(), handle_resize() ;
  966. Pixfont *font[MAXFONTS] ;
  967. Pixrect *images[MAXIMAGES] ;
  968. Pixrect *spr ;
  969. Pixwin *spw, *wpw ;
  970. X
  971. int firsttime ;      /* Set if we haven't resized the window yet. */
  972. int init_height ;    /* Initial height of the scantool window. */
  973. int init_width ;     /* Initial width of the scantool window. */
  974. X
  975. struct rasterfile hdr ;
  976. X
  977. mpr_static(grey_pr,          16, 16, 1, grey_image) ;
  978. mpr_static(icon_pr,          64, 64, 1, icon_image) ;
  979. mpr_static(exclaim_pr,       64, 64, 1, exclaim_image) ;
  980. mpr_static(button_normal_pr, 64, 64, 1, button_normal_image) ;
  981. mpr_static(button_invert_pr, 64, 64, 1, button_invert_image) ;
  982. mpr_static(switch_normal_pr, 16, 16, 1, switch_normal_image) ;
  983. mpr_static(switch_invert_pr, 16, 16, 1, switch_invert_image) ;
  984. mpr_static(main_cursor_pr,   16, 16, 1, main_cursor_array) ;
  985. mpr_static(hour_cursor_pr,   16, 16, 1, hour_cursor_array) ;
  986. mpr_static(help_cursor_pr,   16, 16, 1, help_cursor_array) ;
  987. mpr_static(frame_cursor_pr,  16, 16, 1, frame_cursor_array) ;
  988. X
  989. /*ARGSUSED*/
  990. void
  991. canvas_proc(canvas, event)
  992. Canvas canvas ;
  993. Event *event ;
  994. {
  995. X  cur_event = event ;
  996. X  handle_event() ;       /* Determine what kind of event it is. */
  997. X  process_event() ;      /* And process it. */
  998. }
  999. X
  1000. create_menu(mtype, title, values)    /* Create popup menus for cycle items. */
  1001. enum menu_type mtype ;
  1002. char *title, *values[] ;
  1003. {
  1004. X  int i = 0 ;
  1005. X  int more = 1 ;   /* Cleared when current menu is complete.*/
  1006. X
  1007. X  menus[(int) mtype] = menu_create(MENU_TITLE_ITEM, title,
  1008. X                                   MENU_FONT,       font[(int) NFONT],
  1009. X                                   0) ;
  1010. X  do
  1011. X    {
  1012. X      if (values[i] != NULL)
  1013. X        MENU_SET(menus[(int) mtype], MENU_STRING_ITEM, values[i], i+1, 0) ;
  1014. X      else more = 0 ;
  1015. X      i++ ;
  1016. X    }
  1017. X  while (more) ;
  1018. }
  1019. X
  1020. /*ARGSUSED*/
  1021. Notify_value
  1022. destroy(client, status)
  1023. Notify_client client ;
  1024. Destroy_status status ;
  1025. {
  1026. X  stop_scan() ;        /* Stop the current scan (if there is one). */
  1027. X  exit(0) ;
  1028. }
  1029. X
  1030. display_menu(menuno)
  1031. enum menu_type menuno ;
  1032. {
  1033. X  return((int) menu_show(menus[(int) menuno], canvas,
  1034. X                         canvas_window_event(canvas, cur_event), 0)) ;
  1035. }
  1036. X
  1037. draw_area(x, y, width, height, op)
  1038. int x, y, width, height ;
  1039. enum op_type op ;
  1040. {
  1041. X  PW_WRITEBACKGROUND(wpw, x, y, width, height, ops[(int) op]) ;
  1042. }
  1043. X
  1044. draw_image(x, y, width, height, image)
  1045. int x, y, width, height ;
  1046. enum image_type image ;
  1047. {
  1048. X  PW_ROP(wpw, x, y, width, height, PIX_SRC, images[(int) image], 0, 0) ;
  1049. }
  1050. X
  1051. draw_line(x1, y1, x2, y2, op)
  1052. int x1, y1, x2, y2 ;
  1053. enum op_type op ;
  1054. {
  1055. X  PW_VECTOR(wpw, x1, y1, x2, y2, ops[(int) op], 1) ;
  1056. }
  1057. X
  1058. draw_text(x, y, stencil, ftype, str)
  1059. int x, y ;
  1060. enum sten_type stencil ;
  1061. enum font_type ftype ;
  1062. char *str ;
  1063. {
  1064. X  switch (stencil)
  1065. X    {
  1066. X      case STEN_OFF : PW_TEXT(wpw,  x, y, PIX_SRC, font[(int) ftype], str) ;
  1067. X                      break ;
  1068. X      case STEN_ON  : PW_TTEXT(wpw, x, y, PIX_SET, font[(int) ftype], str) ;
  1069. X                      break ;
  1070. X      case STEN_INV : PW_TTEXT(wpw, x, y, PIX_CLR, font[(int) ftype], str) ;
  1071. X    }
  1072. }
  1073. X
  1074. get_event()       /* Get the next SunView event. */
  1075. {
  1076. X  WINDOW_READ_EVENT(canvas, cur_event) ;
  1077. }
  1078. X
  1079. get_strwidth(ftype, str)    /* Get width in pixels of string value. */
  1080. enum font_type ftype ;
  1081. char *str ;
  1082. {
  1083. X  struct pr_size size ;
  1084. X
  1085. X  size = pf_textwidth(strlen(str), font[(int) ftype], str) ;
  1086. X  return(size.x) ;
  1087. }
  1088. X
  1089. grey_area(x, y, width, height)
  1090. {
  1091. X  PW_REPLROP(wpw, x, y, width, height, PIX_SRC, &grey_pr, 0, 0) ;
  1092. }
  1093. X
  1094. handle_event()        /* Work out what kind of event this is. */
  1095. {
  1096. X  curx = event_x(cur_event) ;
  1097. X  cury = event_y(cur_event) ;
  1098. X  cur_ch = event_id(cur_event) ;
  1099. X
  1100. X  if (event_is_button(cur_event) && event_is_down(cur_event))
  1101. X    {
  1102. X           if (cur_ch == MS_LEFT)     type = LEFT_DOWN ;
  1103. X      else if (cur_ch == MS_MIDDLE)   type = MIDDLE_DOWN ;
  1104. X      else if (cur_ch == MS_RIGHT)    type = RIGHT_DOWN ;
  1105. X    }
  1106. X  else if (event_is_button(cur_event) && event_is_up(cur_event))
  1107. X    {
  1108. X           if (cur_ch == MS_LEFT)     type = LEFT_UP ;
  1109. X      else if (cur_ch == MS_MIDDLE)   type = MIDDLE_UP ;
  1110. X      else if (cur_ch == MS_RIGHT)    type = RIGHT_UP ;
  1111. X    }
  1112. X  else if (event_is_ascii(cur_event)) type = KEYBOARD ;
  1113. X  else if (cur_ch == LOC_MOVE)        type = MOUSE_MOVE ;
  1114. X  else if (cur_ch == LOC_DRAG)        type = MOUSE_DRAG ;
  1115. X  else if (cur_ch == WIN_REPAINT)     type = REPAINT ;
  1116. X  else                                type = IGNORE ;
  1117. }
  1118. X
  1119. Notify_value
  1120. handle_resize(frame, event, arg, type)
  1121. SHAR_EOF
  1122. true || echo 'restore of sunview.c failed'
  1123. fi
  1124. echo 'End of  part 4'
  1125. echo 'File sunview.c is continued in part 5'
  1126. echo 5 > _shar_seq_.tmp
  1127. exit 0
  1128.