🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.x.apps
Article #765

BETA Version of XPaint 2.0 -- Part 4 / 5

#765
From: David Koblas
Date: Thu, 09 Jul 1992 21:09
1929 lines
62584 bytes
#! /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 5)."
# Contents:  ArcOp.c Colormap.h ColormapP.h EraseOp.c FatbitsEdit.c
#   FontOp.c FontSelect.c Hash.h LineOp.c Misc.c Paint.h PaintP.h
#   PencilOp.c Undo.c bitmaps/pattern2.xbm bitmaps/pattern4.xbm
#   bitmaps/pattern5.xbm bitmaps/pattern6.xbm bitmaps/pencilOp.xbm
#   bitmaps/selareaOp.xbm bitmaps/selectOp.xbm main.c region.h
#   xpaint.h
# Wrapped by koblas@bananajr on Thu Jul  9 14:00:23 1992
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'ArcOp.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ArcOp.c'\"
else
echo shar: Extracting \"'ArcOp.c'\" \(4008 characters\)
sed "s/^X//" >'ArcOp.c' <<'END_OF_FILE'
X/* +-------------------------------------------------------------------+ */
X/* | Copyright 1992, David Koblas.                                     | */
X/* |   Permission to use, copy, modify, and distribute this software   | */
X/* |   and its documentation for any purpose and without fee is hereby | */
X/* |   granted, provided that the above copyright notice appear in all | */
X/* |   copies and that both that copyright notice and this permission  | */
X/* |   notice appear in supporting documentation.  This software is    | */
X/* |   provided "as is" without express or implied warranty.           | */
X/* +-------------------------------------------------------------------+ */
X
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include "xpaint.h"
X
Xtypedef struct {
X	int	rx, ry, startX, startY, endX, endY, drawn;
X} LocalInfo;
X
X#define MKRECT(rect, sx, sy, ex, ey) do {				\
X	(rect)->x      = MIN(sx, ex);					\
X	(rect)->y      = MIN(sy, ey);					\
X	(rect)->width  = MAX(sx, ex) - (rect)->x;			\
X	(rect)->height = MAX(sy, ey) - (rect)->y;			\
X	if (flag) {							\
X		(rect)->width = MIN((rect)->width, (rect)->height);	\
X		(rect)->height = (rect)->width; 			\
X	}								\
X	if (sx < ex) {							\
X		if (sy < ey) {						\
X			/* +,+ */					\
X			(rect)->x -= (rect)->width;			\
X			(rect)->angle1 =   0*64;			\
X			(rect)->angle2 =  90*64;			\
X		} else {						\
X			/* +,- */					\
X			/* No Change */					\
X			(rect)->angle1 =  90*64;			\
X			(rect)->angle2 =  90*64;			\
X		}							\
X	} else {							\
X		if (sy < ey) {						\
X			/* -,+ */					\
X			(rect)->x -= (rect)->width;			\
X			(rect)->y -= (rect)->height;			\
X			(rect)->angle1 =   0*64;			\
X			(rect)->angle2 = -90*64;			\
X		} else {						\
X			/* -,- */					\
X			(rect)->y -= (rect)->height;			\
X			(rect)->angle1 = -90*64;			\
X			(rect)->angle2 = -90*64;			\
X		}							\
X	}								\
X	(rect)->width *= 2;						\
X	(rect)->height *= 2;						\
X	} while (0)
X
Xstatic void	press(Widget w, LocalInfo *l, XButtonEvent *event, OpInfo *info)
X{
X	l->rx   = info->x;
X	l->ry   = info->y;
X	l->endX = l->startX = event->x;
X	l->endY = l->startY = event->y;
X
X	l->drawn = False;
X}
X
X
Xstatic void	motion(Widget w, LocalInfo *l, 
X			XMotionEvent *event, OpInfo *info) 
X{
X	Boolean	flag = False;
X	XArc	rect;
X
X	if (l->drawn) {
X		MKRECT(&rect, l->startX, l->startY, l->endX, l->endY);
X
X		XDrawArcs(XtDisplay(w), XtWindow(w), Global.gcx,
X				&rect, 1);
X	}
X
X	l->endX = event->x;
X	l->endY = event->y;
X
X	/*
X	**  Really set this flag in the if statement
X	*/
X	if (l->drawn = (l->startX != l->endX && l->startY != l->endY)) {
X		MKRECT(&rect, l->startX, l->startY, l->endX, l->endY);
X
X		XDrawArcs(XtDisplay(w), XtWindow(w), Global.gcx,
X				&rect, 1);
X	}
X}
X
Xstatic void	release(Widget w, LocalInfo *l, 
X				XButtonEvent *event, OpInfo *info) 
X{
X	XArc		rect;
X	Boolean		flag = False;
X	XRectangle	undo;
X
X	if (l->drawn && info->surface == opWindow)  {
X		MKRECT(&rect, l->startX, l->startY, l->endX, l->endY);
X
X		XDrawArcs(XtDisplay(w), XtWindow(w), Global.gcx,
X				&rect, 1);
X	}
X
X        if (info->surface == opWindow && info->isFat)
X		return;
X
X	UndoStart(w, info);
X
X	MKRECT(&rect, l->rx, l->ry, event->x, event->y);
X	XDrawArcs(XtDisplay(w), info->drawable, info->filled_gc, &rect, 1);
X
X	if (info->surface == opPixmap) {
X		XYtoRECT(l->rx, l->ry, event->x, event->y, &undo);
X		UndoSetRectangle(w, &undo);
X		PwUpdate(w, &undo, False);
X	}
X}
X
X/*
X**  Those public functions
X*/
Xvoid *ArcAdd(Widget w)
X{
X	LocalInfo	*l = (LocalInfo*)XtMalloc(sizeof(LocalInfo));
X
X	OpAddEventHandler(w, opWindow, ButtonPressMask, FALSE, press, l);
X	OpAddEventHandler(w, opWindow, ButtonMotionMask, FALSE, motion, l);
X	OpAddEventHandler(w, opWindow|opPixmap, ButtonReleaseMask, FALSE, release, l);
X	SetCrossHairCursor(w);
X	return l;
X}
Xvoid ArcRemove(Widget w, LocalInfo *l)
X{
X	OpRemoveEventHandler(w, opWindow, ButtonPressMask, FALSE, press, l);
X	OpRemoveEventHandler(w, opWindow, ButtonMotionMask,FALSE, motion, l);
X	OpRemoveEventHandler(w, opWindow|opPixmap, ButtonReleaseMask, FALSE, release, l);
X	XtFree(l);
X}

END_OF_FILE
echo shar: NEWLINE appended to \"'ArcOp.c'\"
if test 4009 -ne `wc -c <'ArcOp.c'`; then
    echo shar: \"'ArcOp.c'\" unpacked with wrong size!
fi
# end of 'ArcOp.c'
fi
if test -f 'Colormap.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Colormap.h'\"
else
echo shar: Extracting \"'Colormap.h'\" \(2075 characters\)
sed "s/^X//" >'Colormap.h' <<'END_OF_FILE'
X#ifndef _Colormap_h
X#define _Colormap_h
X
X/* +-------------------------------------------------------------------+ */
X/* | Copyright 1992, David Koblas.                                     | */
X/* |   Permission to use, copy, modify, and distribute this software   | */
X/* |   and its documentation for any purpose and without fee is hereby | */
X/* |   granted, provided that the above copyright notice appear in all | */
X/* |   copies and that both that copyright notice and this permission  | */
X/* |   notice appear in supporting documentation.  This software is    | */
X/* |   provided "as is" without express or implied warranty.           | */
X/* +-------------------------------------------------------------------+ */
X
X
X/****************************************************************
X *
X * Colormap widget
X *
X ****************************************************************/
X
X/* Resources:
X
X Name		     Class		RepType		Default Value
X ----		     -----		-------		-------------
X background	     Background		Pixel		XtDefaultBackground
X border		     BorderColor	Pixel		XtDefaultForeground
X borderWidth	     BorderWidth	Dimension	1
X destroyCallback     Callback		Pointer		NULL
X height		     Height		Dimension	0
X mappedWhenManaged   MappedWhenManaged	Boolean		True
X sensitive	     Sensitive		Boolean		True
X width		     Width		Dimension	0
X x		     Position		Position	0
X y		     Position		Position	0
X
X*/
X
X/* define any special resource names here that are not in <X11/StringDefs.h> */
X
X#define XtNcellWidth  "cellWidth"
X#define XtNcellHeight "cellHeight"
X#define XtNcolor      "color"
X#define XtNreadOnly   "readOnly"
X
X#define XtCCellWidth  "CellWidth"
X#define XtCCellHeight "CellHeight"
X#define XtCColor      "Color"
X
X/* declare specific ColormapWidget class and instance datatypes */
X
Xtypedef struct _ColormapClassRec*	ColormapWidgetClass;
Xtypedef struct _ColormapRec*		ColormapWidget;
X
X/* declare the class constant */
X
Xextern WidgetClass colormapWidgetClass;
X
Xextern void CwGetColor(Widget, XColor *);
Xextern void CwSetColor(Widget, XColor *);
X
X#endif /* _Colormap_h */

