[comp.sources.x] v06i019: xfig, Part11/15

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

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



#! /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 11 (of 15)."
# Contents:  xfig/addpt.c xfig/copy.area.c xfig/copy.c xfig/drag.c
#   xfig/intspline.c xfig/resources.h xfig/text.c
# Wrapped by argv@turnpike on Wed Feb 28 10:53:23 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'xfig/addpt.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/addpt.c'\"
else
echo shar: Extracting \"'xfig/addpt.c'\" \(7892 characters\)
sed "s/^X//" >'xfig/addpt.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 : August 1985.
X *	2nd revision : March 1988.
X *
X *	%W%	%G%
X*/
X#include "fig.h"
X#include "resources.h"
X#include "alloc.h"
X#include "func.h"
X#include "object.h"
X#include "paintop.h"
X
X#define			TOLERANCE	3
X
Xextern F_line		*line_search();
Xextern F_spline		*spline_search();
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();
Xextern			determine_angle();
X
Xextern int		manhattan_mode, mountain_mode;
Xextern int		latexline_mode, latexarrow_mode;
Xextern int		cur_x, cur_y, fix_x, fix_y;
Xextern int		pointmarker_shown;
Xextern F_line		*line;
Xextern F_spline		*spline;
X
Xextern F_point		*added_point;
Xextern F_point		*left_point, *right_point;
X
X			init_point_adding();
X			move_addedpoint();
X			fix_linepoint_adding();
X			mm_fix_linepoint_adding();
X			fix_splinepoint_adding();
X			latex_elasticline();
X
Xstatic F_line		*cur_line;
Xstatic F_spline		*cur_spline;
X
Xpoint_adding_selected()
X{
X	canvas_kbd_proc = null_proc;
X	canvas_locmove_proc = null_proc;
X	canvas_leftbut_proc = init_point_adding;
X	canvas_middlebut_proc = null_proc;
X	canvas_rightbut_proc = set_popupmenu;
X	set_cursor(&pick9_cursor);
X	}
X
Xinit_point_adding(x, y)
Xint	x, y;
X{
X	int	px, py;
X
X	if ((cur_line = line_search(x, y, TOLERANCE, &px, &py)) != NULL) {
X	    if (cur_line->type == T_BOX || cur_line->type == T_ARC_BOX) {
X		put_msg("Adding points to a box is not allowed");
X		return;
X		}
X	    init_linepointadding(px, py);
X	    }
X	else if ((cur_spline = spline_search(x,y,TOLERANCE,&px,&py)) != NULL){
X	    init_splinepointadding(px, py);
X	    }
X	else {
X	    return;
X	    }
X	canvas_leftbut_proc = canvas_rightbut_proc = null_proc;
X	erase_pointmarker();
X	}
X
Xwrapup_pointadding()
X{
X	show_pointmarker();
X	point_adding_selected();
X	}
X
X/**************************  spline  *******************************/
X
Xinit_splinepointadding(px, py)
Xint		px, py;
X{
X	find_endpoints(cur_spline->points, px, py, &left_point, &right_point);
X	set_temp_cursor(&null_cursor);
X	win_setmouseposition(canvas_swfd, px, py);
X	cur_x = px; cur_y = py;
X	if (left_point == NULL && closed_spline(cur_spline)) {
X	    /* The added_point is between the 1st and 2nd point. */
X	    left_point = right_point;
X	    right_point = right_point->next;
X	    }
X	draw_addedlink(INV_PAINT);
X	canvas_locmove_proc = move_addedpoint;
X	canvas_middlebut_proc = fix_splinepoint_adding;
X	}
X
Xfix_splinepoint_adding(x, y)
Xint	x, y;
X{
X	F_point		*p;
X
X	if (NULL == (Point_malloc(p))) {
X	    put_msg(Err_mem);
X	    wrapup_pointadding();
X	    return;
X	    }
X	clean_up();
X	added_point = p;
X	added_point->x = x;
X	added_point->y = y;
X	draw_addedlink(INV_PAINT);
X	if (-1 == splinepoint_adding(cur_spline, added_point))
X	    wrapup_pointadding();
X	set_action_object(F_ADD_POINT, O_SPLINE);
X	set_latestspline(cur_spline);
X	wrapup_pointadding();
X	}
X
X/*
XWarning: Do not change the value of the pointers left_point and
Xright_point.  Added_point is always inserted between left_point
Xand right_point, except in two cases. 
X	(1) left_point is NULL, the added_point will be prepended
X		to the list of points. This case will never
X		occur if the spline is closed (periodic).
X	(2) right_point is NULL, the added_point will be appended
X		to the end of the list.
X*/
X
Xsplinepoint_adding(spline, added_point)
XF_spline	*spline;
XF_point		*added_point;
X{
X	F_control	*c;
X
X	set_temp_cursor(&wait_cursor);
X	if (int_spline(spline)) {	/* Interpolated spline */
X	    if (NULL == (Control_malloc(c))) {
X		put_msg(Err_mem);
X		return(-1);
X		}
X	    }
X	pw_batch_on(canvas_pixwin);
X	if (pointmarker_shown) toggle_splinepointmarker(spline);  
X	draw_spline(spline, ERASE); /* erase old spline */
X	if (left_point == NULL) {
X	    added_point->next = spline->points;
X	    spline->points = added_point;
X	    }
X	else {
X	    added_point->next = right_point;
X	    left_point->next = added_point;
X	    }
X
X	if (int_spline(spline)) {	/* Interpolated spline */
X	    c->next = spline->controls;
X	    spline->controls = c;
X	    remake_control_points(spline);
X	    }
X
X	draw_spline(spline, PAINT); /* draw the modified spline */
X	if (pointmarker_shown) toggle_splinepointmarker(spline);  
X	pw_batch_off(canvas_pixwin);
X	reset_cursor();
X	set_modifiedflag();
X	return(1);
X	}
X
X/***************************  line  ********************************/
X
Xinit_linepointadding(px, py)
Xint	px, py;
X{
X	find_endpoints(cur_line->points,px,py,&left_point,&right_point);
X	set_temp_cursor(&null_cursor);
X	win_setmouseposition(canvas_swfd, px, py);
X	cur_x = fix_x = px; cur_y = fix_y = py;
X	if (left_point == NULL && cur_line->type == T_POLYGON) {
X	    left_point = right_point;
X	    right_point = right_point->next;
X	    }
X	if (left_point != NULL && right_point != NULL)
X	    draw_line_segment(cur_line->style, cur_line->style_val,
X		left_point->x, left_point->y,
X		right_point->x, right_point->y, INV_PAINT, 1);
X	draw_addedlink(INV_PAINT);
X	if (latexline_mode || latexarrow_mode) {
X	    canvas_locmove_proc = latex_elasticline;
X	    canvas_middlebut_proc = mm_fix_linepoint_adding;
X	    }
X	if( (mountain_mode || manhattan_mode) &&
X	   (left_point == NULL || right_point == NULL) )
X	{
X		canvas_locmove_proc = determine_angle;
X		canvas_middlebut_proc = mm_fix_linepoint_adding;
X	}
X	else
X	{
X		canvas_locmove_proc = move_addedpoint;
X		canvas_middlebut_proc = fix_linepoint_adding;
X	}
X	}
X
Xfix_linepoint_adding(x, y)
Xint	x, y;
X{
X	F_point		*p;
X
X	if (NULL == (Point_malloc(p))) {
X	    put_msg(Err_mem);
X	    wrapup_pointadding();
X	    return;
X	    }
X	clean_up();
X	added_point = p;
X	added_point->x = x;
X	added_point->y = y;
X	draw_addedlink(INV_PAINT);
X	linepoint_adding(cur_line, added_point);
X	set_action_object(F_ADD_POINT, O_POLYLINE);
X	set_latestline(cur_line);
X	wrapup_pointadding();
X	}
X
Xmm_fix_linepoint_adding(x, y)
Xint	x, y;
X{
X	F_point		*p;
X
X	if (NULL == (Point_malloc(p))) {
X	    put_msg(Err_mem);
X	    wrapup_pointadding();
X	    return;
X	    }
X	clean_up();
X	added_point = p;
X	added_point->x = cur_x;
X	added_point->y = cur_y;
X	draw_addedlink(INV_PAINT);
X	linepoint_adding(cur_line, added_point);
X	set_action_object(F_ADD_POINT, O_POLYLINE);
X	set_latestline(cur_line);
X	wrapup_pointadding();
X	}
X
Xlinepoint_adding(line, added_point)
XF_line	*line;
XF_point	*added_point;
X{
X	if (pointmarker_shown) toggle_linepointmarker(line);
X	draw_line(line, ERASE);
X	if (left_point == NULL) {
X	    added_point->next = line->points;
X	    line->points = added_point;
X	    }
X	else {
X	    added_point->next = left_point->next;
X	    left_point->next = added_point;
X	    }
X	draw_line(line, PAINT);
X	if (pointmarker_shown) toggle_linepointmarker(line);  
X	set_modifiedflag();
X	}
X
X/*******************************************************************/
X
X/*
XIf (x,y) is close to a point, q, fp points to q and sp points to q->next
X(right).  However if q is the first point, fp contains NULL and sp points to q.
X*/
X
Xfind_endpoints(p, x, y, fp, sp)
XF_point	*p, **fp, **sp;
Xint	x, y;
X{
X	int	d;
X	F_point	*a = NULL, *b = p;
X
X	if (x == b->x && y == b->y) {
X	    *fp = a;
X	    *sp = b;
X	    return;
X	    }
X
X	for (a = p, b = p->next; b != NULL; a = b, b = b->next){
X	    if (x == b->x && y == b->y) {
X		*fp = b;
X		*sp = b->next;
X		return;
X		}
X	    if (close_to_vector(a->x, a->y, b->x, b->y, x, y, 1, 1.0, &d, &d)) {
X		*fp = a;
X		*sp = b;
X		return;
X		}
X	    }
X	*fp = a;
X	*sp = b;
X	}
X
Xdraw_addedlink(op)
Xint	op;
X{
X	if (left_point != NULL) {
X	    pw_vector(canvas_pixwin, left_point->x, left_point->y,
X			cur_x, cur_y, op, 1);
X	   }
X	if (right_point != NULL) {
X	    pw_vector(canvas_pixwin, right_point->x, 
X			right_point->y, cur_x, cur_y, op, 1);
X	    }
X	}
X
Xmove_addedpoint(x, y)
Xint	x, y;
X{
X	draw_addedlink(INV_PAINT);
X	cur_x = x;
X	cur_y = y;
X	draw_addedlink(INV_PAINT);
X	}
END_OF_FILE
if test 7892 -ne `wc -c <'xfig/addpt.c'`; then
    echo shar: \"'xfig/addpt.c'\" unpacked with wrong size!
