[comp.sources.x] v06i012: xfig, Part04/15

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

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



#! /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 4 (of 15)."
# Contents:  xfig/panel.c xfig/patchlevel.h xfig/ruler.c
# Wrapped by argv@turnpike on Wed Feb 28 10:53:16 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'xfig/panel.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/panel.c'\"
else
echo shar: Extracting \"'xfig/panel.c'\" \(39156 characters\)
sed "s/^X//" >'xfig/panel.c' <<'END_OF_FILE'
X/* 
X *	FIG : Facility for Interactive Generation of figures
X *
X *	panel.c - Button panel
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 "font.h"
X#include "func.h"
X#include "object.h"
X#include "paintop.h"
X
Xextern		null_proc();
Xextern		read_file();
Xextern		save_file();
Xextern		edit_file();
Xextern		change_directory();
Xextern		print_wdir();
Xextern		print_figure();
Xextern	int	line_thickness;
Xextern	int	cur_radius;
Xextern	int	cur_areafill;
Xextern	int	fill_mode;
Xextern	int	foreground_color;
Xextern	char	current_file[];
Xextern	int	landscape;
Xextern	int	print_landscape;
Xextern	int	size_button;
Xextern	int	type_button;
Xextern	char	*printer;
Xextern	int	cur_printer;
Xextern	char	*printer_list[];
Xextern	int	INCHES;
Xextern	TOOL	fontmenu;		/* popup menu for printer fonts */
X
X/**************     local variables and routines   **************/
X
X#include "panel.h"
X#include "panel2.h"
X#include "switch.h"
X
Xstatic		panel_selected();
Xstatic		panel_sighandler();
Xstatic		init_switch();
Xstatic F_switch	*switch_selected();
Xstatic		panel_selected();
Xstatic		switch_handler();
Xstatic		switch_action();
Xstatic		mode_on();
Xstatic		mode_off();
Xstatic		set_command();
Xstatic		set_geometry();
Xstatic		set_grid();
Xstatic		set_style();
Xstatic		dec_thick();
Xstatic		inc_thick();
Xstatic		dec_radius();
Xstatic		inc_radius();
Xstatic		darken_fill();
Xstatic		lighten_fill();
Xextern		turn_off();
X
X/* second panel (lower part of window */
Xstatic		save_n_exit_button();
Xstatic		quit_button();
Xstatic		save_button();
Xstatic		save_in_button();
Xstatic		read_button();
Xstatic		edit_button();
Xstatic		changedir_button();
Xstatic		print_wdir_button();
Xstatic		print_button();
Xstatic		print_sel_button();
Xstatic		text_just_button();
Xstatic		popup_fonts();
Xstatic		inc_size_button();
Xstatic		dec_size_button();
Xstatic		land_button();
Xstatic		undo_button();
Xstatic		redisp_button();
X
Xstatic	Pixmap	Lp_pm;	/* pixmaps for print-Landscape/Portrait button */
Xstatic	Pixmap	lP_pm;
Xstatic	Pixmap	print_sel_pm;	/* pixmap for printer selection widget */
Xstatic	Pixmap	font_size_pm;	/* pixmap for printer selection widget */
Xstatic	Pixmap	text_just_pm[3]; /* pixmaps for left/center/right just widget */
Xstatic	Widget	print_sel_widget;
Xstatic	Widget	font_size_widget;
Xstatic	F_switch *text_just_sw;	/* text justification button */
Xstatic	F_switch *land_port_sw;	/* landscape/portrait button */
X
X#define		on_action(z)	(z->on_func)(z)
X#define		off_action(z)	(z->off_func)(z)
X
Xstatic F_switch	 switches[] = { 
X	{ 0, 0, 0, 0, &cirrad_ic, F_CIRCLE_BY_RAD, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &cirdia_ic, F_CIRCLE_BY_DIA, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &ellrad_ic, F_ELLIPSE_BY_RAD, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &elldia_ic, F_ELLIPSE_BY_DIA, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &c_spl_ic, F_CLOSED_SPLINE, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &spl_ic, F_SPLINE, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &c_intspl_ic, F_CLOSED_INTSPLINE, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &intspl_ic, F_INTSPLINE, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &line_ic, F_POLYLINE, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &polygon_ic, F_POLYGON, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &box_ic, F_BOX, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &arc_box_ic, F_ARC_BOX, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &text_ic, F_TEXT, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &arc_ic, F_CIRCULAR_ARC, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &turn_ic, F_TURN, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &glue_ic, F_GLUE, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &break_ic, F_BREAK, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &scale_ic, F_SCALE, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &autoarrow_ic, F_AUTOARROW, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &addpt_ic, F_ADD_POINT, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &deletept_ic, F_DELETE_POINT, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &move_ic, F_MOVE, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &movept_ic, F_MOVE_POINT, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &copy_ic, F_COPY, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &remove_ic, F_REMOVE, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &flip_x_ic, F_FLIP_XAXIS, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &flip_y_ic, F_FLIP_YAXIS, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &rot90_ic, F_ROTATE90, set_command, null_proc, S_ON, },
X	{ 0, 0, 0, 0, &rot270_ic, F_ROTATE270, set_command, null_proc, S_ON, },
X
X	/* place holders to align some button groups */
X	{ 0, -1, 0, 0, &blank_ic, F_NOP, null_proc, null_proc, S_MOMENT, },
X
X	{ 0, 1, 0, 0, &grid1_ic, F_GRID1, set_grid, set_grid, S_TOG, },
X	{ 0, 1, 0, 0, &grid2_ic, F_GRID2, set_grid, set_grid, S_TOG, },
X	{ 1, 2, 0, 0, &unconstraint_ic, F_UNCONSTRAINT, set_geometry, null_proc, S_ON, },
X	{ 0, 2, 0, 0, &mounthattan_ic, F_MOUNTHATTAN, set_geometry, null_proc, S_ON, },
X	{ 0, 2, 0, 0, &manhattan_ic, F_MANHATTAN, set_geometry, null_proc, S_ON, },
X	{ 0, 2, 0, 0, &mountain_ic, F_MOUNTAIN, set_geometry, null_proc, S_ON, },
X	/* Yuck. Latex */
X	/****************
X	{ 0, 2, 0, 0, &latexline_ic, F_LATEX_LINE, set_geometry, null_proc, S_ON, },
X	{ 0, 2, 0, 0, &latexarrow_ic, F_LATEX_ARROW, set_geometry, null_proc, S_ON, },
X	*****************/
X	{ 1,  3, 0, 0, &solidline_ic, F_SET_SOLID_LINE, set_style, null_proc, S_ON, },
X	{ 0,  3, 0, 0, &dashline_ic, F_SET_DASH_LINE, set_style, null_proc, S_ON, },
X	{ 0,  3, 0, 0, &dottedline_ic, F_SET_DOTTED_LINE, set_style, null_proc, S_ON, },
X	{ 0,  0, 0, 0, &change_style_ic, F_CHANGE_STYLE, set_command, null_proc, S_ON, },
X	{ 0, -1, 0, 0, &backarrow_ic, F_AUTOB_ARROW, mode_on, mode_off, S_TOG, },
X	{ 0, -1, 0, 0, &forarrow_ic, F_AUTOF_ARROW, mode_on, mode_off, S_TOG, },
X	{ 0,  0, 0, 0, &change_thick_ic, F_CHANGE_THICK, set_command, null_proc, S_ON, },
X	{ 1, -1, 0, 0, &magnet_ic, F_MAGNET, mode_on, mode_off, S_TOG, },
X	{ 0, -1, 0, 0, &fill_ic, F_FILL, mode_on, mode_off, S_TOG, },
X	{ 0, -1, 0, 0, &incdec_thick_ic, F_INCDECTHICK, dec_thick, null_proc, S_MOMENT,},
X	{ 0, -1, 0, 0, &incdec_radius_ic, F_INCDECRADIUS, dec_radius, null_proc, S_MOMENT,},
X	{ 0, -1, 0, 0, &fill_color_ic, F_FILLCOLOR, lighten_fill, null_proc, S_MOMENT,},
X
X	/* place holders to keep a multiple of 3 buttons */
X	/* { 0, -1, 0, 0, &blank_ic, F_NOP, null_proc, null_proc, S_MOMENT, }, */
X	};
X
X#define		N_SWITCHES	(sizeof(switches) / sizeof(F_switch))
X#define		NUM_GROUP	4
Xstatic F_switch	*group[NUM_GROUP];
X
X/* second panel of switches below the lower ruler */
Xstatic F_switch		switches2[] = { 
X	{ 0, -1, 0, 0, &save_n_exit_ic,F_SAVE_N_EXIT,save_n_exit_button,null_proc,S_MOMENT,},
X	{ 0, -1, 0, 0, &quit_ic, F_QUIT, quit_button, null_proc, S_MOMENT, },
X	{ 0, -1, 0, 0, &save_ic, F_SAVE, save_button, null_proc, S_MOMENT, },
X	{ 0, -1, 0, 0, &save_in_ic, F_SAVE_IN, save_in_button, null_proc, S_MOMENT, },
X	{ 0, -1, 0, 0, &read_ic, F_READ, read_button, null_proc, S_MOMENT, },
X	{ 0, -1, 0, 0, &edit_ic, F_EDIT, edit_button, null_proc, S_MOMENT, },
X	{ 0, -1, 0, 0, &cdir_ic, F_CHDIR, changedir_button, null_proc, S_MOMENT, },
X	{ 0, -1, 0, 0, &pdir_ic, F_PWDIR, print_wdir_button, null_proc, S_MOMENT, },
X	{ 0, -1, 0, 0, &print_ic, F_PRINT, print_button, null_proc, S_MOMENT, },
X	{ 0, -1, 0, 0, &print_sel_ic, F_PRINTSEL, print_sel_button, null_proc, S_MOMENT,},
X	{ 0, -1, 0, 0, &font_ic, F_FONT, popup_fonts, null_proc, S_MOMENT, },
X	{ 0, -1, 0, 0, &size_ic, F_SIZE, dec_size_button, null_proc, S_MOMENT, },
X	{ 0, -1, 0, 0, &textL_ic, F_JUST, text_just_button, null_proc, S_MOMENT, },
X	{ 0,  0, 0, 0, &change_text_ic, F_CHANGE_TEXT, set_command, null_proc, S_ON, },
X	{ 0, -1, 0, 0, &land_ic, F_LAND, land_button, null_proc, S_MOMENT, },
X	{ 0, -1, 0, 0, &undo_ic, F_UNDO, undo_button, null_proc, S_MOMENT, },
X	{ 0, -1, 0, 0, &redisp_ic, F_REDISPLAY, redisp_button, null_proc, S_MOMENT, },
X	};
X
X#define		N_SWITCHES2	(sizeof(switches2) / sizeof(F_switch))
X
X/*
X *	Panel subwindow section
X */
X
Xstatic Arg	panel_args[] =
X{
X	/*  0 */ { XtNx, (XtArgVal)0 },
X	/*  1 */ { XtNy, (XtArgVal)0 },
X	/*  2 */ { XtNwidth, (XtArgVal)0 },
X	/*  3 */ { XtNheight, (XtArgVal)0 },
X	/*  4 */ { XtNhSpace, (XtArgVal)SWITCH_ICON_SPACING },
X	/*  5 */ { XtNvSpace, (XtArgVal)SWITCH_ICON_SPACING },
X	/* Fix the size of the panel window by chaining both top & bottom
X	   to the top, and both left & right to the right */
X	/*  6 */ { XtNtop, (XtArgVal)XtChainTop},
X	/*  7 */ { XtNbottom, (XtArgVal)XtChainTop},
X	/*  8 */ { XtNleft, (XtArgVal)XtChainLeft },
X	/*  9 */ { XtNright, (XtArgVal)XtChainLeft },
X	/* 10 */ { XtNresizable, (XtArgVal) False },
X};
X
Xstatic Arg	panel2_args[] =
X{
X	/* 0 */ { XtNx, (XtArgVal)0 },
X	/* 1 */ { XtNy, (XtArgVal)0 },
X	/* 2 */ { XtNwidth, (XtArgVal)0 },
X	/* 3 */ { XtNheight, (XtArgVal)0 },
X	/* 4 */ { XtNhSpace, (XtArgVal)SWITCH_ICON_SPACING },
X	/* 5 */ { XtNvSpace, (XtArgVal) SWITCH_ICON_SPACING/2 },
X	/* 6 */ { XtNresizable, (XtArgVal) FALSE },
X	/* 7 */ { XtNfromHoriz, (XtArgVal) NULL },
X	/* 8 */ { XtNfromVert, (XtArgVal) NULL },
X	/* 9 */ { XtNhorizDistance, (XtArgVal) -3*SWITCH_ICON_WIDTH - 6*SWITCH_ICON_SPACING },
X	/* 10 */ { XtNvertDistance, (XtArgVal) 1 },
X	/* Fix the size of the panel window by chaining both top & bottom
X	   to the top, and both left & right to the right */
X	/* 11 */ { XtNtop, (XtArgVal)XtChainBottom},
X	/* 12 */ { XtNbottom, (XtArgVal)XtChainBottom},
X	/* 13 */ { XtNleft, (XtArgVal)XtChainLeft },
X	/* 14 */ { XtNright, (XtArgVal)XtChainLeft },
X};
X
X/* widget arguments to show the current fill color and line thickness*/
X
Xstatic Arg	indicator_panel_args[] =
X{
X	/*  0 */ { XtNx, (XtArgVal)0 },
X	/*  1 */ { XtNy, (XtArgVal)0 },
X	/*  2 */ { XtNlabel, (XtArgVal)"        " },
X	/*  3 */ { XtNwidth, (XtArgVal) SWITCH_ICON_WIDTH },
X	/*  4 */ { XtNheight, (XtArgVal) SWITCH_ICON_HEIGHT },
X	/*  5 */ { XtNresizable, (XtArgVal) FALSE },
X	/*  6 */ { XtNborderWidth, (XtArgVal) 1},
X	/*  7 */ { XtNhorizDistance, (XtArgVal) 0 },
X	/*  8 */ { XtNvertDistance, (XtArgVal) 0 },
X	/*  9 */ { XtNfromHoriz, (XtArgVal) NULL },
X	/* 10 */ { XtNfromVert, (XtArgVal) NULL },
X	/* Fix the size of the panel window by chaining both top & bottom
X	   to the top, and both left & right to the right */
X	/* 11 */ { XtNtop, (XtArgVal)XtChainTop},
X	/* 12 */ { XtNbottom, (XtArgVal)XtChainTop},
X	/* 13 */ { XtNleft, (XtArgVal)XtChainLeft },
X	/* 14 */ { XtNright, (XtArgVal)XtChainLeft },
X	/* 15 */ { XtNbackgroundPixmap, (XtArgVal) NULL },
X};
X
Xextern void button_select();
X
X/* we aren't using the callback anymore - see sel_but() */
Xstatic XtCallbackRec    button_callbacks[] =
X{
X	{ button_select, NULL },
X	{ NULL, NULL },
X};
X
Xstatic Arg	button_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 */ { XtNbackgroundPixmap, (XtArgVal)NULL },
X	/* 6 */ { XtNresizable, (XtArgVal) FALSE },
X	/* 7 */ { XtNborderWidth, (XtArgVal) 1},
X	/* 8 */ { XtNresize, (XtArgVal) FALSE },   /* this keeps the damned buttons from
X						      being resized when there are not a
X						      multiple of three of them */
X
X	/* callbacks not used anymore */
X	/* 8 */ /* { XtNcallback, (XtArgVal)button_callbacks }, */
X};
X
Xextern int	PANEL_LEFT, PANEL_TOP, PANEL_HEIGHT, PANEL_WID;
Xextern int	PANEL2_LEFT, PANEL2_TOP, PANEL2_HEIGHT, PANEL2_WID;
Xextern int	CANVAS_HEIGHT, ICON_COLUMN;
X
Xextern right_but();
X
X/* button selection event handler */
Xextern sel_but();
X
Xint 
Xinit_panel(tool)
X	TOOL		tool;
X{
X	register int		i;
X	register F_switch	*sw;
X
X	panel_args[2].value = PANEL_WID =
X		(SWITCH_ICON_WIDTH + 2 + SWITCH_ICON_SPACING) * ICON_COLUMN
X		+ SWITCH_ICON_SPACING;
X	panel_args[3].value = PANEL_HEIGHT = CANVAS_HEIGHT + RULER_WIDTH + MSG_HEIGHT;
X	panel_sw = XtCreateWidget("panel", boxWidgetClass, tool, panel_args,
X		XtNumber(panel_args));
X
X	for (i = 0; i < N_SWITCHES; ++i)
X	{
X		sw = &switches[i];
X		button_args[0].value = sw->x * sw->icon->width;
X		button_args[1].value = sw->y * sw->icon->height;
X		button_args[3].value = sw->icon->width;
X		button_args[4].value = sw->icon->height;
X		sw->but.widget = XtCreateManagedWidget(
X			"button", commandWidgetClass,
X			panel_sw, button_args, XtNumber(button_args));
X		/* allow left and right buttons (callbacks pass same data for ANY button) */
X		XtAddEventHandler(sw->but.widget,ButtonPressMask,(Boolean) 0, 
X			sel_but, (caddr_t) sw);
X	}
X
X	return (1);
X}
X
Xint 	/* second panel */
Xinit_panel2(tool)
X	TOOL		tool;
X{
X	register int		i;
X	register F_switch	*sw;
X
X
X	panel2_args[2].value = PANEL2_WID = 2 * N_SWITCHES2 *
X			(SWITCH_ICON_WIDTH + SWITCH_ICON_SPACING)
X			+ SWITCH_ICON_SPACING;
X	panel2_args[3].value = PANEL2_HEIGHT = SWITCH_ICON_HEIGHT + 3 * SWITCH_ICON_SPACING;
X	panel2_args[7].value = (XtArgVal) panel_sw;	/* horiz offset from panel_sw */
X	panel2_args[8].value = (XtArgVal) psfont;	/* vert offset from font window */
X
X	panel2_sw = XtCreateWidget("panel2", boxWidgetClass, tool, panel2_args,
X		XtNumber(panel2_args));
X	for (i = 0; i < N_SWITCHES2; ++i)
X	{
X		sw = &switches2[i];
X		button_args[0].value = sw->x * sw->icon->width;
X		button_args[1].value = sw->y * sw->icon->height;
X		button_args[3].value = sw->icon->width;
X		button_args[4].value = sw->icon->height;
X		sw->but.widget = XtCreateManagedWidget(
X			"button", commandWidgetClass,
X			panel2_sw, button_args, XtNumber(button_args));
X		/* allow left and right buttons (callbacks pass same data for ANY button) */
X		XtAddEventHandler(sw->but.widget,ButtonPressMask,(Boolean) 0, 
X			sel_but, (caddr_t) sw);
X	}
X	return (1);
X}
X
Xinit_indicator_panel(tool)
XTOOL tool;
X	{
X		/* vert position */
X		indicator_panel_args[8].value = (XtArgVal) 2*SWITCH_ICON_SPACING;
X		indicator_panel_args[9].value = (XtArgVal) panel_sw;
X		indicator_panel_args[10].value = (XtArgVal) panel_sw;
X		indicator_panel_args[15].value = (XtArgVal) ind_fill_pm[0];/* white pixmap */
X
X		/* horiz position for line thickness indicator */
X		indicator_panel_args[7].value = (XtArgVal) 
X			-SWITCH_ICON_WIDTH*ICON_COLUMN - SWITCH_ICON_SPACING*(ICON_COLUMN+2);
X		line_thick_panel = XtCreateManagedWidget( "indicator", boxWidgetClass,
X			tool, indicator_panel_args, XtNumber(indicator_panel_args));
X
X		/* horiz position for rounded-corner box radius indicator */
X		indicator_panel_args[7].value += SWITCH_ICON_WIDTH+1.5*SWITCH_ICON_SPACING;
X		radius_panel = XtCreateManagedWidget( "indicator", boxWidgetClass,
X			tool, indicator_panel_args, XtNumber(indicator_panel_args));
X				
X		/* horiz position for fill_area color */
X		indicator_panel_args[7].value += SWITCH_ICON_WIDTH+1.5*SWITCH_ICON_SPACING;
X		fill_panel = XtCreateManagedWidget( "indicator", boxWidgetClass,
X			tool, indicator_panel_args, XtNumber(indicator_panel_args));
X	}
X
Xstatic GC button_gc;
X
Xsetup_panel()
X{
X	register int		i;
X	register F_switch	*sw;
X	register Display	*d = tool_d;
X	register Screen		*s = tool_s;
X	register Pixmap		p;
X	XGCValues		gcv;
X	Arg			tmp_arg[3];
X	long			bg, fg;
X	
X	button_gc = XCreateGC(d, XtWindow(panel_sw), 0, &gcv);
X	XtSetArg(tmp_arg[0], XtNbackground, &bg);
X	XtSetArg(tmp_arg[1], XtNforeground, &fg);
X	XtGetValues(switches[0].but.widget, tmp_arg, 2);
X	XSetForeground(d, button_gc, fg);
X	XSetBackground(d, button_gc, bg);
X	XSetFont(d, button_gc, button_font->fid); /* set button font */
X
X	for (i = 0; i < N_SWITCHES; ++i)
X	{
X		sw = &switches[i];
X		p = XCreatePixmapFromBitmapData(d, XtWindow(sw->but.widget),
X				sw->icon->data,
X				sw->icon->width, sw->icon->height,fg,bg,
X				DefaultDepthOfScreen(s));
X
X		sw->but.normal = button_args[5].value = (XtArgVal)p;
X		XtSetValues(sw->but.widget, &button_args[5], 1);
X	}
X/*
X**	Create reversed bitmaps for displaying activated state
X*/
X	XSetForeground(d, button_gc, bg);
X	XSetBackground(d, button_gc, fg);
X	for (i = 0; i < N_SWITCHES; ++i)
X	{
X		sw = &switches[i];
X		p = XCreatePixmapFromBitmapData(d, XtWindow(sw->but.widget),
X				sw->icon->data,
X				sw->icon->width, sw->icon->height,bg,fg,
X				DefaultDepthOfScreen(s));
X
X		sw->but.reverse = (XtArgVal)p;
X	}
X
X	/*******************************/
X	/* now do the same for panel 2 */
X	/*******************************/
X
X	XSetForeground(d, button_gc, fg);
X	XSetBackground(d, button_gc, bg);
X	for (i = 0; i < N_SWITCHES2; ++i)
X	{
X		sw = &switches2[i];
X		p = XCreatePixmapFromBitmapData(d, XtWindow(sw->but.widget),
X				sw->icon->data,
X				sw->icon->width, sw->icon->height,fg,bg,
X				DefaultDepthOfScreen(s));
X		if (sw->value == F_LAND) /* create portrait pixmap for land/portrait button */
X			{
X			Lp_pm = p;	/* save pointer to default */
X			lP_pm = XCreatePixmapFromBitmapData(d, XtWindow(sw->but.widget),
X				port_ic.data,
X				port_ic.width, port_ic.height,fg,bg,
X				DefaultDepthOfScreen(s));
X			if (landscape==0)	/* use portrait for startup image */
X				p = lP_pm;
X			land_port_sw = sw;	/* save pointer to this switch */
X			}
X		else if (sw->value == F_SIZE) /* save pointer to pixmap/widget for font size */
X			{
X			font_size_pm = p;
X			font_size_widget = sw->but.widget;
X			}
X		else if (sw->value == F_JUST) /* save ptr to pixmap/widget for text justification */
X			{
X			text_just_sw = sw;
X			/* create the other bitmaps for Center and Right */
X			text_just_pm[T_LEFT_JUSTIFIED] = p;	/* left just */
X			text_just_pm[T_CENTER_JUSTIFIED] = 	/* center just */
X				XCreatePixmapFromBitmapData(d, XtWindow(sw->but.widget),
X					textC_ic.data,
X					textC_ic.width, textC_ic.height,fg,bg,
X					DefaultDepthOfScreen(s));
X			text_just_pm[T_RIGHT_JUSTIFIED] =	/* right just */
X				XCreatePixmapFromBitmapData(d, XtWindow(sw->but.widget),
X					textR_ic.data,
X					textR_ic.width, textR_ic.height,fg,bg,
X					DefaultDepthOfScreen(s));
X			}
X		else if (sw->value == F_PRINTSEL) /* save pointer to pixmap for print sel */
X			{
X			print_sel_pm = p;
X			print_sel_widget=sw->but.widget;
X			}
X
X		sw->but.normal = button_args[5].value = (XtArgVal)p;
X		XtSetValues(sw->but.widget, &button_args[5], 1);
X	}
X/*
X**	Create reversed bitmaps for displaying activated state
X*/
X	XSetForeground(d, button_gc, bg);
X	XSetBackground(d, button_gc, fg);
X	for (i = 0; i < N_SWITCHES2; ++i)
X	{
X		sw = &switches2[i];
X		p = XCreatePixmapFromBitmapData(d, XtWindow(sw->but.widget),
X				sw->icon->data,
X				sw->icon->width, sw->icon->height,fg,bg,
X				DefaultDepthOfScreen(s));
X		sw->but.reverse = (XtArgVal)p;
X	}
X
X	/* set the foreground and background back to normal */
X	XSetForeground(d, button_gc, fg);
X	XSetBackground(d, button_gc, bg);
X
X	init_switch();
X	panel_pixwin = panel_swfd = XtWindow(panel_sw);
X	XDefineCursor(d, panel_swfd, (Cursor)arrow_cursor.bitmap);
X	panel2_pixwin = panel2_swfd = XtWindow(panel2_sw);
X	XDefineCursor(d, panel2_swfd, (Cursor)arrow_cursor.bitmap);
X
X}
X
X/* come here when a button is pressed in either of the panels */
X
Xstatic
Xsel_but(widget, sw, event)
XWidget widget;
XF_switch *sw;
XXButtonEvent *event;
X	{
X	if (event->button == Button1)		/* left button */
X		button_select(widget, sw);
X	else if (event->button == Button3)	/* right button */
X		right_but(widget, sw);
X	}
X
Xstatic
Xright_but(widget, sw)
XWidget	widget;
XF_switch *sw;
X	{
X	switch (sw->value)	/* do the opposite of the function declared in the switch */
X		{
X		case F_INCDECTHICK:
X			inc_thick(sw);
X			break;
X		case F_FILLCOLOR:
X			darken_fill(sw);
X			break;
X		case F_INCDECRADIUS:
X			inc_radius(sw);
X			break;
X		case F_SIZE:
X			inc_size_button(sw);
X			break;
X		}
X	}
X
Xstatic void 
Xbutton_select(widget, s)
X	TOOL		widget;
X	F_switch	*s;
X{
X	switch_action(s);
X}
X
Xstatic
Xinit_switch()
X{
X	extern int	manhattan_mode;
X	extern int	mountain_mode;
X	extern int	autoforwardarrow_mode;
X	extern int	autobackwardarrow_mode;
X	extern int	latexline_mode;
X	extern int	latexarrow_mode;
X	extern int	magnet_mode;
X	extern int	cur_line_style;
X	extern float	cur_styleval;
X	extern float	cur_dashlength;
X	extern float	cur_dotgap;
X	int		i;
X	F_switch	*sw;
X
X	for (sw = switches, i = 0; i < N_SWITCHES; sw++, i++) {
X	    sw->x *= SWITCH_ICON_WIDTH;
X	    sw->y *= SWITCH_ICON_HEIGHT;
X	    }
X	/* don't forget the second panel */
X	for (sw = switches2, i = 0; i < N_SWITCHES2; sw++, i++) {
X	    sw->x *= SWITCH_ICON_WIDTH;
X	    sw->y *= SWITCH_ICON_HEIGHT;
X	    }
X
X	for (i = 0; i < NUM_GROUP; ) 
X		group[i++] = NULL;
X
X	for (sw = switches, i = 0; i < N_SWITCHES; sw++, i++) {
X	    if (sw->on) {
X		/* Only the following switch can be preset */
X		switch (sw->value) {
X		    case F_UNCONSTRAINT :
X			manhattan_mode = 0;
X			mountain_mode = 0;
X			latexline_mode = 0;
X			latexarrow_mode = 0;
X			group[sw->group] = sw;
X			break;
X		    case F_MOUNTHATTAN :
X			manhattan_mode = 1;
X			mountain_mode = 1;
X			group[sw->group] = sw;
X			break;
X		    case F_MANHATTAN :
X			manhattan_mode = 1;
X			group[sw->group] = sw;
X			break;
X		    case F_MOUNTAIN :
X			mountain_mode = 1;
X			group[sw->group] = sw;
X			break;
X		    case F_LATEX_LINE :
X			latexline_mode = 1;
X			group[sw->group] = sw;
X			break;
X		    case F_LATEX_ARROW :
X			latexarrow_mode = 1;
X			group[sw->group] = sw;
X			break;
X		    case F_AUTOF_ARROW :
X			autoforwardarrow_mode = 1;
X			break;
X		    case F_AUTOB_ARROW :
X			autobackwardarrow_mode = 1;
X			break;
X		    case F_SET_SOLID_LINE :
X			cur_line_style = SOLID_LINE;
X			cur_styleval = 0.0;
X			break;
X		    case F_SET_DASH_LINE :
X			cur_line_style = DASH_LINE;
X			cur_styleval = cur_dashlength;
X			break;
X		    case F_SET_DOTTED_LINE :
X			cur_line_style = DOTTED_LINE;
X			cur_styleval = cur_dotgap;
X			break;
X		    case F_MAGNET :
X			magnet_mode = 1;
X			break;
X		    default :
X			continue;
X		    }
X		turn_on(sw);
X		if (sw->group != -1) 
X			group[sw->group] = sw;
X		}
X	    }
X	}
X
Xstatic
Xset_command(sw)
XF_switch	*sw;
X{
X	extern int	cur_command;
X	extern int	rotate_angle;
X	extern int	flip_axis;
X
X	switch (sw->value) {
X	    case F_CIRCLE_BY_RAD :
X		circlebyradius_drawing_selected();
X		erase_pointmarker();
X		erase_compoundbox();
X		put_msg("CIRCLE drawing: specify RADIUS");
X		break;
X	    case F_CIRCLE_BY_DIA :
X		circlebydiameter_drawing_selected();
X		erase_pointmarker();
X		erase_compoundbox();
X		put_msg("CIRCLE drawing: specify DIAMETER");
X		break;
X	    case F_ELLIPSE_BY_RAD :
X		ellipsebyradius_drawing_selected();
X		erase_pointmarker();
X		erase_compoundbox();
X		put_msg("ELLIPSE drawing: specify RADIUSES");
X		break;
X	    case F_ELLIPSE_BY_DIA :
X		ellipsebydiameter_drawing_selected();
X		erase_pointmarker();
X		erase_compoundbox();
X		put_msg("ELLIPSE drawing: specify DIAMETERS");
X		break;
X	    case F_BOX :
X		box_drawing_selected();
X		erase_pointmarker();
X		erase_compoundbox();
X		put_msg("Rectangular BOX drawing");
X		break;
X	    case F_ARC_BOX :
X		arc_box_drawing_selected();
X		erase_pointmarker();
X		erase_compoundbox();
X		put_msg("Rectangular BOX drawing with ROUNDED CORNERS");
X		break;
X	    case F_POLYGON :
X		line_drawing_selected();
X		erase_pointmarker();
X		erase_compoundbox();
X		put_msg("POLYGON drawing");
X		break;
X	    case F_POLYLINE :
X		line_drawing_selected();
X		erase_pointmarker();
X		erase_compoundbox();
X		put_msg("POLYLINE drawing");
X		break;
X	    case F_TEXT :
X		text_drawing_selected();
X		erase_pointmarker();
X		erase_compoundbox();
X		put_msg("TEXT input (from keyboard)");
X		break;
X	    case F_CIRCULAR_ARC :
X		arc_drawing_selected();
X		erase_pointmarker();
X		erase_compoundbox();
X		put_msg("ARC drawing: specify three points on the arc");
X		break;
X	    case F_SPLINE :
X		draw_spline_selected();
X		erase_pointmarker();
X		erase_compoundbox();
X		put_msg("SPLINE drawing: specify control points");
X		break;
X	    case F_CLOSED_SPLINE :
X		draw_spline_selected();
X		erase_pointmarker();
X		erase_compoundbox();
X		put_msg("CLOSED SPLINE drawing: specify control points");
X		break;
X	    case F_INTSPLINE :
X		draw_intspline_selected();
X		erase_pointmarker();
X		erase_compoundbox();
X		put_msg("INTERPOLATED SPLINE drawing");
X		break;
X	    case F_CLOSED_INTSPLINE :
X		draw_intspline_selected();
X		erase_pointmarker();
X		erase_compoundbox();
X		put_msg("CLOSED INTERPOLATED SPLINE drawing");
X		break;
X	    case F_GLUE :
X		compound_selected();
X		erase_pointmarker();
X		show_compoundbox();
X		put_msg("GLUE objects into COMPOUND object with bounding box");
X		break;
X	    case F_BREAK :
X		break_selected();
X		erase_pointmarker();
X		show_compoundbox();
X		put_msg("BREAK COMPOUND object");
X		break;
X	    case F_SCALE :
X		scale_compound_selected();
X		erase_pointmarker();
X		show_compoundbox();
X		put_msg("SCALE COMPOUND object");
X		break;
X	    case F_ADD_POINT :
X		point_adding_selected();
X		show_pointmarker();
X		erase_compoundbox();
X		put_msg("ADD POINTs (to POLYLINE, POLYGON, CLOSED-SPLINE and SPLINE)");
X		break;
X	    case F_DELETE_POINT :
X		delete_point_selected();
X		show_pointmarker();
X		erase_compoundbox();
X		put_msg("DELETE POINTs (from POLYLINE, POLYGON, CLOSED-SPLINE and SPLINE)");
X		break;
X	    case F_MOVE :
X		move_selected();
X		show_pointmarker();
X		show_compoundbox();
X		put_msg("MOVE objects");
X		break;
X	    case F_MOVE_POINT :
X		move_point_selected();
X		show_pointmarker();
X		erase_compoundbox();
X		put_msg("MOVE POINTs (of POLYLINE, POLYGON, CLOSED-SPLINE, SPLINE and BOX)");
X		break;
X	    case F_REMOVE :
X		remove_selected();
X		show_pointmarker();
X		show_compoundbox();
X		put_msg("REMOVE objects");
X		break;
X	    case F_COPY :
X		copy_selected();
X		show_pointmarker();
X		show_compoundbox();
X		put_msg("COPY objects");
X		break;
X	    case F_ROTATE270 :
X		rotate_selected();
X		show_pointmarker();
X		show_compoundbox();
X		rotate_angle = 270;
X		put_msg("ROTATE objects (middle button) or COPY & ROTATE (left button) -90 degree");
X		break;
X	    case F_ROTATE90 :
X		rotate_selected();
X		show_pointmarker();
X		show_compoundbox();
X		rotate_angle = 90;
X		put_msg("ROTATE objects (middle button) or COPY & ROTATE (left button) 90 degree");
X		break;
X	    case F_FLIP_XAXIS :
X		flip_selected();
X		show_pointmarker();
X		show_compoundbox();
X		flip_axis = 1;
X		put_msg("FLIP objects (middle button) or COPY & FLIP (left button) up or down");
X		break;
X	    case F_FLIP_YAXIS :
X		flip_selected();
X		show_pointmarker();
X		show_compoundbox();
X		flip_axis = 2;
X		put_msg("FLIP objects (middle button) or COPY & FLIP (left button) left or right");
X		break;
X	    case F_TURN :
X		turn_selected();
X		show_pointmarker();
X		erase_compoundbox();
X		put_msg("Turn POLYGON (POLYLINE) into CLOSED-SPLINE (SPLINE) or vice versa");
X		break;
X	    case F_AUTOARROW :
X		arrow_head_selected();
X		show_pointmarker();
X		erase_compoundbox();
X		put_msg("ADD arrow head (left button); DELETE arrow head (middle button)");
X		break;
X	    case F_CHANGE_THICK:
X		change_thick_selected();
X		show_pointmarker();
X		erase_compoundbox();
X		put_msg("CHANGE LINE THICKNESS to current thickness of %d",
X			line_thickness);
X		break;
X	    case F_CHANGE_STYLE:
X		change_style_selected();
X		show_pointmarker();
X		erase_compoundbox();
X		put_msg("CHANGE LINE STYLE to current style");
X		break;
X	    case F_CHANGE_TEXT:
X		change_text_selected();
X		show_pointmarker();
X		erase_compoundbox();
X		put_msg("CHANGE TEXT to current font/type/size");
X		break;
X	    }
X	cur_command = sw->value;
X	}
X
Xstatic
Xset_geometry(sw)
XF_switch	*sw;
X{
X	extern int	manhattan_mode;
X	extern int	mountain_mode;
X	extern int	latexline_mode;
X	extern int	latexarrow_mode;
X
X	switch (sw->value) {
X	    case F_UNCONSTRAINT :
X		manhattan_mode = 0;
X		mountain_mode = 0;
X		latexline_mode = 0;
X		latexarrow_mode = 0;
X		put_msg("UNCONSTRAINT geometry (for POLYLINE and SPLINE)");
X		break;
X	    case F_MOUNTHATTAN :
X		mountain_mode = 1;
X		manhattan_mode = 1;
X		latexline_mode = 0;
X		latexarrow_mode = 0;
X		put_msg("MOUNT-HATTAN geometry (for POLYLINE and SPLINE)");
X		break;
X	    case F_MANHATTAN :
X		manhattan_mode = 1;
X		mountain_mode = 0;
X		latexline_mode = 0;
X		latexarrow_mode = 0;
X		put_msg("MANHATTAN geometry (for POLYLINE and SPLINE)");
X		break;
X	    case F_MOUNTAIN :
X		mountain_mode = 1;
X		manhattan_mode = 0;
X		latexline_mode = 0;
X		latexarrow_mode = 0;
X		put_msg("MOUNTAIN geometry (for POLYLINE and SPLINE)");
X		break;
X	    case F_LATEX_LINE :
X		latexline_mode = 1;
X		manhattan_mode = 0;
X		mountain_mode = 0;
X		latexarrow_mode = 0;
X		put_msg("LATEX LINE geometry: allow only LaTeX line slopes");
X		break;
X	    case F_LATEX_ARROW :
X		latexarrow_mode = 1;
X		manhattan_mode = 0;
X		mountain_mode = 0;
X		latexline_mode = 0;
X		put_msg("LATEX ARROW geometry: allow only LaTeX arrow slopes");
X		break;
X	    }
X	}
X
Xstatic
Xset_grid(sw)
XF_switch	*sw;
X{
X	setup_grid(sw->value);
X	}
X
Xstatic
Xmode_on(sw)
XF_switch	*sw;
X{
X	extern int	autoforwardarrow_mode;
X	extern int	autobackwardarrow_mode;
X	extern int	magnet_mode;
X
X	switch (sw->value) {
X	    case F_AUTOF_ARROW :
X		autoforwardarrow_mode = 1;
X		put_msg("AUTO FORWARD ARROW (for ARC, POLYLINE and SPLINE)");
X		break;
X	    case F_AUTOB_ARROW :
X		autobackwardarrow_mode = 1;
X		put_msg("AUTO BACKWARD ARROW (for ARC, POLYLINE and SPLINE)");
X		break;
X	    case F_MAGNET :
X		magnet_mode = 1;
X		put_msg("MAGNET: round entered points to the nearest %s increment",
X				(INCHES? "1/16\"": "2 mm"));
X		break;
X	    case F_FILL :
X		fill_mode = 1;
X		put_msg("FILL MODE (gray level = %.2f)",
X				1.0-(cur_areafill-1.0)/(NUMFILLPATS-1.0));
X		break;
X	    }
X	}
X
Xstatic
Xmode_off(sw)
XF_switch	*sw;
X{
X	extern int	autoforwardarrow_mode;
X	extern int	autobackwardarrow_mode;
X	extern int	magnet_mode;
X
X	switch (sw->value) {
X	    case F_AUTOF_ARROW :
X		autoforwardarrow_mode = 0;
X		break;
X	    case F_AUTOB_ARROW :
X		autobackwardarrow_mode = 0;
X		break;
X	    case F_MAGNET :
X		magnet_mode = 0;
X		break;
X	    case F_FILL :
X		fill_mode = 0;
X		put_msg("NO-FILL MODE");
X		break;
X	    }
X	}
X
Xstatic
Xset_style(sw)
XF_switch	*sw;
X{
X	extern int	cur_line_style;
X	extern float	cur_styleval;
X	extern float	cur_dashlength;
X	extern float	cur_dotgap;
X
X	switch (sw->value) {
X	    case F_SET_SOLID_LINE :
X		cur_line_style = SOLID_LINE;
X		cur_styleval = 0.0;
X		put_msg("SOLID LINE STYLE (for BOX, POLYGON and POLYLINE)");
X		break;
X	    case F_SET_DASH_LINE :
X		cur_line_style = DASH_LINE;
X		cur_styleval = cur_dashlength;
X		put_msg("DASH LINE STYLE (for BOX, POLYGON and POLYLINE)");
X		break;
X	    case F_SET_DOTTED_LINE :
X		cur_line_style = DOTTED_LINE;
X		cur_styleval = cur_dotgap;
X		put_msg("DOTTED LINE STYLE (for BOX, POLYGON and POLYLINE)");
X		break;
X	    }
X	}
X
X
Xstatic
Xdec_thick(sw)
XF_switch *sw;
X	{
X	if (line_thickness > 1)
X		--line_thickness;
X	show_line_thickness();
X	}
X
X#define MAXLINETHICK 200
X
Xstatic
Xinc_thick(sw)
XF_switch *sw;
X	{
X	if (line_thickness < MAXLINETHICK)
X		++line_thickness;
X	show_line_thickness();
X	}
X
Xstatic	Pixmap line_pm=0;
X
Xshow_line_thickness()
X	{
X	if (line_pm == 0)
X		line_pm = XCreatePixmap(tool_d, XtWindow(line_thick_panel),
X			SWITCH_ICON_WIDTH, SWITCH_ICON_HEIGHT,
X			DefaultDepthOfScreen(tool_s));
X	/* erase by drawing wide, inverted (white) line */
X	pw_vector(line_pm, 0, SWITCH_ICON_HEIGHT/2,
X		SWITCH_ICON_WIDTH, SWITCH_ICON_HEIGHT/2, ERASE, SWITCH_ICON_HEIGHT);
X	/* draw current line thickness into pixmap */
X	pw_vector(line_pm, 0, SWITCH_ICON_HEIGHT/2, 
X		SWITCH_ICON_WIDTH, SWITCH_ICON_HEIGHT/2, PAINT, line_thickness);
X
X	/* Fool the toolkit by changing the background pixmap to 0
X	   then giving it the modified one again.  Otherwise, it sees
X	   that the pixmap ID is not changed and doesn't actually draw
X	   it into the widget window */
X	indicator_panel_args[15].value = 0;
X	XtSetValues(line_thick_panel, &indicator_panel_args[15], 1);
X
X	/* put the pixmap in the widget background */
X	indicator_panel_args[15].value = line_pm;
X	XtSetValues(line_thick_panel, &indicator_panel_args[15], 1);
X	put_msg("LINE Thickness = %d",line_thickness);
X	}
X
X
Xstatic
Xdec_radius(sw)
XF_switch *sw;
X	{
X	--cur_radius;
X	show_radius();
X	}
X
X#define MAXRADIUS 30
X
Xstatic
Xinc_radius(sw)
XF_switch *sw;
X	{
X	++cur_radius;
X	show_radius();
X	}
X
Xstatic	Pixmap radius_pm=0;
X
Xshow_radius()
X	{
X	if (cur_radius > MAXRADIUS)
X		cur_radius = MAXRADIUS;
X	else if (cur_radius < 3)
X		cur_radius = 3;
X	if (radius_pm == 0)
X		radius_pm = XCreatePixmap(tool_d, XtWindow(radius_panel),
X			SWITCH_ICON_WIDTH, SWITCH_ICON_HEIGHT,
X			DefaultDepthOfScreen(tool_s));
X	/* erase by drawing wide, inverted (white) line */
X	pw_vector(radius_pm, 0, SWITCH_ICON_HEIGHT/2,
X		SWITCH_ICON_WIDTH, SWITCH_ICON_HEIGHT/2, ERASE, SWITCH_ICON_HEIGHT);
X	/* draw current radius into pixmap */
X	curve(radius_pm, 0, cur_radius, cur_radius, 0, 0, 1, 1, 
X		1, SWITCH_ICON_HEIGHT-2, foreground_color, 1, 0);
X
X	/* Fool the toolkit by changing the background pixmap to 0
X	   then giving it the modified one again.  Otherwise, it sees
X	   that the pixmap ID is not changed and doesn't actually draw
X	   it into the widget window */
X	indicator_panel_args[15].value = 0;
X	XtSetValues(radius_panel, &indicator_panel_args[15], 1);
X
X	/* put the pixmap in the widget background */
X	indicator_panel_args[15].value = radius_pm;
X	XtSetValues(radius_panel, &indicator_panel_args[15], 1);
X	put_msg("ROUNDED-CORNER BOX Radius = %d",cur_radius);
X	}
X
Xstatic
Xdarken_fill(sw)
X	{
X	if (cur_areafill < NUMFILLPATS)
X		++cur_areafill;
X	show_fill_color();
X	}
X
Xstatic
Xlighten_fill(sw)
X	{
X	if (cur_areafill > 1)
X		--cur_areafill;
X	show_fill_color();
X	}
X
Xshow_fill_color()
X	{
X	/* put fill pixmap in widget background */
X	indicator_panel_args[15].value = ind_fill_pm[cur_areafill-1]; 
X	XtSetValues(fill_panel, &indicator_panel_args[15], 1);
X	put_msg("FILL GRAY = %.2f", 1.0-(cur_areafill-1.0)/(NUMFILLPATS-1.0));
X	}
X
X/* save_n_exit */
X
Xstatic
Xsave_n_exit_button(sw)
XF_switch *sw;
X	{
X	save_n_exit();
X	}
X
X/* quit */
X
Xstatic
Xquit_button(sw)
XF_switch *sw;
X	{
X	quit();
X	}
X
X/* save file */
X
Xstatic
Xsave_button(sw)
XF_switch *sw;
X	{
X	save_current_file();
X	}
X
X/* save into file ... */
X
Xstatic
Xsave_in_button(sw)
XF_switch *sw;
X	{
X	if (no_object()) 
X		put_msg("No figure to save; ignored");
X	else
X		init_msg_receiving(save_file, "Save in file : ");
X	}
X
X/* read file */
X
Xstatic
Xread_button(sw)
XF_switch *sw;
X	{
X	init_msg_receiving(read_file,"Read file : ");
X	}
X
X/* edit file */
X
Xstatic
Xedit_button(sw)
XF_switch *sw;
X	{
X	init_msg_receiving(edit_file, "Edit file : ");
X	}
X
X/* change directories */
X
Xstatic
Xchangedir_button(sw)
XF_switch *sw;
X	{
X	init_msg_receiving(change_directory, "Directory : ");
X	}
X
X/* print working directory */
X
Xstatic
Xprint_wdir_button(sw)
XF_switch *sw;
X	{
X	print_directory();
X	}
X
X/* print figure */
X
Xstatic
Xprint_button(sw)
XF_switch *sw;
X	{
X	XFlush(tool_d);
X	print_figure();
X	}
X
X/* select printer */
X
Xstatic
Xprint_sel_button(sw)
XF_switch *sw;
X	{
X	printer_select();
X	}
X
Xprinter_select()
X	{
X	if (*printer != '\0')	/* increment printer number if not first time here */
X		{
X		if (++cur_printer >= MAXPRINTERS)
X			cur_printer=0;
X		}
X	printer=printer_list[cur_printer];
X	put_msg("SELECT PRINTER: %s",printer);
X
X	/* write the printer name in the background pixmap */
X	XDrawImageString(tool_d, print_sel_pm, button_gc, 
X			32, 14, printer, strlen(printer));
X
X	/* Fool the toolkit by changing the background pixmap to 0
X	   then giving it the modified one again.  Otherwise, it sees
X	   that the pixmap ID is not changed and doesn't actually draw
X	   it into the widget window */
X	button_args[5].value = 0;
X	XtSetValues(print_sel_widget, &button_args[5], 1);
X
X	/* put the pixmap in the widget background */
X	button_args[5].value = print_sel_pm;
X	XtSetValues(print_sel_widget, &button_args[5], 1);
X	}
X
X/* popup menu of printer fonts */
X
Xstatic
Xpopup_fonts(sw)
XF_switch *sw;
X	{
X	XtPopup(fontmenu,XtGrabNonexclusive);
X	setup_fontmenu_cursor();	/* now define the cursor for the font menu */
X	}
X
X/* set text justification to left/center or right */
X
Xstatic
Xtext_just_button(sw)
XF_switch *sw;
X	{
X	if (++type_button > T_RIGHT_JUSTIFIED)	/* increment to next (L/C/R) */
X		type_button = 0;
X	/* put the pixmap in the widget background */
X	text_just_sw->but.normal = text_just_sw->but.reverse = 
X		button_args[5].value = (XtArgVal) text_just_pm[type_button];
X	XtSetValues(text_just_sw->but.widget, &button_args[5], 1);
X	if (type_button==T_LEFT_JUSTIFIED)
X		put_msg("Left justify text");
X	else if (type_button==T_CENTER_JUSTIFIED)
X		put_msg("Center text");
X	else
X		put_msg("Right justify text");
X	}
X
X/* increase font size for print */
X
Xstatic
Xinc_size_button(sw)
XF_switch *sw;
X	{
X	if (size_button >= 100)
X		{
X		size_button = (size_button/10) * 10; /* round first */
X		size_button += 10;
X		}
X	else if (size_button >= 50)
X		{
X		size_button = (size_button/5) * 5;
X		size_button += 5;
X		}
X	else if (size_button >= 10)
X		{
X		size_button = (size_button/2) * 2;
X		size_button += 2;
X		}
X	else
X		size_button++;
X	show_fontsize();
X	}
X
X
X/* decrease font size for print */
X
Xstatic
Xdec_size_button(sw)
XF_switch *sw;
X	{
X	if (size_button > 100)
X		{
X		size_button = (size_button/10) * 10; /* round first */
X		size_button -= 10;
X		}
X	else if (size_button > 50)
X		{
X		size_button = (size_button/5) * 5;
X		size_button -= 5;
X		}
X	else if (size_button > 10)
X		{
X		size_button = (size_button/2) * 2;
X		size_button -= 2;
X		}
X	else if (size_button > 4)
X		size_button--;
X	show_fontsize();
X	}
X
Xstatic char tmpsiz[5];
X
Xshow_fontsize()
X	{
X	put_msg("Font size %d",size_button);
X	/* write the font size in the background pixmap */
X	tmpsiz[0]=tmpsiz[1]=tmpsiz[2]=tmpsiz[3]=tmpsiz[4]='\0';
X	sprintf(tmpsiz,"%3d",size_button);
X	XDrawImageString(tool_d, font_size_pm, button_gc, 
X			31, 12, tmpsiz, strlen(tmpsiz));
X
X	/* Fool the toolkit by changing the background pixmap to 0
X	   then giving it the modified one again.  Otherwise, it sees
X	   that the pixmap ID is not changed and doesn't actually draw
X	   it into the widget window */
X	button_args[5].value = 0;
X	XtSetValues(font_size_widget, &button_args[5], 1);
X
X	/* put the pixmap in the widget background */
X	button_args[5].value = font_size_pm;
X	XtSetValues(font_size_widget, &button_args[5], 1);
X	}
X
X/* change landscape/portrait flag for print */
X
Xstatic
Xland_button(sw)
XF_switch *sw;
X	{
X	print_landscape = 1-print_landscape;
X	land_port();	/* display new state */
X	}
X
X/* this is callable from the 'edit' file routine */
X
Xland_port()
X	{
X	land_port_sw->but.normal = land_port_sw->but.reverse = 
X		button_args[5].value = (XtArgVal) (print_landscape? Lp_pm: lP_pm);
X	XtSetValues(land_port_sw->but.widget, &button_args[5], 1);
X	put_msg("Print in %s mode",print_landscape? "LANDSCAPE": "PORTRAIT");
X	}
X
X/* undo last operation */
X
Xstatic
Xundo_button(sw)
XF_switch *sw;
X	{
X	undo();
X	}
X
X/* redisplay */
X
Xstatic
Xredisp_button(sw)
XF_switch *sw;
X	{
X	redisplay_canvas();
X	}
X
Xturn_on(s)
X	F_switch	*s;
X{
X	s->on = 1;
X	button_args[5].value = (XtArgVal)s->but.reverse;
X	XtSetValues(s->but.widget, &button_args[5], 1);
X}
X
Xturn_off(s)
X	F_switch	*s;
X{
X	s->on = 0;
X	button_args[5].value = (XtArgVal)s->but.normal;
X	XtSetValues(s->but.widget, &button_args[5], 1);
X}
X
Xstatic 
Xswitch_action(sw)
XF_switch	*sw;
X{
X	F_switch	*old;
X
X	if (sw == NULL) return;
X
X	if (sw->group == -1) {
X	    if (sw->on) {
X		turn_off(sw);
X		off_action(sw);
X		}
X	    else {
X		turn_on(sw);
X		on_action(sw);
X		}
X	    if (sw->type == S_MOMENT)	/* added B.V.Smith */
X		{
X		turn_off(sw);
X		off_action(sw);
X		}
X	    return;
X	    }
X
X	old = group[sw->group];
X	if (old == sw) {
X	    if (old->type != S_ON) {
X		turn_off(old);
X		off_action(old);
X		group[old->group] = NULL;
X		}
X	    return;
X	    }
X	else if (old) {
X	    turn_off(old);
X	    off_action(old);
X	    }
X
X	turn_on(sw);
X	on_action(sw);
X	group[sw->group] = sw;
X	if (sw->type == S_MOMENT)	/* added B.V.Smith */
X		{
X		turn_off(sw);
X		off_action(sw);
X		}
X	}
END_OF_FILE
if test 39156 -ne `wc -c <'xfig/panel.c'`; then
    echo shar: \"'xfig/panel.c'\" unpacked with wrong size!