END_OF_FILE
echo shar: NEWLINE appended to \"'Colormap.h'\"
if test 2076 -ne `wc -c <'Colormap.h'`; then
    echo shar: \"'Colormap.h'\" unpacked with wrong size!
fi
# end of 'Colormap.h'
fi
if test -f 'ColormapP.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ColormapP.h'\"
else
echo shar: Extracting \"'ColormapP.h'\" \(1598 characters\)
sed "s/^X//" >'ColormapP.h' <<'END_OF_FILE'
X#include <X11/copyright.h>
X
X/* +-------------------------------------------------------------------+ */
X/* | Copyright 1992, David Koblas.                                     | */
X/* |   Permission to use, copy, modify, and distribute this software   | */
X/* |   and its documentation for any purpose and without fee is hereby | */
X/* |   granted, provided that the above copyright notice appear in all | */
X/* |   copies and that both that copyright notice and this permission  | */
X/* |   notice appear in supporting documentation.  This software is    | */
X/* |   provided "as is" without express or implied warranty.           | */
X/* +-------------------------------------------------------------------+ */
X
X
X#ifndef _ColormapP_h
X#define _ColormapP_h
X
X#include "Colormap.h"
X/* include superclass private header file */
X#include <X11/CoreP.h>
X
X/* define unique representation types not found in <X11/StringDefs.h> */
X
X#define XtRColormapResource "ColormapResource"
X
Xtypedef struct {
X    int empty;
X} ColormapClassPart;
X
Xtypedef struct _ColormapClassRec {
X    CoreClassPart	core_class;
X    ColormapClassPart	colormap_class;
X} ColormapClassRec;
X
Xextern ColormapClassRec colormapClassRec;
X
Xtypedef struct {
X	Boolean		editable;
X	int		ncel, curcel;
X	Pixel		pixel;
X	Colormap	cmap;
X	XtCallbackProc	select;
X	int		cheight, cwidth;	/* cell width, height */
X	int		ncheight, ncwidth;	/* cell width, height */
X	XtCallbackList	callbacks;
X	int		thickness;
X	Pixel		foreground;
X} ColormapPart;
X
Xtypedef struct _ColormapRec {
X    CorePart		core;
X    ColormapPart	color;
X} ColormapRec;
X
X#endif /* _ColormapP_h */

END_OF_FILE
echo shar: NEWLINE appended to \"'ColormapP.h'\"
if test 1599 -ne `wc -c <'ColormapP.h'`; then
    echo shar: \"'ColormapP.h'\" unpacked with wrong size!
fi
# end of 'ColormapP.h'
fi
if test -f 'EraseOp.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'EraseOp.c'\"
else
echo shar: Extracting \"'EraseOp.c'\" \(2174 characters\)
sed "s/^X//" >'EraseOp.c' <<'END_OF_FILE'
X/* +-------------------------------------------------------------------+ */
X/* | Copyright 1992, David Koblas.                                     | */
X/* |   Permission to use, copy, modify, and distribute this software   | */
X/* |   and its documentation for any purpose and without fee is hereby | */
X/* |   granted, provided that the above copyright notice appear in all | */
X/* |   copies and that both that copyright notice and this permission  | */
X/* |   notice appear in supporting documentation.  This software is    | */
X/* |   provided "as is" without express or implied warranty.           | */
X/* +-------------------------------------------------------------------+ */
X
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include "xpaint.h"
X
X#define WIDTH	15
X#define HEIGHT	10
X
Xstatic void	press(Widget w, void *junk, XButtonEvent *event, OpInfo *info) 
X{
X	XRectangle	undo;
X
X	if (info->surface == opWindow && info->isFat)
X		return;
X
X	UndoStart(w, info);
X
X	XFillRectangle(XtDisplay(w), info->drawable, info->base_gc, 
X			event->x, event->y, WIDTH, HEIGHT);
X
X	if (info->surface == opPixmap) {
X		XYtoRECT(event->x, event->y, event->x + WIDTH, event->y + HEIGHT, &undo);
X		UndoSetRectangle(w, &undo);
X		PwUpdate(w, &undo, False);
X	}
X}
X
Xstatic void	motion(Widget w, void *junk, XMotionEvent *event, OpInfo *info) 
X{
X	XRectangle	undo;
X
X	if (info->surface == opWindow && info->isFat)
X		return;
X
X	XFillRectangle(XtDisplay(w), info->drawable, info->base_gc, 
X			event->x, event->y, WIDTH, HEIGHT);
X
X	if (info->surface == opPixmap) {
X		XYtoRECT(event->x, event->y, event->x + WIDTH, event->y + HEIGHT, &undo);
X		UndoGrow(w, event->x, event->y);
X		UndoGrow(w, event->x + WIDTH, event->y + HEIGHT);
X		PwUpdate(w, &undo, False);
X	}
X}
X
X/*
X**  Those public functions
X*/
Xvoid *EraseAdd(Widget w)
X{
X	OpAddEventHandler(w, opWindow|opPixmap, ButtonPressMask, FALSE, press, NULL);
X	OpAddEventHandler(w, opWindow|opPixmap, ButtonMotionMask, FALSE, motion, NULL);
X	return NULL;
X}
Xvoid EraseRemove(Widget w)
X{
X	OpRemoveEventHandler(w, opWindow|opPixmap, ButtonPressMask, FALSE, press, NULL);
X	OpRemoveEventHandler(w, opWindow|opPixmap, ButtonMotionMask, FALSE, motion, NULL);
X}

END_OF_FILE
echo shar: NEWLINE appended to \"'EraseOp.c'\"
if test 2175 -ne `wc -c <'EraseOp.c'`; then
    echo shar: \"'EraseOp.c'\" unpacked with wrong size!
fi
# end of 'EraseOp.c'
fi
if test -f 'FatbitsEdit.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'FatbitsEdit.c'\"
else
echo shar: Extracting \"'FatbitsEdit.c'\" \(2247 characters\)
sed "s/^X//" >'FatbitsEdit.c' <<'END_OF_FILE'
X/* +-------------------------------------------------------------------+ */
X/* | Copyright 1992, David Koblas.                                     | */
X/* |   Permission to use, copy, modify, and distribute this software   | */
X/* |   and its documentation for any purpose and without fee is hereby | */
X/* |   granted, provided that the above copyright notice appear in all | */
X/* |   copies and that both that copyright notice and this permission  | */
X/* |   notice appear in supporting documentation.  This software is    | */
X/* |   provided "as is" without express or implied warranty.           | */
X/* +-------------------------------------------------------------------+ */
X
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include <X11/Xaw/Command.h>
X#include <X11/Xaw/Viewport.h>
X#include <X11/Xaw/Form.h>
X#include <X11/Shell.h>
X#include "Paint.h"
X#include "xpaint.h"
X
Xstatic void updateCallback(Widget w, Widget fat, XRectangle *rect)
X{
X	PwUpdate(fat, rect);
X}
Xstatic void doneCallback(Widget w, Widget fat, void *junk2)
X{
X	Widget	paint;
X
X	XtVaGetValues(fat, XtNpaint, &paint, NULL);
X
X        XtDestroyWidget(GetShell(w));
X}
X
Xvoid FatbitsEdit(Widget paint, XRectangle *rect)
X{
X	Widget		shell, form, fat, viewport;
X	Widget		doneButton;
X	Colormap	cmap;
X
X        XtVaGetValues(paint, XtNcolormap, &cmap, NULL);
X
X        shell = XtVaCreatePopupShell("fatbits", transientShellWidgetClass, 
X				GetShell(paint), XtNcolormap, cmap,
X                                NULL);
X
X	form  = XtVaCreateManagedWidget("form", formWidgetClass, shell, NULL);
X	
X	viewport = XtVaCreateManagedWidget("viewport",
X				viewportWidgetClass, form,
X				XtNallowVert, TRUE,
X				XtNallowHoriz, TRUE,
X				XtNuseBottom, TRUE,
X				XtNuseRight, TRUE,
X				NULL);
X
X	fat = XtVaCreateManagedWidget("bits", paintWidgetClass, viewport,
X				XtNpaint, paint,
X				XtNzoomX, rect->x,
X				XtNzoomY, rect->y,
X				XtNzoom, 8,
X				XtNdrawWidth, rect->width * 8,
X				XtNdrawHeight, rect->height * 8,
X				NULL);
X
X	doneButton = XtVaCreateManagedWidget("done", commandWidgetClass, form,
X				XtNfromVert, viewport,
X				NULL);
X
X	XtAddCallback(doneButton, XtNcallback, doneCallback, fat);
X
X        XtPopup(shell, XtGrabNone);
X
X	/*
X	**  Set the current operator
X	*/
X	GraphicAdd(fat);
X}