fi
# end of 'xfig/addpt.c'
fi
if test -f 'xfig/copy.area.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/copy.area.c'\"
else
echo shar: Extracting \"'xfig/copy.area.c'\" \(8225 characters\)
sed "s/^X//" >'xfig/copy.area.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 "alloc.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			(*return_proc)();
Xextern			null_proc();
Xextern			set_popupmenu();
Xextern F_line		*line_search(), *copy_line();
Xextern F_arc		*arc_search(), *copy_arc();
Xextern F_ellipse	*ellipse_search(), *copy_ellipse();
Xextern F_text		*text_search(), *copy_text();
Xextern F_spline		*spline_search(), *copy_spline();
Xextern F_compound	*compound_search(), *copy_compound();
X
Xextern F_compound	objects;
X
Xextern int		fill_mode,cur_areafill;
Xextern int		copy_selected();
X			init_copy();
X
Xcopy_selected()
X{
X	canvas_kbd_proc = null_proc;
X	canvas_locmove_proc = null_proc;
X	canvas_leftbut_proc = init_copy;
X	canvas_middlebut_proc = null_proc;
X	canvas_rightbut_proc = set_popupmenu;
X	return_proc = copy_selected;
X	set_cursor(&pick15_cursor);
X	reset_action_on();
X	}
X
Xinit_copy(x, y)
Xint	x, y;
X{
X	F_line		*l, *line;
X	F_ellipse	*e, *ellipse;
X	F_text		*t, *text;
X	F_spline	*s, *spline;
X	F_arc		*a, *arc;
X	F_compound	*c, *compound;
X	int		px, py;
X
X	if ((c = compound_search(x, y, TOLERANCE, &px, &py)) != NULL) {
X	    compound = copy_compound(c);
X	    erase_pointmarker();
X	    set_temp_cursor(&null_cursor);
X	    win_setmouseposition(canvas_swfd, px, py);
X	    clean_up();
X	    set_action_object(F_CREATE, O_COMPOUND);
X	    insert_compound(&objects.compounds, compound);
X	    set_latestcompound(compound);
X	    init_compounddragging(compound, px, py);
X	    }
X	else if ((l = line_search(x, y, TOLERANCE, &px, &py)) != NULL) {
X	    line = copy_line(l);
X	    erase_pointmarker();
X	    set_temp_cursor(&null_cursor);
X	    win_setmouseposition(canvas_swfd, px, py);
X	    clean_up();
X	    set_action_object(F_CREATE, O_POLYLINE);
X	    insert_line(&objects.lines, line);
X	    set_latestline(line);
X	    init_linedragging(line, px, py);
X	    }
X	else if ((t = text_search(x, y)) != NULL) {
X	    text = copy_text(t);
X	    erase_pointmarker();
X	    set_temp_cursor(&null_cursor);
X	    clean_up();
X	    set_action_object(F_CREATE, O_TEXT);
X	    insert_text(&objects.texts, text);
X	    set_latesttext(text);
X	    init_textdragging(text, x, y);
X	    }
X	else if ((e = ellipse_search(x, y, TOLERANCE, &px, &py)) != NULL) {
X	    ellipse = copy_ellipse(e);
X	    erase_pointmarker();
X	    set_temp_cursor(&null_cursor);
X	    win_setmouseposition(canvas_swfd, px, py);
X	    clean_up();
X	    set_action_object(F_CREATE, O_ELLIPSE);
X	    insert_ellipse(&objects.ellipses, ellipse);
X	    set_latestellipse(ellipse);
X	    init_ellipsedragging(ellipse, px, py);
X	    }
X	else if ((a = arc_search(x, y, TOLERANCE, &px, &py)) != NULL) {
X	    arc = copy_arc(a);
X	    erase_pointmarker();
X	    set_temp_cursor(&null_cursor);
X	    win_setmouseposition(canvas_swfd, px, py);
X	    clean_up();
X	    set_action_object(F_CREATE, O_ARC);
X	    insert_arc(&objects.arcs, arc);
X	    set_latestarc(arc);
X	    init_arcdragging(arc, px, py);
X	    }
X	else if ((s = spline_search(x, y, TOLERANCE, &px, &py)) != NULL) {
X	    spline = copy_spline(s);
X	    erase_pointmarker();
X	    set_temp_cursor(&null_cursor);
X	    win_setmouseposition(canvas_swfd, px, py);
X	    clean_up();
X	    set_action_object(F_CREATE, O_SPLINE);
X	    insert_spline(&objects.splines, spline);
X	    set_latestspline(spline);
X	    init_splinedragging(spline, px, py);
X	    }
X	else
X	    return;
X	canvas_leftbut_proc = canvas_rightbut_proc = null_proc;
X	}
X
XF_arc *
Xcopy_arc(a)
XF_arc	*a;
X{
X	F_arc	*arc;
X
X	if (NULL == (Arc_malloc(arc))) {
X	    put_msg(Err_mem);
X	    return(NULL);
X	    }
X	*arc = *a;
X	arc->next = NULL;
X	/* added 3/1/89 B.V.Smith*/
X	if (fill_mode)
X		arc->area_fill = cur_areafill;
X	return(arc);
X	}
X
XF_ellipse *
Xcopy_ellipse(e)
XF_ellipse	*e;
X{
X	F_ellipse	*ellipse;
X
X	if (NULL == (Ellipse_malloc(ellipse))) {
X	    put_msg(Err_mem);
X	    return(NULL);
X	    }
X	*ellipse = *e;
X	ellipse->next = NULL;
X	/* added 3/1/89 B.V.Smith*/
X	if (fill_mode)
X		ellipse->area_fill = cur_areafill;
X	return(ellipse);
X	}
X
XF_line *
Xcopy_line(l)
XF_line	*l;
X{
X	F_line	*line;
X	F_point	*p, *point, *last_point;
X
X	if (NULL == (Line_malloc(line))) {
X	    put_msg(Err_mem);
X	    return(NULL);
X	    }
X	*line = *l;
X	line->points = Point_malloc(point);
X	last_point = point;
X	p = l->points;
X	*point = *p;
X	point->next = NULL;
X	for (p = p->next; p != NULL; p = p->next) {
X	    last_point->next = Point_malloc(point);
X	    if (point == NULL) return(NULL);
X	    *point = *p;
X	    point->next = NULL;
X	    last_point = point;
X	    }
X	line->next = NULL;
X	/* added 3/1/89 B.V.Smith*/
X	line->area_fill = 0;
X	if (line->type == T_BOX || line->type == T_POLYGON)
X	    if (fill_mode)
X		line->area_fill = cur_areafill;
X	return(line);
X	}
X
XF_spline *
Xcopy_spline(s)
XF_spline	*s;
X{
X	F_spline	*spline;
X	F_point		*p, *point, *last_point;
X	F_control	*cntrl_pnt, *cp, *last_cntrl_pnt;
X
X	if (NULL == (Spline_malloc(spline))) {
X	    put_msg(Err_mem);
X	    return(NULL);
X	    }
X	*spline = *s;
X	spline->next = NULL;
X
X	Point_malloc(point);
X	last_point = spline->points = point;
X	p = s->points;
X	*point = *p;
X	for (p = p->next; p != NULL; p = p->next) {
X	    last_point->next = Point_malloc(point);
X	    if (point == NULL) return(NULL);
X	    *point = *p;
X	    last_point = point;
X	    }
X	last_point->next = NULL;
X
X	spline->controls = NULL;
X	if (s->controls == NULL) return(spline);
X
X	last_cntrl_pnt = spline->controls = Control_malloc(cntrl_pnt);
X	cp = s->controls;
X	*cntrl_pnt = *cp;
X	for (cp = cp->next; cp != NULL; cp = cp->next) {
X	    last_cntrl_pnt->next = Control_malloc(cntrl_pnt);
X	    if (cntrl_pnt == NULL) return(NULL);
X	    *cntrl_pnt = *cp;
X	    last_cntrl_pnt = cntrl_pnt;
X	    }
X	last_cntrl_pnt->next = NULL;
X	/* added 3/1/89 B.V.Smith*/
X	if (fill_mode && (spline->type == T_CLOSED_NORMAL || 
X			  spline->type == T_CLOSED_INTERPOLATED))
X		spline->area_fill = cur_areafill;
X
X	return(spline);
X	}
X
XF_text *
Xcopy_text(t)
XF_text	*t;
X{
X	F_text		*text;
X	extern char	*calloc();
X
X	if (NULL == (Text_malloc(text))) {
X	    put_msg(Err_mem);
X	    return(NULL);
X	    }
X	*text = *t;
X	text->cstring = calloc((unsigned)(strlen(t->cstring)+1), sizeof(char));
X	if (text->cstring == NULL) {
X	    free((char*)text);
X	    put_msg(Err_mem);
X	    return(NULL);
X	    }
X	strcpy(text->cstring, t->cstring);
X	text->next = NULL;
X	return(text);
X	}
X
XF_compound *
Xcopy_compound(c)
XF_compound	*c;
X{
X	F_ellipse	*e, *ee;
X	F_arc		*a, *aa;
X	F_line		*l, *ll;
X	F_spline	*s, *ss;
X	F_text		*t, *tt;
X	F_compound	*cc, *ccc, *compound;
X
X	if (NULL == (Compound_malloc(compound))) {
X	    put_msg(Err_mem);
X	    return(NULL);
X	    }
X	compound->nwcorner = c->nwcorner;
X	compound->secorner = c->secorner;
X	compound->arcs = NULL;
X	compound->ellipses = NULL;
X	compound->lines = NULL;
X	compound->splines = NULL;
X	compound->texts = NULL;
X	compound->compounds = NULL;
X	compound->next = NULL;
X	for (e = c->ellipses; e != NULL; e = e->next) {
X	    if (NULL == (ee = copy_ellipse(e))) {
X		put_msg(Err_mem);
X		return(NULL);
X		}
X	    insert_ellipse(&compound->ellipses, ee);
X	    }
X	for (a = c->arcs; a != NULL; a = a->next) {
X	    if (NULL == (aa = copy_arc(a))) {
X		put_msg(Err_mem);
X		return(NULL);
X		}
X	    insert_arc(&compound->arcs, aa);
X	    }
X	for (l = c->lines; l != NULL; l = l->next) {
X	    if (NULL == (ll = copy_line(l))) {
X		put_msg(Err_mem);
X		return(NULL);
X		}
X	    insert_line(&compound->lines, ll);
X	    }
X	for (s = c->splines; s != NULL; s = s->next) {
X	    if (NULL == (ss = copy_spline(s))) {
X		put_msg(Err_mem);
X		return(NULL);
X		}
X	    insert_spline(&compound->splines, ss);
X	    }
X	for (t = c->texts; t != NULL; t = t->next) {
X	    if (NULL == (tt = copy_text(t))) {
X		put_msg(Err_mem);
X		return(NULL);
X		}
X	    insert_text(&compound->texts, tt);
X	    }
X	for (cc = c->compounds; cc != NULL; cc = cc->next) {
X	    if (NULL == (ccc = copy_compound(cc))) {
X		put_msg(Err_mem);
X		return(NULL);
X		}
X	    insert_compound(&compound->compounds, ccc);
X	    }
X	return(compound);
X	}
END_OF_FILE
if test 8225 -ne `wc -c <'xfig/copy.area.c'`; then
    echo shar: \"'xfig/copy.area.c'\" unpacked with wrong size!
