[comp.sources.x] v06i016: xfig, Part08/15

argv%turnpike@Sun.COM (Dan Heller) (03/06/90)

Submitted-by: Brian Smith <bvsmith@lbl.gov>
Posting-number: Volume 6, Issue 16
Archive-name: xfig2/part08



#! /bin/sh
# This is a shell archive.  Remove anything before this line, then feed it
# into a shell via "sh file" or similar.  To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to comp-sources-unix@uunet.uu.net if you want that tool.
# If this archive is complete, you will see the following message at the end:
#		"End of archive 8 (of 15)."
# Contents:  xfig/Makefile xfig/canvas.c xfig/f2p.c xfig/rotate.c
#   xfig/xtra.c
# Wrapped by argv@turnpike on Wed Feb 28 10:53:20 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'xfig/Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/Makefile'\"
else
echo shar: Extracting \"'xfig/Makefile'\" \(11372 characters\)
sed "s/^X//" >'xfig/Makefile' <<'END_OF_FILE'
X# Makefile generated by imake - do not edit!
X# $XConsortium: imake.c,v 1.51 89/12/12 12:37:30 jim Exp $
X
X###########################################################################
X# Makefile generated from "Imake.tmpl" and <Imakefile>
X# $XConsortium: Imake.tmpl,v 1.77 89/12/18 17:01:37 jim Exp $
X#
X# Platform-specific parameters may be set in the appropriate .cf
X# configuration files.  Site-wide parameters may be set in the file
X# site.def.  Full rebuilds are recommended if any parameters are changed.
X#
X# If your C preprocessor doesn't define any unique symbols, you'll need
X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
X# "make Makefile", "make Makefiles", or "make World").
X#
X# If you absolutely can't get imake to work, you'll need to set the
X# variables at the top of each Makefile as well as the dependencies at the
X# bottom (makedepend will do this automatically).
X#
X
X###########################################################################
X# platform-specific configuration parameters - edit ultrix.cf to change
X
X# platform:  $XConsortium: ultrix.cf,v 1.20 89/12/22 15:56:14 rws Exp $
X# operating system:             Ultrix-32 3.1
X
X###########################################################################
X# site-specific configuration parameters - edit site.def to change
X
X# site:  $XConsortium: site.def,v 1.21 89/12/06 11:46:50 jim Exp $
X
X            SHELL = 	/bin/sh
X
X              TOP = ../../../mit
X      CURRENT_DIR = .
X
X               AR = ar cq
X  BOOTSTRAPCFLAGS =
X               CC = gcc -DNOSTDHDRS -fwritable-strings -fstrength-reduce -fpcc-struct-return  -Dultrix
X
X         COMPRESS = compress
X              CPP = /lib/cpp $(STD_CPP_DEFINES)
X    PREPROCESSCMD = gcc -DNOSTDHDRS -fwritable-strings -fstrength-reduce -fpcc-struct-return  -Dultrix -E $(STD_CPP_DEFINES)
X          INSTALL = install
X               LD = ld
X             LINT = lint
X      LINTLIBFLAG = -C
X         LINTOPTS = -axz
X               LN = ln -s
X             MAKE = make
X               MV = mv
X               CP = cp
X           RANLIB = ranlib
X  RANLIBINSTFLAGS =
X               RM = rm -f
X     STD_INCLUDES =
X  STD_CPP_DEFINES =
X      STD_DEFINES =
X EXTRA_LOAD_FLAGS =
X  EXTRA_LIBRARIES =
X             TAGS = ctags
X
X    PROTO_DEFINES =
X
X     INSTPGMFLAGS =
X
X     INSTBINFLAGS = -m 0755
X     INSTUIDFLAGS = -m 4755
X     INSTLIBFLAGS = -m 0664
X     INSTINCFLAGS = -m 0444
X     INSTMANFLAGS = -m 0444
X     INSTDATFLAGS = -m 0444
X    INSTKMEMFLAGS = -m 4755
X
X          DESTDIR =
X
X     TOP_INCLUDES = -I$(TOP)
X
X      CDEBUGFLAGS = -O
X        CCOPTIONS =
X      COMPATFLAGS = -DXAW_BC
X
X      ALLINCLUDES = $(STD_INCLUDES) $(TOP_INCLUDES) $(INCLUDES) $(EXTRA_INCLUDES)
X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(DEFINES) $(COMPATFLAGS)
X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS)
X   LDCOMBINEFLAGS = -X -r
X
X        MACROFILE = ultrix.cf
X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
X
X    IMAKE_DEFINES =
X
X         IRULESRC = $(CONFIGSRC)
X        IMAKE_CMD = $(NEWTOP)$(IMAKE) -I$(NEWTOP)$(IRULESRC) $(IMAKE_DEFINES)
X
X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
X			$(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
X			$(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
X
X###########################################################################
X# X Window System Build Parameters
X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
X
X###########################################################################
X# X Window System make variables; this need to be coordinated with rules
X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
X
X          PATHSEP = /
X        USRLIBDIR = $(DESTDIR)/usr/lib
X           BINDIR = $(DESTDIR)/usr/bin/X11
X          INCROOT = $(DESTDIR)/usr/include
X     BUILDINCROOT = $(TOP)
X      BUILDINCDIR = $(BUILDINCROOT)/X11
X      BUILDINCTOP = ..
X           INCDIR = $(INCROOT)/X11
X           ADMDIR = $(DESTDIR)/usr/adm
X           LIBDIR = $(USRLIBDIR)/X11
X        CONFIGDIR = $(LIBDIR)/config
X       LINTLIBDIR = $(USRLIBDIR)/lint
X
X          FONTDIR = $(LIBDIR)/fonts
X         XINITDIR = $(LIBDIR)/xinit
X           XDMDIR = $(LIBDIR)/xdm
X           AWMDIR = $(LIBDIR)/awm
X           TWMDIR = $(LIBDIR)/twm
X           GWMDIR = $(LIBDIR)/gwm
X          MANPATH = $(DESTDIR)/usr/man
X    MANSOURCEPATH = $(MANPATH)/man
X           MANDIR = $(MANSOURCEPATH)n
X        LIBMANDIR = $(MANSOURCEPATH)3
X      XAPPLOADDIR = $(LIBDIR)/app-defaults
X
X       FONTCFLAGS = -t
X
X     INSTAPPFLAGS = $(INSTDATFLAGS)
X
X            IMAKE = $(IMAKESRC)/imake
X           DEPEND = $(DEPENDSRC)/makedepend
X              RGB = $(RGBSRC)/rgb
X            FONTC = $(BDFTOSNFSRC)/bdftosnf
X        MKFONTDIR = $(MKFONTDIRSRC)/mkfontdir
X        MKDIRHIER = 	/bin/sh $(SCRIPTSRC)/mkdirhier.sh
X
X        CONFIGSRC = $(TOP)/config
X        CLIENTSRC = $(TOP)/clients
X          DEMOSRC = $(TOP)/demos
X           LIBSRC = $(TOP)/lib
X          FONTSRC = $(TOP)/fonts
X       INCLUDESRC = $(TOP)/X11
X        SERVERSRC = $(TOP)/server
X          UTILSRC = $(TOP)/util
X        SCRIPTSRC = $(UTILSRC)/scripts
X       EXAMPLESRC = $(TOP)/examples
X       CONTRIBSRC = $(TOP)/../contrib
X           DOCSRC = $(TOP)/doc
X           RGBSRC = $(TOP)/rgb
X        DEPENDSRC = $(UTILSRC)/makedepend
X         IMAKESRC = $(CONFIGSRC)
X         XAUTHSRC = $(LIBSRC)/Xau
X          XLIBSRC = $(LIBSRC)/X
X           XMUSRC = $(LIBSRC)/Xmu
X       TOOLKITSRC = $(LIBSRC)/Xt
X       AWIDGETSRC = $(LIBSRC)/Xaw
X       OLDXLIBSRC = $(LIBSRC)/oldX
X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
X     MKFONTDIRSRC = $(FONTSRC)/mkfontdir
X     EXTENSIONSRC = $(TOP)/extensions
X
X  DEPEXTENSIONLIB =  $(EXTENSIONSRC)/lib/libXext.a
X     EXTENSIONLIB = 			   $(DEPEXTENSIONLIB)
X
X          DEPXLIB = $(DEPEXTENSIONLIB) $(XLIBSRC)/libX11.a
X             XLIB = $(EXTENSIONLIB)       $(XLIBSRC)/libX11.a
X
X      DEPXAUTHLIB =  $(XAUTHSRC)/libXau.a
X         XAUTHLIB = 			  $(DEPXAUTHLIB)
X
X        DEPXMULIB =  $(XMUSRC)/libXmu.a
X           XMULIB = 			  $(DEPXMULIB)
X
X       DEPOLDXLIB =  $(OLDXLIBSRC)/liboldX.a
X          OLDXLIB = 			  $(DEPOLDXLIB)
X
X      DEPXTOOLLIB =  $(TOOLKITSRC)/libXt.a
X         XTOOLLIB = 			  $(DEPXTOOLLIB)
X
X        DEPXAWLIB =  $(AWIDGETSRC)/libXaw.a
X           XAWLIB = 			  $(DEPXAWLIB)
X
X LINTEXTENSIONLIB =  $(EXTENSIONSRC)/lib/llib-lXext.ln
X         LINTXLIB =  $(XLIBSRC)/llib-lX11.ln
X          LINTXMU =  $(XMUSRC)/llib-lXmu.ln
X        LINTXTOOL =  $(TOOLKITSRC)/llib-lXt.ln
X          LINTXAW =  $(AWIDGETSRC)/llib-lXaw.ln
X
X        XWLIBSRC = $(CONTRIBSRC)/toolkits/Xw
X        DEPXWLIB =  $(XWLIBSRC)/libXw.a
X        XWLIB = 			  $(DEPXWLIB)
X
X          DEPLIBS = $(LOCAL_LIBRARIES)
X
X         DEPLIBS1 = $(DEPLIBS)
X         DEPLIBS2 = $(DEPLIBS)
X         DEPLIBS3 = $(DEPLIBS)
X
X###########################################################################
X# Imake rules for building libraries, programs, scripts, and data files
X# rules:  $XConsortium: Imake.rules,v 1.67 89/12/18 17:14:15 jim Exp $
X
X###########################################################################
X# start of Imakefile
X
XSYS_LIBRARIES = -lm
XSYSAUX_LIBRARIES = -lXaw -lXmu -lXt -lX11
XDEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
XLOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
X
XSRCS=   addpt.c arc.c arcbox.c arrow.c autoarrow.c\
X        bitmap.c blink.c bound.c box.c break.c\
X        canvas.c changestyle.o changetext.o changethick.c \
X        char.c color.c copy.c cursor.c curve.c\
X        deletept.c dir.c drag.c draw.c ellipse.c\
X        file.c flip.c font.c free.c\
X        geom.c global.c glue.c graphics.c grid.c\
X        intspline.c latex_line.c line.c list.c\
X        main.c move.c movept.c msgsw.c\
X        panel.c popup.c print.c printfonts.c psbits.c psfonts.c puterr.c\
X        read.c read1_3.c redisplay.c remove.c rotate.c ruler.c\
X        save.c scale.c search.c spline.c\
X        text.c trans.c turn.c undo.c util.c xtra.c
X
XOBJS=   addpt.o arc.o arcbox.o arrow.o autoarrow.o\
X        bitmap.o blink.o bound.o box.o break.o\
X        canvas.o changestyle.o changetext.o changethick.o \
X        char.o color.o copy.o cursor.o curve.o\
X        deletept.o dir.o drag.o draw.o ellipse.o\
X        file.o flip.o font.o free.o\
X        geom.o global.o glue.o graphics.o grid.o\
X        intspline.o latex_line.o line.o list.o\
X        main.o move.o movept.o msgsw.o\
X        panel.o popup.o print.o printfonts.o psbits.o psfonts.o puterr.o\
X        read.o read1_3.o redisplay.o remove.o rotate.o ruler.o\
X        save.o scale.o search.o spline.o\
X        text.o trans.o turn.o undo.o util.o xtra.o
X
XF2PSRC =        arrow.c f2p.c free.c read.c
XF2POBJ =        arrow.o f2p.o free.o read.o
X
XF2PSSRC =       arrow.c bound.c f2ps.c free.c read.c psfonts.c
XF2PSOBJ =       arrow.o bound.o f2ps.o free.o read.o psfonts.o
X
X        PROGRAM = xfig
X
Xall:: xfig
X
Xxfig: $(OBJS) $(DEPLIBS)
X	 $(RM) $@
X	$(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS)
X
Xsaber_xfig:
X	#load $(ALLDEFINES) $(SRCS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
X
Xosaber_xfig:
X	#load $(ALLDEFINES) $(OBJS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
X
Xinstall:: xfig
X	$(INSTALL) -c $(INSTPGMFLAGS)   xfig $(BINDIR)
X
Xinstall.man:: xfig.man
X	$(INSTALL) -c $(INSTMANFLAGS) xfig.man $(MANDIR)/xfig.n
X
Xdepend:: $(DEPEND)
X
X$(DEPEND):
X	@echo "checking $@ over in $(DEPENDSRC) first..."; \
X	cd $(DEPENDSRC); $(MAKE); \
X	echo "okay, continuing in $(CURRENT_DIR)"
X
Xdepend::
X	$(DEPEND) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
X
Xlint:
X	$(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
Xlint1:
X	$(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
X
Xclean::
X	$(RM) $(PROGRAM)
X
Xf2p: $(F2POBJ)
X	 $(RM) $@
X	$(CC) -o $@ $(F2POBJ) $(LDOPTIONS)  $(LDLIBS)  $(EXTRA_LOAD_FLAGS)
X
Xclean::
X	$(RM) f2p
X
Xf2ps: $(F2PSOBJ)
X	 $(RM) $@
X	$(CC) -o $@ $(F2PSOBJ) $(LDOPTIONS)  $(LDLIBS)  $(EXTRA_LOAD_FLAGS)
X
Xclean::
X	$(RM) f2ps
X
X###########################################################################
X# common rules for all Makefiles - do not edit
X
Xemptyrule::
X
Xclean::
X	$(RM_CMD) \#*
X
XMakefile:: $(IMAKE)
X
X$(IMAKE):
X	@(cd $(IMAKESRC); if [ -f Makefile ]; then \
X	echo "checking $@ in $(IMAKESRC) first..."; $(MAKE) all; else \
X	echo "bootstrapping $@ from Makefile.ini in $(IMAKESRC) first..."; \
X	$(MAKE) -f Makefile.ini BOOTSTRAPCFLAGS=$(BOOTSTRAPCFLAGS); fi; \
X	echo "okay, continuing in $(CURRENT_DIR)")
X
XMakefile::
X	-@if [ -f Makefile ]; then \
X		echo "	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
X		$(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
X	else exit 0; fi
X	$(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
X
Xtags::
X	$(TAGS) -w *.[ch]
X	$(TAGS) -xw *.[ch] > TAGS
X
Xsaber:
X	#load $(ALLDEFINES) $(SRCS)
X
Xosaber:
X	#load $(ALLDEFINES) $(OBJS)
X
X###########################################################################
X# empty rules for directories that do not have SUBDIRS - do not edit
X
Xinstall::
X	@echo "install in $(CURRENT_DIR) done"
X
Xinstall.man::
X	@echo "install.man in $(CURRENT_DIR) done"
X
XMakefiles::
X
Xincludes::
X
X###########################################################################
X# dependencies generated by makedepend
X
END_OF_FILE
if test 11372 -ne `wc -c <'xfig/Makefile'`; then
    echo shar: \"'xfig/Makefile'\" unpacked with wrong size!
fi
# end of 'xfig/Makefile'
fi
if test -f 'xfig/canvas.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/canvas.c'\"
else
echo shar: Extracting \"'xfig/canvas.c'\" \(5030 characters\)
sed "s/^X//" >'xfig/canvas.c' <<'END_OF_FILE'
X/* 
X *	FIG : Facility for Interactive Generation of figures
X *
X *	Copyright (c) 1985 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
X *	January 1985.
X *	1st revision : Aug 1985.
X *
X *	%W%	%G%
X*/
X#include "fig.h"
X#include "resources.h"
X#include "const.h"
X#include "paintop.h"
X
X/***************** import global variables and routines *******************/
X
Xextern int		cur_command;
Xextern int		errno;
Xextern int		action_on;     /* tracker.c */
Xextern int		magnet_mode;
X
Xextern int		receiving_msg;
Xextern int		borderwid, stripeht, windowspacing;
Xextern int		CANVAS_WIDTH, CANVAS_HEIGHT;
Xextern			null_proc();
Xextern			(*canvas_kbd_proc)();
Xextern			(*canvas_locmove_proc)();
Xextern			(*canvas_leftbut_proc)();
Xextern			(*canvas_middlebut_proc)();
Xextern			(*canvas_rightbut_proc)();
Xextern			null_proc();
Xextern			set_popupmenu();
X
X
X/*********************** local variables and routines ************************/
X
Xstatic			canvas_selected();
Xstatic			canvas_sighandler();
X
Xstatic Arg      canvas_args[] =
X{
X	/* 0 */ { XtNx, (XtArgVal)0 },
X	/* 1 */ { XtNy, (XtArgVal)0 },
X	/* 2 */ { XtNlabel, (XtArgVal)"" },
X	/* 3 */ { XtNwidth, (XtArgVal)0 },
X	/* 4 */ { XtNheight, (XtArgVal)0 },
X	/* 5 */ { XtNfromHoriz, (XtArgVal)NULL },
X	/* 6 */ { XtNhorizDistance, (XtArgVal)0 },
X	/* 7 */ { XtNfromVert, (XtArgVal)NULL },
X	/* 8 */ { XtNvertDistance, (XtArgVal)0 },
X	/* 9 */ { XtNtop, (XtArgVal)XtChainTop },
X	/*10 */ { XtNleft, (XtArgVal)XtChainLeft },
X};
X
Xstatic void 
X
Xcanvas_exposed(tool, event, params, nparams)
X	TOOL		tool;
X	INPUTEVENT	*event;
X	String		*params;
X	Cardinal	*nparams;
X{
X	if (((XExposeEvent *)event)->count > 0)
X		return;
X	redisplay_canvas();
X	redisplay_rulers();
X}
X
Xstatic void 
X
Xset_pos(tool, event, params, nparams)
X	TOOL		tool;
X	XEvent		*event;
X	String		*params;
X	Cardinal	*nparams;
X{
X	int		x, y;	/* fixed 3/12/89  from patch 3 */
X	Window		w;
X	extern TOOL	menu;
X	
X	XTranslateCoordinates(tool_d, canvas_swfd, XDefaultRootWindow(tool_d),
X			      event->xbutton.x, event->xbutton.y, &x, &y, &w);
X	XtMoveWidget(menu, x-10, y-10);
X}
X
XXtActionsRec canvas_actions[] =
X{
X	{ "Event", (XtActionProc)canvas_selected },
X	{ "Expose", (XtActionProc)canvas_exposed },
X	{ "set_pos", (XtActionProc)set_pos },
X};
X
Xstatic String canvas_translations =
X	"<Motion>:Event()\n\
X	<Btn1Down>:Event()\n\
X	<Btn2Down>:Event()\n\
X	<Btn3Down>:set_pos(popup_menu)MenuPopup(popup_menu)\n\
X	<Key>:Event()\n\
X	<Expose>:Expose()\n";
X
Xstatic	Arg	canvas_color_args[] = {
X	{ XtNforeground, (XtArgVal) &x_fg_color.pixel },
X	{ XtNbackground, (XtArgVal) &x_bg_color.pixel },
X};
X
Xinit_canvas(tool)
X	TOOL		tool;
X{
X	XColor	fixcolors[2];
X	
X	canvas_args[3].value = CANVAS_WIDTH;
X	canvas_args[4].value = CANVAS_HEIGHT;
X	canvas_args[5].value = (XtArgVal)panel_sw;
X	canvas_args[7].value = (XtArgVal)topruler_sw;
X	canvas_sw = XtCreateWidget("canvas", labelWidgetClass, tool,
X		canvas_args, XtNumber(canvas_args));
X	XtGetValues(canvas_sw, canvas_color_args, XtNumber(canvas_color_args));
X
X	/* get the RGB values for recolor cursor use -- may want to have
X	   cursor color resource */
X	fixcolors[0] = x_fg_color;
X	fixcolors[1] = x_bg_color;
X	XQueryColors(tool_d, DefaultColormapOfScreen(tool_s), fixcolors, 2);
X	x_fg_color = fixcolors[0];
X	x_bg_color = fixcolors[1];
X	
X	/* now fix the global GC */
X	XSetState(tool_d, gc, x_fg_color.pixel, x_bg_color.pixel, GXcopy,
X		  AllPlanes);
X	
X	/* and recolor the cursors */
X	recolor_cursors();
X	
X	canvas_leftbut_proc = null_proc;
X	canvas_middlebut_proc = null_proc;
X	canvas_rightbut_proc = null_proc;
X	canvas_kbd_proc = canvas_locmove_proc = null_proc;
X	XtAddActions(canvas_actions, XtNumber(canvas_actions));
X	XtOverrideTranslations(canvas_sw,
X		XtParseTranslationTable(canvas_translations));
X	return (1);
X}
X
Xsetup_canvas()
X{
X	canvas_rightbut_proc = set_popupmenu;
X	canvas_pixwin = canvas_swfd = XtWindow(canvas_sw);
X	init_grid();
X}
X
Xstatic 
X
Xcanvas_selected(tool, event, params, nparams)
X	TOOL		tool;
X	INPUTEVENT	*event;
X	String		*params;
X	Cardinal	*nparams;
X{
X	register int	x, y, t;
X	char		buf[1];
X	XButtonPressedEvent	*be = (XButtonPressedEvent *)event;
X	XKeyPressedEvent	*ke = (XKeyPressedEvent *)event;
X
X	x = event->x;
X	y = event->y;
X	if (magnet_mode)
X	{
X		x = ((t = x % 5) < 3) ? x - t - 1 : x + 5 - t - 1;
X		y = ((t = y % 5) < 3) ? y - t - 1 : y + 5 - t - 1;
X	}
X	switch (event->type)
X	{
X	case MotionNotify:
X		{
X			Window rw, cw;
X			static int sx = -10000, sy = -10000;
X			int rx, ry, cx, cy;
X			unsigned int mask;
X
X			XQueryPointer(event->display, event->window,
X				      &rw, &cw,
X				      &rx, &ry,
X				      &cx, &cy,
X				      &mask);
X			if(cx == sx && cy == sy) break;
X			x = sx = cx;
X			y = sy = cy;
X		}
X		set_rulermark(x, y);
X		(*canvas_locmove_proc)(x, y);
X		break;
X	case ButtonPress:
X		if (be->button & Button1)
X			(*canvas_leftbut_proc)(x, y);
X		else if (be->button & Button3)
X			(*canvas_middlebut_proc)(x, y);
X		break;
X	case KeyPress:
X		if (XLookupString(ke, buf, sizeof(buf), NULL, NULL) > 0)
X			(*canvas_kbd_proc)(buf[0]);
X		break;
X	}
X}
X
Xclear_canvas()
X{
X	XClearArea(tool_d, canvas_pixwin, 0, 0, 0, 0, False);
X}
END_OF_FILE
if test 5030 -ne `wc -c <'xfig/canvas.c'`; then
    echo shar: \"'xfig/canvas.c'\" unpacked with wrong size!
fi
# end of 'xfig/canvas.c'
fi
if test -f 'xfig/f2p.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/f2p.c'\"
else
echo shar: Extracting \"'xfig/f2p.c'\" \(12849 characters\)
sed "s/^X//" >'xfig/f2p.c' <<'END_OF_FILE'
X/* 
X *	F2p : Fig-to-pic translator
X *
X *	Copyright (c) 1985, 1988 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
X *	January 1985.
X *	1st revision : October 1985.
X *	2nd revision : March 1988 - read fig 1.4
X *
X *	%W%	%G%
X*/
X#include "fig.h"
X#include "object.h"
X
Xchar		Usage[] = "Usage: f2p [ -s font_size ] [ input_file [ output_file ] ]\n";
Xchar		*from = NULL, *to = NULL;
XFILE		*ffp = NULL, *tfp = NULL;
Xint		font_size = 11;		/* points */
Xchar		Err_incomp[] = "Incomplete %s object at line %d.";
Xchar		Err_mem[] = "Running out of memory.";
X
Xput_msg(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
Xchar   *format, *arg1, *arg2, *arg3, *arg4, *arg5, *arg6, *arg7, *arg8;
X{
X	fprintf(stderr, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
X	}
X
Xget_args(argc, argv)
Xint	 argc;
Xchar	*argv[];
X{
X	char	*a;
X	int	first = 1;
X
X	while (--argc) {
X	    a = *++argv;
X	    if (*a == '-') {
X		if (*++a == 's') {	/* Font size followed */
X		    if (--argc) {
X			font_size = atoi(*++argv);
X			if (font_size <= 0 || font_size > 30) {
X			    fprintf(stderr, Usage);
X			    exit(0);
X			    }
X			}
X		    else {
X			fprintf(stderr, Usage);
X			exit(0);
X			}
X		    }
X		else {
X		    fprintf(stderr, Usage);
X		    exit(0);
X		    }
X		}
X	    else if (first) {
X		from = a;	/*  from file  */
X		first = 0;
X		}
X	    else if (first == 0) {
X		to = a;		/*  to file  */
X		first = -1;
X		}
X	    else
X		fprintf(stderr, Usage);
X	    }
X	}
X
Xmain(argc, argv)
Xint	 argc;
Xchar	*argv[];
X{
X	F_compound	objects;
X	int		status;
X	char		c;
X
X	get_args(argc, argv);
X	if (to == NULL)
X	    tfp = stdout;
X	else if ((tfp = fopen(to, "w")) == NULL) {
X	    fprintf(stderr, "Couldn't open %s\n", to);
X	    fprintf(stderr, Usage);
X	    exit(0);
X	    }
X
X	if (from)
X	    status = read_fig(from, &objects);
X	else 	/* read from stdin */
X	    status = readfp_fig(stdin, &objects);
X
X	if (status != 0) {
X	    if (from) read_fail_message(from, status);
X	    exit(0);
X	    }
X	genpic_objects(&objects);
X	if (tfp != stdout) fclose(tfp);
X	}
X
X#define			TOP	10.5	/* top of page is 10.5 inch */
Xstatic double		ppi;
Xstatic int		CONV = 0;
X
Xdouble
Xconvy(a)
Xdouble	a;
X{
X	return((double)(CONV ? TOP-a : a));
X	}
X
Xgenpic_objects(objects)
XF_compound	*objects;
X{
X	int		coord_system;
X	F_arc		*a;
X	F_compound	*c;
X	F_ellipse	*e;
X	F_line		*l;
X	F_spline	*s;
X	F_text		*t;
X
X	if (0 == (ppi = (double)objects->nwcorner.x)) {
X	    fprintf(stderr, "Resolution is zero!! default to 80 ppi\n");
X	    ppi = 80.0;
X	    }
X	coord_system = objects->nwcorner.y;
X	if (coord_system != 1 && coord_system != 2) {
X	    fprintf(stderr, "Wrong coordinate system; cannot continue\n");
X	    return;
X	    }
X	if (coord_system == 2) CONV = 1;
X
X	fprintf(tfp, ".PS\n");	/* PostScript magic strings */
X
X	for (a = objects->arcs; a != NULL; a = a->next) genpic_arc(a);
X	for (c = objects->compounds; c != NULL; c = c->next) genpic_compound(c);
X	for (e = objects->ellipses; e != NULL; e = e->next) genpic_ellipse(e);
X	for (l = objects->lines; l != NULL; l = l->next) genpic_line(l);
X	for (s = objects->splines; s != NULL; s = s->next) genpic_spline(s);
X	for (t = objects->texts; t != NULL; t = t->next) genpic_text(t);
X	fprintf(tfp, ".PE\n");
X	}
X
X/*
XThe line thickness is, unfortunately, multiple of pixel.
XOne pixel thickness is a little too thick on the hard copy
Xso I scale it with 0.7; i.e., it's a kludge.  The best way is
Xto allow thickness in fraction of pixel.
X
XNote that the current version of psdit (a ditroff to postcript filter)
Xwon't take the legitimate line thickness command.
X*/
Xset_linewidth(w)
Xint	w;
X{
X	static int	cur_thickness = -1;
X
X	/*
X	if (w == 0) return;
X	if (w != cur_thickness) {
X	    cur_thickness = w;
X	    fprintf(tfp, "\"\\D't %.5fi'\"\n", 0.7 * cur_thickness / ppi);
X	    }
X	*/
X	}
X
Xset_style(s, v)
Xint	s;
Xfloat	v;
X{
X	static float	style_val = -1;
X
X	if (s == DASH_LINE || s == DOTTED_LINE) {
X	    if (v == style_val) return;
X	    if (v == 0.0) return;
X	    style_val = v;
X	    fprintf(tfp, "dashwid = %.3fi\n", style_val/ppi);
X	    }
X	}
X
Xgenpic_compound(com)
XF_compound	*com;
X{
X	F_arc		*a;
X	F_compound	*c;
X	F_ellipse	*e;
X	F_line		*l;
X	F_spline	*s;
X	F_text		*t;
X
X	for (a = com->arcs; a != NULL; a = a->next) genpic_arc(a);
X	for (c = com->compounds; c != NULL; c = c->next) genpic_compound(c);
X	for (e = com->ellipses; e != NULL; e = e->next) genpic_ellipse(e);
X	for (l = com->lines; l != NULL; l = l->next) genpic_line(l);
X	for (s = com->splines; s != NULL; s = s->next) genpic_spline(s);
X	for (t = com->texts; t != NULL; t = t->next) genpic_text(t);
X	}
X
Xgenpic_line(l)
XF_line	*l;
X{
X	F_point		*p, *q;
X
X	set_linewidth(l->thickness);
X	set_style(l->style, l->style_val);
X	p = l->points;
X	q = p->next;
X	if (q == NULL) { /* A single point line */
X	    fprintf(tfp, "line from %.3f,%.3f to %.3f,%.3f\n",
X			p->x/ppi, convy(p->y/ppi), p->x/ppi, convy(p->y/ppi));
X	    return;
X	    }
X	if (l->back_arrow)
X	    draw_arrow_head(q->x/ppi, convy(q->y/ppi), p->x/ppi,
X		convy(p->y/ppi), l->back_arrow->ht/ppi, l->back_arrow->wid/ppi);
X	if (l->style == DASH_LINE && l->style_val > 0.0)
X	    fprintf(tfp, "line dashed from");
X	else if (l->style == DOTTED_LINE && l->style_val > 0.0)
X	    fprintf(tfp, "line dotted from");
X	else
X	    fprintf(tfp, "line from");
X	fprintf(tfp, " %.3f,%.3f to", p->x/ppi, convy(p->y/ppi));
X	while (q->next != NULL) {
X	    p = q;
X	    q = q->next;
X	    fprintf(tfp, " %.3f,%.3f to", p->x/ppi, convy(p->y/ppi));
X	    }
X	fprintf(tfp, " %.3f,%.3f\n", q->x/ppi, convy(q->y/ppi));
X	if (l->for_arrow)
X	    draw_arrow_head(p->x/ppi, convy(p->y/ppi), q->x/ppi,
X		convy(q->y/ppi), l->for_arrow->ht/ppi, l->for_arrow->wid/ppi);
X	}
X
Xgenpic_spline(s)
XF_spline	*s;
X{
X	if (int_spline(s))
X	    genpic_itp_spline(s);
X	else
X	    genpic_ctl_spline(s);
X	}
X
Xgenpic_ctl_spline(s)
XF_spline	*s;
X{
X	if (closed_spline(s))
X	    genpic_closed_spline(s);
X	else
X	    genpic_open_spline(s);
X	}
X
Xgenpic_open_spline(s)
XF_spline	*s;
X{
X	double		x1, y1, x2, y2;
X	F_point		*p, *q;
X
X	p = s->points;
X	x1 = p->x/ppi; y1 = convy(p->y/ppi);
X	p = p->next;
X	x2 = p->x/ppi; y2 = convy(p->y/ppi);
X
X	if (s->back_arrow)
X	    draw_arrow_head(x2, y2, x1, y1,
X		s->back_arrow->ht/ppi, s->back_arrow->wid/ppi);
X
X	/* Pic's spline supports only solid line style */
X	/* set_linewidth(s->thickness); */
X
X	if (p->next == NULL) {
X	    fprintf(tfp, "line from %.3f,%.3f to %.3f,%.3f\n", x1, y1, x2, y2);
X	    if (s->for_arrow)
X		draw_arrow_head(x1, y1, x2, y2, s->for_arrow->ht/ppi,
X				s->for_arrow->wid/ppi);
X	    return;
X	    }
X
X	fprintf(tfp, "spline from %.3f,%.3f to %.3f,%.3f", x1, y1, x2, y2);
X
X	for (q = p->next; q->next != NULL; p = q, q = q->next)
X	    fprintf(tfp, " to %.3f,%.3f", q->x/ppi, convy(q->y/ppi));
X	fprintf(tfp, " to %.3f,%.3f\n", (x2=q->x/ppi), (y2=convy(q->y/ppi)));
X
X	if (s->for_arrow)
X	    draw_arrow_head(p->x/ppi, convy(p->y/ppi), x2, y2,
X		s->for_arrow->ht/ppi, s->for_arrow->wid/ppi);
X	}
X
Xgenpic_ellipse(e)
XF_ellipse	*e;
X{
X	set_linewidth(e->thickness);
X	fprintf(tfp, "ellipse at %.3f,%.3f wid %.3f ht %.3f\n",
X		e->center.x/ppi, convy(e->center.y/ppi),
X		2 * e->radiuses.x/ppi, 2 * e->radiuses.y/ppi);
X	}
X
X/*
XText is display on the screen with the base line starting at
X(base_x, base_y); some characters extend below this line.
XPic displays the center of the height of text at the given
Xcoordinate. HT_OFFSET is use to compensate all the above factors
Xso text position in fig 1.4 should be at the same position on
Xthe screen as on the hard copy.
X*/
X#define			HT_OFFSET	(0.2 / 72.0)
X
Xgenpic_text(t)
XF_text	*t;
X{
X	float	y;
X	int	first = 1;
X
X	if (first) {
X	    first = 0;
X	    fprintf(tfp, ".ps %d\n", font_size);
X	    }
X
X	y = convy(t->base_y/ppi) + font_size * HT_OFFSET;
X	fprintf(tfp, "\"%s\" at %.3f,%.3f ljust\n",
X		t->cstring, t->base_x/ppi, y);
X	}
X
Xgenpic_arc(a)
XF_arc	*a;
X{
X	double		x, y;
X	double		cx, cy, sx, sy, ex, ey;
X
X	cx = a->center.x/ppi; cy = convy(a->center.y/ppi);
X	sx = a->point[0].x/ppi; sy = convy(a->point[0].y/ppi);
X	ex = a->point[2].x/ppi; ey = convy(a->point[2].y/ppi);
X
X	set_linewidth(a->thickness);
X
X	if (a->for_arrow) {
X	    arc_tangent(cx, cy, ex, ey, a->direction, &x, &y);
X	    draw_arrow_head(x, y, ex, ey,
X			a->for_arrow->ht/ppi, a->for_arrow->wid/ppi);
X	    }
X	if (a->back_arrow) {
X	    arc_tangent(cx, cy, sx, sy, !a->direction, &x, &y);
X	    draw_arrow_head(x, y, sx, sy,
X			a->back_arrow->ht/ppi, a->back_arrow->wid/ppi);
X	    }
X
X	if (a->direction)
X	    fprintf(tfp, "arc at %.3f,%.3f from %.3f,%.3f to %.3f,%.3f\n",
X			cx, cy, sx, sy, ex, ey);
X	else
X	    fprintf(tfp, "arc at %.3f,%.3f from %.3f,%.3f to %.3f,%.3f cw\n",
X			cx, cy, sx, sy, ex, ey);
X
X	}
X
Xarc_tangent(x1, y1, x2, y2, direction, x, y)
Xdouble	x1, y1, x2, y2, *x, *y;
Xint	direction;
X{
X	if (direction) { /* counter clockwise  */
X	    *x = x2 + (y2 - y1);
X	    *y = y2 - (x2 - x1);
X	    }
X	else {
X	    *x = x2 - (y2 - y1);
X	    *y = y2 + (x2 - x1);
X	    }
X	}
X
X/*	draw arrow heading from (x1, y1) to (x2, y2)	*/
X
Xdraw_arrow_head(x1, y1, x2, y2, arrowht, arrowwid)
Xdouble	x1, y1, x2, y2, arrowht, arrowwid;
X{
X	double	x, y, xb, yb, dx, dy, l, sina, cosa;
X	double	xc, yc, xd, yd;
X
X	dx = x2 - x1;  dy = y1 - y2;
X	l = sqrt((dx*dx + dy*dy));
X	sina = dy / l;  cosa = dx / l;
X	xb = x2*cosa - y2*sina;
X	yb = x2*sina + y2*cosa;
X	x = xb - arrowht;
X	y = yb - arrowwid / 2;
X	xc = x*cosa + y*sina;
X	yc = -x*sina + y*cosa;
X	y = yb + arrowwid / 2;
X	xd = x*cosa + y*sina;
X	yd = -x*sina + y*cosa;
X	fprintf(tfp, "line from %.3f,%.3f to %.3f,%.3f to %.3f,%.3f\n",
X		xc, yc, x2, y2, xd, yd);
X	}
X
X#define		THRESHOLD	.05	/* inch */
X
Xquadratic_spline(a1, b1, a2, b2, a3, b3, a4, b4)
Xdouble	a1, b1, a2, b2, a3, b3, a4, b4;
X{
X	double	x1, y1, x4, y4;
X	double	xmid, ymid;
X
X	x1 = a1; y1 = b1;
X	x4 = a4; y4 = b4;
X
X	xmid = (a2 + a3) / 2;
X	ymid = (b2 + b3) / 2;
X	if (fabs(x1 - xmid) < THRESHOLD && fabs(y1 - ymid) < THRESHOLD) {
X	    fprintf(tfp, "\tto %.3f,%.3f\\\n", xmid, ymid);
X	    }
X	else {
X	    quadratic_spline(x1, y1, ((x1+a2)/2), ((y1+b2)/2),
X			((3*a2+a3)/4), ((3*b2+b3)/4), xmid, ymid);
X	    }
X
X	if (fabs(xmid - x4) < THRESHOLD && fabs(ymid - y4) < THRESHOLD) {
X	    fprintf(tfp, "\tto %.3f,%.3f\\\n", x4, y4);
X	    }
X	else {
X	    quadratic_spline(xmid, ymid, ((a2+3*a3)/4), ((b2+3*b3)/4),
X			((a3+x4)/2), ((b3+y4)/2), x4, y4);
X	    }
X	}
X
Xgenpic_closed_spline(s)
XF_spline	*s;
X{
X	F_point	*p;
X	double	cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4;
X	double	x1, y1, x2, y2;
X
X	p = s->points;
X	x1 = p->x/ppi;  y1 = convy(p->y/ppi);
X	p = p->next;
X	x2 = p->x/ppi;  y2 = convy(p->y/ppi);
X	cx1 = (x1 + x2) / 2;      cy1 = (y1 + y2) / 2;
X	cx2 = (x1 + 3 * x2) / 4;  cy2 = (y1 + 3 * y2) / 4;
X
X	for (p = p->next; p != NULL; p = p->next) {
X	    fprintf(tfp, "line from %.3f,%.3f ", cx1, cy1);
X	    x1 = x2;  y1 = y2;
X	    x2 = p->x/ppi;  y2 = convy(p->y/ppi);
X	    cx3 = (3 * x1 + x2) / 4;  cy3 = (3 * y1 + y2) / 4;
X	    cx4 = (x1 + x2) / 2;      cy4 = (y1 + y2) / 2;
X	    quadratic_spline(cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4);
X	    fprintf(tfp, "\n");
X	    cx1 = cx4;  cy1 = cy4;
X	    cx2 = (x1 + 3 * x2) / 4;  cy2 = (y1 + 3 * y2) / 4;
X	    }
X	x1 = x2;  y1 = y2;
X	p = s->points->next;
X	x2 = p->x/ppi;  y2 = convy(p->y/ppi);
X	cx3 = (3 * x1 + x2) / 4;  cy3 = (3 * y1 + y2) / 4;
X	cx4 = (x1 + x2) / 2;      cy4 = (y1 + y2) / 2;
X	fprintf(tfp, "line from %.3f,%.3f ", cx1, cy1);
X	quadratic_spline(cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4);
X	fprintf(tfp, "\n");
X	}
X
Xgenpic_itp_spline(s)
XF_spline	*s;
X{
X	F_point		*p1, *p2;
X	F_control	*cp1, *cp2;
X	double		x1, x2, y1, y2;
X
X	p1 = s->points;
X	cp1 = s->controls;
X	cp2 = cp1->next;
X	x2 = p1->x/ppi; y2 = convy(p1->y/ppi);
X
X	if (s->back_arrow)
X	    draw_arrow_head(cp2->lx/ppi, convy(cp2->ly/ppi), x2, y2,
X		s->back_arrow->ht/ppi, s->back_arrow->wid/ppi);
X
X	for (p2 = p1->next, cp2 = cp1->next; p2 != NULL;
X		p1 = p2, cp1 = cp2, p2 = p2->next, cp2 = cp2->next) {
X	    fprintf(tfp, "line from %.3f,%.3f ", x2, y2);
X	    x1 = x2; y1 = y2;
X	    x2 = p2->x/ppi; y2 = convy(p2->y/ppi);
X	    bezier_spline(x1, y1, (double)cp1->rx/ppi, convy(cp1->ry/ppi),
X		(double)cp2->lx/ppi, convy(cp2->ly/ppi), x2, y2);
X	    fprintf(tfp, "\n");
X	    }
X
X	if (s->for_arrow)
X	    draw_arrow_head((double)cp1->lx/ppi, convy(cp1->ly/ppi), x1, y1,
X		(double)s->for_arrow->ht/ppi, (double)s->for_arrow->wid/ppi);
X	}
X
Xbezier_spline(a0, b0, a1, b1, a2, b2, a3, b3)
Xdouble	a0, b0, a1, b1, a2, b2, a3, b3;
X{
X	double	x0, y0, x3, y3;
X	double	sx1, sy1, sx2, sy2, tx, ty, tx1, ty1, tx2, ty2, xmid, ymid;
X
X	x0 = a0; y0 = b0;
X	x3 = a3; y3 = b3;
X	if (fabs(x0 - x3) < THRESHOLD && fabs(y0 - y3) < THRESHOLD) {
X	    fprintf(tfp, "\tto %.3f,%.3f\\\n", x3, y3);
X	    }
X	else {
X	    tx = (a1 + a2) / 2;		ty = (b1 + b2) / 2;
X	    sx1 = (x0 + a1) / 2;	sy1 = (y0 + b1) / 2;
X	    sx2 = (sx1 + tx) / 2;	sy2 = (sy1 + ty) / 2;
X	    tx2 = (a2 + x3) / 2;	ty2 = (b2 + y3) / 2;
X	    tx1 = (tx2 + tx) / 2;	ty1 = (ty2 + ty) / 2;
X	    xmid = (sx2 + tx1) / 2;	ymid = (sy2 + ty1) / 2;
X
X	    bezier_spline(x0, y0, sx1, sy1, sx2, sy2, xmid, ymid);
X	    bezier_spline(xmid, ymid, tx1, ty1, tx2, ty2, x3, y3);
X	    }
X	}
END_OF_FILE
if test 12849 -ne `wc -c <'xfig/f2p.c'`; then
    echo shar: \"'xfig/f2p.c'\" unpacked with wrong size!
fi
# end of 'xfig/f2p.c'
fi
if test -f 'xfig/rotate.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/rotate.c'\"
else
echo shar: Extracting \"'xfig/rotate.c'\" \(11085 characters\)
sed "s/^X//" >'xfig/rotate.c' <<'END_OF_FILE'
X/* 
X *	FIG : Facility for Interactive Generation of figures
X *
X *	Copyright (c) 1985 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
X *	January 1985.
X *	1st revision : Aug 1985.
X *
X *	%W%	%G%
X*/
X#include "fig.h"
X#include "resources.h"
X#include "func.h"
X#include "object.h"
X#include "paintop.h"
X
X#define			TOLERANCE	7
X
Xextern			(*canvas_kbd_proc)();
Xextern			(*canvas_locmove_proc)();
Xextern			(*canvas_leftbut_proc)();
Xextern			(*canvas_middlebut_proc)();
Xextern			(*canvas_rightbut_proc)();
Xextern			null_proc();
Xextern			set_popupmenu();
X
Xextern F_line		*line_search(), *copy_line();
Xextern F_ellipse	*ellipse_search(), *copy_ellipse();
Xextern F_ellipse	*ellipse_point_search();
Xextern F_spline		*spline_search(), *copy_spline();
Xextern F_arc		*arc_point_search(), *copy_arc();
Xextern F_compound	*compound_search(), *copy_compound();
X
Xextern F_compound	objects;
X
Xextern int		rotate_angle;
Xextern int		pointmarker_shown;
Xextern int		foreground_color, background_color;
X
Xstatic int		copy;
X			init_rotate();
X			init_copynrotate();
X
Xrotate_selected()
X{
X	canvas_kbd_proc = null_proc;
X	canvas_locmove_proc = null_proc;
X	canvas_leftbut_proc = init_copynrotate;
X	canvas_middlebut_proc = init_rotate;
X	canvas_rightbut_proc = set_popupmenu;
X	set_cursor(&pick15_cursor);
X	}
X
Xinit_rotate(x, y)
Xint	x, y;
X{
X	copy = 0;
X	rotate_search(x, y);
X	}
X
Xinit_copynrotate(x, y)
Xint	x, y;
X{
X	copy = 1;
X	rotate_search(x, y);
X	}
X
Xrotate_search(x, y)
Xint	x, y;
X{
X	F_line		*l;
X	F_arc		*a;
X	F_ellipse	*e;
X	F_spline	*s;
X	F_compound	*c;
X	int		px, py;
X
X	if ((l = line_search(x, y, TOLERANCE, &px, &py)) != NULL) {
X	    init_rotateline(l, px, py);
X	    }
X	else if ((e = ellipse_point_search(x, y, TOLERANCE, &px)) != NULL) {
X	    if (px == 0)
X		init_rotateellipse(e, e->start.x, e->start.y);
X	    else
X		init_rotateellipse(e, e->end.x, e->end.y);
X	    }
X	else if ((e = ellipse_search(x, y, TOLERANCE, &px, &py)) != NULL) {
X	    init_rotateellipse(e, x, y);
X	    }
X	else if ((a = arc_point_search(x, y, TOLERANCE, &px)) != NULL) {
X	    init_rotatearc(a, a->point[px].x, a->point[px].y);
X	    }
X	else if ((s = spline_search(x, y, TOLERANCE, &px, &py)) != NULL) {
X	    init_rotatespline(s, px, py);
X	    }
X	else if ((c = compound_search(x, y, TOLERANCE, &px, &py)) != NULL) {
X	    init_rotatecompound(c, px, py);
X	    }
X	else {
X	    return;
X	    }
X	set_modifiedflag();
X	}
X
Xinit_rotateline(l, px, py)
XF_line	*l;
Xint	px, py;
X{
X	F_line	*line;
X
X	win_setmouseposition(canvas_swfd, px, py);
X	if (pointmarker_shown) toggle_linepointmarker(l);
X	if (copy) {
X	    line = copy_line(l);
X	    rotate_line(line, px, py, rotate_angle);
X	    insert_line(&objects.lines, line);
X	    clean_up();
X	    set_action_object(F_CREATE, O_POLYLINE);
X	    draw_line(line, PAINT);
X	    }
X	else {
X	    draw_line(l, ERASE);
X	    rotate_line(l, px, py, rotate_angle);
X	    clean_up();
X	    set_action_object(F_ROTATE, O_POLYLINE);
X	    set_lastangle(rotate_angle);
X	    set_lastposition(px, py);
X	    draw_line(l, PAINT);
X	    line = l;
X	    }
X	if (pointmarker_shown) {
X	    if (copy) toggle_linepointmarker(line);
X	    toggle_linepointmarker(l);
X	    }
X	set_latestline(line);
X	}
X
Xinit_rotateellipse(e, px, py)
XF_ellipse	*e;
Xint		px, py;
X{
X	F_ellipse	*ellipse;
X
X	win_setmouseposition(canvas_swfd, px, py);
X	if (pointmarker_shown) toggle_ellipsepointmarker(e);
X	if (copy) {
X	    ellipse = copy_ellipse(e);
X	    rotate_ellipse(ellipse, px, py, rotate_angle);
X	    insert_ellipse(&objects.ellipses, ellipse);
X	    clean_up();
X	    set_action_object(F_CREATE, O_ELLIPSE);
X	    draw_ellipse(ellipse, PAINT);
X	    }
X	else {
X	    draw_ellipse(e, background_color);
X	    rotate_ellipse(e, px, py, rotate_angle);
X	    clean_up();
X	    set_action_object(F_ROTATE, O_ELLIPSE);
X	    set_lastangle(rotate_angle);
X	    set_lastposition(px, py);
X	    draw_ellipse(e, foreground_color);
X	    ellipse = e;
X	    }
X	if (pointmarker_shown) {
X	    if (copy) toggle_ellipsepointmarker(ellipse);
X	    toggle_ellipsepointmarker(e);
X	    }
X	set_latestellipse(ellipse);
X	}
X
Xinit_rotatearc(a, px, py)
XF_arc	*a;
Xint	px, py;
X{
X	F_arc	*arc;
X
X	win_setmouseposition(canvas_swfd, px, py);
X	if (pointmarker_shown) toggle_arcpointmarker(a);
X	if (copy) {
X	    arc = copy_arc(a);
X	    rotate_arc(arc, px, py, rotate_angle);
X	    insert_arc(&objects.arcs, arc);
X	    clean_up();
X	    set_action_object(F_CREATE, O_ARC);
X	    draw_arc(arc, foreground_color);
X	    }
X	else {
X	    draw_arc(a, background_color);
X	    rotate_arc(a, px, py, rotate_angle);
X	    clean_up();
X	    set_action_object(F_ROTATE, O_ARC);
X	    set_lastangle(rotate_angle);
X	    set_lastposition(px, py);
X	    draw_arc(a, foreground_color);
X	    arc = a;
X	    }
X	if (pointmarker_shown) {
X	    if (copy) toggle_arcpointmarker(arc);
X	    toggle_arcpointmarker(a);
X	    }
X	set_latestarc(arc);
X	}
X
Xinit_rotatespline(s, px, py)
XF_spline	*s;
Xint		px, py;
X{
X	F_spline	*spline;
X
X	win_setmouseposition(canvas_swfd, px, py);
X	if (pointmarker_shown) toggle_splinepointmarker(s);
X	if (copy) {
X	    spline = copy_spline(s);
X	    rotate_spline(spline, px, py, rotate_angle);
X	    insert_spline(&objects.splines, spline);
X	    clean_up();
X	    set_action_object(F_CREATE, O_SPLINE);
X	    draw_spline(spline, PAINT);
X	    }
X	else {
X	    draw_spline(s, ERASE);
X	    rotate_spline(s, px, py, rotate_angle);
X	    clean_up();
X	    set_action_object(F_ROTATE, O_SPLINE);
X	    set_lastangle(rotate_angle);
X	    set_lastposition(px, py);
X	    draw_spline(s, PAINT);
X	    spline = s;
X	    }
X	if (pointmarker_shown) {
X	    if (copy) toggle_splinepointmarker(spline);
X	    toggle_splinepointmarker(s);
X	    }
X	set_latestspline(spline);
X	}
X
Xinit_rotatecompound(c, px, py)
XF_compound	*c;
Xint		px, py;
X{
X	F_compound	*compound;
X
X	win_setmouseposition(canvas_swfd, px, py);
X	set_temp_cursor(&wait_cursor);
X	if (copy) {
X	    compound = copy_compound(c);
X	    rotate_compound(compound, px, py, rotate_angle);
X	    insert_compound(&objects.compounds, compound);
X	    clean_up();
X	    set_action_object(F_CREATE, O_COMPOUND);
X	    draw_compound(compound);
X	    draw_compoundbox(compound, INV_PAINT);
X	    }
X	else {
X	    draw_compoundbox(c, INV_PAINT);
X	    erase_compound(c);
X	    rotate_compound(c, px, py, rotate_angle);
X	    clean_up();
X	    set_action_object(F_ROTATE, O_COMPOUND);
X	    set_lastangle(rotate_angle);
X	    set_lastposition(px, py);
X	    draw_compound(c);
X	    draw_compoundbox(c, INV_PAINT);
X	    compound = c;
X	    }
X	set_latestcompound(compound);
X	set_temp_cursor(cur_cursor);
X	}
X
Xrotate_line(l, x, y, rotate_angle)
XF_line	*l;
Xint	x, y, rotate_angle;
X{
X	F_point	*p;
X	int	dx;
X
X	switch(rotate_angle) {
X	    case 270 :
X		for (p = l->points; p != NULL; p = p->next) {
X		    dx = p->x - x;
X		    p->x = x + (y - p->y);
X		    p->y = y + dx;
X		    }
X		break;
X	    case 90 :
X		for (p = l->points; p != NULL; p = p->next) {
X		    dx = p->x - x;
X		    p->x = x - (y - p->y);
X		    p->y = y - dx;
X		    }
X		break;
X	    }
X	}
X
Xrotate_spline(s, x, y, rotate_angle)
XF_spline	*s;
Xint		x, y, rotate_angle;
X{
X	F_point		*p;
X	F_control	*cp;
X	int		dx;
X
X	switch(rotate_angle) {
X	    case 270 :
X		for (p = s->points; p != NULL; p = p->next) {
X		    dx = p->x - x;
X		    p->x = x + (y - p->y);
X		    p->y = y + dx;
X		    }
X		for (cp = s->controls; cp != NULL; cp = cp->next) {
X		    dx = cp->lx - x;
X		    cp->lx = x + (y - cp->ly);
X		    cp->ly = y + dx;
X		    dx = cp->rx - x;
X		    cp->rx = x + (y - cp->ry);
X		    cp->ry = y + dx;
X		    }
X		break;
X	    case 90 :
X		for (p = s->points; p != NULL; p = p->next) {
X		    dx = p->x - x;
X		    p->x = x - (y - p->y);
X		    p->y = y - dx;
X		    }
X		for (cp = s->controls; cp != NULL; cp = cp->next) {
X		    dx = cp->lx - x;
X		    cp->lx = x - (y - cp->ly);
X		    cp->ly = y - dx;
X		    dx = cp->rx - x;
X		    cp->rx = x - (y - cp->ry);
X		    cp->ry = y - dx;
X		    }
X		break;
X	    }
X	}
X
Xrotate_text(t, x, y, rotate_angle)
XF_text	*t;
Xint	x, y, rotate_angle;
X{
X	int	dx;
X
X	switch(rotate_angle) {
X	    case 270 :
X		dx = t->base_x - x;
X		t->base_x = x - (t->base_y - y);
X		t->base_y = y + dx;
X		break;
X	    case 90 :	
X		dx = t->base_x - x;
X		t->base_x = x + (t->base_y - y);
X		t->base_y = y - dx;
X		break;
X	    }
X	}
X
Xrotate_ellipse(e, x, y, rotate_angle)
XF_ellipse	*e;
Xint		x, y, rotate_angle;
X{
X	int	dx;
X
X	switch(rotate_angle) {
X	    case 270 :
X		dx = e->center.x - x;
X		e->center.x = x - (e->center.y - y);
X		e->center.y = y + dx;
X		dx = e->radiuses.x;
X		e->radiuses.x = e->radiuses.y;
X		e->radiuses.y = dx;
X		dx = e->start.x - x;
X		e->start.x = x - (e->start.y - y);
X		e->start.y = y + dx;
X		dx = e->end.x - x;
X		e->end.x = x - (e->end.y - y);
X		e->end.y = y + dx;
X		break;
X	    case 90 :	
X		dx = e->center.x - x;
X		e->center.x = x + (e->center.y - y);
X		e->center.y = y - dx;
X		dx = e->radiuses.x;
X		e->radiuses.x = e->radiuses.y;
X		e->radiuses.y = dx;
X		dx = e->start.x - x;
X		e->start.x = x + (e->start.y - y);
X		e->start.y = y - dx;
X		dx = e->end.x - x;
X		e->end.x = x + (e->end.y - y);
X		e->end.y = y - dx;
X		break;
X	    }
X	}
X
Xrotate_arc(a, x, y, rotate_angle)
XF_arc	*a;
Xint	x, y, rotate_angle;
X{
X	int	dx;
X
X	switch(rotate_angle) {
X	    case 270 :
X		dx = a->center.x - x;
X		a->center.x = x - (a->center.y - y);
X		a->center.y = y + dx;
X		dx = a->point[0].x - x;
X		a->point[0].x = x - (a->point[0].y - y);
X		a->point[0].y = y + dx;
X		dx = a->point[1].x - x;
X		a->point[1].x = x - (a->point[1].y - y);
X		a->point[1].y = y + dx;
X		dx = a->point[2].x - x;
X		a->point[2].x = x - (a->point[2].y - y);
X		a->point[2].y = y + dx;
X		break;
X	    case 90 :	
X		dx = a->center.x - x;
X		a->center.x = x + (a->center.y - y);
X		a->center.y = y - dx;
X		dx = a->point[0].x - x;
X		a->point[0].x = x + (a->point[0].y - y);
X		a->point[0].y = y - dx;
X		dx = a->point[1].x - x;
X		a->point[1].x = x + (a->point[1].y - y);
X		a->point[1].y = y - dx;
X		dx = a->point[2].x - x;
X		a->point[2].x = x + (a->point[2].y - y);
X		a->point[2].y = y - dx;
X		break;
X	    }
X	}
X
X#define			min(a, b)	(((a) < (b)) ? (a) : (b))
X#define			max(a, b)	(((a) > (b)) ? (a) : (b))
X
Xrotate_compound(c, x, y, rotate_angle)
XF_compound	*c;
Xint		x, y, rotate_angle;
X{
X	F_line		*l;
X	F_arc		*a;
X	F_ellipse	*e;
X	F_spline	*s;
X	F_text		*t;
X	F_compound	*c1;
X	int		x1, y1, x2, y2;
X
X	switch(rotate_angle) {
X	    case 270 :
X		x1 = x - (c->nwcorner.y - y);
X		y1 = y + (c->nwcorner.x - x);
X		x2 = x - (c->secorner.y - y);
X		y2 = y + (c->secorner.x - x);
X		break;
X	    case 90 :	
X		x1 = x + (c->nwcorner.y - y);
X		y1 = y - (c->nwcorner.x - x);
X		x2 = x + (c->secorner.y - y);
X		y2 = y - (c->secorner.x - x);
X		break;
X	    }
X	c->nwcorner.x = min(x1, x2);
X	c->nwcorner.y = min(y1, y2);
X	c->secorner.x = max(x1, x2);
X	c->secorner.y = max(y1, y2);
X	for (l = c->lines; l != NULL; l = l->next)
X	    rotate_line(l, x, y, rotate_angle);
X	for (a = c->arcs; a != NULL; a = a->next)
X	    rotate_arc(a, x, y, rotate_angle);
X	for (e = c->ellipses; e != NULL; e = e->next)
X	    rotate_ellipse(e, x, y, rotate_angle);
X	for (s = c->splines; s != NULL; s = s->next)
X	    rotate_spline(s, x, y, rotate_angle);
X	for (t = c->texts; t != NULL; t = t->next)
X	    rotate_text(t, x, y, rotate_angle);
X	for (c1 = c->compounds; c1 != NULL; c1 = c1->next)
X	    rotate_compound(c1, x, y, rotate_angle);
X	}
END_OF_FILE
if test 11085 -ne `wc -c <'xfig/rotate.c'`; then
    echo shar: \"'xfig/rotate.c'\" unpacked with wrong size!
fi
# end of 'xfig/rotate.c'
fi
if test -f 'xfig/xtra.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/xtra.c'\"
else
echo shar: Extracting \"'xfig/xtra.c'\" \(11050 characters\)
sed "s/^X//" >'xfig/xtra.c' <<'END_OF_FILE'
X/* 
X *	FIG : Facility for Interactive Generation of figures
X *
X *	Copyright (c) 1985 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
X *	January 1985.
X *	1st revision : Aug 1985.
X *
X *	%W%	%G%
X*/
X#include "fig.h"
X#include "resources.h"
X#include "paintop.h"
X#include "font.h"
X
Xextern int cur_thickness[];
Xextern PIX_FONT lookfont();
X
X/* print "string" in window "w" using font number "font" and size "size" */
X
Xpw_text(w, x, y, op, font, size, string)
XWindow w;
Xint x, y, op, font, size;
Xchar *string;
X	{
X	if (cur_gcfont[op] != font || cur_gcfontsize[op] != size)
X		{
X		canvas_font = lookfont(font,size);
X		XSetFont(tool_d, gccache[op], canvas_font->fid);
X		cur_gcfont[op] = font;
X		cur_gcfontsize[op] = size;
X		}
X	XDrawString(tool_d, w, gccache[op], x, y, string, strlen(string));
X	}
X
Xpr_size 
Xpf_textwidth(font, size, n, s)
Xint font,size,n;
Xchar *s;
X	{
X	int		dummy;
X	XCharStruct	ch;
X	pr_size		ret;
X
X	canvas_font = lookfont(font,size);	/* make sure it is the right font */
X	XTextExtents(canvas_font, s, n, &dummy, &dummy, &dummy, &ch);
X	ret.x = ch.width;
X	ret.y = ch.ascent + ch.descent;
X	return (ret);
X	}
X
XGC
Xmakegc(op, fg, bg)
Xint	op;
XPixel	fg;
XPixel	bg;
X{
X	register GC	ngc;
X	XGCValues	gcv;
X	int		gcmask;
X
X	gcv.font = roman_font->fid;
X	gcv.join_style = JoinMiter;
X	gcmask = GCJoinStyle|GCFunction|GCForeground|GCBackground|GCFont;
X	switch (op) {
X	case PAINT:
X		gcv.foreground = fg;
X		gcv.background = bg;
X		gcv.function = GXcopy;
X		break;
X	case ERASE:
X		gcv.foreground = bg;
X		gcv.background = bg;
X		gcv.function = GXcopy;
X		break;
X	case INV_PAINT:
X		gcv.foreground = fg ^ bg;
X		gcv.background = bg;
X		gcv.function = GXxor;
X		break;
X	case MERGE:
X		gcv.foreground = fg;
X		gcv.background = bg;
X		gcv.function = GXor;
X		break;
X	}
X	
X	ngc = XCreateGC(tool_d, XtWindow(canvas_sw), gcmask, &gcv);
X	XCopyGC(tool_d, gc, ~(gcmask), ngc);	/* add main gc's values to the new one */
X	return (ngc);
X}
X
Xstatic GC	msg_gccache[0x10];
X
Xinit_gc()
X{
X	Pixel	bg, fg;
X	Arg	tmp_arg[2];
X	
X	gccache[PAINT] = makegc(PAINT, x_fg_color.pixel, x_bg_color.pixel);
X	gccache[ERASE] = makegc(ERASE, x_fg_color.pixel, x_bg_color.pixel);
X	gccache[INV_PAINT] = makegc(INV_PAINT, x_fg_color.pixel,
X				    x_bg_color.pixel);
X	gccache[MERGE] = makegc(MERGE, x_fg_color.pixel, x_bg_color.pixel);
X
X	/* Need to get the values so we can make GC's which XOR correctly */
X	XtSetArg(tmp_arg[0], XtNforeground, &fg);
X	XtSetArg(tmp_arg[1], XtNbackground, &bg);
X	XtGetValues(msg_sw, tmp_arg, 2);
X
X	msg_gccache[PAINT] = makegc(PAINT, fg, bg);
X	msg_gccache[ERASE] = makegc(ERASE, fg, bg);
X	
X	XtSetArg(tmp_arg[0], XtNforeground, &fg);
X	XtSetArg(tmp_arg[1], XtNbackground, &bg);
X	XtGetValues(topruler_sw, tmp_arg, 2);
X
X	topgc = makegc(INV_PAINT, fg, bg);
X	
X	XtSetArg(tmp_arg[0], XtNforeground, &fg);
X	XtSetArg(tmp_arg[1], XtNbackground, &bg);
X	XtGetValues(sideruler_sw, tmp_arg, 2);
X	
X	sidegc = makegc(INV_PAINT, fg, bg);
X}
X
X/* grey images for fill patterns */
X
Xstatic char  fill_images[NUMFILLPATS][8] = {
X   {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
X   {0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00},
X   {0x00, 0x40, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00},
X   {0x00, 0x40, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00},
X   {0x00, 0x44, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00},
X   {0x00, 0x44, 0x00, 0x10, 0x00, 0x44, 0x00, 0x00},
X   {0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00},
X   {0x88, 0x00, 0x32, 0x00, 0x88, 0x00, 0x23, 0x00},
X   {0xc4, 0x00, 0x31, 0x00, 0x8c, 0x00, 0x23, 0x00},
X   {0x99, 0x00, 0xcc, 0x00, 0x66, 0x00, 0x33, 0x00},
X   {0x55, 0x00, 0x55, 0x00, 0x55, 0x00, 0x55, 0x00},
X   {0x55, 0x22, 0x55, 0x08, 0x55, 0x22, 0x55, 0x00},
X   {0x55, 0xa2, 0x55, 0x88, 0x55, 0xa2, 0x55, 0x2a},
X   {0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa},
X   {0x55, 0xaa, 0x77, 0xaa, 0x55, 0xaa, 0xdd, 0xaa},
X   {0x55, 0xae, 0x5f, 0xae, 0x55, 0xea, 0xf5, 0xea},
X   {0x5d, 0xb6, 0x7f, 0xd5, 0x7f, 0xb6, 0x5d, 0xaa},
X   {0x77, 0xff, 0x77, 0xaa, 0x77, 0xff, 0x77, 0xaa},
X   {0x77, 0xdd, 0x7f, 0xbe, 0x7f, 0xdd, 0x77, 0xaa},
X   {0x77, 0xff, 0x7f, 0xbe, 0x7f, 0xff, 0x77, 0xaa},
X   {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
X   };
X
X/* create the gc's for area fill (PAINT and ERASE) */
X
Xinit_fill_gc()
X	{
X	XGCValues gcv;
X	int i;
X
X	gcv.fill_style = FillStippled;	/* Tiled */;
X	gcv.arc_mode = ArcPieSlice;	/* fill mode for arcs */
X	for (i=0; i<NUMFILLPATS; i++)
X		{
X		/******************************************************
X		fill_pm[i] = XCreatePixmapFromBitmapData(tool_d, XtWindow(canvas_sw),
X				fill_images[i],8,8,
X				x_fg_color.pixel,x_bg_color.pixel,
X				DefaultDepthOfScreen(tool_s));
X		*******************************************************/
X		/* if we want the area fill to be "meshed" on top of existing
X		   filled objects, then we must use stippling.  This means
X		   creating a one-plane bitmap and setting the stipple part
X		   of the gc and selecting stipple fill mode.  This created
X		   a problem on the color machines in that it picked random
X		   colors to paint the stipple.  It should have used the 
X		   foreground color in the given gc with the FillPolygon call,
X		   but it didn't.
X		*/
X		/* use the following for stippling */
X		fill_pm[i] = XCreateBitmapFromData(tool_d, XtWindow(canvas_sw),
X				fill_images[i],8,8);
X		/* create pixmaps of area-fill colors for indicator */
X		ind_fill_pm[i] = XCreatePixmapFromBitmapData(tool_d, XtWindow(canvas_sw),
X				fill_images[i],8,8,
X				x_fg_color.pixel,x_bg_color.pixel,
X				DefaultDepthOfScreen(tool_s));
X		fill_gc[i] = makegc(PAINT, x_fg_color.pixel, x_bg_color.pixel);
X		un_fill_gc[i] = makegc(ERASE, x_fg_color.pixel, x_bg_color.pixel);
X		gcv.stipple = fill_pm[i];
X		XChangeGC(tool_d, fill_gc[i], GCStipple|GCFillStyle|GCArcMode, &gcv);
X		XChangeGC(tool_d, un_fill_gc[i], GCStipple|GCFillStyle|GCArcMode, &gcv);
X		}
X	}
X
X/*
X**	The next routine is easy to implement, but I haven't missed
X**	it yet. Generally it is a bad idea to warp the mouse without
X**	the users consent, so maybe the original code is wrong?
X*/
Xwin_setmouseposition(w,x,y)
X	FDTYPE		w;
X	int		x, y;
X{
X}
X
X/* popup a confirmation window */
X
Xint wmgr_confirm(w, message)
X	Window		w;
X	char		*message;
X{
X	static TOOL	label = NULL, confirm = NULL;
X	XEvent		event;
X	Arg	tmp_args[2];
X
X	if( confirm == NULL )
X	{
X		int		rootx, rooty;
X		Window		win;
X		Arg		confirm_args[5];
X		
X		XTranslateCoordinates(tool_d, w, XDefaultRootWindow(tool_d),
X				      150, 200, &rootx, &rooty, &win);
X		XtSetArg(confirm_args[0], XtNallowShellResize, True);
X		XtSetArg(confirm_args[1], XtNx, rootx);
X		XtSetArg(confirm_args[2], XtNy, rooty);
X		confirm = XtCreatePopupShell("confirm",
X					     overrideShellWidgetClass, tool,
X					     confirm_args, 3);
X		XtSetArg(tmp_args[0], XtNfont, bold_font);
X		label = XtCreateManagedWidget("label", labelWidgetClass,
X					      confirm, tmp_args, 1);
X	}
X	
X	XtSetArg(tmp_args[0], XtNlabel, message);
X	XtSetValues(label, tmp_args, 1);
X	XtPopup(confirm, XtGrabNone);
X	for (;;)
X	{
X		XMaskEvent(tool_d, ButtonPressMask|ExposureMask, &event);
X		if (event.type == ButtonPress)
X		{
X			XtPopdown(confirm);
X			if (((XButtonEvent *)&event)->button == Button1)
X				return (-1);
X			else
X				return (0);
X		}
X		/* pass all other events */
X		XtDispatchEvent(&event);
X	}
X/*NOTREACHED*/
X}
X
Xprompt_string(prompt, reply)
X	char		*prompt, *reply;
X{
X	register int	x, y;
X	register int	len, width;
X	register char	*r = reply;
X	XEvent		event;
X	register XKeyEvent	*ke = (XKeyEvent *)&event;
X	char		buf[1];
X	XWindowAttributes	attr;
X
X	XClearArea(tool_d, msgswfd, 0, 0, 0, 0, False);
X	/* uses knowledge that msg_gccache[PAINT] uses roman_font - tsk */
X	len = strlen(prompt);
X	width = char_width(roman_font);
X	y = char_height(roman_font) + 2;
X	XDrawString(tool_d, msgswfd, msg_gccache[PAINT], 2, y, prompt, len);
X	x = width * len + 4;
X	XGetWindowAttributes(tool_d, msgswfd, &attr);
X	XSelectInput(tool_d, msgswfd, attr.your_event_mask | KeyPressMask);
X	for (;;)
X	{
X		XWindowEvent(tool_d, msgswfd, KeyPressMask, &event);
X		if (event.type != KeyPress)
X			continue;
X		if (XLookupString(ke, buf, sizeof(buf), NULL, NULL) <= 0)
X			continue;
X		switch (buf[0])
X		{
X		case CTRL_H:
X		case DEL:
X			if (r != reply)
X			{
X				x -= width;
X				--r;
X				XDrawString(tool_d, msgswfd, msg_gccache[ERASE],
X					x, y, r, 1);
X			}
X			break;
X		case CTRL_U:
X		case CTRL_X:
X			while (r != reply)
X			{
X				x -= width;
X				--r;
X				XDrawString(tool_d, msgswfd, msg_gccache[ERASE],
X					x, y, r, 1);
X			}
X			break;
X		case CR:
X		case NL:
X			*r = '\0';
X			XClearArea(tool_d, msgswfd, 0, 0, 0, 0, False);
X			return;
X		default:
X			if (buf[0] < ' ' || buf[0] > '~')
X				continue;
X			XDrawString(tool_d, msgswfd, msg_gccache[PAINT],
X				x, y, buf, 1);
X			x += width;
X			*r++ = buf[0];
X			break;
X		}
X	}
X}
X
Xstatic void
XCvtStringToFloat(args, num_args, fromVal, toVal)
XXrmValuePtr	args;
XCardinal	*num_args;
XXrmValuePtr	fromVal;
XXrmValuePtr	toVal;
X{
X	static	float	f;
X
X	if(*num_args != 0 )
X		XtWarning("String to Float conversion needs no extra arguments");
X	if(sscanf((char *)fromVal->addr, "%f", &f) == 1)
X	{
X		(*toVal).size = sizeof(float);
X		(*toVal).addr = (caddr_t) &f;
X	}
X	else
X		XtStringConversionWarning((char *) fromVal->addr, "Float");
X}
X
Xstatic void
XCvtIntToFloat(args, num_args, fromVal, toVal)
XXrmValuePtr	args;
XCardinal	*num_args;
XXrmValuePtr	fromVal;
XXrmValuePtr	toVal;
X{
X	static	float	f;
X
X	if(*num_args != 0 )
X		XtWarning("Int to Float conversion needs no extra arguments");
X	f = *(int *)fromVal->addr;
X	(*toVal).size = sizeof(float);
X	(*toVal).addr = (caddr_t) &f;
X}
X
Xfix_converters()
X{
X	XtAddConverter("String", "Float", CvtStringToFloat, NULL, 0);
X	XtAddConverter("Int", "Float", CvtIntToFloat, NULL, 0);
X}
X
Xpw_vector(w, x1, y1, x2, y2, op, line_width)
XWindow w;
Xint x1, y1, x2, y2, op, line_width;
X	{
X	set_line_width(line_width,op);
X	XDrawLine(tool_d, w, gccache[op], x1, y1, x2, y2);
X	}
X
X
Xpw_put(w, x, y, op, line_width)
XWindow w;
Xint x,y,op,line_width;
X	{
X	op = op? PAINT : ERASE;
X	set_line_width(line_width,op);
X	XDrawPoint(tool_d, w, gccache[op], x, y);
X	}
X
Xpw_lines(w, points, npoints, op, line_width, area_fill)
XWindow w;
Xint npoints;
XXPoint *points;
Xint op,line_width,area_fill;
X	{
X	GC gc;
X
X	set_line_width(line_width,op);
X	if (area_fill)
X		{
X		if (op == PAINT)
X			gc = fill_gc[area_fill-1];
X		else
X			gc = un_fill_gc[area_fill-1];
X		XFillPolygon(tool_d, w, gc, points, npoints,
X			Complex, CoordModeOrigin);
X		}
X	XDrawLines(tool_d, w, gccache[op], points, npoints, CoordModeOrigin);
X	}
X
Xpw_rectangle(w, x, y, width, height, op, line_width)
XWindow w;
Xint x,y,width,height;
Xint op,line_width;
X	{
X	set_line_width(width,op);
X	XDrawRectangle(tool_d, w, gccache[op], x, y, width, height);
X	}
X
Xset_line_width(width,op)
Xint width,op;
X	{
X	XGCValues gcv;
X
X	if (width != cur_thickness[op])
X		{
X		gcv.line_width = width == 1? 0: width;	/* use 0 width for 1 (much faster) */
X		XChangeGC(tool_d, gccache[op], GCLineWidth, &gcv);
X		cur_thickness[op] = width;
X		}
X	}
X
X#ifdef  sparc
X
X#include <stdio.h>
X
XFREE ( x )    /*-- disable free --*/
X    char *x ;
X{
X    fprintf( stderr, "FREE -- %8x\n", x ) ;
X}
XCFREE ( x )   /*-- disable cfree --*/
X    char *x ;
X{
X    fprintf( stderr, "FREE -- %8x\n", x ) ;
X}
X
X#endif  sparc
END_OF_FILE
if test 11050 -ne `wc -c <'xfig/xtra.c'`; then
    echo shar: \"'xfig/xtra.c'\" unpacked with wrong size!
fi
# end of 'xfig/xtra.c'
fi
echo shar: End of archive 8 \(of 15\).
cp /dev/null ark8isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 15 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
dan
-----------------------------------------------------------
		    O'Reilly && Associates
		argv@sun.com / argv@ora.com
	   632 Petaluma Ave, Sebastopol, CA 95472 
     800-338-NUTS, in CA: 800-533-NUTS, FAX 707-829-0104
    Opinions expressed reflect those of the author only.