END_OF_FILE
echo shar: NEWLINE appended to \"'FatbitsEdit.c'\"
if test 2248 -ne `wc -c <'FatbitsEdit.c'`; then
    echo shar: \"'FatbitsEdit.c'\" unpacked with wrong size!
fi
# end of 'FatbitsEdit.c'
fi
if test -f 'FontOp.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'FontOp.c'\"
else
echo shar: Extracting \"'FontOp.c'\" \(3247 characters\)
sed "s/^X//" >'FontOp.c' <<'END_OF_FILE'
X/* +-------------------------------------------------------------------+ */
X/* | Copyright 1992, David Koblas.                                     | */
X/* |   Permission to use, copy, modify, and distribute this software   | */
X/* |   and its documentation for any purpose and without fee is hereby | */
X/* |   granted, provided that the above copyright notice appear in all | */
X/* |   copies and that both that copyright notice and this permission  | */
X/* |   notice appear in supporting documentation.  This software is    | */
X/* |   provided "as is" without express or implied warranty.           | */
X/* +-------------------------------------------------------------------+ */
X
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include <X11/cursorfont.h>
X#include "xpaint.h"
X#include "Paint.h"
X
X#define	DELAY	500
X
Xstatic int		startX, startY, curX, curY, height;
Xstatic XtIntervalId	id = NULL;
Xstatic int		state = False;
Xstatic int		slen = 0;
X
X#if 0
X
Xstatic void	cursor(PaintWidget w, Boolean flag)
X{
X	if (flag) {
X		XDrawLine(XtDisplay(w), XtWindow(w), w->paint.gcx,
X				curX, curY, curX, curY + height);
X		state = !state;
X	} else if (state) {
X		XDrawLine(XtDisplay(w), XtWindow(w), w->paint.gcx,
X				curX, curY, curX, curY + height);
X		state = False;
X	}
X}
X
Xstatic void	flash(PaintWidget w)
X{
X	cursor(w, True);
X	id = XtAddTimeOut(DELAY, flash, w);
X}
X
Xstatic void	press(PaintWidget w, void *junk, XButtonEvent *event) 
X{
X	cursor(w, False);
X
X	curX = startX = event->x;
X	curY = startY = event->y;
X
X	height = w->paint.fontInfo->ascent + w->paint.fontInfo->descent;
X
X	curY = curY - height / 2;
X
X	if (id == NULL)
X		flash(w);
X
X	slen = 0;
X
X	UndoStart(w, event->x, event->y, 0, 0);
X}
X
Xstatic void	key(PaintWidget w, void *junk, XKeyEvent *event) 
X{
X	char	buf[21];
X	KeySym	keysym;
X	int	len, i, width;
X
X	len = XLookupString(event, buf, sizeof(buf) - 1, &keysym, NULL);
X
X	if (len != 0)
X		cursor(w, False);
X	for (i = 0; i < len; i++) {
X		if (buf[i] == '\n' || buf[i] == '\r') {
X			curX = startX;
X			curY += w->paint.fontInfo->ascent + 
X			        w->paint.fontInfo->descent + 2;
X#if 0
X		} else if (buf[i] == 0x08 || buf[i] == 0x7f) {
X			/*
X			** Not yet
X			*/
X			slen--;
X			curX -= XTextWidth(w->paint.fontInfo, 
X						&string[--slen], 1);
X#endif
X		} else {
X			XDrawString(XtDisplay(w), XtWindow(w), w->paint.fgc, 
X					curX, curY + w->paint.fontInfo->ascent,
X					&buf[i], 1);
X			XDrawString(XtDisplay(w), PwPixmap(w), w->paint.fgc, 
X					curX, curY + w->paint.fontInfo->ascent,
X					&buf[i], 1);
X			width = XTextWidth(w->paint.fontInfo, &buf[i], 1);
X			curX += width;
X
X			UndoGrow(w, event->x, event->y, width,
X					w->paint.fontInfo->ascent + 
X					w->paint.fontInfo->descent);
X		}
X				
X	}
X}
X#endif
X
X/*
X**  Those public functions
X*/
Xvoid FontAdd(Widget w)
X{
X#if 0
X	Cursor	c;
X
X	OpAddEventHandler(w, ButtonPressMask, FALSE, press, NULL);
X	OpAddEventHandler(w, KeyPressMask, FALSE, key, NULL);
X
X	c = XCreateFontCursor(XtDisplay(w), XC_xterm);
X	XDefineCursor(XtDisplay(w), XtWindow(w), c);
X#endif
X}
Xvoid FontRemove(Widget w)
X{
X#if 0
X	OpRemoveEventHandler(w, ButtonPressMask, FALSE, press, NULL);
X	OpRemoveEventHandler(w, KeyPressMask, FALSE, key, NULL);
X
X	if (id != NULL)
X		XtRemoveTimeOut(id);
X
X	id = NULL;
X	cursor((PaintWidget)w, False);
X#endif
X}

END_OF_FILE
echo shar: NEWLINE appended to \"'FontOp.c'\"
if test 3248 -ne `wc -c <'FontOp.c'`; then
    echo shar: \"'FontOp.c'\" unpacked with wrong size!
fi
# end of 'FontOp.c'
fi
if test -f 'FontSelect.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'FontSelect.c'\"
else
echo shar: Extracting \"'FontSelect.c'\" \(3087 characters\)
sed "s/^X//" >'FontSelect.c' <<'END_OF_FILE'
X/* +-------------------------------------------------------------------+ */
X/* | Copyright 1992, David Koblas.                                     | */
X/* |   Permission to use, copy, modify, and distribute this software   | */
X/* |   and its documentation for any purpose and without fee is hereby | */
X/* |   granted, provided that the above copyright notice appear in all | */
X/* |   copies and that both that copyright notice and this permission  | */
X/* |   notice appear in supporting documentation.  This software is    | */
X/* |   provided "as is" without express or implied warranty.           | */
X/* +-------------------------------------------------------------------+ */
X
X#include <X11/StringDefs.h>
X#include <X11/Intrinsic.h>
X#include <X11/Shell.h>
X#include <X11/Xaw/Form.h>
X#include <X11/Xaw/List.h>
X#include <X11/Xaw/AsciiText.h>
X#include <X11/Xaw/Command.h>
X#include <X11/Xaw/Viewport.h>
X
X#include "xpaint.h"
X
Xstatic void okCallback(Widget w, Widget font)
X{
X	/*
X	**  Set It
X	*/
X}
X
Xstatic void closeCallback(Widget w, Widget shell)
X{
X	XtPopdown(shell);
X}
X
Xstatic void fontCallback(Widget w, Widget text, XawListReturnStruct *item)
X{
X	static Font	fid = 0;
X
X#if 0
X	if (fid != 0) 
X		XFreeFont(XtDisplay(w), fid);
X#endif
X
X	fid = XLoadFont(XtDisplay(w), item->string);
X
X	XtVaSetValues(text, XtNfont, fid, NULL);
X}
X
X
Xvoid FontSelect(Widget w)
X{
X	Widget	shell, form, font, style, size, text, form2;
X	Widget	okButton, doneButton, vport;
X	char	**names;
X	int	num;
X
X	shell = XtVaCreatePopupShell("fontSelect",
X			topLevelShellWidgetClass, GetToplevel(w),
X			NULL);
X
X	form = XtVaCreateManagedWidget("form",
X			formWidgetClass, shell,
X			XtNborderWidth, 0,
X			NULL);
X	
X#if 0
X	font = XtVaCreateManagedWidget("family",
X			listWidgetClass, form,
X			XtNheight, 100,
X			NULL);
X
X	style = XtVaCreateManagedWidget("style",
X			listWidgetClass, form,
X			XtNfromHoriz, font,
X			XtNheight, 100,
X			NULL);
X
X	size = XtVaCreateManagedWidget("size",
X			listWidgetClass, form,
X			XtNfromHoriz, style,
X			XtNheight, 100,
X			NULL);
X#else
X	names = XListFonts(XtDisplay(shell), "*", 32767, &num),
X
X	vport = XtVaCreateManagedWidget("vport",
X			viewportWidgetClass, form,
X			XtNuseBottom, True,
X			XtNuseRight, True,
X			XtNallowHoriz, True,
X			XtNallowVert, True,
X			NULL);
X	font = XtVaCreateManagedWidget("font",
X			listWidgetClass, vport,
X			XtNverticalList, True,
X			XtNlist, names,
X			XtNforceColumns, True,
X			XtNdefaultColumns, 1,
X			XtNnumberStrings, num,
X			NULL);
X#endif
X	
X	text = XtVaCreateManagedWidget("text",
X			asciiTextWidgetClass, form,
X			XtNfromVert, vport,
X			XtNstring, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
X			NULL);
X
X	okButton = XtVaCreateManagedWidget("apply",
X			commandWidgetClass, form,
X			XtNfromVert, text,
X			NULL);
X
X	doneButton = XtVaCreateManagedWidget("done",
X			commandWidgetClass, form,
X			XtNfromVert, text,
X			XtNfromHoriz, okButton,
X			NULL);
X
X	XtAddCallback(okButton, XtNcallback, okCallback, font);
X	XtAddCallback(doneButton, XtNcallback, closeCallback, shell);
X	XtAddCallback(font, XtNcallback, fontCallback, text);
X	
X	XtPopup(shell, XtGrabNone);
X}