fi
# end of 'xfig/copy.area.c'
fi
if test -f 'xfig/copy.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/copy.c'\"
else
echo shar: Extracting \"'xfig/copy.c'\" \(7706 characters\)
sed "s/^X//" >'xfig/copy.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 "alloc.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			(*return_proc)();
Xextern			null_proc();
Xextern			set_popupmenu();
Xextern F_line		*line_search(), *copy_line();
Xextern F_arc		*arc_search(), *copy_arc();
Xextern F_ellipse	*ellipse_search(), *copy_ellipse();
Xextern F_text		*text_search(), *copy_text();
Xextern F_spline		*spline_search(), *copy_spline();
Xextern F_compound	*compound_search(), *copy_compound();
X
Xextern F_compound	objects;
X
Xextern int		copy_selected();
X			init_copy();
X
Xcopy_selected()
X{
X	canvas_kbd_proc = null_proc;
X	canvas_locmove_proc = null_proc;
X	canvas_leftbut_proc = init_copy;
X	canvas_middlebut_proc = null_proc;
X	canvas_rightbut_proc = set_popupmenu;
X	return_proc = copy_selected;
X	set_cursor(&pick15_cursor);
X	reset_action_on();
X	}
X
Xinit_copy(x, y)
Xint	x, y;
X{
X	F_line		*l, *line;
X	F_ellipse	*e, *ellipse;
X	F_text		*t, *text;
X	F_spline	*s, *spline;
X	F_arc		*a, *arc;
X	F_compound	*c, *compound;
X	int		px, py;
X
X	if ((c = compound_search(x, y, TOLERANCE, &px, &py)) != NULL) {
X	    compound = copy_compound(c);
X	    erase_pointmarker();
X	    set_temp_cursor(&null_cursor);
X	    win_setmouseposition(canvas_swfd, px, py);
X	    clean_up();
X	    set_action_object(F_CREATE, O_COMPOUND);
X	    insert_compound(&objects.compounds, compound);
X	    set_latestcompound(compound);
X	    init_compounddragging(compound, px, py);
X	    }
X	else if ((l = line_search(x, y, TOLERANCE, &px, &py)) != NULL) {
X	    line = copy_line(l);
X	    erase_pointmarker();
X	    set_temp_cursor(&null_cursor);
X	    win_setmouseposition(canvas_swfd, px, py);
X	    clean_up();
X	    set_action_object(F_CREATE, O_POLYLINE);
X	    insert_line(&objects.lines, line);
X	    set_latestline(line);
X	    init_linedragging(line, px, py);
X	    }
X	else if ((t = text_search(x, y)) != NULL) {
X	    text = copy_text(t);
X	    erase_pointmarker();
X	    set_temp_cursor(&null_cursor);
X	    clean_up();
X	    set_action_object(F_CREATE, O_TEXT);
X	    insert_text(&objects.texts, text);
X	    set_latesttext(text);
X	    init_textdragging(text, x, y);
X	    }
X	else if ((e = ellipse_search(x, y, TOLERANCE, &px, &py)) != NULL) {
X	    ellipse = copy_ellipse(e);
X	    erase_pointmarker();
X	    set_temp_cursor(&null_cursor);
X	    win_setmouseposition(canvas_swfd, px, py);
X	    clean_up();
X	    set_action_object(F_CREATE, O_ELLIPSE);
X	    insert_ellipse(&objects.ellipses, ellipse);
X	    set_latestellipse(ellipse);
X	    init_ellipsedragging(ellipse, px, py);
X	    }
X	else if ((a = arc_search(x, y, TOLERANCE, &px, &py)) != NULL) {
X	    arc = copy_arc(a);
X	    erase_pointmarker();
X	    set_temp_cursor(&null_cursor);
X	    win_setmouseposition(canvas_swfd, px, py);
X	    clean_up();
X	    set_action_object(F_CREATE, O_ARC);
X	    insert_arc(&objects.arcs, arc);
X	    set_latestarc(arc);
X	    init_arcdragging(arc, px, py);
X	    }
X	else if ((s = spline_search(x, y, TOLERANCE, &px, &py)) != NULL) {
X	    spline = copy_spline(s);
X	    erase_pointmarker();
X	    set_temp_cursor(&null_cursor);
X	    win_setmouseposition(canvas_swfd, px, py);
X	    clean_up();
X	    set_action_object(F_CREATE, O_SPLINE);
X	    insert_spline(&objects.splines, spline);
X	    set_latestspline(spline);
X	    init_splinedragging(spline, px, py);
X	    }
X	else
X	    return;
X	canvas_leftbut_proc = canvas_rightbut_proc = null_proc;
X	}
X
XF_arc *
Xcopy_arc(a)
XF_arc	*a;
X{
X	F_arc	*arc;
X
X	if (NULL == (Arc_malloc(arc))) {
X	    put_msg(Err_mem);
X	    return(NULL);
X	    }
X	*arc = *a;
X	arc->next = NULL;
X	return(arc);
X	}
X
XF_ellipse *
Xcopy_ellipse(e)
XF_ellipse	*e;
X{
X	F_ellipse	*ellipse;
X
X	if (NULL == (Ellipse_malloc(ellipse))) {
X	    put_msg(Err_mem);
X	    return(NULL);
X	    }
X	*ellipse = *e;
X	ellipse->next = NULL;
X	return(ellipse);
X	}
X
XF_line *
Xcopy_line(l)
XF_line	*l;
X{
X	F_line	*line;
X	F_point	*p, *point, *last_point;
X
X	if (NULL == (Line_malloc(line))) {
X	    put_msg(Err_mem);
X	    return(NULL);
X	    }
X	*line = *l;
X	line->points = Point_malloc(point);
X	last_point = point;
X	p = l->points;
X	*point = *p;
X	point->next = NULL;
X	for (p = p->next; p != NULL; p = p->next) {
X	    last_point->next = Point_malloc(point);
X	    if (point == NULL) return(NULL);
X	    *point = *p;
X	    point->next = NULL;
X	    last_point = point;
X	    }
X	line->next = NULL;
X	return(line);
X	}
X
XF_spline *
Xcopy_spline(s)
XF_spline	*s;
X{
X	F_spline	*spline;
X	F_point		*p, *point, *last_point;
X	F_control	*cntrl_pnt, *cp, *last_cntrl_pnt;
X
X	if (NULL == (Spline_malloc(spline))) {
X	    put_msg(Err_mem);
X	    return(NULL);
X	    }
X	*spline = *s;
X	spline->next = NULL;
X
X	Point_malloc(point);
X	last_point = spline->points = point;
X	p = s->points;
X	*point = *p;
X	for (p = p->next; p != NULL; p = p->next) {
X	    last_point->next = Point_malloc(point);
X	    if (point == NULL) return(NULL);
X	    *point = *p;
X	    last_point = point;
X	    }
X	last_point->next = NULL;
X
X	spline->controls = NULL;
X	if (s->controls == NULL) return(spline);
X
X	last_cntrl_pnt = spline->controls = Control_malloc(cntrl_pnt);
X	cp = s->controls;
X	*cntrl_pnt = *cp;
X	for (cp = cp->next; cp != NULL; cp = cp->next) {
X	    last_cntrl_pnt->next = Control_malloc(cntrl_pnt);
X	    if (cntrl_pnt == NULL) return(NULL);
X	    *cntrl_pnt = *cp;
X	    last_cntrl_pnt = cntrl_pnt;
X	    }
X	last_cntrl_pnt->next = NULL;
X
X	return(spline);
X	}
X
XF_text *
Xcopy_text(t)
XF_text	*t;
X{
X	F_text		*text;
X	extern char	*calloc();
X
X	if (NULL == (Text_malloc(text))) {
X	    put_msg(Err_mem);
X	    return(NULL);
X	    }
X	*text = *t;
X	text->cstring = calloc((unsigned)(strlen(t->cstring)+1), sizeof(char));
X	if (text->cstring == NULL) {
X	    free((char*)text);
X	    put_msg(Err_mem);
X	    return(NULL);
X	    }
X	strcpy(text->cstring, t->cstring);
X	text->next = NULL;
X	return(text);
X	}
X
XF_compound *
Xcopy_compound(c)
XF_compound	*c;
X{
X	F_ellipse	*e, *ee;
X	F_arc		*a, *aa;
X	F_line		*l, *ll;
X	F_spline	*s, *ss;
X	F_text		*t, *tt;
X	F_compound	*cc, *ccc, *compound;
X
X	if (NULL == (Compound_malloc(compound))) {
X	    put_msg(Err_mem);
X	    return(NULL);
X	    }
X	compound->nwcorner = c->nwcorner;
X	compound->secorner = c->secorner;
X	compound->arcs = NULL;
X	compound->ellipses = NULL;
X	compound->lines = NULL;
X	compound->splines = NULL;
X	compound->texts = NULL;
X	compound->compounds = NULL;
X	compound->next = NULL;
X	for (e = c->ellipses; e != NULL; e = e->next) {
X	    if (NULL == (ee = copy_ellipse(e))) {
X		put_msg(Err_mem);
X		return(NULL);
X		}
X	    insert_ellipse(&compound->ellipses, ee);
X	    }
X	for (a = c->arcs; a != NULL; a = a->next) {
X	    if (NULL == (aa = copy_arc(a))) {
X		put_msg(Err_mem);
X		return(NULL);
X		}
X	    insert_arc(&compound->arcs, aa);
X	    }
X	for (l = c->lines; l != NULL; l = l->next) {
X	    if (NULL == (ll = copy_line(l))) {
X		put_msg(Err_mem);
X		return(NULL);
X		}
X	    insert_line(&compound->lines, ll);
X	    }
X	for (s = c->splines; s != NULL; s = s->next) {
X	    if (NULL == (ss = copy_spline(s))) {
X		put_msg(Err_mem);
X		return(NULL);
X		}
X	    insert_spline(&compound->splines, ss);
X	    }
X	for (t = c->texts; t != NULL; t = t->next) {
X	    if (NULL == (tt = copy_text(t))) {
X		put_msg(Err_mem);
X		return(NULL);
X		}
X	    insert_text(&compound->texts, tt);
X	    }
X	for (cc = c->compounds; cc != NULL; cc = cc->next) {
X	    if (NULL == (ccc = copy_compound(cc))) {
X		put_msg(Err_mem);
X		return(NULL);
X		}
X	    insert_compound(&compound->compounds, ccc);
X	    }
X	return(compound);
X	}
END_OF_FILE
if test 7706 -ne `wc -c <'xfig/copy.c'`; then
    echo shar: \"'xfig/copy.c'\" unpacked with wrong size!
