Filewatcher File Search
FTP Search
  
Directory 
  
Content Search 
   
pkg://xscrabble-1.0-1.src.rpm:492219/xscrabble.tar.gz  info  downloads

xscrabble/040700 000310 000001 00000000000 06312025022 013711 5ustar00mchapmanstaff000000 000000 xscrabble/Xc/040700 000310 000001 00000000000 06311435313 014272 5ustar00mchapmanstaff000000 000000 xscrabble/Xc/Imakefile100600 000310 000001 00000001571 06050710605 016106 0ustar00mchapmanstaff000000 000000 # Simple Imakefile, courtesy of Robert Withrow.  Use xmkmf to make the
# Makefile. 

RELEASE = 1.0

EXTRA_INCLUDES = -I$(TOP) -I. 

HEADERS = ControlP.h Xc.h BarGraf.h Value.h\
	Control.h BarGrafP.h ValueP.h

SRCS = Control.c Value.c BarGraf.c 
OBJS = Control.o Value.o BarGraf.o

DEPXCLIB = libXc.a
XCLIB = -lXc
LOCAL_LDFLAGS = -L$(TOP)
LOCAL_LIBS = $(XCLIB) XawClientLibs

# Here we must protect against different linking semantics...
#if ProjectX < 5
        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) $(LOCAL_LDFLAGS) -L$(USRLIBDIR)
#endif

NormalLibraryTarget(Xc,$(OBJS))
InstallLibrary(Xc,$(USRLIBDIR))

BuildIncludes($(HEADERS),Xc,..)
InstallMultiple($(HEADERS),$(INCDIR)/Xc)

#clean::
#	$(RM) -r $(TOP)/X11

World::
	@echo ""
	@echo "Building Release "$(RELEASE)" of the Xc Widget Set"
	@echo ""
	$(MAKE) clean
	$(MAKE) includes
	$(MAKE) depend
	$(MAKE) $(WORLDOPTS)

DependTarget()

xscrabble/Xc/copyright.doc100600 000310 000001 00000001171 06047125541 016775 0ustar00mchapmanstaff000000 000000 /*************************************************************************
				COPYRIGHT NOTICE:

			Control Panel Widget Set (Xc), v. 1.3

			copyright (c) 1992 by Paul D. Johnston 

   All rights reserved.  You may freely use and distribute the Control
Panel Widget Set (Xc), but you may not use it, or any widget in the set,
in your commercial or freely distributable applications without giving the 
author due recognition.
Example:

  "This software product makes use of the Control Panel Widget Set (Xc),
v. 1.3, copyright 1992 by Paul D. Johnston."

**************************************************************************/
c,..)
InstallMultiple($(HEADERS),$(INCDIR)/Xc)

#clean::
#	$(RM) -r $(TOP)/X11

World::
	@echo ""
	@echo "Building Release "$(RELEASE)" of the Xc Widget Set"
	@echo ""
	$(MAKE) clean
	$(MAKE) includes
	$(MAKE) depend
	$(MAKE) $(WORLDOPTS)

DependTarget()

xscrabble/Xc/Control.c100600 000310 000001 00000051101 06047125547 016066 0ustar00mchapmanstaff000000 000000 /*******************************************************************
 FILE:		Control.c
 CONTENTS:	Definitions for structures, methods, and actions of the 
		Control widget.
 AUTHOR:	Paul D. Johnston
 HISTORY:
 Date		Action
 ---------	------------------------------------
 5/23/92	Changed the widget class name so that it is preceded
		by 'xc' with the first major word capitalized.
 5/18/92	Changed Label resource processing so that it copies a " "
		to the label pointer instead of "NO LABEL".
 10/22/91	Created.

********************************************************************/

#include <stdio.h>

/* Xlib includes */
#include <X11/Xlib.h>

/* Xt includes */
#include <X11/StringDefs.h>
#include <X11/IntrinsicP.h>
#ifdef X11R3
#include <X11/Xmu.h>
#else
#include <X11/Xmu/Xmu.h>
#endif

/* Widget includes */
#include <X11/Xc/ControlP.h>	/* (includes Control.h also) */


/* Macro redefinition for offset. */
#define offset(field) XtOffset(ControlWidget, field)

/* Constants used in 3D rectangle color generation. */
#define MAX_RGB	65280
#define SHADE_INTENSITY	((unsigned short)(MAX_RGB / 4))

/* Data for the bitmap used for the 3D shading effect. */
#define shade_width 2
#define shade_height 2
static char shade_bits[] = { 0x02, 0x01};

/* Declare widget methods */
static void Initialize();
static void Destroy();
static Boolean SetValues();



/* Define the widget's resource list */
static XtResource resources[] =
{
  {
    XcNbackground,
    XtCColor,
    XtRPixel,
    sizeof(Pixel),
    offset(control.background_pixel),
    XtRString,
    "gray"
  },
  {
    XcNlabelColor,
    XtCColor,
    XtRPixel,
    sizeof(Pixel),
    offset(control.label_pixel),
    XtRString,
    XtDefaultForeground
  },
  {
    XcNlabel,
    XcCLabel,
    XtRString,
    sizeof(String),
    offset(control.label),
    XtRString,
    "  "
  },
  {
    XtNfont,
    XtCFont,
    XtRFontStruct,
    sizeof(XFontStruct *),
    offset(control.font),
    XtRString,
    XtDefaultFont
  },
  {
    XcNshadeDepth,
    XcCShadeDepth,
    XtRInt,
    sizeof(int),
    offset(control.shade_depth),
    XtRString,
    "3"
  },

};



/* Widget Class Record initialization */
ControlClassRec controlClassRec =
{
  {
  /* core_class part */
    (WidgetClass) &widgetClassRec,		/* superclass */
    "Control",					/* class_name */
    sizeof(ControlRec),				/* widget_size */
    NULL,					/* class_initialize */
    NULL,					/* class_part_initialize */
    FALSE,					/* class_inited */
    Initialize,					/* initialize */
    NULL,					/* initialize_hook */
    XtInheritRealize,				/* realize */
    NULL,					/* actions */
    0,						/* num_actions */
    resources,					/* resources */
    XtNumber(resources),			/* num_resources */
    NULLQUARK,					/* xrm_class */
    TRUE,					/* compress_motion */
    TRUE,					/* compress_exposure */
    TRUE,					/* compress_enterleave */
    TRUE,					/* visible_interest */
    Destroy,					/* destroy */
    NULL,					/* resize */
    NULL,					/* expose */
    SetValues,					/* set_values */
    NULL,					/* set_values_hook */
    XtInheritSetValuesAlmost,			/* set_values_almost */
    NULL,					/* get_values_hook */
    NULL,					/* accept_focus */
    XtVersion,					/* version */
    NULL,					/* callback_private */
    NULL,					/* tm_table */
    NULL,					/* query_geometry */
    NULL,					/* display_accelerator */
    NULL,					/* extension */
  },
  {
  /* Control class part */
    0,						/* dummy_field */
  },
};

WidgetClass xcControlWidgetClass = (WidgetClass)&controlClassRec;


/* Widget method function definitions */

/*******************************************************************
 NAME:		Initialize.		
 DESCRIPTION:
   This is the initialize method for the Control widget.  It 
validates user-modifiable instance resources and initializes private 
widget variables and structures.  This function also creates any server 
resources (i.e., GCs, fonts, Pixmaps, etc.) used by this widget.  This
method is called by Xt when the application calls XtCreateWidget().

*******************************************************************/

static void Initialize(request, new)
ControlWidget request, new;
{
/* Local variables */
XColor bg, exact;
Display *display = XtDisplay(new);
int scr = DefaultScreen(XtDisplay(new));
XGCValues values;
XtGCMask mask; 
static char dash_list[2] = { 1, 1 };

#ifdef NICE_SHADES
/* These macros are used for calculating the 3D shade colors. */
#define COLOR_ADD(member) \
   if (((int)bg.member + (int)SHADE_INTENSITY) <= MAX_RGB) \
      new->control.shade1.member = bg.member + SHADE_INTENSITY; \
   else  new->control.shade1.member = MAX_RGB; \

#define COLOR_SUBTRACT(member) \
   if (((int)bg.member - (int)SHADE_INTENSITY) >= 0) \
      new->control.shade2.member = bg.member - SHADE_INTENSITY; \
   else  new->control.shade2.member = 0; \


/*
 * Determine whether or not a backgroud color resource has been set for
 * this widget, and if so, what its RGB values are. If no color has been
 * established, set gray as its background by default.
 */
   if (new->control.background_pixel)
   {
      bg.pixel = new->control.background_pixel;
      XQueryColor(display, DefaultColormap(display, scr), &bg);
   }
   else
   {
      if (XAllocNamedColor(display, DefaultColormap(display, scr),
		"gray", &bg, &exact)) 
	 new->control.background_pixel = bg.pixel;
      else
	 XtWarning("Control: unable to alloc default bg\n");
   }

/*
 * Calculate the 3D rectangle shades based on the background color RGB
 * values, and allocate the corresponding colors. 
 */
   COLOR_ADD(red);
   COLOR_ADD(green);
   COLOR_ADD(blue);
   COLOR_SUBTRACT(red);
   COLOR_SUBTRACT(green);
   COLOR_SUBTRACT(blue);
   if (XAllocColor(display, DefaultColormap(display, scr), 
					&(new->control.shade1)) == 0)
   {
      XtWarning("Control: unable to alloc shade 1 color\n");
      new->control.shade1.pixel = WhitePixel(display, DefaultScreen(display));
   }
   if (XAllocColor(display, DefaultColormap(display, scr), 
					&(new->control.shade2)) == 0)
   {
      XtWarning("Control: unable to alloc shade 2 color\n");
      new->control.shade2.pixel = BlackPixel(display, DefaultScreen(display));
   }
#endif	/* NICE_SHADES */


/*
 * Validate public instance variable settings.
 */
   if (strlen(new->control.label) == 0)
   {
      XtWarning("Control: invalid or missing label string.");
      strcpy(new->control.label, " "); 
   }

   if ((new->control.shade_depth < MIN_SHADE_DEPTH) || 
			(new->control.shade_depth > MAX_SHADE_DEPTH))
   {
      XtWarning("Control: invalid shadeDepth specification.");
      new->control.shade_depth = 3;
   }


/* Create the GC used by all subclasses for drawing in this widget. */
   values.graphics_exposures = False;
   values.foreground = new->control.label_pixel;
   values.background = new->control.background_pixel;
   values.font = new->control.font->fid;
   mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures; 
   if ((new->control.gc = XCreateGC(display, 
			RootWindowOfScreen(XtScreen(new)), 
			mask, &values)) == NULL)
      XtWarning("Control: couldn't create GC");

/* Set basic line attributes used in drawing this widget. */
   XSetLineAttributes(display, new->control.gc, 0, LineSolid, 
						CapButt, JoinRound);
   XSetDashes(display, new->control.gc, 0, dash_list, 2);


}  /* end of Initialize */




/*******************************************************************
 NAME:		SetValues.
 DESCRIPTION:
   This is the set_values method for this widget. It validates resource
settings set with XtSetValues. If a resource is changed that would
require re-drawing the widget, return True.

*******************************************************************/

static Boolean SetValues(cur, req, new)
ControlWidget cur, req, new;
{
/* Local variables */
Boolean do_redisplay = False;


/* Validate new resource settings. */
/* Check to see if the labelColor has changed. */
   if (new->control.label_pixel != cur->control.label_pixel)
      do_redisplay = True;

/* Check for valid shadeDepth setting. */
   if (new->control.shade_depth != cur->control.shade_depth)
   {
      do_redisplay = True;
      if ((new->control.shade_depth < MIN_SHADE_DEPTH) || 
			(new->control.shade_depth > MAX_SHADE_DEPTH))
      {
         XtWarning("Control: invalid shadeDepth setting.");
         new->control.shade_depth = 3;
      }
   }

/* Check for a valid label */
   if (strcmp(new->control.label, cur->control.label) != 0)
   {
      if (strlen(new->control.label) == 0)
      {
         XtWarning("Control: invalid Label setting.");
	 if (new->control.label != NULL)
            strcpy(new->control.label, " ");
      }
      do_redisplay = True;
   }

   return do_redisplay;


}  /* end of SetValues */



/*******************************************************************
 NAME:		Destroy.
 DESCRIPTION:
   This function is the widget's destroy method.  It simply releases
any server resources acquired during the life of the widget.

*******************************************************************/

static void Destroy(w)
ControlWidget w;
{

   if (w->control.gc)
      XFreeGC(XtDisplay(w), w->control.gc);

}  /* end of Destroy */





/* Functions shared by widget subclasses. */

/***************************************************************************
   FUNCTION:	Point_In_Rect.
   DESCRIPTION:
   This function simply checks to see if the given point is within the 
given rectangle and returns TRUE if it is, or FALSE if it isn't within
the rectangle. 

***************************************************************************/

Boolean Point_In_Rect(		/* RETURN: True or False; identifies whether
				 * 	   or not the point is in the 
				 * 	   rectangle.
				 */

		x,		/* INPUT: The x coordinate of the point */

		y,		/* INPUT: The y coordinate of the point */

		rect_x,		/* INPUT: The x coordinate of the rectangle */

		rect_y,		/* INPUT: The y coordinate of the rectangle */

		width,		/* INPUT: The rectangle's width */

		height)		/* INPUT: The rectangle's height */

int 	x, 
	y, 
	rect_x, 
	rect_y, 
	width, 
	height;
{
/* Check x coordinate first */
   if ((x < rect_x) || (x > (rect_x + width)))
      return False;

/* Check y coordinate next. If its within the rectangle, return True. */
   if ((y < rect_y) || (y > (rect_y + height)))
      return False;

   return True;

} /* end of Point_In_Rect */






/*******************************************************************
 NAME:		Rect3d.
 DESCRIPTION:
   This function generates a filled rectangle with a 3D effect in
the given drawable.  It uses the widget's background color and the
derived shades (calculated in the Initialize method) to produce the
3D rectangle.  

*******************************************************************/

void Rect3d(w, display, drawable, gc, x, y, width, height, type)
ControlWidget w;
Display *display;
Drawable drawable;
GC gc;
int x, y;
unsigned int width, height;
Type3d type;
{
int j;
unsigned long shade1, shade2;

/* Set basic GC attributes used in drawing the 3D rectangle. */
#ifdef NICE_SHADES
   shade1 = w->control.shade1.pixel;
   shade2 = w->control.shade2.pixel;
#else
   shade1 = WhitePixel(display, DefaultScreen(display));
   shade2 = BlackPixel(display, DefaultScreen(display));
   XSetLineAttributes(display, gc, 0, LineOnOffDash, CapButt, JoinRound);
#endif

/* Draw the shadow lines */
   for (j = 0; j < w->control.shade_depth; j++)
   {
      if (type == RAISED)
	 XSetForeground(display, gc, shade1);
      else
	 XSetForeground(display, gc, shade2);
      XDrawLine(display, drawable, gc, x+j, y+j, x+j, y+height-j);
      XDrawLine(display, drawable, gc, x+j, y+j, x+width-j, y+j);

      if (type == RAISED)
	 XSetForeground(display, gc, shade2);
      else
	 XSetForeground(display, gc, shade1);
      XDrawLine(display, drawable, gc, x+j, y+height-j, x+width-j, y+height-j);
      XDrawLine(display, drawable, gc, x+width-j, y+j, x+width-j, y+height-j);
   }

/* Fill in the background. */
   XSetFillStyle(display, gc, FillSolid);
   XSetLineAttributes(display, gc, 0, LineSolid, CapButt, JoinRound);
   XSetForeground(display, gc, w->control.background_pixel);
   if ((width > (2 * w->control.shade_depth)) && 
			(height > (2 * w->control.shade_depth)))
      XFillRectangle(display, drawable, gc, x+w->control.shade_depth, 
	y+w->control.shade_depth, width-(2 * w->control.shade_depth), 
				height-(2 * w->control.shade_depth));
   

}  /* end of Rect3d */



/*******************************************************************
 NAME:		VarRect3d.
 DESCRIPTION:
   This function generates a filled rectangle with a 3D effect in
the given drawable.  It uses the widget's background color and the
derived shades (calculated in the Initialize method) to produce the
3D rectangle.  

*******************************************************************/

void VarRect3d(w, display, drawable, gc, x, y, width, height, type, depth)
ControlWidget w;
Display *display;
Drawable drawable;
GC gc;
int x, y;
unsigned int width, height;
Type3d type;
int depth;
{
int j = ((depth < 1) ? 1 : depth);
unsigned long shade1, shade2;

/* Set basic line attributes used in drawing the 3D rectangle. */
#ifdef NICE_SHADES
   shade1 = w->control.shade1.pixel;
   shade2 = w->control.shade2.pixel;
#else
   shade1 = WhitePixel(display, DefaultScreen(display));
   shade2 = BlackPixel(display, DefaultScreen(display));
   XSetLineAttributes(display, gc, 0, LineOnOffDash, CapButt, JoinRound);
#endif

/* Draw the shadow lines */
   for (j = 0; j < w->control.shade_depth; j++)
   {
      if (type == RAISED)
	 XSetForeground(display, gc, shade1);
      else
	 XSetForeground(display, gc, shade2);
      XDrawLine(display, drawable, gc, x+j, y+j, x+j, y+height-j);
      XDrawLine(display, drawable, gc, x+j, y+j, x+width-j, y+j);

      if (type == RAISED)
	 XSetForeground(display, gc, shade2);
      else
	 XSetForeground(display, gc, shade1);
      XDrawLine(display, drawable, gc, x+j, y+height-j, x+width-j, y+height-j);
      XDrawLine(display, drawable, gc, x+width-j, y+j, x+width-j, y+height-j);
   }

/* Fill in the background. */
   XSetLineAttributes(display, gc, 0, LineSolid, CapButt, JoinRound);
   XSetFillStyle(display, gc, FillSolid);
   XSetForeground(display, gc, w->control.background_pixel);
   if ((width > (2 * depth)) && (height > (2 * depth)))
      XFillRectangle(display, drawable, gc, x + depth, 
	y + depth, width-(2 * depth), height-(2 * depth));
   

}  /* end of VarRect3d */



/*******************************************************************
 NAME:		ToLower.		
 DESCRIPTION:
   Converts a character string to all lowercase for use in the 
resource string conversion routines.

*******************************************************************/

void ToLower(source, dest)
char *source, *dest;
{
/* Local variables */
char ch;

   for (; (ch = *source) != 0; source++, dest++)
   {
      if ('A' <= ch && ch <= 'Z')
	 *dest = ch - 'A' + 'a';
      else
	 *dest = ch;
   }

   *dest = 0;

}  /* end of ToLower */




/*******************************************************************
 NAME:		CvtStringToOrient.		
 DESCRIPTION:
   This function converts resource settings in string form to the
XcROrient representation type.

*******************************************************************/

void CvtStringToOrient(args, num_args, fromVal, toVal)
XrmValuePtr args;		/* unused */
Cardinal *num_args;		/* unused */
XrmValuePtr fromVal;
XrmValuePtr toVal;
{
/* Local variables */
static XcOrient orient;
char lowerstring[100];


/* Convert the resource string to lower case for quick comparison */
   ToLower((char *)fromVal->addr, lowerstring);


/*
 * Compare resource string with valid XcOrient strings and assign to
 * datatype.
 */
   if (strcmp(lowerstring, XcEvert) == 0) 
   {
      orient = XcVert;
      CvtDone(XcOrient, &orient);
   }
   else if (strcmp(lowerstring, XcEhoriz) == 0) 
   {
      orient = XcHoriz;
      CvtDone(XcOrient, &orient);
   }

/*
 * If the string is not valid for this resource type, print a warning
 * and do not make the conversion.
 */
   XtStringConversionWarning(fromVal->addr, "XcOrient");
   toVal->addr = NULL;
   toVal->size = 0;

}  /* end of CvtStringToOrient */



/*******************************************************************
 NAME:		Arrow3d.
 DESCRIPTION:
   This function generates a filled arrow polygon with a 3D effect in
the given drawable.  It uses the widget's background color and the
derived shades (calculated in Control's Initialize method) to produce the
3D effect.  

*******************************************************************/

void Arrow3d(w, display, drawable, gc, bounds, orientation, type)
ControlWidget w;
Display *display;
Drawable drawable;
GC gc;
XRectangle *bounds;
ArrowType orientation;
Type3d type;
{
/* Local variables */
int i, j, adjustment = w->control.shade_depth+1;
XPoint points[4];
unsigned long shade1, shade2;

/* Set basic line attributes used in drawing the 3D arrow. */
#ifdef NICE_SHADES
   shade1 = w->control.shade1.pixel;
   shade2 = w->control.shade2.pixel;
#else
   shade1 = WhitePixel(display, DefaultScreen(display));
   shade2 = BlackPixel(display, DefaultScreen(display));
   XSetLineAttributes(display, gc, 0, LineOnOffDash, CapButt, JoinRound);
#endif

/* This macro is used to determine the shading color to use. */
#define SET_SHADE( sh1, sh2 ) \
 if (type == RAISED) XSetForeground(display, gc, sh1); \
 else XSetForeground(display, gc, sh2); \


/*
 * Calculate the arrow vertices based on the bounding rectangle and
 * orientation.
 */
   if (orientation == UP)
   {
   /* left corner */
      points[0].x = bounds->x;
      points[0].y = bounds->y + bounds->height;
   /* arrow tip */
      points[1].x = points[0].x + (bounds->width / 2 + 0.5);
      points[1].y = bounds->y;
   /* right corner */
      points[2].x = points[0].x + bounds->width;
      points[2].y = points[0].y;
   }
   else if (orientation == DOWN)
   {
   /* left corner */
      points[0].x = bounds->x;  
      points[0].y = bounds->y;  
   /* arrow tip */
      points[1].x = points[0].x + (bounds->width / 2 + 0.5); 
      points[1].y = bounds->y + bounds->height; 
   /* right corner */
      points[2].x = points[0].x + bounds->width;
      points[2].y = points[0].y;
   }
   else if (orientation == LEFT)
   {
   /* left corner */
      points[0].x = bounds->x + bounds->width;  
      points[0].y = bounds->y + bounds->height;  
   /* arrow tip */
      points[1].x = bounds->x;
      points[1].y = bounds->y + (bounds->height / 2 + 0.5);  
   /* right corner */
      points[2].x = points[0].x; 
      points[2].y = bounds->y;
   }
   else if (orientation == RIGHT)
   {
   /* left corner */
      points[0].x = bounds->x;
      points[0].y = bounds->y;
   /* arrow tip */
      points[1].x = bounds->x + bounds->width;
      points[1].y = bounds->y + (bounds->height / 2 + 0.5);  
   /* right corner */
      points[2].x = points[0].x; 
      points[2].y = bounds->y + bounds->height;
   }

/* left corner */
   points[3].x = points[0].x;
   points[3].y = points[0].y;


/* Draw the shadow lines */
   for (j = 0; j < w->control.shade_depth; j++)
   {
      if (orientation == UP)
      {
	 SET_SHADE(shade1, shade2);
	 XDrawLine(display, drawable, gc, points[0].x+j, points[0].y-j, 
				points[1].x, points[1].y+j);
	 XDrawLine(display, drawable, gc, points[1].x, points[1].y+j, 
				points[2].x-j, points[2].y-j);
	 SET_SHADE(shade2, shade1);
	 XDrawLine(display, drawable, gc, points[2].x-j, points[2].y-j, 
				points[3].x+j, points[3].y-j);
      }
      else if (orientation == DOWN)
      {
	 SET_SHADE(shade2, shade1);
	 XDrawLine(display, drawable, gc, points[0].x+j, points[0].y+j, 
				points[1].x, points[1].y-j);
	 XDrawLine(display, drawable, gc, points[1].x, points[1].y-j, 
				points[2].x-j, points[2].y+j);
	 SET_SHADE(shade1, shade2);
	 XDrawLine(display, drawable, gc, points[2].x-j, points[3].y+j, 
				points[3].x+j, points[3].y+j);
      }
      else if (orientation == LEFT)
      {
	 SET_SHADE(shade2, shade1);
	 XDrawLine(display, drawable, gc, points[0].x-j, points[0].y-j, 
				points[1].x+j, points[1].y);
	 SET_SHADE(shade1, shade2);
	 XDrawLine(display, drawable, gc, points[1].x+j, points[1].y, 
				points[2].x-j, points[2].y+j);
	 SET_SHADE(shade2, shade1);
	 XDrawLine(display, drawable, gc, points[2].x-j, points[2].y+j, 
				points[3].x-j, points[3].y-j);
      }
      else if (orientation == RIGHT)
      {
	 SET_SHADE(shade1, shade2);
	 XDrawLine(display, drawable, gc, points[0].x+j, points[0].y+j, 
				points[1].x-j, points[1].y);
	 SET_SHADE(shade2, shade1);
	 XDrawLine(display, drawable, gc, points[1].x-j, points[1].y, 
				points[2].x+j, points[2].y-j);
	 SET_SHADE(shade1, shade2);
	 XDrawLine(display, drawable, gc, points[2].x+j, points[2].y-j, 
				points[3].x+j, points[3].y+j);
      }
   }

   XSetLineAttributes(display, gc, 0, LineSolid, CapButt, JoinRound);
   XSetFillStyle(display, gc, FillSolid);

}  /* end of Arrow3d */


/* end of Control.c */

et basic line attributes used in drawing the 3D arrow. */
#ifdef NICE_SHADES
   shade1 = w->control.shade1.pixel;
   shade2 = w->control.shade2.pixel;
#else
   shade1 = WhitePixel(display, DefaultScreen(display));
   shade2 = BlackPixel(display, DefaultScreen(display));
   XSetLineAttributes(display, gc, 0, LineOnOffDash, CapButt, JoinRound);
#endif

/* This macro is used to determine the shading color to use. */
#define SET_SHADE( sh1, sh2 ) xscrabble/Xc/Control.c.orig100600 000310 000001 00000051103 06047125547 017027 0ustar00mchapmanstaff000000 000000 /*******************************************************************
 FILE:		Control.c
 CONTENTS:	Definitions for structures, methods, and actions of the 
		Control widget.
 AUTHOR:	Paul D. Johnston
 HISTORY:
 Date		Action
 ---------	------------------------------------
 5/23/92	Changed the widget class name so that it is preceded
		by 'xc' with the first major word capitalized.
 5/18/92	Changed Label resource processing so that it copies a " "
		to the label pointer instead of "NO LABEL".
 10/22/91	Created.

********************************************************************/

#include <stdio.h>

/* Xlib includes */
#include <X11/Xlib.h>

/* Xt includes */
#include <X11/StringDefs.h>
#include <X11/IntrinsicP.h>
#ifdef X11R3
#include <X11/Xmu.h>
#else
#include <X11/Xmu/Xmu.h>
#endif

/* Widget includes */
#include <X11/Xc/ControlP.h>	/* (includes Control.h also) */


/* Macro redefinition for offset. */
#define offset(field) XtOffset(ControlWidget, field)

/* Constants used in 3D rectangle color generation. */
#define MAX_RGB	65280
#define SHADE_INTENSITY	((unsigned short)(MAX_RGB / 4))

/* Data for the bitmap used for the 3D shading effect. */
#define shade_width 2
#define shade_height 2
static char shade_bits[] = { 0x02, 0x01};

/* Declare widget methods */
static void Initialize();
static void Destroy();
static Boolean SetValues();



/* Define the widget's resource list */
static XtResource resources[] =
{
  {
    XcNbackground,
    XtCColor,
    XtRPixel,
    sizeof(Pixel),
    offset(control.background_pixel),
    XtRString,
    "gray"
  },
  {
    XcNlabelColor,
    XtCColor,
    XtRPixel,
    sizeof(Pixel),
    offset(control.label_pixel),
    XtRString,
    XtDefaultForeground
  },
  {
    XcNlabel,
    XcCLabel,
    XtRString,
    sizeof(String),
    offset(control.label),
    XtRString,
    "  "
  },
  {
    XtNfont,
    XtCFont,
    XtRFontStruct,
    sizeof(XFontStruct *),
    offset(control.font),
    XtRString,
    XtDefaultFont
  },
  {
    XcNshadeDepth,
    XcCShadeDepth,
    XtRInt,
    sizeof(int),
    offset(control.shade_depth),
    XtRString,
    "3"
  },

};



/* Widget Class Record initialization */
ControlClassRec controlClassRec =
{
  {
  /* core_class part */
    (WidgetClass) &widgetClassRec,		/* superclass */
    "Control",					/* class_name */
    sizeof(ControlRec),				/* widget_size */
    NULL,					/* class_initialize */
    NULL,					/* class_part_initialize */
    FALSE,					/* class_inited */
    Initialize,					/* initialize */
    NULL,					/* initialize_hook */
    XtInheritRealize,				/* realize */
    NULL,					/* actions */
    0,						/* num_actions */
    resources,					/* resources */
    XtNumber(resources),			/* num_resources */
    NULLQUARK,					/* xrm_class */
    TRUE,					/* compress_motion */
    TRUE,					/* compress_exposure */
    TRUE,					/* compress_enterleave */
    TRUE,					/* visible_interest */
    Destroy,					/* destroy */
    NULL,					/* resize */
    NULL,					/* expose */
    SetValues,					/* set_values */
    NULL,					/* set_values_hook */
    XtInheritSetValuesAlmost,			/* set_values_almost */
    NULL,					/* get_values_hook */
    NULL,					/* accept_focus */
    XtVersion,					/* version */
    NULL,					/* callback_private */
    NULL,					/* tm_table */
    NULL,					/* query_geometry */
    NULL,					/* display_accelerator */
    NULL,					/* extension */
  },
  {
  /* Control class part */
    0,						/* dummy_field */
  },
};

WidgetClass xcControlWidgetClass = (WidgetClass)&controlClassRec;


/* Widget method function definitions */

/*******************************************************************
 NAME:		Initialize.		
 DESCRIPTION:
   This is the initialize method for the Control widget.  It 
validates user-modifiable instance resources and initializes private 
widget variables and structures.  This function also creates any server 
resources (i.e., GCs, fonts, Pixmaps, etc.) used by this widget.  This
method is called by Xt when the application calls XtCreateWidget().

*******************************************************************/

static void Initialize(request, new)
ControlWidget request, new;
{
/* Local variables */
XColor bg, exact;
Display *display = XtDisplay(new);
int scr = DefaultScreen(XtDisplay(new));
XGCValues values;
XtGCMask mask; 
static char dash_list[2] = { 1, 1 };

#ifdef NICE_SHADES
/* These macros are used for calculating the 3D shade colors. */
#define COLOR_ADD(member) \
   if (((int)bg.member + (int)SHADE_INTENSITY) <= MAX_RGB) \
      new->control.shade1.member = bg.member + SHADE_INTENSITY; \
   else  new->control.shade1.member = MAX_RGB; \

#define COLOR_SUBTRACT(member) \
   if (((int)bg.member - (int)SHADE_INTENSITY) >= 0) \
      new->control.shade2.member = bg.member - SHADE_INTENSITY; \
   else  new->control.shade2.member = 0; \


/*
 * Determine whether or not a backgroud color resource has been set for
 * this widget, and if so, what its RGB values are. If no color has been
 * established, set gray as its background by default.
 */
   if (new->control.background_pixel)
   {
      bg.pixel = new->control.background_pixel;
      XQueryColor(display, DefaultColormap(display, scr), &bg);
   }
   else
   {
      if (XAllocNamedColor(display, DefaultColormap(display, scr),
		"gray", &bg, &exact)) 
	 new->control.background_pixel = bg.pixel;
      else
	 XtWarning("Control: unable to alloc default bg\n");
   }

/*
 * Calculate the 3D rectangle shades based on the background color RGB
 * values, and allocate the corresponding colors. 
 */
   COLOR_ADD(red);
   COLOR_ADD(green);
   COLOR_ADD(blue);
   COLOR_SUBTRACT(red);
   COLOR_SUBTRACT(green);
   COLOR_SUBTRACT(blue);
   if (XAllocColor(display, DefaultColormap(display, scr), 
					&(new->control.shade1)) == 0)
   {
      XtWarning("Control: unable to alloc shade 1 color\n");
      new->control.shade1.pixel = WhitePixel(display, DefaultScreen(display));
   }
   if (XAllocColor(display, DefaultColormap(display, scr), 
					&(new->control.shade2)) == 0)
   {
      XtWarning("Control: unable to alloc shade 2 color\n");
      new->control.shade2.pixel = BlackPixel(display, DefaultScreen(display));
   }
#endif	/* NICE_SHADES */


/*
 * Validate public instance variable settings.
 */
   if (strlen(new->control.label) == 0)
   {
      XtWarning("Control: invalid or missing label string.");
      strcpy(new->control.label, " "); 
   }

   if ((new->control.shade_depth < MIN_SHADE_DEPTH) || 
			(new->control.shade_depth > MAX_SHADE_DEPTH))
   {
      XtWarning("Control: invalid shadeDepth specification.");
      new->control.shade_depth = 3;
   }


/* Create the GC used by all subclasses for drawing in this widget. */
   values.graphics_exposures = False;
   values.foreground = new->control.label_pixel;
   values.background = new->control.background_pixel;
   values.font = new->control.font->fid;
   mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures; 
   if ((new->control.gc = XCreateGC(display, 
			RootWindowOfScreen(XtScreen(new)), 
			mask, &values)) == NULL)
      XtWarning("Control: couldn't create GC");

/* Set basic line attributes used in drawing this widget. */
   XSetLineAttributes(display, new->control.gc, 0, LineSolid, 
						CapButt, JoinRound);
   XSetDashes(display, new->control.gc, 0, dash_list, 2);


}  /* end of Initialize */




/*******************************************************************
 NAME:		SetValues.
 DESCRIPTION:
   This is the set_values method for this widget. It validates resource
settings set with XtSetValues. If a resource is changed that would
require re-drawing the widget, return True.

*******************************************************************/

static Boolean SetValues(cur, req, new)
ControlWidget cur, req, new;
{
/* Local variables */
Boolean do_redisplay = False;


/* Validate new resource settings. */
/* Check to see if the labelColor has changed. */
   if (new->control.label_pixel != cur->control.label_pixel)
      do_redisplay = True;

/* Check for valid shadeDepth setting. */
   if (new->control.shade_depth != cur->control.shade_depth)
   {
      do_redisplay = True;
      if ((new->control.shade_depth < MIN_SHADE_DEPTH) || 
			(new->control.shade_depth > MAX_SHADE_DEPTH))
      {
         XtWarning("Control: invalid shadeDepth setting.");
         new->control.shade_depth = 3;
      }
   }

/* Check for a valid label */
   if (strcmp(new->control.label, cur->control.label) != 0)
   {
      if (strlen(new->control.label) == 0)
      {
         XtWarning("Control: invalid Label setting.");
	 if (new->control.label != NULL)
            strcpy(new->control.label, " ");
      }
      do_redisplay = True;
   }

   return do_redisplay;


}  /* end of SetValues */



/*******************************************************************
 NAME:		Destroy.
 DESCRIPTION:
   This function is the widget's destroy method.  It simply releases
any server resources acquired during the life of the widget.

*******************************************************************/

static void Destroy(w)
ControlWidget w;
{

   if (w->control.gc)
      XFreeGC(XtDisplay(w), w->control.gc);

}  /* end of Destroy */





/* Functions shared by widget subclasses. */

/***************************************************************************
   FUNCTION:	Point_In_Rect.
   DESCRIPTION:
   This function simply checks to see if the given point is within the 
given rectangle and returns TRUE if it is, or FALSE if it isn't within
the rectangle. 

***************************************************************************/

Boolean Point_In_Rect(		/* RETURN: True or False; identifies whether
				 * 	   or not the point is in the 
				 * 	   rectangle.
				 */

		x,		/* INPUT: The x coordinate of the point */

		y,		/* INPUT: The y coordinate of the point */

		rect_x,		/* INPUT: The x coordinate of the rectangle */

		rect_y,		/* INPUT: The y coordinate of the rectangle */

		width,		/* INPUT: The rectangle's width */

		height)		/* INPUT: The rectangle's height */

int 	x, 
	y, 
	rect_x, 
	rect_y, 
	width, 
	height;
{
/* Check x coordinate first */
   if ((x < rect_x) || (x > (rect_x + width)))
      return False;

/* Check y coordinate next. If its within the rectangle, return True. */
   if ((y < rect_y) || (y > (rect_y + height)))
      return False;

   return True;

} /* end of Point_In_Rect */






/*******************************************************************
 NAME:		Rect3d.
 DESCRIPTION:
   This function generates a filled rectangle with a 3D effect in
the given drawable.  It uses the widget's background color and the
derived shades (calculated in the Initialize method) to produce the
3D rectangle.  

*******************************************************************/

void Rect3d(w, display, drawable, gc, x, y, width, height, type)
ControlWidget w;
Display *display;
Drawable drawable;
GC gc;
int x, y;
unsigned int width, height;
Type3d type;
{
int j;
unsigned long shade1, shade2;

/* Set basic GC attributes used in drawing the 3D rectangle. */
#ifdef NICE_SHADES
   shade1 = w->control.shade1.pixel;
   shade2 = w->control.shade2.pixel;
#else
   shade1 = WhitePixel(display, DefaultScreen(display));
   shade2 = BlackPixel(display, DefaultScreen(display));
   XSetLineAttributes(display, gc, 0, LineOnOffDash, CapButt, JoinRound);
#endif

/* Draw the shadow lines */
   for (j = 0; j < w->control.shade_depth; j++)
   {
      if (type == RAISED)
	 XSetForeground(display, gc, shade1);
      else
	 XSetForeground(display, gc, shade2);
      XDrawLine(display, drawable, gc, x+j, y+j, x+j, y+height-j);
      XDrawLine(display, drawable, gc, x+j, y+j, x+width-j, y+j);

      if (type == RAISED)
	 XSetForeground(display, gc, shade2);
      else
	 XSetForeground(display, gc, shade1);
      XDrawLine(display, drawable, gc, x+j, y+height-j, x+width-j, y+height-j);
      XDrawLine(display, drawable, gc, x+width-j, y+j, x+width-j, y+height-j);
   }

/* Fill in the background. */
   XSetFillStyle(display, gc, FillSolid);
   XSetLineAttributes(display, gc, 0, LineSolid, CapButt, JoinRound);
   XSetForeground(display, gc, w->control.background_pixel);
   if ((width > (2 * w->control.shade_depth)) && 
			(height > (2 * w->control.shade_depth)))
      XFillRectangle(display, drawable, gc, x+w->control.shade_depth, 
	y+w->control.shade_depth, width-(2 * w->control.shade_depth), 
				height-(2 * w->control.shade_depth));
   

}  /* end of Rect3d */



/*******************************************************************
 NAME:		VarRect3d.
 DESCRIPTION:
   This function generates a filled rectangle with a 3D effect in
the given drawable.  It uses the widget's background color and the
derived shades (calculated in the Initialize method) to produce the
3D rectangle.  

*******************************************************************/

void VarRect3d(w, display, drawable, gc, x, y, width, height, type, depth)
ControlWidget w;
Display *display;
Drawable drawable;
GC gc;
int x, y;
unsigned int width, height;
Type3d type;
int depth;
{
int j = ((depth < 1) ? 1 : depth);
unsigned long shade1, shade2;

/* Set basic line attributes used in drawing the 3D rectangle. */
#ifdef NICE_SHADES
   shade1 = w->control.shade1.pixel;
   shade2 = w->control.shade2.pixel;
#else
   shade1 = WhitePixel(display, DefaultScreen(display));
   shade2 = BlackPixel(display, DefaultScreen(display));
   XSetLineAttributes(display, gc, 0, LineOnOffDash, CapButt, JoinRound);
#endif

/* Draw the shadow lines */
   for (j = 0; j < w->control.shade_depth; j++)
   {
      if (type == RAISED)
	 XSetForeground(display, gc, shade1);
      else
	 XSetForeground(display, gc, shade2);
      XDrawLine(display, drawable, gc, x+j, y+j, x+j, y+height-j);
      XDrawLine(display, drawable, gc, x+j, y+j, x+width-j, y+j);

      if (type == RAISED)
	 XSetForeground(display, gc, shade2);
      else
	 XSetForeground(display, gc, shade1);
      XDrawLine(display, drawable, gc, x+j, y+height-j, x+width-j, y+height-j);
      XDrawLine(display, drawable, gc, x+width-j, y+j, x+width-j, y+height-j);
   }

/* Fill in the background. */
   XSetLineAttributes(display, gc, 0, LineSolid, CapButt, JoinRound);
   XSetFillStyle(display, gc, FillSolid);
   XSetForeground(display, gc, w->control.background_pixel);
   if ((width > (2 * depth)) && (height > (2 * depth)))
      XFillRectangle(display, drawable, gc, x + depth, 
	y + depth, width-(2 * depth), height-(2 * depth));
   

}  /* end of VarRect3d */



/*******************************************************************
 NAME:		ToLower.		
 DESCRIPTION:
   Converts a character string to all lowercase for use in the 
resource string conversion routines.

*******************************************************************/

void ToLower(source, dest)
char *source, *dest;
{
/* Local variables */
char ch;

   for (; (ch = *source) != 0; source++, dest++)
   {
      if ('A' <= ch && ch <= 'Z')
	 *dest = ch - 'A' + 'a';
      else
	 *dest = ch;
   }

   dest = NULL;

}  /* end of ToLower */




/*******************************************************************
 NAME:		CvtStringToOrient.		
 DESCRIPTION:
   This function converts resource settings in string form to the
XcROrient representation type.

*******************************************************************/

void CvtStringToOrient(args, num_args, fromVal, toVal)
XrmValuePtr args;		/* unused */
Cardinal *num_args;		/* unused */
XrmValuePtr fromVal;
XrmValuePtr toVal;
{
/* Local variables */
static XcOrient orient;
char lowerstring[100];


/* Convert the resource string to lower case for quick comparison */
   ToLower((char *)fromVal->addr, lowerstring);


/*
 * Compare resource string with valid XcOrient strings and assign to
 * datatype.
 */
   if (strcmp(lowerstring, XcEvert) == 0) 
   {
      orient = XcVert;
      CvtDone(XcOrient, &orient);
   }
   else if (strcmp(lowerstring, XcEhoriz) == 0) 
   {
      orient = XcHoriz;
      CvtDone(XcOrient, &orient);
   }

/*
 * If the string is not valid for this resource type, print a warning
 * and do not make the conversion.
 */
   XtStringConversionWarning(fromVal->addr, "XcOrient");
   toVal->addr = NULL;
   toVal->size = 0;

}  /* end of CvtStringToOrient */



/*******************************************************************
 NAME:		Arrow3d.
 DESCRIPTION:
   This function generates a filled arrow polygon with a 3D effect in
the given drawable.  It uses the widget's background color and the
derived shades (calculated in Control's Initialize method) to produce the
3D effect.  

*******************************************************************/

void Arrow3d(w, display, drawable, gc, bounds, orientation, type)
ControlWidget w;
Display *display;
Drawable drawable;
GC gc;
XRectangle *bounds;
ArrowType orientation;
Type3d type;
{
/* Local variables */
int i, j, adjustment = w->control.shade_depth+1;
XPoint points[4];
unsigned long shade1, shade2;

/* Set basic line attributes used in drawing the 3D arrow. */
#ifdef NICE_SHADES
   shade1 = w->control.shade1.pixel;
   shade2 = w->control.shade2.pixel;
#else
   shade1 = WhitePixel(display, DefaultScreen(display));
   shade2 = BlackPixel(display, DefaultScreen(display));
   XSetLineAttributes(display, gc, 0, LineOnOffDash, CapButt, JoinRound);
#endif

/* This macro is used to determine the shading color to use. */
#define SET_SHADE( sh1, sh2 ) \
 if (type == RAISED) XSetForeground(display, gc, sh1); \
 else XSetForeground(display, gc, sh2); \


/*
 * Calculate the arrow vertices based on the bounding rectangle and
 * orientation.
 */
   if (orientation == UP)
   {
   /* left corner */
      points[0].x = bounds->x;
      points[0].y = bounds->y + bounds->height;
   /* arrow tip */
      points[1].x = points[0].x + (bounds->width / 2 + 0.5);
      points[1].y = bounds->y;
   /* right corner */
      points[2].x = points[0].x + bounds->width;
      points[2].y = points[0].y;
   }
   else if (orientation == DOWN)
   {
   /* left corner */
      points[0].x = bounds->x;  
      points[0].y = bounds->y;  
   /* arrow tip */
      points[1].x = points[0].x + (bounds->width / 2 + 0.5); 
      points[1].y = bounds->y + bounds->height; 
   /* right corner */
      points[2].x = points[0].x + bounds->width;
      points[2].y = points[0].y;
   }
   else if (orientation == LEFT)
   {
   /* left corner */
      points[0].x = bounds->x + bounds->width;  
      points[0].y = bounds->y + bounds->height;  
   /* arrow tip */
      points[1].x = bounds->x;
      points[1].y = bounds->y + (bounds->height / 2 + 0.5);  
   /* right corner */
      points[2].x = points[0].x; 
      points[2].y = bounds->y;
   }
   else if (orientation == RIGHT)
   {
   /* left corner */
      points[0].x = bounds->x;
      points[0].y = bounds->y;
   /* arrow tip */
      points[1].x = bounds->x + bounds->width;
      points[1].y = bounds->y + (bounds->height / 2 + 0.5);  
   /* right corner */
      points[2].x = points[0].x; 
      points[2].y = bounds->y + bounds->height;
   }

/* left corner */
   points[3].x = points[0].x;
   points[3].y = points[0].y;


/* Draw the shadow lines */
   for (j = 0; j < w->control.shade_depth; j++)
   {
      if (orientation == UP)
      {
	 SET_SHADE(shade1, shade2);
	 XDrawLine(display, drawable, gc, points[0].x+j, points[0].y-j, 
				points[1].x, points[1].y+j);
	 XDrawLine(display, drawable, gc, points[1].x, points[1].y+j, 
				points[2].x-j, points[2].y-j);
	 SET_SHADE(shade2, shade1);
	 XDrawLine(display, drawable, gc, points[2].x-j, points[2].y-j, 
				points[3].x+j, points[3].y-j);
      }
      else if (orientation == DOWN)
      {
	 SET_SHADE(shade2, shade1);
	 XDrawLine(display, drawable, gc, points[0].x+j, points[0].y+j, 
				points[1].x, points[1].y-j);
	 XDrawLine(display, drawable, gc, points[1].x, points[1].y-j, 
				points[2].x-j, points[2].y+j);
	 SET_SHADE(shade1, shade2);
	 XDrawLine(display, drawable, gc, points[2].x-j, points[3].y+j, 
				points[3].x+j, points[3].y+j);
      }
      else if (orientation == LEFT)
      {
	 SET_SHADE(shade2, shade1);
	 XDrawLine(display, drawable, gc, points[0].x-j, points[0].y-j, 
				points[1].x+j, points[1].y);
	 SET_SHADE(shade1, shade2);
	 XDrawLine(display, drawable, gc, points[1].x+j, points[1].y, 
				points[2].x-j, points[2].y+j);
	 SET_SHADE(shade2, shade1);
	 XDrawLine(display, drawable, gc, points[2].x-j, points[2].y+j, 
				points[3].x-j, points[3].y-j);
      }
      else if (orientation == RIGHT)
      {
	 SET_SHADE(shade1, shade2);
	 XDrawLine(display, drawable, gc, points[0].x+j, points[0].y+j, 
				points[1].x-j, points[1].y);
	 SET_SHADE(shade2, shade1);
	 XDrawLine(display, drawable, gc, points[1].x-j, points[1].y, 
				points[2].x+j, points[2].y-j);
	 SET_SHADE(shade1, shade2);
	 XDrawLine(display, drawable, gc, points[2].x+j, points[2].y-j, 
				points[3].x+j, points[3].y+j);
      }
   }

   XSetLineAttributes(display, gc, 0, LineSolid, CapButt, JoinRound);
   XSetFillStyle(display, gc, FillSolid);

}  /* end of Arrow3d */


/* end of Control.c */

et basic line attributes used in drawing the 3D arrow. */
#ifdef NICE_SHADES
   shade1 = w->control.shade1.pixel;
   shade2 = w->control.shade2.pixel;
#else
   shade1 = WhitePixel(display, DefaultScreen(display));
   shade2 = BlackPixel(display, DefaultScreen(display));
   XSetLineAttributes(display, gc, 0, LineOnOffDash, CapButt, JoinRound);
#endif

/* This macro is used to determine the shading color to use. */
#define SET_SHADE( sh1, sh2 xscrabble/Xc/Control.h100700 000310 000001 00000003112 06047125547 016073 0ustar00mchapmanstaff000000 000000 /*******************************************************************
 FILE:		Control.h
 CONTENTS:	Public header file for the Control widget class.
 AUTHOR:	Paul D. Johnston
 HISTORY:
 Date		Action
 ---------	------------------------------------
 5/23/92	Changed the widget class name so that it is preceded
		by 'xc' with the first major word capitalized.
 3/11/92	Created.

********************************************************************/

#ifndef CONTROL_H
#define CONTROL_H


/* Debug printf statements for Control Panel widget development. */
#ifdef XCDEBUG 
#define DPRINTF(statement)  printf statement  
#else
#define DPRINTF(statement)  
#endif 


/*
 * This macro is used by the resource string conversion routines to 
 * assign the converted type elements to the XrmValue struct.
 */
#define CvtDone(type, address) \
{ toVal->size = sizeof(type); \
  toVal->addr = (caddr_t)address; \
  return; } 


/*
 * This enumeration defines the possible 3D rectangle types, used in the
 * call to Rect3d().
 */
typedef enum rect3d_t
{
   RAISED,
   DEPRESSED
} Type3d;

/* Type used to indicate the Arrow direction (i.e., up, down, etc.) */
typedef enum
{
   UP,
   DOWN,
   LEFT,
   RIGHT
} ArrowType;


/* Class record declarations */

extern WidgetClass xcControlWidgetClass;

typedef struct _ControlClassRec *ControlWidgetClass;
typedef struct _ControlRec *ControlWidget;


/* Declaration of widget class functions */
extern Boolean Point_In_Rect();
extern void Rect3d();
extern void VarRect3d();
extern void Arrow3d();
extern void ToLower();
extern void CvtStringToOrient();


#endif /* CONTROL_H */

points[2].x-j, points[2].y-j, 
				points[3].x+j, points[3].y-j);
      }
      else if (orientation == DOWN)
      {
	 SET_SHADE(shade2, shade1);
	 XDrawLine(display, drawable, gc, points[0].x+j, points[0].y+j, 
				points[1].x, points[1].y-j);
	 XDrawLine(display, drawable, gc, points[1].x, points[1].y-j, 
				points[2].x-j, points[2].y+j);
	 SET_SHADE(shade1, shade2);
	 XDrawLine(display, drawable, gc, points[2].x-j, points[3].y+j,xscrabble/Xc/ControlP.h100600 000310 000001 00000003652 06047125547 016223 0ustar00mchapmanstaff000000 000000 /*******************************************************************
 FILE:		ControlP.h
 CONTENTS:	Private definitions for the Control widget class.
 AUTHOR:	Paul D. Johnston
 HISTORY:
 Date		Action
 ---------	------------------------------------
 3/11/92	Created.

********************************************************************/

#ifndef CONTROLP_H
#define CONTROLP_H

/*
 * Include the superclass private header.
 */
#include <X11/CoreP.h>

/*
 * Include the widget set header. 
 */
#include <X11/Xc/Xc.h>

/*
 * Include this widget class public header.
 */
#include <X11/Xc/Control.h>

/* Private declarations and definitions. */
#define MAX_LABEL		20


/*
 * Class part.
 */
typedef struct 
{
   int dummy;	/* Minimum of one member required. */
} ControlClassPart;

/*
 * Class record.
 */
typedef struct _ControlClassRec
{
   CoreClassPart core_class;
   ControlClassPart control_class;
} ControlClassRec;

/*
 * Declare the widget class record as external for use in the widget source
 * file.
 */
extern ControlClassRec controlClassRec;



/*
 * Instance part.
 */
typedef struct
{
   /* Public instance variables. */
   Pixel background_pixel;		/* Widget's background color (used
					 * in producing 3D effect).
					 */
   Pixel label_pixel;			/* Widget's Label color. */
   char *label;				/* Widget's Label string. */
   XFontStruct *font;			/* Font for Label string. */
   int shade_depth;			/* Depth of the 3D effect in pixels. */

   /* Private instance variables. */
   Pixmap shade;			/* Stipple bitmap for generating 
					 * 3D shading effect.
					 */
   XColor shade1, shade2;		/* Colors derived from background
					 * used with the -DNICE_SHADES compiler
					 * option for 3D shading of widget.
					 */
   GC gc;				/* GC used for drawing in this 
					 * widget.
					 */

} ControlPart;

/*
 * Instance record.
 */
typedef struct _ControlRec
{
   CorePart core;
   ControlPart control;
} ControlRec;



#endif  /* CONTROLP_H */

ints[2].y+j, 
				points[3].x-j, points[3].y-j);
      }
      else if (orientation ==xscrabble/Xc/Value.c100600 000310 000001 00000044226 06047125556 015534 0ustar00mchapmanstaff000000 000000 /*******************************************************************
 FILE:		Value.c
 CONTENTS:	Definitions for structures, methods, and actions of the 
		Value widget.
 AUTHOR:	Paul D. Johnston
 HISTORY:
 Date		Action
 ---------	------------------------------------
 5/23/92	Changed the widget class name so that it is preceded
		by 'xc' with the first major word capitalized.
 10/22/91	Created.

********************************************************************/

#include <stdio.h>

/* Xlib includes */
#include <X11/Xlib.h>

/* Xt includes */
#include <X11/StringDefs.h>
#include <X11/IntrinsicP.h>

/* Xc includes */
#include <X11/Xc/Xc.h>
#include <X11/Xc/Control.h>

/* Widget includes */
#include <X11/Xc/ValueP.h>	/* (includes Value.h also) */


/* Macro redefinition for offset. */
#define offset(field) XtOffset(ValueWidget, field)


/* Declare widget methods */
static void ClassInitialize();
static void Initialize();
static Boolean SetValues();

/* Declare widget class functions */
static void CvtStringToDType();
static void CvtStringToVType();
static void CvtStringToValueJustify();



/* Define the widget's resource list */
static XtResource resources[] =
{
  {
    XcNvalueForeground,
    XtCColor,
    XtRPixel,
    sizeof(Pixel),
    offset(value.value_fg_pixel),
    XtRString,
    XtDefaultForeground
  },
  {
    XcNvalueBackground,
    XtCColor,
    XtRPixel,
    sizeof(Pixel),
    offset(value.value_bg_pixel),
    XtRString,
    "white"
  },
  {
    XcNvalueCallback,
    XtCCallback,
    XtRCallback,
    sizeof(caddr_t),
    offset(value.callback),
    XtRCallback,
    NULL
  },
  {
    XcNdataType,
    XcCDataType,
    XcRDType,
    sizeof(XcDType),
    offset(value.datatype),
    XtRString,
    "lval"
  },
  {
    XcNdecimals,
    XcCDecimals,
    XtRInt,
    sizeof(int),
    offset(value.decimals),
    XtRImmediate,
    (caddr_t)2
  },
  {
    XcNincrement,
    XcCIncrement,
    XcRVType,
    sizeof(XcVType),
    offset(value.increment),
    XtRString,
    "1"
  },
  {
    XcNupperBound,
    XcCUpperBound,
    XcRVType,
    sizeof(XcVType),
    offset(value.upper_bound),
    XtRString,
    "100"
  },
  {
    XcNlowerBound,
    XcCLowerBound,
    XcRVType,
    sizeof(XcVType),
    offset(value.lower_bound),
    XtRString,
    "0"
  },
  {
    XcNvalueJustify,
    XcCValueJustify,
    XcRValueJustify,
    sizeof(XcValueJustify),
    offset(value.justify),
    XtRString,
    "justifycenter"
  },
  {
    XcNvalue,
    XcCValue,
    XcRVType,
    sizeof(XcVType),
    offset(value.val),
    XtRString,
    "0"
  },
};



/* Widget Class Record initialization */
ValueClassRec valueClassRec =
{
  {
  /* core_class part */
    (WidgetClass) &controlClassRec,		/* superclass */
    "Value",					/* class_name */
    sizeof(ValueRec),				/* widget_size */
    ClassInitialize,				/* class_initialize */
    NULL,					/* class_part_initialize */
    FALSE,					/* class_inited */
    Initialize,					/* initialize */
    NULL,					/* initialize_hook */
    XtInheritRealize,				/* realize */
    NULL,					/* actions */
    0,						/* num_actions */
    resources,					/* resources */
    XtNumber(resources),			/* num_resources */
    NULLQUARK,					/* xrm_class */
    TRUE,					/* compress_motion */
    TRUE,					/* compress_exposure */
    TRUE,					/* compress_enterleave */
    TRUE,					/* visible_interest */
    NULL,					/* destroy */
    NULL,					/* resize */
    NULL,					/* expose */
    SetValues,					/* set_values */
    NULL,					/* set_values_hook */
    XtInheritSetValuesAlmost,			/* set_values_almost */
    NULL,					/* get_values_hook */
    NULL,					/* accept_focus */
    XtVersion,					/* version */
    NULL,					/* callback_private */
    NULL,					/* tm_table */
    NULL,					/* query_geometry */
    NULL,					/* display_accelerator */
    NULL,					/* extension */
  },
  {
  /* Control class part */
    0,						/* dummy_field */
  },
  {
  /* Value class part */
    0,						/* dummy_field */
  },
};

WidgetClass xcValueWidgetClass = (WidgetClass)&valueClassRec;


/* Widget method function definitions */

/*******************************************************************
 NAME:		ClassInitialize.	
 DESCRIPTION:
   This method initializes the Value widget class. Specifically,
it registers resource value converter functions with Xt.

*******************************************************************/

static void ClassInitialize()
{

   XtAddConverter(XtRString, XcRDType, CvtStringToDType, NULL, 0);
   XtAddConverter(XtRString, XcRVType, CvtStringToVType, NULL, 0);
   XtAddConverter(XtRString, XcRValueJustify, CvtStringToValueJustify, NULL,0);

}  /* end of ClassInitialize */




/*******************************************************************
 NAME:		Initialize.		
 DESCRIPTION:
   This is the initialize method for the Value widget.  It 
validates user-modifiable instance resources and initializes private 
widget variables and structures.  

*******************************************************************/

static void Initialize(request, new)
ValueWidget request, new;
{

DPRINTF(("Value: executing Initialize \n"));
/*
 * Validate public instance variable settings.
 */
   if ((new->value.datatype != XcLval) &&
       (new->value.datatype != XcHval) &&
       (new->value.datatype != XcFval))
   {
      XtWarning("Value: invalid datatype setting.");
      new->value.datatype = XcLval;
   }

/* Check decimals setting */
   if ((new->value.datatype == XcFval) && 
        ((new->value.decimals < MIN_DECIMALS) ||
         (new->value.decimals > MAX_DECIMALS)))
   {
      XtWarning("Value: invalid decimals setting.");
      new->value.decimals = 2;
   }

/* Check increment setting */
   if (((new->value.datatype == XcLval) || (new->value.datatype == XcHval))
				&& (new->value.increment.lval <= 0))
   {
      XtWarning("Value: invalid increment setting.");
      new->value.increment.lval = 1L;
   } 
   else if ((new->value.datatype == XcFval) &&  
			(new->value.increment.fval <= 0.0)) 
   {
      XtWarning("Value: invalid increment setting.");
      new->value.increment.fval = 1.0;
   } 

/* Check lower/upper bound setting */
   if (((new->value.datatype == XcLval) || 
       (new->value.datatype == XcHval)) && 
	(new->value.lower_bound.lval >= 
		new->value.upper_bound.lval)) 
   {
      XtWarning("Value: invalid lowerBound/upperBound setting.");
      new->value.lower_bound.lval = 
	(new->value.upper_bound.lval - new->value.increment.lval);
   } 
   else if ((new->value.datatype == XcFval) && 
	(new->value.lower_bound.fval >= 
		new->value.upper_bound.fval)) 
   {
      XtWarning("Value: invalid lowerBound/upperBound setting.");
      new->value.lower_bound.fval = 
	(new->value.upper_bound.fval - new->value.increment.fval);
   } 


/* Check the initial value setting */
   if ((new->value.datatype == XcLval)  || (new->value.datatype == XcHval))
   {
      if (new->value.val.lval < new->value.lower_bound.lval)
         new->value.val.lval = new->value.lower_bound.lval;
      else if (new->value.val.lval > new->value.upper_bound.lval)
         new->value.val.lval = new->value.upper_bound.lval; 
   }
   else if (new->value.datatype == XcFval) 
   {
      if (new->value.val.fval < new->value.lower_bound.fval)
         new->value.val.fval = new->value.lower_bound.fval;
      else if (new->value.val.fval > new->value.upper_bound.fval)
         new->value.val.fval = new->value.upper_bound.fval; 
   }

/* Check the initial valueJustify setting. */
   if ((new->value.justify != XcJustifyLeft) &&
          (new->value.justify != XcJustifyRight) &&
          (new->value.justify != XcJustifyCenter))
   {
      XtWarning("Value: invalid valueJustify setting.");
      new->value.justify = XcJustifyCenter;
   }

DPRINTF(("Value: done Initialize \n"));

}  /* end of Initialize */





/*******************************************************************
 NAME:		SetValues.
 DESCRIPTION:
   This is the set_values method for this widget. It validates resource
settings set with XtSetValues. If a resource is changed that would
require re-drawing the widget, return True.

*******************************************************************/

static Boolean SetValues(cur, req, new)
ValueWidget cur, req, new;
{
/* Local variables */
Boolean do_redisplay = False;


DPRINTF(("Value: executing SetValues \n"));

/* Validate new resource settings. */

/* Check the widget's color resources. */
   if ((new->value.value_fg_pixel != cur->value.value_fg_pixel) ||
       (new->value.value_fg_pixel != cur->value.value_fg_pixel)) 
      do_redisplay = True;

/* Check the datatype */
   if (new->value.datatype != cur->value.datatype)
   {
      do_redisplay = True;
      if ((new->value.datatype != XcLval) &&
          (new->value.datatype != XcHval) &&
          (new->value.datatype != XcFval))
      {
         XtWarning("Value: invalid datatype setting.");
         new->value.datatype = XcLval;
      }
   }
   
/* Check the decimals setting */
   if (new->value.decimals != cur->value.decimals);
   {
      do_redisplay = True;
      if ((new->value.decimals < MIN_DECIMALS) || 
		(new->value.decimals > MAX_DECIMALS))
      {
	 XtWarning("Value: invalid decimals setting.");
	 new->value.decimals = 2;
      }
   }

/* Check the increment setting */
   if (((new->value.datatype == XcLval) || (new->value.datatype == XcHval))
				&& (new->value.increment.lval <= 0))
   {
      XtWarning("Value: invalid increment setting.");
      new->value.increment.lval = 1L;
   } 
   else if ((new->value.datatype == XcFval) &&  
			(new->value.increment.fval <= 0.0)) 
   {
      XtWarning("Value: invalid increment setting.");
      new->value.increment.fval = 1.0;
   } 

/* Check the lowerBound/upperBound setting */
   if (((new->value.datatype == XcLval) || 
       (new->value.datatype == XcHval)) && 
	(new->value.lower_bound.lval >= 
		new->value.upper_bound.lval)) 
   {
      XtWarning("Value: invalid lowerBound/upperBound setting.");
      new->value.lower_bound.lval = 
	(new->value.upper_bound.lval - new->value.increment.lval);
   }
   else if ((new->value.datatype == XcFval) && 
	(new->value.lower_bound.fval >= 
		new->value.upper_bound.fval)) 
   {
      XtWarning("Value: invalid lowerBound/upperBound setting.");
      new->value.lower_bound.fval = 
	(new->value.upper_bound.fval - new->value.increment.fval);
   }


/* Check the new value setting */
   if (((new->value.datatype == XcLval) || (new->value.datatype == XcHval)) && 
		(new->value.val.lval != cur->value.val.lval))
   {
      do_redisplay = True;
      if (new->value.val.lval < new->value.lower_bound.lval)
         new->value.val.lval = new->value.lower_bound.lval;
      else if (new->value.val.lval > new->value.upper_bound.lval)
         new->value.val.lval = new->value.upper_bound.lval; 
   }
   if ((new->value.datatype == XcFval)  &&
		(new->value.val.fval != cur->value.val.fval))
   {
      do_redisplay = True;
      if (new->value.val.fval < new->value.lower_bound.fval)
         new->value.val.fval = new->value.lower_bound.fval;
      else if (new->value.val.fval > new->value.upper_bound.fval)
         new->value.val.fval = new->value.upper_bound.fval; 
   }

/* Check the valueJustify setting. */
   if (new->value.justify != cur->value.justify)
   {
      do_redisplay = True;
      if ((new->value.justify != XcJustifyLeft) &&
          (new->value.justify != XcJustifyRight) &&
          (new->value.justify != XcJustifyCenter))
      {
         XtWarning("Value: invalid valueJustify setting.");
         new->value.justify = XcJustifyCenter;
      }
   }
   

DPRINTF(("Value: done SetValues\n"));

   return do_redisplay;


}  /* end of SetValues */




/* Widget class functions */

/*******************************************************************
 NAME:		CvtStringToDType.		
 DESCRIPTION:
   This function converts resource settings in string form to the
XtRDType representation type.

*******************************************************************/

static void CvtStringToDType(args, num_args, fromVal, toVal)
XrmValuePtr args;		/* unused */
Cardinal *num_args;		/* unused */
XrmValuePtr fromVal;
XrmValuePtr toVal;
{
/* Local variables */
static XcDType datatype;
char lowerstring[100];


/* Convert the resource string to lower case for quick comparison */
   ToLower((char *)fromVal->addr, lowerstring);


/*
 * Compare resource string with valid datatype strings and assign to
 * datatype.
 */
   if (strcmp(lowerstring, XcElval) == 0) 
   {
      datatype = XcLval;
      CvtDone(XcDType, &datatype);
   }
   else if (strcmp(lowerstring, XcEhval) == 0) 
   {
      datatype = XcHval;
      CvtDone(XcDType, &datatype);
   }
   else if (strcmp(lowerstring, XcEfval) == 0) 
   {
      datatype = XcFval;
      CvtDone(XcDType, &datatype);
   }

/*
 * If the string is not valid for this resource type, print a warning
 * and do not make the conversion.
 */
   XtStringConversionWarning(fromVal->addr, "XcDType");
   toVal->addr = NULL;
   toVal->size = 0;

}  /* end of CvtStringToDType */




/*******************************************************************
 NAME:		CvtStringToVType.		
 DESCRIPTION:
   This function converts resource settings in string form to the
XtRVType representation type.

*******************************************************************/

static void CvtStringToVType(args, num_args, fromVal, toVal)
XrmValuePtr args;		/* unused */
Cardinal *num_args;		/* unused */
XrmValuePtr fromVal;
XrmValuePtr toVal;
{
/* Local variables */
long num;
static XcVType value;
char temp[30], temp2[30];

/*
 * Make sure the string is a numeric constant. If it isn't, print
 * a warning, and NULL the destination value.
 */
   if ((num = sscanf((char *)fromVal->addr, 
			"%[-012345689ABCDEFabcdef.]", temp)) == 0)
   {
      XtStringConversionWarning(fromVal->addr, "XcVType");
      CvtDone(char, NULL);
   }

/* If the number contains a decimal point, convert it into a float. */
   if (strchr(temp, '.') != NULL)
   {
      sscanf(temp, "%f", &value.fval); 
      CvtDone(XcVType, &value.fval);
   }

/* If it contains any hexadecimal characters, convert it to a long hex int */
   if (sscanf(temp, "%[ABCDEFabcdef]", temp2) != 0)
   {
      sscanf(temp, "%lX", &value.lval); 
      CvtDone(XcVType, &value.lval);
   }


/* Otherwise, it's an integer type. Convert the string to a numeric constant. */
   sscanf(temp, "%ld", &value.lval); 
   CvtDone(XcVType, &value.lval);
 
}  /* end of CvtStringToVType */




/*******************************************************************
 NAME:		CvtStringToValueJustify.		
 DESCRIPTION:
   This function converts resource settings in string form to the
XcRValueJustify representation type.

*******************************************************************/

static void CvtStringToValueJustify(args, num_args, fromVal, toVal)
XrmValuePtr args;		/* unused */
Cardinal *num_args;		/* unused */
XrmValuePtr fromVal;
XrmValuePtr toVal;
{
/* Local variables */
static XcValueJustify val_justify;
char lowerstring[100];

/* Convert the resource string to lower case for quick comparison */
   ToLower((char *)fromVal->addr, lowerstring);

/*
 * Compare resource string with valid XcValueJustify strings and assign to
 * datatype.
 */
   if (strcmp(lowerstring, XcEjustifyLeft) == 0) 
   {
      val_justify = XcJustifyLeft;
      CvtDone(XcValueJustify, &val_justify);
   }
   else if (strcmp(lowerstring, XcEjustifyRight) == 0) 
   {
      val_justify = XcJustifyRight;
      CvtDone(XcValueJustify, &val_justify);
   }
   else if (strcmp(lowerstring, XcEjustifyCenter) == 0) 
   {
      val_justify = XcJustifyCenter;
      CvtDone(XcValueJustify, &val_justify);
   }

/*
 * If the string is not valid for this resource type, print a warning
 * and do not make the conversion.
 */
   XtStringConversionWarning(fromVal->addr, XcRValueJustify);
   toVal->addr = NULL;
   toVal->size = 0;

}  /* end of CvtStringToValueJustify */




/*******************************************************************
 NAME:		Correlate.		
 DESCRIPTION:
   This function takes the given value between the given range and
correlates it to the destination range, returning the correlated value.

*******************************************************************/

float Correlate(from_val, from_range, to_range)
float from_val, from_range, to_range;
{
/* Local variables */
float percent, result;

   percent = ((from_val * 100.0) / from_range);

   result = (to_range * (percent / 100));

   return result;

}  /* end of Correlate */



/*********************************************************************
 FUNCTION:	Print_value.
 DESCRIPTION:
  Simply converts a widget's value into a string based on the value's
datatype and returns a pointer to it.

*********************************************************************/

char *Print_value(datatype, value, decimals)
XcDType datatype;
XcVType *value;
int decimals;
{
static char string[40];

   if (datatype == XcLval)
      sprintf(string, "%ld", value->lval);
   else if (datatype == XcHval)
      sprintf(string, "%lX", value->lval);
   else if (datatype == XcFval)
      sprintf(string, "%.*f", decimals, value->fval);

   return &string[0];

}  /* end of Print_value */




/*********************************************************************
 FUNCTION:	Position_val.
 DESCRIPTION:
  This function positions the displayed value within the Value Box based
on the XcNvalueJustify resource setting.

*********************************************************************/

void Position_val(w)
ValueWidget w;
{
/* Local variables */
char *val_string;
int text_width;

/* Establish the position of the value string within the Value Box. */
   val_string = Print_value(w->value.datatype, &w->value.val, 
							w->value.decimals);
   text_width = XTextWidth(w->control.font, val_string, strlen(val_string)); 

   if (w->value.justify == XcJustifyLeft)
      w->value.vp.x = w->value.value_box.x +
			(w->control.font->max_bounds.rbearing / 2 + 0.5);
   else if (w->value.justify == XcJustifyRight)
      w->value.vp.x = w->value.value_box.x +
      		w->value.value_box.width - text_width -
			(w->control.font->max_bounds.rbearing / 2 + 0.5);
   else if (w->value.justify == XcJustifyCenter)
      w->value.vp.x = w->value.value_box.x +
                (w->value.value_box.width / 2 + 0.5) -
                            (text_width / 2 + 0.5); 

   w->value.vp.y = w->value.value_box.y + 
		(w->value.value_box.height / 2 + 0.5) + 
				w->control.font->descent;

}  /* end of Position_val */


/* end of Value.c */

ype */




/*******************************************************************
 NAME:		CvtStringToValueJustify.		
 DESCRIPTION:
   This function converts resource settings in string form to the
XcRValueJustify representation type.

*******************************************************************/

static void CvtStringToValueJustify(args, num_args, fromValxscrabble/Xc/Value.c.orig100600 000310 000001 00000044226 06047125556 016473 0ustar00mchapmanstaff000000 000000 /*******************************************************************
 FILE:		Value.c
 CONTENTS:	Definitions for structures, methods, and actions of the 
		Value widget.
 AUTHOR:	Paul D. Johnston
 HISTORY:
 Date		Action
 ---------	------------------------------------
 5/23/92	Changed the widget class name so that it is preceded
		by 'xc' with the first major word capitalized.
 10/22/91	Created.

********************************************************************/

#include <stdio.h>

/* Xlib includes */
#include <X11/Xlib.h>

/* Xt includes */
#include <X11/StringDefs.h>
#include <X11/IntrinsicP.h>

/* Xc includes */
#include <X11/Xc/Xc.h>
#include <X11/Xc/Control.h>

/* Widget includes */
#include <X11/Xc/ValueP.h>	/* (includes Value.h also) */


/* Macro redefinition for offset. */
#define offset(field) XtOffset(ValueWidget, field)


/* Declare widget methods */
static void ClassInitialize();
static void Initialize();
static Boolean SetValues();

/* Declare widget class functions */
static void CvtStringToDType();
static void CvtStringToVType();
static void CvtStringToValueJustify();



/* Define the widget's resource list */
static XtResource resources[] =
{
  {
    XcNvalueForeground,
    XtCColor,
    XtRPixel,
    sizeof(Pixel),
    offset(value.value_fg_pixel),
    XtRString,
    XtDefaultForeground
  },
  {
    XcNvalueBackground,
    XtCColor,
    XtRPixel,
    sizeof(Pixel),
    offset(value.value_bg_pixel),
    XtRString,
    "white"
  },
  {
    XcNvalueCallback,
    XtCCallback,
    XtRCallback,
    sizeof(caddr_t),
    offset(value.callback),
    XtRCallback,
    NULL
  },
  {
    XcNdataType,
    XcCDataType,
    XcRDType,
    sizeof(XcDType),
    offset(value.datatype),
    XtRString,
    "lval"
  },
  {
    XcNdecimals,
    XcCDecimals,
    XtRInt,
    sizeof(int),
    offset(value.decimals),
    XtRImmediate,
    (caddr_t)2
  },
  {
    XcNincrement,
    XcCIncrement,
    XcRVType,
    sizeof(XcVType),
    offset(value.increment),
    XtRString,
    "1"
  },
  {
    XcNupperBound,
    XcCUpperBound,
    XcRVType,
    sizeof(XcVType),
    offset(value.upper_bound),
    XtRString,
    "100"
  },
  {
    XcNlowerBound,
    XcCLowerBound,
    XcRVType,
    sizeof(XcVType),
    offset(value.lower_bound),
    XtRString,
    "0"
  },
  {
    XcNvalueJustify,
    XcCValueJustify,
    XcRValueJustify,
    sizeof(XcValueJustify),
    offset(value.justify),
    XtRString,
    "justifycenter"
  },
  {
    XcNvalue,
    XcCValue,
    XcRVType,
    sizeof(XcVType),
    offset(value.val),
    XtRString,
    "0"
  },
};



/* Widget Class Record initialization */
ValueClassRec valueClassRec =
{
  {
  /* core_class part */
    (WidgetClass) &controlClassRec,		/* superclass */
    "Value",					/* class_name */
    sizeof(ValueRec),				/* widget_size */
    ClassInitialize,				/* class_initialize */
    NULL,					/* class_part_initialize */
    FALSE,					/* class_inited */
    Initialize,					/* initialize */
    NULL,					/* initialize_hook */
    XtInheritRealize,				/* realize */
    NULL,					/* actions */
    0,						/* num_actions */
    resources,					/* resources */
    XtNumber(resources),			/* num_resources */
    NULLQUARK,					/* xrm_class */
    TRUE,					/* compress_motion */
    TRUE,					/* compress_exposure */
    TRUE,					/* compress_enterleave */
    TRUE,					/* visible_interest */
    NULL,					/* destroy */
    NULL,					/* resize */
    NULL,					/* expose */
    SetValues,					/* set_values */
    NULL,					/* set_values_hook */
    XtInheritSetValuesAlmost,			/* set_values_almost */
    NULL,					/* get_values_hook */
    NULL,					/* accept_focus */
    XtVersion,					/* version */
    NULL,					/* callback_private */
    NULL,					/* tm_table */
    NULL,					/* query_geometry */
    NULL,					/* display_accelerator */
    NULL,					/* extension */
  },
  {
  /* Control class part */
    0,						/* dummy_field */
  },
  {
  /* Value class part */
    0,						/* dummy_field */
  },
};

WidgetClass xcValueWidgetClass = (WidgetClass)&valueClassRec;


/* Widget method function definitions */

/*******************************************************************
 NAME:		ClassInitialize.	
 DESCRIPTION:
   This method initializes the Value widget class. Specifically,
it registers resource value converter functions with Xt.

*******************************************************************/

static void ClassInitialize()
{

   XtAddConverter(XtRString, XcRDType, CvtStringToDType, NULL, 0);
   XtAddConverter(XtRString, XcRVType, CvtStringToVType, NULL, 0);
   XtAddConverter(XtRString, XcRValueJustify, CvtStringToValueJustify, NULL,0);

}  /* end of ClassInitialize */




/*******************************************************************
 NAME:		Initialize.		
 DESCRIPTION:
   This is the initialize method for the Value widget.  It 
validates user-modifiable instance resources and initializes private 
widget variables and structures.  

*******************************************************************/

static void Initialize(request, new)
ValueWidget request, new;
{

DPRINTF(("Value: executing Initialize \n"));
/*
 * Validate public instance variable settings.
 */
   if ((new->value.datatype != XcLval) &&
       (new->value.datatype != XcHval) &&
       (new->value.datatype != XcFval))
   {
      XtWarning("Value: invalid datatype setting.");
      new->value.datatype = XcLval;
   }

/* Check decimals setting */
   if ((new->value.datatype == XcFval) && 
        ((new->value.decimals < MIN_DECIMALS) ||
         (new->value.decimals > MAX_DECIMALS)))
   {
      XtWarning("Value: invalid decimals setting.");
      new->value.decimals = 2;
   }

/* Check increment setting */
   if (((new->value.datatype == XcLval) || (new->value.datatype == XcHval))
				&& (new->value.increment.lval <= 0))
   {
      XtWarning("Value: invalid increment setting.");
      new->value.increment.lval = 1L;
   } 
   else if ((new->value.datatype == XcFval) &&  
			(new->value.increment.fval <= 0.0)) 
   {
      XtWarning("Value: invalid increment setting.");
      new->value.increment.fval = 1.0;
   } 

/* Check lower/upper bound setting */
   if (((new->value.datatype == XcLval) || 
       (new->value.datatype == XcHval)) && 
	(new->value.lower_bound.lval >= 
		new->value.upper_bound.lval)) 
   {
      XtWarning("Value: invalid lowerBound/upperBound setting.");
      new->value.lower_bound.lval = 
	(new->value.upper_bound.lval - new->value.increment.lval);
   } 
   else if ((new->value.datatype == XcFval) && 
	(new->value.lower_bound.fval >= 
		new->value.upper_bound.fval)) 
   {
      XtWarning("Value: invalid lowerBound/upperBound setting.");
      new->value.lower_bound.fval = 
	(new->value.upper_bound.fval - new->value.increment.fval);
   } 


/* Check the initial value setting */
   if ((new->value.datatype == XcLval)  || (new->value.datatype == XcHval))
   {
      if (new->value.val.lval < new->value.lower_bound.lval)
         new->value.val.lval = new->value.lower_bound.lval;
      else if (new->value.val.lval > new->value.upper_bound.lval)
         new->value.val.lval = new->value.upper_bound.lval; 
   }
   else if (new->value.datatype == XcFval) 
   {
      if (new->value.val.fval < new->value.lower_bound.fval)
         new->value.val.fval = new->value.lower_bound.fval;
      else if (new->value.val.fval > new->value.upper_bound.fval)
         new->value.val.fval = new->value.upper_bound.fval; 
   }

/* Check the initial valueJustify setting. */
   if ((new->value.justify != XcJustifyLeft) &&
          (new->value.justify != XcJustifyRight) &&
          (new->value.justify != XcJustifyCenter))
   {
      XtWarning("Value: invalid valueJustify setting.");
      new->value.justify = XcJustifyCenter;
   }

DPRINTF(("Value: done Initialize \n"));

}  /* end of Initialize */





/*******************************************************************
 NAME:		SetValues.
 DESCRIPTION:
   This is the set_values method for this widget. It validates resource
settings set with XtSetValues. If a resource is changed that would
require re-drawing the widget, return True.

*******************************************************************/

static Boolean SetValues(cur, req, new)
ValueWidget cur, req, new;
{
/* Local variables */
Boolean do_redisplay = False;


DPRINTF(("Value: executing SetValues \n"));

/* Validate new resource settings. */

/* Check the widget's color resources. */
   if ((new->value.value_fg_pixel != cur->value.value_fg_pixel) ||
       (new->value.value_fg_pixel != cur->value.value_fg_pixel)) 
      do_redisplay = True;

/* Check the datatype */
   if (new->value.datatype != cur->value.datatype)
   {
      do_redisplay = True;
      if ((new->value.datatype != XcLval) &&
          (new->value.datatype != XcHval) &&
          (new->value.datatype != XcFval))
      {
         XtWarning("Value: invalid datatype setting.");
         new->value.datatype = XcLval;
      }
   }
   
/* Check the decimals setting */
   if (new->value.decimals != cur->value.decimals);
   {
      do_redisplay = True;
      if ((new->value.decimals < MIN_DECIMALS) || 
		(new->value.decimals > MAX_DECIMALS))
      {
	 XtWarning("Value: invalid decimals setting.");
	 new->value.decimals = 2;
      }
   }

/* Check the increment setting */
   if (((new->value.datatype == XcLval) || (new->value.datatype == XcHval))
				&& (new->value.increment.lval <= 0))
   {
      XtWarning("Value: invalid increment setting.");
      new->value.increment.lval = 1L;
   } 
   else if ((new->value.datatype == XcFval) &&  
			(new->value.increment.fval <= 0.0)) 
   {
      XtWarning("Value: invalid increment setting.");
      new->value.increment.fval = 1.0;
   } 

/* Check the lowerBound/upperBound setting */
   if (((new->value.datatype == XcLval) || 
       (new->value.datatype == XcHval)) && 
	(new->value.lower_bound.lval >= 
		new->value.upper_bound.lval)) 
   {
      XtWarning("Value: invalid lowerBound/upperBound setting.");
      new->value.lower_bound.lval = 
	(new->value.upper_bound.lval - new->value.increment.lval);
   }
   else if ((new->value.datatype == XcFval) && 
	(new->value.lower_bound.fval >= 
		new->value.upper_bound.fval)) 
   {
      XtWarning("Value: invalid lowerBound/upperBound setting.");
      new->value.lower_bound.fval = 
	(new->value.upper_bound.fval - new->value.increment.fval);
   }


/* Check the new value setting */
   if (((new->value.datatype == XcLval) || (new->value.datatype == XcHval)) && 
		(new->value.val.lval != cur->value.val.lval))
   {
      do_redisplay = True;
      if (new->value.val.lval < new->value.lower_bound.lval)
         new->value.val.lval = new->value.lower_bound.lval;
      else if (new->value.val.lval > new->value.upper_bound.lval)
         new->value.val.lval = new->value.upper_bound.lval; 
   }
   if ((new->value.datatype == XcFval)  &&
		(new->value.val.fval != cur->value.val.fval))
   {
      do_redisplay = True;
      if (new->value.val.fval < new->value.lower_bound.fval)
         new->value.val.fval = new->value.lower_bound.fval;
      else if (new->value.val.fval > new->value.upper_bound.fval)
         new->value.val.fval = new->value.upper_bound.fval; 
   }

/* Check the valueJustify setting. */
   if (new->value.justify != cur->value.justify)
   {
      do_redisplay = True;
      if ((new->value.justify != XcJustifyLeft) &&
          (new->value.justify != XcJustifyRight) &&
          (new->value.justify != XcJustifyCenter))
      {
         XtWarning("Value: invalid valueJustify setting.");
         new->value.justify = XcJustifyCenter;
      }
   }
   

DPRINTF(("Value: done SetValues\n"));

   return do_redisplay;


}  /* end of SetValues */




/* Widget class functions */

/*******************************************************************
 NAME:		CvtStringToDType.		
 DESCRIPTION:
   This function converts resource settings in string form to the
XtRDType representation type.

*******************************************************************/

static void CvtStringToDType(args, num_args, fromVal, toVal)
XrmValuePtr args;		/* unused */
Cardinal *num_args;		/* unused */
XrmValuePtr fromVal;
XrmValuePtr toVal;
{
/* Local variables */
static XcDType datatype;
char lowerstring[100];


/* Convert the resource string to lower case for quick comparison */
   ToLower((char *)fromVal->addr, lowerstring);


/*
 * Compare resource string with valid datatype strings and assign to
 * datatype.
 */
   if (strcmp(lowerstring, XcElval) == 0) 
   {
      datatype = XcLval;
      CvtDone(XcDType, &datatype);
   }
   else if (strcmp(lowerstring, XcEhval) == 0) 
   {
      datatype = XcHval;
      CvtDone(XcDType, &datatype);
   }
   else if (strcmp(lowerstring, XcEfval) == 0) 
   {
      datatype = XcFval;
      CvtDone(XcDType, &datatype);
   }

/*
 * If the string is not valid for this resource type, print a warning
 * and do not make the conversion.
 */
   XtStringConversionWarning(fromVal->addr, "XcDType");
   toVal->addr = NULL;
   toVal->size = 0;

}  /* end of CvtStringToDType */




/*******************************************************************
 NAME:		CvtStringToVType.		
 DESCRIPTION:
   This function converts resource settings in string form to the
XtRVType representation type.

*******************************************************************/

static void CvtStringToVType(args, num_args, fromVal, toVal)
XrmValuePtr args;		/* unused */
Cardinal *num_args;		/* unused */
XrmValuePtr fromVal;
XrmValuePtr toVal;
{
/* Local variables */
long num;
static XcVType value;
char temp[30], temp2[30];

/*
 * Make sure the string is a numeric constant. If it isn't, print
 * a warning, and NULL the destination value.
 */
   if ((num = sscanf((char *)fromVal->addr, 
			"%[-012345689ABCDEFabcdef.]", temp)) == 0)
   {
      XtStringConversionWarning(fromVal->addr, "XcVType");
      CvtDone(char, NULL);
   }

/* If the number contains a decimal point, convert it into a float. */
   if (strchr(temp, '.') != NULL)
   {
      sscanf(temp, "%f", &value.fval); 
      CvtDone(XcVType, &value.fval);
   }

/* If it contains any hexadecimal characters, convert it to a long hex int */
   if (sscanf(temp, "%[ABCDEFabcdef]", temp2) != 0)
   {
      sscanf(temp, "%lX", &value.lval); 
      CvtDone(XcVType, &value.lval);
   }


/* Otherwise, it's an integer type. Convert the string to a numeric constant. */
   sscanf(temp, "%ld", &value.lval); 
   CvtDone(XcVType, &value.lval);
 
}  /* end of CvtStringToVType */




/*******************************************************************
 NAME:		CvtStringToValueJustify.		
 DESCRIPTION:
   This function converts resource settings in string form to the
XcRValueJustify representation type.

*******************************************************************/

static void CvtStringToValueJustify(args, num_args, fromVal, toVal)
XrmValuePtr args;		/* unused */
Cardinal *num_args;		/* unused */
XrmValuePtr fromVal;
XrmValuePtr toVal;
{
/* Local variables */
static XcValueJustify val_justify;
char lowerstring[100];

/* Convert the resource string to lower case for quick comparison */
   ToLower((char *)fromVal->addr, lowerstring);

/*
 * Compare resource string with valid XcValueJustify strings and assign to
 * datatype.
 */
   if (strcmp(lowerstring, XcEjustifyLeft) == 0) 
   {
      val_justify = XcJustifyLeft;
      CvtDone(XcValueJustify, &val_justify);
   }
   else if (strcmp(lowerstring, XcEjustifyRight) == 0) 
   {
      val_justify = XcJustifyRight;
      CvtDone(XcValueJustify, &val_justify);
   }
   else if (strcmp(lowerstring, XcEjustifyCenter) == 0) 
   {
      val_justify = XcJustifyCenter;
      CvtDone(XcValueJustify, &val_justify);
   }

/*
 * If the string is not valid for this resource type, print a warning
 * and do not make the conversion.
 */
   XtStringConversionWarning(fromVal->addr, XcRValueJustify);
   toVal->addr = NULL;
   toVal->size = 0;

}  /* end of CvtStringToValueJustify */




/*******************************************************************
 NAME:		Correlate.		
 DESCRIPTION:
   This function takes the given value between the given range and
correlates it to the destination range, returning the correlated value.

*******************************************************************/

float Correlate(from_val, from_range, to_range)
float from_val, from_range, to_range;
{
/* Local variables */
float percent, result;

   percent = ((from_val * 100.0) / from_range);

   result = (to_range * (percent / 100));

   return result;

}  /* end of Correlate */



/*********************************************************************
 FUNCTION:	Print_value.
 DESCRIPTION:
  Simply converts a widget's value into a string based on the value's
datatype and returns a pointer to it.

*********************************************************************/

char *Print_value(datatype, value, decimals)
XcDType datatype;
XcVType *value;
int decimals;
{
static char string[40];

   if (datatype == XcLval)
      sprintf(string, "%ld", value->lval);
   else if (datatype == XcHval)
      sprintf(string, "%lX", value->lval);
   else if (datatype == XcFval)
      sprintf(string, "%.*f", decimals, value->fval);

   return &string[0];

}  /* end of Print_value */




/*********************************************************************
 FUNCTION:	Position_val.
 DESCRIPTION:
  This function positions the displayed value within the Value Box based
on the XcNvalueJustify resource setting.

*********************************************************************/

void Position_val(w)
ValueWidget w;
{
/* Local variables */
char *val_string;
int text_width;

/* Establish the position of the value string within the Value Box. */
   val_string = Print_value(w->value.datatype, &w->value.val, 
							w->value.decimals);
   text_width = XTextWidth(w->control.font, val_string, strlen(val_string)); 

   if (w->value.justify == XcJustifyLeft)
      w->value.vp.x = w->value.value_box.x +
			(w->control.font->max_bounds.rbearing / 2 + 0.5);
   else if (w->value.justify == XcJustifyRight)
      w->value.vp.x = w->value.value_box.x +
      		w->value.value_box.width - text_width -
			(w->control.font->max_bounds.rbearing / 2 + 0.5);
   else if (w->value.justify == XcJustifyCenter)
      w->value.vp.x = w->value.value_box.x +
                (w->value.value_box.width / 2 + 0.5) -
                            (text_width / 2 + 0.5); 

   w->value.vp.y = w->value.value_box.y + 
		(w->value.value_box.height / 2 + 0.5) + 
				w->control.font->descent;

}  /* end of Position_val */


/* end of Value.c */

ype */




/*******************************************************************
 NAME:		CvtStringToValueJustify.		
 DESCRIPTION:
   This function converts resource settings in string form to the
XcRValueJustify representation type.

*******************************************************************/

static void CvtStringToValueJustify(args, num_args, fromValxscrabble/Xc/Value.h100600 000310 000001 00000001410 06047125556 015525 0ustar00mchapmanstaff000000 000000 /*******************************************************************
 FILE:		Value.h
 CONTENTS:	Public header file for the Value widget class.
 AUTHOR:	Paul D. Johnston
 HISTORY:
 Date		Action
 ---------	------------------------------------
 5/23/92	Changed the widget class name so that it is preceded
		by 'xc' with the first major word capitalized.
 3/11/92	Created.

********************************************************************/

#ifndef VALUE_H
#define VALUE_H




/* Class record declarations */

extern WidgetClass xcValueWidgetClass;

typedef struct _ValueClassRec *ValueWidgetClass;
typedef struct _ValueRec *ValueWidget;


/* Widget class functions. */
extern float Correlate();
extern char *Print_value();
extern void Position_val();

#endif /* VALUE_H */

e string within the Value Box. */
   val_string = Print_value(w->value.datatype, &w->value.val, 
							w->value.decimals);
   text_width = XTextWidth(w->control.font, val_string, strlen(val_string)); 

   if (w->value.justify == XcJustifyLeft)
   xscrabble/Xc/ValueP.h100600 000310 000001 00000004133 06047125556 015652 0ustar00mchapmanstaff000000 000000 /*******************************************************************
 FILE:		ValueP.h
 CONTENTS:	Private definitions for the Value widget class.
 AUTHOR:	Paul D. Johnston
 HISTORY:
 Date		Action
 ---------	------------------------------------
 3/11/92	Created.

********************************************************************/

#ifndef VALUEP_H
#define VALUEP_H

/*
 * Include the superclass private header.
 */
#include <X11/CoreP.h>
#include <X11/Xc/Xc.h>
#include <X11/Xc/ControlP.h>


/*
 * Include this widget class public header.
 */
#include <X11/Xc/Value.h>


/* Maximum and minimum decimal precision settings. */
#define MIN_DECIMALS		1
#define MAX_DECIMALS		6


/*
 * Class part.
 */
typedef struct 
{
   int dummy;	/* Minimum of one member required. */
} ValueClassPart;

/*
 * Class record.
 */
typedef struct _ValueClassRec
{
   CoreClassPart core_class;
   ControlClassPart control_class;
   ValueClassPart value_class;
} ValueClassRec;

/*
 * Declare the widget class record as external for use in the widget source
 * file.
 */
extern ValueClassRec valueClassRec;



/*
 * Instance part.
 */
typedef struct
{
   /* Public instance variables. */
   Pixel value_fg_pixel;		/* Value string foreground color */
   Pixel value_bg_pixel;		/* Value Box background color */
   XtCallbackList callback;		/* Widget callbacks */
   XcDType datatype;			/* Value's data type */
   int decimals;			/* No. of decimal points (if Fval). */
   XcVType increment;			/* Widget's increment. */
   XcVType upper_bound;			/* Upper range limit. */
   XcVType lower_bound;			/* Lower range limit. */
   XcVType val;				/* Storage for the current value
					 * manipulated by the widget.
					 */
   XcValueJustify justify;		/* Left, Right, or Center justification
					 * of the value within the Value Box.
					 */
   /* Private instance variables. */
   XRectangle value_box;		/* Value Box to display value in. */
   XPoint vp;				/* Place in Value Box to draw value. */

} ValuePart;

/*
 * Instance record.
 */
typedef struct _ValueRec
{
   CorePart core;
   ControlPart control;
   ValuePart value;
} ValueRec;



#endif  /* VALUEP_H */

Val;
XrmValuePtr toVal;
{
/* Local variables */
static XcValueJustify val_justify;
char lowerstring[100];

/* Convert the resource string to lower case for quick comparison */
   ToLower((char *)fromVal->addr, lowerstring);

/*
 * Compare resource string with valid XcValueJustify strings and assign to
 * datatype.
 */
   if (strcmp(lowerstring, XcEjustifyLeft) == 0) 
   {
      val_justify = XcJustifyLeft;
      CvtDoxscrabble/Xc/Xc.h100600 000310 000001 00000010121 06047125563 015020 0ustar00mchapmanstaff000000 000000 /*******************************************************************
 FILE:		Xc.h
 CONTENTS:	Public header file for the Xc Control Panel Widget Set.
 AUTHOR:	Paul D. Johnston
 HISTORY:
 Date		Action
 ---------	------------------------------------
 3/11/92	Created.

********************************************************************/

#ifndef XC_H
#define XC_H

/*
 * Defined Xc widget resource names, classes, and representation types.
 * Use these resource strings in your resource files.
 */
/* The Control widget's background color (used in generating 3D effect). */
#define XcNbackground	"background"

/* The Control widget's color resource strings. */
#define XcNlabelColor	"labelColor"

/* The Control widget's label string. */
#define XcNlabel	"label"
#define XcCLabel	"Label"

/* The Control widget's shade depth for the 3D effect. */
#define XcNshadeDepth	"shadeDepth"
#define XcCShadeDepth	"ShadeDepth"

/* Max and min shadeDepth resource settings. */
#define MIN_SHADE_DEPTH		1
#define MAX_SHADE_DEPTH		5

/*
 * These strings are used in specifying a Value widget's value datatype. 
 */
#define XcNdataType	"dataType"
#define XcCDataType	"DataType"
#define XcRDType	"XcDType"
#define XcElval		"lval"
#define XcEhval		"hval"
#define XcEfval		"fval"

/* Widget's value resource. */
#define XcNvalue	"value"
#define XcCValue	"Value"


/* Value foreground/background color resources */
#define XcNvalueForeground	"valueForeground"
#define XcNvalueBackground	"valueBackground"

/* Resource that specifies what to increment a widget's value by. */
#define XcNincrement	"increment"
#define XcCIncrement	"Increment"

/* Number of decimal positions for floating point values. */
#define XcNdecimals	"decimals"	
#define XcCDecimals	"Decimals"

/* Upper range of a widget's value. */
#define XcNupperBound	"upperBound"
#define XcCUpperBound	"UpperBound"

/* Lower range of a widget's value. */
#define XcNlowerBound	"lowerBound"
#define XcCLowerBound	"LowerBound"

/* Widget orientation: vertical or horizontal */
#define XcNorient	"orient"
#define XcCOrient	"Orient"
#define XcROrient	"XcOrient"
#define XcEvert		"vertical"
#define XcEhoriz	"horizontal"

/*
 * Time interval between update callbacks used by the indicator style 
 * widgets.
 */
#define XcNinterval	"interval"
#define XcCInterval	"Interval"

/*
 * Callback function called by the button style widgets when the user
 * activates the button.
 */
#define XcNactivateCallback	"activateCallback"

/*
 * Callback function called by the Value style widgets when the user
 * has changed its value.  A pointer to the XcData structure is passed to
 * the callback function containing the new value, it's datatype, and
 * number of decimal places if applicable.
 */
#define XcNvalueCallback	"valueCallback"

/*
 * Callback function called by the indicator style widgets at timed
 * intervals.
 */
#define XcNupdateCallback	"updateCallback"


/* Justification of a widget's value within the Value Box. */
#define XcNvalueJustify		"valueJustify"
#define XcCValueJustify		"ValueJustify"
#define XcRValueJustify		"XcValueJustify"
#define XcEjustifyLeft		"justifyleft"
#define XcEjustifyRight		"justifyright"
#define XcEjustifyCenter	"justifycenter"


/* Type for a widget's orientation. */
typedef enum
{
   XcVert = 1,
   XcHoriz
} XcOrient;


/* Data type of the value manipulated with a Xc widget subclass. */
typedef enum
{
   XcLval = 1,
   XcFval,
   XcHval
} XcDType;


/* Type for a widget's valueJustify resource setting. */
typedef enum
{
   XcJustifyLeft = 1,
   XcJustifyRight,
   XcJustifyCenter
} XcValueJustify;


/*
 * This respresentation type is a union for the possible Xc datatypes.
 */
#define XcRVType	"XcVType"

/* Type used for holding values manipulated with an Xc widget subclass . */
typedef union v_t
{
   long lval;
   float fval;
} XcVType;


/*
 * This structure is used by Xc widget action functions to communicate
 * important values to the application's callback functions. 
 * The application should use the XcData data type for the call_data 
 * parameter.
 */
typedef struct xc_stuff
{
   XcDType dtype;
   XcVType value;
   int decimals;
} XcCallData, *XcData;



#endif  /* XC_H */






/*******************************************************************
 NAME:		Correlate.		
 DESCRIPTION:
   This function takes the given value between the given range and
correlates it to the destination range, returning the correlated value.

*******************************************************************/

float Correlate(from_val, from_range, to_range)
float from_val, from_range, to_range;
{
/* Local variables */
flxscrabble/Xc/BarGraf.c100600 000310 000001 00000070623 06047127504 015757 0ustar00mchapmanstaff000000 000000 /*******************************************************************
 FILE:		BarGraf.c
 CONTENTS:	Definitions for structures, methods, and actions of the 
		BarGraph widget.
 AUTHOR:	Paul D. Johnston
 HISTORY:
 Date		Action
 ---------	------------------------------------
 5/23/92	Changed the widget class name so that it is preceded
		by 'xc' with the first major word capitalized.
 5/19/92	Added range checking to the callback processing and the
		XcBGUpdateValue function.
 4/15/92	Created.

********************************************************************/

#include <stdio.h>

/* Xlib includes */
#include <X11/Xlib.h>

/* Xt includes */
#include <X11/StringDefs.h>
#include <X11/IntrinsicP.h>


/* Widget includes */
#include <X11/Xc/Xc.h>
#include <X11/Xc/Control.h>
#include <X11/Xc/Value.h>
#include <X11/Xc/BarGrafP.h>	/* (includes BarGraf.h also) */


/* Macro redefinition for offset. */
#define offset(field) XtOffset(BarGraphWidget, field)


/* Declare widget methods */
static void ClassInitialize();
static void Initialize();
static void Redisplay();
static void Destroy();
static void Resize();
static XtGeometryResult QueryGeometry();
static Boolean SetValues();


/* Declare functions and variables private to this widget */
static void Update_value();
static void Draw_display();
static void Get_value();
static void Print_bounds();



/* Define the widget's resource list */
static XtResource resources[] =
{
  {
    XcNorient,
    XcCOrient,
    XcROrient,
    sizeof(XcOrient),
    offset(barGraph.orient),
    XtRString,
    "vertical"
  },
  {
    XcNbarForeground,
    XtCColor,
    XtRPixel,
    sizeof(Pixel),
    offset(barGraph.bar_foreground),
    XtRString,
    XtDefaultForeground
  },
  {
    XcNbarBackground,
    XtCColor,
    XtRPixel,
    sizeof(Pixel),
    offset(barGraph.bar_background),
    XtRString,
    XtDefaultBackground
  },
  {
    XcNscaleColor,
    XtCColor,
    XtRPixel,
    sizeof(Pixel),
    offset(barGraph.scale_pixel),
    XtRString,
    XtDefaultForeground
  },
  {
    XcNscaleSegments,
    XcCScaleSegments,
    XtRInt,
    sizeof(int),
    offset(barGraph.num_segments),
    XtRImmediate,
    (XtPointer)7
  },
  {
    XcNvalueVisible,
    XtCBoolean,
    XtRBoolean,
    sizeof(Boolean),
    offset(barGraph.value_visible),
    XtRString,
    "True"
  },
  {
    XcNinterval,
    XcCInterval,
    XtRInt,
    sizeof(int),
    offset(barGraph.interval),
    XtRImmediate,
    (XtPointer)0
  },
  {
    XcNupdateCallback,
    XtCCallback,
    XtRCallback,
    sizeof(caddr_t),
    offset(barGraph.update_callback),
    XtRCallback,
    NULL
  },
};




/* Widget Class Record initialization */
BarGraphClassRec barGraphClassRec =
{
  {
  /* core_class part */
    (WidgetClass) &valueClassRec,		/* superclass */
    "BarGraph",					/* class_name */
    sizeof(BarGraphRec),			/* widget_size */
    ClassInitialize,				/* class_initialize */
    NULL,					/* class_part_initialize */
    FALSE,					/* class_inited */
    Initialize,					/* initialize */
    NULL,					/* initialize_hook */
    XtInheritRealize,				/* realize */
    NULL,					/* actions */
    0,						/* num_actions */
    resources,					/* resources */
    XtNumber(resources),			/* num_resources */
    NULLQUARK,					/* xrm_class */
    TRUE,					/* compress_motion */
    TRUE,					/* compress_exposure */
    TRUE,					/* compress_enterleave */
    TRUE,					/* visible_interest */
    Destroy,					/* destroy */
    Resize,					/* resize */
    Redisplay,					/* expose */
    SetValues,					/* set_values */
    NULL,					/* set_values_hook */
    XtInheritSetValuesAlmost,			/* set_values_almost */
    NULL,					/* get_values_hook */
    NULL,					/* accept_focus */
    XtVersion,					/* version */
    NULL,					/* callback_private */
    NULL,					/* tm_table */
    QueryGeometry,				/* query_geometry */
    NULL,					/* display_accelerator */
    NULL,					/* extension */
  },
  {
  /* Control class part */
    0,						/* dummy_field */
  },
  {
  /* Value class part */
    0,						/* dummy_field */
  },
  {
  /* BarGraph class part */
    0,						/* dummy_field */
  }
};

WidgetClass xcBarGraphWidgetClass = (WidgetClass)&barGraphClassRec;


/* Widget method function definitions */

/*******************************************************************
 NAME:		ClassInitialize.	
 DESCRIPTION:
   This method initializes the BarGraph widget class. Specifically,
it registers resource value converter functions with Xt.

*******************************************************************/

static void ClassInitialize()
{

   XtAddConverter(XtRString, XcROrient, CvtStringToOrient, NULL, 0);

}  /* end of ClassInitialize */






/*******************************************************************
 NAME:		Initialize.		
 DESCRIPTION:
   This is the initialize method for the BarGraph widget.  It 
validates user-modifiable instance resources and initializes private 
widget variables and structures.  This function also creates any server 
resources (i.e., GCs, fonts, Pixmaps, etc.) used by this widget.  This
method is called by Xt when the application calls XtCreateWidget().

*******************************************************************/

static void Initialize(request, new)
BarGraphWidget request, new;
{
/* Local variables */
Display *display = XtDisplay(new);


DPRINTF(("BarGraph: executing Initialize...\n"));

/*
 * Validate public instance variable settings.
 */
/* Check orientation resource setting. */
   if ((new->barGraph.orient != XcVert) && (new->barGraph.orient != XcHoriz))
   {
      XtWarning("BarGraph: invalid orientation setting");
      new->barGraph.orient = XcVert;
   }

/* Check the interval resource setting. */
   if (new->barGraph.interval >0)
   {
      new->barGraph.interval_id = 
		XtAppAddTimeOut(XtWidgetToApplicationContext(new),
				new->barGraph.interval, Get_value, new);
   }

/* Check the scaleSegments resource setting. */
   if (new->barGraph.num_segments < MIN_SCALE_SEGS)
   {
      XtWarning("BarGraph: invalid number of scale segments");
      new->barGraph.num_segments = MIN_SCALE_SEGS;
   }
   else if (new->barGraph.num_segments > MAX_SCALE_SEGS)
   {
      XtWarning("BarGraph: invalid number of scale segments");
      new->barGraph.num_segments = MAX_SCALE_SEGS;
   }
   
/* Check the valueVisible resource setting. */
   if ((new->barGraph.value_visible != True) &&
		(new->barGraph.value_visible != False))
   {
      XtWarning("BarGraph: invalid valueVisible setting");
      new->barGraph.value_visible = True;
   }

/* Initialize the BarGraph width and height. */
   if (new->core.width < MIN_BG_WIDTH)
      new->core.width = MIN_BG_WIDTH; 
   if (new->core.height < MIN_BG_HEIGHT)
      new->core.height = MIN_BG_HEIGHT; 
   
/* Initialize private instance variables.  */

/* Set the initial geometry of the BarGraph elements. */
   Resize(new);


DPRINTF(("BarGraph: done Initialize\n"));

}  /* end of Initialize */





/*******************************************************************
 NAME:		Redisplay.	
 DESCRIPTION:
   This function is the BarGraph's Expose method.  It redraws the
BarGraph's 3D rectangle background, Value Box, label, Bar indicator,
and the Scale.  All drawing takes place within the widget's window 
(no need for an off-screen pixmap).

*******************************************************************/

static void Redisplay(w, event)
BarGraphWidget w;
XExposeEvent *event;
{
/* Local variables */
int j;
char upper[30], lower[30];

/*
 * Check to see whether or not the widget's window is mapped.  You can't
 * draw into a window that is not mapped.  Realizing a widget doesn't 
 * mean its mapped, but this call will work for most Window Managers.
 */
   if (!XtIsRealized(w))
      return;

DPRINTF(("BarGraph: executing Redisplay\n"));

/* Draw the 3D rectangle background for the BarGraph. */
   XSetClipMask(XtDisplay(w), w->control.gc, None);
   Rect3d(w, XtDisplay(w), XtWindow(w), w->control.gc,
		0, 0, w->core.width, w->core.height, RAISED);

/* Draw the Label string. */
   XSetClipRectangles(XtDisplay(w), w->control.gc, 0, 0, 
  			&(w->barGraph.face), 1, Unsorted); 
   XSetForeground(XtDisplay(w), w->control.gc,
                        w->control.label_pixel);
   XDrawString(XtDisplay(w), XtWindow(w), w->control.gc,
	w->barGraph.lbl.x, w->barGraph.lbl.y, 
	w->control.label, strlen(w->control.label));

/* Draw the Scale along the Bar indicator */
   XSetForeground(XtDisplay(w), w->control.gc,
                        w->barGraph.scale_pixel);
   XDrawLine(XtDisplay(w), XtWindow(w), w->control.gc,
	w->barGraph.scale_line.x1, w->barGraph.scale_line.y1,
	w->barGraph.scale_line.x2, w->barGraph.scale_line.y2);

/* Draw the max and min value segments. */
   if (w->barGraph.orient == XcVert)
   {
      XDrawLine(XtDisplay(w), XtWindow(w), w->control.gc,
		w->barGraph.scale_line.x1 - w->barGraph.seg_length, 
		w->barGraph.scale_line.y1, w->barGraph.scale_line.x1, 
						w->barGraph.scale_line.y1);
      XDrawLine(XtDisplay(w), XtWindow(w), w->control.gc,
		w->barGraph.scale_line.x2 - w->barGraph.seg_length, 
		w->barGraph.scale_line.y2, w->barGraph.scale_line.x2, 
						w->barGraph.scale_line.y2);
   }
   else
   {
      XDrawLine(XtDisplay(w), XtWindow(w), w->control.gc,
		w->barGraph.scale_line.x1, 
		w->barGraph.scale_line.y1 - w->barGraph.seg_length, 
		w->barGraph.scale_line.x1, w->barGraph.scale_line.y1);
      XDrawLine(XtDisplay(w), XtWindow(w), w->control.gc,
		w->barGraph.scale_line.x2, 
		w->barGraph.scale_line.y2 - w->barGraph.seg_length, 
		w->barGraph.scale_line.x2, w->barGraph.scale_line.y2);
   }

/* Now draw the rest of the Scale segments. */
   if (w->barGraph.num_segments > 0)
   {
      for (j = 0; j < w->barGraph.num_segments; j++)
      {
         if (w->barGraph.orient == XcVert)
	    XDrawLine(XtDisplay(w), XtWindow(w), w->control.gc,
		w->barGraph.segs[j].x, w->barGraph.segs[j].y,
		w->barGraph.scale_line.x1, w->barGraph.segs[j].y);
         else
	    XDrawLine(XtDisplay(w), XtWindow(w), w->control.gc,
		w->barGraph.segs[j].x, w->barGraph.segs[j].y,
		w->barGraph.segs[j].x, w->barGraph.scale_line.y1);
      }
   }


/* Draw the max and min value string indicators */
   Print_bounds(w, upper, lower);
   XDrawString(XtDisplay(w), XtWindow(w), w->control.gc,
    	w->barGraph.max_val.x, w->barGraph.max_val.y,
						upper, strlen(upper)); 
   XDrawString(XtDisplay(w), XtWindow(w), w->control.gc,
    	w->barGraph.min_val.x, w->barGraph.min_val.y, 
						lower, strlen(lower)); 


/* Draw the Bar indicator border */
   Rect3d(w, XtDisplay(w), XtWindow(w), w->control.gc,
	w->barGraph.bar.x - w->control.shade_depth, 
	w->barGraph.bar.y - w->control.shade_depth,
	w->barGraph.bar.width + (2 * w->control.shade_depth),  
	w->barGraph.bar.height + (2 * w->control.shade_depth), DEPRESSED);

/* Draw the Value Box */
   if (w->barGraph.value_visible == True)
      Rect3d(w, XtDisplay(w), XtWindow(w), w->control.gc,
	w->value.value_box.x - w->control.shade_depth, 
	w->value.value_box.y - w->control.shade_depth,
	w->value.value_box.width + (2 * w->control.shade_depth),  
	w->value.value_box.height + (2 * w->control.shade_depth), 
							DEPRESSED);

/* Draw the new value represented by the Bar indicator and the value string */
   Draw_display(w, XtDisplay(w), XtWindow(w), w->control.gc);


DPRINTF(("BarGraph: done Redisplay\n"));

}  /* end of Redisplay */





/*******************************************************************
 NAME:		SetValues.
 DESCRIPTION:
   This is the set_values method for this widget. It validates resource
settings set with XtSetValues. If a resource is changed that would
require re-drawing the widget, return True.

*******************************************************************/

static Boolean SetValues(cur, req, new)
BarGraphWidget cur, req, new;
{
/* Local variables */
Boolean do_redisplay = False;


DPRINTF(("BarGraph: executing SetValues \n"));

/* Validate new resource settings. */

/* Check widget color resource settings. */
   if ((new->barGraph.bar_foreground != cur->barGraph.bar_foreground) ||
	(new->barGraph.bar_background != cur->barGraph.bar_background) ||
	(new->barGraph.scale_pixel != cur->barGraph.scale_pixel)) 
      do_redisplay = True;

/* Check orientation resource setting. */
   if (new->barGraph.orient != cur->barGraph.orient)
   {
      do_redisplay = True;
      if ((new->barGraph.orient != XcVert) && (new->barGraph.orient != XcHoriz))
      {
         XtWarning("BarGraph: invalid orientation setting");
         new->barGraph.orient = XcVert;
      }
   }

/* Check the interval resource setting. */
   if (new->barGraph.interval != cur->barGraph.interval) 
   {
      if (cur->barGraph.interval > 0)
	    XtRemoveTimeOut (cur->barGraph.interval_id);
      if (new->barGraph.interval > 0)
         new->barGraph.interval_id = 
		XtAppAddTimeOut(XtWidgetToApplicationContext(new),
					new->barGraph.interval, Get_value, new);
   }

/* Check the scaleSegments resource setting. */
   if (new->barGraph.num_segments != cur->barGraph.num_segments)
   {
      if (new->barGraph.num_segments < MIN_SCALE_SEGS)
      {
         XtWarning("BarGraph: invalid number of scale segments");
         new->barGraph.num_segments = MIN_SCALE_SEGS;
      }
      else if (new->barGraph.num_segments > MAX_SCALE_SEGS)
      {
         XtWarning("BarGraph: invalid number of scale segments");
         new->barGraph.num_segments = MAX_SCALE_SEGS;
      }
   }

/* Check the valueVisible resource setting. */
   if (new->barGraph.value_visible != cur->barGraph.value_visible)
   {
      do_redisplay = True;
      if ((new->barGraph.value_visible != True) &&
		(new->barGraph.value_visible != False))
      {
         XtWarning("BarGraph: invalid valueVisible setting");
         new->barGraph.value_visible = True;
      }
   }

/* Check to see if the value has changed. */
   if ((((new->value.datatype == XcLval) || (new->value.datatype == XcHval)) && 
		(new->value.val.lval != cur->value.val.lval))
      || ((new->value.datatype == XcFval) && 
		(new->value.val.fval != cur->value.val.fval)))
   {
      do_redisplay = True;
   }


DPRINTF(("BarGraph: done SetValues\n"));
   return do_redisplay;


}  /* end of SetValues */




/*******************************************************************
 NAME:		Resize.
 DESCRIPTION:
   This is the resize method of the BarGraph widget. It resizes the
BarGraph's graphics based on the new width and height of the widget's
window.  

*******************************************************************/

static void Resize(w)
BarGraphWidget w;
{
/* Local variables */
int j;
int seg_spacing;
int max_val_width, min_val_width;
int font_center;
char upper[30], lower[30];

DPRINTF(("BarGraph: executing Resize\n"));

/* Set the widgets new width and height. */
   w->barGraph.face.x = w->barGraph.face.y = w->control.shade_depth;
   w->barGraph.face.width = w->core.width - (2*w->control.shade_depth);
   w->barGraph.face.height = w->core.height - (2*w->control.shade_depth);

/* Establish the new Value Box geometry. */
   if (w->barGraph.orient == XcVert)
   {
      w->value.value_box.x = w->barGraph.face.x + (2*w->control.shade_depth);
      w->value.value_box.y = w->barGraph.face.y + w->barGraph.face.height -
			(short)(w->barGraph.face.height / 8 + 0.5) +
					(2 * w->control.shade_depth);
      w->value.value_box.width = w->barGraph.face.width -
					(4 * w->control.shade_depth);
      w->value.value_box.height = (short)(w->barGraph.face.height / 8 +0.5) -
					(2*w->control.shade_depth);
   }
   else
   {
      w->value.value_box.x = w->barGraph.face.x + 
				(short)(w->barGraph.face.width / 3 + 0.5) +
				w->control.shade_depth;
      w->value.value_box.y = w->barGraph.face.y +
			(short)((3 * w->barGraph.face.height) / 4 + 0.5) +
					(2 * w->control.shade_depth);
      w->value.value_box.width = (short)(w->barGraph.face.width / 3 +0.5) -
					(2 * w->control.shade_depth);
      w->value.value_box.height = (short)(w->barGraph.face.height / 4 +0.5) -
					(2*w->control.shade_depth);
   }

/* Set the position of the displayed value within the Value Box. */
   Position_val(w);

/* Set the new label location. */
   w->barGraph.lbl.x = (w->core.width / 2 + 0.5) -
		(XTextWidth(w->control.font, w->control.label, 
			strlen(w->control.label)) / 2 + 0.5); 
   w->barGraph.lbl.y = w->barGraph.face.y + w->control.font->ascent + 1;


/* Resize the Bar indicator */
   if (w->barGraph.orient == XcVert)
   {
      w->barGraph.bar.x = w->barGraph.face.x +
			(short)((2 * w->barGraph.face.width) / 3 +0.5) +
				w->control.shade_depth;
      w->barGraph.bar.y = w->barGraph.face.y +
			(short)(w->barGraph.face.height / 8 +0.5) +
				w->control.shade_depth;
      w->barGraph.bar.width = (short)(w->barGraph.face.width / 3 +0.5) -
					(2*w->control.shade_depth);
      w->barGraph.bar.height = (short)((6*w->barGraph.face.height) / 8 +0.5) -
					(2*w->control.shade_depth);
   }
   else
   {
      w->barGraph.bar.x = w->barGraph.face.x +
			(short)(w->barGraph.face.width / 8 +0.5) +
				w->control.shade_depth;
      w->barGraph.bar.y = w->barGraph.face.y +
			(short)(w->barGraph.face.height / 2 +0.5) +
				w->control.shade_depth;
      w->barGraph.bar.width = (short)((6 * w->barGraph.face.width) / 8 +0.5) -
					(2*w->control.shade_depth);
      w->barGraph.bar.height = (short)(w->barGraph.face.height / 4 +0.5) -
					(2*w->control.shade_depth);
   }


/* Resize the Scale line. */
   if (w->barGraph.orient == XcVert)
   {
      w->barGraph.scale_line.x1 = w->barGraph.bar.x - w->control.shade_depth -
					(w->barGraph.face.width / 32 + 0.5);
      w->barGraph.scale_line.y1 = w->barGraph.bar.y;
      w->barGraph.scale_line.x2 = w->barGraph.scale_line.x1;
      w->barGraph.scale_line.y2 = w->barGraph.bar.y + w->barGraph.bar.height;
   }
   else
   {
      w->barGraph.scale_line.x1 = w->barGraph.bar.x;
      w->barGraph.scale_line.y1 = w->barGraph.bar.y - w->control.shade_depth -
					(w->barGraph.face.height / 32 + 0.5);
      w->barGraph.scale_line.x2 = w->barGraph.bar.x + w->barGraph.bar.width;
      w->barGraph.scale_line.y2 = w->barGraph.scale_line.y1;
   }

/* Now, resize Scale line segments */
   if (w->barGraph.num_segments > 0)
   {
      if (w->barGraph.orient == XcVert)
      {
         w->barGraph.seg_length = (w->barGraph.face.width / 16 + 0.5);
         seg_spacing = (w->barGraph.bar.height / 
				(w->barGraph.num_segments + 1) + 0.5);
         for (j = 0; j < w->barGraph.num_segments; j++)
         {
	    w->barGraph.segs[j].x = w->barGraph.scale_line.x1 - 
						w->barGraph.seg_length;
	    w->barGraph.segs[j].y = w->barGraph.scale_line.y1 + 
						((j+1) * seg_spacing);
         }
      }
      else
      {
         w->barGraph.seg_length = (w->barGraph.face.height / 16 + 0.5);
         seg_spacing = (w->barGraph.bar.width / 
				(w->barGraph.num_segments + 1) + 0.5);
         for (j = 0; j < w->barGraph.num_segments; j++)
         {
	    w->barGraph.segs[j].x = w->barGraph.scale_line.x1 + 
						((j+1) * seg_spacing);
	    w->barGraph.segs[j].y = w->barGraph.scale_line.y1 - 
						w->barGraph.seg_length;
         }
      }
   }

/* Set the position of the max and min value strings */
   Print_bounds(w, upper, lower);
   max_val_width = XTextWidth(w->control.font, upper, strlen(upper));
   min_val_width = XTextWidth(w->control.font, lower, strlen(lower));

   if (w->barGraph.orient == XcVert)
   {
      font_center = ((w->control.font->ascent + 
				w->control.font->descent) / 2 + 0.5) 
				- w->control.font->descent;
      w->barGraph.max_val.x = w->barGraph.scale_line.x1 - 
				w->barGraph.seg_length - max_val_width;
      w->barGraph.max_val.y = w->barGraph.scale_line.y1 + font_center;
      w->barGraph.min_val.x = w->barGraph.scale_line.x2 - 
				w->barGraph.seg_length - min_val_width;
      w->barGraph.min_val.y = w->barGraph.scale_line.y2 + font_center;
   }
   else
   {
      w->barGraph.max_val.x = w->barGraph.scale_line.x2 - (max_val_width / 2);
      w->barGraph.max_val.y = w->barGraph.min_val.y =
      		w->barGraph.scale_line.y1 - w->barGraph.seg_length - 
					w->control.font->descent;
      w->barGraph.min_val.x = w->barGraph.scale_line.x1 - (min_val_width / 2);
   }


DPRINTF(("BarGraph: done Resize\n"));

}  /* end of Resize */




/*******************************************************************
 NAME:		QueryGeometry.		
 DESCRIPTION:
   This function is the widget's query_geometry method.  It simply
checks the proposed size and returns the appropriate value based on
the proposed size.  If the proposed size is greater than the maximum
appropriate size for this widget, QueryGeometry returns the recommended
size.

*******************************************************************/

static XtGeometryResult QueryGeometry(w, proposed, answer)
BarGraphWidget w;
XtWidgetGeometry *proposed, *answer;
{
/* Set the request mode mask for the returned answer. */
   answer->request_mode = CWWidth | CWHeight;

/* Set the recommended size. */
   answer->width = (w->core.width > MAX_BG_WIDTH)
	? MAX_BG_WIDTH : w->core.width;
   answer->height = (w->core.height > MAX_BG_HEIGHT)
	? MAX_BG_HEIGHT : w->core.height;

/* 
 * Check the proposed dimensions. If the proposed size is larger than
 * appropriate, return the recommended size.
 */
   if (((proposed->request_mode & (CWWidth | CWHeight)) == (CWWidth | CWHeight))
	&& proposed->width == answer->width 
	&& proposed->height == answer->height)
      return XtGeometryYes;
   else if (answer->width == w->core.width && answer->height == w->core.height)
      return XtGeometryNo;
   else
      return XtGeometryAlmost;

}  /* end of QueryGeometry */




/*******************************************************************
 NAME:		Destroy.
 DESCRIPTION:
   This function is the widget's destroy method.  It simply releases
any server resources acquired during the life of the widget.

*******************************************************************/

static void Destroy(w)
BarGraphWidget w;
{

   if (w->barGraph.interval > 0)
      XtRemoveTimeOut (w->barGraph.interval_id);

}  /* end of Destroy */





/* Widget action functions. */

/*******************************************************************
 NAME:		Get_value.		
 DESCRIPTION:
   This function is the time out procedure called at XcNinterval 
intervals.  It calls the application registered callback function to
get the latest value and updates the BarGraph display accordingly.

*******************************************************************/

static void Get_value(client_data, id)
caddr_t client_data;
XtIntervalId *id;		/* unused */
{
/* Local variables */
static XcCallData call_data;
BarGraphWidget w = (BarGraphWidget)client_data;
   
/* Get the new value by calling the application's callback if it exists. */
   if (w->barGraph.update_callback == NULL)
       return;

/* Re-register this TimeOut procedure for the next interval. */
   if (w->barGraph.interval > 0)
      w->barGraph.interval_id = 
	XtAppAddTimeOut(XtWidgetToApplicationContext((Widget)w),
		       w->barGraph.interval, Get_value, client_data);

/* Set the widget's current value and datatype before calling the callback. */
   call_data.dtype = w->value.datatype;
   call_data.decimals = w->value.decimals;
   if ((w->value.datatype == XcLval) || (w->value.datatype == XcHval))  
      call_data.value.lval = w->value.val.lval;
   else if (w->value.datatype == XcFval)
      call_data.value.fval = w->value.val.fval;
   XtCallCallbacks((Widget)w, XcNupdateCallback, &call_data);


/* Update the new value, update the BarGraph display. */
   if ((w->value.datatype == XcLval) || (w->value.datatype == XcHval))  
   {
      if ((call_data.value.lval <= w->value.upper_bound.lval) && 
			(call_data.value.lval >= w->value.lower_bound.lval))
	 w->value.val.lval = call_data.value.lval;
   }
   else if (w->value.datatype == XcFval)
   {
      if ((call_data.value.fval <= w->value.upper_bound.fval) && 
			(call_data.value.fval >= w->value.lower_bound.fval))
	 w->value.val.fval = call_data.value.fval;
   }

   if (XtIsRealized(w))
      Draw_display(w, XtDisplay(w), XtWindow(w), w->control.gc);
   

}  /* end of Get_value */




/*******************************************************************
 NAME:		XcBGUpdateValue.		
 DESCRIPTION:
   This convenience function is called by the application in order to
update the value (a little quicker than using XtSetArg/XtSetValue).
The application passes the new value to be updated with.

*******************************************************************/

void XcBGUpdateValue(w, value)
BarGraphWidget w;
XcVType *value;
{
/* Local variables */
   
/* Update the new value, then update the BarGraph display. */
   if (value != NULL)
   {
      if ((w->value.datatype == XcLval) || (w->value.datatype == XcHval))  
      {
	 if ((value->lval <= w->value.upper_bound.lval) && 
			(value->lval >= w->value.lower_bound.lval))
	    w->value.val.lval = value->lval;
      }
      else if (w->value.datatype == XcFval)
      {
	 if ((value->fval <= w->value.upper_bound.fval) && 
			(value->fval >= w->value.lower_bound.fval))
	    w->value.val.fval = value->fval;
      }

      if (XtIsRealized(w))
         Draw_display(w, XtDisplay(w), XtWindow(w), w->control.gc);

   }
   
}  /* end of XcBGUpdateValue */




/*******************************************************************
 NAME:		Draw_display.		
 DESCRIPTION:
   This function redraws the Bar indicator and the value string in the 
Value Box.

*******************************************************************/

static void Draw_display( w, display, drawable, gc)
BarGraphWidget w;
Display *display;
Drawable drawable;
GC gc;
{
/* Local variables */
char *temp;
float range, dim;

/* Draw the Bar indicator */
/* Fill the Bar with its background color. */
   XSetForeground(display, gc, w->barGraph.bar_background); 
   XFillRectangle(display, drawable, gc,
  	w->barGraph.bar.x, w->barGraph.bar.y, 
  	w->barGraph.bar.width, w->barGraph.bar.height); 

/* Draw the Bar in its foreground color according to the value. */
   if (w->barGraph.orient == XcVert)
      range = (float)(w->barGraph.bar.height);
   else
      range = (float)(w->barGraph.bar.width);

   if ((w->value.datatype == XcLval) || (w->value.datatype == XcHval))
      dim = Correlate(((float)(w->value.val.lval) - 
			(float)(w->value.lower_bound.lval)),
			((float)(w->value.upper_bound.lval) -
			 (float)(w->value.lower_bound.lval)), range);
   else if (w->value.datatype == XcFval)
      dim = Correlate((w->value.val.fval - w->value.lower_bound.fval),
			(w->value.upper_bound.fval -
		 	 w->value.lower_bound.fval), range);

   if ((int)dim < 1)
      dim = 1;
   XSetForeground(display, gc, w->barGraph.bar_foreground); 
   if (w->barGraph.orient == XcVert)
      XFillRectangle(display, drawable, gc, w->barGraph.bar.x,
		(w->barGraph.bar.y + w->barGraph.bar.height - (int)dim),
		w->barGraph.bar.width, (int)dim);
   else
      XFillRectangle(display, drawable, gc, w->barGraph.bar.x,
		w->barGraph.bar.y, (int)dim, w->barGraph.bar.height);


/* If the value string is supposed to be displayed, draw it. */
   if (w->barGraph.value_visible == True)
   {
   /* Clear the Value Box by re-filling it with its background color. */
      XSetForeground(display, gc, w->value.value_bg_pixel); 
      XFillRectangle(display, drawable, gc,
  	w->value.value_box.x, w->value.value_box.y, 
  	w->value.value_box.width, w->value.value_box.height); 

   /*
    * Now draw the value string in its foreground color, clipped by the
    * Value Box.
    */
      XSetForeground(display, gc, w->value.value_fg_pixel); 
      XSetClipRectangles(display, gc, 0, 0, 
  	&(w->value.value_box), 1, Unsorted); 

      temp = Print_value(w->value.datatype, &w->value.val, w->value.decimals);

      Position_val(w);

      XDrawString(display, drawable, gc,
    	w->value.vp.x, w->value.vp.y, temp, strlen(temp)); 
   }

/* Reset the clip_mask to no clipping. */
   XSetClipMask(display, gc, None);

}  /* end of Draw_display */




/*******************************************************************
 NAME:		Print_bounds.		
 DESCRIPTION:
   This is a utility function used by the Redisplay and Resize methods to
print the upper and lower bound values as strings for displaying and resizing
purposes.

*******************************************************************/

static void Print_bounds(w, upper, lower)
BarGraphWidget w;
char *upper, *lower;
{

   if (w->value.datatype == XcLval)  
   {
      sprintf(upper, "%ld", w->value.upper_bound.lval); 
      sprintf(lower, "%ld", w->value.lower_bound.lval); 
   } 
   else if (w->value.datatype == XcHval)  
   {
      sprintf(upper, "%lX", w->value.upper_bound.lval); 
      sprintf(lower, "%lX", w->value.lower_bound.lval); 
   } 
   else if (w->value.datatype == XcFval)  
   {
      sprintf(upper, "%.*f", w->value.decimals, w->value.upper_bound.fval); 
      sprintf(lower, "%.*f", w->value.decimals, w->value.lower_bound.fval); 
   } 

}  /* end of Print_bounds */


/* end of BarGraf.c */

}
      else if (w->value.datatype == XcFval)
      {
	 if ((value->fval <= w->value.upper_bound.fval) && 
		xscrabble/Xc/BarGraf.h100600 000310 000001 00000002171 06047127504 015755 0ustar00mchapmanstaff000000 000000 /*******************************************************************
 FILE:		BarGraf.h
 CONTENTS:	Public header file for the BarGraph widget.
 AUTHOR:	Paul D. Johnston
 HISTORY:
 Date		Action
 ---------	------------------------------------
 5/23/92	Changed the widget class name so that it is preceded
		by 'xc' with the first major word capitalized.
 4/15/92	Created.

********************************************************************/

#ifndef BARGRAPH_H
#define BARGRAPH_H

/* Superclass header */
#include <X11/Xc/Value.h>


/*
 * Define widget resource names, classes, and representation types.
 * Use these resource strings in your resource files.
 */
#define XcNbarBackground	"barBackground"
#define XcNbarForeground	"barForeground"
#define XcNscaleColor		"scaleColor"
#define XcNscaleSegments	"scaleSegments"
#define XcCScaleSegments	"ScaleSegments"
#define XcNvalueVisible		"valueVisible"



/* Class record declarations */

extern WidgetClass xcBarGraphWidgetClass;

typedef struct _BarGraphClassRec *BarGraphWidgetClass;
typedef struct _BarGraphRec *BarGraphWidget;


/* Widget functions */
extern void XcBGUpdateValue();

#endif

har *temp;
float range, dim;

/* Draw the Bar indicator */
/* Fill the Bar with its background color. */
   XSetForeground(display, gc, w->barGraph.bar_background); 
   XFillRectangle(display, drawable, gc,
  	w->barGraph.bar.x, w->barGraph.bar.y, 
  	w->barGraph.bar.width, w->barGraph.bar.height); 

/* Draw the Bar in its foreground color according to the value. */
   if (w->barGraph.orixscrabble/Xc/BarGrafP.h100600 000310 000001 00000005410 06047127504 016074 0ustar00mchapmanstaff000000 000000 /*******************************************************************
 FILE:		BarGrafP.h
 CONTENTS:	Private definitions for the BarGraph widget.
 AUTHOR:	Paul D. Johnston
 HISTORY:
 Date		Action
 ---------	------------------------------------
 4/15/91	Created.

********************************************************************/

#ifndef BARGRAPHP_H
#define BARGRAPHP_H

/*
 * Include the superclass private headers.
 */
#include <X11/CoreP.h>
#include <X11/Xc/Xc.h>
#include <X11/Xc/ValueP.h>

/*
 * Include this widget class public header.
 */
#include <X11/Xc/BarGraf.h>


/* Private declarations and definitions. */
#define MIN_BG_WIDTH		50
#define MIN_BG_HEIGHT		90
#define MAX_BG_WIDTH		150
#define MAX_BG_HEIGHT		300

/* Max number of Scale segments. */
#define MIN_SCALE_SEGS		0
#define MAX_SCALE_SEGS		20


/*
 * Class part.
 */
typedef struct 
{
   int dummy;	/* Minimum of one member required. */
} BarGraphClassPart;

/*
 * Class record.
 */
typedef struct _BarGraphClassRec
{
   CoreClassPart core_class;
   ControlClassPart control_class;
   ValueClassPart value_class;
   BarGraphClassPart barGraph_class;
} BarGraphClassRec;

/*
 * Declare the widget class record as external for use in the widget source
 * file.
 */
extern BarGraphClassRec barGraphClassRec;



/*
 * Instance part.
 */
typedef struct
{
   /* Public instance variables. */
   XcOrient orient;			/* BarGraph's orientation: vertical
					 * or horizontal.
					 */
   int interval;			/* Time interval for updateCallback */
   XtCallbackList update_callback;	/* The updateCallback function. */
   Pixel bar_background;		/* Background color of the bar. */
   Pixel bar_foreground;		/* Foreground color of the bar. */
   Pixel scale_pixel;			/* Color of the Scale indicator. */
   int num_segments;			/* Number of segments in the Scale */
   Boolean value_visible;		/* Enable/Disable display of the 
					 * value in the Value Box.
					 */

   /* Private instance variables. */
   XRectangle face;			/* Geometry of the BarGraph face */
   XPoint lbl;				/* Location of the Label string */
   XRectangle bar;			/* Rectangle for the Bar indicator. */
   XSegment scale_line;			/* Scale line along Bar indicator. */
   XPoint segs[MAX_SCALE_SEGS+1];	/* Line segments for the Scale. */
   int seg_length;			/* Length of Scale line segments. */
   XPoint max_val;			/* Point at which to draw the max
					 * value string on the Scale.
					 */
   XPoint min_val;			/* Point at which to draw the min
					 * value string on the Scale.
					 */
   int interval_id;			/* Xt TimeOut interval ID. */

} BarGraphPart;

/*
 * Instance record.
 */
typedef struct _BarGraphRec
{
   CorePart core;
   ControlPart control;
   ValuePart value;
   BarGraphPart barGraph;
} BarGraphRec;


/* Declare widget class functions here. */


#endif  /* BARGRAPHP_H */

er_bound.lval)),
			((float)(w->value.upper_bound.lval) -
			 (float)(w->value.lower_bound.lval)), range);
   else if (w->value.datatype == XcFval)
      dim = Correlate((w->value.val.fval - w->value.lower_bound.fval),
			(w->value.upper_bound.fvalxscrabble/Xc/Makefile100644 000310 000001 00000045762 06311435232 015757 0ustar00mchapmanstaff000000 000000 # Makefile generated by imake - do not edit!
# $XConsortium: imake.c,v 1.91 95/01/12 16:15:47 kaleb Exp $

# ----------------------------------------------------------------------
# Makefile generated from "Imake.tmpl" and </tmp/IIf.a00344>
# $XConsortium: Imake.tmpl,v 1.224.1.1 95/06/19 17:51:01 gildea Exp $
# $XFree86: xc/config/cf/Imake.tmpl,v 3.18 1995/07/12 15:27:23 dawes Exp $
#

.SUFFIXES: .i

# $XConsortium: Imake.cf,v 1.19 95/01/05 19:24:32 kaleb Exp $
# $XFree86: xc/config/cf/Imake.cf,v 3.15 1995/06/08 06:18:39 dawes Exp $

# -----------------------------------------------------------------------
# site-specific configuration parameters that need to come before
# the platform-specific parameters - edit site.def to change

# site:  $XConsortium: site.sample,v 1.9 94/04/08 17:02:06 rws Exp $
# site:  $XFree86: xc/config/cf/site.def,v 3.8 1995/05/27 01:56:50 dawes Exp $

MOTIFLIBINSTALLDIR = /usr/pkg/motif-2.0/X11R6/lib
MOTIFSHLIBINSTALLDIR = /usr/pkg/motif-2.0/X11R6/lib
MOTIFBININSTALLDIR = /usr/pkg/motif-2.0/X11R6/bin

# $XFree86: xc/config/cf/xf86site.def,v 3.48 1995/07/22 04:11:45 dawes Exp $

# -----------------------------------------------------------------------
# platform-specific configuration parameters - edit linux.cf to change

# platform:  $XConsortium: linux.cf,v 1.11 95/01/23 18:32:03 kaleb Exp $
# platform:  $XFree86: xc/config/cf/linux.cf,v 3.26 1995/07/12 15:27:34 dawes Exp $

# $XConsortium: lnxLib.rules,v 1.8 95/01/16 21:11:00 kaleb Exp $
# $XFree86: xc/config/cf/lnxLib.rules,v 3.14 1995/06/01 08:18:56 dawes Exp $

# $XConsortium: xfree86.cf,v 1.9 95/01/25 16:42:40 kaleb Exp $
# $XFree86: xc/config/cf/xfree86.cf,v 3.66 1995/07/22 04:11:47 dawes Exp $

LINKKITDIR = $(USRLIBDIR)/Server

       XF86SRC = $(SERVERSRC)/hw/xfree86
  XF86ACCELSRC = $(XF86SRC)/accel
    XF86COMSRC = $(XF86SRC)/common
 XF86CONFIGSRC = $(XF86COMSRC)
     XF86HWSRC = $(XF86SRC)/common_hw
     XF86OSSRC = $(XF86SRC)/os-support
  VGADRIVERSRC = $(XF86SRC)/vga256/drivers
VGA16DRIVERSRC = $(XF86SRC)/vga16/drivers
 VGA2DRIVERSRC = $(XF86SRC)/vga2/drivers
 MONODRIVERSRC = $(XF86SRC)/mono/drivers
   S3DRIVERSRC = $(XF86SRC)/accel/s3/drivers

        XFREE86DOCDIR = /usr/X11R6/doc/XFree86
      XFREE86PSDOCDIR = $(XFREE86DOCDIR)
    XFREE86HTMLDOCDIR = /usr/X11R6/html/XFree86
XFREE86JAPANESEDOCDIR = $(XFREE86DOCDIR)/Japanese

# $XConsortium: xf86.rules,v 1.7 95/01/25 16:34:39 kaleb Exp $
# $XFree86: xc/config/cf/xf86.rules,v 3.9 1995/07/12 15:27:38 dawes Exp $

# -----------------------------------------------------------------------
# site-specific configuration parameters that go after
# the platform-specific parameters - edit site.def to change

# site:  $XConsortium: site.sample,v 1.9 94/04/08 17:02:06 rws Exp $
# site:  $XFree86: xc/config/cf/site.def,v 3.8 1995/05/27 01:56:50 dawes Exp $

# -----------------------------------------------------------------------
# Imake rules for building libraries, programs, scripts, and data files
# rules:  $XConsortium: Imake.rules,v 1.197.1.1 95/06/19 18:01:48 gildea Exp $
# rules:  $XFree86: xc/config/cf/Imake.rules,v 3.18 1995/07/22 09:39:32 dawes Exp $

 _NULLCMD_ = @ echo -n

          PATHSEP = /
            SHELL = /bin/sh

              TOP = ..
      CURRENT_DIR = Xc

            IMAKE = imake
           DEPEND = gccmakedep
        MKDIRHIER = mkdir -p
        CONFIGSRC = $(TOP)/config
         IMAKESRC = $(CONFIGSRC)/imake
        DEPENDSRC = $(CONFIGSRC)/util
           IXXSRC = $(UNSUPPORTEDSRC)/programs/ixx
              IXX = ixx
         IXXFLAGS = -s BaseObject -m TypeObj -r RequestObj -p Xf
      IXXINCLUDES = -i '<X11/Fresco/enter-scope.h>'

          INCROOT = /usr/X11R6/include
        USRLIBDIR = /usr/pkg/gcc/lib
         SHLIBDIR = /usr/X11R6/lib
       LINTLIBDIR = $(USRLIBDIR)/lint
          MANPATH = /usr/X11R6/man
    MANSOURCEPATH = $(MANPATH)/man
           MANDIR = $(MANSOURCEPATH)1
        LIBMANDIR = $(MANSOURCEPATH)X
       FILEMANDIR = $(MANSOURCEPATH)5

               AR = ar clq
  BOOTSTRAPCFLAGS =
               CC = gcc
               AS = as

.SUFFIXES: .cxx

              CXX = g++
    CXXDEBUGFLAGS = -O
 CXXEXTRA_DEFINES =
CXXEXTRA_INCLUDES =
  CXXIDL_INCLUDES = -I$(TOP)/include
   CXXSTD_DEFINES = -Dlinux -D__i386__ -D_ALL_SOURCE
       CXXOPTIONS =
      CXXINCLUDES = $(INCLUDES) $(TOP_INCLUDES) $(CXXEXTRA_INCLUDES) $(CXXIDL_INCLUDES)
       CXXDEFINES = $(CXXINCLUDES) $(CXXSTD_DEFINES) $(THREADS_CXXDEFINES) $(CXXEXTRA_DEFINES)
         CXXFLAGS = $(CXXDEBUGFLAGS) $(CXXOPTIONS) $(THREADS_CXXFLAGS) $(CXXDEFINES)

         COMPRESS = compress
              CPP = /lib/cpp $(STD_CPP_DEFINES)
    PREPROCESSCMD = gcc -E $(STD_CPP_DEFINES)
          INSTALL = install
     INSTALLFLAGS = -c
               LD = ld
              LEX = flex -l
           LEXLIB = -lfl
             YACC = bison -y
           CCYACC = bison -y
             LINT = lint
      LINTLIBFLAG = -C
         LINTOPTS = -axz
               LN = ln -s
             MAKE = make
               MV = mv
               CP = cp

           RANLIB = ranlib
  RANLIBINSTFLAGS =

               RM = rm -f
        MANSUFFIX = 1x
     LIBMANSUFFIX = X
    FILEMANSUFFIX = 5x
            TROFF = psroff
         MSMACROS = -ms
              TBL = tbl
              EQN = eqn

            DVIPS = dvips
            LATEX = latex

     STD_INCLUDES =
  STD_CPP_DEFINES = -traditional -Dlinux -D__i386__ -D_ALL_SOURCE
      STD_DEFINES = -Dlinux -D__i386__ -D_ALL_SOURCE
 EXTRA_LOAD_FLAGS = -Wl,-rpath,/usr/X11R6/lib
  EXTRA_LDOPTIONS =
  EXTRA_LIBRARIES =
             TAGS = ctags

    SHAREDCODEDEF =
         SHLIBDEF =

     SHLIBLDFLAGS = -shared

         PICFLAGS = -fPIC

      CXXPICFLAGS = -fPIC

    PROTO_DEFINES = -DFUNCPROTO=15 -DNARROWPROTO

     INSTPGMFLAGS = -s

     INSTBINFLAGS = -m 0755
     INSTUIDFLAGS = -s -m 4755
     INSTLIBFLAGS = -m 0644
     INSTINCFLAGS = -m 0444
     INSTMANFLAGS = -m 0444
     INSTDATFLAGS = -m 0444
    INSTKMEMFLAGS = -s -m 4755

      PROJECTROOT = /usr/X11R6

     TOP_INCLUDES = -I$(INCROOT)

      CDEBUGFLAGS = -O
        CCOPTIONS = -ansi -fcommon

      ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES)
       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(THREADS_DEFINES) $(DEFINES)
           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(THREADS_CFLAGS) $(ALLDEFINES)
        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES) $(DEPEND_DEFINES)
         LDPRELIB = -L$(SHLIBDIR)
        LDPOSTLIB =
        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS)  $(EXTRA_LDOPTIONS) $(THREADS_LDFLAGS) $(LOCAL_LDFLAGS) $(LDPRELIB)
     CXXLDOPTIONS = $(CXXDEBUGFLAGS) $(CXXOPTIONS) $(EXTRA_LDOPTIONS) $(THREADS_CXXLDFLAGS) $(LOCAL_LDFLAGS) $(LDPRELIB)

           LDLIBS = $(LDPOSTLIB) $(THREADS_LIBS) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)

           CCLINK = $(CC)

          CXXLINK = $(CXX)

     LDSTRIPFLAGS = -x
   LDCOMBINEFLAGS = -r
      DEPENDFLAGS =

        MACROFILE = linux.cf
           RM_CMD = $(RM)

    IMAKE_DEFINES =

         IRULESRC = $(CONFIGDIR)
        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)

     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Project.tmpl 			$(IRULESRC)/site.def $(IRULESRC)/$(MACROFILE) 			$(IRULESRC)/xfree86.cf $(IRULESRC)/xf86.rules $(IRULESRC)/xf86site.def $(IRULESRC)/host.def $(EXTRA_ICONFIGFILES)

#   $RCSfile: Motif.rules,v $ $Revision: 1.5.233.3 $ $Date: 1994/07/15 14:36:58 $

# ----------------------------------------------------------------------
# X Window System Build Parameters and Rules
# $XConsortium: Project.tmpl,v 1.249 95/05/23 21:36:40 matt Exp $
# $XFree86: xc/config/cf/Project.tmpl,v 3.18 1995/07/22 04:11:42 dawes Exp $

# -----------------------------------------------------------------------
# X Window System make variables; these need to be coordinated with rules

           BINDIR = /usr/X11R6/bin
     BUILDINCROOT = $(TOP)
      BUILDINCDIR = $(BUILDINCROOT)/X11
      BUILDINCTOP = ..
      BUILDLIBDIR = $(TOP)/usrlib
      BUILDLIBTOP = ..
           INCDIR = $(INCROOT)/X11
           ADMDIR = /usr/adm
           LIBDIR = /usr/X11R6/lib/X11

          FONTDIR = $(LIBDIR)/fonts
         XINITDIR = /etc/X11/xinit
           XDMDIR = /etc/X11/xdm
           TWMDIR = $(LIBDIR)/twm
           XSMDIR = $(LIBDIR)/xsm
           NLSDIR = $(LIBDIR)/nls
       XLOCALEDIR = $(LIBDIR)/locale
        PEXAPIDIR = $(LIBDIR)/PEX
      XAPPLOADDIR = $(LIBDIR)/app-defaults
       FONTCFLAGS = -t

     INSTAPPFLAGS = $(INSTDATFLAGS)

              RGB = rgb
            FONTC = bdftopcf
        MKFONTDIR = mkfontdir

       DOCUTILSRC = $(TOP)/doc/util
       XDOCMACROS = $(DOCUTILSRC)/macros.t
       XIDXMACROS = $(DOCUTILSRC)/indexmacros.t
       PROGRAMSRC = $(TOP)/programs
           LIBSRC = $(TOP)/lib
          FONTSRC = $(TOP)/fonts
       INCLUDESRC = $(TOP)/X11
        SERVERSRC = $(TOP)/programs/Xserver
       CONTRIBSRC = $(TOP)/../contrib
   UNSUPPORTEDSRC = $(TOP)/unsupported
           DOCSRC = $(TOP)/doc
           RGBSRC = $(TOP)/programs/rgb
      BDFTOPCFSRC = $(PROGRAMSRC)/bdftopcf
     MKFONTDIRSRC = $(PROGRAMSRC)/mkfontdir
    FONTSERVERSRC = $(PROGRAMSRC)/xfs
       FONTINCSRC = $(TOP)/include/fonts
        EXTINCSRC = $(TOP)/include/extensions
     TRANSCOMMSRC = $(LIBSRC)/xtrans
   TRANS_INCLUDES = -I$(TRANSCOMMSRC)

# $XConsortium: lnxLib.tmpl,v 1.5 95/01/11 21:44:44 kaleb Exp $
# $XFree86: xc/config/cf/lnxLib.tmpl,v 3.7 1995/04/09 13:39:23 dawes Exp $

          XLIBSRC = $(LIBSRC)/X11

SOXLIBREV = 6.0
DEPXONLYLIB =
XONLYLIB =  -lX11

LINTXONLY = $(LINTLIBDIR)/llib-lX11.ln

         XLIBONLY = $(XONLYLIB)

      XEXTLIBSRC = $(LIBSRC)/Xext
   LBXXEXTLIBSRC = $(TOP)/workInProgress/lbx/lib/Xext

    XEXEXTLIBSRC = $(LIBSRC)/XExExt

SOXEXTREV = 6.0
DEPXEXTLIB =
XEXTLIB =  -lXext

LINTXEXT = $(LINTLIBDIR)/llib-lXext.ln

SOXEXTREV = 6.0
DEPLBXXEXTLIB =
LBXXEXTLIB =  -llbxXext

LINTLBXXEXT = $(LINTLIBDIR)/llib-llbxXext.ln

DEPXEXEXTLIB = $(USRLIBDIR)/libXExExt.a
XEXEXTLIB =  -lXExExt

LINTXEXEXT = $(LINTLIBDIR)/llib-lXExExt.ln

     EXTENSIONLIB = $(XEXEXTLIB) $(XEXTLIB)
  DEPEXTENSIONLIB = $(DEPXEXEXTLIB) $(DEPXEXTLIB)
    LINTEXTENSION = $(LINTXEXEXT) $(LINTXEXT)

 LINTEXTENSIONLIB = $(LINTEXTENSION)
          DEPXLIB = $(DEPEXTENSIONLIB) $(DEPXONLYLIB)
             XLIB = $(EXTENSIONLIB) $(XONLYLIB)
         LINTXLIB = $(LINTXONLYLIB)

         XAUTHSRC = $(LIBSRC)/Xau

DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
XAUTHLIB =  -lXau

LINTXAUTH = $(LINTLIBDIR)/llib-lXau.ln

      XDMCPLIBSRC = $(LIBSRC)/Xdmcp

DEPXDMCPLIB = $(USRLIBDIR)/libXdmcp.a
XDMCPLIB =  -lXdmcp

LINTXDMCP = $(LINTLIBDIR)/llib-lXdmcp.ln

           XMUSRC = $(LIBSRC)/Xmu

SOXMUREV = 6.0
DEPXMULIB =
XMULIB =  -lXmu

LINTXMU = $(LINTLIBDIR)/llib-lXmu.ln

       OLDXLIBSRC = $(LIBSRC)/oldX

DEPOLDXLIB = $(USRLIBDIR)/liboldX.a
OLDXLIB =  -loldX

LINTOLDX = $(LINTLIBDIR)/llib-loldX.ln

       TOOLKITSRC = $(LIBSRC)/Xt

SOXTREV = 6.0
DEPXTOOLONLYLIB =
XTOOLONLYLIB =  -lXt

LINTXTOOLONLY = $(LINTLIBDIR)/llib-lXt.ln

      DEPXTOOLLIB = $(DEPXTOOLONLYLIB) $(DEPSMLIB) $(DEPICELIB)
         XTOOLLIB = $(XTOOLONLYLIB) $(SMLIB) $(ICELIB)
     LINTXTOOLLIB = $(LINTXTOOLONLYLIB)

       AWIDGETSRC = $(LIBSRC)/Xaw

SOXAWREV = 6.0
DEPXAWLIB =
XAWLIB =  -lXaw

LINTXAW = $(LINTLIBDIR)/llib-lXaw.ln

       XTFSRC = $(TOP)/workInProgress/Xtf

DEPXTFLIB = $(USRLIBDIR)/libXtf.a
XTFLIB =  -lXtf

LINTXTF = $(LINTLIBDIR)/llib-lXtf.ln

       FRESCOSRC = $(TOP)/workInProgress/Fresco

DEPFRESCOLIB = $(USRLIBDIR)/libFresco.a
FRESCOLIB =  -lFresco

LINTFRESCO = $(LINTLIBDIR)/llib-lFresco.ln

         XILIBSRC = $(LIBSRC)/Xi

SOXINPUTREV = 6.0
DEPXILIB =
XILIB =  -lXi

LINTXI = $(LINTLIBDIR)/llib-lXi.ln

      XTESTLIBSRC = $(LIBSRC)/Xtst

SOXTESTREV = 6.0
DEPXTESTLIB =
XTESTLIB =  -lXtst

LINTXTEST = $(LINTLIBDIR)/llib-lXtst.ln

        PEXLIBSRC = $(LIBSRC)/PEX5

SOPEXREV = 6.0
DEPPEXLIB =
PEXLIB =  -lPEX5

LINTPEX = $(LINTLIBDIR)/llib-lPEX5.ln

        XIELIBSRC = $(LIBSRC)/XIE

SOXIEREV = 6.0
DEPXIELIB =
XIELIB =  -lXIE

LINTXIE = $(LINTLIBDIR)/llib-lXIE.ln

      PHIGSLIBSRC = $(LIBSRC)/PHIGS

DEPPHIGSLIB = $(USRLIBDIR)/libphigs.a
PHIGSLIB =  -lphigs

LINTPHIGS = $(LINTLIBDIR)/llib-lphigs.ln

DEPXBSDLIB = $(USRLIBDIR)/libXbsd.a
XBSDLIB =  -lXbsd

LINTXBSD = $(LINTLIBDIR)/llib-lXbsd.ln

           ICESRC = $(LIBSRC)/ICE

SOICEREV = 6.0
DEPICELIB =
ICELIB =  -lICE

LINTICE = $(LINTLIBDIR)/llib-lICE.ln

            SMSRC = $(LIBSRC)/SM

SOSMREV = 6.0
DEPSMLIB =
SMLIB =  -lSM

LINTSM = $(LINTLIBDIR)/llib-lSM.ln

         FSLIBSRC = $(LIBSRC)/FS

DEPFSLIB = $(USRLIBDIR)/libFS.a
FSLIB =  -lFS

LINTFS = $(LINTLIBDIR)/llib-lFS.ln

         FONTLIBSRC = $(LIBSRC)/font

DEPFONTLIB = $(USRLIBDIR)/libfont.a
FONTLIB =  -lfont

LINTFONT = $(LINTLIBDIR)/llib-lfont.ln

          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)

         DEPLIBS1 = $(DEPLIBS)
         DEPLIBS2 = $(DEPLIBS)
         DEPLIBS3 = $(DEPLIBS)

#   $RCSfile: Motif.tmpl,v $ $Revision: 1.5.332.3 $ $Date: 1994/07/06 14:56:17 $

          SOXMREV = 2.0
         SOMRMREV = 2.0
         SOUILREV = 2.0
     SOACOMMONREV = 2.0
      SOSCRIPTREV = 2.0
        SOUTILREV = 2.0
      SOCREATEREV = 2.0
      SOVISUALREV = 2.0
       SOSYNTHREV = 2.0
     SOMCOMMONREV = 2.0

              XTOP = $(TOP)
              MTOP = $(TOP)
     XBUILDINCROOT = $(XTOP)
      XBUILDINCDIR = $(XBUILDINCROOT)/X11

	IMAKE_CMD = $(IMAKE) -DUseInstalled -DUseInstalledMotif -I$(IRULESRC) $(IMAKE_DEFINES)

         CLIENTSRC = $(XTOP)/clients
           DEMOSRC = $(XTOP)/demos
            LIBSRC = $(XTOP)/lib
           FONTSRC = $(XTOP)/fonts
        INCLUDESRC = $(XTOP)/X11
         SERVERSRC = $(XTOP)/server
           UTILSRC = $(XTOP)/util
        EXAMPLESRC = $(XTOP)/examples
            DOCSRC = $(XTOP)/doc
            RGBSRC = $(XTOP)/rgb
      EXTENSIONSRC = $(XTOP)/extensions

      TOP_INCLUDES = -I$(INCROOT)

      UIL_INCLUDES = -I$(USRINCDIR)/uil

     XPM_DEFINES =

     XPM_TOP = $(XTOP)

     XPM_INCLUDES	= -I$(INCDIR)

     XPM_LIBS		= -lXpm

      USRINCDIR = /usr/X11R6/include
         UIDDIR = $(LIBDIR)/uid
        TESTSRC = $(MTOP)/tests
        TESTLIB = $(TESTSRC)/lib
  GENERALSRCLIB = $(TESTSRC)/General/lib
  GENERALSRCBIN = $(TESTSRC)/General/bin
   MANUALSRCLIB = $(TESTSRC)/Manual/lib
   MANUALSRCBIN = $(TESTSRC)/Manual/bin
     AUTOSRCLIB = $(TESTSRC)/Auto/lib
     AUTOSRCBIN = $(TESTSRC)/Auto/bin
       COMMONPP = $(GENERALSRCBIN)/Commonpp
         GENRUN = $(GENERALSRCBIN)/Genrun
         MANRUN = $(GENERALSRCBIN)/Manrun

     TESTCOMSRC = $(MANUALSRCLIB)/Common

    MTOOLKITSRC = $(TOOLKITSRC)
    MINCLUDESRC = $(MTOP)/X11
#MINCLUDESRC = $(INCDIR)
        MLIBSRC = $(MTOP)/lib
#MLIBSRC = $(USRLIBDIR)
     MCLIENTSRC = $(MTOP)/clients
       MDEMOSRC = $(MTOP)/demos
     MWIDGETSRC = $(MLIBSRC)/Xm
#MWIDGETSRC = $(USRLIBDIR)/Xm
   MRESOURCESRC = $(MLIBSRC)/Mrm
#MRESOURCESRC = $(USRLIBDIR)/Mrm
         UILSRC = $(MCLIENTSRC)/uil

            UIL = uil
         DEPUIL =

   XMEXTRA_LIBS =

SOXMREV = 2.0
DEPXMLIBONLYLIB =
XMLIBONLYLIB =  -lXm

LINTXMLIBONLY = $(LINTLIBDIR)/llib-lXm.ln

   XMLIB = $(XMLIBONLYLIB) $(XPM_LIBS)
   DEPXMLIB = $(DEPXMLIBONLYLIB)

SOMRMREV = 2.0
DEPMRESOURCELIB =
MRESOURCELIB =  -lMrm

LINTMRESOURCE = $(LINTLIBDIR)/llib-lMrm.ln

SOUILREV = 2.0
DEPUILLIB =
UILLIB =  -lUil

LINTUIL = $(LINTLIBDIR)/llib-lUil.ln

SOMCOMMONREV = 2.0
DEPTESTCOMLIB =
TESTCOMLIB =  -lCommon

LINTTESTCOM = $(LINTLIBDIR)/llib-lCommon.ln

TESTUILCOMLIB = $(TESTCOMSRC)/libCommonUil.a

  LINTMRESOURCE = $(MRESOURCESRC)/libMrm.a
LINTXMWIDGETLIB = $(MWIDGETSRC)/llib-l/Xm.ln
     LINTXMTOOL = $(MTOOLKITSRC)/llib-lXt.ln
     LINTUILLIB = $(UILSRC)/llib-lUil.ln

      YACCFLAGS =
       UILFLAGS =

         RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut  *.Dat

    STD_DEFINES = -Dlinux -D__i386__ -D_ALL_SOURCE  -DNO_MESSAGE_CATALOG

        DEPLIBS = $(DEPXMLIB) $(DEPXTOOLLIB) $(DEPXLIB)

        DEPLIBS1 = $(DEPLIBS)
        DEPLIBS2 = $(DEPLIBS)
        DEPLIBS3 = $(DEPLIBS)

.SUFFIXES: .o .c .cc .C .cxx

        CPLUSPLUSCOM = CC

        CPLUSPLUSLINKCOM = $(CPLUSPLUSCOM)

        STD_CPLUSPLUS_INCLUDES = $(STD_INCLUDES)

      ALLCPLUSPLUSINCLUDES = 	$(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) 	$(STD_CPLUSPLUS_INCLUDES)

        STD_CPLUSPLUS_DEFINES = $(STD_DEFINES)

       ALLCPLUSPLUSDEFINES = 	$(ALLCPLUSPLUSINCLUDES) $(STD_CPLUSPLUS_DEFINES) $(EXTRA_DEFINES) 	$(PROTO_DEFINES) $(DEFINES)

       CPLUSPLUSFLAGS = $(CDEBUGFLAGS) $(ALLCPLUSPLUSDEFINES)

       CPLUSPLUSLIBS =

XMULIBONLY = -lXmu
XMULIB = $(XMULIBONLY) $(XTOOLLIB) $(XLIB)

        CONFIGDIR = $(LIBDIR)/config

# -----------------------------------------------------------------------
# start of Imakefile

# Simple Imakefile, courtesy of Robert Withrow.  Use xmkmf to make the
# Makefile.

RELEASE = 1.0

EXTRA_INCLUDES = -I$(TOP) -I.

HEADERS = ControlP.h Xc.h BarGraf.h Value.h	Control.h BarGrafP.h ValueP.h

SRCS = Control.c Value.c BarGraf.c
OBJS = Control.o Value.o BarGraf.o

DEPXCLIB = libXc.a
XCLIB = -lXc
LOCAL_LDFLAGS = -L$(TOP)
LOCAL_LIBS = $(XCLIB) $(XAWLIB) $(XMULIBONLY) $(XTOOLLIB) $(XLIB)

# Here we must protect against different linking semantics...

all:: libXc.a

libXc.a: $(OBJS)
	$(RM) $@
	$(AR) $@ $(OBJS)
	$(RANLIB) $@
	$(_NULLCMD_)

install:: libXc.a
	@if [ -d $(DESTDIR)$(USRLIBDIR) ]; then set +x; \
	else (set -x; $(MKDIRHIER) $(DESTDIR)$(USRLIBDIR)); fi
	$(INSTALL) $(INSTALLFLAGS) $(INSTLIBFLAGS) libXc.a $(DESTDIR)$(USRLIBDIR)
	$(RANLIB) $(RANLIBINSTFLAGS) $(DESTDIR)$(USRLIBDIR)/libXc.a

includes::
	@if [ -d $(BUILDINCDIR)/Xc ]; then set +x; \
	else (set -x; $(MKDIRHIER) $(BUILDINCDIR)/Xc); fi
	@(set -x; cd $(BUILDINCDIR)/Xc; for i in $(HEADERS); do \
	$(RM) $$i; \
	$(LN) $(BUILDINCTOP)/../$(CURRENT_DIR)/$$i .; \
	done)

install:: $(HEADERS)
	@if [ -d $(DESTDIR)$(INCDIR)/Xc ]; then set +x; \
	else (set -x; $(MKDIRHIER) $(DESTDIR)$(INCDIR)/Xc); fi
	@case '${MFLAGS}' in *[i]*) set +e;; esac; \
	for i in $(HEADERS); do \
	(set -x; $(INSTALL) $(INSTALLFLAGS) $(INSTDATFLAGS) $$i $(DESTDIR)$(INCDIR)/Xc); \
	done

# clean::
#	$(RM) -r $(TOP)/X11

World::
	@echo ""
	@echo "Building Release "$(RELEASE)" of the Xc Widget Set"
	@echo ""
	$(MAKE) clean
	$(MAKE) includes
	$(MAKE) depend
	$(MAKE) $(WORLDOPTS)

depend::
	$(DEPEND) $(DEPENDFLAGS) -- $(ALLDEFINES) $(DEPEND_DEFINES) -- $(SRCS)

# -----------------------------------------------------------------------
# common rules for all Makefiles - do not edit

.c.i:
	$(RM) $@
	$(CC) -E $(CFLAGS) $(_NOOP_) $*.c > $@

emptyrule::

clean::
	$(RM_CMD) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut  "#"*

Makefile::
	-@if [ -f Makefile ]; then set -x; \
	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
	else exit 0; fi
	$(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)

tags::
	$(TAGS) -w *.[ch]
	$(TAGS) -xw *.[ch] > TAGS

# -----------------------------------------------------------------------
# empty rules for directories that do not have SUBDIRS - do not edit

install::
	@echo "install in $(CURRENT_DIR) done"

install.man::
	@echo "install.man in $(CURRENT_DIR) done"

install.linkkit::
	@echo "install.linkkit in $(CURRENT_DIR) done"

Makefiles::

includes::

depend::

# -----------------------------------------------------------------------
# dependencies generated by makedepend

DEPUILLIB =
UIxscrabble/Imakefile100600 000310 000001 00000000327 06311172015 015527 0ustar00mchapmanstaff000000 000000 
#define PassCDebugFlags 'CDEBUGFLAGS= -O'
#define IHaveSubdirs

SUBDIRS = Xc src

MakeSubdirs($(SUBDIRS))
DependSubdirs($(SUBDIRS))
MakeLintLibSubdirs($(SUBDIRS))
MakeLintSubdirs($(SUBDIRS),install.ln,install.ln)

Value.c.origutaÐt½Value.hät¾ValueP.htÌôt¿Xc.hintÀ	BarGraf.cobtÁ	BarGraf.h0tÂ
BarGrafP.h°tÃMakefilexscrabble/Makefile100600 000310 000001 00000051226 06311435227 015371 0ustar00mchapmanstaff000000 000000 # Makefile generated by imake - do not edit!
# $XConsortium: imake.c,v 1.91 95/01/12 16:15:47 kaleb Exp $

# ----------------------------------------------------------------------
# Makefile generated from "Imake.tmpl" and <Imakefile>
# $XConsortium: Imake.tmpl,v 1.224.1.1 95/06/19 17:51:01 gildea Exp $
# $XFree86: xc/config/cf/Imake.tmpl,v 3.18 1995/07/12 15:27:23 dawes Exp $
#

.SUFFIXES: .i

# $XConsortium: Imake.cf,v 1.19 95/01/05 19:24:32 kaleb Exp $
# $XFree86: xc/config/cf/Imake.cf,v 3.15 1995/06/08 06:18:39 dawes Exp $

# -----------------------------------------------------------------------
# site-specific configuration parameters that need to come before
# the platform-specific parameters - edit site.def to change

# site:  $XConsortium: site.sample,v 1.9 94/04/08 17:02:06 rws Exp $
# site:  $XFree86: xc/config/cf/site.def,v 3.8 1995/05/27 01:56:50 dawes Exp $

MOTIFLIBINSTALLDIR = /usr/pkg/motif-2.0/X11R6/lib
MOTIFSHLIBINSTALLDIR = /usr/pkg/motif-2.0/X11R6/lib
MOTIFBININSTALLDIR = /usr/pkg/motif-2.0/X11R6/bin

# $XFree86: xc/config/cf/xf86site.def,v 3.48 1995/07/22 04:11:45 dawes Exp $

# -----------------------------------------------------------------------
# platform-specific configuration parameters - edit linux.cf to change

# platform:  $XConsortium: linux.cf,v 1.11 95/01/23 18:32:03 kaleb Exp $
# platform:  $XFree86: xc/config/cf/linux.cf,v 3.26 1995/07/12 15:27:34 dawes Exp $

# $XConsortium: lnxLib.rules,v 1.8 95/01/16 21:11:00 kaleb Exp $
# $XFree86: xc/config/cf/lnxLib.rules,v 3.14 1995/06/01 08:18:56 dawes Exp $

# $XConsortium: xfree86.cf,v 1.9 95/01/25 16:42:40 kaleb Exp $
# $XFree86: xc/config/cf/xfree86.cf,v 3.66 1995/07/22 04:11:47 dawes Exp $

LINKKITDIR = $(USRLIBDIR)/Server

       XF86SRC = $(SERVERSRC)/hw/xfree86
  XF86ACCELSRC = $(XF86SRC)/accel
    XF86COMSRC = $(XF86SRC)/common
 XF86CONFIGSRC = $(XF86COMSRC)
     XF86HWSRC = $(XF86SRC)/common_hw
     XF86OSSRC = $(XF86SRC)/os-support
  VGADRIVERSRC = $(XF86SRC)/vga256/drivers
VGA16DRIVERSRC = $(XF86SRC)/vga16/drivers
 VGA2DRIVERSRC = $(XF86SRC)/vga2/drivers
 MONODRIVERSRC = $(XF86SRC)/mono/drivers
   S3DRIVERSRC = $(XF86SRC)/accel/s3/drivers

        XFREE86DOCDIR = /usr/X11R6/doc/XFree86
      XFREE86PSDOCDIR = $(XFREE86DOCDIR)
    XFREE86HTMLDOCDIR = /usr/X11R6/html/XFree86
XFREE86JAPANESEDOCDIR = $(XFREE86DOCDIR)/Japanese

# $XConsortium: xf86.rules,v 1.7 95/01/25 16:34:39 kaleb Exp $
# $XFree86: xc/config/cf/xf86.rules,v 3.9 1995/07/12 15:27:38 dawes Exp $

# -----------------------------------------------------------------------
# site-specific configuration parameters that go after
# the platform-specific parameters - edit site.def to change

# site:  $XConsortium: site.sample,v 1.9 94/04/08 17:02:06 rws Exp $
# site:  $XFree86: xc/config/cf/site.def,v 3.8 1995/05/27 01:56:50 dawes Exp $

# -----------------------------------------------------------------------
# Imake rules for building libraries, programs, scripts, and data files
# rules:  $XConsortium: Imake.rules,v 1.197.1.1 95/06/19 18:01:48 gildea Exp $
# rules:  $XFree86: xc/config/cf/Imake.rules,v 3.18 1995/07/22 09:39:32 dawes Exp $

 _NULLCMD_ = @ echo -n

          PATHSEP = /
            SHELL = /bin/sh

              TOP = .
      CURRENT_DIR = .

            IMAKE = imake
           DEPEND = gccmakedep
        MKDIRHIER = mkdir -p
        CONFIGSRC = $(TOP)/config
         IMAKESRC = $(CONFIGSRC)/imake
        DEPENDSRC = $(CONFIGSRC)/util
           IXXSRC = $(UNSUPPORTEDSRC)/programs/ixx
              IXX = ixx
         IXXFLAGS = -s BaseObject -m TypeObj -r RequestObj -p Xf
      IXXINCLUDES = -i '<X11/Fresco/enter-scope.h>'

          INCROOT = /usr/X11R6/include
        USRLIBDIR = /usr/pkg/gcc/lib
         SHLIBDIR = /usr/X11R6/lib
       LINTLIBDIR = $(USRLIBDIR)/lint
          MANPATH = /usr/X11R6/man
    MANSOURCEPATH = $(MANPATH)/man
           MANDIR = $(MANSOURCEPATH)1
        LIBMANDIR = $(MANSOURCEPATH)X
       FILEMANDIR = $(MANSOURCEPATH)5

               AR = ar clq
  BOOTSTRAPCFLAGS =
               CC = gcc
               AS = as

.SUFFIXES: .cxx

              CXX = g++
    CXXDEBUGFLAGS = -O
 CXXEXTRA_DEFINES =
CXXEXTRA_INCLUDES =
  CXXIDL_INCLUDES = -I$(TOP)/include
   CXXSTD_DEFINES = -Dlinux -D__i386__ -D_ALL_SOURCE
       CXXOPTIONS =
      CXXINCLUDES = $(INCLUDES) $(TOP_INCLUDES) $(CXXEXTRA_INCLUDES) $(CXXIDL_INCLUDES)
       CXXDEFINES = $(CXXINCLUDES) $(CXXSTD_DEFINES) $(THREADS_CXXDEFINES) $(CXXEXTRA_DEFINES)
         CXXFLAGS = $(CXXDEBUGFLAGS) $(CXXOPTIONS) $(THREADS_CXXFLAGS) $(CXXDEFINES)

         COMPRESS = compress
              CPP = /lib/cpp $(STD_CPP_DEFINES)
    PREPROCESSCMD = gcc -E $(STD_CPP_DEFINES)
          INSTALL = install
     INSTALLFLAGS = -c
               LD = ld
              LEX = flex -l
           LEXLIB = -lfl
             YACC = bison -y
           CCYACC = bison -y
             LINT = lint
      LINTLIBFLAG = -C
         LINTOPTS = -axz
               LN = ln -s
             MAKE = make
               MV = mv
               CP = cp

           RANLIB = ranlib
  RANLIBINSTFLAGS =

               RM = rm -f
        MANSUFFIX = 1x
     LIBMANSUFFIX = X
    FILEMANSUFFIX = 5x
            TROFF = psroff
         MSMACROS = -ms
              TBL = tbl
              EQN = eqn

            DVIPS = dvips
            LATEX = latex

     STD_INCLUDES =
  STD_CPP_DEFINES = -traditional -Dlinux -D__i386__ -D_ALL_SOURCE
      STD_DEFINES = -Dlinux -D__i386__ -D_ALL_SOURCE
 EXTRA_LOAD_FLAGS = -Wl,-rpath,/usr/X11R6/lib
  EXTRA_LDOPTIONS =
  EXTRA_LIBRARIES =
             TAGS = ctags

    SHAREDCODEDEF =
         SHLIBDEF =

     SHLIBLDFLAGS = -shared

         PICFLAGS = -fPIC

      CXXPICFLAGS = -fPIC

    PROTO_DEFINES = -DFUNCPROTO=15 -DNARROWPROTO

     INSTPGMFLAGS = -s

     INSTBINFLAGS = -m 0755
     INSTUIDFLAGS = -s -m 4755
     INSTLIBFLAGS = -m 0644
     INSTINCFLAGS = -m 0444
     INSTMANFLAGS = -m 0444
     INSTDATFLAGS = -m 0444
    INSTKMEMFLAGS = -s -m 4755

      PROJECTROOT = /usr/X11R6

     TOP_INCLUDES = -I$(INCROOT)

      CDEBUGFLAGS = -O
        CCOPTIONS = -ansi -fcommon

      ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES)
       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(THREADS_DEFINES) $(DEFINES)
           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(THREADS_CFLAGS) $(ALLDEFINES)
        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES) $(DEPEND_DEFINES)
         LDPRELIB = -L$(SHLIBDIR)
        LDPOSTLIB =
        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS)  $(EXTRA_LDOPTIONS) $(THREADS_LDFLAGS) $(LOCAL_LDFLAGS) $(LDPRELIB)
     CXXLDOPTIONS = $(CXXDEBUGFLAGS) $(CXXOPTIONS) $(EXTRA_LDOPTIONS) $(THREADS_CXXLDFLAGS) $(LOCAL_LDFLAGS) $(LDPRELIB)

           LDLIBS = $(LDPOSTLIB) $(THREADS_LIBS) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)

           CCLINK = $(CC)

          CXXLINK = $(CXX)

     LDSTRIPFLAGS = -x
   LDCOMBINEFLAGS = -r
      DEPENDFLAGS =

        MACROFILE = linux.cf
           RM_CMD = $(RM)

    IMAKE_DEFINES =

         IRULESRC = $(CONFIGDIR)
        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)

     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Project.tmpl 			$(IRULESRC)/site.def $(IRULESRC)/$(MACROFILE) 			$(IRULESRC)/xfree86.cf $(IRULESRC)/xf86.rules $(IRULESRC)/xf86site.def $(IRULESRC)/host.def $(EXTRA_ICONFIGFILES)

#   $RCSfile: Motif.rules,v $ $Revision: 1.5.233.3 $ $Date: 1994/07/15 14:36:58 $

# ----------------------------------------------------------------------
# X Window System Build Parameters and Rules
# $XConsortium: Project.tmpl,v 1.249 95/05/23 21:36:40 matt Exp $
# $XFree86: xc/config/cf/Project.tmpl,v 3.18 1995/07/22 04:11:42 dawes Exp $

# -----------------------------------------------------------------------
# X Window System make variables; these need to be coordinated with rules

           BINDIR = /usr/X11R6/bin
     BUILDINCROOT = $(TOP)
      BUILDINCDIR = $(BUILDINCROOT)/X11
      BUILDINCTOP = ..
      BUILDLIBDIR = $(TOP)/usrlib
      BUILDLIBTOP = ..
           INCDIR = $(INCROOT)/X11
           ADMDIR = /usr/adm
           LIBDIR = /usr/X11R6/lib/X11

          FONTDIR = $(LIBDIR)/fonts
         XINITDIR = /etc/X11/xinit
           XDMDIR = /etc/X11/xdm
           TWMDIR = $(LIBDIR)/twm
           XSMDIR = $(LIBDIR)/xsm
           NLSDIR = $(LIBDIR)/nls
       XLOCALEDIR = $(LIBDIR)/locale
        PEXAPIDIR = $(LIBDIR)/PEX
      XAPPLOADDIR = $(LIBDIR)/app-defaults
       FONTCFLAGS = -t

     INSTAPPFLAGS = $(INSTDATFLAGS)

              RGB = rgb
            FONTC = bdftopcf
        MKFONTDIR = mkfontdir

       DOCUTILSRC = $(TOP)/doc/util
       XDOCMACROS = $(DOCUTILSRC)/macros.t
       XIDXMACROS = $(DOCUTILSRC)/indexmacros.t
       PROGRAMSRC = $(TOP)/programs
           LIBSRC = $(TOP)/lib
          FONTSRC = $(TOP)/fonts
       INCLUDESRC = $(TOP)/X11
        SERVERSRC = $(TOP)/programs/Xserver
       CONTRIBSRC = $(TOP)/../contrib
   UNSUPPORTEDSRC = $(TOP)/unsupported
           DOCSRC = $(TOP)/doc
           RGBSRC = $(TOP)/programs/rgb
      BDFTOPCFSRC = $(PROGRAMSRC)/bdftopcf
     MKFONTDIRSRC = $(PROGRAMSRC)/mkfontdir
    FONTSERVERSRC = $(PROGRAMSRC)/xfs
       FONTINCSRC = $(TOP)/include/fonts
        EXTINCSRC = $(TOP)/include/extensions
     TRANSCOMMSRC = $(LIBSRC)/xtrans
   TRANS_INCLUDES = -I$(TRANSCOMMSRC)

# $XConsortium: lnxLib.tmpl,v 1.5 95/01/11 21:44:44 kaleb Exp $
# $XFree86: xc/config/cf/lnxLib.tmpl,v 3.7 1995/04/09 13:39:23 dawes Exp $

          XLIBSRC = $(LIBSRC)/X11

SOXLIBREV = 6.0
DEPXONLYLIB =
XONLYLIB =  -lX11

LINTXONLY = $(LINTLIBDIR)/llib-lX11.ln

         XLIBONLY = $(XONLYLIB)

      XEXTLIBSRC = $(LIBSRC)/Xext
   LBXXEXTLIBSRC = $(TOP)/workInProgress/lbx/lib/Xext

    XEXEXTLIBSRC = $(LIBSRC)/XExExt

SOXEXTREV = 6.0
DEPXEXTLIB =
XEXTLIB =  -lXext

LINTXEXT = $(LINTLIBDIR)/llib-lXext.ln

SOXEXTREV = 6.0
DEPLBXXEXTLIB =
LBXXEXTLIB =  -llbxXext

LINTLBXXEXT = $(LINTLIBDIR)/llib-llbxXext.ln

DEPXEXEXTLIB = $(USRLIBDIR)/libXExExt.a
XEXEXTLIB =  -lXExExt

LINTXEXEXT = $(LINTLIBDIR)/llib-lXExExt.ln

     EXTENSIONLIB = $(XEXEXTLIB) $(XEXTLIB)
  DEPEXTENSIONLIB = $(DEPXEXEXTLIB) $(DEPXEXTLIB)
    LINTEXTENSION = $(LINTXEXEXT) $(LINTXEXT)

 LINTEXTENSIONLIB = $(LINTEXTENSION)
          DEPXLIB = $(DEPEXTENSIONLIB) $(DEPXONLYLIB)
             XLIB = $(EXTENSIONLIB) $(XONLYLIB)
         LINTXLIB = $(LINTXONLYLIB)

         XAUTHSRC = $(LIBSRC)/Xau

DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
XAUTHLIB =  -lXau

LINTXAUTH = $(LINTLIBDIR)/llib-lXau.ln

      XDMCPLIBSRC = $(LIBSRC)/Xdmcp

DEPXDMCPLIB = $(USRLIBDIR)/libXdmcp.a
XDMCPLIB =  -lXdmcp

LINTXDMCP = $(LINTLIBDIR)/llib-lXdmcp.ln

           XMUSRC = $(LIBSRC)/Xmu

SOXMUREV = 6.0
DEPXMULIB =
XMULIB =  -lXmu

LINTXMU = $(LINTLIBDIR)/llib-lXmu.ln

       OLDXLIBSRC = $(LIBSRC)/oldX

DEPOLDXLIB = $(USRLIBDIR)/liboldX.a
OLDXLIB =  -loldX

LINTOLDX = $(LINTLIBDIR)/llib-loldX.ln

       TOOLKITSRC = $(LIBSRC)/Xt

SOXTREV = 6.0
DEPXTOOLONLYLIB =
XTOOLONLYLIB =  -lXt

LINTXTOOLONLY = $(LINTLIBDIR)/llib-lXt.ln

      DEPXTOOLLIB = $(DEPXTOOLONLYLIB) $(DEPSMLIB) $(DEPICELIB)
         XTOOLLIB = $(XTOOLONLYLIB) $(SMLIB) $(ICELIB)
     LINTXTOOLLIB = $(LINTXTOOLONLYLIB)

       AWIDGETSRC = $(LIBSRC)/Xaw

SOXAWREV = 6.0
DEPXAWLIB =
XAWLIB =  -lXaw

LINTXAW = $(LINTLIBDIR)/llib-lXaw.ln

       XTFSRC = $(TOP)/workInProgress/Xtf

DEPXTFLIB = $(USRLIBDIR)/libXtf.a
XTFLIB =  -lXtf

LINTXTF = $(LINTLIBDIR)/llib-lXtf.ln

       FRESCOSRC = $(TOP)/workInProgress/Fresco

DEPFRESCOLIB = $(USRLIBDIR)/libFresco.a
FRESCOLIB =  -lFresco

LINTFRESCO = $(LINTLIBDIR)/llib-lFresco.ln

         XILIBSRC = $(LIBSRC)/Xi

SOXINPUTREV = 6.0
DEPXILIB =
XILIB =  -lXi

LINTXI = $(LINTLIBDIR)/llib-lXi.ln

      XTESTLIBSRC = $(LIBSRC)/Xtst

SOXTESTREV = 6.0
DEPXTESTLIB =
XTESTLIB =  -lXtst

LINTXTEST = $(LINTLIBDIR)/llib-lXtst.ln

        PEXLIBSRC = $(LIBSRC)/PEX5

SOPEXREV = 6.0
DEPPEXLIB =
PEXLIB =  -lPEX5

LINTPEX = $(LINTLIBDIR)/llib-lPEX5.ln

        XIELIBSRC = $(LIBSRC)/XIE

SOXIEREV = 6.0
DEPXIELIB =
XIELIB =  -lXIE

LINTXIE = $(LINTLIBDIR)/llib-lXIE.ln

      PHIGSLIBSRC = $(LIBSRC)/PHIGS

DEPPHIGSLIB = $(USRLIBDIR)/libphigs.a
PHIGSLIB =  -lphigs

LINTPHIGS = $(LINTLIBDIR)/llib-lphigs.ln

DEPXBSDLIB = $(USRLIBDIR)/libXbsd.a
XBSDLIB =  -lXbsd

LINTXBSD = $(LINTLIBDIR)/llib-lXbsd.ln

           ICESRC = $(LIBSRC)/ICE

SOICEREV = 6.0
DEPICELIB =
ICELIB =  -lICE

LINTICE = $(LINTLIBDIR)/llib-lICE.ln

            SMSRC = $(LIBSRC)/SM

SOSMREV = 6.0
DEPSMLIB =
SMLIB =  -lSM

LINTSM = $(LINTLIBDIR)/llib-lSM.ln

         FSLIBSRC = $(LIBSRC)/FS

DEPFSLIB = $(USRLIBDIR)/libFS.a
FSLIB =  -lFS

LINTFS = $(LINTLIBDIR)/llib-lFS.ln

         FONTLIBSRC = $(LIBSRC)/font

DEPFONTLIB = $(USRLIBDIR)/libfont.a
FONTLIB =  -lfont

LINTFONT = $(LINTLIBDIR)/llib-lfont.ln

          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)

         DEPLIBS1 = $(DEPLIBS)
         DEPLIBS2 = $(DEPLIBS)
         DEPLIBS3 = $(DEPLIBS)

#   $RCSfile: Motif.tmpl,v $ $Revision: 1.5.332.3 $ $Date: 1994/07/06 14:56:17 $

          SOXMREV = 2.0
         SOMRMREV = 2.0
         SOUILREV = 2.0
     SOACOMMONREV = 2.0
      SOSCRIPTREV = 2.0
        SOUTILREV = 2.0
      SOCREATEREV = 2.0
      SOVISUALREV = 2.0
       SOSYNTHREV = 2.0
     SOMCOMMONREV = 2.0

              XTOP = $(TOP)
              MTOP = $(TOP)
     XBUILDINCROOT = $(XTOP)
      XBUILDINCDIR = $(XBUILDINCROOT)/X11

	IMAKE_CMD = $(IMAKE) -DUseInstalled -DUseInstalledMotif -I$(IRULESRC) $(IMAKE_DEFINES)

         CLIENTSRC = $(XTOP)/clients
           DEMOSRC = $(XTOP)/demos
            LIBSRC = $(XTOP)/lib
           FONTSRC = $(XTOP)/fonts
        INCLUDESRC = $(XTOP)/X11
         SERVERSRC = $(XTOP)/server
           UTILSRC = $(XTOP)/util
        EXAMPLESRC = $(XTOP)/examples
            DOCSRC = $(XTOP)/doc
            RGBSRC = $(XTOP)/rgb
      EXTENSIONSRC = $(XTOP)/extensions

      TOP_INCLUDES = -I$(INCROOT)

      UIL_INCLUDES = -I$(USRINCDIR)/uil

     XPM_DEFINES =

     XPM_TOP = $(XTOP)

     XPM_INCLUDES	= -I$(INCDIR)

     XPM_LIBS		= -lXpm

      USRINCDIR = /usr/X11R6/include
         UIDDIR = $(LIBDIR)/uid
        TESTSRC = $(MTOP)/tests
        TESTLIB = $(TESTSRC)/lib
  GENERALSRCLIB = $(TESTSRC)/General/lib
  GENERALSRCBIN = $(TESTSRC)/General/bin
   MANUALSRCLIB = $(TESTSRC)/Manual/lib
   MANUALSRCBIN = $(TESTSRC)/Manual/bin
     AUTOSRCLIB = $(TESTSRC)/Auto/lib
     AUTOSRCBIN = $(TESTSRC)/Auto/bin
       COMMONPP = $(GENERALSRCBIN)/Commonpp
         GENRUN = $(GENERALSRCBIN)/Genrun
         MANRUN = $(GENERALSRCBIN)/Manrun

     TESTCOMSRC = $(MANUALSRCLIB)/Common

    MTOOLKITSRC = $(TOOLKITSRC)
    MINCLUDESRC = $(MTOP)/X11
#MINCLUDESRC = $(INCDIR)
        MLIBSRC = $(MTOP)/lib
#MLIBSRC = $(USRLIBDIR)
     MCLIENTSRC = $(MTOP)/clients
       MDEMOSRC = $(MTOP)/demos
     MWIDGETSRC = $(MLIBSRC)/Xm
#MWIDGETSRC = $(USRLIBDIR)/Xm
   MRESOURCESRC = $(MLIBSRC)/Mrm
#MRESOURCESRC = $(USRLIBDIR)/Mrm
         UILSRC = $(MCLIENTSRC)/uil

            UIL = uil
         DEPUIL =

   XMEXTRA_LIBS =

SOXMREV = 2.0
DEPXMLIBONLYLIB =
XMLIBONLYLIB =  -lXm

LINTXMLIBONLY = $(LINTLIBDIR)/llib-lXm.ln

   XMLIB = $(XMLIBONLYLIB) $(XPM_LIBS)
   DEPXMLIB = $(DEPXMLIBONLYLIB)

SOMRMREV = 2.0
DEPMRESOURCELIB =
MRESOURCELIB =  -lMrm

LINTMRESOURCE = $(LINTLIBDIR)/llib-lMrm.ln

SOUILREV = 2.0
DEPUILLIB =
UILLIB =  -lUil

LINTUIL = $(LINTLIBDIR)/llib-lUil.ln

SOMCOMMONREV = 2.0
DEPTESTCOMLIB =
TESTCOMLIB =  -lCommon

LINTTESTCOM = $(LINTLIBDIR)/llib-lCommon.ln

TESTUILCOMLIB = $(TESTCOMSRC)/libCommonUil.a

  LINTMRESOURCE = $(MRESOURCESRC)/libMrm.a
LINTXMWIDGETLIB = $(MWIDGETSRC)/llib-l/Xm.ln
     LINTXMTOOL = $(MTOOLKITSRC)/llib-lXt.ln
     LINTUILLIB = $(UILSRC)/llib-lUil.ln

      YACCFLAGS =
       UILFLAGS =

         RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut  *.Dat

    STD_DEFINES = -Dlinux -D__i386__ -D_ALL_SOURCE  -DNO_MESSAGE_CATALOG

        DEPLIBS = $(DEPXMLIB) $(DEPXTOOLLIB) $(DEPXLIB)

        DEPLIBS1 = $(DEPLIBS)
        DEPLIBS2 = $(DEPLIBS)
        DEPLIBS3 = $(DEPLIBS)

.SUFFIXES: .o .c .cc .C .cxx

        CPLUSPLUSCOM = CC

        CPLUSPLUSLINKCOM = $(CPLUSPLUSCOM)

        STD_CPLUSPLUS_INCLUDES = $(STD_INCLUDES)

      ALLCPLUSPLUSINCLUDES = 	$(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) 	$(STD_CPLUSPLUS_INCLUDES)

        STD_CPLUSPLUS_DEFINES = $(STD_DEFINES)

       ALLCPLUSPLUSDEFINES = 	$(ALLCPLUSPLUSINCLUDES) $(STD_CPLUSPLUS_DEFINES) $(EXTRA_DEFINES) 	$(PROTO_DEFINES) $(DEFINES)

       CPLUSPLUSFLAGS = $(CDEBUGFLAGS) $(ALLCPLUSPLUSDEFINES)

       CPLUSPLUSLIBS =

XMULIBONLY = -lXmu
XMULIB = $(XMULIBONLY) $(XTOOLLIB) $(XLIB)

        CONFIGDIR = $(LIBDIR)/config

# -----------------------------------------------------------------------
# start of Imakefile

SUBDIRS = Xc src

all::
	@case '${MFLAGS}' in *[ik]*) set +e;; esac; \
	for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo "making" all "in $(CURRENT_DIR)/$$i..."; \
	$(MAKE) $(MFLAGS) 'CDEBUGFLAGS= -O' all); \
	done

depend::
	@case '${MFLAGS}' in *[ik]*) set +e;; esac; \
	for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo "depending" "in $(CURRENT_DIR)/$$i..."; \
	$(MAKE) $(MFLAGS)  depend); \
	done

lintlib::
	@case '${MFLAGS}' in *[ik]*) set +e;; esac; \
	for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo "linting" for lintlib and lintlib "in $(CURRENT_DIR)/$$i..."; \
	$(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) LINTOPTS='$(LINTOPTS)' lintlib); \
	done

install.ln::
	@case '${MFLAGS}' in *[ik]*) set +e;; esac; \
	for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo "linting" for install.ln and install.ln "in $(CURRENT_DIR)/$$i..."; \
	$(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) LINTOPTS='$(LINTOPTS)' install.ln); \
	done

# -----------------------------------------------------------------------
# common rules for all Makefiles - do not edit

.c.i:
	$(RM) $@
	$(CC) -E $(CFLAGS) $(_NOOP_) $*.c > $@

emptyrule::

clean::
	$(RM_CMD) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut  "#"*

Makefile::
	-@if [ -f Makefile ]; then set -x; \
	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
	else exit 0; fi
	$(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)

tags::
	$(TAGS) -w *.[ch]
	$(TAGS) -xw *.[ch] > TAGS

# -----------------------------------------------------------------------
# rules for building in SUBDIRS - do not edit

install::
	@case '${MFLAGS}' in *[ik]*) set +e;; esac; \
	for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo "installing" "in $(CURRENT_DIR)/$$i..."; \
	$(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) install); \
	done

install.man::
	@case '${MFLAGS}' in *[ik]*) set +e;; esac; \
	for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo "installing man pages" "in $(CURRENT_DIR)/$$i..."; \
	$(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) install.man); \
	done

install.linkkit::
	@case '${MFLAGS}' in *[ik]*) set +e;; esac; \
	for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo "installing link kit" "in $(CURRENT_DIR)/$$i..."; \
	$(MAKE) $(MFLAGS) DESTDIR='$(DESTDIR)' install.linkkit); \
	done

clean::
	@case '${MFLAGS}' in *[ik]*) set +e;; esac; \
	for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo "cleaning" "in $(CURRENT_DIR)/$$i..."; \
	$(MAKE) $(MFLAGS) RM_CMD='$(RM_CMD)' clean); \
	done

tags::
	@case '${MFLAGS}' in *[ik]*) set +e;; esac; \
	for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo "tagging" "in $(CURRENT_DIR)/$$i..."; \
	$(MAKE) $(MFLAGS) TAGS='$(TAGS)' tags); \
	done

Makefiles::
	-@case '${MFLAGS}' in *[ik]*) set +e;; esac; \
	case '${MFLAGS}' in *n*) executeit="no";; esac; \
	for i in $(SUBDIRS) ;\
	do \
	case "$(CURRENT_DIR)" in \
	.) curdir= ;; \
	*) curdir=$(CURRENT_DIR)/ ;; \
	esac; \
	echo "making Makefiles in $$curdir$$i..."; \
	itmp="$$i" \
	curtmp="$(CURRENT_DIR)" \
	toptmp=""; \
	case "$$itmp" in \
	../?*) \
	while echo "$$itmp" | grep '^../' > /dev/null;\
	do \
	toptmp="/`basename $$curtmp`$$toptmp"; \
	curtmp="`dirname $$curtmp`"; \
	itmp="`echo $$itmp | sed 's;../;;'`"; \
	done \
	;; \
	./?*) \
	while echo "$$itmp" | grep '^./' > /dev/null;\
	do \
	itmp="`echo $$itmp | sed 's;./;;'`"; \
	done \
	;; \
	esac; \
	case "$$itmp" in \
	*/?*/?*/?*/?*)	newtop=../../../../..;; \
	*/?*/?*/?*)	newtop=../../../..;; \
	*/?*/?*)	newtop=../../..;; \
	*/?*)		newtop=../..;; \
	*)		newtop=..;; \
	esac; \
	newtop="$$newtop$$toptmp"; \
	case "$(TOP)" in \
	/?*) imaketop=$(TOP) \
	imakeprefix= ;; \
	.) imaketop=$$newtop \
	imakeprefix=$$newtop/ ;; \
	*) imaketop=$$newtop/$(TOP) \
	imakeprefix=$$newtop/ ;; \
	esac; \
	cd $$i; \
	if [ $$? = 0 ]; then \
	$(RM) Makefile.bak; \
	if [ -f Makefile ]; then \
	echo "	$(MV) Makefile Makefile.bak"; \
	if [ "$$executeit" != "no" ]; then \
	$(MV) Makefile Makefile.bak; \
	fi; \
	fi; \
	if [ "$$executeit" != "no" ]; then \
	$(IMAKE_CMD) -DTOPDIR=$$imaketop -DCURDIR=$$curdir$$i; \
	fi; \
	$(MAKE) $(MFLAGS) Makefiles; \
	cd $$newtop; \
	fi; \
	done

includes::
	@case '${MFLAGS}' in *[ik]*) set +e;; esac; \
	for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo including "in $(CURRENT_DIR)/$$i..."; \
	$(MAKE) $(MFLAGS)  includes); \
	done

# -----------------------------------------------------------------------
# dependencies generated by makedepend

${MFLAGS}' in *[ik]*) set +e;; esac; \
	for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo "depending" "in $(CURRENT_DIR)/$$i..."; \
	$(MAKE) $(MFLAGS)  depend); \
	done

lintlib::
	@case '${MFLAGS}' in *[ik]*) set +e;; esac; \
	for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo "linting" for lintlib and lintlib "in $(CURRENT_DIR)/$$i..."; \
	$(MAKE) $(MFLAGS) DESTDIR=$(Dxscrabble/X11/040700 000310 000001 00000000000 06304225552 014275 5ustar00mchapmanstaff000000 000000 xscrabble/X11/Xc/040755 000310 000001 00000000000 06304225553 014662 5ustar00mchapmanstaff000000 000000 xscrabble/X11/Xc/ControlP.h120777 000310 000001 00000000000 6312024152 021407 2../../Xc/ControlP.hustar00mchapmanstaff000000 000000 xscrabble/X11/Xc/Xc.h120777 000310 000001 00000000000 6312024152 017033 2../../Xc/Xc.hustar00mchapmanstaff000000 000000 xscrabble/X11/Xc/BarGraf.h120777 000310 000001 00000000000 6312024152 020717 2../../Xc/BarGraf.hustar00mchapmanstaff000000 000000 xscrabble/X11/Xc/Value.h120777 000310 000001 00000000000 6312024152 020237 2../../Xc/Value.hustar00mchapmanstaff000000 000000 xscrabble/X11/Xc/Control.h120777 000310 000001 00000000000 6312024152 021147 2../../Xc/Control.hustar00mchapmanstaff000000 000000 xscrabble/X11/Xc/BarGrafP.h120777 000310 000001 00000000000 6312024152 021157 2../../Xc/BarGrafP.hustar00mchapmanstaff000000 000000 xscrabble/X11/Xc/ValueP.h120777 000310 000001 00000000000 6312024152 020477 2../../Xc/ValueP.hustar00mchapmanstaff000000 000000 xscrabble/README100600 000310 000001 00000003747 06311435161 014613 0ustar00mchapmanstaff000000 000000 
XScrabble - X version of the popular board game, for 1 to 4 players.
**********

To build:
	xmkmf
	make Makefiles
	make

There are two directories of source code. The first to be built is part of
Xc, the Control Panel Widget Set, v 1.3, copyright 1992 by Paul D.
Johnston.  The second is the main XScrabble code. This also contains the
BarGraf widget from the Free Widget Foundation.

If all goes well, you should have two executables, xscrab and xscrabble in
the src/ directory.


To install:

Copy the dictionary "OSPD3.gz", the permutations file
"scrabble_permutations" (needed by the computer player), and the
"xscrabble.scores" file to wherever you wish to install them.  This
last file will need to be writable by anyone who will be able to run
xscrabble, so that the highscores and best goes can be stored.

You then need to rename "XScrabble.ad" to "XScrabble" and place it in
a resource directory, such as /usr/lib/X11/app-defaults/, or your home
directory. You will get the error 'Couldn't find resource file
XScrabble' if this is not done correctly. Now edit the three lines
near the beginning of this file to indicate the location of the three
required files.

Finally put the two executables in a directory contained in your $PATH
variable.


To run:

Simpy type xscrabble. This will bring up the setup box which will allow
you to enter the names and displays and other info for the game to wish
to play. Then click on the Start Game button, (or Load Previous if you're
restarting a game). The main program, xscrab, will then be automatically
called with the appropriate options.

The game is saved after every turn (in "~/.xscrabble.save" of the
person running it) and can be restarted by running xscrabble, entering
exactly the same info, and hitting the Load Previous button.

This was a student project, and there are not likely to be any future
releases.

Have fun,

Matt Chapman.
E-mail: matt@belgarath.demon.co.uk (no longer csuoq@csv.warwick.ac.uk)
Version 1.00. Mar 1997 (original version Nov 1994)

FLAGS}' in *[ik]*) set +exscrabble/src/040700 000310 000001 00000000000 06311435314 014510 5ustar00mchapmanstaff000000 000000 xscrabble/src/CircPerc.c100600 000310 000001 00000035603 06047122456 016362 0ustar00mchapmanstaff000000 000000 #ifndef _HPUX_SOURCE
#define _HPUX_SOURCE
#endif

#include <stdio.h>
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>

#include "CircPercP.h"

#define DEFAULT_LENGTH 75
#define DEFAULT_WIDTH  75

#define offset(field) XtOffsetOf(XfwfCircularPercentageRec, field)

static XtResource resources[] = {
{
  XtNborderColor, XtCBorderColor,
  XtRPixel, sizeof(Pixel),
  offset(circular_percentage.border_color),
  XtRString,
  (XtPointer) "black"
},
{
  XtNinteriorColor, XtCInteriorColor,
  XtRPixel, sizeof(Pixel),
  offset(circular_percentage.interior_color),
  XtRString,
  (XtPointer) "red"
},
{
  XtNcompletedColor, XtCCompletedColor,
  XtRPixel, sizeof(Pixel),
  offset(circular_percentage.completed_color),
  XtRString,
  (XtPointer) "yellow"
},
{
  XtNpercentageCompleted, XtCPercentageCompleted,
  XtRInt, sizeof(int),
  offset(circular_percentage.iPercentageCompleted),
  XtRImmediate, 
  (XtPointer) 0
}
};

#if NeedFunctionPrototypes > 0
static void Initialize(Widget,Widget,ArgList,Cardinal *);
static void Redisplay(Widget,XExposeEvent *);
static void Destroy(Widget);
static void Resize(Widget);
static Boolean SetValues(Widget,Widget,Widget,ArgList,Cardinal *);
static XtGeometryResult QueryGeometry(Widget,
				      XtWidgetGeometry *,
				      XtWidgetGeometry *);
static void MakeGC(XfwfCircularPercentageWidget);
static void RedrawPart(XfwfCircularPercentageWidget, int, int);
#else
static void Initialize();
static void Redisplay();
static void Destroy();
static void Resize();
static Boolean SetValues();
static XtGeometryResult QueryGeometry();
static void MakeGC();
static void RedrawPart();
#endif


XfwfCircularPercentageClassRec xfwfCircularPercentageClassRec = {
    {
    /* core_class fields     */
    /* superclass            */ (WidgetClass) &widgetClassRec,
    /* class_name            */ "XfwfCircularPercentage",
    /* widget_size           */ sizeof(XfwfCircularPercentageRec),
    /* class_initialize      */ NULL,
    /* class_part_initialize */ NULL,
    /* class_inited          */ FALSE,
    /* initialize            */ (XtInitProc) Initialize,
    /* initialize_hook       */ NULL,
    /* realize               */ XtInheritRealize,
    /* actions               */ NULL,
    /* num_actions           */ 0,
    /* resources             */ resources,
    /* num_resources         */ XtNumber(resources),
    /* xrm_class             */ NULLQUARK,
    /* compress_motion       */ TRUE,
    /* compress_exposure     */ XtExposeCompressMultiple,
    /* compress_enterleave   */ TRUE,
    /* visible_interest      */ FALSE,
    /* destroy               */ (XtWidgetProc) Destroy,
    /* resize                */ (XtWidgetProc) Resize,
    /* expose                */ (XtExposeProc) Redisplay,
    /* set_values            */ (XtSetValuesFunc) SetValues,
    /* set_values_hook       */ NULL,
    /* set_values_almost     */ XtInheritSetValuesAlmost,
    /* get_values_hook       */ NULL,
    /* accept_focus          */ NULL,
    /* version               */ XtVersion,
    /* callback_private      */ NULL,
    /* tm_table              */ NULL,
    /* query_geometry        */ (XtGeometryHandler) QueryGeometry,
    /* display_accelerator   */ XtInheritDisplayAccelerator,
    /* extension             */ NULL
    },
    {
    /* extension          */        0
    }
};

WidgetClass xfwfCircularPercentageWidgetClass = (WidgetClass) & xfwfCircularPercentageClassRec;

#if NeedFunctionPrototypes > 0
static void Initialize(Widget treq_widget, 
		       Widget tnew_widget, 
		       ArgList args, 
		       Cardinal *num_args)
#else
static void Initialize(treq_widget,tnew_widget,args,num_args)
Widget treq_widget;
Widget tnew_widget;
ArgList args;
Cardinal *num_args;
#endif
{
   XfwfCircularPercentageWidget new_widget = (XfwfCircularPercentageWidget) tnew_widget; 
   
     Dimension dimWidth, dimHeight;

     dimWidth = DEFAULT_LENGTH;
     dimHeight = DEFAULT_WIDTH;

     if (dimWidth > new_widget -> core.width)
       new_widget -> core.width = dimWidth;
	
     if (dimHeight > new_widget -> core.height)
       new_widget -> core.height = dimHeight;
	

    if (new_widget -> circular_percentage.iPercentageCompleted < 0)
      {
	XtWarning("XfwfCircularPercentage: percentageCompleted resource should have a value between 0 and 10000,\n            (value specified was negative).");
	new_widget -> circular_percentage.iPercentageCompleted = 0;
      }
    else
    if (new_widget -> circular_percentage.iPercentageCompleted > 10000)
      {
	XtWarning("XfwfCircularPercentage: percentageCompleted resource should have a value between 0 and 10000,\n            (value specified was over 10000).");
        new_widget -> circular_percentage.iPercentageCompleted = 10000;
      }

    new_widget -> circular_percentage.gc = None;
}

#if NeedFunctionPrototypes > 0
static void CalculateArcs(XfwfCircularPercentageWidget our_widget, 
			  XArc *arcs, 
			   int iPercentageCompleted)
#else
static void CalculateArcs(our_widget,arcs,iPercentageCompleted)
XfwfCircularPercentageWidget our_widget; 
XArc *arcs; 
int iPercentageCompleted;
#endif
{
  int iXfwfCircularPercentageArc;

  iXfwfCircularPercentageArc = (iPercentageCompleted * 360 * 64) / 10000;

  arcs[0].x = 5 ; 
  arcs[0].y = 5 ;
  arcs[0].width = our_widget -> core.width - arcs[0].x * 2;
  arcs[0].height = our_widget -> core.height - arcs[0].x * 2;
  arcs[0].angle1 = 90 * 64 ;
  arcs[0].angle2 = - iXfwfCircularPercentageArc ;

#ifdef WANT_NOISE

  fprintf (stderr, 
          "(x,y) : (%d,%d) (width,height) (%d,%d) (angle1,angle2) (%d,%d)\n",
	    (int) arcs[0].x,(int)arcs[0].y,
	    (int)arcs[0].width,(int)arcs[0].height,
	    (int)arcs[0].angle1,(int)arcs[0].angle2);
#endif

  arcs[1].x = 5 ; 
  arcs[1].y = 5 ;
  arcs[1].width = our_widget -> core.width - arcs[1].x * 2;
  arcs[1].height = our_widget -> core.height - arcs[1].x * 2;
  arcs[1].angle1 = (90 * 64 - iXfwfCircularPercentageArc) ;
  arcs[1].angle2 = - (360 * 64 - iXfwfCircularPercentageArc);

#ifdef WANT_NOISE

  fprintf (stderr, 
          "(x,y) : (%d,%d) (width,height) (%d,%d) (angle1,angle2) (%d,%d)\n",
	    (int) arcs[1].x,(int)arcs[1].y,
	    (int)arcs[1].width,(int)arcs[1].height,
	    (int)arcs[1].angle1,(int)arcs[1].angle2);

#endif
}

#if NeedFunctionPrototypes > 0
static void Redisplay(Widget w, XExposeEvent *event)
#else
static void Redisplay(w,event)
Widget w;
XExposeEvent *event;
#endif
{
  XfwfCircularPercentageWidget our_widget = (XfwfCircularPercentageWidget) w;
  Display *pDisplay = XtDisplay(our_widget);
  Window window = XtWindow(our_widget);
  XArc arcs[2];
  Dimension dimWidth = our_widget -> core.width;
  Dimension dimHeight = our_widget -> core.height;

  if (!XtIsRealized(w))
    return;
  
  if ((our_widget -> core.width < 25) ||
      (our_widget -> core.height < 25))
    return;

   if (our_widget -> circular_percentage.gc == None)
     MakeGC(our_widget);

   CalculateArcs(our_widget,arcs,our_widget -> circular_percentage.iPercentageCompleted);

   if (arcs[0].angle2)
     {
       XSetForeground(pDisplay, 
		      our_widget -> circular_percentage.gc, 
		      our_widget -> circular_percentage.completed_color);

       XFillArcs(pDisplay,
    	         window,
	         our_widget -> circular_percentage.gc,
	         &arcs[0],
	         1);
     }

   if  (arcs[1].angle2)
     {
       XSetForeground(pDisplay, 
		      our_widget -> circular_percentage.gc, 
		      our_widget -> circular_percentage.interior_color);

       XFillArcs(pDisplay,
    	         window,
	         our_widget -> circular_percentage.gc,
	         &arcs[1],
	         1);
     }

   XSetForeground(pDisplay, 
		  our_widget -> circular_percentage.gc, 
		  our_widget -> circular_percentage.border_color);

   XDrawArc(pDisplay, window, our_widget -> circular_percentage.gc,
	    5,5, dimWidth - 10, dimHeight - 10,
	    0, 360*64);

   XFlush(pDisplay);

}


#define WidgetValuesDiffer(w1,w2,component) (w1 -> circular_percentage.component != \
					     w2 -> circular_percentage.component)

/* ARGSUSED */
#if NeedFunctionPrototypes > 0
static Boolean SetValues(Widget current, 
	                 Widget request, 
	                 Widget new_widget, 
	                 ArgList args, 
	                 Cardinal *num_args)
#else
static Boolean SetValues(current, request, new_widget, args, num_args)
Widget current; 
Widget request; 
Widget new_widget; 
ArgList args; 
Cardinal *num_args;
#endif
{
   Boolean bShouldRedraw = False;

   XfwfCircularPercentageWidget current_widget = (XfwfCircularPercentageWidget) current;
   XfwfCircularPercentageWidget check_widget   = (XfwfCircularPercentageWidget) new_widget;

   if (WidgetValuesDiffer(current_widget,check_widget, border_color) ||
       WidgetValuesDiffer(current_widget,check_widget, interior_color) ||
       WidgetValuesDiffer(current_widget,check_widget, completed_color))
     bShouldRedraw = True;

   if (WidgetValuesDiffer(current_widget,check_widget, iPercentageCompleted))
     {
       if (check_widget -> circular_percentage.iPercentageCompleted < 0 ||
	   check_widget -> circular_percentage.iPercentageCompleted > 10000)
         {
	   XtWarning("XfwfCircularPercentage: new value for percentage out of range [0,10000]).");
	   check_widget -> circular_percentage.iPercentageCompleted =
	         current_widget -> circular_percentage.iPercentageCompleted;
         }
       else
	 bShouldRedraw = True;
     }

   if (bShouldRedraw)
     Redisplay(new_widget,NULL);

   return False;
}

#if NeedFunctionPrototypes > 0
static void Destroy(Widget w)
#else
static void Destroy(w)
Widget w;
#endif
{
  XfwfCircularPercentageWidget our_widget = (XfwfCircularPercentageWidget) w;

  if (our_widget -> circular_percentage.gc != None)
    XFreeGC(XtDisplay(our_widget),our_widget -> circular_percentage.gc);
}

#if NeedFunctionPrototypes > 0
static void Resize(Widget w)
#else
static void Resize(w)
Widget w;
#endif
{
}

#if NeedFunctionPrototypes > 0
static XtGeometryResult QueryGeometry(Widget w, 
				      XtWidgetGeometry *proposed, 
				      XtWidgetGeometry *answer)
#else
static XtGeometryResult QueryGeometry(w, proposed, answer)
Widget w;
XtWidgetGeometry *proposed; 
XtWidgetGeometry *answer;
#endif
{
    XfwfCircularPercentageWidget our_widget = (XfwfCircularPercentageWidget) w;
    XtGeometryResult xtgrOutcome = XtGeometryYes;

#ifdef WANT_NOISE
fprintf(stderr, "Proposed:\n\nreq_mode : %d,\n(x,y):(%d,%d)\n(width,height) : (%d,%d)\nbw: %d, sibling : %x, stack_mode : %i\n\n",
	proposed -> request_mode,
	proposed -> x, proposed -> y,
	proposed -> width, proposed -> height,
	proposed -> border_width,
	proposed -> sibling,
	proposed -> stack_mode);
#endif

    answer -> request_mode = CWWidth | CWHeight;
    answer -> width =  DEFAULT_LENGTH;
    answer -> height = DEFAULT_WIDTH;

    if (proposed -> request_mode & CWWidth)
      if (proposed -> width >= answer -> width)
	answer -> width = proposed -> width;
      else
	 xtgrOutcome = XtGeometryAlmost;

    if (proposed -> request_mode & CWHeight)
      if (proposed -> height >= answer -> height)
	answer -> height = proposed -> height ;
      else
	 xtgrOutcome = XtGeometryAlmost;

    if (answer -> width  == our_widget -> core.width &&
        answer -> height == our_widget -> core.height)
      xtgrOutcome = XtGeometryNo;

#ifdef WANT_NOISE
fprintf(stderr, "Answer:\n\n(width,height) : (%d,%d)\n",
	answer -> width, answer -> height);
#endif

    return xtgrOutcome;
}

#if NeedFunctionPrototypes > 0
static void MakeGC(XfwfCircularPercentageWidget w)
#else
static void MakeGC(w)
XfwfCircularPercentageWidget w;
#endif
{
  Display *pDisplay = XtDisplay(w);

  XGCValues xgcValues;

  xgcValues.function   = GXcopy;
  xgcValues.line_width = 1;
  xgcValues.line_style = LineSolid;
  xgcValues.fill_style = FillSolid;
  xgcValues.fill_rule  = EvenOddRule;
  xgcValues.cap_style  = CapRound;
  xgcValues.join_style = JoinMiter;
  xgcValues.arc_mode   = ArcPieSlice ;

  w -> circular_percentage.gc = XCreateGC(pDisplay,
				 XtWindow(w),
	                         GCFunction| 
			         GCLineWidth| 
			         GCLineStyle| 
			         GCFillStyle| 
			         GCFillRule|
			         GCCapStyle|
			         GCJoinStyle|
			         GCArcMode,
			         &xgcValues);
}

#if NeedFunctionPrototypes > 0
void XfwfCircularPercentageSetPercentage(Widget w, int iNewXfwfCircularPercentage)
#else
void XfwfCircularPercentageSetPercentage(w,iNewXfwfCircularPercentage)
Widget w;
int iNewXfwfCircularPercentage ;
#endif
{
  XfwfCircularPercentageWidget our_widget = (XfwfCircularPercentageWidget) w;

  if (! XtIsSubclass(w,xfwfCircularPercentageWidgetClass))
    return;

  if (iNewXfwfCircularPercentage < 0 || iNewXfwfCircularPercentage > 10000)
    {
     XtWarning("XfwfCircularPercentage: new value for percentage out of range [0,10000]).");
     return;
    }

  RedrawPart(our_widget, 
	     our_widget -> circular_percentage.iPercentageCompleted,
	     iNewXfwfCircularPercentage);

  our_widget -> circular_percentage.iPercentageCompleted = iNewXfwfCircularPercentage;
}

#if NeedFunctionPrototypes > 0
static void RedrawPart(XfwfCircularPercentageWidget our_widget,
		       int iOldXfwfCircularPercentage,
		       int iNewXfwfCircularPercentage)
#else
static void RedrawPart(our_widget,
		       iOldXfwfCircularPercentage,
		       iNewXfwfCircularPercentage)
XfwfCircularPercentageWidget our_widget;
int iOldXfwfCircularPercentage; 
int iNewXfwfCircularPercentage;
#endif
{
   Display *pDisplay = XtDisplay(our_widget);
   Window    window  = XtWindow(our_widget);

   XArc      old_arc[2] ;
   XArc      new_arc[2] ;

   short sDifference;
   Pixel drawing_color;
   short sAngle;

   if (! XtIsRealized((Widget) our_widget))
     return;

   if (our_widget -> circular_percentage.gc == None)
     { 
       Redisplay((Widget)our_widget,NULL);
       return;
     }

   if (iOldXfwfCircularPercentage == iNewXfwfCircularPercentage)
     return;

#ifdef WANT_NOISE
   fprintf(stderr,"*** Redraw Part (%d,%d)\n",iOldXfwfCircularPercentage,iNewXfwfCircularPercentage);
#endif

   CalculateArcs(our_widget, old_arc, iOldXfwfCircularPercentage);
   CalculateArcs(our_widget, new_arc, iNewXfwfCircularPercentage);


   if (iNewXfwfCircularPercentage < iOldXfwfCircularPercentage)
     { 
       sDifference = (old_arc[1].angle1 - new_arc[1].angle1);
       drawing_color = our_widget -> circular_percentage.interior_color;
       sAngle = new_arc[1].angle1;
     }
   else
     { 
       sDifference = (new_arc[1].angle1 - old_arc[1].angle1);
       drawing_color = our_widget -> circular_percentage.completed_color;
       sAngle = old_arc[1].angle1;
     }

   XSetForeground(pDisplay, 
   	          our_widget -> circular_percentage.gc,
		  drawing_color);

   XFillArc(pDisplay, window, our_widget -> circular_percentage.gc,
	    old_arc[1].x, old_arc[1].y, 
	    old_arc[1].width, old_arc[1].height,
	    sAngle, sDifference);

   XSetForeground(pDisplay, 
   	          our_widget -> circular_percentage.gc,
		  our_widget -> circular_percentage.border_color);

   XDrawArc(pDisplay, window, our_widget -> circular_percentage.gc,
	    old_arc[1].x, old_arc[1].y, 
	    old_arc[1].width, old_arc[1].height,
	    sAngle, sDifference);

   XFlush(pDisplay);
}
;

    if (answer -> width  == our_widget -> core.width &&
        answer -> height == our_widget -> core.height)
      xtgrOxscrabble/src/CircPerc.h100600 000310 000001 00000002070 06047122456 016357 0ustar00mchapmanstaff000000 000000 #ifndef _XfwfCircularPercentage_h
#define _XfwfCircularPercentage_h

#ifndef XtNborderColor
#define XtNborderColor "borderColor"
#endif
#ifndef XtCBorderColor
#define XtCBorderColor "BorderColor"
#endif

#define XtNinteriorColor "interiorColor"
#define XtCInteriorColor "InteriorColor"

#define XtNcompletedColor "completedColor"
#define XtCCompletedColor "CompletedColor"

#define XtNpercentageCompleted "percentageCompleted"
#define XtCPercentageCompleted "PercentageCompleted"

#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif

#include <X11/Core.h>

extern WidgetClass xfwfCircularPercentageWidgetClass;

typedef struct _XfwfCircularPercentageClassRec *XfwfCircularPercentageWidgetClass;
typedef struct _XfwfCircularPercentageRec      *XfwfCircularPercentageWidget;

#if NeedFunctionPrototypes > 0
extern void XfwfCircularPercentageSetPercentage(Widget,int);
#else
extern void XfwfCircularPercentageSetPercentage();
#endif

#if defined(__cplusplus) || defined(c_plusplus)
}  /* Close scope of 'extern "C"' declaration which encloses file. */
#endif

#endif
     our_widget -> circular_percentage.iPercentageCompleted,
	     iNewXfwfCircularPercentage);

  our_widget -> circular_percentage.iPercentageCompleted = iNewXfwfCircularPercentage;
}

#if NeedFunctionPrototypes > 0
static void RedrawPart(XfwfCircularPercentageWidget our_widget,
		       int iOldXfwfCircularPercentage,
		       int iNewXfwfCircularPercentage)
#else
static void RedrawPart(our_widget,
		       iOldXfwfCircularPercentage,
		       iNewXxscrabble/src/CircPercP.h100600 000310 000001 00000002366 06047122456 016507 0ustar00mchapmanstaff000000 000000 #ifndef _XmCircularPercentageWidgetP_h
#define _XmCircularPercentageWidgetP_h

#include <X11/CoreP.h>
#include "CircPerc.h"

#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif

/* class part definition */

typedef 
  struct
    {
      int iMakeCompilerHappy ; /* dummy field */
    } XfwfCircularPercentageClassPart;

/* full class record declaration */

typedef 
  struct _XfwfCircularPercentageClassRec
    {
      CoreClassPart        core_class;
      XfwfCircularPercentageClassPart  circular_percentage_class;
    } XfwfCircularPercentageClassRec;

/* new fields for this widget */

typedef
  struct
    {

      /* resources */
      Pixel   border_color;
      Pixel   interior_color;
      Pixel   completed_color;
      int     iPercentageCompleted;

      /* private data */
      GC       gc;
    } XfwfCircularPercentagePart;

/* full instance record declaration */

typedef
  struct _XfwfCircularPercentageRec
    {
      CorePart        core;
      XfwfCircularPercentagePart  circular_percentage;
    } XfwfCircularPercentageRec;

extern XfwfCircularPercentageClassRec xfwfCircularPercentageClassRec;

#if defined(__cplusplus) || defined(c_plusplus)
}  /* Close scope of 'extern "C"' declaration which encloses file. */
#endif

#endif

_arc[2] ;
   XArc      new_arc[2] ;

   short sDifference;
   Pixel drawing_color;
   short sAngle;

   if (! XtIsRealized((Widget) our_widget))
     return;

   if (our_widget -> circular_percentage.gc == None)
     { 
       Redisplay((Widget)our_widget,NULL);
   xscrabble/src/Imakefile100600 000310 000001 00000002213 06311172010 016305 0ustar00mchapmanstaff000000 000000 /*
 *
 *
 * This software comes with NO warranty whatsoever. I therefore take no
 * responsibility for any damages, losses or problems caused through use
 * or misuse of this program.
 *
 * I hereby grant permission for this program to be freely copied and
 * distributed by any means, provided no charge is made for it.
 *
 * Matthew Chapman, csuoq@csv.warwick.ac.uk
 *    June 1995.
 */

/* main Imakefile */

   SETUP_SRCS = setup.c xutils.c
   SETUP_OBJS = setup.o xutils.o

         SRCS = init.c xinit.c misc.c moves.c cmove.c main.c xutils.c mess.c \
	 	popup.c widgets.c display.c user.c CircPerc.c

         OBJS = init.o xinit.o misc.o moves.o cmove.o main.o xutils.o mess.o \
	 	popup.o widgets.o display.o user.o CircPerc.o

   LOCAL_LIBS = XawClientLibs 
      DEPLIBS = XawClientDepLibs
     PROGRAMS = xscrab xscrabble
        SLIBS = 

     INCLUDES = -I.. -I/home/mchapman/include
SYS_LIBRARIES = -lXpm -L../Xc -lXc -L/home/mchapman/lib

    CCOPTIONS = 

AllTarget($(PROGRAMS))

NormalProgramTarget(xscrab,$(OBJS),$(DEPLIBS),$(LOCAL_LIBS),$(SLIBS))
NormalProgramTarget(xscrabble,$(SETUP_OBJS),$(DEPLIBS),$(LOCAL_LIBS),$(SLIBS))

DependTarget()

/
      Pixel   border_color;
      Pixel   interior_color;
      Pixel   completed_color;
      int     iPercentageCompleted;

      /* private data */
      GC       gc;
    } XfwfCircularPercentagePart;

/* full instance record declaration */

typedef
  struct _XfwfCircularPercentageRec
    {
      CorePart        core;
      XfwfCircularPercentagePart  circular_percexscrabble/src/Makefile100644 000310 000001 00000044654 06311435232 016173 0ustar00mchapmanstaff000000 000000 # Makefile generated by imake - do not edit!
# $XConsortium: imake.c,v 1.91 95/01/12 16:15:47 kaleb Exp $

# ----------------------------------------------------------------------
# Makefile generated from "Imake.tmpl" and <Imakefile>
# $XConsortium: Imake.tmpl,v 1.224.1.1 95/06/19 17:51:01 gildea Exp $
# $XFree86: xc/config/cf/Imake.tmpl,v 3.18 1995/07/12 15:27:23 dawes Exp $
#

.SUFFIXES: .i

# $XConsortium: Imake.cf,v 1.19 95/01/05 19:24:32 kaleb Exp $
# $XFree86: xc/config/cf/Imake.cf,v 3.15 1995/06/08 06:18:39 dawes Exp $

# -----------------------------------------------------------------------
# site-specific configuration parameters that need to come before
# the platform-specific parameters - edit site.def to change

# site:  $XConsortium: site.sample,v 1.9 94/04/08 17:02:06 rws Exp $
# site:  $XFree86: xc/config/cf/site.def,v 3.8 1995/05/27 01:56:50 dawes Exp $

MOTIFLIBINSTALLDIR = /usr/pkg/motif-2.0/X11R6/lib
MOTIFSHLIBINSTALLDIR = /usr/pkg/motif-2.0/X11R6/lib
MOTIFBININSTALLDIR = /usr/pkg/motif-2.0/X11R6/bin

# $XFree86: xc/config/cf/xf86site.def,v 3.48 1995/07/22 04:11:45 dawes Exp $

# -----------------------------------------------------------------------
# platform-specific configuration parameters - edit linux.cf to change

# platform:  $XConsortium: linux.cf,v 1.11 95/01/23 18:32:03 kaleb Exp $
# platform:  $XFree86: xc/config/cf/linux.cf,v 3.26 1995/07/12 15:27:34 dawes Exp $

# $XConsortium: lnxLib.rules,v 1.8 95/01/16 21:11:00 kaleb Exp $
# $XFree86: xc/config/cf/lnxLib.rules,v 3.14 1995/06/01 08:18:56 dawes Exp $

# $XConsortium: xfree86.cf,v 1.9 95/01/25 16:42:40 kaleb Exp $
# $XFree86: xc/config/cf/xfree86.cf,v 3.66 1995/07/22 04:11:47 dawes Exp $

LINKKITDIR = $(USRLIBDIR)/Server

       XF86SRC = $(SERVERSRC)/hw/xfree86
  XF86ACCELSRC = $(XF86SRC)/accel
    XF86COMSRC = $(XF86SRC)/common
 XF86CONFIGSRC = $(XF86COMSRC)
     XF86HWSRC = $(XF86SRC)/common_hw
     XF86OSSRC = $(XF86SRC)/os-support
  VGADRIVERSRC = $(XF86SRC)/vga256/drivers
VGA16DRIVERSRC = $(XF86SRC)/vga16/drivers
 VGA2DRIVERSRC = $(XF86SRC)/vga2/drivers
 MONODRIVERSRC = $(XF86SRC)/mono/drivers
   S3DRIVERSRC = $(XF86SRC)/accel/s3/drivers

        XFREE86DOCDIR = /usr/X11R6/doc/XFree86
      XFREE86PSDOCDIR = $(XFREE86DOCDIR)
    XFREE86HTMLDOCDIR = /usr/X11R6/html/XFree86
XFREE86JAPANESEDOCDIR = $(XFREE86DOCDIR)/Japanese

# $XConsortium: xf86.rules,v 1.7 95/01/25 16:34:39 kaleb Exp $
# $XFree86: xc/config/cf/xf86.rules,v 3.9 1995/07/12 15:27:38 dawes Exp $

# -----------------------------------------------------------------------
# site-specific configuration parameters that go after
# the platform-specific parameters - edit site.def to change

# site:  $XConsortium: site.sample,v 1.9 94/04/08 17:02:06 rws Exp $
# site:  $XFree86: xc/config/cf/site.def,v 3.8 1995/05/27 01:56:50 dawes Exp $

# -----------------------------------------------------------------------
# Imake rules for building libraries, programs, scripts, and data files
# rules:  $XConsortium: Imake.rules,v 1.197.1.1 95/06/19 18:01:48 gildea Exp $
# rules:  $XFree86: xc/config/cf/Imake.rules,v 3.18 1995/07/22 09:39:32 dawes Exp $

 _NULLCMD_ = @ echo -n

          PATHSEP = /
            SHELL = /bin/sh

              TOP = ..
      CURRENT_DIR = src

            IMAKE = imake
           DEPEND = gccmakedep
        MKDIRHIER = mkdir -p
        CONFIGSRC = $(TOP)/config
         IMAKESRC = $(CONFIGSRC)/imake
        DEPENDSRC = $(CONFIGSRC)/util
           IXXSRC = $(UNSUPPORTEDSRC)/programs/ixx
              IXX = ixx
         IXXFLAGS = -s BaseObject -m TypeObj -r RequestObj -p Xf
      IXXINCLUDES = -i '<X11/Fresco/enter-scope.h>'

          INCROOT = /usr/X11R6/include
        USRLIBDIR = /usr/pkg/gcc/lib
         SHLIBDIR = /usr/X11R6/lib
       LINTLIBDIR = $(USRLIBDIR)/lint
          MANPATH = /usr/X11R6/man
    MANSOURCEPATH = $(MANPATH)/man
           MANDIR = $(MANSOURCEPATH)1
        LIBMANDIR = $(MANSOURCEPATH)X
       FILEMANDIR = $(MANSOURCEPATH)5

               AR = ar clq
  BOOTSTRAPCFLAGS =
               CC = gcc
               AS = as

.SUFFIXES: .cxx

              CXX = g++
    CXXDEBUGFLAGS = -O
 CXXEXTRA_DEFINES =
CXXEXTRA_INCLUDES =
  CXXIDL_INCLUDES = -I$(TOP)/include
   CXXSTD_DEFINES = -Dlinux -D__i386__ -D_ALL_SOURCE
       CXXOPTIONS =
      CXXINCLUDES = $(INCLUDES) $(TOP_INCLUDES) $(CXXEXTRA_INCLUDES) $(CXXIDL_INCLUDES)
       CXXDEFINES = $(CXXINCLUDES) $(CXXSTD_DEFINES) $(THREADS_CXXDEFINES) $(CXXEXTRA_DEFINES)
         CXXFLAGS = $(CXXDEBUGFLAGS) $(CXXOPTIONS) $(THREADS_CXXFLAGS) $(CXXDEFINES)

         COMPRESS = compress
              CPP = /lib/cpp $(STD_CPP_DEFINES)
    PREPROCESSCMD = gcc -E $(STD_CPP_DEFINES)
          INSTALL = install
     INSTALLFLAGS = -c
               LD = ld
              LEX = flex -l
           LEXLIB = -lfl
             YACC = bison -y
           CCYACC = bison -y
             LINT = lint
      LINTLIBFLAG = -C
         LINTOPTS = -axz
               LN = ln -s
             MAKE = make
               MV = mv
               CP = cp

           RANLIB = ranlib
  RANLIBINSTFLAGS =

               RM = rm -f
        MANSUFFIX = 1x
     LIBMANSUFFIX = X
    FILEMANSUFFIX = 5x
            TROFF = psroff
         MSMACROS = -ms
              TBL = tbl
              EQN = eqn

            DVIPS = dvips
            LATEX = latex

     STD_INCLUDES =
  STD_CPP_DEFINES = -traditional -Dlinux -D__i386__ -D_ALL_SOURCE
      STD_DEFINES = -Dlinux -D__i386__ -D_ALL_SOURCE
 EXTRA_LOAD_FLAGS = -Wl,-rpath,/usr/X11R6/lib
  EXTRA_LDOPTIONS =
  EXTRA_LIBRARIES =
             TAGS = ctags

    SHAREDCODEDEF =
         SHLIBDEF =

     SHLIBLDFLAGS = -shared

         PICFLAGS = -fPIC

      CXXPICFLAGS = -fPIC

    PROTO_DEFINES = -DFUNCPROTO=15 -DNARROWPROTO

     INSTPGMFLAGS = -s

     INSTBINFLAGS = -m 0755
     INSTUIDFLAGS = -s -m 4755
     INSTLIBFLAGS = -m 0644
     INSTINCFLAGS = -m 0444
     INSTMANFLAGS = -m 0444
     INSTDATFLAGS = -m 0444
    INSTKMEMFLAGS = -s -m 4755

      PROJECTROOT = /usr/X11R6

     TOP_INCLUDES = -I$(INCROOT)

      CDEBUGFLAGS = -O
        CCOPTIONS = -ansi -fcommon

      ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES)
       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(THREADS_DEFINES) $(DEFINES)
           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(THREADS_CFLAGS) $(ALLDEFINES)
        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES) $(DEPEND_DEFINES)
         LDPRELIB = -L$(SHLIBDIR)
        LDPOSTLIB =
        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS)  $(EXTRA_LDOPTIONS) $(THREADS_LDFLAGS) $(LOCAL_LDFLAGS) $(LDPRELIB)
     CXXLDOPTIONS = $(CXXDEBUGFLAGS) $(CXXOPTIONS) $(EXTRA_LDOPTIONS) $(THREADS_CXXLDFLAGS) $(LOCAL_LDFLAGS) $(LDPRELIB)

           LDLIBS = $(LDPOSTLIB) $(THREADS_LIBS) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)

           CCLINK = $(CC)

          CXXLINK = $(CXX)

     LDSTRIPFLAGS = -x
   LDCOMBINEFLAGS = -r
      DEPENDFLAGS =

        MACROFILE = linux.cf
           RM_CMD = $(RM)

    IMAKE_DEFINES =

         IRULESRC = $(CONFIGDIR)
        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)

     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Project.tmpl 			$(IRULESRC)/site.def $(IRULESRC)/$(MACROFILE) 			$(IRULESRC)/xfree86.cf $(IRULESRC)/xf86.rules $(IRULESRC)/xf86site.def $(IRULESRC)/host.def $(EXTRA_ICONFIGFILES)

#   $RCSfile: Motif.rules,v $ $Revision: 1.5.233.3 $ $Date: 1994/07/15 14:36:58 $

# ----------------------------------------------------------------------
# X Window System Build Parameters and Rules
# $XConsortium: Project.tmpl,v 1.249 95/05/23 21:36:40 matt Exp $
# $XFree86: xc/config/cf/Project.tmpl,v 3.18 1995/07/22 04:11:42 dawes Exp $

# -----------------------------------------------------------------------
# X Window System make variables; these need to be coordinated with rules

           BINDIR = /usr/X11R6/bin
     BUILDINCROOT = $(TOP)
      BUILDINCDIR = $(BUILDINCROOT)/X11
      BUILDINCTOP = ..
      BUILDLIBDIR = $(TOP)/usrlib
      BUILDLIBTOP = ..
           INCDIR = $(INCROOT)/X11
           ADMDIR = /usr/adm
           LIBDIR = /usr/X11R6/lib/X11

          FONTDIR = $(LIBDIR)/fonts
         XINITDIR = /etc/X11/xinit
           XDMDIR = /etc/X11/xdm
           TWMDIR = $(LIBDIR)/twm
           XSMDIR = $(LIBDIR)/xsm
           NLSDIR = $(LIBDIR)/nls
       XLOCALEDIR = $(LIBDIR)/locale
        PEXAPIDIR = $(LIBDIR)/PEX
      XAPPLOADDIR = $(LIBDIR)/app-defaults
       FONTCFLAGS = -t

     INSTAPPFLAGS = $(INSTDATFLAGS)

              RGB = rgb
            FONTC = bdftopcf
        MKFONTDIR = mkfontdir

       DOCUTILSRC = $(TOP)/doc/util
       XDOCMACROS = $(DOCUTILSRC)/macros.t
       XIDXMACROS = $(DOCUTILSRC)/indexmacros.t
       PROGRAMSRC = $(TOP)/programs
           LIBSRC = $(TOP)/lib
          FONTSRC = $(TOP)/fonts
       INCLUDESRC = $(TOP)/X11
        SERVERSRC = $(TOP)/programs/Xserver
       CONTRIBSRC = $(TOP)/../contrib
   UNSUPPORTEDSRC = $(TOP)/unsupported
           DOCSRC = $(TOP)/doc
           RGBSRC = $(TOP)/programs/rgb
      BDFTOPCFSRC = $(PROGRAMSRC)/bdftopcf
     MKFONTDIRSRC = $(PROGRAMSRC)/mkfontdir
    FONTSERVERSRC = $(PROGRAMSRC)/xfs
       FONTINCSRC = $(TOP)/include/fonts
        EXTINCSRC = $(TOP)/include/extensions
     TRANSCOMMSRC = $(LIBSRC)/xtrans
   TRANS_INCLUDES = -I$(TRANSCOMMSRC)

# $XConsortium: lnxLib.tmpl,v 1.5 95/01/11 21:44:44 kaleb Exp $
# $XFree86: xc/config/cf/lnxLib.tmpl,v 3.7 1995/04/09 13:39:23 dawes Exp $

          XLIBSRC = $(LIBSRC)/X11

SOXLIBREV = 6.0
DEPXONLYLIB =
XONLYLIB =  -lX11

LINTXONLY = $(LINTLIBDIR)/llib-lX11.ln

         XLIBONLY = $(XONLYLIB)

      XEXTLIBSRC = $(LIBSRC)/Xext
   LBXXEXTLIBSRC = $(TOP)/workInProgress/lbx/lib/Xext

    XEXEXTLIBSRC = $(LIBSRC)/XExExt

SOXEXTREV = 6.0
DEPXEXTLIB =
XEXTLIB =  -lXext

LINTXEXT = $(LINTLIBDIR)/llib-lXext.ln

SOXEXTREV = 6.0
DEPLBXXEXTLIB =
LBXXEXTLIB =  -llbxXext

LINTLBXXEXT = $(LINTLIBDIR)/llib-llbxXext.ln

DEPXEXEXTLIB = $(USRLIBDIR)/libXExExt.a
XEXEXTLIB =  -lXExExt

LINTXEXEXT = $(LINTLIBDIR)/llib-lXExExt.ln

     EXTENSIONLIB = $(XEXEXTLIB) $(XEXTLIB)
  DEPEXTENSIONLIB = $(DEPXEXEXTLIB) $(DEPXEXTLIB)
    LINTEXTENSION = $(LINTXEXEXT) $(LINTXEXT)

 LINTEXTENSIONLIB = $(LINTEXTENSION)
          DEPXLIB = $(DEPEXTENSIONLIB) $(DEPXONLYLIB)
             XLIB = $(EXTENSIONLIB) $(XONLYLIB)
         LINTXLIB = $(LINTXONLYLIB)

         XAUTHSRC = $(LIBSRC)/Xau

DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
XAUTHLIB =  -lXau

LINTXAUTH = $(LINTLIBDIR)/llib-lXau.ln

      XDMCPLIBSRC = $(LIBSRC)/Xdmcp

DEPXDMCPLIB = $(USRLIBDIR)/libXdmcp.a
XDMCPLIB =  -lXdmcp

LINTXDMCP = $(LINTLIBDIR)/llib-lXdmcp.ln

           XMUSRC = $(LIBSRC)/Xmu

SOXMUREV = 6.0
DEPXMULIB =
XMULIB =  -lXmu

LINTXMU = $(LINTLIBDIR)/llib-lXmu.ln

       OLDXLIBSRC = $(LIBSRC)/oldX

DEPOLDXLIB = $(USRLIBDIR)/liboldX.a
OLDXLIB =  -loldX

LINTOLDX = $(LINTLIBDIR)/llib-loldX.ln

       TOOLKITSRC = $(LIBSRC)/Xt

SOXTREV = 6.0
DEPXTOOLONLYLIB =
XTOOLONLYLIB =  -lXt

LINTXTOOLONLY = $(LINTLIBDIR)/llib-lXt.ln

      DEPXTOOLLIB = $(DEPXTOOLONLYLIB) $(DEPSMLIB) $(DEPICELIB)
         XTOOLLIB = $(XTOOLONLYLIB) $(SMLIB) $(ICELIB)
     LINTXTOOLLIB = $(LINTXTOOLONLYLIB)

       AWIDGETSRC = $(LIBSRC)/Xaw

SOXAWREV = 6.0
DEPXAWLIB =
XAWLIB =  -lXaw

LINTXAW = $(LINTLIBDIR)/llib-lXaw.ln

       XTFSRC = $(TOP)/workInProgress/Xtf

DEPXTFLIB = $(USRLIBDIR)/libXtf.a
XTFLIB =  -lXtf

LINTXTF = $(LINTLIBDIR)/llib-lXtf.ln

       FRESCOSRC = $(TOP)/workInProgress/Fresco

DEPFRESCOLIB = $(USRLIBDIR)/libFresco.a
FRESCOLIB =  -lFresco

LINTFRESCO = $(LINTLIBDIR)/llib-lFresco.ln

         XILIBSRC = $(LIBSRC)/Xi

SOXINPUTREV = 6.0
DEPXILIB =
XILIB =  -lXi

LINTXI = $(LINTLIBDIR)/llib-lXi.ln

      XTESTLIBSRC = $(LIBSRC)/Xtst

SOXTESTREV = 6.0
DEPXTESTLIB =
XTESTLIB =  -lXtst

LINTXTEST = $(LINTLIBDIR)/llib-lXtst.ln

        PEXLIBSRC = $(LIBSRC)/PEX5

SOPEXREV = 6.0
DEPPEXLIB =
PEXLIB =  -lPEX5

LINTPEX = $(LINTLIBDIR)/llib-lPEX5.ln

        XIELIBSRC = $(LIBSRC)/XIE

SOXIEREV = 6.0
DEPXIELIB =
XIELIB =  -lXIE

LINTXIE = $(LINTLIBDIR)/llib-lXIE.ln

      PHIGSLIBSRC = $(LIBSRC)/PHIGS

DEPPHIGSLIB = $(USRLIBDIR)/libphigs.a
PHIGSLIB =  -lphigs

LINTPHIGS = $(LINTLIBDIR)/llib-lphigs.ln

DEPXBSDLIB = $(USRLIBDIR)/libXbsd.a
XBSDLIB =  -lXbsd

LINTXBSD = $(LINTLIBDIR)/llib-lXbsd.ln

           ICESRC = $(LIBSRC)/ICE

SOICEREV = 6.0
DEPICELIB =
ICELIB =  -lICE

LINTICE = $(LINTLIBDIR)/llib-lICE.ln

            SMSRC = $(LIBSRC)/SM

SOSMREV = 6.0
DEPSMLIB =
SMLIB =  -lSM

LINTSM = $(LINTLIBDIR)/llib-lSM.ln

         FSLIBSRC = $(LIBSRC)/FS

DEPFSLIB = $(USRLIBDIR)/libFS.a
FSLIB =  -lFS

LINTFS = $(LINTLIBDIR)/llib-lFS.ln

         FONTLIBSRC = $(LIBSRC)/font

DEPFONTLIB = $(USRLIBDIR)/libfont.a
FONTLIB =  -lfont

LINTFONT = $(LINTLIBDIR)/llib-lfont.ln

          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)

         DEPLIBS1 = $(DEPLIBS)
         DEPLIBS2 = $(DEPLIBS)
         DEPLIBS3 = $(DEPLIBS)

#   $RCSfile: Motif.tmpl,v $ $Revision: 1.5.332.3 $ $Date: 1994/07/06 14:56:17 $

          SOXMREV = 2.0
         SOMRMREV = 2.0
         SOUILREV = 2.0
     SOACOMMONREV = 2.0
      SOSCRIPTREV = 2.0
        SOUTILREV = 2.0
      SOCREATEREV = 2.0
      SOVISUALREV = 2.0
       SOSYNTHREV = 2.0
     SOMCOMMONREV = 2.0

              XTOP = $(TOP)
              MTOP = $(TOP)
     XBUILDINCROOT = $(XTOP)
      XBUILDINCDIR = $(XBUILDINCROOT)/X11

	IMAKE_CMD = $(IMAKE) -DUseInstalled -DUseInstalledMotif -I$(IRULESRC) $(IMAKE_DEFINES)

         CLIENTSRC = $(XTOP)/clients
           DEMOSRC = $(XTOP)/demos
            LIBSRC = $(XTOP)/lib
           FONTSRC = $(XTOP)/fonts
        INCLUDESRC = $(XTOP)/X11
         SERVERSRC = $(XTOP)/server
           UTILSRC = $(XTOP)/util
        EXAMPLESRC = $(XTOP)/examples
            DOCSRC = $(XTOP)/doc
            RGBSRC = $(XTOP)/rgb
      EXTENSIONSRC = $(XTOP)/extensions

      TOP_INCLUDES = -I$(INCROOT)

      UIL_INCLUDES = -I$(USRINCDIR)/uil

     XPM_DEFINES =

     XPM_TOP = $(XTOP)

     XPM_INCLUDES	= -I$(INCDIR)

     XPM_LIBS		= -lXpm

      USRINCDIR = /usr/X11R6/include
         UIDDIR = $(LIBDIR)/uid
        TESTSRC = $(MTOP)/tests
        TESTLIB = $(TESTSRC)/lib
  GENERALSRCLIB = $(TESTSRC)/General/lib
  GENERALSRCBIN = $(TESTSRC)/General/bin
   MANUALSRCLIB = $(TESTSRC)/Manual/lib
   MANUALSRCBIN = $(TESTSRC)/Manual/bin
     AUTOSRCLIB = $(TESTSRC)/Auto/lib
     AUTOSRCBIN = $(TESTSRC)/Auto/bin
       COMMONPP = $(GENERALSRCBIN)/Commonpp
         GENRUN = $(GENERALSRCBIN)/Genrun
         MANRUN = $(GENERALSRCBIN)/Manrun

     TESTCOMSRC = $(MANUALSRCLIB)/Common

    MTOOLKITSRC = $(TOOLKITSRC)
    MINCLUDESRC = $(MTOP)/X11
#MINCLUDESRC = $(INCDIR)
        MLIBSRC = $(MTOP)/lib
#MLIBSRC = $(USRLIBDIR)
     MCLIENTSRC = $(MTOP)/clients
       MDEMOSRC = $(MTOP)/demos
     MWIDGETSRC = $(MLIBSRC)/Xm
#MWIDGETSRC = $(USRLIBDIR)/Xm
   MRESOURCESRC = $(MLIBSRC)/Mrm
#MRESOURCESRC = $(USRLIBDIR)/Mrm
         UILSRC = $(MCLIENTSRC)/uil

            UIL = uil
         DEPUIL =

   XMEXTRA_LIBS =

SOXMREV = 2.0
DEPXMLIBONLYLIB =
XMLIBONLYLIB =  -lXm

LINTXMLIBONLY = $(LINTLIBDIR)/llib-lXm.ln

   XMLIB = $(XMLIBONLYLIB) $(XPM_LIBS)
   DEPXMLIB = $(DEPXMLIBONLYLIB)

SOMRMREV = 2.0
DEPMRESOURCELIB =
MRESOURCELIB =  -lMrm

LINTMRESOURCE = $(LINTLIBDIR)/llib-lMrm.ln

SOUILREV = 2.0
DEPUILLIB =
UILLIB =  -lUil

LINTUIL = $(LINTLIBDIR)/llib-lUil.ln

SOMCOMMONREV = 2.0
DEPTESTCOMLIB =
TESTCOMLIB =  -lCommon

LINTTESTCOM = $(LINTLIBDIR)/llib-lCommon.ln

TESTUILCOMLIB = $(TESTCOMSRC)/libCommonUil.a

  LINTMRESOURCE = $(MRESOURCESRC)/libMrm.a
LINTXMWIDGETLIB = $(MWIDGETSRC)/llib-l/Xm.ln
     LINTXMTOOL = $(MTOOLKITSRC)/llib-lXt.ln
     LINTUILLIB = $(UILSRC)/llib-lUil.ln

      YACCFLAGS =
       UILFLAGS =

         RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut  *.Dat

    STD_DEFINES = -Dlinux -D__i386__ -D_ALL_SOURCE  -DNO_MESSAGE_CATALOG

        DEPLIBS = $(DEPXMLIB) $(DEPXTOOLLIB) $(DEPXLIB)

        DEPLIBS1 = $(DEPLIBS)
        DEPLIBS2 = $(DEPLIBS)
        DEPLIBS3 = $(DEPLIBS)

.SUFFIXES: .o .c .cc .C .cxx

        CPLUSPLUSCOM = CC

        CPLUSPLUSLINKCOM = $(CPLUSPLUSCOM)

        STD_CPLUSPLUS_INCLUDES = $(STD_INCLUDES)

      ALLCPLUSPLUSINCLUDES = 	$(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) 	$(STD_CPLUSPLUS_INCLUDES)

        STD_CPLUSPLUS_DEFINES = $(STD_DEFINES)

       ALLCPLUSPLUSDEFINES = 	$(ALLCPLUSPLUSINCLUDES) $(STD_CPLUSPLUS_DEFINES) $(EXTRA_DEFINES) 	$(PROTO_DEFINES) $(DEFINES)

       CPLUSPLUSFLAGS = $(CDEBUGFLAGS) $(ALLCPLUSPLUSDEFINES)

       CPLUSPLUSLIBS =

XMULIBONLY = -lXmu
XMULIB = $(XMULIBONLY) $(XTOOLLIB) $(XLIB)

        CONFIGDIR = $(LIBDIR)/config

# -----------------------------------------------------------------------
# start of Imakefile

   SETUP_SRCS = setup.c xutils.c
   SETUP_OBJS = setup.o xutils.o

         SRCS = init.c xinit.c misc.c moves.c cmove.c main.c xutils.c mess.c 	 	popup.c widgets.c display.c user.c CircPerc.c

         OBJS = init.o xinit.o misc.o moves.o cmove.o main.o xutils.o mess.o 	 	popup.o widgets.o display.o user.o CircPerc.o

   LOCAL_LIBS = $(XAWLIB) $(XMULIBONLY) $(XTOOLLIB) $(XLIB)
      DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
     PROGRAMS = xscrab xscrabble
        SLIBS =

     INCLUDES = -I.. -I/home/mchapman/include
SYS_LIBRARIES = -lXpm -L../Xc -lXc -L/home/mchapman/lib

    CCOPTIONS =

all:: $(PROGRAMS)

xscrab: $(OBJS) $(DEPLIBS)
	$(RM) $@
	$(CCLINK) -o $@ $(LDOPTIONS) $(OBJS) $(LOCAL_LIBS) $(LDLIBS) $(SLIBS) $(EXTRA_LOAD_FLAGS)

clean::
	$(RM) xscrab

xscrabble: $(SETUP_OBJS) $(DEPLIBS)
	$(RM) $@
	$(CCLINK) -o $@ $(LDOPTIONS) $(SETUP_OBJS) $(LOCAL_LIBS) $(LDLIBS) $(SLIBS) $(EXTRA_LOAD_FLAGS)

clean::
	$(RM) xscrabble

depend::
	$(DEPEND) $(DEPENDFLAGS) -- $(ALLDEFINES) $(DEPEND_DEFINES) -- $(SRCS)

# -----------------------------------------------------------------------
# common rules for all Makefiles - do not edit

.c.i:
	$(RM) $@
	$(CC) -E $(CFLAGS) $(_NOOP_) $*.c > $@

emptyrule::

clean::
	$(RM_CMD) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut  "#"*

Makefile::
	-@if [ -f Makefile ]; then set -x; \
	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
	else exit 0; fi
	$(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)

tags::
	$(TAGS) -w *.[ch]
	$(TAGS) -xw *.[ch] > TAGS

# -----------------------------------------------------------------------
# empty rules for directories that do not have SUBDIRS - do not edit

install::
	@echo "install in $(CURRENT_DIR) done"

install.man::
	@echo "install.man in $(CURRENT_DIR) done"

install.linkkit::
	@echo "install.linkkit in $(CURRENT_DIR) done"

Makefiles::

includes::

depend::

# -----------------------------------------------------------------------
# dependencies generated by makedepend


     MCLIENTSRC = $(MTOP)/clients
       MDEMOSRC = $(MTOP)/demos
     MWIDGETSRC =xscrabble/src/cmove.c100600 000310 000001 00000043070 06311434254 015772 0ustar00mchapmanstaff000000 000000 /*      XScrabble
        cmove.c
        computer player
        By csuos@warwick.ac.uk
*/

#include "scrab.h"
#include "globals.h"

int check_boardh(int x,int y,int numlett)
{
    int pieces = 0;
    int checkx = x,checky = y;
    char valboard[BOARDSIZE][BOARDSIZE];
    int vx,vy,dummy;
    
    for (vx = 0; vx < BOARDSIZE; vx++)
	for (vy = 0; vy < BOARDSIZE; vy++)
	    valboard[vx][vy] = board[vx][vy];

    assert(checky < BOARDSIZE);
    while (checkx < x+numlett)
    {
	assert(checkx < BOARDSIZE);
	if (board[checkx][checky] == ' ')
	    valboard[checkx][checky] = '*';
	else
	    pieces++;
	checkx++;
    }
    /* ignore words already there */
    if (pieces == numlett)
	return INVALID;
    else
	return validate(valboard,1,&dummy);	
}

int check_boardv(int x, int y,int numlett)
{
    int pieces = 0;
    int checkx = x,checky = y;
    char valboard[BOARDSIZE][BOARDSIZE];
    int vx,vy,dummy;
	
    for (vx = 0; vx < BOARDSIZE; vx++)
	for (vy = 0; vy < BOARDSIZE; vy++)
	    valboard[vx][vy] = board[vx][vy];
	
    assert(checkx < BOARDSIZE);
    while (checky < y+numlett)
    {
	assert(checky < BOARDSIZE);
	if (board[checkx][checky] == ' ')
	    valboard[checkx][checky] = '*';
	else
	    pieces++;
	checky++;
    }
    /* ignore 4 letter words already there */
    if (pieces == numlett)
	return INVALID;
    else
	return validate(valboard,1,&dummy);
}

void makeperm(short int p[7][5040][7],int num[7])
{
#ifdef MAKEPERMS
    int used[7];
    int ptr[7];
    int count;
    int clash,max;
    int lastptr[7] = {-1,-1,-1,-1,-1,-1,-1};
	
    for (count = 0; count < 7; count++)
	num[count] = 0;
    for (max = 0; max < 7; max++)
    {
	for (ptr[0] = 0; ptr[0] < 7; ptr[0]++)
	    for (ptr[1] = 0; ptr[1] < 7; ptr[1]++)
		for (ptr[2] = 0; ptr[2] < 7; ptr[2]++)
		    for (ptr[3] = 0; ptr[3] < 7; ptr[3]++)
			for (ptr[4] = 0; ptr[4] < 7; ptr[4]++)
			    for (ptr[5] = 0; ptr[5] < 7; ptr[5]++)
				for (ptr[6] = 0; ptr[6] < 7; ptr[6]++)
				{
				    for (count = 0; count < 7; count++)
				    {
					used[count] = 0;
				    }
		
				    clash = 0;
				    for (count = 0; count < (max+1); count++)
					if (!used[ptr[count]])
					    used[ptr[count]] = 1;
					else
					{
					    clash = 1;
					    break;
					}
				    if (clash)
					continue;
				    clash = 0;
				    for (count = 0; count < (max+1); count++)
				    {
					if (ptr[count] == lastptr[count])
					    clash++;	
				    }
				    if (clash == (max+1))
					continue;
				    for (count = 0; count < (max+1); count++)
				    {
					assert(max < 7);
					assert(num[max] < 5040);
					assert(count < 7);
					p[max][num[max]][count] = ptr[count];
					lastptr[count] = ptr[count];
				    }
				    (num[max])++;
				}
    }
#else
    loadperms();
#endif
    /* MAKEPERMS */
}

extern void findh_blank(int numblanks,char word[16],int xpos,int ypos,
			int *curr_bestscore,char curr_bestword[16],
			char tempboard[BOARDSIZE][BOARDSIZE],char prefix[16],
			int numlett)
{
    int count,scount;
    char blanktiles[NUMBLANKS] = BLANKTILES;
    int c,fblankpos = -1,sblankpos = -1,wordlength,indict,checkx;
    int currscore,foundfirst,foundsecond,valid;
    char checkdict[16],temp[16];
	
    /* using slow loop method!!! */
    wordlength = strlen(word);
    if (numblanks == 1)
	/* find words for 1 blank */
    {
	for (c = 0;c <= wordlength;c++)
	    if (word[c] == '*')
		fblankpos = c;
	for (count = 0;count < NUMBLANKS;count++)
	{
	    assert(fblankpos < 16);
	    word[fblankpos] = blanktiles[count];
			
	    strcpy(temp,prefix);
	    strcpy(checkdict,strcat(temp,word));
	    convupper(checkdict);
	    indict = wordsearch(checkdict);
	    if (indict)
	    {
		/* insert the letters on the temp board */
		for (checkx = xpos; checkx < xpos+numlett; checkx++)
		{
		    assert(checkx < BOARDSIZE);
		    assert(ypos < BOARDSIZE);
		    tempboard[checkx][ypos] = word[checkx-xpos];
		}
		/* now check all words created */
		valid = checkwords(tempboard,xpos,ypos,xpos+wordlength-1,ypos,0,&currscore);
		if ((valid == VALID)&&(currscore > *curr_bestscore))
		{
		    *curr_bestscore = currscore;
		    strcpy(curr_bestword,word);
		}
	    }
	}
    }
    else
	/* find words for 2 blanks */
    {
	c = 0; foundfirst = 0; foundsecond = 0;
	while ((c <= wordlength)&&(!foundsecond))
	{
	    if (word[c] == '*')
	    {
		if (!foundfirst)
		{
		    fblankpos = c;
		    foundfirst = 1;
		}
		else
		{
		    sblankpos = c;
		    foundsecond = 1;
		}
	    }
	    c++;
	}
		
	for (count = 0;count < NUMBLANKS;count++)
	    for (scount = 0;scount < NUMBLANKS;scount++)
	    {
		assert(fblankpos < 16);
		assert(sblankpos < 16);
		word[fblankpos] = blanktiles[count];
		word[sblankpos] = blanktiles[scount];
		strcpy(temp,prefix);
		strcpy(checkdict,strcat(temp,word));
		convupper(checkdict);
		indict = wordsearch(checkdict);
		if (indict)
		{
		    /* insert the letters on the temp board */
		    for (checkx = xpos; checkx < xpos+numlett; checkx++)
		    {
			assert(checkx < BOARDSIZE);
			assert(ypos < BOARDSIZE);
			tempboard[checkx][ypos] = word[checkx-xpos];
		    }
		    /* now check all words created */
		    valid = checkwords(tempboard,xpos,ypos,xpos+wordlength-1,ypos,0,&currscore);
		    if ((valid == VALID)&&(currscore > *curr_bestscore))
		    {
			*curr_bestscore = currscore;
			strcpy(curr_bestword,word);
		    }
		}
	    }
    }
}

extern void findv_blank(int numblanks,char word[16],int xpos,int ypos,
			int *curr_bestscore,char curr_bestword[16],
			char tempboard[BOARDSIZE][BOARDSIZE],char prefix[16],
			int numlett)
{
    int count,scount;
    char blanktiles[NUMBLANKS] = BLANKTILES;
    int c,fblankpos = -1,sblankpos = -1,wordlength,indict,checky;
    int currscore,foundfirst,foundsecond,valid;
    char checkdict[16],temp[16];
	
    /* using slow loop method!!! */
    wordlength = strlen(word);
    if (numblanks == 1)
	/* find words for 1 blank */
    {
	for (c = 0;c <= wordlength;c++)
	    if (word[c] == '*')
		fblankpos = c;
	for (count = 0;count < NUMBLANKS;count++)
	{
	    assert(fblankpos < 16);
	    word[fblankpos] = blanktiles[count];
			
	    strcpy(temp,prefix);
	    strcpy(checkdict,strcat(temp,word));
	    convupper(checkdict);
	    indict = wordsearch(checkdict);
	    if (indict)
	    {
		/* insert the letters on the temp board */
		for (checky = ypos; checky < ypos+numlett; checky++)
		{
		    assert(checky < BOARDSIZE);
		    assert(xpos < BOARDSIZE);
		    tempboard[xpos][checky] = word[checky-ypos];
		}
		/* now check all words created */
		valid = checkwords(tempboard,xpos,ypos,xpos,ypos+wordlength-1,0,&currscore);
		if ((valid == VALID)&&(currscore > *curr_bestscore))
		{
		    *curr_bestscore = currscore;
		    strcpy(curr_bestword,word);
		}
	    }
	}
    }
    else
	/* find words for 2 blanks */
    {
	c = 0; foundfirst = 0; foundsecond = 0;
	while ((c <= wordlength)&&(!foundsecond))
	{
	    if (word[c] == '*')
	    {
		if (!foundfirst)
		{
		    fblankpos = c;
		    foundfirst = 1;
		}
		else
		{
		    sblankpos = c;
		    foundsecond = 1;
		}
	    }
	    c++;
	}

	for (count = 0;count < NUMBLANKS;count++)
	    for (scount = 0;scount < NUMBLANKS;scount++)
	    {
		assert(fblankpos < 16);
		assert(sblankpos < 16);
		word[fblankpos] = blanktiles[count];
		word[sblankpos] = blanktiles[scount];
					
		strcpy(temp,prefix);
		strcpy(checkdict,strcat(temp,word));
		convupper(checkdict);
		indict = wordsearch(checkdict);
		if (indict)
		{
		    /* insert the letters on the temp board */
		    for (checky = ypos; checky < ypos+numlett; checky++)
		    {
			assert(checky < BOARDSIZE);
			assert(xpos < BOARDSIZE);
			tempboard[xpos][checky] = word[checky-ypos];
		    }
		    /* now check all words created */
		    valid = checkwords(tempboard,xpos,ypos,xpos,ypos+wordlength-1,0,&currscore);
		    if ((valid == VALID)&&(currscore > *curr_bestscore))
		    {
			*curr_bestscore = currscore;
			strcpy(curr_bestword,word);
		    }
		}
	    }
    }
}

void checkh_words(int x, int y,char best[16],int *bestscore,int numlett)
{
    char test[16], dummy[16],temp[16];
    int locked[8] = {0,0,0,0,0,0,0,0};
    int checkx;
    int maxlett = numlett;
    int inslett;
    int indict;
    char tempboard[BOARDSIZE][BOARDSIZE];
    int bx,by;
    int count,rev;
    int currscore;
    int num_perm,wordlen,valid;
    int blank; /* represents whether there is a blank in the word */
    int space; /* represents whether there is a space in the bar */

    *bestscore = 0;
	
    /* make a copy of board */
    for (bx = 0; bx < BOARDSIZE; bx++)
	for (by = 0; by < BOARDSIZE; by++)
	    tempboard[bx][by]=board[bx][by];

    /* lock the tiles in the test word */
    for (checkx = x; checkx < x+numlett; checkx++)
    {
	if ((checkx < BOARDSIZE)&&(board[checkx][y] != ' '))
	{
	    assert((checkx-x) < 16);
	    test[checkx-x] = board[checkx][y];
	    assert((checkx-x) < 8);
	    locked[checkx-x] = 1;
	    maxlett--;
	}
    }

    /* create a string containing the letters before the word */
    if ((x-1 >= 0)&&(board[x-1][y] != ' '))
    {
	count = 1;
	while ((x-count >= 0)&&(board[x-count][y] != ' '))
	{
	    count++;
	}
	count--;
	for (rev = count;rev > 0;rev--)
	{
	    assert((count - rev) < 16);
	    dummy[count-rev] = board[x-rev][y];
	}
	assert(count < 16);
	dummy[count] = '\0';
    }
    else
	dummy[0]='\0';
	
    num_perm = numperms[maxlett-1];

    for (count = 0; count < num_perm; count++)
    {
	ProcessEvent();
	
	/* insert the letters in the test word */
	inslett = 0;
	blank = 0;
	space = 0;
	for (checkx = 0; checkx < numlett; checkx++)
	{
	    if (!locked[checkx])
	    {
		assert(checkx < 16);
		test[checkx] = player[curr_player].bar[perms[maxlett-1][count][inslett++]];
		if (test[checkx] == '*')
		    blank++;
		if (test[checkx] == ' ')
		    space++;
	    }
	    /* cycles lettptr array, depending of number of letters to
	       place (maxlett), and letter just placed */
	}
	

	/* if the word created contains a space end immediately */
	if (!space)
	{

	    /* fill in the letters after the word placed */
	    while ((x+checkx < BOARDSIZE)&&(board[x+checkx][y] != ' '))
	    {
		assert(checkx < 16);
		test[checkx] = board[x+checkx][y];
		checkx++;
	    }
	    assert(checkx < 16);
	    test[checkx]='\0';
	    wordlen = checkx-1;

	    /* if there is no blank in the word check normaly*/
	    if (!blank)
	    {
		strcpy(temp,dummy);
		indict = wordsearch(strcat(temp,test));
		if (indict)
		{
		    /* insert the letters on the temp board */
		    for (checkx = x; checkx < x+numlett; checkx++)
		    {
			assert(checkx < BOARDSIZE);
			assert(y < BOARDSIZE);
			tempboard[checkx][y] = test[checkx-x];
		    }
		    /* now check all words created */
		    valid = checkwords(tempboard,x,y,x+wordlen,y,0,&currscore);
			
		    if ((valid == VALID)&&(currscore > *bestscore))
		    {
			*bestscore = currscore;
			strcpy(best,test);
		    }
		}
	    }
	    else
	    {
		/* run words with blanks routine */
		findh_blank(blank,test,x,y,bestscore,best,tempboard,dummy,numlett);
	    }
	    /* next word */
	}
    }
}

void checkv_words(int x, int y,char best[16],int *bestscore,int numlett)
{
    char test[16], dummy[16],temp[16];
    int locked[8] = {0,0,0,0,0,0,0,0};
    int checky;
    int maxlett = numlett;
    int inslett;
    int indict;
    char tempboard[BOARDSIZE][BOARDSIZE];
    int bx,by;
    int count,rev;
    int currscore;
    int num_perm,wordlen,valid;
    int blank; /* represents whether there is a blank in the word */
    int space; /* represents whether there is a space in the bar */
	
    *bestscore = 0;
	
    /* make a copy of board */
    for (bx = 0; bx < BOARDSIZE; bx++)
	for (by = 0; by < BOARDSIZE; by++)
	    tempboard[bx][by]=board[bx][by];

    /* lock the tiles in the test word */
    for (checky = y; checky < y+numlett; checky++)
    {
	if ((checky < BOARDSIZE)&&(board[x][checky] != ' '))
	{
	    assert((checky-y) < 16);
	    test[checky-y] = board[x][checky];
	    assert((checky-y) < 8);
	    locked[checky-y] = 1;
	    maxlett--;
	}
    }

    /* create a string containing the letters before the word */
    if ((y-1 >= 0)&&(board[x][y-1] != ' '))
    {
	count = 1;
	while ((y-count >= 0)&&(board[x][y-count] != ' '))
	{
	    count++;
	}
	count--;
	for (rev = count;rev > 0;rev--)
	{
	    assert((count-rev) < 16);
	    dummy[count-rev] = board[x][y-rev];
	}
	assert(count < 16);
	dummy[count] = '\0';
    }
    else
	dummy[0]='\0';
	
    num_perm = numperms[maxlett-1];

    for (count = 0; count < num_perm; count++)
    {
	ProcessEvent();
	
	/* insert the letters in the test word */
	inslett = 0;
	blank = 0;
	space = 0;
	for (checky = 0; checky < numlett; checky++)
	{
	    if (!locked[checky])
	    {
		assert(checky < 16);
		test[checky] = player[curr_player].bar[perms[maxlett-1][count][inslett++]];
		if (test[checky] == '*')
		    blank++;
		if (test[checky] == ' ')
		    space++;
	    }
	    /* cycles lettptr array, depending of number of letters to
	       place (maxlett), and letter just placed */
	}
	
	/* if the word created contains a space end immediately */
	if (!space)
	{
	
	    /* fill in the letters after the word placed */
	    while ((y+checky < BOARDSIZE)&&(board[x][y+checky] != ' '))
	    {
		assert(checky < 16);
		test[checky] = board[x][y+checky];
		checky++;
	    }
	    assert(checky < 16);
	    test[checky]='\0';
	    wordlen = checky-1;

	    /* if there is no blank in the word check normaly*/
	    if (!blank)
	    {
		strcpy(temp,dummy);
		indict = wordsearch(strcat(temp,test));
		if (indict)
		{
		    /* insert the letters on the temp board */
		    for (checky = y; checky < y+numlett; checky++)
		    {
			assert(x < BOARDSIZE);
			assert(checky < BOARDSIZE);
			tempboard[x][checky] = test[checky-y];
		    }
		    /* now check all words created */
		    valid = checkwords(tempboard,x,y,x,y+wordlen,0,&currscore);
			
		    if ((valid == VALID)&&(currscore > *bestscore))
		    {
			*bestscore = currscore;
			strcpy(best,test);
		    }
		}
	    }
	    else
	    {
		/* run words with blanks routine */
		findv_blank(blank,test,x,y,bestscore,best,tempboard,dummy,numlett);
	    }
	    /* next word */
	}
    }
}


void comp_move(int *compscore,int level)
{
    int x,y,checkgo;
    char bestword[16],newword[16];
    int bestscore = 0,newscore = 0;
    int bestdir = 0; /* direction of best word 0 = horiz, 1 = vert */
    int bx = -1,by = -1;
    int foundgo = 0;
    int wordlength;
    char lettused[8];
    int used,rembar;
    int randlen;
    int sum,counter;
    int smallestword, largestword;
    float percinc, searchinc, realinc, removeinc, currperc, sizeinc;

    if ((level>0)&&(level < 7))
    {
	randlen = (rand()%norms_max[level-1])+1;
	sum = 0;
	counter = 0;	
	while ((sum < norms_max[level-1]+1)&&(sum < randlen))
	{
	    sum+=norms[level-1][counter];
	    counter++;
	}
	smallestword = counter - (level-1);
	largestword = counter + (level-1);
	if (smallestword < 1) smallestword = 1;
	if (largestword > 7) largestword = 7;
    }
    else
    {
	smallestword = 1;
	largestword = 7;
    }
	
    percinc = 93.0 / (largestword - smallestword + 1.0);
    realinc = 0;
    currperc = 0;
    UpdateComp((int)currperc);

    sizeinc = percinc / (largestword+1-smallestword);
    for (wordlength =smallestword; wordlength < largestword+1; wordlength++)
    {
	searchinc = sizeinc / (BOARDSIZE-wordlength+1);
	for (x=0; x < BOARDSIZE-wordlength+1; x++)
	{
	    ProcessEvent();
	    if (searchinc > 0) UpdateComp((int)currperc);
	    for (y=0; y < BOARDSIZE-wordlength+1; y++)
	    {
		ProcessEvent();
		checkgo = check_boardh(x,y,wordlength);
		if (checkgo == VALID)
		{
		    checkh_words(x,y,newword,&newscore,wordlength);
		    if (newscore > bestscore)
		    {
			strcpy(bestword,newword);
			bx = x; by = y;
			bestscore = newscore;
			bestdir = 0;
			foundgo=1;
		    }
		}
		/*ProcessEvent();*/
		checkgo = check_boardv(x,y,wordlength);
		if (checkgo == VALID)
		{
		    checkv_words(x,y,newword,&newscore,wordlength);
		    if (newscore > bestscore)
		    {
			strcpy(bestword,newword);
			bx = x; by = y;
			bestscore = newscore;
			bestdir = 1;
			foundgo=1;
		    }
		}
	    }
	    currperc += searchinc;
	}
	realinc += percinc;
	currperc = realinc;
	if (searchinc == 0) UpdateComp(currperc);
    }

    /*
    if (foundgo)
    {
	printf("Computer goes ");
	if (bestdir == 0)
	    printf("Horizontaly ");
	else
	    printf("Verticaly ");
	printf("at (%i,%i) with : %s, scoring : %i\n",bx,by,bestword,bestscore);
    }
    else
	printf("Computer cannot go!");
	*/

    /*	currperc = 93.0;*/
    UpdateComp((int)currperc);
	
    if (foundgo)
    {
	lettused[0] = '\0';
	wordlength = strlen(bestword);
	if (bestdir == 0)
	    for(x=bx;x < bx+wordlength;x++)
	    {
		if (board[x][by] == ' ')
		{
		    assert((strlen(lettused)+1) < 8);
		    lettused[strlen(lettused)+1] = '\0';
		    assert(strlen(lettused) < 8);
		    lettused[strlen(lettused)] = bestword[x-bx];
		}
		assert(x < BOARDSIZE);
		assert(by < BOARDSIZE);
		board[x][by] = bestword[x-bx];
	    }
	else
	    for(y=by;y < by+wordlength;y++)
	    {
		if (board[bx][y] == ' ')
		{
		    assert((strlen(lettused)+1) < 8);
		    lettused[strlen(lettused)+1] = '\0';
		    assert(strlen(lettused) < 8);
		    lettused[strlen(lettused)] = bestword[y-by];
		}
		assert(bx < BOARDSIZE);
		assert(y < BOARDSIZE);
		board[bx][y] = bestword[y-by];
	    }
	assert(curr_player < 4);
	player[curr_player].score += bestscore;
	*compscore = bestscore;
	removeinc = 7.0 / strlen(lettused);
	for (used = 0; used < (int)strlen(lettused);used++)
	{
	    for (rembar = 0; rembar < BARLEN;rembar++)
	    {
		if ((islower(lettused[used])&&
		     (player[curr_player].bar[rembar] == '*'))||
		    (player[curr_player].bar[rembar] ==
		     lettused[used]))
		{
		    assert(rembar < BARLEN);
		    player[curr_player].bar[rembar] = ' ';
		    break;
		}
	    }
	    currperc += removeinc;
	    UpdateComp((int)currperc);
	}
	fillbar((int)curr_player);
    }
    else
    {
	*compscore = 0;
    }
    UpdateComp(100);
}

			*bestscore = currscore;
			strcpy(best,test);
		    }
		}
	    }
	    else
	    {
		/* run words with blanks routine */
		findv_blank(blank,test,x,y,bestscore,best,tempboard,dummy,numlett);
	    }
	    /* next word */
	}
    }
}


void comp_move(int *compscore,int level)
{
    int x,y,checkgo;
    char bestword[16],newword[16];
    int bestscore = 0,newscore = 0;
    int bestdir = 0; /* direction of best word 0 = horiz, 1 = vert */
    int bx = -1,xscrabble/src/display.c100600 000310 000001 00000011742 06173540110 016322 0ustar00mchapmanstaff000000 000000 /*
 *  XScrabble - X version of the popular board game, for 1 to 4 players.
 *
 * This software comes with NO warranty whatsoever. I therefore take no
 * responsibility for any damages, losses or problems caused through use
 * or misuse of this program.
 *
 * I hereby grant permission for this program to be freely copied and
 * distributed by any means, provided no charge is made for it.
 *
 * Matthew Chapman, csuoq@csv.warwick.ac.uk
 *    Oct 1994.
 */

/* display.c - output functions for X interface */

#include "scrab.h"
#include "globals.h"

void ShowTiles()
{
	char lname[2];
	int ac,dn;
	
	for (dn=0; dn<BOARDSIZE; dn++)
		for (ac=0; ac<BOARDSIZE; ac++)
			if (cboard[ac][dn] != ' ')
			{
				sprintf(lname,"%c",cboard[ac][dn]);
				XtVaSetValues(sq[curr_player][ac][dn],XtNlabel,lname,
					SETBG(TILECOL),NULL);
				is_perm[ac][dn]=True;
			}
			else
			{
				XtVaSetValues(sq[curr_player][ac][dn],XtNlabel," ",
						SETBG((char *)colours[sq_col[ac][dn]]),NULL);
				is_perm[ac][dn]=False;
			}
}

void ShowBoard(Boolean leavecolours)
{
	/* display board for everyone */
	int ac,dn,i;
	char lname[2];

	for (i=0; i<num_players; i++)
		for (dn=0; dn<BOARDSIZE; dn++)
			for (ac=0; ac<BOARDSIZE; ac++)
				if (board[ac][dn] != ' ')
				{
					sprintf(lname,"%c",board[ac][dn]);
					XtVaSetValues(sq[i][ac][dn],XtNlabel,lname,NULL);
					if (leavecolours && (!is_perm[ac][dn]))
						XtVaSetValues(sq[i][ac][dn],SETBG(BRIGHTCOL),NULL);
					else
						XtVaSetValues(sq[i][ac][dn],SETBG(TILECOL),NULL);
				}
}

void ShowBar(int ply)
{
	/* display letters in bar for player number ply */
	int i;
	char ch,lett[3];

	for (i=0; i<LONGBAR; i++)
	{
		if ((i>2) && (i<10))
		{
			/* in central part of bar */
			ch=player[ply].bar[i-3];
			bar[ply][i]=ch;
			sprintf(lett,"%c",ch);
			if (ch==' ')
				XtVaSetValues(br[ply][i],SETBG(BARCOL),XtNlabel,lett,NULL);
			else
				XtVaSetValues(br[ply][i],SETBG(BRIGHTCOL),XtNlabel,lett,NULL);
		}
		else
		{
			XtVaSetValues(br[ply][i],SETBG(BARCOL),XtNlabel," ",NULL);
			bar[ply][i]=' ';
		}
	}
}

void ShowScores()
{
	int i,rep;
	char scoretext[256]="",scstring[8];

	for (i=0; i<num_players; i++)
	{
		if (i==curr_player)
			strcat(scoretext,">");
		else
			strcat(scoretext," ");
		strcat(scoretext,player[i].name);
		sprintf(scstring,"%d",player[i].score);
		for (rep=0; rep<(int)(16-strlen(player[i].name)-strlen(scstring)); rep++)
			strcat(scoretext,".");
		strcat(scoretext,scstring);
		if (i<num_players-1)
			strcat(scoretext,"\n");
	}	
	
	for (i=0; i<num_players; i++)
		XtVaSetValues(scorebox[i],XtNlabel,scoretext,NULL);
}

void TilesLeft()
{
	char tileltext[256];
	int i;
/*printf("bagprt+1 = %d\n",bagptr+1);	*/
	sprintf(tileltext,"%s%d",TILES_LEFT,bagptr+1);
/*printf("tileltext = %s\n",tileltext);*/
	for (i=0; i<num_players; i++)
		XtVaSetValues(tilesleft[i],XtNlabel,tileltext,NULL);
/*printf("tileltext = %s\n",tileltext);*/

}

/* for the timer */
void Click()
{
	if (!finished_go)
	{
        comp+=10;
        if (comp==10000-10*50)
        	XBell(dpy[curr_player],50);
        if (comp==10000-10*25)
        	XBell(dpy[curr_player],75);
        if (comp==10000/2)
        	XBell(dpy[curr_player],50);
        if (comp>10000)
		{
			char mess[256];
			
			XBell(dpy[curr_player],100);
			sprintf(mess,OUT_TIME_ALL,player[curr_player].name);
			Message(curr_player,OUT_TIME,mess);
			Deselect(curr_player);

			RemoveFromBoard();
			ShowTiles();
			ShowBar(curr_player);
			num_passed=0;
			if (waiting_for_change)
			{
				XtPopdown(changeshell);
				XtDestroyWidget(changeshell);
				waiting_for_change=False;
			}
			if (waiting_for_blank)
			{
				XtPopdown(blankshell);
				XtDestroyWidget(blankshell);
				waiting_for_blank=False;
			}
			GotoNextPlayer();
		}
		else
		{
	        XtVaSetValues(timeleft[curr_player],XtNpercentageCompleted,
	        	comp,NULL);
	        XtAppAddTimeOut(app_context,55*time_limit,Click,
	        	timeleft[curr_player]);
		}
	}
}


void MessageAll(char *mess)
{
	/* send same message to everyone */
	int i;

	for (i=0; i<num_players; i++)
		XtVaSetValues(message[i],XtNlabel,mess,NULL);
}

void Message(int ply,char *mess1, char *mess2)
{
	/* send mess1 to ply, and mess2 to everyone else */
	int i;
	
	for (i=0; i<num_players; i++)
		if (i==ply)
			XtVaSetValues(message[i],XtNlabel,mess1,NULL);
		else
			XtVaSetValues(message[i],XtNlabel,mess2,NULL);
}

void MessageOne(int ply,char *mess)
{
	/* send mess only to ply */
	XtVaSetValues(message[ply],XtNlabel,mess,NULL);
}

void EndDelay()
{
	waiting=False;
}

void Wait(int delay)
{
	/* wait for specified time, processing X events */
	waiting=True;
	XtAppAddTimeOut(XtWidgetToApplicationContext(message[0]),delay,
		EndDelay,message[0]);
	while (waiting==True)
		ProcessEvent();
}

void ProcessEvent()
{
	/* processes any pending events */
	XtInputMask msk=XtIMAll;
	if (XtAppPending(app_context)!=0)
		XtAppProcessEvent(app_context,msk);	
}

void UpdateComp(int perc)
{
	/* on computer's move, update Xc widget with % completed */
  /*  printf("Update value = %i\n",perc);*/
	XcBGUpdateValue(compw[curr_player],&perc);
}
rdlength);
		if (checkgo == VAxscrabble/src/dot.xbm100600 000310 000001 00000000335 05725660115 016015 0ustar00mchapmanstaff000000 000000 #define dot_width 12
#define dot_height 12
static char dot_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0xf8, 0x01, 0xf8, 0x01,
   0xf8, 0x01, 0xf8, 0x01, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
				{
					sprintf(lname,"%c",board[ac][dn]);
					XtVaSetValues(sq[i][ac][dn],XtNlabel,lname,NULL);
					if (leavecolours && (!is_perm[ac][dn]))
						XtVaSetValues(sq[i][ac][dn],SETBG(BRIGHTCOL),NULL);
					else
						XtVaSetValues(sq[i][ac][dn],SETBG(TILECOL),NULL);
				}
}

void ShowBarxscrabble/src/globals.h100600 000310 000001 00000005333 06303060417 016306 0ustar00mchapmanstaff000000 000000 /*
	globals.h - external variables
*/

#include "xglobals.h"

extern char board[BOARDSIZE][BOARDSIZE];
extern char bag[BAGSIZE];
extern int bagptr;
extern scoreStat highscores[4][NUMHIGHSCORES];
extern int num_players;
extern playerStat player[MAXPLAYERS];
extern int letterscore[26];
extern int sq_col[BOARDSIZE][BOARDSIZE];
extern int curr_player;
extern char dict[DICTSIZE][16];
extern int word_pos[15];
extern short int perms[7][5040][7];
extern int numperms[7];
extern int norms[6][7];
extern int norms_max[6];
extern goStat bestgos[NUMGOSCORES];

/* external prototypes for misc.c */
extern void loaddict();
extern void loadperms();
extern void savegame();
extern void loadgame();
extern void savescores();
extern void loadscores();
extern void alterscores();
extern void alterbestgo(int goscore,char *wordsmade);
extern void showscores(int numplay,char outstring[256]);
extern void showgoscores(char *outstring);
extern unsigned int wordsearch(char *word);
extern void clearboard(char b[BOARDSIZE][BOARDSIZE]);
extern void makebag();
extern void shufflebag();
extern void addtobag(char *letts);
extern void fillbar(int playernum);
extern int bartotal(int playernum);
extern void takeletters(int numletters,char *letters);
extern void playersetup(char playername[MAXPLAYERS][NAMELEN]);
extern void showbag();
extern void showboard(char b[BOARDSIZE][BOARDSIZE]);
extern void showstats();

/* external prototypes for moves.c */
extern void convupper(char *str);
extern unsigned int emptyboard(char b[BOARDSIZE][BOARDSIZE]);
extern int validate(char newboard[BOARDSIZE][BOARDSIZE],int testing,int *goscore);
extern int checkwords(char nb[BOARDSIZE][BOARDSIZE],int sx,int sy,int ex,int ey,int testing,int *goscore);
extern void addhword(char newboard[BOARDSIZE][BOARDSIZE],int x,int y,char *word,int length);
extern void addvword(char newboard[BOARDSIZE][BOARDSIZE],int x,int y,char *word,int length);
extern int scoreword(int sx,int sy,int ex,int ey, char nb[BOARDSIZE][BOARDSIZE]);

/* external prototypes for cmove.c */
extern int check_boardh(int x,int y,int numlett);
extern int check_boardv(int x, int y,int numlett);
extern void makeperm(short int p[7][5040][7],int num[7]);
extern void findh_blank(int numblanks,char word[16],int xpos,int ypos,
			int *curr_bestscore,char curr_bestword[16],
			char tempboard[BOARDSIZE][BOARDSIZE],char prefix[16],
			int numlett);
extern void findv_blank(int numblanks,char word[16],int xpos,int ypos,
			int *curr_bestscore,char curr_bestword[16],
			char tempboard[BOARDSIZE][BOARDSIZE],char prefix[16],
			int numlett);
extern void checkh_words(int x, int y,char best[16],int *bestscore,int numlett);
extern void checkv_words(int x, int y,char best[16],int *bestscore,int numlett);
extern void comp_move(int *compscore,int level);
extern playerStat player[MAXPLAYERS];
extern int letterscore[26];
extern int sq_col[BOARDSIZE][BOARDSIZE];
extern int curr_player;
extern char dict[DICTSIZE][16];
extern int word_pos[15];
extern short int perms[7][5040][7];
extern int numperms[7];
extern int norms[6][7];
extern int norms_max[xscrabble/src/init.c100600 000310 000001 00000003126 05750733272 015632 0ustar00mchapmanstaff000000 000000 /*	XScrabble v1.00
	init.c
	initialisation routines
	By csuos@warwick.ac.uk
*/

#include "scrab.h"
#include "globals.h"

char board[BOARDSIZE][BOARDSIZE];
char bag[BAGSIZE];
int bagptr = BAGSIZE-1;

scoreStat highscores[4][NUMHIGHSCORES];

int num_players;
playerStat player[MAXPLAYERS];/* for the coloured squares, and bonues */
int curr_player = 0;

/* 0 = normal square (green)
   1 = double letter (skyblue)
   2 = triple letter (dark blue)
   3 = double word (orange)
   4 = triple word (red)
*/

int sq_col[BOARDSIZE][BOARDSIZE] =
{
        {4,0,0,1,0,0,0,4,0,0,0,1,0,0,4},
        {0,3,0,0,0,2,0,0,0,2,0,0,0,3,0},
        {0,0,3,0,0,0,1,0,1,0,0,0,3,0,0},
        {1,0,0,3,0,0,0,1,0,0,0,3,0,0,1},
        {0,0,0,0,3,0,0,0,0,0,3,0,0,0,0},
        {0,2,0,0,0,2,0,0,0,2,0,0,0,2,0},
        {0,0,1,0,0,0,1,0,1,0,0,0,1,0,0},
        {4,0,0,1,0,0,0,3,0,0,0,1,0,0,4},
        {0,0,1,0,0,0,1,0,1,0,0,0,1,0,0},
        {0,2,0,0,0,2,0,0,0,2,0,0,0,2,0},
        {0,0,0,0,3,0,0,0,0,0,3,0,0,0,0},
        {1,0,0,3,0,0,0,1,0,0,0,3,0,0,1},
        {0,0,3,0,0,0,1,0,1,0,0,0,3,0,0},
        {0,3,0,0,0,2,0,0,0,2,0,0,0,3,0},
        {4,0,0,1,0,0,0,4,0,0,0,1,0,0,4}
};

int letterscore[NUMLETTERS] = LETTER_SCORES;

/* The dictionary */ 
char dict[DICTSIZE][16];
int word_pos[15];

/* the permutation lists */
short int perms[7][5040][7];
int numperms[7];

int norms[6][7] =
{
	{0,0,0,10,0,0,0},
	{0,0,5,20,5,0,0},
	{0,0,10,20,40,5,0},
	{20,40,60,80,100,10,5},
	{20,40,60,80,100,120,5},
	{20,40,60,80,100,120,60}
};
int norms_max[6] = {9,29,74,314,424,479};
/* sum of the normal distribution values -1 */

goStat bestgos[NUMGOSCORES];
checkwords(char nb[BOARDSIZE][BOARDSIZE],int sx,int sy,int ex,int ey,int testing,int *goscore);
extern void addhword(char newboard[BOARDSIZE][BOARDSIZE],int x,int y,char *word,int length);
extern void addvword(char newboard[BOARDSIZE][BOARDSIZE],int x,int y,char *word,int length);
extern int scoreword(int sx,int sy,int ex,int ey, char nb[BOARDSIZE][BOARDSIZE]);

/* external prototypes for cmove.c */
extern int check_boardhxscrabble/src/main.c100600 000310 000001 00000013445 06310726424 015612 0ustar00mchapmanstaff000000 000000 /*
 *  XScrabble - X version of the popular board game, for 1 to 4 players.
 *
 * This software comes with NO warranty whatsoever. I therefore take no
 * responsibility for any damages, losses or problems caused through use
 * or misuse of this program.
 *
 * I hereby grant permission for this program to be freely copied and
 * distributed by any means, provided no charge is made for it.
 *
 * Matthew Chapman, csuoq@csv.warwick.ac.uk
 *    Nov 1994.
 */

/* main.c - the main function */

#include "scrab.h"
#include "globals.h"

#include "xscrabble.xpm"
#include "slate_green.xpm"

/* option types and default values */
static XtResource resources[] =
{
	{"version","Version",XtRInt,sizeof(int),XtOffsetOf(struct AppData,version),
		XtRImmediate,(XtPointer) 0},
	{"load","Load",XtRBoolean,sizeof(Boolean),XtOffsetOf(struct AppData,load),
		XtRImmediate,(XtPointer) False},
	{"players","Players",XtRInt,sizeof(int),XtOffsetOf(struct AppData,players),
		XtRImmediate,(XtPointer) 1},
	{"time","Time",XtRInt,sizeof(int),XtOffsetOf(struct AppData,timelim),
		XtRImmediate,(XtPointer) 0},
	{"d1","D1",XtRString,sizeof(String),XtOffsetOf(struct AppData,disp[0]),
		XtRImmediate,":0.0"},
	{"d2","D2",XtRString,sizeof(String),XtOffsetOf(struct AppData,disp[1]),
		XtRImmediate,":0.0"},
	{"d3","D3",XtRString,sizeof(String),XtOffsetOf(struct AppData,disp[2]),
		XtRImmediate,":0.0"},
	{"d4","D4",XtRString,sizeof(String),XtOffsetOf(struct AppData,disp[3]),
		XtRImmediate,":0.0"},
	{"n1","N1",XtRString,sizeof(String),XtOffsetOf(struct AppData,name[0]),
		XtRImmediate,"Player 1"},
	{"n2","N2",XtRString,sizeof(String),XtOffsetOf(struct AppData,name[1]),
		XtRImmediate,"Player 2"},
	{"n3","N3",XtRString,sizeof(String),XtOffsetOf(struct AppData,name[2]),
		XtRImmediate,"Player 3"},
	{"n4","N4",XtRString,sizeof(String),XtOffsetOf(struct AppData,name[3]),
		XtRImmediate,"Player 4"},
	{"t1","T1",XtRInt,sizeof(int),XtOffsetOf(struct AppData,t[0]),
		XtRImmediate,(XtPointer) 0},
	{"t2","T2",XtRInt,sizeof(int),XtOffsetOf(struct AppData,t[1]),
		XtRImmediate,(XtPointer) 0},
	{"t3","T3",XtRInt,sizeof(int),XtOffsetOf(struct AppData,t[2]),
		XtRImmediate,(XtPointer) 0},
	{"t4","T4",XtRInt,sizeof(int),XtOffsetOf(struct AppData,t[3]),
		XtRImmediate,(XtPointer) 0},
	{"dictfile","Dictfile",XtRString,sizeof(String),
	 XtOffsetOf(struct AppData,dictfile),XtRImmediate,
	 "/usr/local/lib/OSPD3"},
	{"permfile","Permfile",XtRString,sizeof(String),
	 XtOffsetOf(struct AppData,permfile),XtRImmediate,
	 "/usr/local/lib/scrabble_permutations"},
	{"scorefile","Scorefile",XtRString,sizeof(String),
	 XtOffsetOf(struct AppData,scorefile),XtRImmediate,
	 "/usr/local/lib/xscrabble.scores"},
};

/* resource options */
static XrmOptionDescRec options[] =
{
        {"-load",     	 "*load",        XrmoptionNoArg, "True" },
        {"-players",     "*players",     XrmoptionSepArg, NULL  },
        {"-time",     	 "*time",        XrmoptionSepArg, NULL  },
        {"-d1",      	 "*d1",          XrmoptionSepArg, NULL  },
        {"-d2",      	 "*d2",          XrmoptionSepArg, NULL  },
        {"-d3",      	 "*d3",          XrmoptionSepArg, NULL  },
        {"-d4",      	 "*d4",          XrmoptionSepArg, NULL  },
        {"-n1",      	 "*n1",          XrmoptionSepArg, NULL  },
        {"-n2",      	 "*n2",          XrmoptionSepArg, NULL  },
        {"-n3",      	 "*n3",          XrmoptionSepArg, NULL  },
        {"-n4",      	 "*n4",          XrmoptionSepArg, NULL  },
        {"-t1",      	 "*t1",          XrmoptionSepArg, NULL  },
        {"-t2",      	 "*t2",          XrmoptionSepArg, NULL  },
        {"-t3",      	 "*t3",          XrmoptionSepArg, NULL  },
        {"-t4",      	 "*t4",          XrmoptionSepArg, NULL  },
        {"-dictfile",  	 "*dictfile",    XrmoptionSepArg, NULL  },
        {"-permfile",  	 "*permfile",    XrmoptionSepArg, NULL  },
        {"-scorefile", 	 "*scorefile",   XrmoptionSepArg, NULL  },
};

void main(int argc, char **argv)
{
	char defaultname[MAXPLAYERS][NAMELEN];
	int i;
	Widget topLevel;
	Boolean any_comp=False;

	topLevel = XtVaAppInitialize(&app_context,"XScrabble",options,XtNumber(options),
		&argc,argv,NULL,NULL);

	XtVaGetApplicationResources(topLevel,&app_data,resources,
		XtNumber(resources),NULL);

	if (app_data.version != VERSION)
	{
		fprintf(stderr,"Couldn't find resource file XScrabble.\n");
		exit(1);
	}
	
	for (i=0; i<MAXPLAYERS; i++)
		type[i]=app_data.t[i];
	
	num_players=app_data.players;
	time_limit=app_data.timelim;

	for (i=0; i<num_players; i++)
	{
		dpy[i] = XtOpenDisplay(app_context,app_data.disp[i],argv[0],"XScrabble",
			NULL,0,&argc, argv); 
		if (dpy[i] == NULL)
		{
			printf("Can't open display %s\n",app_data.disp[i]);
			exit(1);
		}
		strcpy(defaultname[i],app_data.name[i]);
		
		/* check for any computer players */
		if (app_data.t[i]>0)
		    any_comp=True;
	}

	loaddict();
	if (any_comp)
	    makeperm(perms,numperms);

	clearboard(cboard);
	clearboard(board);
	makebag();
	shufflebag();
	playersetup(defaultname);

	for (i=0; i<num_players; i++)
	{
		topl[i] =  XtVaAppCreateShell("topl","XScrabble",
			applicationShellWidgetClass,dpy[i],NULL);

		XtVaSetValues(topl[i],XtNtitle,player[i].name,NULL);
		load_data_pixmap(slate_green_xpm,&bgxpm,topl[i]);

		set_board(topl[i],i);
		set_icon_pixmap(xscrabble_xpm,topl[i]);
		acceptQuitPre(topl[i]);
		XtRealizeWidget(topl[i]);
		acceptQuitPost(topl[i]);
	}

	for (i=0; i<num_players; i++)
		XDefineCursor(dpy[i],XtWindow(topl[i]),
			XCreateFontCursor(dpy[i],XC_left_ptr));


	/* select starting player */
	curr_player=rand()%num_players;

	if (app_data.load)
	{
		loadgame();
		curr_player=(curr_player==0) ? (num_players-1) : (curr_player-1);
	}
		
	for (i=0; i<num_players; i++)
		ShowBar(i);
	ShowScores();

	TilesLeft();
	MessageAll("Starting game");
	GotoNextPlayer();

	for (i=0; i<num_players; i++)
		ShowBar(i);
	ShowTiles();
	ShowBoard(False);
	
	XtAppMainLoop(app_context);
}

ruct AppData,name[3]),
		XtRImmediate,"Player 4"},
	{"t1","T1",XtRInt,sizeof(int),XtOffsetOf(struct AppData,t[0]),
		XtRImmediate,(XtPointer) 0},
	{"t2","T2",XtRInt,sizeof(int),XtOffsetOf(struct AppData,t[1]),
		XtRImmexscrabble/src/makeperm.c100600 000310 000001 00000003442 06310723233 016456 0ustar00mchapmanstaff000000 000000 /* Permutaion file creation program - shouldn't be needed */


#include "scrab.h"

short int perms[7][5040][7];
int numperms[7];

void makeperm(short int p[7][5040][7],int num[7])
{
	int used[7];
	int ptr[7];
	int count;
	int clash,max;
	int lastptr[7] = {-1,-1,-1,-1,-1,-1,-1};

	for (count = 0; count < 7; count++)
		num[count] = 0;
	for (max = 0; max < 7; max++)
	{
	printf("Making %i perms\n",max+1);
	for (ptr[0] = 0; ptr[0] < 7; ptr[0]++)
	for (ptr[1] = 0; ptr[1] < 7; ptr[1]++)
	for (ptr[2] = 0; ptr[2] < 7; ptr[2]++)
	for (ptr[3] = 0; ptr[3] < 7; ptr[3]++)
	for (ptr[4] = 0; ptr[4] < 7; ptr[4]++)
	for (ptr[5] = 0; ptr[5] < 7; ptr[5]++)
	for (ptr[6] = 0; ptr[6] < 7; ptr[6]++)
	{
		for (count = 0; count < 7; count++)
		{
			used[count] = 0;
		}
		
		clash = 0;
		for (count = 0; count < (max+1); count++)
			if (!used[ptr[count]])
				used[ptr[count]] = 1;
			else
				{
				clash = 1;
				break;
				}
		if (clash)
			continue;
		clash = 0;
		for (count = 0; count < (max+1); count++)
		{
			if (ptr[count] == lastptr[count])
				clash++;	
		}
		if (clash == (max+1))
			continue;
		for (count = 0; count < (max+1); count++)
		{
			p[max][num[max]][count] = ptr[count];
			lastptr[count] = ptr[count];
			}
		(num[max])++;
	}
	}

}

void writeperms()
{
	FILE *fp;
	int perm,nperms,values;
	
	fp = fopen(PERMFILE,"w");
	if (fp==NULL)
	{
		fprintf(stderr,"Couldn't open permutaions file");
		exit(1);
	}
	printf("writing perm file...\n");
	for (nperms = 0;nperms < 7;nperms++)
	{
		fprintf(fp,"%i\n",numperms[nperms]);
	}
	for (perm = 0;perm < 7;perm++)
		for (nperms = 0; nperms < numperms[perm];nperms++)
		{
			for (values = 0; values < perm+1;values++)
			{
				putc(perms[perm][nperms][values],fp);
			}
			fprintf(fp,"\n");
		}
	fclose(fp);
}

int main()
{
	makeperm(perms,numperms);
	writeperms();
	return 0;
}
dictfile),XtRImmediate,
	 "/usr/local/lib/OSPD3"},
	{"permfile","Permfile",XtRString,sizeof(String),
	 XtOffsetOf(struct AppData,permfile),XtRImmediate,
	 "/usr/local/lib/scrabble_permutations"},
	{"scorefile","Scorefile",xscrabble/src/mess.c100600 000310 000001 00000007606 06311171617 015636 0ustar00mchapmanstaff000000 000000 /*
 *  XScrabble - X version of the popular board game, for 1 to 4 players.
 *
 * This software comes with NO warranty whatsoever. I therefore take no
 * responsibility for any damages, losses or problems caused through use
 * or misuse of this program.
 *
 * I hereby grant permission for this program to be freely copied and
 * distributed by any means, provided no charge is made for it.
 *
 * Matthew Chapman, csuoq@csv.warwick.ac.uk
 *    Mov 1994.
 */

/* mess.c - multiperson message system */

#include "scrab.h"
#include "globals.h"

#include <X11/Xaw/Text.h>
#include <X11/Xaw/TextSrc.h>

Widget messmain[MAXPLAYERS],messentry[MAXPLAYERS],messf[MAXPLAYERS];
Widget messdismiss[MAXPLAYERS],ping[MAXPLAYERS];
XawTextPosition pos=0;

void KeyRedirect(Widget w, XEvent *event,String *params,Cardinal num_params)
{
	int dnum;
	
	for (dnum=0; dpy[dnum] != XtDisplay(w); dnum++)
		;
    event->xany.window = XtWindow(messentry[dnum]);
    XtDispatchEvent(event);
}

void AddChar(Widget w, char *c)
{
	XawTextBlock txt;
	txt.firstPos=0;
	txt.format=FMT8BIT;
	txt.length=strlen(c);
	txt.ptr=c;
	XawTextReplace(w, pos, pos, &txt);
	pos+=txt.length;
	XawTextSetInsertionPoint(w,pos);
}

void DoMessage(Widget w,XExposeEvent *event,String *params,Cardinal *num_params)
{
	String line;
	int dnum,i;
	
	for (dnum=0; dpy[dnum] != XtDisplay(w); dnum++)
		;

	/* send message to all human players */
	XtVaGetValues(w,XtNstring,&line,NULL);
	if (strlen(line)>0)
		for (i=0; i<num_players; i++)
		    if (type[i]==0)
		    {
			AddChar(messmain[i],player[dnum].name);
			AddChar(messmain[i],": ");
			AddChar(messmain[i],line);
			AddChar(messmain[i],"\n");
		}
	XtVaSetValues(w,XtNstring,"",NULL);
}

void MessPopdown(Widget w, XtPointer client_data, XtPointer call_data)
{
	int dnum;
	
	for (dnum=0;messdismiss[dnum]!=w; dnum++)
		;

	XtUnmapWidget(messtop[dnum]);

	XtVaSetValues(menu_item[dnum][MESSAGE],XtNleftBitmap,None,NULL);
	menu_status[dnum][MESSAGE]= !menu_status[dnum][MESSAGE];
}

void Ping(Widget w, XtPointer client_data, XtPointer call_data)
{
	char mess[512];
	int dnum;
	
	for (dnum=0; ping[dnum]!=w; dnum++)
		;
			
	sprintf(mess,MESS_PING,player[dnum].name);
	MessageAll(mess);
}

void CreateMess(int dnum)
{
	static XtActionsRec actions[] = {
		{"DoMessage", DoMessage},
		{"KeyRedirect", KeyRedirect},
	};
	String trans1 = "#override\n\
		<Key>: KeyRedirect()";
	String trans2 = "#override\n\
		<Key>Return: DoMessage()\n\
		Ctrl<Key>R:  no-op()\n\
		Ctrl<Key>S:  no-op()\n\
		Meta<Key>I:  no-op()\n\
		<Key>Tab:    no-op()";

	messtop[dnum] = XtVaAppCreateShell("messtop","XScrabble",
		applicationShellWidgetClass,dpy[dnum],XtNmappedWhenManaged,False,NULL);
	messf[dnum] = XtVaCreateManagedWidget("messf",formWidgetClass,messtop[dnum],NULL);
	messdismiss[dnum] = XtVaCreateManagedWidget("messdimiss",
		commandWidgetClass,messf[dnum],XtNlabel,"Dismiss",NULL);
	ping[dnum] = XtVaCreateManagedWidget("ping",
		commandWidgetClass,messf[dnum],XtNlabel,"Ping all",XtNfromHoriz,
		messdismiss[dnum],NULL);
	messmain[dnum] = XtVaCreateManagedWidget("messmain",asciiTextWidgetClass,
		messf[dnum],XtNheight,200,XtNwidth,400,XtNstring,"",
		XtNtranslations,XtParseTranslationTable(trans1),
		XtNeditType,"edit",XtNscrollVertical,XawtextScrollWhenNeeded,
		XtNwrap,XawtextWrapWord,XtNfromVert,messdismiss[dnum],NULL);
	messentry[dnum] = XtVaCreateManagedWidget("messmain",asciiTextWidgetClass,messf[dnum],
		XtNfromVert,messmain[dnum],XtNwidth,400,XtNeditType,"edit",
		XtNtranslations,XtParseTranslationTable(trans2),
		XtNwrap,XawtextWrapLine,NULL);

	bg_pixmap(messf[dnum]);
	XtAppAddActions(app_context,actions,XtNumber(actions));
	XtRealizeWidget(messtop[dnum]);
	XtAddCallback(messdismiss[dnum],XtNcallback,MessPopdown,messtop[dnum]);
	XtAddCallback(ping[dnum],XtNcallback,Ping,messtop[dnum]);
}

void MessPopup(int dnum)
{
	if (menu_status[dnum][MESSAGE]==False)
		/* popup is already up */
		XtUnmapWidget(messtop[dnum]);
	else
		XtMapWidget(messtop[dnum]);
}

 *
 * Matthew Chapman, csuoq@csv.warwick.ac.uk
 *    Mov 1994.
 */

/* mess.c - multiperson message system */

#include "xscrabble/src/misc.c100600 000310 000001 00000034407 06310724250 015615 0ustar00mchapmanstaff000000 000000 /*      XScrabble
        misc.c
        various functions
        By csuos@warwick.ac.uk
*/

#include "scrab.h"
#include "globals.h"

void loaddict()
{
	FILE *fp;
	int count;
	int nextlen = 3;
	char sys[255];
	char unname[255] = "";

	fp = fopen(app_data.dictfile,"r");
	if (fp==NULL)
	{
	    sprintf(sys,"%s.gz",app_data.dictfile);
	    fp = fopen(sys,"r");
	    if (fp==NULL)
	    {
		fprintf(stderr,"Couldn't open dictionary %s or %s\n",
			app_data.dictfile,sys);
        	exit(1);
	    }

	    sprintf(unname,"/tmp/.ScrabDict%d",getpid());
	    sprintf(sys,"gzip -cd %s > %s",app_data.dictfile,unname);
	    system(sys);

	    fp = fopen(unname,"r");
	    if (fp==NULL)
	    {
		fprintf(stderr,"Error during unzip of dictionary\n");
        	exit(1);
	    }
	}

	/*printf("Loading dictionary...\n");	*/
	count = 0;
	word_pos[0] = count;
	while (!feof(fp))
	{
		fscanf(fp, "%s\n",dict[count]);
		if (strlen(dict[count]) == nextlen)
		{
			word_pos[nextlen-2] = count;
			/* word length borders = word length - 2 */
			nextlen++;
		}
		count++;
		if (count >= DICTSIZE)
		{
			fprintf(stderr,"dictionary exceeds maximum size.\n");
			exit(1);
		}
	}
	word_pos[nextlen-2] = count-1;
	fclose(fp);

	if (unname[0] != '\0')
	    unlink(unname);
}

void loadperms()
{
	FILE *fp;
	int perm,nperms,values;
	
	fp = fopen(app_data.permfile,"r");
	if (fp==NULL)
	{
		fprintf(stderr,"Couldn't open permutations file\n");
		exit(1);
	}
	/*printf("Loading permutations...\n");*/
	for (nperms = 0;nperms < 7;nperms++)
	{
		fscanf(fp,"%i\n",&numperms[nperms]);
	}
	for (perm = 0;perm < 7;perm++)
		for (nperms = 0; nperms < numperms[perm];nperms++)
		{
			for (values = 0; values < perm+1;values++)
			{
				perms[perm][nperms][values] = getc(fp);
			}
			fscanf(fp,"\n");
		}
	fclose(fp);
}

void savegame()
{
	FILE *fp;
	char homedir[MAXPATHLEN];
	char fullpath[MAXPATHLEN];
	int sx,sy,np,cn;
	int checksum = 0;

	strcpy(homedir,getenv("HOME"));
	strcpy(&fullpath[0],homedir);
	strcat(fullpath,SAVENAME);

	fp = fopen(fullpath,"w");
	if (fp==NULL)
	{
		fprintf(stderr,"Couldn't save position to file : %s",fullpath);
	}
	else
	{
		for (sx = 0;sx < BOARDSIZE; sx++)
			for (sy = 0;sy < BOARDSIZE; sy++)
			{
				fprintf(fp,"%c",board[sx][sy]);
				checksum+=board[sx][sy]*sx*sy;
			}
		fprintf(fp,"\n");
		fprintf(fp,"%i\n",num_players);
		checksum+=num_players;
		for (np = 0;np < num_players;np++)
		{
			fprintf(fp,"%i\n%s\n%s\n%i\n",player[np].score,
					player[np].name,player[np].bar,
					type[np]);
			for(cn=0;player[np].name[cn] != '\0';cn++)
				checksum+=player[np].name[cn]*cn;
			for(cn=0;player[np].bar[cn] != '\0';cn++)
				checksum+=player[np].bar[cn]*cn;
			checksum+=player[np].score*np;
			checksum+=type[np]*np;
		}
		if (bagptr == -1) /* if bag is empty */
			fprintf(fp,"%i\nEMPTY\n",bagptr);
		else
			fprintf(fp,"%i\n%s\n",bagptr,bag);
		checksum+=bagptr;
		if (bagptr > -1)
			for(cn=0;bag[cn]!= '\0';cn++)
				checksum+=bag[cn];
		fprintf(fp,"%i\n",num_passed);
		checksum+=num_passed;
		fprintf(fp,"%i\n",curr_player);
		checksum+=curr_player;
		fprintf(fp,"%i\n",checksum%MAGNUM);
		fclose(fp);
	}
}

void loadgame()
{
	FILE *fp;
	char homedir[MAXPATHLEN];
	char fullpath[MAXPATHLEN];
	int sx,sy,np,cn;
	int checksum = 0;
	int filechecksum;

	strcpy(homedir,getenv("HOME"));
	strcpy(&fullpath[0],homedir);
	strcat(fullpath,SAVENAME);

	fp = fopen(fullpath,"r");
	if (fp==NULL)
	{
		fprintf(stderr,"Couldn't find save position file : %s",fullpath);
	}
	else
	{
		for (sx = 0;sx < BOARDSIZE; sx++)
			for (sy = 0;sy < BOARDSIZE; sy++)
			{
				fscanf(fp,"%c",&board[sx][sy]);
				checksum+=board[sx][sy]*sx*sy;
				cboard[sx][sy]=board[sx][sy];
			}
		fscanf(fp,"\n");
		fscanf(fp,"%i\n",&num_players);
		checksum+=num_players;
		for (np = 0;np < num_players;np++)
		{
			fscanf(fp,"%i\n%[^\n]\n%[^\n]\n%i\n",&player[np].score,
					player[np].name,player[np].bar,
					&type[np]);
			for(cn=0;player[np].name[cn] != '\0';cn++)
				checksum+=player[np].name[cn]*cn;
			for(cn=0;player[np].bar[cn] != '\0';cn++)
				checksum+=player[np].bar[cn]*cn;
			checksum+=player[np].score*np;
			checksum+=type[np]*np;
		} 
		fscanf(fp,"%i\n%[^\n]\n",&bagptr,bag);
		checksum+=bagptr;
		if (bagptr > -1)
			for(cn=0;bag[cn]!= '\0';cn++)
				checksum+=bag[cn];
		fscanf(fp,"%i\n",&num_passed);
		checksum+=num_passed;
		fscanf(fp,"%i\n",&curr_player);
		checksum+=curr_player;
		fscanf(fp,"%i\n",&filechecksum);
		fclose(fp);
		checksum=checksum%MAGNUM;

		if (checksum != filechecksum)
		{
			fprintf(stderr,"Checksum error in save file.");
			exit(1);
		}
	}
}

void savescores()
{
	FILE *fp;
	int nplayers,numscores,cgoscores;

	fp = fopen(app_data.scorefile,"w");
	if (fp==NULL)
	{
		fprintf(stderr,"Couldn't save high scores to file\n");
	}
	else
	{
		for (nplayers = 0;nplayers < 4;nplayers++)
		for (numscores = 0;numscores < NUMHIGHSCORES;numscores++)
		{
			fprintf(fp,"%s\n",highscores[nplayers][numscores].name);
			fprintf(fp,"%i\n",highscores[nplayers][numscores].score);
			fprintf(fp,"%li\n",highscores[nplayers][numscores].date);
		}
		for (cgoscores = 0;cgoscores < NUMGOSCORES; cgoscores++)
		{
			fprintf(fp,"%s\n",bestgos[cgoscores].name);
			fprintf(fp,"%i\n",bestgos[cgoscores].score);
			fprintf(fp,"%li\n",bestgos[cgoscores].date);
			fprintf(fp,"%s\n",bestgos[cgoscores].words);
		}
		fclose(fp);
	}
}

void loadscores()
{
	FILE *fp;
	int nplayers,numscores,cgoscores;

	fp = fopen(app_data.scorefile,"r");
	if (fp==NULL)
	{
		fprintf(stderr,"Couldn't open high scores to file\n");
	}
	else
	{
		for (nplayers = 0;nplayers < 4;nplayers++)
		for (numscores = 0;numscores < NUMHIGHSCORES;numscores++)
		{
			fscanf(fp,"%[^\n]\n",highscores[nplayers][numscores].name);
			fscanf(fp,"%i\n",&highscores[nplayers][numscores].score);
			fscanf(fp,"%li\n",&highscores[nplayers][numscores].date);
		}
		for (cgoscores = 0;cgoscores < NUMGOSCORES; cgoscores++)
		{
			fscanf(fp,"%[^\n]\n",bestgos[cgoscores].name);
			fscanf(fp,"%i\n",&bestgos[cgoscores].score);
			fscanf(fp,"%li\n",&bestgos[cgoscores].date);
			fscanf(fp,"%[^\n]\n",bestgos[cgoscores].words);
		}
		fclose(fp);
	}
}

void alterscores()
{
	int playercount,checkhi,placed;
	int slip;
	time_t t;
	
	for (playercount = 0; playercount < num_players;playercount++)
	{
		if (type[playercount] > 0)
			continue;
		placed = 0;
		checkhi = 0;
		while ((checkhi < NUMHIGHSCORES)&&(!placed))
		{
			if (highscores[num_players-1][checkhi].score
				< player[playercount].score)
			{
				placed = 1;
				slip = NUMHIGHSCORES-1;
				while (slip > checkhi)
				{
					highscores[num_players-1][slip].score =
					  highscores[num_players-1][slip-1].score;
					strcpy(highscores[num_players-1][slip].name,
					  highscores[num_players-1][slip-1].name);
					highscores[num_players-1][slip].date =
					  highscores[num_players-1][slip-1].date;
					slip--;
				}
				highscores[num_players-1][checkhi].score =
				  player[playercount].score;
				strcpy(highscores[num_players-1][checkhi].name,
				  player[playercount].name);
				t = time((time_t *)NULL);
				highscores[num_players-1][checkhi].date = t;
			}
			checkhi++;
		}
	}
}

void alterbestgo(int goscore,char *wordsmade)
{
	int placed,checkhi,slip;
	time_t t;
	
	if ((num_players == 1)||(type[curr_player] > 0)) return;
	
	placed = 0;
	checkhi = 0;
	while ((checkhi < NUMGOSCORES)&&(!placed))
	{
		if (bestgos[checkhi].score
			< goscore)
		{
			placed = 1;
			slip = NUMGOSCORES-1;
			while (slip > checkhi)
			{
				bestgos[slip].score =
				  bestgos[slip-1].score;
				strcpy(bestgos[slip].name,
				  bestgos[slip-1].name);
				bestgos[slip].date =
				  bestgos[slip-1].date;
				strcpy(bestgos[slip].words,
				  bestgos[slip-1].words);
				slip--;
			}
			bestgos[checkhi].score =
			  goscore;
			strcpy(bestgos[checkhi].name,
			  player[curr_player].name);
			t = time((time_t *)NULL);
			bestgos[checkhi].date = t;
			strcpy(bestgos[checkhi].words,
			  wordsmade);
		}
		checkhi++;
	}
	if (placed)
	{
		savescores();
		UpdateBestgo();
	}
}

void showscores(int numplay,char outstring[256])
{
	int hicount,rep;
	char histr[80];
	char timestr[80];

	outstring[0] = '\0';
	for (hicount = 0;hicount < NUMHIGHSCORES;hicount++)
	{
		strcat(outstring,highscores[numplay-1][hicount].name);
		sprintf(histr,"%i",highscores[numplay-1][hicount].score);
		for (rep=0; rep<(int)(16-strlen(highscores[numplay-1][hicount].name)-strlen(histr)); rep++)
			strcat(outstring,".");
		strcat(outstring,histr);

		timestr[0]='\0';
		if (highscores[numplay-1][hicount].date == 0)
			strcpy(timestr,"(empty)");
		else
			sprintf(timestr,"%.24s",ctime(&highscores[numplay-1][hicount].date));

		for (rep=0; rep<(int)(26-strlen(timestr));rep++)
			strcat(outstring,".");
		strcat(outstring,timestr);

		if (hicount < NUMHIGHSCORES-1)
			strcat(outstring,"\n");
	} 
}

void showgoscores(char *outstring)
{
	int hicount,rep;
	char histr[80];
	char timestr[80];
	
	outstring[0] = '\0';
	for (hicount = 0;hicount < NUMGOSCORES;hicount++)
	{
		strcat(outstring,bestgos[hicount].name);
		sprintf(histr,"%i",bestgos[hicount].score);
		for (rep=0; rep<(int)(16-strlen(bestgos[hicount].name)-strlen(histr)); rep++)
			strcat(outstring,".");
		strcat(outstring,histr);

		timestr[0]='\0';
		if (bestgos[hicount].date == 0)
			strcpy(timestr,"(empty)");
		else
			sprintf(timestr,"%.24s",ctime(&bestgos[hicount].date));

		for (rep=0; rep<(int)(26-strlen(timestr));rep++)
			strcat(outstring,".");
		strcat(outstring,timestr);

		for (rep=0; rep<(int)(35-strlen(bestgos[hicount].words));rep++)
			strcat(outstring,".");
		strcat(outstring," ");
		strcat(outstring,bestgos[hicount].words);
		if (hicount < NUMGOSCORES-1)
			strcat(outstring,"\n");
	} 
}

unsigned int wordsearch(char *word)
{
	int start,end;
	int found = 0;
	int compare,wordlength;
	int lastmid = -1;
	int middle = -2;
	
	wordlength=strlen(word);
	if (wordlength < 2)
		return found;
	switch(wordlength)
	{
	case 2 : { start = word_pos[0] ; end = word_pos[1] ; break; }
	case 3 : { start = word_pos[1] ; end = word_pos[2] ; break; }
	case 4 : { start = word_pos[2] ; end = word_pos[3] ; break; }
	case 5 : { start = word_pos[3] ; end = word_pos[4] ; break; }
	case 6 : { start = word_pos[4] ; end = word_pos[5] ; break; }
	case 7 : { start = word_pos[5] ; end = word_pos[6] ; break; }
	case 8 : { start = word_pos[6] ; end = word_pos[7] ; break; }
	case 9 : { start = word_pos[7] ; end = word_pos[8] ; break; }
	case 10 : { start = word_pos[8] ; end = word_pos[9] ; break; }
	case 11 : { start = word_pos[9] ; end = word_pos[10] ; break; }
	case 12 : { start = word_pos[10] ; end = word_pos[11] ; break; }
	case 13 : { start = word_pos[11] ; end = word_pos[12] ; break; }
	case 14 : { start = word_pos[12] ; end = word_pos[13] ; break; }
	default : { start = word_pos[13] ; end = word_pos[14]+1 ; break; }
	}

	while ((lastmid != middle) && (!found))
	{
		lastmid = middle;
		middle = ((end - start)/2)+start;
		compare = strcmp(word,dict[middle]);
		if (!compare)
			found = 1;
		else
			if (compare > 0)
			{
				start = middle;
			}
			else end = middle;
	}
	return found;
}

void clearboard(char b[BOARDSIZE][BOARDSIZE])
{
	int x,y;
	/* place blank spaces in board */
	for(y=0; y < BOARDSIZE; y++)
		for(x=0; x < BOARDSIZE; x++)
			b[x][y]=' '; 
}

void makebag()
{
	/* set up letter frequency array */
	int freq[NUMLETTERS] =	LETTER_FREQUENCY_TABLE;
	/* start filling bag from 2nd position as blanks are first two */
	int fillbagptr = 2;
	int makeptr,letter;

	/* cycle through frequency table */
	for (makeptr = 0; makeptr < NUMLETTERS; makeptr++)
		/* place the correct number of each letter in the bag */
		for (letter=1; letter <= freq[makeptr]; letter++)
			{
				bag[fillbagptr++] = 'A'+makeptr;
			}
	/* finally inserts the blanks in the bag */
	bag[0]=bag[1]='*';	
}

void shufflebag()
{
	/* create a new bag into which the random letters will go */
	char newbag[BAGSIZE];
	int shuffleptr,currentlett;
	int newbagptr= 0;
	
	/* generate new random number sequence based on the time */
	srand((unsigned int)time((time_t *)NULL));

	/* take all but one of the letters one at a time */
	for (shuffleptr=(bagptr+1); shuffleptr > 1; shuffleptr--)
		{
			/* pick a random letter from the old bag */
			currentlett = rand()%shuffleptr;
			/* put it in the new bag */
			newbag[newbagptr++] = bag[currentlett];
			/* fill its gap with the last letter in the bag */
			bag[currentlett] = bag[shuffleptr-1];
		}

	/* put the last letter in the new bag */
	newbag[newbagptr]=bag[0];
	
	/* put all the random letters bag in the old bag */
	for (shuffleptr=0; shuffleptr < (bagptr+1); shuffleptr++)
		bag[shuffleptr] = newbag[shuffleptr];
}

void addtobag(char *letts)
{
	/* routine for adjusting bag when letters are changed */
	strcat(bag,letts);
	bagptr += strlen(letts);
	shufflebag();
}

void fillbar(int playernum)
{
	int bn;
	
	for (bn=0; bn < BARLEN; bn++)
	{
		if (player[playernum].bar[bn] == ' ')
		{
			if (bagptr != -1)
				player[playernum].bar[bn] = bag[bagptr--];
		}
	}
	bag[bagptr+1] = '\0';
}

int bartotal(int playernum)
{
	int bcount,total = 0;
	
	for (bcount = 0;bcount < BARLEN; bcount++)
	{
		if (isupper(player[playernum].bar[bcount]))
		{
			total+=letterscore[player[playernum].bar[bcount]-'A'];
		}
	}
	return total;
}

void takeletters(int numletters,char *letters)
{
	int count;

	/* take a number of letters from the front of the bag */
	for (count=0; count < numletters; count++)
		letters[count]=bag[bagptr--];
	bag[bagptr+1] = '\0';
}

void playersetup(char playername[MAXPLAYERS][NAMELEN])
{
	int playercount;

	/* fill player data into player structure */
	for (playercount = 0; playercount < num_players; playercount++)
		{
			strcpy(player[playercount].name,playername[playercount]);
			player[playercount].score=0;
			takeletters(BARLEN,player[playercount].bar);
		}
}

/* debug routines */

void showbag()
{
	int check;
	
	/* show the bag */
	for(check=0; check < bagptr+1; check++)
		printf("%c",bag[check]);
	printf("\n");
}

void showboard(char b[BOARDSIZE][BOARDSIZE])
{
	int x,y;
	
	/* show the board */
	printf("-----------------\n");
	printf("|");
	for(y=0; y < BOARDSIZE; y++)
		for(x=0; x < BOARDSIZE; x++)
			{
			printf("%c",b[x][y]);
			if ((x == BOARDSIZE-1)&& (y != BOARDSIZE-1))
				printf("|\n|");
			else
				if (x == BOARDSIZE-1)
					printf("|\n");
			}
	printf("-----------------\n");
}

void showstats()
{
	int count;
	
	/* display player data */
	for (count=0; count < num_players; count++)
		{
			printf("Player %i :-\nName : %s\nScore : %i\nBar : %s\n\n",count+1,player[count].name,player[count].score,player[count].bar);
		}
}

/* end of debug routines */
[10] ; break; }
	case 12 : { start = word_pos[10] ; end = word_pos[11] ; break; }
	case 13 : { start = word_pos[11] ; end = word_pos[12] ; break; }
	case 14 : { start = word_pos[12] ; end = word_pos[13] ; break; }
	default : { start = word_pos[13] ;xscrabble/src/moves.c100600 000310 000001 00000033351 06047206571 016020 0ustar00mchapmanstaff000000 000000 /*      XScrabble
        moves.c
        move validation and scoring routines
        By csuos@warwick.ac.uk
*/

#include "scrab.h"
#include "globals.h"

void convupper(char *str)
{
	int conv = 0;
	
	while (str[conv] != '\0')
	{
		str[conv] = toupper((int)str[conv]);
		conv++;
	}
}

unsigned int emptyboard(char b[BOARDSIZE][BOARDSIZE])
{
	int x,y;
	int empty = 1;
	for (x = 0; x < BOARDSIZE; x++)
		for (y = 0; y < BOARDSIZE; y++)
			{
				if (b[x][y] != ' ')
			 		empty = 0;
			 }
	return empty;
}

int validate(char newboard[BOARDSIZE][BOARDSIZE],int testing, int *goscore)
{
	int checkx,checky;
	int sx,sy,ex,ey;
	int finish = 0; /* set finished flag to false */
	int invalid = 0; /* set invalid flag to false */
	int nothoriz = 1; /* set horizontal check to true */
	int notvert = 1; /* set vertical check to true */
	int oldpiece = 0; /* set old piece check to false */
	int csx,csy,cex,cey,empty;
	
	empty = emptyboard(board);
	
	/* find first new letter */
	checkx = checky = 0;
	while (!((board[checkx][checky] == ' ') && (newboard[checkx][checky] != ' '))
		&& (!finish))
	{
		checkx++;
		if (checkx == BOARDSIZE)
			{ checkx = 0;
			  checky++; }
		if (checky == BOARDSIZE)
			finish = 1; /* set finished flag to true */
	}
	if (finish) return HORLICKS;
	/* return invalid if new pieces are not added */
	else
		{ sx=checkx; sy=checky; }
	
	/* check for a horizontal word */
	if ((checkx+1 < BOARDSIZE) && (newboard[checkx+1][checky] != ' '))
	{
		/* find end of horizontal , including old pieces*/
		while ((checkx+1 < BOARDSIZE) &&
		 (newboard[checkx+1][checky] != ' '))
		 {
			if (board[checkx+1][checky] == ' ')
				{ nothoriz = 0; }
			checkx++;
		 }
		 if (!nothoriz)
		 {
			 ex = checkx;
			 ey = checky;
		 
		/* check for no extra pieces */
		checkx++;
		if (checkx == BOARDSIZE)
			{ checkx = 0 ; checky++; }
		while ((checky < BOARDSIZE) && (!invalid))
			{
				if ((board[checkx][checky] == ' ') &&
				    (newboard[checkx][checky] != ' '))
				   invalid = 1; /* go is invalid */
				else {
					checkx++;
					if (checkx == BOARDSIZE)
						{ checkx = 0 ; checky++; }
				}
			}
		if (invalid)
			return HORLICKS;
		else
			{
			if (!empty)
			/* check to see if there is an old piece around word */
			{
			csx = sx;
			cex = ex;
			if (sy > 0) csy = sy-1;
			else csy = sy;
			if (ey < BOARDSIZE-1) cey = ey+1;
			else cey = ey;
			for (checkx = csx; checkx <= cex; checkx++)
				for (checky = csy; checky <= cey; checky++)
					if (board[checkx][checky] != ' ')
						oldpiece = 1;
			if ((sx > 0)&&(board[sx-1][sy]!=' '))
				oldpiece = 1;
			if ((ex < BOARDSIZE-1)&&(board[ex+1][ey]!=' '))
				oldpiece = 1;
			if (oldpiece)
			return (checkwords(newboard,sx,sy,ex,ey,testing,goscore));
			else
				return HORLICKS;
			}
			else
				return (checkwords(newboard,sx,sy,ex,ey,testing,goscore));
			}
		}
	}
	checkx = sx;
	checky = sy;
		/* check for a vertical word */
		if ((checky+1 < BOARDSIZE) && (newboard[checkx][checky+1] != ' ')
			&& nothoriz)
		{

			/* check for no extra pieces before vertical word */
			checky++;
			checkx = 0;
			while ((checkx < sx) && (!invalid))
			{
				if ((board[checkx][checky] == ' ') &&
				    (newboard[checkx][checky] != ' '))
				   invalid = 1; /* extra piece, go is invalid */
				else {
					checky++;
					if (checky == BOARDSIZE)
						{ checky = sy+1; checkx++; }
					}
			}
			if (invalid)
				return HORLICKS;
			/* reset check variables */
			checkx=sx; checky=sy;
			
			/* now find end of vertical word */
			while ((checky+1 < BOARDSIZE) &&
		 		(newboard[checkx][checky+1] != ' '))
		 	{
				if (board[checkx][checky+1] == ' ')
					{ notvert = 0; }
				checky++;
		 	}
		 	
		 	if (!notvert)
		 	{
		 	ex = checkx;
			ey = checky;
			
			/* check for no extra pieces after vertical word */
			checky++;
			if (checky == BOARDSIZE)
				{ checky = sy; checkx ++; }		
			while ((checkx < BOARDSIZE) && (!invalid))
				{
					if ((board[checkx][checky] == ' ') &&
					    (newboard[checkx][checky] != ' '))
					   invalid = 1; /* go is invalid */
					else {
						checky++;
						if (checky == BOARDSIZE)
							{ checky = sy ; checkx++; }
					}
				}
			if (invalid)
				return HORLICKS;
			else
			{
			if (!empty)
			{			
				csy = sy;
				cey = ey;
				if (sx > 0) csx = sx-1;
				else csx = sx;
				if (ex < BOARDSIZE-1) cex = ex+1;
				else cex = ex;
				for (checkx = csx; checkx <= cex; checkx++)
					for (checky = csy; checky <= cey; checky++)
						if (board[checkx][checky] != ' ')
							oldpiece = 1;
				if ((sy > 0)&&(board[sx][sy-1]!=' '))
					oldpiece = 1;
				if ((ey < BOARDSIZE-1)&&(board[ex][ey+1]!=' '))
					oldpiece = 1;
				if (oldpiece)
					return (checkwords(newboard,sx,sy,ex,ey,testing,goscore));
				else
					return HORLICKS;
			}
			else
				return (checkwords(newboard,sx,sy,ex,ey,testing,goscore));
			}
			}
		}
			if (notvert && nothoriz)
			{	/* one letter */
				ex = sx; ey = sy;
				/* check for no extra letters */
				checkx++;
				if (checkx == BOARDSIZE)
					{ checkx = 0; checky++; }
				while ((checky < BOARDSIZE) && (!invalid))
				{
					if ((board[checkx][checky] == ' ') &&
					    (newboard[checkx][checky] != ' '))
					   invalid = 1; /* go is invalid */
					else {
						checkx++;
						if (checkx == BOARDSIZE)
							{ checkx = 0; checky++; }
					}
				}
			if (invalid)
				return HORLICKS;
			else
			{
			/* check to see if there is at least one surrounding piece */
			if (((sy > 0)&&(board[sx][sy-1]!=' '))||
			    ((sy < BOARDSIZE-1)&&(board[sx][sy+1]!=' '))||
			    ((sx > 0)&&(board[sx-1][sy]!=' '))||
			    ((sx < BOARDSIZE-1)&&(board[sx+1][sy]!=' ')))
				return (checkwords(newboard,sx,sy,ex,ey,testing,goscore));
			else
				return HORLICKS;
			}
			}
	return HORLICKS; /* just in case */
}


int checkwords(char nb[BOARDSIZE][BOARDSIZE],int sx,int sy,int ex,int ey,int testing,int *goscore)
{
	int checkx,checky,lefttile,righttile,toptile,bottile;
	int indict,fillword;
	char checkword[16];
	int correct = 1;
	int loneletter = 0;
	char wordsmade[BESTGOWORDSLEN] = "";
	int wordpos = 0;
	
	/* initialise go score */
	*goscore = 0;
	
	/* if first go check to see if it passes through centre */
	if (emptyboard(board))
	{
		/* if horizontal word */
		if (ey-sy == 0)
		{
			if (!((sx <= 7) && (ex >= 7) && (sy == 7)))
				return NOTCENTRE;
		}
		else
		/* if vertical word */
		{
			if (!((sy <= 7) && (ey >= 7) && (sx == 7)))
				return NOTCENTRE;
		}
	}
	
	/* check for horizontal word */
	if (ey-sy == 0)
	{
		/* ####check left and right for complete word#### */
		
		/* check left */
		checkx = sx;
		while (((checkx-1) >= 0) && (board[checkx-1][sy] != ' '))
		{
			checkx--;
		}
		lefttile = checkx;
		
		/* check right */
		checkx = ex;
		while (((checkx+1) < BOARDSIZE) && (board[checkx+1][sy] != ' '))
		{
			checkx++;
		}
		righttile = checkx;

		/* do not check if it is one letter */
		if (!((lefttile == sx)&&(righttile == sx)))
		{		
			/* construct word */
			for (fillword=lefttile; fillword <= righttile; fillword++)
			{
				checkword[fillword-lefttile] = nb[fillword][sy];	
			}
			checkword[fillword-lefttile]='\0';
		
			/* and check it */
			convupper(checkword);
			if (!testing)
				indict = wordsearch(checkword);
			else
				indict = 1;
			correct = correct&&indict;
			if (indict)
				{ 
				*goscore += scoreword(lefttile,sy,righttile,sy,nb);
				if ((wordpos+strlen(checkword)+1)<BESTGOWORDSLEN)
				{
					if (wordpos != 0)
						strcat(wordsmade,",");
					wordpos+=strlen(checkword)+1;
					strcat(wordsmade,checkword);
				}
				}
		}
		else
			{ loneletter = 1; }

		/* #####check up and down along word#### */
		checkx = sx;

		/* move along letters */
		while ((checkx <= ex)&&correct)
		{
		/* only check and score new words */
		if (board[checkx][sy] == ' ')
			{
			/* check up */
			checky = sy;		
			while (((checky-1) >= 0) && (board[checkx][checky-1] != ' '))
			{
				checky--;
			}
			toptile = checky;
			
			/* check down */
			checky = sy;
			while (((checky+1) < BOARDSIZE) && (board[checkx][checky+1] != ' '))		
			{
				checky++;
			}
			bottile = checky;


			/* do not check if it is one letter */
			if (!((toptile == sy)&&(bottile == sy)))
			{
				/* construct word */
				for (fillword=toptile; fillword <= bottile; fillword++)
				{
					checkword[fillword-toptile] = nb[checkx][fillword];
				}
				checkword[fillword-toptile]='\0';
				
				/* and check it */
				convupper(checkword);
				if (!testing)
					{
					indict = wordsearch(checkword);
					}
				else
					indict = 1;
				correct = correct&&indict;
				if (indict)
					{
					*goscore += scoreword(checkx,toptile,checkx,bottile,nb);
					if ((wordpos+strlen(checkword)+1)<BESTGOWORDSLEN)
					{
						if (wordpos != 0)
							strcat(wordsmade,",");
						wordpos+=strlen(checkword)+1;
						strcat(wordsmade,checkword);
					}
					}
			}
			else
			{
				if (loneletter)
					correct = 0;
				/* if this is an "island" then it is not a word */
			}
			}
			checkx++;
		}
		if (correct)
		{
			if (!testing) alterbestgo(*goscore,wordsmade);
			return VALID;
		}
		else
			return INVALID;
	}
	else
	/*### check up and down for complete word ###*/
	{
		/* check up */
		checky = sy;
		while (((checky-1) >= 0) && (board[sx][checky-1] != ' '))
		{
			checky--;
		}
		toptile = checky;
		
		/* check down */
		checky = ey;
		while (((checky+1) < BOARDSIZE) && (board[sx][checky+1] != ' '))
		{
			checky++;
		}
		bottile = checky;
		
		/* no need
Results 1 - 1
Help - FTP Sites List - Software Dir.
Searching half a billion files worldwide
© 1997-2009 MARUHN Internet Solutions