END_OF_FILE
echo shar: NEWLINE appended to \"'FontSelect.c'\"
if test 3088 -ne `wc -c <'FontSelect.c'`; then
    echo shar: \"'FontSelect.c'\" unpacked with wrong size!
fi
# end of 'FontSelect.c'
fi
if test -f 'Hash.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Hash.h'\"
else
echo shar: Extracting \"'Hash.h'\" \(1114 characters\)
sed "s/^X//" >'Hash.h' <<'END_OF_FILE'
X/* +-------------------------------------------------------------------+ */
X/* | Copyright 1992, David Koblas.                                     | */
X/* |   Permission to use, copy, modify, and distribute this software   | */
X/* |   and its documentation for any purpose and without fee is hereby | */
X/* |   granted, provided that the above copyright notice appear in all | */
X/* |   copies and that both that copyright notice and this permission  | */
X/* |   notice appear in supporting documentation.  This software is    | */
X/* |   provided "as is" without express or implied warranty.           | */
X/* +-------------------------------------------------------------------+ */
X
X#ifdef __STDC__
Xvoid	*HashCreate(int (*cmp)(), void (*free)(), int nelem);
Xvoid	HashDestroy(void *tbl);
Xvoid	*HashFind(void *tbl, int value, void *val);
Xint	HashAdd(void *tbl, int value, void *val);
Xint     HashRemove(void *tbl, int value, void *elem);
Xint     HashAll(void *tbl, int (*func)(void *));
X#else
Xvoid	*HashCreate();
Xvoid	HashDestroy();
Xvoid	*HashFind();
Xint	HashAdd();
Xint     HashRemove();
Xint     HashAll();
X#endif

END_OF_FILE
echo shar: NEWLINE appended to \"'Hash.h'\"
if test 1115 -ne `wc -c <'Hash.h'`; then
    echo shar: \"'Hash.h'\" unpacked with wrong size!
fi
# end of 'Hash.h'
fi
if test -f 'LineOp.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'LineOp.c'\"
else
echo shar: Extracting \"'LineOp.c'\" \(2726 characters\)
sed "s/^X//" >'LineOp.c' <<'END_OF_FILE'
X/* +-------------------------------------------------------------------+ */
X/* | Copyright 1992, David Koblas.                                     | */
X/* |   Permission to use, copy, modify, and distribute this software   | */
X/* |   and its documentation for any purpose and without fee is hereby | */
X/* |   granted, provided that the above copyright notice appear in all | */
X/* |   copies and that both that copyright notice and this permission  | */
X/* |   notice appear in supporting documentation.  This software is    | */
X/* |   provided "as is" without express or implied warranty.           | */
X/* +-------------------------------------------------------------------+ */
X
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include "xpaint.h"
X
Xtypedef struct {
X	int	rx, ry;
X	int	startX, startY, endX, endY;
X	int	drawn;
X} LocalInfo;
X
Xstatic void	press(Widget w, LocalInfo *l, XButtonEvent *event, OpInfo *info) 
X{
X	l->rx     = info->x;
X	l->ry     = info->y;
X	l->startX = event->x;
X	l->startY = event->y;
X
X	l->drawn = False;
X}
X
Xstatic void	motion(Widget w, LocalInfo *l, XMotionEvent *event, OpInfo *info) 
X{
X	if (l->drawn) {
X		XDrawLine(XtDisplay(w), info->drawable, Global.gcx,
X				l->startX, l->startY, l->endX, l->endY);
X	}
X
X	l->endX = event->x;
X	l->endY = event->y;
X
X	/*
X	**  Really set this flag in the if statement
X	*/
X	if (l->drawn = (l->startX != l->endX && l->startY != l->endY)) {
X		XDrawLine(XtDisplay(w), info->drawable, Global.gcx,
X				l->startX, l->startY, l->endX, l->endY);
X	}
X}
X
Xstatic void	release(Widget w, LocalInfo *l, XButtonEvent *event, OpInfo *info) 
X{
X	XRectangle	undo;
X
X	if (l->drawn && info->surface == opWindow) 
X		XDrawLine(XtDisplay(w), info->drawable, Global.gcx,
X				l->startX, l->startY, l->endX, l->endY);
X
X	if (info->surface == opWindow && info->isFat)
X		return;
X
X	UndoStart(w, info);
X
X	XDrawLine(XtDisplay(w), info->drawable, info->filled_gc,
X			l->rx, l->ry, event->x, event->y);
X
X	if (info->surface == opPixmap) {
X		XYtoRECT(l->rx, l->ry, event->x, event->y, &undo);
X		UndoSetRectangle(w, &undo);
X		PwUpdate(w, &undo, False);
X	}
X}
X
X/*
X**  Those public functions
X*/
Xvoid *LineAdd(Widget w)
X{
X	LocalInfo	*l = (LocalInfo *)XtMalloc(sizeof(LocalInfo));
X	OpAddEventHandler(w, opWindow, ButtonPressMask, FALSE, press, l);
X	OpAddEventHandler(w, opWindow, ButtonMotionMask, FALSE, motion, l);
X	OpAddEventHandler(w, opWindow|opPixmap, ButtonReleaseMask, FALSE, release, l);
X	SetCrossHairCursor(w);
X	return l;
X}
Xvoid LineRemove(Widget w, LocalInfo *l)
X{
X	OpRemoveEventHandler(w, opWindow, ButtonPressMask, FALSE, press, l);
X	OpRemoveEventHandler(w, opWindow, ButtonMotionMask, FALSE, motion, l);
X	OpRemoveEventHandler(w, opWindow|opPixmap, ButtonReleaseMask, FALSE, release, l);
X}

END_OF_FILE
echo shar: NEWLINE appended to \"'LineOp.c'\"
if test 2727 -ne `wc -c <'LineOp.c'`; then
    echo shar: \"'LineOp.c'\" unpacked with wrong size!
fi
# end of 'LineOp.c'
fi
if test -f 'Misc.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Misc.c'\"
else
echo shar: Extracting \"'Misc.c'\" \(1632 characters\)
sed "s/^X//" >'Misc.c' <<'END_OF_FILE'
X/* +-------------------------------------------------------------------+ */
X/* | Copyright 1992, David Koblas.                                     | */
X/* |   Permission to use, copy, modify, and distribute this software   | */
X/* |   and its documentation for any purpose and without fee is hereby | */
X/* |   granted, provided that the above copyright notice appear in all | */
X/* |   copies and that both that copyright notice and this permission  | */
X/* |   notice appear in supporting documentation.  This software is    | */
X/* |   provided "as is" without express or implied warranty.           | */
X/* +-------------------------------------------------------------------+ */
X
X#include <X11/Intrinsic.h>
X#include <X11/cursorfont.h>
X#include "xpaint.h"
X
XWidget GetToplevel(Widget w)
X{
X        return XtIsTopLevelShell(w) ? w : GetToplevel(XtParent(w));
X}
X
XWidget GetShell(Widget w)
X{
X        return XtIsShell(w) ? w : GetShell(XtParent(w));
X}
X
Xvoid SetCrossHairCursor(Widget w)
X{
X	Cursor	c;
X
X        c = XCreateFontCursor(XtDisplay(w), XC_crosshair);
X	XDefineCursor(XtDisplay(w), XtWindow(w), c);
X}
X
Xvoid SetWatchCursor(Widget w)
X{
X	Cursor	c;
X
X        c = XCreateFontCursor(XtDisplay(w), XC_watch);
X	XDefineCursor(XtDisplay(w), XtWindow(w), c);
X	XFlush(XtDisplay(w));
X}
X
XXRectangle *RectOverlap(XRectangle *a, XRectangle *b)
X{
X	static XRectangle	out;
X	int			w, h;
X 
X	out.x = MAX(a->x, b->x);
X	out.y = MAX(a->y, b->y);
X	w     = MIN(a->x + a->width,  b->x + b->width)  - out.x;
X	h     = MIN(a->y + a->height, b->y + b->height) - out.y;
X
X	if (w <= 0 || h <= 0)
X		return NULL;
X
X	out.width  = w;
X	out.height = h;
X
X	return &out;
X}