fi
# end of 'xfig/copy.c'
fi
if test -f 'xfig/drag.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/drag.c'\"
else
echo shar: Extracting \"'xfig/drag.c'\" \(7285 characters\)
sed "s/^X//" >'xfig/drag.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 "font.h"
X#include "object.h"
X#include "paintop.h"
X
Xextern F_pos		last_position, new_position;  /* undo.c   */
Xextern int		foreground_color, background_color;
Xextern int		fix_x, fix_y, cur_x, cur_y;
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
Xstatic			draw_movingbox();
Xstatic int		x1off, y1off, x2off, y2off;
X
X			(*return_proc)();
X			 move_line(), place_line();
X			 move_arc(), place_arc();
X			 move_spline(), place_spline();
X			 move_movingbox();
X			 place_ellipse();
X			 move_text(), place_text();
X			 place_compound();
X
Xstatic F_arc		*arc;
Xstatic F_compound	*compound;
Xstatic F_ellipse	*ellipse;
Xstatic F_line		*line;
Xstatic F_spline		*spline;
Xstatic F_text		*text;
X
Xstatic
Xdraw_movingbox(op)
Xint	op;
X{
X	register int	x1, y1, x2, y2;
X
X	x1 = cur_x + x1off;
X	x2 = cur_x + x2off;
X	y1 = cur_y + y1off;
X	y2 = cur_y + y2off;
X	pw_vector(canvas_pixwin, x1, y1, x1, y2, op, 1);
X	pw_vector(canvas_pixwin, x1, y2, x2, y2, op, 1);
X	pw_vector(canvas_pixwin, x2, y2, x2, y1, op, 1);
X	pw_vector(canvas_pixwin, x2, y1, x1, y1, op, 1);
X	}
X
Xmove_movingbox(x, y)
Xint	x, y;
X{
X	draw_movingbox(INV_PAINT);
X	cur_x = x;
X	cur_y = y;
X	draw_movingbox(INV_PAINT);
X	}
X
X/***************************** ellipse section ************************/
X
Xinit_ellipsedragging(e, x, y)
XF_ellipse	*e;
Xint		x, y;
X{
X	ellipse = e;
X	last_position.x = cur_x = x; 
X	last_position.y = cur_y = y;
X	x1off = (e->center.x - e->radiuses.x) - cur_x; 
X	x2off = (e->center.x + e->radiuses.x) - cur_x; 
X	y1off = (e->center.y - e->radiuses.y) - cur_y;
X	y2off = (e->center.y + e->radiuses.y) - cur_y;
X	canvas_locmove_proc = move_movingbox;
X	canvas_middlebut_proc = place_ellipse;
X	set_action_on();
X	draw_movingbox(INV_PAINT);
X	}
X
Xplace_ellipse(x, y)
Xint	x, y;
X{
X	draw_movingbox(INV_PAINT);
X	new_position.x = x;
X	new_position.y = y;
X	translate_ellipse(ellipse, x - last_position.x, y - last_position.y);
X	pw_batch_on(canvas_pixwin);
X	draw_ellipse(ellipse, foreground_color);
X	pw_batch_off(canvas_pixwin);
X	show_pointmarker();
X	set_modifiedflag();
X	(*return_proc)();
X	}
X
X/*****************************  arc  section  *******************/
X
Xinit_arcdragging(a, x, y)
XF_arc	*a;
Xint	x, y;
X{
X	arc = a;
X	fix_x = last_position.x = cur_x = x;
X	fix_y = last_position.y = cur_y = y;
X	canvas_locmove_proc = move_arc;
X	canvas_middlebut_proc = place_arc;
X	set_action_on();
X	draw_movingarc(arc, INV_PAINT);
X	}
X
Xmove_arc(x, y)
Xint	x, y;
X{
X	draw_movingarc(arc, INV_PAINT);
X	cur_x = x;  
X	cur_y = y;
X	draw_movingarc(arc, INV_PAINT);
X	}
X
Xplace_arc(x, y)
Xint	x, y;
X{
X	draw_movingarc(arc, INV_PAINT);
X	new_position.x = x;
X	new_position.y = y;
X	translate_arc(arc, x - fix_x, y - fix_y);
X	pw_batch_on(canvas_pixwin);
X	draw_arc(arc, foreground_color);
X	pw_batch_off(canvas_pixwin);
X	show_pointmarker();
X	set_modifiedflag();
X	(*return_proc)();
X	}
X
Xdraw_movingarc(a, op)
XF_arc	*a;
Xint	op;
X{
X	int	dx, dy;
X
X	dx = cur_x - fix_x;
X	dy = cur_y - fix_y;
X	pw_vector(canvas_pixwin, a->point[0].x+dx, a->point[0].y+dy,
X		a->point[1].x+dx, a->point[1].y+dy, op, 1);
X	pw_vector(canvas_pixwin, a->point[1].x+dx, a->point[1].y+dy,
X		a->point[2].x+dx, a->point[2].y+dy, op, 1);
X	}
X
X/*************************  line  section  **********************/
X
Xinit_linedragging(l, x, y)
XF_line	*l;
Xint	x, y;
X{
X	line = l;
X	last_position.x = cur_x = fix_x = x;
X	last_position.y = cur_y = fix_y = y;
X	canvas_locmove_proc = move_line;
X	canvas_middlebut_proc = place_line;
X	set_action_on();
X	draw_movingpoint(line->points, INV_PAINT);
X	}
X
Xmove_line(x, y)
Xint	x, y;
X{
X	draw_movingpoint(line->points, INV_PAINT);
X	cur_x = x;  
X	cur_y = y;
X	draw_movingpoint(line->points, INV_PAINT);
X	}
X
Xplace_line(x, y)
Xint	x, y;
X{
X	draw_movingpoint(line->points, INV_PAINT);
X	new_position.x = x;
X	new_position.y = y;
X	translate_line(line, x - fix_x, y - fix_y);
X	draw_line(line, PAINT);
X	show_pointmarker();
X	set_modifiedflag();
X	(*return_proc)();
X	}
X
Xdraw_movingpoint(ps, op)
XF_point	*ps;
Xint	op;
X{
X	F_point	*p;
X	int	dx, dy, x, y, xx, yy;
X
X	dx = cur_x - fix_x;
X	dy = cur_y - fix_y;
X	p = ps;
X	x = p->x + dx;
X	y = p->y + dy;
X	for (p = p->next; p != NULL; x = xx, y = yy, p = p->next) {
X	    xx = p->x + dx;  yy = p->y +dy;
X	    pw_vector(canvas_pixwin, x, y, xx, yy, op, 1);
X	    }
X		}
X
X/************************  text section  **************************/
X
Xstatic	PR_SIZE	txsize;
X
Xinit_textdragging(t, x, y)
XF_text	*t;
Xint	x, y;
X{
X
X	text = t;
X	fix_x = cur_x = x; 
X	fix_y = cur_y = y;
X	y1off = t->base_y - y;
X	if (t->type == T_CENTER_JUSTIFIED || t->type == T_RIGHT_JUSTIFIED)
X		{
X		txsize = pf_textwidth(t->font, t->size, strlen(t->cstring), t->cstring);
X		if (t->type == T_CENTER_JUSTIFIED)
X			x1off =  - txsize.x/2;
X		else
X			x1off =  - txsize.x;
X		fix_x = t->base_x;
X		}
X	else /* LEFT */
X		{
X		x1off = 0;
X		fix_x = t->base_x;
X		}
X	canvas_locmove_proc = move_text;
X	canvas_middlebut_proc = place_text;
X	draw_movingtext();
X	set_action_on();
X	}
X
Xmove_text(x, y)
Xint	x, y;
X{
X	draw_movingtext();
X	cur_x = x;
X	cur_y = y;
X	draw_movingtext();
X	}
X
Xplace_text(x, y)
Xint	x, y;
X{
X	draw_movingtext();
X	new_position.x = x;
X	new_position.y = y;
X	last_position.x = fix_x; 
X	last_position.y = fix_y;
X	translate_text(text, x - fix_x, y - fix_y);
X	draw_text(text, PAINT);
X	set_modifiedflag();
X	(*return_proc)();
X	}
X
Xdraw_movingtext()
X{
X	pw_text(canvas_pixwin, cur_x + x1off, cur_y + y1off, INV_PAINT,
X		text->font, text->size, text->cstring);
X	}
X
X/*************************  spline  section  **********************/
X
Xinit_splinedragging(s, x, y)
XF_spline	*s;
Xint		x, y;
X{
X	spline = s;
X	last_position.x = cur_x = fix_x = x;
X	last_position.y = cur_y = fix_y = y;
X	canvas_locmove_proc = move_spline;
X	canvas_middlebut_proc = place_spline;
X	set_action_on();
X	draw_movingpoint(spline->points, INV_PAINT);
X	}
X
Xmove_spline(x, y)
Xint	x, y;
X{
X	draw_movingpoint(spline->points, INV_PAINT);
X	cur_x = x;  
X	cur_y = y;
X	draw_movingpoint(spline->points, INV_PAINT);
X	}
X
Xplace_spline(x, y)
Xint	x, y;
X{
X	draw_movingpoint(spline->points, INV_PAINT);
X	translate_spline(spline, x - fix_x, y - fix_y);
X	new_position.x = x;
X	new_position.y = y;
X	pw_batch_on(canvas_pixwin);
X	draw_spline(spline, PAINT);
X	pw_batch_off(canvas_pixwin);
X	show_pointmarker();
X	set_modifiedflag();
X	(*return_proc)();
X	}
X
X/*****************************  Compound section  *******************/
X
Xinit_compounddragging(c, x, y)
XF_compound	*c;
Xint		x, y;
X{
X	compound = c;
X	last_position.x = cur_x = x; 
X	last_position.y = cur_y = y;
X	x1off = c->nwcorner.x - x;
X	x2off = c->secorner.x - x;
X	y1off = c->nwcorner.y - y;
X	y2off = c->secorner.y - y;
X	canvas_locmove_proc = move_movingbox;
X	canvas_middlebut_proc = place_compound;
X	set_action_on();
X	draw_movingbox(INV_PAINT);
X	}
X
Xplace_compound(x, y)
Xint	x, y;
X{
X	draw_movingbox(INV_PAINT);
X	new_position.x = x;
X	new_position.y = y;
X	translate_compound(compound, x - last_position.x, y - last_position.y);
X	draw_compound(compound);
X	draw_compoundbox(compound, INV_PAINT);
X	set_modifiedflag();
X	(*return_proc)();
X	}
END_OF_FILE
if test 7285 -ne `wc -c <'xfig/drag.c'`; then
    echo shar: \"'xfig/drag.c'\" unpacked with wrong size!