fi
# end of 'xfig/panel.c'
fi
if test -f 'xfig/patchlevel.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/patchlevel.h'\"
else
echo shar: Extracting \"'xfig/patchlevel.h'\" \(21 characters\)
sed "s/^X//" >'xfig/patchlevel.h' <<'END_OF_FILE'
X#define PATCHLEVEL 2
END_OF_FILE
if test 21 -ne `wc -c <'xfig/patchlevel.h'`; then
    echo shar: \"'xfig/patchlevel.h'\" unpacked with wrong size!
fi
# end of 'xfig/patchlevel.h'
fi
if test -f 'xfig/ruler.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xfig/ruler.c'\"
else
echo shar: Extracting \"'xfig/ruler.c'\" \(12468 characters\)
sed "s/^X//" >'xfig/ruler.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 "font.h"
X#include "paintop.h"
X
X#define			INCH_MARK		12
X#define			HALF_MARK		11
X#define			QUARTER_MARK		8
X#define			SIXTEENTH_MARK		6
X
X#define			MARK_HT			5
X#define			TRM_WID			16
X#define			TRM_HT			8
X#define			SRM_WID			8
X#define			SRM_HT			16
X
Xextern int		CANVAS_HEIGHT, CANVAS_WIDTH;
Xextern int		SIDERULER_WIDTH, SIDERULER_HEIGHT;
Xextern int		TOPRULER_WIDTH, TOPRULER_HEIGHT;
Xextern int		SIDERULER_HEIGHT, SIDERULER_START;
Xextern int		TOPRULER_LEFT, TOPRULER_TOP;
Xextern			null_proc();
Xextern int		RHS_PANEL;
Xextern int		TRACKING;
Xextern int		INCHES;
X
Xstatic			lasty = -100;
Xstatic			lastx = -100;
Xstatic int	 	start;
Xstatic char		*number[] = {"0", "1", "2", "3", "4", "5", 
X					"6", "7", "8", "9", "10", "11" };
Xstatic int		troffx = -7, troffy = -10;
Xstatic char		tr_marker_image[16] = {
X				0xFF, 0xFE,	/* *************** */
X				0x7F, 0xFC,	/*  *************  */
X				0x3F, 0xF8,	/*   ***********   */
X				0x1F, 0xF0,	/*    *********    */
X				0x0F, 0xE0,	/*     *******     */
X				0x07, 0xC0,	/*      *****      */
X				0x03, 0x80,	/*       ***       */
X				0x01, 0x00	/*        *        */
X				};
Xstatic			mpr_static(trm_pr, TRM_WID, TRM_HT, 1, tr_marker_image);
Xstatic int		srroffx = 2, srroffy = -7;
Xstatic char		srr_marker_image[16] = {
X				0x01,	/*          *  */
X				0x03,	/*         **  */
X				0x07,	/*        ***  */
X				0x0F,	/*       ****  */
X				0x1F,	/*      *****  */
X				0x3F,	/*     ******  */
X				0x7F,	/*    *******  */
X				0xFF,	/*   ********  */
X				0x7F,	/*    *******  */
X				0x3F,	/*     ******  */
X				0x1F,	/*      *****  */
X				0x0F,	/*       ****  */
X				0x07,	/*        ***  */
X				0x03,	/*         **  */
X				0x01,	/*          *  */
X				0x00
X				};
Xstatic		mpr_static(srrm_pr, SRM_WID, SRM_HT, 1, srr_marker_image);
X
Xstatic int		srloffx = -10, srloffy = -7;
Xstatic char		srl_marker_image[16] = {
X				0x80,	/*  *          */
X				0xC0,	/*  **         */
X				0xE0,	/*  ***        */
X				0xF0,	/*  ****       */
X				0xF8,	/*  *****      */
X				0xFC,	/*  ******     */
X				0xFE,	/*  *******    */
X				0xFF,	/*  ********   */
X				0xFE,	/*  *******    */
X				0xFC,	/*  ******     */
X				0xF8,	/*  *****      */
X				0xF0,	/*  ****       */
X				0xE0,	/*  ***        */
X				0xC0,	/*  **         */
X				0x80,	/*  *          */
X				0x00
X				};
Xstatic		mpr_static(srlm_pr, SRM_WID, SRM_HT, 1, srl_marker_image);
X
Xstatic Pixmap		toparrow_pm, sidearrow_pm;
X
Xset_toprulermark(x)
Xint	x;
X{
X	XClearArea(tool_d, topruler_pixwin,lastx + troffx,
X		   TOPRULER_HEIGHT + troffy,trm_pr.width,
X		   trm_pr.height, False);
X	XCopyArea(tool_d, toparrow_pm, topruler_pixwin, topgc,
X		0, 0, trm_pr.width, trm_pr.height,
X		x + troffx, TOPRULER_HEIGHT + troffy);
X	lastx = x;
X	}
X
Xstatic Arg	ruler_args[] =
X{
X	/*  0 */ { XtNx, (XtArgVal)0 },
X	/*  1 */ { XtNy, (XtArgVal)0 },
X	/*  2 */ { XtNwidth, (XtArgVal)0 },
X	/*  3 */ { XtNheight, (XtArgVal)0 },
X	/*  4 */ { XtNlabel, (XtArgVal)"" },
X	/*  5 */ { XtNfromHoriz, (XtArgVal)NULL },
X	/*  6 */ { XtNhorizDistance, (XtArgVal)0 },
X	/*  7 */ { XtNfromVert, (XtArgVal)NULL },
X	/*  8 */ { XtNvertDistance, (XtArgVal)0 },
X	/*  9 */ { XtNresizable, (XtArgVal)FALSE },
X	/* 10 */ { XtNtop, (XtArgVal)XtRubber },
X	/* 11 */ { XtNbottom, (XtArgVal)XtRubber },
X	/* 12 */ { XtNleft, (XtArgVal)XtRubber },
X	/* 13 */ { XtNright, (XtArgVal)XtRubber },
X};
X
Xextern int	SIDERULER_WIDTH, SIDERULER_HEIGHT;
Xextern int	TOPRULER_WIDTH, TOPRULER_HEIGHT;
X
Xint init_sideruler(tool)
X	TOOL		tool;
X{
X	ruler_args[2].value = SIDERULER_WIDTH = RULER_WIDTH;
X	ruler_args[3].value = SIDERULER_HEIGHT = CANVAS_HEIGHT;
X	ruler_args[5].value = (XtArgVal)canvas_sw;
X	ruler_args[7].value = (XtArgVal)topruler_sw;
X	/* Place the sideruler below the topruler, next to the canvas,
X	   but fixed offset from the top of the form */
X	ruler_args[10].value = (XtArgVal)XtChainTop;
X	ruler_args[11].value = (XtArgVal)XtRubber;
X	ruler_args[12].value = (XtArgVal)XtRubber;
X	ruler_args[13].value = (XtArgVal)XtRubber;
X	
X	sideruler_sw = XtCreateWidget("sruler", labelWidgetClass, tool,
X		ruler_args, XtNumber(ruler_args));
X	return(1);
X}
X
Xredisplay_sideruler()
X{
X	XClearWindow(tool_d, sideruler_pixwin);
X}
X
Xsetup_rulers()
X{
X	register int		i, j;
X	register Pixmap		p;
X#define	QINCH	(PIX_PER_INCH / 4)
X#define	SINCH	(PIX_PER_INCH / 16)
X#define TWOMM	(PIX_PER_CM / 5)	
X	char			number[3];
X	Arg			tmp_arg[3];
X	long			bg, fg;
X	static Arg		ruler_args[] =
X	{
X		{ XtNbackgroundPixmap, (XtArgVal)NULL },
X	};
X
X	topruler_pixwin = trswfd = XtWindow(topruler_sw);
X	sideruler_pixwin = srswfd = XtWindow(sideruler_sw);
X	XDefineCursor(tool_d, trswfd, (Cursor)bull_cursor.bitmap);
X	XDefineCursor(tool_d, srswfd, (Cursor)bull_cursor.bitmap);
X
X	/* top ruler, adjustments for digits are kludges based on 6x13 char */
X	p = XCreatePixmap(tool_d, topruler_pixwin,
X			  TOPRULER_WIDTH, TOPRULER_HEIGHT,
X			  DefaultDepthOfScreen(tool_s));
X
X	XtSetArg(tmp_arg[0], XtNbackground, &bg);
X	XtSetArg(tmp_arg[1], XtNforeground, &fg);
X	XtGetValues(topruler_sw, tmp_arg, 2);
X
X	XSetBackground(tool_d, gc, bg);
X	XSetForeground(tool_d, gc, bg);
X	XFillRectangle(tool_d, p, gc, 0, 0, TOPRULER_WIDTH,
X			TOPRULER_HEIGHT);
X	XSetForeground(tool_d, gc, fg);
X	
X	XDrawString(tool_d, p, gc, 2, TOPRULER_HEIGHT - INCH_MARK - 3,
X		    INCHES ? "in" : "cm", 2);
X	if(INCHES) for (i = SINCH - 1; i <= TOPRULER_WIDTH; i += SINCH)
X	{
X		j = i + 1;
X		if (j % PIX_PER_INCH == 0)
X		{
X			XDrawLine(tool_d, p, gc, i, TOPRULER_HEIGHT - 1, i,
X				TOPRULER_HEIGHT - INCH_MARK - 1);
X			sprintf(number, "%d", j / PIX_PER_INCH);
X			XDrawString(tool_d, p, gc, i - 2,
X				TOPRULER_HEIGHT - INCH_MARK - 3, number,
X				j < PIX_PER_INCH * 10 ? 1 : 2);
X		}
X		else if (j % QINCH == 0)
X			XDrawLine(tool_d, p, gc, i, TOPRULER_HEIGHT - 1, i,
X				TOPRULER_HEIGHT - QUARTER_MARK - 1);
X		else if (j % SINCH == 0)
X			XDrawLine(tool_d, p, gc, i, TOPRULER_HEIGHT - 1, i,
X				TOPRULER_HEIGHT - SIXTEENTH_MARK - 1);
X	}
X	else for (i = TWOMM - 1; i <= TOPRULER_WIDTH; i++)
X	{
X		j = i + 1;
X		if (j % PIX_PER_CM == 0)
X		{
X			XDrawLine(tool_d, p, gc, i, TOPRULER_HEIGHT - 1, i,
X				  TOPRULER_HEIGHT - INCH_MARK - 1);
X			sprintf(number, "%d", j / PIX_PER_CM);
X			XDrawString(tool_d, p, gc, i - 2,
X				    TOPRULER_HEIGHT - INCH_MARK - 3, number,
X				    j < PIX_PER_CM * 10 ? 1 : 2);
X		}
X		else if (j % TWOMM == 0)
X			XDrawLine(tool_d, p, gc, i, TOPRULER_HEIGHT - 1, i,
X				  TOPRULER_HEIGHT - QUARTER_MARK - 1);
X	}
X	ruler_args[0].value = (XtArgVal)p;
X	XtSetValues(topruler_sw, ruler_args, 1);
X
X	/* The arrows will be XORed into the rulers.
X	   We want the foreground color in the arrow to result in
X	   the foreground or background color in the display.
X	   so if the source pixel is fg^bg, it produces fg when XOR'ed
X	   with bg, and bg when XOR'ed with bg.
X
X	   If the source pixel is zero, it produces fg when XOR'ed with
X	   fg, and bg when XOR'ed with bg.
X	   */
X	XSetForeground(tool_d, gc, fg ^ bg);
X	XSetBackground(tool_d, gc, 0);
X
X	/* make pixmaps for top ruler arrow */
X	toparrow_pm = XCreatePixmap(tool_d, topruler_pixwin, trm_pr.width,
X				    trm_pr.height,
X				    DefaultDepthOfScreen(tool_s));
X	XPutImage(tool_d, toparrow_pm, gc, &trm_pr, 0, 0, 0, 0,
X		trm_pr.width, trm_pr.height);
X	
X	/* side ruler, adjustments for digits are kludges based on 6x13 char */
X	p = XCreatePixmap(tool_d, sideruler_pixwin,
X			  SIDERULER_WIDTH, SIDERULER_HEIGHT,
X			  DefaultDepthOfScreen(tool_s));
X	XtSetArg(tmp_arg[0], XtNbackground, &bg);
X	XtSetArg(tmp_arg[1], XtNforeground, &fg);
X	XtGetValues(sideruler_sw, tmp_arg, 2);
X
X	XSetBackground(tool_d, gc, bg);
X	XSetForeground(tool_d, gc, bg);
X	XFillRectangle(tool_d, p, gc, 0, 0, SIDERULER_WIDTH,
X			SIDERULER_HEIGHT);
X	XSetForeground(tool_d, gc, fg);
X	
X	if( INCHES ) 
X	{
X		if( RHS_PANEL )
X		{
X		for (i = SINCH - 1; i <= SIDERULER_HEIGHT; i += SINCH)
X		{
X			j = i + 1;
X			if (j % PIX_PER_INCH == 0)
X			{
X				XDrawLine(tool_d, p, gc, RULER_WIDTH-INCH_MARK,
X					  i, RULER_WIDTH, i);
X				sprintf(number, "%d", j / PIX_PER_INCH);
X				XDrawString(tool_d, p, gc,
X					    RULER_WIDTH-INCH_MARK - 8, i + 3,
X					    number, j < PIX_PER_INCH * 10 ? 1 : 2);
X			}
X			else if (j % QINCH == 0)
X				XDrawLine(tool_d, p, gc,
X					  RULER_WIDTH-QUARTER_MARK, i,
X					  RULER_WIDTH, i);
X			else if (j % SINCH == 0)
X				XDrawLine(tool_d, p, gc,
X					  RULER_WIDTH-SIXTEENTH_MARK, i,
X					  RULER_WIDTH, i);
X		}
X		}
X		else
X		{
X		for (i = SINCH - 1; i <= SIDERULER_HEIGHT; i += SINCH)
X		{
X			j = i + 1;
X			if (j % PIX_PER_INCH == 0)
X			{
X				XDrawLine(tool_d, p, gc, 0, i,
X					  INCH_MARK - 1, i);
X				sprintf(number, "%d", j / PIX_PER_INCH);
X				XDrawString(tool_d, p, gc, INCH_MARK + 3,
X					    i + 3, number,
X					    j < PIX_PER_INCH * 10 ? 1 : 2);
X			}	
X			else if (j % QINCH == 0)
X				XDrawLine(tool_d, p, gc, 0, i,
X					  QUARTER_MARK - 1, i);
X			else if (j % SINCH == 0)
X				XDrawLine(tool_d, p, gc, 0, i,
X					  SIXTEENTH_MARK - 1, i);
X		}	
X		}
X	}
X	else 
X	{
X		if( RHS_PANEL )
X		{
X		for (i = TWOMM - 1; i <= SIDERULER_HEIGHT; i++)
X		{
X			j = i + 1;
X			if (j % PIX_PER_CM == 0)
X			{
X				XDrawLine(tool_d, p, gc, RULER_WIDTH-INCH_MARK,
X					  i, RULER_WIDTH, i);
X				sprintf(number, "%d", j / PIX_PER_CM);
X				XDrawString(tool_d, p, gc,
X					    RULER_WIDTH-INCH_MARK - 8, i + 3,
X					    number, j < PIX_PER_CM * 10 ? 1 : 2);
X			}
X			else if (j % TWOMM == 0)
X				XDrawLine(tool_d, p, gc,
X					  RULER_WIDTH-QUARTER_MARK, i,
X					  RULER_WIDTH, i);
X		}
X		}
X		else
X		{
X		for (i = TWOMM - 1; i <= SIDERULER_HEIGHT; i++)
X		{
X			j = i + 1;
X			if (j % PIX_PER_CM == 0)
X			{
X				XDrawLine(tool_d, p, gc, 0, i,
X					  INCH_MARK - 1, i);
X				sprintf(number, "%d", j / PIX_PER_CM);
X				XDrawString(tool_d, p, gc, INCH_MARK + 3,
X					    i + 3, number,
X					    j < PIX_PER_CM * 10 ? 1 : 2);
X			}
X			else if (j % TWOMM == 0)
X				XDrawLine(tool_d, p, gc, 0, i,
X					  QUARTER_MARK - 1, i);
X                }
X		}
X	}
X	ruler_args[0].value = (XtArgVal)p;
X	XtSetValues(sideruler_sw, ruler_args, 1);
X
X	/* Colors set as above */
X	XSetForeground(tool_d, gc, fg ^ bg);
X	XSetBackground(tool_d, gc, 0);
X
X	/* make pixmaps for side ruler arrow */
X	if( RHS_PANEL )
X	{
X		sidearrow_pm = XCreatePixmap(tool_d, sideruler_pixwin,
X					     srlm_pr.width, srlm_pr.height,
X					     DefaultDepthOfScreen(tool_s));
X		XPutImage(tool_d, sidearrow_pm, gc, &srlm_pr, 0, 0, 0, 0,
X			  srlm_pr.width, srlm_pr.height);
X	}
X	else
X	{
X		sidearrow_pm = XCreatePixmap(tool_d, sideruler_pixwin,
X					     srrm_pr.width, srrm_pr.height,
X					     DefaultDepthOfScreen(tool_s));
X		XPutImage(tool_d, sidearrow_pm, gc, &srrm_pr, 0, 0, 0, 0,
X			  srrm_pr.width, srrm_pr.height);
X	}
X}
X
Xint init_topruler(tool)
X	TOOL		tool;
X{
X	ruler_args[2].value = TOPRULER_WIDTH = CANVAS_WIDTH;;	/* width */
X	ruler_args[3].value = TOPRULER_HEIGHT = RULER_WIDTH;	/* height */
X	ruler_args[5].value = (XtArgVal)panel_sw;
X	ruler_args[7].value = (XtArgVal)NULL;
X	/* fix the top & bottom to the top of the form,
X	   the left to the panel, and the right is rubber */
X	ruler_args[10].value = (XtArgVal)XtChainTop;
X	ruler_args[11].value = (XtArgVal)XtChainTop;
X	ruler_args[12].value = (XtArgVal)XtChainLeft;
X	ruler_args[13].value = (XtArgVal)XtRubber;
X	
X	topruler_sw = XtCreateWidget("truler", labelWidgetClass, tool,
X		ruler_args, XtNumber(ruler_args));
X	return(1);
X}
X
Xredisplay_topruler()
X{
X	XClearWindow(tool_d, topruler_pixwin);
X}
X
Xset_rulermark(x, y)
Xint	x, y;
X{
X	if( TRACKING )
X	{
X		set_siderulermark(y);
X		set_toprulermark(x);
X	}
X}
X
Xredisplay_rulers()
X{
X	redisplay_topruler();
X	redisplay_sideruler();
X}
X
Xset_siderulermark(y)
Xint	y;
X{
X	int	sy;
X
X	if( RHS_PANEL ) {
X		/* Because the ruler uses a background pixmap, we can win
X		   here by using XClearArea to erase the old thing. */
X		XClearArea(tool_d, sideruler_pixwin,
X			   RULER_WIDTH+srloffx, lasty + srloffy,
X			   srlm_pr.width, srlm_pr.height, False);
X		XCopyArea(tool_d, sidearrow_pm, sideruler_pixwin,
X			  sidegc, 0, 0, srlm_pr.width,
X			  srlm_pr.height, RULER_WIDTH+srloffx, y + srloffy);
X	}
X	else
X	{
X		/* Because the ruler uses a background pixmap, we can win
X		   here by using XClearArea to erase the old thing. */
X		XClearArea(tool_d, sideruler_pixwin,
X			   srroffx, lasty + srroffy,
X			   srlm_pr.width, srlm_pr.height, False);
X		XCopyArea(tool_d, sidearrow_pm, sideruler_pixwin,
X			  sidegc, 0, 0, srrm_pr.width,
X			  srrm_pr.height, srroffx, y + srroffy);
X	}
X	lasty = y;
X}
END_OF_FILE
if test 12468 -ne `wc -c <'xfig/ruler.c'`; then
    echo shar: \"'xfig/ruler.c'\" unpacked with wrong size!
fi
# end of 'xfig/ruler.c'
fi
echo shar: End of archive 4 \(of 15\).
cp /dev/null ark4isdone
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.