END_OF_FILE
echo shar: NEWLINE appended to \"'Misc.c'\"
if test 1633 -ne `wc -c <'Misc.c'`; then
    echo shar: \"'Misc.c'\" unpacked with wrong size!
fi
# end of 'Misc.c'
fi
if test -f 'Paint.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Paint.h'\"
else
echo shar: Extracting \"'Paint.h'\" \(2853 characters\)
sed "s/^X//" >'Paint.h' <<'END_OF_FILE'
X#ifndef _Paint_h
X#define _Paint_h
X
X/* +-------------------------------------------------------------------+ */
X/* | Copyright 1992, David Koblas.                                     | */
X/* |   Permission to use, copy, modify, and distribute this software   | */
X/* |   and its documentation for any purpose and without fee is hereby | */
X/* |   granted, provided that the above copyright notice appear in all | */
X/* |   copies and that both that copyright notice and this permission  | */
X/* |   notice appear in supporting documentation.  This software is    | */
X/* |   provided "as is" without express or implied warranty.           | */
X/* +-------------------------------------------------------------------+ */
X
X/****************************************************************
X *
X * Paint widget
X *
X ****************************************************************/
X
X/* Resources:
X
X Name		     Class		RepType		Default Value
X ----		     -----		-------		-------------
X background	     Background		Pixel		XtDefaultBackground
X border		     BorderColor	Pixel		XtDefaultForeground
X borderWidth	     BorderWidth	Dimension	1
X destroyCallback     Callback		Pointer		NULL
X height		     Height		Dimension	0
X mappedWhenManaged   MappedWhenManaged	Boolean		True
X sensitive	     Sensitive		Boolean		True
X width		     Width		Dimension	0
X x		     Position		Position	0
X y		     Position		Position	0
X
X*/
X
X/* define any special resource names here that are not in <X11/StringDefs.h> */
X
X#define XtNpaintResource "paintResource"
X#define XtNpattern	 "pattern"
X#define XtNgrid	 	 "grid"
X#define XtNgridOn 	 "gridOn"
X#define XtNlineWidth	 "lineWidth"
X#define XtNfatBack	 "fatBack"
X#define XtNundoSize	 "undoSize"
X#define XtNzoom	 	 "zoom"
X#define XtNpaint	 "paint"
X#define XtNzoomX	 "zoomX"
X#define XtNzoomY	 "zoomY"
X#define XtNdrawWidth	 "drawWidth"
X#define XtNdrawHeight	 "drawHeight"
X
X#define XtCPaintResource "PaintResource"
X#define XtCPattern	 "Pattern"
X#define XtCGrid		 "Grid"
X#define XtCGridOn	 "GridOn"
X#define XtCLineWidth	 "LineWidth"
X#define XtCFatBack	 "FatBack"
X#define XtCUndoSize	 "UndoSize"
X#define XtCZoom	  	 "Zoom"
X#define XtCPaint	 "Paint"
X#define XtCZoomX	 "ZoomX"
X#define XtCZoomY	 "ZoomY"
X#define XtCDrawWidth	 "DrawWidth"
X#define XtCDrawHeight	 "DrawHeight"
X
X/* declare specific PaintWidget class and instance datatypes */
X
Xtypedef struct _PaintClassRec*		PaintClass;
Xtypedef struct _PaintRec*		PaintWidget;
X
X/* declare the class constant */
X
Xextern WidgetClass paintWidgetClass;
X
X/*
X**  Public functions
X*/
X#ifndef _PaintP_h
X
X#include "region.h"
X
XBoolean PwCopyRegion(Widget w, Pixmap *data, Pixmap *mask);
XBoolean PwClearRegion(Widget w);
XBoolean PwCutRegion(Widget w);
Xvoid PwGetPixmap(Widget w, Pixmap *pix, int *width, int *height);
Xvoid PwSetPixmap(Widget w, Pixmap pix);
XRegion_t *PwGetRegion(Widget w);
X
X#endif
X
X#endif /* _Paint_h */

END_OF_FILE
echo shar: NEWLINE appended to \"'Paint.h'\"
if test 2854 -ne `wc -c <'Paint.h'`; then
    echo shar: \"'Paint.h'\" unpacked with wrong size!
fi
# end of 'Paint.h'
fi
if test -f 'PaintP.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'PaintP.h'\"
else
echo shar: Extracting \"'PaintP.h'\" \(1877 characters\)
sed "s/^X//" >'PaintP.h' <<'END_OF_FILE'
X#ifndef _PaintP_h
X#define _PaintP_h
X
X/* +-------------------------------------------------------------------+ */
X/* | Copyright 1992, David Koblas.                                     | */
X/* |   Permission to use, copy, modify, and distribute this software   | */
X/* |   and its documentation for any purpose and without fee is hereby | */
X/* |   granted, provided that the above copyright notice appear in all | */
X/* |   copies and that both that copyright notice and this permission  | */
X/* |   notice appear in supporting documentation.  This software is    | */
X/* |   provided "as is" without express or implied warranty.           | */
X/* +-------------------------------------------------------------------+ */
X
X
X#include "Paint.h"
X/* include superclass private header file */
X#include <X11/CoreP.h>
X
X/* define unique representation types not found in <X11/StringDefs.h> */
X
X#define XtRPaintResource "PaintResource"
X
Xtypedef struct {
X    int		empty;
X} PaintClassPart;
X
Xtypedef struct _PaintClassRec {
X    CoreClassPart	core_class;
X    PaintClassPart	paint_class;
X} PaintClassRec;
X
Xextern PaintClassRec paintClassRec;
X
X#include "region.h"
X
Xtypedef struct s_undoStack {
X	XRectangle		box;
X	Pixmap			pixmap;
X	struct s_undoStack	*next, *prev;
X} UndoStack;
X
Xtypedef struct {
X	int		drawWidth, drawHeight;
X	GC		gc, igc;
X	GC		fgc, sgc;
X	Pixmap		sourcePixmap;
X	Pixmap		pattern;
X	int		lineWidth;
X	XFontStruct	*fontInfo;
X	Pixel		foreground, background;
X	int		undoSize;
X
X	/*
X	**  The undo system
X	*/
X	Pixmap		base;
X	UndoStack	*undo, *top;
X
X	Region_t	*region;
X	Boolean		gridOn;
X	int		grid;
X	void		*eventList;
X	XtCallbackList	*fatcalls;
X	int		zoomX, zoomY;
X	int		zoom;
X	GC		tgc;
X	Widget		paint;
X	Pixel		linePixel;
X} PaintPart;
X
X#define PwPixmap(w)	((w)->paint.active->pixmap)
X
Xtypedef struct _PaintRec {
X    CorePart		core;
X    PaintPart		paint;
X} PaintRec;
X
X#endif /* _PaintP_h */

END_OF_FILE
echo shar: NEWLINE appended to \"'PaintP.h'\"
if test 1878 -ne `wc -c <'PaintP.h'`; then
    echo shar: \"'PaintP.h'\" unpacked with wrong size!
fi
# end of 'PaintP.h'
fi
if test -f 'PencilOp.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'PencilOp.c'\"
else
echo shar: Extracting \"'PencilOp.c'\" \(2620 characters\)
sed "s/^X//" >'PencilOp.c' <<'END_OF_FILE'
X/* +-------------------------------------------------------------------+ */
X/* | Copyright 1992, David Koblas.                                     | */
X/* |   Permission to use, copy, modify, and distribute this software   | */
X/* |   and its documentation for any purpose and without fee is hereby | */
X/* |   granted, provided that the above copyright notice appear in all | */
X/* |   copies and that both that copyright notice and this permission  | */
X/* |   notice appear in supporting documentation.  This software is    | */
X/* |   provided "as is" without express or implied warranty.           | */
X/* +-------------------------------------------------------------------+ */
X
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include <X11/cursorfont.h>
X#include "xpaint.h"
X
Xtypedef struct {
X	int	startX, startY;
X} LocalInfo;
X
Xstatic void	press(Widget w, LocalInfo *l, XButtonEvent *event, OpInfo *info) 
X{
X	XRectangle	undo;
X
X	if (info->surface == opWindow)
X		return;
X
X	l->startX = event->x;
X	l->startY = event->y;
X
X	undo.x      = event->x;
X	undo.y      = event->y;
X	undo.width  = 1;
X	undo.height = 1;
X
X	UndoStartPoint(w, info, event->x, event->y);
X
X	XDrawPoint(XtDisplay(w), info->drawable, info->solid_gc, event->x, event->y);
X	if (!info->isFat)
X		XDrawPoint(XtDisplay(w), XtWindow(w), info->solid_gc, event->x, event->y);
X
X	PwUpdate(w, &undo, False);
X}
X
Xstatic void	motion(Widget w, LocalInfo *l, XMotionEvent *event, OpInfo *info) 
X{
X	XRectangle	undo;
X
X	if (info->surface == opWindow)
X		return;
X
X	XDrawLine(XtDisplay(w), info->drawable, info->solid_gc,
X			 l->startX, l->startY, event->x, event->y);
X	if (!info->isFat)
X		XDrawLine(XtDisplay(w), XtWindow(w), info->solid_gc,
X			 l->startX, l->startY, event->x, event->y);
X
X	UndoGrow(w, event->x, event->y);
X
X	undo.x      = MIN(l->startX, event->x);
X	undo.y      = MIN(l->startY, event->y);
X	undo.width  = MAX(l->startX, event->x) - undo.x + 1;
X	undo.height = MAX(l->startY, event->y) - undo.y + 1;
X
X	l->startX = event->x;
X	l->startY = event->y;
X
X	PwUpdate(w, &undo, False);
X}
X
X/*
X**  Those public functions
X*/
Xvoid *PencilAdd(Widget w)
X{
X	LocalInfo	*l = (LocalInfo*)XtMalloc(sizeof(LocalInfo));
X	Cursor	c;
X
X	OpAddEventHandler(w, opPixmap, ButtonPressMask, FALSE, press, l);
X	OpAddEventHandler(w, opPixmap, ButtonMotionMask, FALSE, motion, l);
X
X	c = XCreateFontCursor(XtDisplay(w), XC_pencil);
X	XDefineCursor(XtDisplay(w), XtWindow(w), c);
X
X	return l;
X}
Xvoid PencilRemove(Widget w, LocalInfo *l)
X{
X	OpRemoveEventHandler(w, opPixmap, ButtonPressMask, FALSE, press, l);
X	OpRemoveEventHandler(w, opPixmap, ButtonMotionMask, FALSE, motion, l);
X	XtFree(l);
X}