fi
# end of 'xfig/drag.c'
fi
if test -f 'xfig/intspline.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/intspline.c'\"
else
echo shar: Extracting \"'xfig/intspline.c'\" \(8152 characters\)
sed "s/^X//" >'xfig/intspline.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 "alloc.h"
X#include "func.h"
X#include "object.h"
X#include "paintop.h"
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 int		cur_line_style, line_thickness;
Xextern float		cur_styleval;
Xextern int		cur_color;
Xextern int		cur_areafill;
Xextern int		fill_mode;
Xextern int		fix_x, fix_y, cur_x, cur_y;
Xextern int		cur_command;
Xextern int		manhattan_mode, mountain_mode;
Xextern int		autoforwardarrow_mode;
Xextern int		autobackwardarrow_mode;
Xextern F_compound	objects;
Xextern int		num_point;
Xextern int		DEBUG;
Xextern F_point		*first_point, *cur_point;
X
Xint			create_intsplineobject();
X			init_intspline_drawing();
X
Xdraw_intspline_selected()
X{
X	canvas_kbd_proc = null_proc;
X	canvas_locmove_proc = null_proc;
X	canvas_leftbut_proc = init_intspline_drawing;
X	canvas_middlebut_proc = null_proc;
X	canvas_rightbut_proc = set_popupmenu;
X	set_cursor(&arrow_cursor);
X	reset_action_on();
X	}
X
Xinit_intspline_drawing(x, y)
Xint	x, y;
X{
X	init_line_drawing(x, y);
X	canvas_middlebut_proc = create_intsplineobject;
X	canvas_rightbut_proc = null_proc;
X	}
X
Xcreate_intsplineobject(x, y)
Xint	x, y;
X{
X	extern F_arrow	*forward_arrow(), *backward_arrow();
X	F_spline	*spline;
X
X	if (x != fix_x || y != fix_y) get_intermediatepoint(x, y);
X	draw_elasticline();
X	if (num_point <= 2) {
X	    pw_vector(canvas_pixwin, first_point->x, first_point->y,
X			cur_point->x, cur_point->y, PAINT, 0);
X	    if (num_point == 1) free((char*)cur_point);
X	    free((char*)first_point);
X	    draw_intspline_selected();
X	    return;
X	    }
X	if (NULL == (Spline_malloc(spline))) {
X	    if (num_point == 1) free((char*)cur_point);
X	    free((char*)first_point);
X	    put_msg(Err_mem);
X	    return;
X	    }
X	spline->style = cur_line_style;
X	spline->thickness = line_thickness;
X	spline->style_val = cur_styleval;
X	spline->color = cur_color;
X	spline->depth = 0;
X	spline->area_fill = 0;
X	spline->pen = NULL;
X	spline->points = first_point;
X	spline->controls = NULL; 
X	spline->next = NULL; 
X	cur_x = cur_y = fix_x = fix_y = 0; /* used in draw_movingpoint */
X	draw_movingpoint(spline->points, INV_PAINT); /* erase control vector */
X	spline->for_arrow = NULL;
X	spline->back_arrow  = NULL;
X	if (cur_command == F_CLOSED_INTSPLINE) {
X	    spline->type = T_CLOSED_INTERPOLATED;
X	    /* added 3/1/89 B.V.Smith */
X	    /* The current area fill color will be saved in the object if 
X	       fill_mode is != 0, but the method presently used to draw
X	       the spline doesn't easily lend itself to area fill,
X	       so it is not filled.
X	       The spline is drawn in sections that aren't adjacent, 
X	       and have overlapping sections. */
X	    spline->area_fill = fill_mode? cur_areafill : 0;
X	    num_point++;
X	    append_point(first_point->x, first_point->y, &cur_point);
X	    }
X	else {
X	    spline->type = T_OPEN_INTERPOLATED;
X	    if (autoforwardarrow_mode) spline->for_arrow = forward_arrow();
X	    if (autobackwardarrow_mode) spline->back_arrow = backward_arrow();
X	    }
X	make_control_points(spline);
X	pw_batch_on(canvas_pixwin);
X	draw_intspline(spline, PAINT);
X	if (DEBUG) {
X	    int	xmin, ymin, xmax, ymax;
X	    spline_bound(spline, &xmin, &ymin, &xmax, &ymax);
X	    draw_rectbox(xmin, ymin, xmax, ymax, PAINT, 1);
X	    }
X	pw_batch_off(canvas_pixwin);
X	clean_up();
X	set_action_object(F_CREATE, O_SPLINE);
X	insert_spline(&objects.splines, spline);
X	set_latestspline(spline);
X	set_modifiedflag();
X	draw_intspline_selected();
X	}
X
X/* Tension : 0 (min) -> 1 (max)	*/
X
X#define		round(x)	((int) (x + .5))
X
Xcreate_control_list(s)
XF_spline	*s;
X{
X	F_point		*p;
X	F_control	*cp;
X
X	if (NULL == (Control_malloc(cp))) {
X	    put_msg(Err_mem);
X	    return(-1);
X	    }
X	s->controls = cp;
X	for (p = s->points->next; p != NULL; p = p->next) {
X	    if (NULL == (Control_malloc(cp->next))) {
X		put_msg(Err_mem);
X		return(-1);
X		}
X	    cp = cp->next;
X	    }
X	cp->next = NULL;
X	return(1);
X	}
X
Xmake_control_points(s)
XF_spline	*s;
X{
X	if (-1 == create_control_list(s)) return;
X
X	remake_control_points(s);
X	}
X
Xremake_control_points(s)
XF_spline	*s;
X{
X	if (s->type == T_CLOSED_INTERPOLATED)
X	    compute_cp(s->points, s->controls, CLOSED_PATH);
X	else
X	    compute_cp(s->points, s->controls, OPEN_PATH);
X	}
X
Xdraw_intspline(s, op)
XF_spline	*s;
Xint		op;
X{
X	F_point		*p1, *p2;
X	F_control	*cp1, *cp2;
X
X	p1 = s->points;
X	cp1 = s->controls;
X	cp2 = cp1->next;
X	if (s->back_arrow)
X	    draw_arrow(round(cp2->lx), round(cp2->ly), p1->x, p1->y, 
X		       s->back_arrow, op);
X	for (p2 = p1->next, cp2 = cp1->next; p2 != NULL;
X		p1 = p2, cp1 = cp2, p2 = p2->next, cp2 = cp2->next) {
X	    bezier_spline((float)p1->x, (float)p1->y, cp1->rx, cp1->ry,
X			cp2->lx, cp2->ly, (float)p2->x, (float)p2->y, op, s->thickness);
X	    }
X	if (s->for_arrow)
X	    draw_arrow(round(cp1->lx), round(cp1->ly), p1->x,
X			p1->y, s->for_arrow, op);
X	}
X
X#define		T		0.45
X#define		_2xPI		6.2832
X#define		_1dSQR2		0.7071
X#define		_SQR2		1.4142
X
Xcompute_cp(points, controls, path)
XF_point		*points;
XF_control	*controls;
Xint		path;
X{
X	F_control	*cp, *cpn;
X	F_point		*p, *p2, *pk;	/* Pk is the next-to-last point. */
X	float		dx, dy;
X	float		x1, y1, x2, y2, x3, y3;
X	float		l1, l2, theta1, theta2;
X
X	x1 = points->x;  y1 = points->y;
X	pk = p2 = points->next;
X	x2 = p2->x;  y2 = p2->y;
X	p = p2->next;
X	x3 = p->x;  y3 = p->y;
X
X	dx = x1 - x2;
X	dy = y2 - y1;
X	l1 = sqrt((double)(dx*dx + dy*dy));
X	theta1 = atan2((double)dy, (double)dx);
X	dx = x3 - x2;
X	dy = y2 - y3;
X	l2 = sqrt((double)(dx*dx + dy*dy));
X	theta2 = atan2((double)dy, (double)dx);
X	/* -PI <= theat1, theta2 <= PI */
X	if (theta1 < 0) theta1 += _2xPI;
X	if (theta2 < 0) theta2 += _2xPI;
X	/* 0 <= theat1, theta2 < 2PI */
X
X	cp = controls->next;
X	control_points(x2, y2, l1, l2, theta1, theta2, T, cp);
X	/* control points for (x2, y2) */
X	if (path == OPEN_PATH) {
X	    controls->lx = 0.0; controls->ly = 0.0;
X	    controls->rx = (x1 + 3*cp->lx)/4; controls->ry = (y1 + 3*cp->ly)/4;
X	    cp->lx = (3*cp->lx + x2)/4; cp->ly = (3*cp->ly + y2)/4;
X	    }
X
X	while (1) {
X	    x2 = x3; y2 = y3;
X	    l1 = l2;
X	    if (theta2 >= M_PI)
X		theta1 = theta2 - M_PI;
X	    else
X		theta1 = theta2 + M_PI;
X	    if ((p = p->next) == NULL) break;
X	    pk = pk->next;
X	    x3 = p->x; y3 = p->y;
X	    dx = x3 - x2;
X	    dy = y2 - y3;
X	    l2 = sqrt((double)(dx*dx + dy*dy));
X	    theta2 = atan2((double)dy, (double)dx);
X	    if (theta2 < 0) theta2 += _2xPI;
X	    cp = cp->next;
X	    control_points(x2, y2, l1, l2, theta1, theta2, T, cp);
X	    };
X
X	if (path == CLOSED_PATH) {
X	    dx = p2->x - x2;
X	    dy = y2 - p2->y;
X	    l2 = sqrt((double)(dx*dx + dy*dy));
X	    theta2 = atan2((double)dy, (double)dx);
X	    if (theta2 < 0) theta2 += _2xPI;
X	    cp = cp->next;
X	    control_points(x2, y2, l1, l2, theta1, theta2, T, cp);
X	    controls->lx = cp->lx; controls->ly = cp->ly;
X	    controls->rx = cp->rx; controls->ry = cp->ry;
X	    }
X	else {
X	    cpn = cp->next;
X	    cpn->lx = (3*cp->rx + x2) / 4; cpn->ly = (3*cp->ry + y2) / 4;
X	    cpn->rx = 0.0; cpn->ry = 0.0;
X	    cp->rx = (pk->x + 3*cp->rx) / 4; cp->ry = (pk->y + 3*cp->ry) / 4;
X	    }
X	}
X
X/*
XThe parameter t is the tension.  It must range in [0, 1].
XThe bigger the value of t, the higher the tension.
X*/
X
Xcontrol_points(x, y, l1, l2, theta1, theta2, t, cp)
Xfloat	x, y, l1, l2, theta1, theta2, t;
XF_control	*cp;
X{
X	float	s, theta, r = 1 - t;
X
X	/* 0 <= theat1, theta2 < 2PI */
X
X	theta = (theta1 + theta2) / 2;
X
X	if (theta1 > theta2) {
X	    s = sin((double)(theta-theta2));
X	    theta1 = theta + M_PI_2;
X	    theta2 = theta - M_PI_2;
X	    }
X	else {
X	    s = sin((double)(theta2-theta));
X	    theta1 = theta - M_PI_2;
X	    theta2 = theta + M_PI_2;
X	    }
X	if (s > _1dSQR2) s = _SQR2 - s;
X	s *= r;
X	l1 *= s; l2 *= s;
X	cp->lx = x + l1 * cos((double)theta1);
X	cp->ly = y - l1 * sin((double)theta1);
X	cp->rx = x + l2 * cos((double)theta2);
X	cp->ry = y - l2 * sin((double)theta2);
X	}
END_OF_FILE
if test 8152 -ne `wc -c <'xfig/intspline.c'`; then
    echo shar: \"'xfig/intspline.c'\" unpacked with wrong size!
