home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume19 / xfig / part17 < prev    next >
Encoding:
Text File  |  1993-05-26  |  61.4 KB  |  1,832 lines

  1. Newsgroups: comp.sources.x
  2. From: envbvs@epb9.lbl.gov (Brian V. Smith)
  3. Subject: v19i129:  xfig - Draw amd manipulate objects in an X-Window, Part17/27
  4. Message-ID: <1993May21.021624.6813@sparky.imd.sterling.com>
  5. X-Md4-Signature: 621e4680aa05f4fb879911b2fafbe33c
  6. Sender: chris@sparky.imd.sterling.com (Chris Olson)
  7. Organization: Sterling Software
  8. Date: Fri, 21 May 1993 02:16:24 GMT
  9. Approved: chris@sparky.imd.sterling.com
  10.  
  11. Submitted-by: envbvs@epb9.lbl.gov (Brian V. Smith)
  12. Posting-number: Volume 19, Issue 129
  13. Archive-name: xfig/part17
  14. Environment: X11
  15. Supersedes: xfig: Volume 16, Issue 6-30,39
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then unpack
  19. # it by saving it into a file and typing "sh file".  To overwrite existing
  20. # files, type "sh file -c".  You can also feed this as standard input via
  21. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  22. # will see the following message at the end:
  23. #        "End of archive 17 (of 27)."
  24. # Contents:  CHANGES f_read.c
  25. # Wrapped by envbvs@epb9.lbl.gov.lbl.gov on Mon May  3 12:06:01 1993
  26. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  27. if test -f 'CHANGES' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'CHANGES'\"
  29. else
  30. echo shar: Extracting \"'CHANGES'\" \(30300 characters\)
  31. sed "s/^X//" >'CHANGES' <<'END_OF_FILE'
  32. XVersion 2.1
  33. X===========
  34. X
  35. XPatchlevel 7 (May 3, 1993)
  36. XChanges to Patchlevel 6:
  37. X
  38. XNEW FEATURES:
  39. X
  40. Xo Vertical and upside-down text - text with angles of 90, 180 and 270 degrees
  41. X    supported. Text between those angles will be drawn with the next 
  42. X    higher angle (e.g. 130 degree text will be drawn at 180 degrees).
  43. X    from Alan Richardson (mppa3@uk.ac.sussex.syma)
  44. Xo message panel uses asciiTextWidget so one may select text from it
  45. Xo does not ask if it is OK to write an existing file during save if it is the
  46. X    current figure file that is being saved.  Same for export.
  47. Xo accelerators to Save or Load file without popping up file menu 
  48. X    (default: Meta-S to Save and Meta-L to Load)
  49. Xo PRINTER environment variable is used if no resource is set for 
  50. X    Fig*printer*string
  51. Xo if an ellipse is scaled such that the radii become equal it is "converted"
  52. X    to a circle
  53. Xo ablity to change to/from imperial and metric with popup menu by hitting
  54. X    mouse button 3 in the units box (where rulers meet)
  55. X    from Paul King (king@cs.uq.oz.au)
  56. Xo new command-line parameters -userscale (resource userscale) and -userunit
  57. X    (resource userunit) which are used in the on-screen messages which
  58. X    show the current length/diameter etc.  This provides a simple way of
  59. X    doing scale drawings, e.g. 0.25 inch = 1 ft (userscale=0.25,
  60. X    userunit="ft") or 1 cm = 1 m (userscale=1, userunit="m").  These may
  61. X    be changed via the popup menu by hitting mouse button 3 in the units
  62. X    box (where rulers meet)
  63. Xo new indicator button allows text flags to be viewed/set
  64. Xo compiles/runs on DEC Alpha with OSF/1 now
  65. Xo text widget in the print popup to pass extra parameters to print program
  66. X    (lp or lpr as the case may be)
  67. Xo indicator shows the number of figures in the batch print file in print popup
  68. Xo automatic on-screen generation of preview bitmap for EPS objects if you have 
  69. X    gs (ghostscript) - compile with -DGSBIT flag
  70. X    from Michael C. Grant (mcgrant@rascals.stanford.edu) 
  71. X    adapted from
  72. X    Marc Goldburg's (marcg@rascals.stanford.edu) original idea and code.
  73. Xo indicator in upper-left corner (under Quit button) shows current filename
  74. Xo print button changes message from "print FIGURE to printer" to "print BATCH to
  75. X    printer" if there are figures in batch file
  76. Xo when drawing objects or moving/adding points the length/radius/diameter is 
  77. X    displayed in the message window
  78. Xo feature to shift figure on page if it is off the page has been disabled until
  79. X    it can be done with option or explicit command
  80. Xo added -noscalablefonts command-line option to force scalable fonts OFF
  81. X    (usually for debugging)
  82. X
  83. XBUG FIXES:
  84. X
  85. Xo condition for OSF/1 added to use dirent
  86. X    from Dave Hill (ddhill@zk2.dec.com)
  87. Xo Floating point values allowed for BoundingBox in EPS files
  88. Xo if user asks for scalable fonts but server doesn't support them, xfig auto-
  89. X    matically switches to non-scalable fonts
  90. Xo when printing to batch file, incorrect filename appeared in message panel
  91. Xo undo of a text move didn't redraw the text
  92. Xo <unistd.h> included unnecessarily in f_util.c (X11/Xos.h includes it if 
  93. X    necessary). Also, various cleanups with multiply defined cursors etc.
  94. X    From Casey Leedom (casey@gauss.llnl.gov)
  95. Xo internalborderwidth resource should be integer not float
  96. Xo cancel when drawing latex line left unwanted garbage on screen
  97. Xo put_fmsg removed and put_msg uses varargs now so MIPS machines and others
  98. X    should all work fine now
  99. Xo writing X11 bitmap still had bugs
  100. Xo text wasn't being rotated around mouse point with rotate mode
  101. Xo when moving end points of a (sp)line or when adding points to the end
  102. X  of a (sp)line, the angle geometry button was not available
  103. Xo export directory now follows file directory when load/save figure is done
  104. Xo entering centered text with odd number of characters caused double image
  105. Xo fixed bug with incorrectly placing text with point positioning on when the
  106. X    text was originally created with point positioning off
  107. Xo when moving centered or right-justified zoomed text grab point was shifted
  108. Xo rotated ellipses panned incorrectly
  109. Xo centering/flush-left options in Export menu were reversed
  110. Xo flipped EPS objects weren't being flipped properly when reading in figure
  111. Xo GC's weren't being freed when xfig finished
  112. Xo added Titan OS (Stardent) to list of machines needing getenv() and atof() 
  113. X    explicitely defined (not in /usr/include/... file )
  114. X    from Joachim Wiesel (wiesel@ipf.bau-verm.uni-karlsruhe.de)
  115. Xo underscores weren't showing in text line in popup edit
  116. X    from Daniel Faigin (faigin@aero.org)
  117. Xo old text outline wasn't being erased
  118. X    from Daniel Faigin (faigin@aero.org)
  119. Xo number[] array wasn't large enough for new 3-character numbers in the rulers
  120. X    from Andrew Haylett (ajh@gec-mrc.co.uk)
  121. Xo check for X_NOT_STDC_ENV reversed in fig.h for inclusion of stdlib.h and
  122. X    defs of getenv() and atof()
  123. X    from Jonathan Kamens (jik@pit-manager.mit.edu)
  124. Xo SetDir() parameters added (but not used) to placate certain compilers
  125. Xo point positioning resolution wasn't available with add-point-in-object
  126. Xo angle geometry indicator appeared when moving/adding points but isn't used
  127. Xo problem fixed with file popup and grab
  128. X    from David Brooke (BROOKE@leva.leeds.ac.uk)
  129. X
  130. X------------------------------------------------------------------------------
  131. XPatchlevel 6 (Nov 1992)
  132. XChanges to Patchlevel 5:
  133. X
  134. XNEW FEATURES:
  135. X
  136. XBUG FIXES:
  137. X
  138. Xo typo in man pages with menu item "Textyl \special commands" in export menu
  139. Xo action changed from "cancel" to "dismiss" for print menu accelerator
  140. Xo bug in Intrinsics? on Sun Monochrome prevented side ruler from scrolling
  141. Xo was using ellipse routine to draw circles - was choppy for small circles
  142. Xo cast comparison function argument to qsort
  143. Xo rotated ellipses don't become coarse as they are zoomed 
  144. X
  145. X------------------------------------------------------------------------------
  146. XPatchlevel 5 (Nov 1992)
  147. XChanges to Patchlevel 4:
  148. X
  149. XNEW FEATURES:
  150. X
  151. Xo support for two button mouse - use META + Button 3 to simulate button 2
  152. X    from Lars Berntzon (lasse@delila.cgl.se)
  153. Xo new resource "textoutline" (class "TextOutline") and command-line argument
  154. X    "-textoutline" which will outline text in red to show the bounding box
  155. X    that the text will occupy when printed (useful for rotated text)
  156. Xo print popup stays up until dismissed - can still pop up file/export menues, 
  157. X    draw etc. while print popup is up.  HOWEVER, while file or export 
  158. X    popups are up, the print panel is not active.
  159. Xo can align all objects to canvas, not just to compound - use mouse button 2
  160. X    idea from Jon Forrest
  161. Xo ellipses may now be rotated by an arbitrary angle and show their rotation
  162. X    from Janes Tough (jamest@cs.heriot-watt.ac.uk)
  163. Xo new -iconGeometry command-line argument
  164. Xo new command-line argument and resource -exportLanguage to specify default 
  165. X    Export language.  See man pages.
  166. Xo new command-line argument and resource -flushleft to set default printing to 
  167. X    flush left on page. See man pages.
  168. Xo keyboard accelerators! Resource file has defaults for file, export and print
  169. X    popup panels and top command panel accelerators; <Meta>f will popup file
  170. X    panel, <Meta>q will quit, etc. See resource file and man pages for
  171. X    details.
  172. Xo one may now batch together several xfig files for printing with one print job.
  173. X    See popup print panel and man pages.
  174. Xo new label in the mouse function window & more obvious default color (yellow)
  175. Xo added scrollbar for indicator panel when buttons won't all fit on screen
  176. Xo can now edit sizes of arrowheads using popup edit panel
  177. Xo "make install" now automatically installs Fig.ad and Fig-color.ad in 
  178. X    app-defaults directory
  179. Xo WM_DELETE_WINDOW now supported by popups - cancels popup function
  180. X    WM_DELETE_WINDOW in main canvas saves figure in xfig.SAVE and quits
  181. X    from David Wexelblat (dwex@mtgzfs3.att.com)
  182. X
  183. XBUG FIXES:
  184. X
  185. Xo rulers only allowed 2 digits for inches/cm
  186. Xo deleted line thickness/color/area-fill/line-style and arrow settings for EPS
  187. X    objects in the update mode and removed color part in popup edit panel
  188. Xo depth wasn't being updated for splines and texts using update button
  189. Xo more cleanup with respect to procedure/variable types/casts
  190. X    from Don Sharp (dws@mari.co.uk)
  191. Xo fixed text bounds calculation to take into account any rotation when reading
  192. X    in figure from a file to decide whether to shift figure to keep on 
  193. X    canvas
  194. X    (fig2dev 2.1.5 is also fixed so figures with rotated text near edges
  195. X    should center properly now)
  196. Xo fixed bug where segments disappeared while drawing interpolated spline in any
  197. X    LaTeX drawing mode
  198. Xo rearranged a-z and A-Z keys in the CompKeyDB file because some HP computers
  199. X    were apparently doing random things with capitalization
  200. X    from Anthony Shipman (als@bohra.cpg.oz.au)
  201. Xo fixed export of color figure to X11 bitmap format.  White -> white, all other
  202. X    colors -> black.
  203. Xo removed apparently unnecessary translation from w_export, w_file and w_print
  204. X    which causes coredump on some HP machines.
  205. X    From Alfred van der Hoeven (alfred@arthur.et.tudelft.nl)
  206. Xo fixed initialization bug in u_undo.c and object.c which caused HP 9000/700
  207. X    compilers to segfault
  208. X    From Alfred van der Hoeven (alfred@arthur.et.tudelft.nl)
  209. Xo new environvemt variable "XFIGTMPDIR" used for xfig temporary files directory
  210. Xo when reading a figure file, if any object coordinates are negative, the figure
  211. X    is shifted to keep it on the canvas so that the upper-left corner of the
  212. X    figure is placed on the current point positioning grid
  213. X    (in 2.1.4, the upper-left corner was placed at 10,10)
  214. Xo changed "char" to "unsigned char" for initialization of bitmaps by compilers
  215. X    from Teus Hagen (teus@oce.nl)
  216. Xo was passing floats to put_fmsg() instead of doubles.
  217. Xo includes copy of X11/Xfuncs.h now to use correct routines for zeroing/copying
  218. X    memory.
  219. Xo zooming to 0.1 no longer gives X error (dash list was null)
  220. Xo filenames in File/Export windows weren't sorted correctly
  221. X    from Simon Marshall (S.Marshall@sequent.cc.hull.ac.uk)
  222. Xo more explicit note about object depth in the man pages in the "GRAPHICAL 
  223. X    OBJECTS" section
  224. Xo scaling vertical or horizontal line no longer causes floating point exception
  225. X    from Steve Tynor (tynor@prism.gatech.edu)
  226. Xo null strings in text objects now produce warning message when reading from 
  227. X    file but xfig continues to read rest of file
  228. Xo scrollbars in File and Export popups reset to top when changing directories
  229. Xo default output filename in Export popup now changes to reflect current 
  230. X    figure filename
  231. Xo default colors in Fig-color are a little nicer :-)
  232. Xo checking for file writablity now uses access() call
  233. X    from Devon Bowen (bowen@cs.buffalo.edu)
  234. Xo XtRemoveGrab bug when popping down file message window finally fixed
  235. X    many thanks to David Wexelblat (dwex@mtgzfs3.att.com)
  236. Xo XtAppAddActions() only called once now for each action
  237. X    from David Wexelblat (dwex@mtgzfs3.att.com)
  238. Xo changed cfree() calls to free() for those machines that don't have it
  239. X    from Anthony Datri (datri@concave.convex.com)
  240. Xo moved static function definitions outside of procedures for those machines 
  241. X    which can't handle them
  242. X    from Anthony Datri (datri@concave.convex.com)
  243. Xo added second line to Imakefile to put the xfig directory containing the 
  244. X    CompKeyDB (multi-key) database file in the standard X11 library
  245. Xo fixed bug introduced in 2.1.1 which incorrectly placed radius marker of
  246. X    circles created by radius
  247. Xo circle is now changed to ellipse type when scaled assymetrically
  248. Xo fixed various typos in xfig.man
  249. Xo changed references to mouse buttons left/middle/right to say buttons 1/2/3
  250. X    respectively
  251. Xo radius of ellipses-specified-by-radius was one pixel too large
  252. Xo changed interpretation of 1/0 bits in EPS preview bitmaps back to original
  253. X    0=white, 1=black according to EPSF guide version 2.0.
  254. X    Brought to my attention by Vivek Khera (khera@cs.duke.edu)
  255. Xo moved #include Xaw... directives to figx.h to speed up compilation
  256. Xo added conditional for Sun 3 and SunOs 4.0.3
  257. X    from Peter Scott (pjs@euclid.jpl.nasa.gov)
  258. Xo fixed typo in FORMAT2.1 file describing values for types of splines
  259. Xo more lint cleanup and print file name "protection" in case filename has 
  260. X    any shell meta characters
  261. X    from Jonathan Kamens (jik@MIT.Edu)
  262. Xo epsf file wasn't closed after reading if there was no preview bitmap
  263. X    from Herve Poirier (rvp@dxcern.cern.ch)
  264. Xo fixed bug where certain objects inside compound weren't being drawn when
  265. X    there was more than one compound object in the figure
  266. Xo removed ISO8859 requirement for Symbol and ZapfDingbats fonts (those fonts
  267. X    weren't being displayed)
  268. X
  269. X------------------------------------------------------------------------------
  270. XPatchlevel 4 (April 1992)
  271. XChanges to Patchlevel 3:
  272. X
  273. Xo keyFile resource allows ANY path for compose key data base, not just relative
  274. X    to $XFIGLIBDIR
  275. X    from Pete Kaiser (kaiser@heron.enet.dec.com)
  276. Xo simple edit arrowhead feature in the popup edit for lines - can add/delete 
  277. X    arrow heads.  No adjustment of arrow size yet - uses current linewidth 
  278. X    from indicator panel
  279. Xo Example figure files have all been converted to 2.1 file format
  280. Xo if any object coordinates are negative, the whole figure is shifted to keep it
  281. X    on the canvas
  282. Xo fixed major bug where the preview bitmap of EPS objects was in reverse video
  283. X    (1 is white not black, according to the PostScript Language Ref. Manual)
  284. X    *** SEE COMMENT IN PATCHLEVEL 5 ABOUT EPSI PREVIEW BITMAPS ***
  285. Xo general cleanup of param types in Xt callback/action etc. procedures and other
  286. X    lint cleanup
  287. X    from Jonathan Kamens (jik@MIT.Edu)
  288. Xo Alt_L key added to list of keys to do international characters
  289. X    from Marc Goldburg (marcg@alfalfa.stanford.edu)
  290. Xo fractional zoom (i.e. zoom < 1) - see man pages
  291. Xo eps data wasn't being initialized when the eps file wasn't available
  292. Xo redefined filename length for eps object to PATH_MAX
  293. Xo -showallbuttons option didn't show the depth indicator
  294. X    from Paul King (king@cs.uq.oz.au)
  295. Xo fixed bugs where using export and print shortcut before ever popping
  296. X    up respective menus used incorrect options
  297. Xo changes to the file popup:
  298. X    o new "Home" button changes directory to $HOME
  299. X    o ~ (username) operator allowed in the current directory ascii widget
  300. X    o new label widget shows the current figure filename
  301. X    o presssing "Load", "Save" or "Merge Read" will operate on the 
  302. X      filename in the "Filename" window.  If that name is empty the
  303. X      operation is done on the file specified in the "Current Filename" 
  304. X      window.
  305. X    o additionally, the "Load" operation will copy the name (if any)
  306. X      from the "Filename" window to the "Current Filename" window
  307. X    o pressing return in the "list of files" window in the popup File panel
  308. X      will "Load" the file
  309. Xo changes to the export popup:
  310. X    o new "Home" button changes directory to $HOME
  311. X    o ~ (username) operator allowed in the current directory ascii widget
  312. X    o pressing return in the "list of files" window in the popup Export 
  313. X      panel will "Export" the file
  314. Xo Pre-2.1 fig files now have text flags set to PostScript mode when reading into
  315. X    xfig 2.1.4
  316. Xo 1.4-TFX fig files now have text flags set to PostScript mode PLUS Special
  317. Xo font names now include "ISO-8859" to insure that ISO Latin characters are used
  318. X    from Thierry EXCOFFIER (exco@ligiahp.univ-lyon1.fr)
  319. Xo -debug no longer runs xfig synchronously - use standard toolkit option -sync
  320. Xo control points for spline objects now span multiple lines in output file if 
  321. X    there are many points
  322. Xo scrollable x-y points panel in the popup edit panel for objects with many
  323. X    points (mwm didn't display the x-y values when the popup was taller than
  324. X    the screen)
  325. Xo If you have Display Postscript in your server, compile xfig with -DDPS
  326. X    and you will see the full Postscript object instead of preview bitmap
  327. X    when you include EPS objects.
  328. X    !!! WARNING: this has only been tested on IBM's AIX 3.2 (X11R4) on
  329. X    an RS/6000 !!!
  330. X    from Dave Hale (dhale@green.mines.colorado.edu)
  331. Xo fixed bug in error return from system() - now popups error message when 
  332. X    can't export/print figure
  333. Xo unused function clear_char_string() deleted from w_canvas.c
  334. Xo current depth is now in an indicator window and may be set like line 
  335. X    thickness, color etc.
  336. Xo added update tags to control which object components are modified/copied
  337. X    when using the update button.  Button appears in upper-right corner
  338. X    of indicator button (e.g linewidth) when in update mode.  Clicking 
  339. X    on the update tag enables/disables components (e.g. linewidth) from 
  340. X    being copied to/from objects when using update.
  341. Xo fixed exporting of pstex_t and pstex (used to give Postscript for both)
  342. Xo FIG 1.4-TFX file area_fill values now correctly translated to 2.1 format
  343. Xo deleted duplicate #include <math.h> from u_geom.c and w_export.c
  344. Xo changed ^U (control U) in w_canvas.c to \023 for mailers which clobber 
  345. X    control chars
  346. Xo added possibility of wider top ruler and taller side ruler by using
  347. X    -DMAX_TOPRULER_WD=value and -DMAX_SIDERULER_HT=value in Imakefile
  348. Xo added function strtol() for those systems that don't have it.
  349. X    from Jonathan Kamens (jik@pit-manager.MIT.EDU)
  350. Xo added note about -DNOSTRSTR and -DNOSTRTOL for those systems that don't
  351. X    have strstr() and/or strtol() respectively.
  352. Xo fixed type mismatch and bug in call to getenv in main().
  353. Xo type mismatch fixed for X11R5 in call to XtAppInitialize(). 
  354. X    from Jonathan Kamens (jik@pit-manager.MIT.EDU)
  355. Xo small performance fix in u_draw.c in add_point() when reallocating points
  356. X    from Dave Hale (dhale@green.Mines.Colorado.EDU)
  357. X
  358. X------------------------------------------------------------------------------
  359. XPatchlevel 3
  360. XChanges to Patchlevel 2:
  361. X
  362. Xo pressing carriage return in value part of popup indicator buttons that take 
  363. X    integer or float (e.g. line width) now sets the value and pops down
  364. Xo added foreground colors to Text*, Menu* and List* widgets in default Fig-color.ad
  365. X    this fixes problem of white-on-white text when using inverse video
  366. Xo changes two resource names -
  367. X    "xfig_export_menu.export_panel.just_label.flush left" to 
  368. X    "xfig_export_menu.export_panel.just_label.justify" 
  369. X    and 
  370. X    "xfig_print_menu.print_panel.just_label.flush left" to
  371. X    "xfig_print_menu.print_panel.just_label.justify"
  372. Xo some type castings fixed
  373. X    from Wayne D Richardson (wdr@rchland.vnet.ibm.com)
  374. Xo fixed "open file leak" - directory wasn't closed after file popup finished
  375. Xo fixed selection of Times-Roman font under Openwindows
  376. Xo changed titles of popup panels to meaningful names
  377. Xo leading blanks no longer stripped from text objects
  378. X    from George Ferguson (ferguson@cs.rochester.edu)
  379. Xo null strings in text objects now abort load/read of file with error message
  380. X    from George Ferguson (ferguson@cs.rochester.edu)
  381. Xo conditional in xfig.man to set page offset only when using troff
  382. X    from George Ferguson (ferguson@cs.rochester.edu)
  383. Xo added translation so that pressing return in filename window in popup FILE
  384. X    will load the file
  385. Xo added translation so that pressing return in filename window in popup EXPORT
  386. X    will export the file
  387. Xo fixed filled objects of DEFAULT color
  388. Xo fixed bug in delete region
  389. X    from Peter Asenstorfer (peter@audrey.levels.unisa.edu.au)
  390. Xo cleaned up cursor stuff - no impact on user
  391. X    from Brian Boyter (pyrdc!bimbo!boyter@uunet.UU.NET)
  392. Xo new resource "-keyFile" to specify alternate compose key translation
  393. X    file in the XFIGLIBDIR directory
  394. X    From Herve Soulard (soulard@corto.inria.fr)
  395. Xo popup message window to inform user when illegal values in figure file
  396. X    are fixed or when converting from older file versions to newest
  397. Xo limit on depth of objects to 1000 when reading figure file. Fixes problems
  398. X    of infinite looping for files which were converted from Fig 2.0.
  399. X    Also sets depth to zero (0) when reading files older than 2.1.
  400. Xo xfig.man now tells man to run tbl so that regular tables can be used
  401. X    from James B. Davis (james@solbourne.com)
  402. Xo fixed Meta-Y (insert current selection), ^Y (unkill) and ^G (multiply reset) 
  403. X    in CompKeyDB
  404. Xo added capability to delete whole text line from text widgets with ^X
  405. X    from Brian Boyter (pyrdc!bimbo!boyter@uunet.UU.NET)
  406. Xo ^U no longer deletes line of text in text object mode for compatibility
  407. X    with text widgets.  Use only ^X now.
  408. Xo fixed problem with OpenWindows and rubberbanding objects
  409. X    from Brian Boyter (pyrdc!bimbo!boyter@uunet.UU.NET)
  410. Xo fixed minor bug in f_util.c line 82: assignment with '==' instead of '='
  411. X    from pf@diab.se (Per Fogelstr|m)
  412. Xo fixed up bug in set_tags call in w_modepanel.c
  413. X    from Graeme Gill (graeme@labtam.labtam.oz.au)
  414. Xo added strstr() function for systems without it
  415. Xo warning message about redefining InstallManPage fixed
  416. Xo removed unneeded O_NONE symbol from object.h
  417. Xo directory code fixed to work with SVR4
  418. X    from David Elliot (dce@krusty.smsc.sony.com)
  419. Xo cleaned up function declarations for event handlers
  420. X    from Anthony Datri (datri@lovecraft.convex.com)
  421. Xo renamed Fig-co.ad to Fig-color.ad for color customization under X11R5 (see 
  422. X    README). Fig-co.ad can be deleted (if you have an older copy of xfig)
  423. X    from David Elliot (dce@krusty.smsc.sony.com)
  424. X
  425. X------------------------------------------------------------------------------
  426. XPatchlevel 2
  427. XChanges to Patchlevel 1:
  428. X
  429. Xo the font flag (LaTeX, PostScript) wasn't being changed correctly in the
  430. X    UPDATE text object operation when switching from LaTeX to PostScript 
  431. X    or vice versa.
  432. X
  433. Xo the textstep value may now be entered in floating point in the popup menu
  434. X
  435. Xo the eps-bitmap icon was renamed to eps-object because it can be any
  436. X    eps object that is imported.  If it has a preview bitmap
  437. X    that will be displayed.  Several filenames/program variables
  438. X    were also changed to reflect this.
  439. X
  440. Xo there is now a more general glue mechanism for compounding objects
  441. X
  442. Xo text pasting into canvas now possible with F18 function key or any translation
  443. X    desired by user.  F18 is hardwired default in program; F20 also 
  444. X    programmed in Fig.ad to paste text.
  445. X    Brian Boyter (pyrdc!bimbo!boyter@uunet.UU.NET)
  446. X
  447. Xo DEFAULT fill_style caused core dump 
  448. X    from Jeffry R. Abramson (jra@violin.att.com)
  449. X
  450. Xo made the mouse-tracking markers hollow so as not to be visually obtrusive
  451. X    as suggested by Stephen Gildea (gildea@expo.lcs.mit.edu)
  452. X
  453. Xo removed extraneous call to free() in add_point() (u_draw.c)
  454. X    from Per Fogelstr|m (pf@diab.se)
  455. X
  456. Xo cleaned up gcc compiler warnings about type mismatches etc.
  457. X
  458. Xo compound objects may be rotated by arbitrary angles if there are no boxes, 
  459. X    arc-boxes, ellipses or circles contained within.
  460. X
  461. Xo text rotation support is improved - markers are now shown rotated and
  462. X    the angle attribute is set by the relevant rotate operations.
  463. X
  464. Xo both ps and eps modes now supported in export menu.
  465. X
  466. Xo new directory browsing facilities integrated with File and Export popups.
  467. X    Allows selection of file by clicking on the filename.  Has mask to list
  468. X    only those files of interest.  See the man pages for further details.
  469. X
  470. Xo Default font for Postscript fonts may now be selected and objects that
  471. X    have default font may be edited
  472. X
  473. Xo FASTSERVER flag removed; now always uses smart redrawing when available
  474. X    Additionally, smart redrawing is available more often
  475. X
  476. Xo fixed bug in regular polygon where some vertices were off by one pixel
  477. X
  478. Xo added "Use orig. size" button for eps objects to set object to original 
  479. X    size in popup edit
  480. X    from Peter Scott (pjs@euclid.jpl.nasa.gov)
  481. X
  482. Xo international characters supported (umlauts, accents, cedilla etc) using
  483. X    compose (meta) key
  484. X    from Herve Soulard (soulard@corto.inria.fr)
  485. X
  486. Xo much improved color support
  487. X    from Henning Spruth (hns@regent.e-technik.tu-muenchen.de)
  488. X
  489. Xo additional pan and zoom mode with <Ctrl>Key and left/middle/right button
  490. X    from Henning Spruth (hns@regent.e-technik.tu-muenchen.de)
  491. X
  492. Xo removed reference to FONTLIBDIR in Imakefile (no longer required)
  493. X
  494. Xo added a smart-links feature for the MOVE and COPY commands.
  495. X    With smart links turned on, when a BOX-like object is moved
  496. X    so are the lines which join up to it (its links).
  497. X    Two modes are supported: one which moves just the endpoint,
  498. X    the other slides the endlink so that it's angle doesn't change.
  499. X    In the second mode horizontal/vertical lines remain that way.
  500. X
  501. Xo added the ability to save figure during quit if it is modified
  502. X
  503. Xo added support for scalable fonts under R5
  504. X
  505. Xo additional command line flags supported
  506. X    -latexfonts flag (resource .latexfonts) to start xfig with the LaTeX
  507. X    fonts as the default instead of PostScript fonts
  508. X    -specialtext flag (resource .specialtext) to start xfig with special
  509. X    text as the default
  510. X
  511. Xo bug fixed where number of objects count in file popup was sometimes clipped
  512. X
  513. X------------------------------------------------------------------------------
  514. XPatchlevel 1
  515. XChanges to Patchlevel 0:
  516. X
  517. Xo xfig now reads text size, height and length as floats and rounds to ints
  518. X    this is done because certain programs generate floats for these
  519. X
  520. Xo compound object was rounded to next larger grid even if objects inside were
  521. X    already on the grid
  522. X
  523. Xo Examples/logo.fig included Logo.eps instead of logo.eps
  524. X
  525. Xo cancellation of line drawing left single dot on screen
  526. X
  527. Xo filename in File popup menu didn't get set until first popup - file save 
  528. X    shortcut would save to unnamed.fig even if xfig was started with file name
  529. X
  530. Xo bug fixed in not being able to delete points from certain objects
  531. X
  532. Xo typo in FORMAT2.1 file (and all previous) stating that text angle is int when
  533. X    it is really float
  534. X
  535. Xo can now change corners of compound object with edit popup
  536. X    also shows number of objects inside compound
  537. X
  538. Xo file menu now shows number of objects in figure
  539. X
  540. Xo some bugs fixed in calculating bounding boxes after scaling ellipses and 
  541. X    compounds
  542. X
  543. Xo "#ifdefined SYSV" now reads "#if defined(SYSV) || defined(SVR4)" because X11R5
  544. X    doesn't define SYSV if SVR4 is defined
  545. X    David Elliott (dce@krusty.smsc.Sony.COM)
  546. X    
  547. Xo object depths < 0 are converted to depth = 0
  548. X
  549. Xo typo in Adobe font name (was "-abode-new century schoolbook-medium-r-*--*")
  550. X    Jan Lindheim (lindheim@ccsf.caltech.edu)
  551. X
  552. Xo radius field for non-arcbox line objects now set to -1
  553. X    Jan Nusteling (j.nusteling@et.tudelft.nl)
  554. X
  555. Xo bug fixed in not trying to load an eps bitmap file called <empty>
  556. X    and not trying to reload an eps bitmap during a copy.
  557. X
  558. Xo bug fixed which caused crash after editing 0-width or 0-height ellipses
  559. X
  560. Xo bug fixed which caused incorrect mode after cancelling draw (int)spline
  561. X
  562. Xo bug fixed which caused incorrect minimum number of points for (int)spline
  563. X
  564. Xo bug fixed which caused erroneous large values to occur after box scale of
  565. X    0-width or 0-height objects.  You can no longer box scale such objects
  566. X
  567. X------------------------------------------------------------------------------
  568. XPatchlevel 0
  569. XChanges to Version 2.0 Patchlevel 10:
  570. XImplemented by Paul King (king@cs.uq.oz.au) and
  571. XBrian Smith (envbvs@epb7.lbl.gov) with help from
  572. XMicah Beck (beck@cs.cornell.edu) and
  573. XBrian Boyter (pyrdc!bimbo!boyter@uunet.UU.NET) (EPS code).
  574. X
  575. XUSER INTERFACE
  576. X--------------
  577. X
  578. Xo The buttons are now grouped into three panels:
  579. X
  580. X    COMMAND panel:
  581. X        Quit, Delete all, Undo, Redraw, Paste, File popup, Export popup and 
  582. X        Print popup buttons.  See man pages for details.
  583. X        (see "Drawing Modes", below for description of Cut)
  584. X    MODE panel:
  585. X    Allow the user to select the current drawing or editing mode.
  586. X    INDICATOR panel:
  587. X    By default shows indicator buttons relevant to the current mode.
  588. X    Each indicator button displays current setting of some quantity
  589. X    (e.g. line width, area-fill) and allows it to be changed:
  590. X        left button gives popup menu to select setting,
  591. X        middle/right buttons provide a shortcut to inc/decrement settings.
  592. X
  593. Xo Pan figure by using left/middle/right button in the rulers in addition to
  594. X    the previously supported arrow keys.  Also a pan to origin operation
  595. X    is available by clicking in the units window (or using HOME key).
  596. X
  597. Xo May now print figure that hasn't been saved (i.e. print what is on the 
  598. X    canvas, not the file)
  599. X
  600. Xo Zoom up or down with zoom button.
  601. X
  602. Xo Mouse function window shows function of active buttons
  603. X
  604. Xo New resources/command-line switches which affect the user interface:
  605. X    -showallbuttons        (show all indicator buttons all the time)
  606. X    -internalBW n        (use lines of width n between buttons/panels)
  607. X
  608. XDRAWING MODES
  609. X-------------
  610. X
  611. Xo Regular polygon drawing button - select number of sized from bottom panel.
  612. X        Object created is normal xfig polygon.
  613. X
  614. Xo Inclusion of Encapsulated Postscript files (bitmap image in EPS file is
  615. X    displayed).
  616. X
  617. Xo Rubberbanding of ellipses/circles.
  618. X
  619. Xo Filled splines show areafill on screen now
  620. X        also dashed/dotted line type shows on screen
  621. X
  622. Xo Dot-gap and dash-length can be changed in the line-style indicator popup.
  623. X
  624. XEDITING MODES
  625. X-------------
  626. X
  627. Xo Cut to buffer operation is now part of Copy object mode & Delete object mode.
  628. X
  629. Xo Update button to either update objects to current settings, or update
  630. X        indicator settings from an object.
  631. X
  632. Xo Rotation of certain objects by any angle (30, 45, 60, 90, 120 degrees can
  633. X    be selected using the mouse middle/right shortcut buttons).
  634. X
  635. Xo Alignment horizontally and/or vertically of objects to compound object edge(s)
  636. X
  637. Xo Objects can be scaled (not just compounds).
  638. X
  639. Xo Point move or object copy/move constrainable to horizontal or vertical
  640. X    movement (middle mouse button)
  641. X
  642. Xo Compound bounding corners shrink to fit enclosed objects and have markers
  643. X    that appear the same as other objects.
  644. X
  645. Xo Shift-click selection should work on all editing operations.
  646. X
  647. Xo Only the objects relevant to a particular editing operation will
  648. X    have their markers shown.
  649. X
  650. XOVERALL OPERATION
  651. X-----------------
  652. X
  653. Xo Smarter redrawing (if compiled with -DFASTSERVER).
  654. X    Only the relevant objects are redrawn after an expose or after
  655. X    an edit operation (not all operations support this yet).
  656. X
  657. Xo Undo should work for all commands.
  658. X
  659. Xo Operations can now be cancelled (using the right button when appropriate).
  660. X
  661. Xo Point positioning to three resolutions:
  662. X    magnet (1/16inch), small grid or large grid
  663. X
  664. Xo TransFig 2.1 features: LaTex fonts, hidden text, scalable text, "special" text
  665. X        see TransFig man pages for description
  666. X        scalable text sizes with resizing of figure
  667. X
  668. Xo Attempts to save figure if signal detected (segmentation violation, etc)
  669. X
  670. Xo Resizing the xfig window should now be a bit smarter.
  671. X
  672. Xo The philosophy behind button usage has changed. This was necessary to
  673. X    provide a consistent (as possible) philosophy which supports the
  674. X    use of several buttons per mode.  Now the same button used to start
  675. X    an edit/draw operation is used to continue to the normal next step
  676. X    in the operation.  The right button can be used to cancel an operation.
  677. X    Watch the mouse function window until you get the hang of it.
  678. X
  679. END_OF_FILE
  680. if test 30300 -ne `wc -c <'CHANGES'`; then
  681.     echo shar: \"'CHANGES'\" unpacked with wrong size!
  682. fi
  683. # end of 'CHANGES'
  684. fi
  685. if test -f 'f_read.c' -a "${1}" != "-c" ; then 
  686.   echo shar: Will not clobber existing file \"'f_read.c'\"
  687. else
  688. echo shar: Extracting \"'f_read.c'\" \(28176 characters\)
  689. sed "s/^X//" >'f_read.c' <<'END_OF_FILE'
  690. X/*
  691. X * FIG : Facility for Interactive Generation of figures
  692. X * Copyright (c) 1985 by Supoj Sutanthavibul
  693. X *
  694. X * "Permission to use, copy, modify, distribute, and sell this software and its
  695. X * documentation for any purpose is hereby granted without fee, provided that
  696. X * the above copyright notice appear in all copies and that both the copyright
  697. X * notice and this permission notice appear in supporting documentation. 
  698. X * No representations are made about the suitability of this software for 
  699. X * any purpose.  It is provided "as is" without express or implied warranty."
  700. X */
  701. X
  702. X#include "fig.h"
  703. X#include "figx.h"
  704. X#include "resources.h"
  705. X#include "object.h"
  706. X#include "mode.h"
  707. X#include "u_fonts.h"
  708. X#include "u_create.h"
  709. X#include "version.h"
  710. X#include "w_setup.h"
  711. X#include "w_util.h"
  712. X#include "w_zoom.h"
  713. X
  714. X/* file popup information */
  715. Xextern Widget    file_popup;    /* the popup itself */
  716. Xextern Boolean    file_up;
  717. X
  718. X/* so w_file.c can access */
  719. XBoolean    file_msg_is_popped=False;
  720. XWidget    file_msg_popup;
  721. X
  722. Xstatic Widget    file_msg_panel,
  723. X        file_msg_win, file_msg_dismiss;
  724. Xstatic Boolean    first_file_msg;
  725. Xstatic int    file_msg_length=0;
  726. Xstatic char    *read_file_name;
  727. Xstatic char    tmpstr[100];
  728. X
  729. Xstatic String    file_msg_translations =
  730. X    "<Message>WM_PROTOCOLS: DismissFileMsg()\n";
  731. Xstatic XtEventHandler file_msg_panel_dismiss();
  732. Xstatic XtActionsRec    file_msg_actions[] =
  733. X{
  734. X    {"DismissFileMsg", (XtActionProc) file_msg_panel_dismiss},
  735. X};
  736. X
  737. Xstatic char    Err_incomp[] = "Incomplete %s object at line %d.";
  738. X
  739. Xstatic F_ellipse  *read_ellipseobject();
  740. Xstatic F_line      *read_lineobject();
  741. Xstatic F_text     *read_textobject();
  742. Xstatic F_spline   *read_splineobject();
  743. Xstatic F_arc      *read_arcobject();
  744. Xstatic F_compound *read_compoundobject();
  745. X
  746. X#define        FILL_CONVERT(f) \
  747. X            (((proto>=20) || (f) == UNFILLED || !TFX) \
  748. X                ? (f) : (!TFX? 21 - ((f)-1)*5: 0))
  749. X
  750. X#define        BUF_SIZE        1024
  751. X
  752. XDeclareStaticArgs(10);
  753. Xchar        buf[BUF_SIZE];
  754. Xint        line_no;
  755. Xint        num_object;
  756. Xint        proto;        /* file protocol*10 */
  757. Xint        TFX;        /* true for 1.4TFX protocol */
  758. X
  759. Xread_fail_message(file, err)
  760. X    char       *file;
  761. X    int            err;
  762. X{
  763. X    if (err == 0)        /* Successful read */
  764. X    return;
  765. X#ifdef ENAMETOOLONG
  766. X    else if (err == ENAMETOOLONG)
  767. X    file_msg("File name \"%s\" is too long", file);
  768. X#endif
  769. X    else if (err == ENOENT)
  770. X    file_msg("File \"%s\" does not exist", file);
  771. X    else if (err == ENOTDIR)
  772. X    file_msg("A name in the path \"%s\" is not a directory", file);
  773. X    else if (err == EACCES)
  774. X    file_msg("Read access to file \"%s\" is blocked", file);
  775. X    else if (err == EISDIR)
  776. X    file_msg("File \"%s\" is a directory", file);
  777. X    else if (err == -2) {
  778. X    file_msg("File \"%s\" is empty", file);
  779. X    } else if (err == -1) {
  780. X    /* Format error; relevant error message is already delivered */
  781. X    } else
  782. X    file_msg("File \"%s\" is not accessable; %s", file, sys_errlist[err]);
  783. X}
  784. X
  785. X/**********************************************************
  786. XRead_fig returns :
  787. X
  788. X     0 : successful read.
  789. X    -1 : File is in incorrect format
  790. X    -2 : File is empty
  791. Xerr_no : if file can not be read for various reasons
  792. X
  793. XThe resolution (ppi) and the coordinate system (coord_sys) are
  794. Xstored in obj->nwcorner.x and obj->nwcorner.y respectively.
  795. XThe coordinate system is 1 for lower left at 0,0 and
  796. X2 for upper left at 0,0
  797. X>>> xfig only uses 2 for the coordinate system. <<<
  798. X**********************************************************/
  799. X
  800. Xread_fig(file_name, obj)
  801. X    char       *file_name;
  802. X    F_compound       *obj;
  803. X{
  804. X    FILE       *fp;
  805. X
  806. X    line_no = 0;
  807. X    read_file_name = file_name;
  808. X    first_file_msg = True;
  809. X    if ((fp = fopen(file_name, "r")) == NULL)
  810. X    return (errno);
  811. X    else {
  812. X    put_msg("Reading objects from \"%s\" ...", file_name);
  813. X    return (readfp_fig(fp, obj));
  814. X    }
  815. X}
  816. X
  817. Xreadfp_fig(fp, obj)
  818. X    FILE       *fp;
  819. X    F_compound       *obj;
  820. X{
  821. X    int            status;
  822. X    float        fproto;
  823. X    char        tmpstr[10];
  824. X
  825. X    num_object = 0;
  826. X    bzero(obj, COMOBJ_SIZE);
  827. X    if (fgets(buf, BUF_SIZE, fp) == 0)    /* version */
  828. X    return -2;
  829. X    if (strncmp(buf, "#FIG", 4) == 0) { /* versions 1.4/later have #FIG in
  830. X                     * first line */
  831. X    if ((sscanf((char*)(index(buf, ' ') + 1), "%f", &fproto)) == 0)    /* assume 1.4 */
  832. X        proto = 14;
  833. X    else
  834. X        proto = (fproto + .01) * 10;    /* protocol version*10 */
  835. X    /* if file protocol != current protocol, give message */
  836. X    sprintf(tmpstr,"%.1f",fproto);
  837. X    if (strcmp(tmpstr,PROTOCOL_VERSION) != 0)
  838. X        file_msg("Converting figure from %s format to %s",tmpstr,PROTOCOL_VERSION);
  839. X    TFX = False;
  840. X    if (strstr(buf, "TFX") != NULL)
  841. X        TFX = True;
  842. X    status = read_objects(fp, obj);
  843. X    } else {
  844. X    file_msg("Converting figure from 1.3 format to %s",PROTOCOL_VERSION);
  845. X    proto = 13;
  846. X    status = read_1_3_objects(fp, obj);
  847. X    }
  848. X
  849. X    /* shift the figure on the page if there are negative coords */
  850. X    /**** DISABLE UNTIL WE PUT IN AN *OPTION* TO DO THIS */
  851. X    /* shift_figure(obj); */
  852. X
  853. X    fclose(fp);
  854. X    return (status);
  855. X}
  856. X
  857. Xint
  858. Xread_objects(fp, obj)
  859. X    FILE       *fp;
  860. X    F_compound       *obj;
  861. X{
  862. X    F_ellipse       *e, *le = NULL;
  863. X    F_line       *l, *ll = NULL;
  864. X    F_text       *t, *lt = NULL;
  865. X    F_spline       *s, *ls = NULL;
  866. X    F_arc       *a, *la = NULL;
  867. X    F_compound       *c, *lc = NULL;
  868. X    int            object, ppi, coord_sys;
  869. X
  870. X    line_no++;
  871. X    if (get_line(fp) < 0) {
  872. X    file_msg("File is truncated");
  873. X    return (-1);
  874. X    }
  875. X    if (2 != sscanf(buf, "%d%d\n", &ppi, &coord_sys)) {
  876. X    file_msg("Incomplete data at line %d", line_no);
  877. X    return (-1);
  878. X    }
  879. X    obj->nwcorner.x = ppi;
  880. X    obj->nwcorner.y = coord_sys;
  881. X    while (get_line(fp) > 0) {
  882. X    if (1 != sscanf(buf, "%d", &object)) {
  883. X        file_msg("Incorrect format at line %d", line_no);
  884. X        return (-1);
  885. X    }
  886. X    switch (object) {
  887. X    case O_POLYLINE:
  888. X        if ((l = read_lineobject(fp)) == NULL)
  889. X        return (-1);
  890. X        if (ll)
  891. X        ll = (ll->next = l);
  892. X        else
  893. X        ll = obj->lines = l;
  894. X        num_object++;
  895. X        break;
  896. X    case O_SPLINE:
  897. X        if ((s = read_splineobject(fp)) == NULL)
  898. X        return (-1);
  899. X        if (ls)
  900. X        ls = (ls->next = s);
  901. X        else
  902. X        ls = obj->splines = s;
  903. X        num_object++;
  904. X        break;
  905. X    case O_ELLIPSE:
  906. X        if ((e = read_ellipseobject()) == NULL)
  907. X        return (-1);
  908. X        if (le)
  909. X        le = (le->next = e);
  910. X        else
  911. X        le = obj->ellipses = e;
  912. X        num_object++;
  913. X        break;
  914. X    case O_ARC:
  915. X        if ((a = read_arcobject(fp)) == NULL)
  916. X        return (-1);
  917. X        if (la)
  918. X        la = (la->next = a);
  919. X        else
  920. X        la = obj->arcs = a;
  921. X        num_object++;
  922. X        break;
  923. X    case O_TEXT:
  924. X        if ((t = read_textobject(fp)) == NULL)
  925. X        continue;
  926. X        /*return (-1);*/
  927. X        if (lt)
  928. X        lt = (lt->next = t);
  929. X        else
  930. X        lt = obj->texts = t;
  931. X        num_object++;
  932. X        break;
  933. X    case O_COMPOUND:
  934. X        if ((c = read_compoundobject(fp)) == NULL)
  935. X        return (-1);
  936. X        if (lc)
  937. X        lc = (lc->next = c);
  938. X        else
  939. X        lc = obj->compounds = c;
  940. X        num_object++;
  941. X        break;
  942. X    default:
  943. X        file_msg("Incorrect object code at line %d", line_no);
  944. X        return (-1);
  945. X    }            /* switch */
  946. X    }                /* while */
  947. X    if (feof(fp))
  948. X    return (0);
  949. X    else
  950. X    return (errno);
  951. X}                /* read_objects */
  952. X
  953. Xstatic F_arc   *
  954. Xread_arcobject(fp)
  955. X    FILE       *fp;
  956. X{
  957. X    F_arc       *a;
  958. X    int            n, fa, ba;
  959. X    int            type, style;
  960. X    float        thickness, wid, ht;
  961. X
  962. X    if ((a = create_arc()) == NULL)
  963. X    return (NULL);
  964. X
  965. X    a->next = NULL;
  966. X    a->for_arrow = a->back_arrow = NULL;    /* added 8/23/89 B.V.Smith */
  967. X    n = sscanf(buf, "%*d%d%d%d%d%d%d%d%f%d%d%d%f%f%d%d%d%d%d%d\n",
  968. X           &a->type, &a->style, &a->thickness,
  969. X           &a->color, &a->depth,
  970. X           &a->pen, &a->fill_style,
  971. X           &a->style_val, &a->direction, &fa, &ba,
  972. X           &a->center.x, &a->center.y,
  973. X           &a->point[0].x, &a->point[0].y,
  974. X           &a->point[1].x, &a->point[1].y,
  975. X           &a->point[2].x, &a->point[2].y);
  976. X    if (n != 19) {
  977. X    file_msg(Err_incomp, "arc", line_no);
  978. X    free((char *) a);
  979. X    return (NULL);
  980. X    }
  981. X    a->fill_style = FILL_CONVERT(a->fill_style);
  982. X    fixdepth(&a->depth);
  983. X    skip_comment(fp);
  984. X    if (fa) {
  985. X    line_no++;
  986. X    if (5 != fscanf(fp, "%d%d%f%f%f", &type, &style, &thickness, &wid, &ht)) {
  987. X        fprintf(stderr, Err_incomp, "arc", line_no);
  988. X        return (NULL);
  989. X    }
  990. X    skip_line(fp);
  991. X    a->for_arrow = new_arrow(type, style, thickness, wid, ht);
  992. X    skip_comment(fp);
  993. X    }
  994. X    skip_comment(fp);
  995. X    if (ba) {
  996. X    line_no++;
  997. X    if (5 != fscanf(fp, "%d%d%f%f%f", &type, &style, &thickness, &wid, &ht)) {
  998. X        fprintf(stderr, Err_incomp, "arc", line_no);
  999. X        return (NULL);
  1000. X    }
  1001. X    skip_line(fp);
  1002. X    a->back_arrow = new_arrow(type, style, thickness, wid, ht);
  1003. X    }
  1004. X    return (a);
  1005. X}
  1006. X
  1007. Xstatic F_compound *
  1008. Xread_compoundobject(fp)
  1009. X    FILE       *fp;
  1010. X{
  1011. X    F_arc       *a, *la = NULL;
  1012. X    F_ellipse       *e, *le = NULL;
  1013. X    F_line       *l, *ll = NULL;
  1014. X    F_spline       *s, *ls = NULL;
  1015. X    F_text       *t, *lt = NULL;
  1016. X    F_compound       *com, *c, *lc = NULL;
  1017. X    int            n, object;
  1018. X
  1019. X    if ((com = create_compound()) == NULL)
  1020. X    return (NULL);
  1021. X
  1022. X    com->arcs = NULL;
  1023. X    com->ellipses = NULL;
  1024. X    com->lines = NULL;
  1025. X    com->splines = NULL;
  1026. X    com->texts = NULL;
  1027. X    com->compounds = NULL;
  1028. X    com->next = NULL;
  1029. X    n = sscanf(buf, "%*d%d%d%d%d\n", &com->nwcorner.x, &com->nwcorner.y,
  1030. X           &com->secorner.x, &com->secorner.y);
  1031. X    if (4 != n) {
  1032. X    file_msg(Err_incomp, "compound", line_no);
  1033. X    free((char *) com);
  1034. X    return (NULL);
  1035. X    }
  1036. X    while (get_line(fp) > 0) {
  1037. X    if (1 != sscanf(buf, "%d", &object)) {
  1038. X        file_msg(Err_incomp, "compound", line_no);
  1039. X        free_compound(&com);
  1040. X        return (NULL);
  1041. X    }
  1042. X    switch (object) {
  1043. X    case O_POLYLINE:
  1044. X        if ((l = read_lineobject(fp)) == NULL) {
  1045. X        free_line(&l);
  1046. X        return (NULL);
  1047. X        }
  1048. X        if (ll)
  1049. X        ll = (ll->next = l);
  1050. X        else
  1051. X        ll = com->lines = l;
  1052. X        break;
  1053. X    case O_SPLINE:
  1054. X        if ((s = read_splineobject(fp)) == NULL) {
  1055. X        free_spline(&s);
  1056. X        return (NULL);
  1057. X        }
  1058. X        if (ls)
  1059. X        ls = (ls->next = s);
  1060. X        else
  1061. X        ls = com->splines = s;
  1062. X        break;
  1063. X    case O_ELLIPSE:
  1064. X        if ((e = read_ellipseobject()) == NULL) {
  1065. X        free_ellipse(&e);
  1066. X        return (NULL);
  1067. X        }
  1068. X        if (le)
  1069. X        le = (le->next = e);
  1070. X        else
  1071. X        le = com->ellipses = e;
  1072. X        break;
  1073. X    case O_ARC:
  1074. X        if ((a = read_arcobject(fp)) == NULL) {
  1075. X        free_arc(&a);
  1076. X        return (NULL);
  1077. X        }
  1078. X        if (la)
  1079. X        la = (la->next = a);
  1080. X        else
  1081. X        la = com->arcs = a;
  1082. X        break;
  1083. X    case O_TEXT:
  1084. X        if ((t = read_textobject(fp)) == NULL) {
  1085. X        free_text(&t);
  1086. X        return (NULL);
  1087. X        }
  1088. X        if (lt)
  1089. X        lt = (lt->next = t);
  1090. X        else
  1091. X        lt = com->texts = t;
  1092. X        break;
  1093. X    case O_COMPOUND:
  1094. X        if ((c = read_compoundobject(fp)) == NULL) {
  1095. X        free_compound(&c);
  1096. X        return (NULL);
  1097. X        }
  1098. X        if (lc)
  1099. X        lc = (lc->next = c);
  1100. X        else
  1101. X        lc = com->compounds = c;
  1102. X        break;
  1103. X    case O_END_COMPOUND:
  1104. X        return (com);
  1105. X    default:
  1106. X        file_msg("Incorrect object code at line %d", line_no);
  1107. X        return (NULL);
  1108. X    }            /* switch */
  1109. X    }
  1110. X    if (feof(fp))
  1111. X    return (com);
  1112. X    else
  1113. X    return (NULL);
  1114. X}
  1115. X
  1116. Xstatic F_ellipse *
  1117. Xread_ellipseobject()
  1118. X{
  1119. X    F_ellipse       *e;
  1120. X    int            n;
  1121. X
  1122. X    if ((e = create_ellipse()) == NULL)
  1123. X    return (NULL);
  1124. X
  1125. X    e->next = NULL;
  1126. X    n = sscanf(buf, "%*d%d%d%d%d%d%d%d%f%d%f%d%d%d%d%d%d%d%d\n",
  1127. X           &e->type, &e->style, &e->thickness,
  1128. X           &e->color, &e->depth, &e->pen, &e->fill_style,
  1129. X           &e->style_val, &e->direction, &e->angle,
  1130. X           &e->center.x, &e->center.y,
  1131. X           &e->radiuses.x, &e->radiuses.y,
  1132. X           &e->start.x, &e->start.y,
  1133. X           &e->end.x, &e->end.y);
  1134. X    if (n != 18) {
  1135. X    file_msg(Err_incomp, "ellipse", line_no);
  1136. X    free((char *) e);
  1137. X    return (NULL);
  1138. X    }
  1139. X    e->fill_style = FILL_CONVERT(e->fill_style);
  1140. X    fixdepth(&e->depth);
  1141. X    return (e);
  1142. X}
  1143. X
  1144. Xstatic F_line  *
  1145. Xread_lineobject(fp)
  1146. X    FILE       *fp;
  1147. X{
  1148. X    F_line       *l;
  1149. X    F_point       *p, *q;
  1150. X    int            n, x, y, fa, ba;
  1151. X    int            type, style, radius_flag;
  1152. X    float        thickness, wid, ht;
  1153. X
  1154. X    if ((l = create_line()) == NULL)
  1155. X    return (NULL);
  1156. X
  1157. X    l->points = NULL;
  1158. X    l->for_arrow = l->back_arrow = NULL;
  1159. X    l->next = NULL;
  1160. X
  1161. X    sscanf(buf, "%*d%d", &l->type);
  1162. X
  1163. X    /* 2.1 or later has radius parm for all line objects */
  1164. X    /* 2.0 has radius parm only for arc-box objects */
  1165. X    radius_flag = ((proto >= 21) || (l->type == T_ARC_BOX && proto == 20));
  1166. X    if (radius_flag) {
  1167. X    n = sscanf(buf, "%*d%d%d%d%d%d%d%d%f%d%d%d",
  1168. X           &l->type, &l->style, &l->thickness, &l->color, &l->depth,
  1169. X          &l->pen, &l->fill_style, &l->style_val, &l->radius, &fa, &ba);
  1170. X    } else {            /* old format uses pen for radius of arc-box
  1171. X                 * corners */
  1172. X    n = sscanf(buf, "%*d%d%d%d%d%d%d%d%f%d%d",
  1173. X           &l->type, &l->style, &l->thickness, &l->color,
  1174. X           &l->depth, &l->pen, &l->fill_style, &l->style_val, &fa, &ba);
  1175. X    if (l->type == T_ARC_BOX) {
  1176. X        l->radius = l->pen;
  1177. X        l->pen = 0;
  1178. X    } else
  1179. X        l->radius = 0;
  1180. X    }
  1181. X    if ((!radius_flag && n != 10) || (radius_flag && n != 11)) {
  1182. X    file_msg(Err_incomp, "line", line_no);
  1183. X    free((char *) l);
  1184. X    return (NULL);
  1185. X    }
  1186. X    l->fill_style = FILL_CONVERT(l->fill_style);
  1187. X    fixdepth(&l->depth);
  1188. X    skip_comment(fp);
  1189. X    if (fa) {
  1190. X    line_no++;
  1191. X    if (5 != fscanf(fp, "%d%d%f%f%f", &type, &style, &thickness, &wid, &ht)) {
  1192. X        fprintf(stderr, Err_incomp, "line", line_no);
  1193. X        return (NULL);
  1194. X    }
  1195. X    skip_line(fp);
  1196. X    l->for_arrow = new_arrow(type, style, thickness, wid, ht);
  1197. X    skip_comment(fp);
  1198. X    }
  1199. X    if (ba) {
  1200. X    line_no++;
  1201. X    if (5 != fscanf(fp, "%d%d%f%f%f", &type, &style, &thickness, &wid, &ht)) {
  1202. X        fprintf(stderr, Err_incomp, "line", line_no);
  1203. X        return (NULL);
  1204. X    }
  1205. X    skip_line(fp);
  1206. X    l->back_arrow = new_arrow(type, style, thickness, wid, ht);
  1207. X    skip_comment(fp);
  1208. X    }
  1209. X    if (l->type == T_EPS_BOX) {
  1210. X    line_no++;
  1211. X    if ((l->eps = create_eps()) == NULL) {
  1212. X        free((char *) l);
  1213. X        return (NULL);
  1214. X    }
  1215. X    if (2 != fscanf(fp, "%d %s", &l->eps->flipped, l->eps->file)) {
  1216. X        file_msg(Err_incomp, "Encapsulated Postscript", line_no);
  1217. X        fprintf(stderr, Err_incomp, "Encapsulated Postscript", line_no);
  1218. X        return (NULL);
  1219. X    }
  1220. X    read_epsf(l->eps);
  1221. X    } else
  1222. X    l->eps = NULL;
  1223. X
  1224. X    /* points start on new line */
  1225. X    line_no++;
  1226. X    if ((p = create_point()) == NULL)
  1227. X    return (NULL);
  1228. X
  1229. X    l->points = p;
  1230. X    p->next = NULL;
  1231. X
  1232. X    /* read first point */
  1233. X    if (fscanf(fp, "%d%d", &p->x, &p->y) != 2) {
  1234. X    file_msg(Err_incomp, "line", line_no);
  1235. X    free_linestorage(l);
  1236. X    return (NULL);
  1237. X    }
  1238. X    /* read subsequent points */
  1239. X    for (;;) {
  1240. X    if (fscanf(fp, "%d%d", &x, &y) != 2) {
  1241. X        file_msg(Err_incomp, "line", line_no);
  1242. X        free_linestorage(l);
  1243. X        return (NULL);
  1244. X    }
  1245. X    if (x == 9999)
  1246. X        break;
  1247. X    if ((q = create_point()) == NULL) {
  1248. X        free_linestorage(l);
  1249. X        return (NULL);
  1250. X    }
  1251. X    q->x = x;
  1252. X    q->y = y;
  1253. X    q->next = NULL;
  1254. X    p->next = q;
  1255. X    p = q;
  1256. X    }
  1257. X    skip_line(fp);
  1258. X    return (l);
  1259. X}
  1260. X
  1261. Xstatic F_spline *
  1262. Xread_splineobject(fp)
  1263. X    FILE       *fp;
  1264. X{
  1265. X    F_spline       *s;
  1266. X    F_point       *p, *q;
  1267. X    F_control       *cp, *cq;
  1268. X    int            c, n, x, y, fa, ba;
  1269. X    int            type, style;
  1270. X    float        thickness, wid, ht;
  1271. X    float        lx, ly, rx, ry;
  1272. X
  1273. X    if ((s = create_spline()) == NULL)
  1274. X    return (NULL);
  1275. X
  1276. X    s->points = NULL;
  1277. X    s->controls = NULL;
  1278. X    s->for_arrow = s->back_arrow = NULL;
  1279. X    s->next = NULL;
  1280. X
  1281. X    n = sscanf(buf, "%*d%d%d%d%d%d%d%d%f%d%d%d%d%d%d",
  1282. X           &s->type, &s->style, &s->thickness, &s->color,
  1283. X           &s->depth, &s->pen, &s->fill_style, &s->style_val, &fa, &ba);
  1284. X    if (n != 10) {
  1285. X    file_msg(Err_incomp, "spline", line_no);
  1286. X    free((char *) s);
  1287. X    return (NULL);
  1288. X    }
  1289. X    s->fill_style = FILL_CONVERT(s->fill_style);
  1290. X    fixdepth(&s->depth);
  1291. X    skip_comment(fp);
  1292. X    if (fa) {
  1293. X    line_no++;
  1294. X    if (5 != fscanf(fp, "%d%d%f%f%f", &type, &style, &thickness, &wid, &ht)) {
  1295. X        fprintf(stderr, Err_incomp, "spline", line_no);
  1296. X        return (NULL);
  1297. X    }
  1298. X    skip_line(fp);
  1299. X    s->for_arrow = new_arrow(type, style, thickness, wid, ht);
  1300. X    skip_comment(fp);
  1301. X    }
  1302. X    if (ba) {
  1303. X    line_no++;
  1304. X    if (5 != fscanf(fp, "%d%d%f%f%f", &type, &style, &thickness, &wid, &ht)) {
  1305. X        fprintf(stderr, Err_incomp, "spline", line_no);
  1306. X        return (NULL);
  1307. X    }
  1308. X    skip_line(fp);
  1309. X    s->back_arrow = new_arrow(type, style, thickness, wid, ht);
  1310. X    skip_comment(fp);
  1311. X    }
  1312. X    line_no++;
  1313. X
  1314. X    /* Read points */
  1315. X    if ((n = fscanf(fp, "%d%d", &x, &y)) != 2) {
  1316. X    file_msg(Err_incomp, "spline", line_no);
  1317. X    free_splinestorage(s);
  1318. X    return (NULL);
  1319. X    };
  1320. X    if ((p = create_point()) == NULL) {
  1321. X    free_splinestorage(s);
  1322. X    return (NULL);
  1323. X    }
  1324. X    s->points = p;
  1325. X    p->x = x;
  1326. X    p->y = y;
  1327. X    for (c = 1;;) {
  1328. X    if (fscanf(fp, "%d%d", &x, &y) != 2) {
  1329. X        file_msg(Err_incomp, "spline", line_no);
  1330. X        p->next = NULL;
  1331. X        free_splinestorage(s);
  1332. X        return (NULL);
  1333. X    };
  1334. X    if (x == 9999)
  1335. X        break;
  1336. X    if ((q = create_point()) == NULL) {
  1337. X        free_splinestorage(s);
  1338. X        return (NULL);
  1339. X    }
  1340. X    q->x = x;
  1341. X    q->y = y;
  1342. X    p->next = q;
  1343. X    p = q;
  1344. X    c++;
  1345. X    }
  1346. X    p->next = NULL;
  1347. X    skip_line(fp);
  1348. X
  1349. X    if (normal_spline(s))
  1350. X    return (s);
  1351. X
  1352. X    line_no++;
  1353. X    skip_comment(fp);
  1354. X    /* Read controls */
  1355. X    if ((n = fscanf(fp, "%f%f%f%f", &lx, &ly, &rx, &ry)) != 4) {
  1356. X    file_msg(Err_incomp, "spline", line_no);
  1357. X    free_splinestorage(s);
  1358. X    return (NULL);
  1359. X    };
  1360. X    if ((cp = create_cpoint()) == NULL) {
  1361. X    free_splinestorage(s);
  1362. X    return (NULL);
  1363. X    }
  1364. X    s->controls = cp;
  1365. X    cp->lx = lx;
  1366. X    cp->ly = ly;
  1367. X    cp->rx = rx;
  1368. X    cp->ry = ry;
  1369. X    while (--c) {
  1370. X    if (fscanf(fp, "%f%f%f%f", &lx, &ly, &rx, &ry) != 4) {
  1371. X        file_msg(Err_incomp, "spline", line_no);
  1372. X        cp->next = NULL;
  1373. X        free_splinestorage(s);
  1374. X        return (NULL);
  1375. X    };
  1376. X    if ((cq = create_cpoint()) == NULL) {
  1377. X        cp->next = NULL;
  1378. X        free_splinestorage(s);
  1379. X        return (NULL);
  1380. X    }
  1381. X    cq->lx = lx;
  1382. X    cq->ly = ly;
  1383. X    cq->rx = rx;
  1384. X    cq->ry = ry;
  1385. X    cp->next = cq;
  1386. X    cp = cq;
  1387. X    }
  1388. X    cp->next = NULL;
  1389. X
  1390. X    skip_line(fp);
  1391. X    return (s);
  1392. X}
  1393. X
  1394. Xstatic F_text  *
  1395. Xread_textobject(fp)
  1396. X    FILE       *fp;
  1397. X{
  1398. X    F_text       *t;
  1399. X    int            n;
  1400. X    int            ignore = 0;
  1401. X    char        s[BUF_SIZE], s_temp[BUF_SIZE], junk[2];
  1402. X    float        tx_size, tx_height, tx_length;
  1403. X    extern PIX_ROT_FONT lookfont();
  1404. X
  1405. X    if ((t = create_text()) == NULL)
  1406. X    return (NULL);
  1407. X
  1408. X    t->next = NULL;
  1409. X    /*
  1410. X     * The text object is terminated by a CONTROL-A, so we read everything up
  1411. X     * to the CONTROL-A and then read that character. If we do not find the
  1412. X     * CONTROL-A on this line then this must be a multi-line text object and
  1413. X     * we will have to read more.
  1414. X     * 
  1415. X     * We read text size, height and length as floats because TransFig uses
  1416. X     * floats for these, but they are rounded to ints internally to xfig.
  1417. X     */
  1418. X    /* read the leading blanks for the string, but delete the first later */
  1419. X    n = sscanf(buf, "%*d%d%d%f%d%d%d%f%d%f%f%d%d%[^\1]%[\1]",
  1420. X           &t->type, &t->font, &tx_size, &t->pen,
  1421. X           &t->color, &t->depth, &t->angle,
  1422. X           &t->flags, &tx_height, &tx_length,
  1423. X           &t->base_x, &t->base_y, s, junk);
  1424. X    if (n != 13 && n != 14) {
  1425. X    file_msg(Err_incomp, "text", line_no);
  1426. X    free((char *) t);
  1427. X    return (NULL);
  1428. X    }
  1429. X    /* now round size, height and length to int */
  1430. X    if ((int) tx_size == DEFAULT)    /* just copy DEFAULT */
  1431. X    t->size = DEFAULT;
  1432. X    else
  1433. X    t->size = round(tx_size);
  1434. X    while (t->angle < 0.0)
  1435. X    t->angle += M_2PI;
  1436. X    while (t->angle > M_2PI)
  1437. X    t->angle -= M_2PI;
  1438. X    /* get the font struct */
  1439. X    t->fontstruct = lookfont(x_fontnum(t->flags, t->font), 
  1440. X            round(t->size*zoomscale), t->angle);  
  1441. X    t->height = round(tx_height);
  1442. X    t->length = round(tx_length);
  1443. X    fixdepth(&t->depth);
  1444. X    if (n == 13) {
  1445. X    /* Read in the remainder of the text object. */
  1446. X    do {
  1447. X        /*
  1448. X         * khc 06JUL90 - test for end-of-file or else hangs in loop if no
  1449. X         * ^A is found
  1450. X         */
  1451. X        if (fgets(buf, BUF_SIZE, fp) == NULL)
  1452. X        break;
  1453. X        line_no++;        /* As is done in get_line */
  1454. X        n = sscanf(buf, "%[^\1]%[\1]", s_temp, junk);
  1455. X        /* Safety check */
  1456. X        if (strlen(s) + 1 + strlen(s_temp) + 1 > BUF_SIZE) {
  1457. X        /* Too many characters.     Ignore the rest. */
  1458. X        if (!ignore)
  1459. X            file_msg("Truncating TEXT object to %d chars in line %d",
  1460. X                BUF_SIZE,line_no);
  1461. X        ignore = 1;
  1462. X        }
  1463. X        if (!ignore)
  1464. X        strcat(s, s_temp);
  1465. X    } while (n == 1);
  1466. X    }
  1467. X    if (t->type > T_RIGHT_JUSTIFIED) {
  1468. X    file_msg("Invalid text justification at line %d, setting to LEFT.", line_no);
  1469. X    t->type = T_LEFT_JUSTIFIED;
  1470. X    }
  1471. X
  1472. X    /* convert all pre-2.1 NON-TFX text flags (used to be font_style) to PostScript
  1473. X       and all pre-2.1 TFX flags to PostScript + Special */
  1474. X    if (proto <= 20)
  1475. X    {
  1476. X    t->flags = PSFONT_TEXT;
  1477. X    if (TFX)
  1478. X        t->flags |= SPECIAL_TEXT;
  1479. X    }
  1480. X
  1481. X    if (t->font >= MAXFONT(t)) {
  1482. X    file_msg("Invalid text font (%d) at line %d, setting to DEFAULT.",
  1483. X        t->font, line_no);
  1484. X    t->font = DEFAULT;
  1485. X    }
  1486. X    if (strlen(s) <= 1)
  1487. X    {
  1488. X    file_msg("Empty text string at line %d", line_no);
  1489. X    return (NULL);
  1490. X    }
  1491. X    /* skip first blank from input file by starting at s[1] */
  1492. X    if ((t->cstring = new_string(strlen(&s[1]) + 1)) == NULL) {
  1493. X    free((char *) t);
  1494. X    return (NULL);
  1495. X    }
  1496. X    (void) strcpy(t->cstring, &s[1]);
  1497. X
  1498. X    return (t);
  1499. X}
  1500. X
  1501. Xget_line(fp)
  1502. X    FILE       *fp;
  1503. X{
  1504. X    while (1) {
  1505. X    if (NULL == fgets(buf, BUF_SIZE, fp)) {
  1506. X        return (-1);
  1507. X    }
  1508. X    line_no++;
  1509. X    if (*buf != '\n' && *buf != '#')    /* Skip empty and comment
  1510. X                         * lines */
  1511. X        return (1);
  1512. X    }
  1513. X}
  1514. X
  1515. Xskip_comment(fp)
  1516. X    FILE       *fp;
  1517. X{
  1518. X    char        c;
  1519. X
  1520. X    while ((c = fgetc(fp)) == '#')
  1521. X    skip_line(fp);
  1522. X    if (c != '#')
  1523. X    ungetc(c, fp);
  1524. X}
  1525. X
  1526. Xskip_line(fp)
  1527. X    FILE       *fp;
  1528. X{
  1529. X    while (fgetc(fp) != '\n') {
  1530. X    if (feof(fp))
  1531. X        return;
  1532. X    }
  1533. X}
  1534. X
  1535. Xfixdepth(depth) 
  1536. X    int          *depth;
  1537. X{
  1538. X    if (*depth>MAXDEPTH) {
  1539. X        *depth=MAXDEPTH; 
  1540. X        file_msg("Depth > %d, setting to %d in line %d", 
  1541. X            MAXDEPTH,line_no,MAXDEPTH); 
  1542. X    } 
  1543. X    else if (*depth<0 || proto<21) { 
  1544. X        *depth=0; 
  1545. X        if (proto>=21) 
  1546. X        file_msg("Depth < 0, setting to 0 in line %d", line_no); 
  1547. X    }
  1548. X}
  1549. X
  1550. Xshift_figure(obj)
  1551. XF_compound       *obj;
  1552. X{
  1553. X    F_ellipse       *e;
  1554. X    F_arc       *a;
  1555. X    F_line       *l;
  1556. X    F_spline       *s;
  1557. X    F_compound       *c;
  1558. X    F_text       *t;
  1559. X    int            lowx,lowy,dx,dy;
  1560. X    int            llx,lly,urx,ury;
  1561. X    int            rnd;
  1562. X
  1563. X    lowx = 10000;
  1564. X    lowy = 10000;
  1565. X    for (e = obj->ellipses; e != NULL; e = e->next) {
  1566. X    ellipse_bound(e, &llx, &lly, &urx, &ury);
  1567. X    lowx = min2(llx,lowx);
  1568. X    lowy = min2(lly,lowy);
  1569. X    }
  1570. X    for (a = obj->arcs; a != NULL; a = a->next) {
  1571. X    arc_bound(a, &llx, &lly, &urx, &ury);
  1572. X    lowx = min2(llx,lowx);
  1573. X    lowy = min2(lly,lowy);
  1574. X    }
  1575. X    for (l = obj->lines; l != NULL; l = l->next) {
  1576. X    line_bound(l, &llx, &lly, &urx, &ury);
  1577. X    lowx = min2(llx,lowx);
  1578. X    lowy = min2(lly,lowy);
  1579. X    }
  1580. X    for (s = obj->splines; s != NULL; s = s->next) {
  1581. X    spline_bound(s, &llx, &lly, &urx, &ury);
  1582. X    lowx = min2(llx,lowx);
  1583. X    lowy = min2(lly,lowy);
  1584. X    }
  1585. X    for (c = obj->compounds; c != NULL; c = c->next) {
  1586. X    compound_bound(c, &llx, &lly, &urx, &ury);
  1587. X    lowx = min2(llx,lowx);
  1588. X    lowy = min2(lly,lowy);
  1589. X    }
  1590. X    for (t = obj->texts; t != NULL; t = t->next) {
  1591. X    int   dum;
  1592. X    text_bound_actual(t, t->angle, &llx, &lly, &urx, &ury, 
  1593. X              &dum,&dum,&dum,&dum,&dum,&dum,&dum,&dum);
  1594. X    lowx = min2(llx,lowx);
  1595. X    lowy = min2(lly,lowy);
  1596. X    }
  1597. X    /* check if any part of the figure has negative coords */
  1598. X    if (lowx >= 0 && lowy >= 0)
  1599. X    return;                /* no, ok */
  1600. X
  1601. X    /* shift the whole figure to keep it "on the page" */
  1602. X    dx = dy = 0;
  1603. X    rnd = posn_rnd[cur_pointposn];
  1604. X    if (lowx < 0)
  1605. X    {
  1606. X    dx = -lowx+rnd;    /* and round up to small grid */
  1607. X    if (rnd != 0)
  1608. X        dx--;
  1609. X    }
  1610. X    if (lowy < 0)
  1611. X    {
  1612. X    dy = -lowy+rnd;
  1613. X    if (rnd != 0)
  1614. X        dy--;
  1615. X    }
  1616. X    file_msg(
  1617. X    "Shifting entire figure %d pixels right and %d pixels down to keep on page",
  1618. X    dx,dy);
  1619. X    for (e = obj->ellipses; e != NULL; e = e->next)
  1620. X    translate_ellipse(e, dx, dy);
  1621. X    for (a = obj->arcs; a != NULL; a = a->next)
  1622. X    translate_arc(a, dx, dy);
  1623. X    for (l = obj->lines; l != NULL; l = l->next)
  1624. X    translate_line(l, dx, dy);
  1625. X    for (s = obj->splines; s != NULL; s = s->next)
  1626. X    translate_spline(s, dx, dy);
  1627. X    for (c = obj->compounds; c != NULL; c = c->next)
  1628. X    translate_compound(c, dx, dy);
  1629. X    for (t = obj->texts; t != NULL; t = t->next)
  1630. X    translate_text(t, dx, dy);
  1631. X}
  1632. X
  1633. X/* VARARGS1 */
  1634. Xfile_msg(format, arg1, arg2, arg3, arg4, arg5)
  1635. X    char       *format;
  1636. X    int            arg1, arg2, arg3, arg4, arg5;
  1637. X{
  1638. X    XawTextBlock block;
  1639. X    popup_file_msg();
  1640. X    if (first_file_msg)
  1641. X    {
  1642. X    first_file_msg = False;
  1643. X    file_msg("---------------------");
  1644. X    file_msg("File %s:",read_file_name);
  1645. X    }
  1646. X    sprintf(tmpstr, format, arg1, arg2, arg3, arg4, arg5);
  1647. X    strcat(tmpstr,"\n");
  1648. X    /* append this message to the file message widget string */
  1649. X    block.firstPos = 0;
  1650. X    block.ptr = tmpstr;
  1651. X    block.length = strlen(tmpstr);
  1652. X    block.format = FMT8BIT;
  1653. X    /* make editable to add new message */
  1654. X    FirstArg(XtNeditType, XawtextEdit);
  1655. X    SetValues(file_msg_win);
  1656. X    /* insert the new message after the end */
  1657. X    (void) XawTextReplace(file_msg_win,file_msg_length,file_msg_length,&block);
  1658. X    (void) XawTextSetInsertionPoint(file_msg_win,file_msg_length);
  1659. X
  1660. X    /* make read-only again */
  1661. X    FirstArg(XtNeditType, XawtextRead);
  1662. X    SetValues(file_msg_win);
  1663. X    file_msg_length += block.length;
  1664. X}
  1665. X
  1666. Xclear_file_message(w, ev)
  1667. X    Widget        w;
  1668. X    XButtonEvent   *ev;
  1669. X{
  1670. X    XawTextBlock    block;
  1671. X    int            replcode;
  1672. X
  1673. X    if (!file_msg_popup)
  1674. X    return;
  1675. X
  1676. X    tmpstr[0]=' ';
  1677. X    block.firstPos = 0;
  1678. X    block.ptr = tmpstr;
  1679. X    block.length = 1;
  1680. X    block.format = FMT8BIT;
  1681. X
  1682. X    /* make editable to clear message */
  1683. X    FirstArg(XtNeditType, XawtextEdit);
  1684. X    NextArg(XtNdisplayPosition, 0);
  1685. X    SetValues(file_msg_win);
  1686. X
  1687. X    /* replace all messages with one blank */
  1688. X    replcode = XawTextReplace(file_msg_win,0,file_msg_length,&block);
  1689. X    if (replcode == XawPositionError)
  1690. X    fprintf(stderr,"XawTextReplace XawPositionError\n");
  1691. X    else if (replcode == XawEditError)
  1692. X    fprintf(stderr,"XawTextReplace XawEditError\n");
  1693. X
  1694. X    /* make read-only again */
  1695. X    FirstArg(XtNeditType, XawtextRead);
  1696. X    SetValues(file_msg_win);
  1697. X    file_msg_length = 0;
  1698. X}
  1699. X
  1700. Xstatic Bool grabbed=False;
  1701. X
  1702. Xstatic
  1703. XXtEventHandler
  1704. Xfile_msg_panel_dismiss(w, ev)
  1705. X    Widget        w;
  1706. X    XButtonEvent   *ev;
  1707. X{
  1708. X    if ((grabbed) && (!file_up))
  1709. X        XtAddGrab(file_msg_popup, False, False);
  1710. X    XtPopdown(file_msg_popup);
  1711. X    file_msg_is_popped=False;
  1712. X}
  1713. X
  1714. Xpopup_file_msg()
  1715. X{
  1716. X    extern Atom wm_delete_window;
  1717. X
  1718. X    if (file_msg_popup)
  1719. X        {
  1720. X        if (!file_msg_is_popped)
  1721. X            {
  1722. X            if (file_up)
  1723. X                {
  1724. X                XtPopup(file_msg_popup, XtGrabNonexclusive);
  1725. X                    XSetWMProtocols(XtDisplay(file_msg_popup), 
  1726. X                        XtWindow(file_msg_popup),
  1727. X                               &wm_delete_window, 1);
  1728. X                grabbed = True;
  1729. X                }
  1730. X            else
  1731. X                {
  1732. X                XtPopup(file_msg_popup, XtGrabNone);
  1733. X                    XSetWMProtocols(XtDisplay(file_msg_popup), 
  1734. X                        XtWindow(file_msg_popup),
  1735. X                               &wm_delete_window, 1);
  1736. X                grabbed = False;
  1737. X                }
  1738. X            }
  1739. X        file_msg_is_popped = True;
  1740. X        return;
  1741. X        }
  1742. X
  1743. X    file_msg_is_popped = True;
  1744. X    FirstArg(XtNx, 0);
  1745. X    NextArg(XtNy, 0);
  1746. X    NextArg(XtNtitle, "Xfig: File error messages");
  1747. X    file_msg_popup = XtCreatePopupShell("xfig_file_msg",
  1748. X                    transientShellWidgetClass,
  1749. X                    tool, Args, ArgCount);
  1750. X    XtOverrideTranslations(file_msg_popup,
  1751. X            XtParseTranslationTable(file_msg_translations));
  1752. X    XtAppAddActions(tool_app, file_msg_actions, XtNumber(file_msg_actions));
  1753. X
  1754. X    file_msg_panel = XtCreateManagedWidget("file_msg_panel", formWidgetClass,
  1755. X                       file_msg_popup, NULL, ZERO);
  1756. X    FirstArg(XtNwidth, 500);
  1757. X    NextArg(XtNheight, 200);
  1758. X    NextArg(XtNeditType, XawtextRead);
  1759. X    NextArg(XtNdisplayCaret, False);
  1760. X    NextArg(XtNborderWidth, INTERNAL_BW);
  1761. X    NextArg(XtNscrollHorizontal, XawtextScrollWhenNeeded);
  1762. X    NextArg(XtNscrollVertical, XawtextScrollAlways);
  1763. X    file_msg_win = XtCreateManagedWidget("file_msg_win", asciiTextWidgetClass,
  1764. X                         file_msg_panel, Args, ArgCount);
  1765. X
  1766. X    FirstArg(XtNlabel, "Dismiss");
  1767. X    NextArg(XtNheight, 25);
  1768. X    NextArg(XtNborderWidth, INTERNAL_BW);
  1769. X    NextArg(XtNfromVert, file_msg_win);
  1770. X    file_msg_dismiss = XtCreateManagedWidget("dismiss", commandWidgetClass,
  1771. X                       file_msg_panel, Args, ArgCount);
  1772. X    XtAddEventHandler(file_msg_dismiss, ButtonReleaseMask, (Boolean) 0,
  1773. X              (XtEventHandler)file_msg_panel_dismiss, (XtPointer) NULL);
  1774. X
  1775. X    FirstArg(XtNlabel, "Clear");
  1776. X    NextArg(XtNheight, 25);
  1777. X    NextArg(XtNborderWidth, INTERNAL_BW);
  1778. X    NextArg(XtNfromVert, file_msg_win);
  1779. X    NextArg(XtNfromHoriz, file_msg_dismiss);
  1780. X    file_msg_dismiss = XtCreateManagedWidget("clear", commandWidgetClass,
  1781. X                       file_msg_panel, Args, ArgCount);
  1782. X    XtAddEventHandler(file_msg_dismiss, ButtonReleaseMask, (Boolean) 0,
  1783. X              (XtEventHandler)clear_file_message, (XtPointer) NULL);
  1784. X
  1785. X    if (file_up)
  1786. X        {
  1787. X        XtPopup(file_msg_popup, XtGrabNonexclusive);
  1788. X            XSetWMProtocols(XtDisplay(file_msg_popup), 
  1789. X                XtWindow(file_msg_popup),
  1790. X                       &wm_delete_window, 1);
  1791. X        grabbed = True;
  1792. X        }
  1793. X    else
  1794. X        {
  1795. X        XtPopup(file_msg_popup, XtGrabNone);
  1796. X            XSetWMProtocols(XtDisplay(file_msg_popup), 
  1797. X                XtWindow(file_msg_popup),
  1798. X                       &wm_delete_window, 1);
  1799. X        grabbed = False;
  1800. X        }
  1801. X}
  1802. END_OF_FILE
  1803. if test 28176 -ne `wc -c <'f_read.c'`; then
  1804.     echo shar: \"'f_read.c'\" unpacked with wrong size!
  1805. fi
  1806. # end of 'f_read.c'
  1807. fi
  1808. echo shar: End of archive 17 \(of 27\).
  1809. cp /dev/null ark17isdone
  1810. MISSING=""
  1811. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 ; do
  1812.     if test ! -f ark${I}isdone ; then
  1813.     MISSING="${MISSING} ${I}"
  1814.     fi
  1815. done
  1816. if test "${MISSING}" = "" ; then
  1817.     echo You have unpacked all 27 archives.
  1818.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1819. else
  1820.     echo You still need to unpack the following archives:
  1821.     echo "        " ${MISSING}
  1822. fi
  1823. ##  End of shell archive.
  1824. exit 0
  1825.  
  1826. exit 0 # Just in case...
  1827. -- 
  1828.   // chris@IMD.Sterling.COM       | Send comp.sources.x submissions to:
  1829. \X/  Amiga - The only way to fly! |    sources-x@imd.sterling.com
  1830.  "It's intuitively obvious to the |
  1831.   most casual observer..."        | GCS d+/-- p+ c++ l+ m+ s++/+ g+ w+ t+ r+ x+
  1832.