END_OF_FILE
echo shar: NEWLINE appended to \"'PencilOp.c'\"
if test 2621 -ne `wc -c <'PencilOp.c'`; then
    echo shar: \"'PencilOp.c'\" unpacked with wrong size!
fi
# end of 'PencilOp.c'
fi
if test -f 'Undo.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Undo.c'\"
else
echo shar: Extracting \"'Undo.c'\" \(4204 characters\)
sed "s/^X//" >'Undo.c' <<'END_OF_FILE'
X/* +-------------------------------------------------------------------+ */
X/* | Copyright 1992, David Koblas.                                     | */
X/* |   Permission to use, copy, modify, and distribute this software   | */
X/* |   and its documentation for any purpose and without fee is hereby | */
X/* |   granted, provided that the above copyright notice appear in all | */
X/* |   copies and that both that copyright notice and this permission  | */
X/* |   notice appear in supporting documentation.  This software is    | */
X/* |   provided "as is" without express or implied warranty.           | */
X/* +-------------------------------------------------------------------+ */
X
X#include <X11/IntrinsicP.h>
X#include "xpaint.h"
X#include "PaintP.h"
X
Xvoid UndoSwap(PaintWidget w)
X{
X	XRectangle	*rect;
X
X	if (w->paint.undo == NULL)
X		w->paint.undo = w->paint.top;
X	else
X		w->paint.undo = w->paint.undo->next;
X
X	PwUpdate(w, NULL, True);
X}
X
Xvoid UndoStart(PaintWidget pw, OpInfo *info)
X{
X	int			act, non;
X	UndoStack		*cur;
X	PaintWidget		orig = pw;
X
X	if (info->surface != opPixmap)
X		return;
X	
X	/*
X	**  If we are a view of another widget, get the parent
X	*/
X	if (pw->paint.paint != None)
X		pw = (PaintWidget)(pw->paint.paint);
X
X	if (pw->paint.top == NULL) {
X		/*
X		**  No undo store, use the base pixmap
X		*/
X		info->drawable = pw->paint.base;
X		return;
X	}
X
X	if (pw->paint.undo != pw->paint.top) {
X		/*
X		**  In the middle of the undo list, get either the
X		**   previous buffer or the last buffer.
X		*/
X		if (pw->paint.undo != NULL) {
X			cur = pw->paint.undo->prev;
X		} else {
X			cur = pw->paint.top;
X			while (cur->next != NULL)
X				cur = cur->next;
X		}
X	} else {
X		/*
X		**  At the top, update the base, with
X		**  the undo buffer above it.
X		**  the make that buffer current,
X		**  and move it to the top
X		*/
X		cur = pw->paint.undo;
X		while (cur != NULL && cur->next != NULL)
X			cur = cur->next;
X
X		if (cur->box.width != 0 && cur->box.height != 0)
X			XCopyArea(XtDisplay(pw), cur->pixmap, pw->paint.base,
X					pw->paint.gc,
X					cur->box.x, cur->box.y,
X					cur->box.width, cur->box.height,
X					cur->box.x, cur->box.y);
X
X		if (cur->prev != NULL)
X			cur->prev->next = NULL;
X		if (pw->paint.undo == cur)
X			pw->paint.undo = NULL;
X		cur->prev = NULL;
X
X		if (pw->paint.top != cur) {
X			cur->next     = pw->paint.top;
X			pw->paint.top = cur;
X			if (cur->next != NULL)
X				cur->next->prev = cur;
X		}
X	}
X
X	PwUpdateDrawable(pw, cur->pixmap, NULL);
X
X	cur->box.x      = 0;
X	cur->box.y      = 0;
X	cur->box.width  = 0;
X	cur->box.height = 0;
X
X	pw->paint.undo = cur;
X
X	info->drawable = cur->pixmap;
X
X	if (orig != pw)
X		orig->paint.undo = pw->paint.undo;
X}
X
Xvoid	UndoStartPoint(PaintWidget pw, OpInfo *info, int x, int y)
X{
X	if (XtClass(pw) != paintWidgetClass || info->surface != opPixmap)
X		return;
X
X	UndoStart(pw, info);
X
X	pw->paint.undo->box.x      = x;
X	pw->paint.undo->box.y      = y;
X	pw->paint.undo->box.width  = 1;
X	pw->paint.undo->box.height = 1;
X}
X
Xvoid	UndoStartRectangle(PaintWidget pw, OpInfo *info, XRectangle *rect)
X{
X	if (XtClass(pw) != paintWidgetClass || info->surface != opPixmap)
X		return;
X
X	UndoStart(pw, info);
X
X	pw->paint.undo->box = *rect;
X	pw->paint.undo->box.width++;
X	pw->paint.undo->box.height++;
X}
X
Xvoid UndoGrow(PaintWidget pw, int x, int y)
X{
X	XRectangle		*rect;
X	int			w, h;
X
X	if (XtClass(pw) != paintWidgetClass)
X		return;
X
X	rect = &pw->paint.undo->box;
X
X	w = x - rect->x;
X	h = y - rect->y;
X
X	if (w > 0) {
X		rect->width = MAX(rect->width, w) + 1;
X	} else {
X		rect->width = (int)rect->width - w + 1;
X		rect->x     = x;
X	}
X
X	if (h > 0) {
X		rect->height = MAX(rect->height, h) + 1;
X	} else {
X		rect->height = (int)rect->height - h + 1;
X		rect->y      = y;
X	}
X}
X
Xvoid UndoSetBounds(PaintWidget pw, int x, int y, int width, int height)
X{
X	XRectangle	*rect;
X
X	if (XtClass(pw) != paintWidgetClass || pw->paint.undo == NULL)
X		return;
X
X	rect = &pw->paint.undo->box;
X
X	rect->x      = x;
X	rect->y      = y;
X	rect->width  = width+1;
X	rect->height = height+1;
X}
Xvoid UndoSetRectangle(PaintWidget pw, XRectangle *rect)
X{
X	if (XtClass(pw) != paintWidgetClass || pw->paint.undo == NULL)
X		return;
X
X	pw->paint.undo->box = *rect;
X	pw->paint.undo->box.width += 2;
X	pw->paint.undo->box.height += 2;
X}

END_OF_FILE
echo shar: NEWLINE appended to \"'Undo.c'\"
if test 4205 -ne `wc -c <'Undo.c'`; then
    echo shar: \"'Undo.c'\" unpacked with wrong size!
fi
# end of 'Undo.c'
fi
if test -f 'bitmaps/pattern2.xbm' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'bitmaps/pattern2.xbm'\"
else
echo shar: Extracting \"'bitmaps/pattern2.xbm'\" \(887 characters\)
sed "s/^X//" >'bitmaps/pattern2.xbm' <<'END_OF_FILE'
X#define pattern2_width 32
X#define pattern2_height 32
Xstatic char pattern2_bits[] = {
X   0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa,
X   0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55,
X   0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa,
X   0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55,
X   0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa,
X   0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55,
X   0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa,
X   0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55,
X   0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa,
X   0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55,
X   0xaa, 0xaa, 0xaa, 0xaa, 0x55, 0x55, 0x55, 0x55};