fi
# end of 'xfig/intspline.c'
fi
if test -f 'xfig/resources.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/resources.h'\"
else
echo shar: Extracting \"'xfig/resources.h'\" \(4123 characters\)
sed "s/^X//" >'xfig/resources.h' <<'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#ifdef	GLOBAL		/* global.c defines GLOBAL so that we actually allocate space */
X#define	EXTERN
X#else
X#define	EXTERN	extern
X#endif
X
Xtypedef struct
X{
X	unsigned int	x, y, z;
X	caddr_t		*m;
X} MprData;
X
X#define mpr_static(name,x,y,z,pix)	\
XXImage name	= \
X{ \
X(x),		/* width */ \
X(y),		/* height */ \
X0,		/* offset */ \
XXYBitmap,	/* format */ \
X(char *)(pix),	/* data pointer */ \
XMSBFirst,	/* data byte order LSB or MSB first */ \
X8,		/* quant of scanline */ \
XLSBFirst,	/* bitmap bit order LSB or MSBFirst */ \
X8,		/* bitmap pad */ \
X(z),		/* depth */ \
X(x+7)/8,	/* bytes-per-line */ \
X1,		/* bits per pizel */ \
X0,		/* red_mask */ \
X0,		/* z arrangement green_mask */ \
X0,		/* z arrangement blue_mask */ \
XNULL 		/* object data pointer for extension */ \
X}
X
Xtypedef struct
X{
X	int		x, y;
X} pr_size;
X
Xtypedef struct
X{
X	unsigned int	hotx, hoty;
X	unsigned int	graphop;
X	XImage		*bitmap;
X} CursorRec;
X
Xtypedef struct
X{
X	unsigned int	r_width, r_height, r_left, r_top;
X} RectRec;
X
Xtypedef struct
X{
X	int		type;
X	char		*label;
X	caddr_t		info;
X} MenuItemRec;
X
Xstruct Menu
X{
X	int		m_imagetype;
X#define	MENU_IMAGESTRING	0x00	/* imagedata is char * */
X#define MENU_GRAPHIC            0x01    /* imagedata is pixrect * */
X	caddr_t		m_imagedata;
X	int		m_itemcount;
X	MenuItemRec	*m_items;
X	struct Menu	*m_next;
X	caddr_t		m_data;
X};
X
Xtypedef	struct Menu	MenuRec;
X
Xtypedef		Window			PIXWIN;
Xtypedef		XImage			PIXRECTREC;
Xtypedef		XImage *		PIXRECT;
Xtypedef		XFontStruct *		PIX_FONT;
Xtypedef		MprData			MPR_DATA;
Xtypedef		CursorRec		CURSORREC;
Xtypedef		CursorRec *		CURSOR;
Xtypedef		Widget			TOOL;
Xtypedef		Widget			TOOLSW;
Xtypedef		Window			FDTYPE;
Xtypedef		XButtonEvent		INPUTEVENT;
Xtypedef		unsigned long		INPUTMASK;
Xtypedef		pr_size			PR_SIZE;
Xtypedef		RectRec			RECT;
Xtypedef		MenuItemRec		MENUITEM;
Xtypedef		MenuRec			MENU;
X
X#define	set_marker(win,x,y,w,h,op,pix,z1,z2) \
X	set_line_width(1,(op)); \
X	XDrawRectangle(tool_d,(win),gccache[(op)],(x),(y),(w),(h))
X
XEXTERN PIXWIN		canvas_pixwin,
X			msg_pixwin,
X			panel_pixwin,
X			panel2_pixwin,
X			sideruler_pixwin,
X			topruler_pixwin;
X
XEXTERN CURSOR		cur_cursor;
XEXTERN CURSORREC	arrow_cursor,
X			bull_cursor,
X			buster_cursor,
X			crosshair_cursor,
X			null_cursor,
X			pencil_cursor,
X			pick15_cursor,
X			pick9_cursor,
X			wait_cursor;
X
XEXTERN TOOL		tool;
X
XEXTERN TOOLSW		canvas_sw,
X			psfont,		/* current printer font indicator */
X			fontmenu,	/* printer font menu tool */
X			msg_sw,
X			panel_sw,
X			panel2_sw,
X			fill_panel,
X			line_thick_panel,
X			radius_panel,
X			sideruler_sw,
X			topruler_sw;
X
XEXTERN FDTYPE		canvas_swfd,
X			panel_swfd,
X			panel2_swfd,
X			msgswfd,
X			trswfd,
X			srswfd;
X
XEXTERN Display		*tool_d;
XEXTERN Screen		*tool_s;
XEXTERN int		tool_sn;
X#define NUMFILLPATS 21
XEXTERN int		cur_gcfont[0x10],cur_gcfontsize[0x10];  /* font/size currently in each GC */
XEXTERN GC		gc, bold_gc, gccache[0x10], topgc, sidegc,
X			fill_gc[NUMFILLPATS],		/* area fill gc's */
X			un_fill_gc[NUMFILLPATS];	/* area "un"-fill gc's */
XEXTERN Pixmap		fill_pm[NUMFILLPATS];
XEXTERN Pixmap		ind_fill_pm[NUMFILLPATS];	/* for indicator which must be different */
XEXTERN XColor		x_fg_color, x_bg_color;
X
Xstruct icon {
X	short	 	ic_width, ic_height;	/* overall icon dimensions */
X	PIXRECT	 	ic_background;	/* background pattern (mem pixrect) */
X	RECT		ic_gfxrect;	/* where the graphic goes */
X	PIXRECT 	ic_mpr;		/* the graphic (a memory pixrect) */
X	RECT		ic_textrect;	/* where text goes */
X	char	       *ic_text;	/* the text */
X	PIX_FONT 	ic_font;	/* Font with which to display text */
X	int		ic_flags;
X};
X
X/* flag values */
X#define	ICON_BKGRDPAT	0x02		/* use ic_background to prepare image*/
X#define	ICON_BKGRDGRY	0x04		/* use std gray to prepare image*/
X#define	ICON_BKGRDCLR	0x08		/* clear to prepare image*/
X#define	ICON_BKGRDSET	0x10		/* set to prepare image*/
X#define	ICON_FIRSTPRIV	0x0100		/* start of private flags range */
X#define	ICON_LASTPRIV	0x8000		/* end of private flags range */
X
X#include "xtra.h"
END_OF_FILE
if test 4123 -ne `wc -c <'xfig/resources.h'`; then
    echo shar: \"'xfig/resources.h'\" unpacked with wrong size!