END_OF_FILE
echo shar: NEWLINE appended to \"'bitmaps/pattern2.xbm'\"
if test 888 -ne `wc -c <'bitmaps/pattern2.xbm'`; then
    echo shar: \"'bitmaps/pattern2.xbm'\" unpacked with wrong size!
fi
# end of 'bitmaps/pattern2.xbm'
fi
if test -f 'bitmaps/pattern4.xbm' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'bitmaps/pattern4.xbm'\"
else
echo shar: Extracting \"'bitmaps/pattern4.xbm'\" \(887 characters\)
sed "s/^X//" >'bitmaps/pattern4.xbm' <<'END_OF_FILE'
X#define pattern4_width 32
X#define pattern4_height 32
Xstatic char pattern4_bits[] = {
X   0x88, 0x88, 0x88, 0x88, 0x11, 0x11, 0x11, 0x11, 0x22, 0x22, 0x22, 0x22,
X   0x44, 0x44, 0x44, 0x44, 0x88, 0x88, 0x88, 0x88, 0x11, 0x11, 0x11, 0x11,
X   0x22, 0x22, 0x22, 0x22, 0x44, 0x44, 0x44, 0x44, 0x88, 0x88, 0x88, 0x88,
X   0x11, 0x11, 0x11, 0x11, 0x22, 0x22, 0x22, 0x22, 0x44, 0x44, 0x44, 0x44,
X   0x88, 0x88, 0x88, 0x88, 0x11, 0x11, 0x11, 0x11, 0x22, 0x22, 0x22, 0x22,
X   0x44, 0x44, 0x44, 0x44, 0x88, 0x88, 0x88, 0x88, 0x11, 0x11, 0x11, 0x11,
X   0x22, 0x22, 0x22, 0x22, 0x44, 0x44, 0x44, 0x44, 0x88, 0x88, 0x88, 0x88,
X   0x11, 0x11, 0x11, 0x11, 0x22, 0x22, 0x22, 0x22, 0x44, 0x44, 0x44, 0x44,
X   0x88, 0x88, 0x88, 0x88, 0x11, 0x11, 0x11, 0x11, 0x22, 0x22, 0x22, 0x22,
X   0x44, 0x44, 0x44, 0x44, 0x88, 0x88, 0x88, 0x88, 0x11, 0x11, 0x11, 0x11,
X   0x22, 0x22, 0x22, 0x22, 0x44, 0x44, 0x44, 0x44};

END_OF_FILE
echo shar: NEWLINE appended to \"'bitmaps/pattern4.xbm'\"
if test 888 -ne `wc -c <'bitmaps/pattern4.xbm'`; then
    echo shar: \"'bitmaps/pattern4.xbm'\" unpacked with wrong size!
fi
# end of 'bitmaps/pattern4.xbm'
fi
if test -f 'bitmaps/pattern5.xbm' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'bitmaps/pattern5.xbm'\"
else
echo shar: Extracting \"'bitmaps/pattern5.xbm'\" \(887 characters\)
sed "s/^X//" >'bitmaps/pattern5.xbm' <<'END_OF_FILE'
X#define pattern5_width 32
X#define pattern5_height 32
Xstatic char pattern5_bits[] = {
X   0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
X   0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa, 0xaa, 0xaa,
X   0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
X   0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa, 0xaa, 0xaa,
X   0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
X   0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa, 0xaa, 0xaa,
X   0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
X   0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa, 0xaa, 0xaa,
X   0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00,
X   0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa, 0xaa, 0xaa,
X   0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa, 0xaa, 0xaa};

END_OF_FILE
echo shar: NEWLINE appended to \"'bitmaps/pattern5.xbm'\"
if test 888 -ne `wc -c <'bitmaps/pattern5.xbm'`; then
    echo shar: \"'bitmaps/pattern5.xbm'\" unpacked with wrong size!
fi
# end of 'bitmaps/pattern5.xbm'
fi
if test -f 'bitmaps/pattern6.xbm' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'bitmaps/pattern6.xbm'\"
else
echo shar: Extracting \"'bitmaps/pattern6.xbm'\" \(887 characters\)
sed "s/^X//" >'bitmaps/pattern6.xbm' <<'END_OF_FILE'
X#define pattern6_width 32
X#define pattern6_height 32
Xstatic char pattern6_bits[] = {
X   0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

END_OF_FILE
echo shar: NEWLINE appended to \"'bitmaps/pattern6.xbm'\"
if test 888 -ne `wc -c <'bitmaps/pattern6.xbm'`; then
    echo shar: \"'bitmaps/pattern6.xbm'\" unpacked with wrong size!
fi
# end of 'bitmaps/pattern6.xbm'
fi
if test -f 'bitmaps/pencilOp.xbm' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'bitmaps/pencilOp.xbm'\"
else
echo shar: Extracting \"'bitmaps/pencilOp.xbm'\" \(887 characters\)
sed "s/^X//" >'bitmaps/pencilOp.xbm' <<'END_OF_FILE'
X#define pencilOp_width 32
X#define pencilOp_height 32
Xstatic char pencilOp_bits[] = {
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x12, 0x00,
X   0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x80, 0x04, 0x00,
X   0x00, 0x80, 0x04, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
X   0x00, 0x20, 0x01, 0x00, 0x00, 0x20, 0x01, 0x00, 0x00, 0x90, 0x00, 0x00,
X   0x00, 0x90, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00,
X   0x00, 0x24, 0x00, 0x00, 0x00, 0x24, 0x00, 0x08, 0x00, 0x12, 0x00, 0x08,
X   0x00, 0x12, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x10, 0x00, 0x06, 0x00, 0x10,
X   0x00, 0x06, 0x00, 0x10, 0x00, 0x08, 0x0e, 0x10, 0x00, 0x10, 0x11, 0x08,
X   0x00, 0xe0, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

END_OF_FILE
echo shar: NEWLINE appended to \"'bitmaps/pencilOp.xbm'\"
if test 888 -ne `wc -c <'bitmaps/pencilOp.xbm'`; then
    echo shar: \"'bitmaps/pencilOp.xbm'\" unpacked with wrong size!
fi
# end of 'bitmaps/pencilOp.xbm'
fi
if test -f 'bitmaps/selareaOp.xbm' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'bitmaps/selareaOp.xbm'\"
else
echo shar: Extracting \"'bitmaps/selareaOp.xbm'\" \(890 characters\)
sed "s/^X//" >'bitmaps/selareaOp.xbm' <<'END_OF_FILE'
X#define selareaOp_width 32
X#define selareaOp_height 32
Xstatic char selareaOp_bits[] = {
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x00, 0xc0, 0xff, 0x0f, 0x00,
X   0xf0, 0x07, 0x1c, 0x00, 0x70, 0x00, 0x38, 0x00, 0x30, 0x00, 0x30, 0x00,
X   0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x60, 0x00,
X   0x60, 0x00, 0x60, 0x00, 0xe0, 0x00, 0x60, 0x00, 0xc0, 0x03, 0x60, 0x00,
X   0x80, 0x0f, 0x60, 0x00, 0x00, 0x1c, 0x78, 0x00, 0x00, 0x38, 0x3e, 0x00,
X   0x00, 0xf0, 0x1f, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x70, 0x00, 0x00,
X   0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00,
X   0x00, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00,
X   0x00, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

END_OF_FILE
echo shar: NEWLINE appended to \"'bitmaps/selareaOp.xbm'\"
if test 891 -ne `wc -c <'bitmaps/selareaOp.xbm'`; then
    echo shar: \"'bitmaps/selareaOp.xbm'\" unpacked with wrong size!
fi
# end of 'bitmaps/selareaOp.xbm'
fi
if test -f 'bitmaps/selectOp.xbm' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'bitmaps/selectOp.xbm'\"
else
echo shar: Extracting \"'bitmaps/selectOp.xbm'\" \(887 characters\)
sed "s/^X//" >'bitmaps/selectOp.xbm' <<'END_OF_FILE'
X#define selectOp_width 32
X#define selectOp_height 32
Xstatic char selectOp_bits[] = {
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x49, 0x92, 0x04,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x04,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x04,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x04,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x04,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x49, 0x92, 0x04,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

END_OF_FILE
echo shar: NEWLINE appended to \"'bitmaps/selectOp.xbm'\"
if test 888 -ne `wc -c <'bitmaps/selectOp.xbm'`; then
    echo shar: \"'bitmaps/selectOp.xbm'\" unpacked with wrong size!
fi
# end of 'bitmaps/selectOp.xbm'
fi
if test -f 'main.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'main.c'\"
else
echo shar: Extracting \"'main.c'\" \(1427 characters\)
sed "s/^X//" >'main.c' <<'END_OF_FILE'
X/* +-------------------------------------------------------------------+ */
X/* | Copyright 1992, David Koblas.                                     | */
X/* |   Permission to use, copy, modify, and distribute this software   | */
X/* |   and its documentation for any purpose and without fee is hereby | */
X/* |   granted, provided that the above copyright notice appear in all | */
X/* |   copies and that both that copyright notice and this permission  | */
X/* |   notice appear in supporting documentation.  This software is    | */
X/* |   provided "as is" without express or implied warranty.           | */
X/* +-------------------------------------------------------------------+ */
X
X#include <X11/Intrinsic.h>
X#include <stdio.h>
X#include <fcntl.h>
X
X#define DEFINE_GLOBAL
X#include "xpaint.h"
X
Xmain(int argc, char *argv[])
X{
X	Widget	toplevel;
X	int	i;
X
X	/*
X	**  Create the application context
X	*/
X	toplevel = XtInitialize(argv[0], "XPaint", NULL, 0, &argc, argv);
X
X	/*
X	**  Call the initializers
X	*/
X
X	OperationInit(toplevel);
X
X	/*
X	**  A few rogue initaliziers
X	*/
X	BrushInit(toplevel);
X
X	/*
X	**  Realize it
X	*/
X	XtRealizeWidget(toplevel);
X
X	/*
X	**  Now open any file on the command line
X	*/
X	for (i = 1; i < argc; i++) {
X		int	f = open(argv[i], O_RDONLY);
X		char	c;
X
X		if (f < 0)
X			continue;
X		read(f, &c, 1);
X		close(f);
X
X		OpenFile(toplevel, argv[i], c == 'P' ? FT_PBM : FT_XBM);
X	}
X
X	/*
X	**  MainLoop
X	*/
X	XtMainLoop();
X}

END_OF_FILE
echo shar: NEWLINE appended to \"'main.c'\"
if test 1428 -ne `wc -c <'main.c'`; then
    echo shar: \"'main.c'\" unpacked with wrong size!
fi
# end of 'main.c'
fi
if test -f 'region.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'region.h'\"
else
echo shar: Extracting \"'region.h'\" \(1392 characters\)
sed "s/^X//" >'region.h' <<'END_OF_FILE'
X/* +-------------------------------------------------------------------+ */
X/* | Copyright 1992, David Koblas.                                     | */
X/* |   Permission to use, copy, modify, and distribute this software   | */
X/* |   and its documentation for any purpose and without fee is hereby | */
X/* |   granted, provided that the above copyright notice appear in all | */
X/* |   copies and that both that copyright notice and this permission  | */
X/* |   notice appear in supporting documentation.  This software is    | */
X/* |   provided "as is" without express or implied warranty.           | */
X/* +-------------------------------------------------------------------+ */
X
X#define	R_NONE		0
X#define R_BOX		1
X#define R_AREA		2
X
Xtypedef struct {
X	XRectangle	bbox;
X	Pixmap		(*mask)(Widget w);
X	void		(*free)(void*);
X	int		npoints;
X	XPoint		*points;
X	int		startX, startY;
X} RegionArea_t;
X
Xtypedef struct {
X	XRectangle	bbox;
X	Pixmap		(*mask)(Widget w);
X	void		(*free)(void*);
X} RegionBox_t;
X
Xtypedef union {
X	struct {
X		XRectangle	bbox;
X		Pixmap		(*mask)(Widget w);
X		void		(*free)(void*);
X	} generic;
X	RegionBox_t	box;
X	RegionArea_t	area;
X} Region_t;
X
X#define SETREGION(region, new) do {					\
X			if (region != NULL) {				\
X				if (region->generic.free != NULL)	\
X					region->generic.free(region);	\
X				XtFree(region);				\
X			}						\
X			region = (Region_t*)new;			\
X		} while (0)

END_OF_FILE
echo shar: NEWLINE appended to \"'region.h'\"
if test 1393 -ne `wc -c <'region.h'`; then
    echo shar: \"'region.h'\" unpacked with wrong size!
fi
# end of 'region.h'
fi
if test -f 'xpaint.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xpaint.h'\"
else
echo shar: Extracting \"'xpaint.h'\" \(2562 characters\)
sed "s/^X//" >'xpaint.h' <<'END_OF_FILE'
X/* +-------------------------------------------------------------------+ */
X/* | Copyright 1992, David Koblas.                                     | */
X/* |   Permission to use, copy, modify, and distribute this software   | */
X/* |   and its documentation for any purpose and without fee is hereby | */
X/* |   granted, provided that the above copyright notice appear in all | */
X/* |   copies and that both that copyright notice and this permission  | */
X/* |   notice appear in supporting documentation.  This software is    | */
X/* |   provided "as is" without express or implied warranty.           | */
X/* +-------------------------------------------------------------------+ */
X
X#define MIN(a,b)	(((a) < (b)) ? (a) : (b))
X#define MAX(a,b)	(((a) > (b)) ? (a) : (b))
X#define ABS(a)		((a > 0) ? (a) : 0 - (a))
X
X#ifdef __STDC__
X#define CONCAT(a,b)	a##b
X#else
X#define CONCAT(a,b)	a/**/b
X#endif
X
Xtypedef void	(*PaintMenuCallback)();
X
Xtypedef struct {
X	char			*name;
X	PaintMenuCallback	callback;
X	void			*data;
X	int			flags;
X} PaintMenuItem;
X
X#define MF_NONE		0x00
X#define MF_CHECK	0x01
X
Xtypedef struct {
X	char		*name;
X	int		nitems;
X	PaintMenuItem	*items;
X} PaintMenuBar;
X
Xtypedef enum	{ opPixmap = 0x01, opWindow = 0x02 } OpSurface;
X
Xtypedef struct {
X	int		refCount;
X	OpSurface	surface;
X	Drawable	drawable;
X	GC		filled_gc, base_gc, solid_gc;
X	void		*data;
X	int		isFat;
X	int		x, y;
X} OpInfo;
X
Xextern struct Global_s {
X	GC		gcx;
X} Global;
X
Xtypedef	void		*(*OperationFunc)(Widget, ...);
X
Xtypedef OperationFunc	Operation_t;
X
Xextern Widget 		MenuBarCreate(Widget, int, PaintMenuBar[]);
X
X#ifdef DEFINE_GLOBAL
X#define EXTERN(var, val)	var = val ;
X#else
X#define EXTERN(var, val)	extern var ;
X#endif
X
X#define FT_XBM	1
X#define FT_PBM	2
X
XEXTERN(Operation_t *CurrentOp, NULL)
XEXTERN(Pixmap CheckBitmap,None)
X#ifdef DEFINE_GLOBAL
Xstruct Global_s Global;
X#endif
X
Xextern void 	BrushSelect(Widget);
Xextern void 	FontSelect(Widget);
Xextern void	GraphicCreate(Widget, Boolean);
Xextern void	OpenFile(Widget, char *, int);
Xextern Widget	GetToplevel(Widget);
Xextern Widget	GetShell(Widget);
Xextern void	ToggleSetPattern(Widget, Widget);
X#if 0
Xextern void     OpAddEventHandler(Widget, int, Boolean, void *, void *);
Xextern void     OpAddGroupEventHandler(Widget,int,int, Boolean, void *, void *);
Xextern void     OpRemoveEventHandler(Widget, int, Boolean, void *, void *);
X#endif
X
X#define XYtoRECT(x1,y1,x2,y2,rect)					\
X			(rect)->x = MIN(x1,x2); 			\
X			(rect)->y = MIN(y1,y2);				\
X			(rect)->width = MAX(x1,x2) - (rect)->x + 1;	\
X			(rect)->height = MAX(y1,y2) - (rect)->y + 1;

END_OF_FILE
echo shar: NEWLINE appended to \"'xpaint.h'\"
if test 2563 -ne `wc -c <'xpaint.h'`; then
    echo shar: \"'xpaint.h'\" unpacked with wrong size!
fi
# end of 'xpaint.h'
fi
echo shar: End of archive 4 \(of 5\).
cp /dev/null ark4isdone
MISSING=""
for I in 1 2 3 4 5 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 5 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
name : David Koblas                        domain: koblas@mips.com
quote: If you have sex in your car, does that make it a recreational vehicle?
Technical Details
Message-ID: <l5pancINNmiv@spim.mips.com>
Path: arc1-ca.pugleaf.net!wupost!darwin.sura.net!mips!koblas

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!wupost!darwin.sura.net!mips!koblas
From: koblas@mips.com (David Koblas)
Newsgroups: comp.windows.x.apps,alt.sources
Subject: BETA Version of XPaint 2.0  -- Part 4 / 5
Date: 9 Jul 1992 21:09:00 GMT
Organization: MIPS Computer Systems, Sunnyvale, California
Lines: 1929
Distribution: world
Message-ID: <l5pancINNmiv@spim.mips.com>
NNTP-Posting-Host: lloyd.mips.com
Originator: koblas@lloyd.mips.com