fi
# end of 'xfig/resources.h'
fi
if test -f 'xfig/text.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/text.c'\"
else
echo shar: Extracting \"'xfig/text.c'\" \(7294 characters\)
sed "s/^X//" >'xfig/text.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 *	2nd revision : Feb 1988.
X *
X *	%W%	%G%
X*/
X#include "fig.h"
X#include "resources.h"
X#include "alloc.h"
X#include "const.h"
X#include "font.h"
X#include "func.h"
X#include "object.h"
X#include "paintop.h"
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	char		*calloc();
Xextern			set_popupmenu();
Xextern	F_text		*text_search();
Xextern	PIX_FONT	lookfont();
X
Xextern	int		font_button, size_button;
Xextern	int		type_button;
X
Xextern	int		cur_font, cur_fontsize;
Xextern			char_handler();
Xextern	int		cur_x, cur_y;
Xextern	char		prefix[], suffix[];
Xextern	int		leng_prefix, leng_suffix;
Xextern	int		cur_color;
Xextern	int		cur_textstyle;
Xextern	int		cur_texttype;
Xextern	float		cur_angle;
X
Xextern	F_compound	objects;
X
Xstatic	int		char_ht, char_wid;
Xstatic	int		base_x, base_y;
Xstatic	F_text		*cur_text;
Xstatic	PR_SIZE		tsize;
Xstatic	PR_SIZE		ssize;
X
XF_text			*create_text();
Xstatic			finish_text_input();
Xstatic			finish_n_start();
Xstatic			init_text_input();
X
Xstatic
Xfinish_n_start(x, y)
X{
X	wrap_up();
X	init_text_input(x, y);
X	}
X
Xstatic
Xfinish_text_input()
X{
X	wrap_up();
X	text_drawing_selected();
X	}
X
Xstatic
Xwrap_up()
X{
X	PR_SIZE		size;
X	int		kbd_received;
X
X	reset_action_on();
X	kbd_received = terminate_char_handler();
X	if ( ! kbd_received) return;
X
X	if (cur_text == NULL) {	/* a brand new text */
X	    if (leng_prefix == 0) return;
X	    cur_text = create_text();
X	    insert_text(&objects.texts, cur_text);
X	    }
X	else {			/* existing text modified */
X	    strcat(prefix, suffix);
X	    leng_prefix += leng_suffix;
X	    if (leng_prefix == 0) {
X		delete_text(&objects.texts, cur_text);
X		cfree(cur_text->cstring);
X		free((char*)cur_text);
X		return;
X		}
X	    if (strlen(cur_text->cstring) >= leng_prefix) { 
X		strcpy(cur_text->cstring, prefix);
X		}
X	    else { /* free old and allocate new */
X		cfree(cur_text->cstring);
X		cur_text->cstring = calloc((unsigned)(leng_prefix+1), sizeof(char));
X		strcpy(cur_text->cstring, prefix);
X		}
X	    size = pf_textwidth(cur_text->font, cur_text->size, leng_prefix, prefix);
X	    cur_text->height = size.y;
X	    cur_text->length = size.x;  /* in pixels */
X	    }
X	draw_text(cur_text, PAINT);
X	clean_up();
X	set_action_object(F_TEXT, O_TEXT);
X	set_latesttext(cur_text);
X	set_modifiedflag();
X	}
X
Xstatic
Xinit_text_input(x, y)
Xint	x, y;
X{
X	int abasex, basx;
X	int twidth,pwidth;
X
X	cur_x = x;
X	cur_y = y;
X
X	set_action_on();
X	canvas_kbd_proc = char_handler;
X	canvas_middlebut_proc = finish_text_input;
X	canvas_leftbut_proc = finish_n_start;
X	canvas_rightbut_proc = null_proc;
X
X	/* set current font info to indicator button settings */
X	cur_fontsize = size_button;
X	cur_font = font_button;
X	cur_texttype = type_button;
X
X	/* load the X font and get its id for this font, size */
X	canvas_font = lookfont(cur_font, cur_fontsize);
X	char_ht = char_height(canvas_font);
X	char_wid = char_width(canvas_font);
X
X	if ((cur_text = text_search(cur_x, cur_y)) == NULL) {	/* new text input */
X	    leng_prefix = leng_suffix = 0;
X	    *suffix = 0;
X	    prefix[leng_prefix] = '\0';
X	    abasex = base_x = cur_x;
X	    base_y = cur_y;
X	    twidth = 0;
X	    pwidth = 0;
X	    }
X	else { 		/* clicked on existing text */
X	    /* leng_prefix is # of char in the text before the cursor */
X	    leng_suffix = strlen(cur_text->cstring);
X	    abasex = basx = cur_text->base_x;
X	    if (cur_text->type == T_CENTER_JUSTIFIED)
X		basx -= cur_text->length/2;
X	    else if (cur_text->type == T_RIGHT_JUSTIFIED)
X		basx -= cur_text->length;
X	    leng_prefix = prefix_length(cur_text->cstring, cur_x - basx);
X	    leng_suffix -= leng_prefix;
X	    cpy_n_char(prefix, cur_text->cstring, leng_prefix);
X	    strcpy(suffix, &cur_text->cstring[leng_prefix]);
X	    tsize = pf_textwidth(cur_text->font, cur_text->size, leng_prefix, prefix);
X	    ssize = pf_textwidth(cur_text->font, cur_text->size, leng_suffix, suffix);
X	    pwidth = tsize.x;		/* pixel width of prefix */
X	    twidth = pwidth+ssize.x;	/* total pixel width of string */
X	    cur_x = base_x = basx;
X	    cur_y = base_y = cur_text->base_y;
X	    cur_x += tsize.x;
X	    cur_font = cur_text->font;
X	    cur_fontsize = cur_text->size;
X	    cur_texttype = cur_text->type;
X	    }
X	initialize_char_handler(canvas_pixwin, finish_text_input, 
X			base_x, base_y);
X	}
X
X/* This procedure is called before any other text stuff here */
X
Xtext_drawing_selected()
X{
X	canvas_kbd_proc = null_proc;
X	canvas_locmove_proc = null_proc;
X	canvas_middlebut_proc = null_proc;
X	canvas_leftbut_proc = init_text_input;
X	canvas_rightbut_proc = set_popupmenu;
X
X	set_cursor(&pencil_cursor);
X	}
X
XF_text *
Xcreate_text()
X{
X	F_text		*text;
X	PR_SIZE		size;
X
X	if ((Text_malloc(text)) == NULL) {
X	    put_msg(Err_mem);
X	    return(NULL);
X	    }
X	text->cstring = calloc((unsigned)(leng_prefix+1), sizeof(char));
X	text->type = cur_texttype;;
X	text->font = cur_font;	/* put in current font number */
X	text->size = cur_fontsize;	/* added 9/25/89 B.V.Smith */
X	text->angle = cur_angle;
X	text->style = cur_textstyle;
X	text->color = cur_color;
X	text->depth = 0;
X	text->pen = NULL;
X	size = pf_textwidth(text->font, text->size, leng_prefix, prefix);
X	text->length = size.x;	/* in pixels */
X	text->height = size.y;	/* in pixels */
X	text->base_x = base_x;
X	text->base_y = base_y;
X	strcpy(text->cstring, prefix);
X	text->next = NULL;
X	return(text);
X	}
X
Xcpy_n_char(dst, src, n)
Xchar	*dst, *src;
Xint	 n;
X{
X	/* src must be longer than n chars */
X
X	while (n--) *dst++ = *src++;
X	*dst = '\0';
X	}
X
Xint
Xprefix_length(string, where_p)
Xchar		*string;
Xint		 where_p;
X{
X	/* c stands for character unit and p for pixel unit */
X	int		l, len_c, len_p;
X	int		char_wid, where_c;
X	PR_SIZE		size;
X
X	if (canvas_font == NULL) 
X		fprintf(stderr,"Error, in prefix_length, canvas_font = NULL\n");
X	len_c = strlen(string);
X	size = pf_textwidth(cur_text->font, cur_text->size, len_c, string);
X	len_p = size.x;
X	if (where_p >= len_p) return(len_c); /* entire string is the preffix */
X
X	char_wid = char_width(canvas_font);
X	where_c = where_p / char_wid;	/* estimated char position */
X	size = pf_textwidth(cur_text->font, cur_text->size, where_c, string);
X	l = size.x;	/* actual lenght (pixels) of string of where_c chars */
X	if (l < where_p) {
X	    do {	/* add the width of next char to l */
X		l += (char_wid = char_advance(canvas_font,string[where_c++]));
X		} while (l < where_p);
X	    if (l-(char_wid>>1) >= where_p) where_c--;
X	    }
X	else if (l > where_p) {
X	    do {	/* subtract the width of last char from l */
X		l -= (char_wid = char_advance(canvas_font,string[--where_c]));
X		} while (l > where_p);
X	    if (l+(char_wid>>1) >= where_p) where_c++;
X	    }
X	return(where_c);
X	}
X
Xdraw_text(text, op)
XF_text	*text;
Xint	op;
X{
X	PR_SIZE	size;
X	int x;
X
X	x = text->base_x;
X	if (text->type == T_CENTER_JUSTIFIED || text->type == T_RIGHT_JUSTIFIED)
X		{
X		size = pf_textwidth(text->font,text->size,strlen(text->cstring),text->cstring);
X		if (text->type == T_CENTER_JUSTIFIED)
X			x -= size.x/2;
X		else
X			x -= size.x;
X		}
X	pw_text(canvas_pixwin, x, text->base_y, 
X		op, text->font, text->size, text->cstring);
X	}
END_OF_FILE
if test 7294 -ne `wc -c <'xfig/text.c'`; then
    echo shar: \"'xfig/text.c'\" unpacked with wrong size!
fi
# end of 'xfig/text.c'
fi
echo shar: End of archive 11 \(of 15\).
cp /dev/null ark11isdone
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.