[comp.sources.x] v11i079: xsunclock - enhacned oclock, Patch1, Part01/01

pfuetz@agd.fhg.de (02/15/91)

Submitted-by: pfuetz@agd.fhg.de
Posting-number: Volume 11, Issue 79
Archive-name: xsunclock/patch1
Patch-To: xsunclock: Volume XXX, Issue XXX

Hello!

This is a two part posting. I added the sound option that were included in 
"oclock" by Mike Wagner (wagner@cadillac.siemens.com) to xclock.
Please refer to the manual page for former information.

Matthias Pfuetzner

#!/bin/sh
# To unshare, sh or unshar this file
echo CHANGES 1>&2
sed -e 's/^X//' > CHANGES <<'E!O!F! CHANGES'
XThe following changes have been made to this directory since R3:
X
X     o	added icon mask.
X     o	added WM_DELETE_WINDOW.
X     o	removed vendor shell hack now that Xaw does correctly.
X
XThe following changes were done by Matthias Pfuetzner
Xpfuetzner@agd.fhg.de:
X
X     o  added the sound option that were included in "oclock"
E!O!F! CHANGES
echo Clock.c 1>&2
sed -e 's/^X//' > Clock.c <<'E!O!F! Clock.c'
X#ifndef lint
Xstatic char Xrcsid[] = "$XConsortium: Clock.c,v 1.50 89/12/06 15:23:24 kit Exp $";
X#endif /* lint */
X
X
X/***********************************************************
XCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X
X                        All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its 
Xdocumentation for any purpose and without fee is hereby granted, 
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in 
Xsupporting documentation, and that the names of Digital or MIT not be
Xused in advertising or publicity pertaining to distribution of the
Xsoftware without specific, written prior permission.  
X
XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
XSOFTWARE.
X
X******************************************************************/
X
X#include <X11/Xlib.h>
X#include <X11/StringDefs.h>
X#include <X11/IntrinsicP.h>
X#include <X11/Xaw/XawInit.h>
X#include "ClockP.h"
X
Xextern long time();
Xstatic void clock_tic(), DrawHand(), DrawSecond(), SetSeg(), DrawClockFace();
Xstatic erase_hands(), round();
X	
X/* Private Definitions */
X
X#define VERTICES_IN_HANDS	6	/* to draw triangle */
X#define PI			3.14159265358979
X#define TWOPI			(2. * PI)
X
X#define SECOND_HAND_FRACT	90
X#define MINUTE_HAND_FRACT	70
X#define HOUR_HAND_FRACT		40
X#define HAND_WIDTH_FRACT	7
X#define SECOND_WIDTH_FRACT	5
X#define SECOND_HAND_TIME	30
X
X#define ANALOG_SIZE_DEFAULT	164
X
X#define max(a, b) ((a) > (b) ? (a) : (b))
X#define min(a, b) ((a) < (b) ? (a) : (b))
X#define abs(a) ((a) < 0 ? -(a) : (a))
X
X
X/* Initialization of defaults */
X
X#define offset(field) XtOffset(ClockWidget,clock.field)
X#define goffset(field) XtOffset(Widget,core.field)
X
Xstatic XtResource resources[] = {
X    {XtNwidth, XtCWidth, XtRDimension, sizeof(Dimension),
X	goffset(width), XtRImmediate, (caddr_t) 0},
X    {XtNheight, XtCHeight, XtRDimension, sizeof(Dimension),
X	goffset(height), XtRImmediate, (caddr_t) 0},
X    {XtNbackground, XtCBackground, XtRPixel, sizeof(Pixel),
X	goffset(background_pixel), XtRString, "XtdefaultBackground"},
X    {XtNupdate, XtCInterval, XtRInt, sizeof(int), 
X        offset(update), XtRImmediate, (caddr_t) 60 },
X    {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
X        offset(fgpixel), XtRString, "XtdefaultForeground"},
X    {XtNhand, XtCForeground, XtRPixel, sizeof(Pixel),
X        offset(Hdpixel), XtRString, "XtdefaultForeground"},
X    {XtNhighlight, XtCForeground, XtRPixel, sizeof(Pixel),
X        offset(Hipixel), XtRString, "XtdefaultForeground"},
X    {XtNanalog, XtCBoolean, XtRBoolean, sizeof(Boolean),
X        offset(analog), XtRImmediate, (caddr_t) TRUE},
X    {XtNchime, XtCBoolean, XtRBoolean, sizeof(Boolean),
X	offset(chime), XtRImmediate, (caddr_t) FALSE },
X    {XtNpadding, XtCMargin, XtRInt, sizeof(int),
X        offset(padding), XtRImmediate, (caddr_t) 8},
X    {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
X        offset(font), XtRString, "fixed"},
X    {XtNreverseVideo, XtCReverseVideo, XtRBoolean, sizeof (Boolean),
X	offset (reverse_video), XtRImmediate, (caddr_t) FALSE},
X    {XtNbackingStore, XtCBackingStore, XtRBackingStore, sizeof (int),
X    	offset (backing_store), XtRString, "default"},
X    {XtNhourSound, XtCHourSound, XtRString, sizeof (String),
X       offset (hour_sound), XtRString, NULL},
X    {XtNquarterPastSound, XtCQuarterPastSound, XtRString, sizeof (String),
X       offset (quarter_past_sound), XtRString, NULL},
X    {XtNhalfPastSound, XtCHalfPastSound, XtRString, sizeof (String),
X       offset (half_past_sound), XtRString, NULL},
X    {XtNquarterOfSound, XtCQuarterOfSound, XtRString, sizeof (String),
X       offset (quarter_of_sound), XtRString, NULL},
X    {XtNchimeSound, XtCChimeSound, XtRString, sizeof (String),
X       offset (chime_sound), XtRString, NULL},
X    {XtNvolume, XtCVolume, XtRInt, sizeof (int),
X       offset (volume), XtRString, NULL},
X};
X
X#undef offset
X#undef goffset
X
Xstatic void ClassInitialize();
Xstatic void Initialize(), Realize(), Destroy(), Resize(), Redisplay();
Xstatic Boolean SetValues();
X
XClockClassRec clockClassRec = {
X    { /* core fields */
X    /* superclass		*/	&widgetClassRec,
X    /* class_name		*/	"Clock",
X    /* widget_size		*/	sizeof(ClockRec),
X    /* class_initialize		*/	ClassInitialize,
X    /* class_part_initialize	*/	NULL,
X    /* class_inited		*/	FALSE,
X    /* initialize		*/	Initialize,
X    /* initialize_hook		*/	NULL,
X    /* realize			*/	Realize,
X    /* actions			*/	NULL,
X    /* num_actions		*/	0,
X    /* resources		*/	resources,
X    /* resource_count		*/	XtNumber(resources),
X    /* xrm_class		*/	NULL,
X    /* compress_motion		*/	TRUE,
X    /* compress_exposure	*/	TRUE,
X    /* compress_enterleave	*/	TRUE,
X    /* visible_interest		*/	FALSE,
X    /* destroy			*/	Destroy,
X    /* resize			*/	Resize,
X    /* expose			*/	Redisplay,
X    /* set_values		*/	SetValues,
X    /* set_values_hook		*/	NULL,
X    /* set_values_almost	*/	XtInheritSetValuesAlmost,
X    /* get_values_hook		*/	NULL,
X    /* accept_focus		*/	NULL,
X    /* version			*/	XtVersion,
X    /* callback_private		*/	NULL,
X    /* tm_table			*/	NULL,
X    /* query_geometry           */	XtInheritQueryGeometry,
X    /* display_accelerator      */	XtInheritDisplayAccelerator,
X    /* extension                */	NULL
X    }
X};
X
XWidgetClass clockWidgetClass = (WidgetClass) &clockClassRec;
X
X/****************************************************************
X *
X * Private Procedures
X *
X ****************************************************************/
X
Xstatic void ClassInitialize()
X{
X    XawInitializeWidgetSet();
X    XtAddConverter( XtRString, XtRBackingStore, XmuCvtStringToBackingStore,
X		    NULL, 0 );
X}
X
X/* ARGSUSED */
Xstatic void Initialize (request, new)
X    Widget request, new;
X{
X    ClockWidget w = (ClockWidget)new;
X    XtGCMask		valuemask;
X    XGCValues	myXGCV;
X    int min_height, min_width;
X
X    valuemask = GCForeground | GCBackground | GCFont | GCLineWidth;
X    if (w->clock.font != NULL)
X        myXGCV.font = w->clock.font->fid;
X    else
X        valuemask &= ~GCFont;	/* use server default font */
X
X    min_width = min_height = ANALOG_SIZE_DEFAULT;
X    if(!w->clock.analog) {
X       char *str;
X       struct tm tm, *localtime();
X       long time_value;
X       (void) time(&time_value);
X       tm = *localtime(&time_value);
X       str = asctime(&tm);
X       if (w->clock.font == NULL)
X          w->clock.font = XQueryFont( XtDisplay(w),
X				      XGContextFromGC(
X					   DefaultGCOfScreen(XtScreen(w))) );
X       min_width = XTextWidth(w->clock.font, str, strlen(str)) +
X	  2 * w->clock.padding;
X       min_height = w->clock.font->ascent +
X	  w->clock.font->descent + 2 * w->clock.padding;
X    }
X    if (w->core.width == 0)
X	w->core.width = min_width;
X    if (w->core.height == 0)
X	w->core.height = min_height;
X
X    myXGCV.foreground = w->clock.fgpixel;
X    myXGCV.background = w->core.background_pixel;
X    if (w->clock.font != NULL)
X        myXGCV.font = w->clock.font->fid;
X    else
X        valuemask &= ~GCFont;	/* use server default font */
X    myXGCV.line_width = 0;
X    w->clock.myGC = XtGetGC((Widget)w, valuemask, &myXGCV);
X
X    valuemask = GCForeground | GCLineWidth ;
X    myXGCV.foreground = w->core.background_pixel;
X    w->clock.EraseGC = XtGetGC((Widget)w, valuemask, &myXGCV);
X
X    myXGCV.foreground = w->clock.Hipixel;
X    w->clock.HighGC = XtGetGC((Widget)w, valuemask, &myXGCV);
X
X    valuemask = GCForeground;
X    myXGCV.foreground = w->clock.Hdpixel;
X    w->clock.HandGC = XtGetGC((Widget)w, valuemask, &myXGCV);
X
X    if (w->clock.update <= 0)
X	w->clock.update = 60;	/* make invalid update's use a default */
X    w->clock.show_second_hand = (w->clock.update <= SECOND_HAND_TIME);
X    w->clock.numseg = 0;
X    w->clock.interval_id = 0;
X}
X
Xstatic void Realize (gw, valueMask, attrs)
X     Widget gw;
X     XtValueMask *valueMask;
X     XSetWindowAttributes *attrs;
X{
X     ClockWidget	w = (ClockWidget) gw;
X#ifdef notdef
X     *valueMask |= CWBitGravity;
X     attrs->bit_gravity = ForgetGravity;
X#endif
X     switch (w->clock.backing_store) {
X     case Always:
X     case NotUseful:
X     case WhenMapped:
X     	*valueMask |=CWBackingStore;
X	attrs->backing_store = w->clock.backing_store;
X	break;
X     }
X     XtCreateWindow( gw, InputOutput, (Visual *)CopyFromParent,
X		     *valueMask, attrs);
X     Resize(gw);
X}
X
Xstatic void Destroy (gw)
X     Widget gw;
X{
X     ClockWidget w = (ClockWidget) gw;
X     if (w->clock.interval_id) XtRemoveTimeOut (w->clock.interval_id);
X     XtDestroyGC (w->clock.myGC);
X     XtDestroyGC (w->clock.HighGC);
X     XtDestroyGC (w->clock.HandGC);
X     XtDestroyGC (w->clock.EraseGC);
X}
X
Xstatic void Resize (gw) 
X    Widget gw;
X{
X    ClockWidget w = (ClockWidget) gw;
X    /* don't do this computation if window hasn't been realized yet. */
X    if (XtIsRealized(gw) && w->clock.analog) {
X	/* need signed value since Dimension is unsigned */
X	int radius = ((int) min(w->core.width, w->core.height) - (int) (2 * w->clock.padding)) / 2;
X        w->clock.radius = (Dimension) max (radius, 1);
X
X        w->clock.second_hand_length = ((SECOND_HAND_FRACT * w->clock.radius) / 100);
X        w->clock.minute_hand_length = ((MINUTE_HAND_FRACT * w->clock.radius) / 100);
X        w->clock.hour_hand_length = ((HOUR_HAND_FRACT * w->clock.radius) / 100);
X        w->clock.hand_width = ((HAND_WIDTH_FRACT * w->clock.radius) / 100);
X        w->clock.second_hand_width = ((SECOND_WIDTH_FRACT * w->clock.radius) / 100);
X
X        w->clock.centerX = w->core.width / 2;
X        w->clock.centerY = w->core.height / 2;
X    }
X}
X
X/* ARGSUSED */
Xstatic void Redisplay (gw, event, region)
X    Widget gw;
X    XEvent *event;		/* unused */
X    Region region;		/* unused */
X{
X    ClockWidget w = (ClockWidget) gw;
X    if (w->clock.analog) {
X	if (w->clock.numseg != 0)
X	    erase_hands (w, (struct tm *) 0);
X        DrawClockFace(w);
X    } else {
X	w->clock.prev_time_string[0] = '\0';
X    }
X    clock_tic((caddr_t)w, (XtIntervalId)0);
X}
X
X/* ARGSUSED */
Xstatic void clock_tic(client_data, id)
X        caddr_t client_data;
X        XtIntervalId *id;
X{
X        ClockWidget w = (ClockWidget)client_data;    
X	struct tm *localtime();
X	struct tm tm; 
X	long	time_value;
X	char	*time_ptr;
X        register Display *dpy = XtDisplay(w);
X        register Window win = XtWindow(w);
X        int i;	
X
X	if (id || !w->clock.interval_id)
X	    w->clock.interval_id =
X		XtAppAddTimeOut( XtWidgetToApplicationContext( (Widget) w),
X				w->clock.update*1000, clock_tic, (caddr_t)w );
X	(void) time(&time_value);
X	tm = *localtime(&time_value);
X	/*
X	 * Beep on the half hour; double-beep on the hour.
X	 */
X	if (w->clock.beeped && (tm.tm_min != 30) && (tm.tm_min != 0)
X	                    && (tm.tm_min != 45) && (tm.tm_min != 15))
X	   w->clock.beeped = FALSE;
X
X	if (w->clock.chime == TRUE) {
X	    if (((tm.tm_min == 30) || (tm.tm_min == 0)) 
X		&& (!w->clock.beeped)) {
X		w->clock.beeped = TRUE;
X		XBell(dpy, 50);	
X		if (tm.tm_min == 0)
X		  XBell(dpy, 50);
X	    }
X	}
X
X/* Included */
X        if (!w->clock.beeped)
X	   switch (tm.tm_min)
X	   {
X	   case 0:
X	      if (w->clock.hour_sound)
X	         play_sound(w->clock.hour_sound, w->clock.volume);
X	      if (w->clock.chime_sound)
X	      {
X	         if (!(i=(tm.tm_hour%12)))
X	            i = 12;
X	         for ( ; i--; )
X	            play_sound(w->clock.chime_sound, w->clock.volume);
X	      }
X	      w->clock.beeped = TRUE;
X	      break;
X	   case 15:
X	      if (w->clock.quarter_past_sound)
X	         play_sound(w->clock.quarter_past_sound, w->clock.volume);
X	      w->clock.beeped = TRUE;
X	      break;
X	   case 30:
X	      if (w->clock.half_past_sound)
X	         play_sound(w->clock.half_past_sound, w->clock.volume);
X	      w->clock.beeped = TRUE;
X	      break;
X	   case 45:
X	      if (w->clock.quarter_of_sound)
X	         play_sound(w->clock.quarter_of_sound, w->clock.volume);
X	      w->clock.beeped = TRUE;
X	      break;
X	   }
X/* End included */
X
X	if( w->clock.analog == FALSE ) {
X	    int	clear_from;
X	    int i, len, prev_len;
X
X	    time_ptr = asctime(&tm);
X	    len = strlen (time_ptr);
X	    if (time_ptr[len - 1] == '\n') time_ptr[--len] = '\0';
X	    prev_len = strlen (w->clock.prev_time_string);
X	    for (i = 0; ((i < len) && (i < prev_len) && 
X	    		 (w->clock.prev_time_string[i] == time_ptr[i])); i++);
X	    strcpy (w->clock.prev_time_string+i, time_ptr+i);
X
X	    XDrawImageString (dpy, win, w->clock.myGC,
X			      (2+w->clock.padding +
X			       XTextWidth (w->clock.font, time_ptr, i)),
X			      2+w->clock.font->ascent+w->clock.padding,
X			      time_ptr + i, len - i);
X	    /*
X	     * Clear any left over bits
X	     */
X	    clear_from = XTextWidth (w->clock.font, time_ptr, len)
X 	    		+ 2 + w->clock.padding;
X	    if (clear_from < w->core.width)
X		XFillRectangle (dpy, win, w->clock.EraseGC,
X		    clear_from, 0, w->core.width - clear_from, w->core.height);
X	} else {
X			/*
X			 * The second (or minute) hand is sec (or min) 
X			 * sixtieths around the clock face. The hour hand is
X			 * (hour + min/60) twelfths of the way around the
X			 * clock-face.  The derivation is left as an excercise
X			 * for the reader.
X			 */
X
X			/*
X			 * 12 hour clock.
X			 */
X			if(tm.tm_hour > 12)
X				tm.tm_hour -= 12;
X
X			erase_hands (w, &tm);
X
X		    if (w->clock.numseg == 0 ||
X			tm.tm_min != w->clock.otm.tm_min ||
X			tm.tm_hour != w->clock.otm.tm_hour) {
X			    w->clock.segbuffptr = w->clock.segbuff;
X			    w->clock.numseg = 0;
X			    /*
X			     * Calculate the hour hand, fill it in with its
X			     * color and then outline it.  Next, do the same
X			     * with the minute hand.  This is a cheap hidden
X			     * line algorithm.
X			     */
X			    DrawHand(w,
X				w->clock.minute_hand_length, w->clock.hand_width,
X				((double) tm.tm_min)/60.0
X			    );
X			    if(w->clock.Hdpixel != w->core.background_pixel)
X				XFillPolygon( dpy,
X				    win, w->clock.HandGC,
X				    w->clock.segbuff, VERTICES_IN_HANDS,
X				    Convex, CoordModeOrigin
X				);
X			    XDrawLines( dpy,
X				win, w->clock.HighGC,
X				w->clock.segbuff, VERTICES_IN_HANDS,
X				       CoordModeOrigin);
X			    w->clock.hour = w->clock.segbuffptr;
X			    DrawHand(w, 
X				w->clock.hour_hand_length, w->clock.hand_width,
X				((((double)tm.tm_hour) + 
X				    (((double)tm.tm_min)/60.0)) / 12.0)
X			    );
X			    if(w->clock.Hdpixel != w->core.background_pixel) {
X			      XFillPolygon(dpy,
X					   win, w->clock.HandGC,
X					   w->clock.hour,
X					   VERTICES_IN_HANDS,
X					   Convex, CoordModeOrigin
X					   );
X			    }
X			    XDrawLines( dpy,
X				       win, w->clock.HighGC,
X				       w->clock.hour, VERTICES_IN_HANDS,
X				       CoordModeOrigin );
X
X			    w->clock.sec = w->clock.segbuffptr;
X		    }
X		    if (w->clock.show_second_hand == TRUE) {
X			    w->clock.segbuffptr = w->clock.sec;
X			    DrawSecond(w,
X				w->clock.second_hand_length - 2, 
X				w->clock.second_hand_width,
X				w->clock.minute_hand_length + 2,
X				((double) tm.tm_sec)/60.0
X			    );
X			    if(w->clock.Hdpixel != w->core.background_pixel)
X				XFillPolygon( dpy,
X				    win, w->clock.HandGC,
X				    w->clock.sec,
X				    VERTICES_IN_HANDS -2,
X				    Convex, CoordModeOrigin
X			    );
X			    XDrawLines( dpy,
X				       win, w->clock.HighGC,
X				       w->clock.sec,
X				       VERTICES_IN_HANDS-1,
X				       CoordModeOrigin
X				        );
X
X			}
X			w->clock.otm = tm;
X		}
X}
X
Xstatic erase_hands (w, tm)
XClockWidget	w;
Xstruct tm	*tm;
X{
X    /*
X     * Erase old hands.
X     */
X    if(w->clock.numseg > 0) {
X	Display	*dpy;
X	Window	win;
X
X	dpy = XtDisplay (w);
X	win = XtWindow (w);
X	if (w->clock.show_second_hand == TRUE) {
X	    XDrawLines(dpy, win,
X		w->clock.EraseGC,
X		w->clock.sec,
X		VERTICES_IN_HANDS-1,
X		CoordModeOrigin);
X	    if(w->clock.Hdpixel != w->core.background_pixel) {
X		XFillPolygon(dpy,
X			win, w->clock.EraseGC,
X			w->clock.sec,
X			VERTICES_IN_HANDS-2,
X			Convex, CoordModeOrigin
X			);
X	    }
X	}
X	if(!tm || tm->tm_min != w->clock.otm.tm_min ||
X		  tm->tm_hour != w->clock.otm.tm_hour)
X 	{
X	    XDrawLines( dpy, win,
X			w->clock.EraseGC,
X			w->clock.segbuff,
X			VERTICES_IN_HANDS,
X			CoordModeOrigin);
X	    XDrawLines( dpy, win,
X			w->clock.EraseGC,
X			w->clock.hour,
X			VERTICES_IN_HANDS,
X			CoordModeOrigin);
X	    if(w->clock.Hdpixel != w->core.background_pixel) {
X		XFillPolygon( dpy, win,
X 			      w->clock.EraseGC,
X			      w->clock.segbuff, VERTICES_IN_HANDS,
X			      Convex, CoordModeOrigin);
X		XFillPolygon( dpy, win,
X 			      w->clock.EraseGC,
X			      w->clock.hour,
X			      VERTICES_IN_HANDS,
X			      Convex, CoordModeOrigin);
X	    }
X	}
X    }
X}
X
X/*
X * DrawLine - Draws a line.
X *
X * blank_length is the distance from the center which the line begins.
X * length is the maximum length of the hand.
X * Fraction_of_a_circle is a fraction between 0 and 1 (inclusive) indicating
X * how far around the circle (clockwise) from high noon.
X *
X * The blank_length feature is because I wanted to draw tick-marks around the
X * circle (for seconds).  The obvious means of drawing lines from the center
X * to the perimeter, then erasing all but the outside most pixels doesn't
X * work because of round-off error (sigh).
X */
Xstatic void DrawLine(w, blank_length, length, fraction_of_a_circle)
XClockWidget w;
XDimension blank_length;
XDimension length;
Xdouble fraction_of_a_circle;
X{
X	double dblank_length = (double)blank_length, dlength = (double)length;
X	double angle, cosangle, sinangle;
X	double cos();
X	double sin();
X	int cx = w->clock.centerX, cy = w->clock.centerY, x1, y1, x2, y2;
X
X	/*
X	 *  A full circle is 2 PI radians.
X	 *  Angles are measured from 12 o'clock, clockwise increasing.
X	 *  Since in X, +x is to the right and +y is downward:
X	 *
X	 *	x = x0 + r * sin(theta)
X	 *	y = y0 - r * cos(theta)
X	 *
X	 */
X	angle = TWOPI * fraction_of_a_circle;
X	cosangle = cos(angle);
X	sinangle = sin(angle);
X
X	/* break this out so that stupid compilers can cope */
X	x1 = cx + (int)(dblank_length * sinangle);
X	y1 = cy - (int)(dblank_length * cosangle);
X	x2 = cx + (int)(dlength * sinangle);
X	y2 = cy - (int)(dlength * cosangle);
X	SetSeg(w, x1, y1, x2, y2);
X}
X
X/*
X * DrawHand - Draws a hand.
X *
X * length is the maximum length of the hand.
X * width is the half-width of the hand.
X * Fraction_of_a_circle is a fraction between 0 and 1 (inclusive) indicating
X * how far around the circle (clockwise) from high noon.
X *
X */
Xstatic void DrawHand(w, length, width, fraction_of_a_circle)
XClockWidget w;
XDimension length, width;
Xdouble fraction_of_a_circle;
X{
X
X	register double angle, cosangle, sinangle;
X	register double ws, wc;
X	Position x, y, x1, y1, x2, y2;
X	double cos();
X	double sin();
X
X	/*
X	 *  A full circle is 2 PI radians.
X	 *  Angles are measured from 12 o'clock, clockwise increasing.
X	 *  Since in X, +x is to the right and +y is downward:
X	 *
X	 *	x = x0 + r * sin(theta)
X	 *	y = y0 - r * cos(theta)
X	 *
X	 */
X	angle = TWOPI * fraction_of_a_circle;
X	cosangle = cos(angle);
X	sinangle = sin(angle);
X	/*
X	 * Order of points when drawing the hand.
X	 *
X	 *		1,4
X	 *		/ \
X	 *	       /   \
X	 *	      /     \
X	 *	    2 ------- 3
X	 */
X	wc = width * cosangle;
X	ws = width * sinangle;
X	SetSeg(w,
X	       x = w->clock.centerX + round(length * sinangle),
X	       y = w->clock.centerY - round(length * cosangle),
X	       x1 = w->clock.centerX - round(ws + wc), 
X	       y1 = w->clock.centerY + round(wc - ws));  /* 1 ---- 2 */
X	/* 2 */
X	SetSeg(w, x1, y1, 
X	       x2 = w->clock.centerX - round(ws - wc), 
X	       y2 = w->clock.centerY + round(wc + ws));  /* 2 ----- 3 */
X
X	SetSeg(w, x2, y2, x, y);	/* 3 ----- 1(4) */
X}
X
X/*
X * DrawSecond - Draws the second hand (diamond).
X *
X * length is the maximum length of the hand.
X * width is the half-width of the hand.
X * offset is direct distance from center to tail end.
X * Fraction_of_a_circle is a fraction between 0 and 1 (inclusive) indicating
X * how far around the circle (clockwise) from high noon.
X *
X */
Xstatic void DrawSecond(w, length, width, offset, fraction_of_a_circle)
XClockWidget w;
XDimension length, width, offset;
Xdouble fraction_of_a_circle;
X{
X
X	register double angle, cosangle, sinangle;
X	register double ms, mc, ws, wc;
X	register int mid;
X	Position x, y;
X	double cos();
X	double sin();
X
X	/*
X	 *  A full circle is 2 PI radians.
X	 *  Angles are measured from 12 o'clock, clockwise increasing.
X	 *  Since in X, +x is to the right and +y is downward:
X	 *
X	 *	x = x0 + r * sin(theta)
X	 *	y = y0 - r * cos(theta)
X	 *
X	 */
X	angle = TWOPI * fraction_of_a_circle;
X	cosangle = cos(angle);
X	sinangle = sin(angle);
X	/*
X	 * Order of points when drawing the hand.
X	 *
X	 *		1,5
X	 *		/ \
X	 *	       /   \
X	 *	      /     \
X	 *	    2<       >4
X	 *	      \     /
X	 *	       \   /
X	 *		\ /
X	 *	-	 3
X	 *	|
X	 *	|
X	 *   offset
X	 *	|
X	 *	|
X	 *	-	 + center
X	 */
X
X	mid = (length + offset) / 2;
X	mc = mid * cosangle;
X	ms = mid * sinangle;
X	wc = width * cosangle;
X	ws = width * sinangle;
X	/*1 ---- 2 */
X	SetSeg(w,
X	       x = w->clock.centerX + round(length * sinangle),
X	       y = w->clock.centerY - round(length * cosangle),
X	       w->clock.centerX + round(ms - wc),
X	       w->clock.centerY - round(mc + ws) );
X	SetSeg(w, w->clock.centerX + round(offset *sinangle),
X	       w->clock.centerY - round(offset * cosangle), /* 2-----3 */
X	       w->clock.centerX + round(ms + wc), 
X	       w->clock.centerY - round(mc - ws));
X	w->clock.segbuffptr->x = x;
X	w->clock.segbuffptr++->y = y;
X	w->clock.numseg ++;
X}
X
Xstatic void SetSeg(w, x1, y1, x2, y2)
XClockWidget w;
Xint x1, y1, x2, y2;
X{
X	w->clock.segbuffptr->x = x1;
X	w->clock.segbuffptr++->y = y1;
X	w->clock.segbuffptr->x = x2;
X	w->clock.segbuffptr++->y = y2;
X	w->clock.numseg += 2;
X}
X
X/*
X *  Draw the clock face (every fifth tick-mark is longer
X *  than the others).
X */
Xstatic void DrawClockFace(w)
XClockWidget w;
X{
X	register int i;
X	register int delta = (w->clock.radius - w->clock.second_hand_length) / 3;
X	
X	w->clock.segbuffptr = w->clock.segbuff;
X	w->clock.numseg = 0;
X	for (i = 0; i < 60; i++)
X		DrawLine(w, ( (i % 5) == 0 ? 
X			     w->clock.second_hand_length :
X			     (w->clock.radius - delta) ),
X			 w->clock.radius, ((double) i)/60.);
X	/*
X	 * Go ahead and draw it.
X	 */
X	XDrawSegments(XtDisplay(w), XtWindow(w),
X		      w->clock.myGC, (XSegment *) &(w->clock.segbuff[0]),
X		      w->clock.numseg/2);
X	
X	w->clock.segbuffptr = w->clock.segbuff;
X	w->clock.numseg = 0;
X}
X
Xstatic int round(x)
Xdouble x;
X{
X	return(x >= 0.0 ? (int)(x + .5) : (int)(x - .5));
X}
X
X/* ARGSUSED */
Xstatic Boolean SetValues (gcurrent, grequest, gnew)
X    Widget gcurrent, grequest, gnew;
X{
X      ClockWidget current = (ClockWidget) gcurrent;
X      ClockWidget new = (ClockWidget) gnew;
X      Boolean redisplay = FALSE;
X      XtGCMask valuemask;
X      XGCValues	myXGCV;
X
X      /* first check for changes to clock-specific resources.  We'll accept all
X         the changes, but may need to do some computations first. */
X
X      if (new->clock.update != current->clock.update) {
X	  if (current->clock.interval_id)
X	      XtRemoveTimeOut (current->clock.interval_id);
X	  if (XtIsRealized(new))
X	      new->clock.interval_id = XtAppAddTimeOut( 
X                                         XtWidgetToApplicationContext(gnew),
X					 new->clock.update*1000,
X				         clock_tic, (caddr_t)gnew);
X
X	  new->clock.show_second_hand =(new->clock.update <= SECOND_HAND_TIME);
X      }
X
X      if (new->clock.padding != current->clock.padding)
X	   redisplay = TRUE;
X
X      if (new->clock.analog != current->clock.analog)
X	   redisplay = TRUE;
X
X       if (new->clock.font != current->clock.font)
X	   redisplay = TRUE;
X
X      if ((new->clock.fgpixel != current->clock.fgpixel)
X          || (new->core.background_pixel != current->core.background_pixel)) {
X          valuemask = GCForeground | GCBackground | GCFont | GCLineWidth;
X	  myXGCV.foreground = new->clock.fgpixel;
X	  myXGCV.background = new->core.background_pixel;
X          myXGCV.font = new->clock.font->fid;
X	  myXGCV.line_width = 0;
X	  XtDestroyGC (current->clock.myGC);
X	  new->clock.myGC = XtGetGC(gcurrent, valuemask, &myXGCV);
X	  redisplay = TRUE;
X          }
X
X      if (new->clock.Hipixel != current->clock.Hipixel) {
X          valuemask = GCForeground | GCLineWidth;
X	  myXGCV.foreground = new->clock.fgpixel;
X          myXGCV.font = new->clock.font->fid;
X	  myXGCV.line_width = 0;
X	  XtDestroyGC (current->clock.HighGC);
X	  new->clock.HighGC = XtGetGC((Widget)gcurrent, valuemask, &myXGCV);
X	  redisplay = TRUE;
X          }
X
X      if (new->clock.Hdpixel != current->clock.Hdpixel) {
X          valuemask = GCForeground;
X	  myXGCV.foreground = new->clock.fgpixel;
X	  XtDestroyGC (current->clock.HandGC);
X	  new->clock.HandGC = XtGetGC((Widget)gcurrent, valuemask, &myXGCV);
X	  redisplay = TRUE;
X          }
X
X      if (new->core.background_pixel != current->core.background_pixel) {
X          valuemask = GCForeground | GCLineWidth;
X	  myXGCV.foreground = new->core.background_pixel;
X	  myXGCV.line_width = 0;
X	  XtDestroyGC (current->clock.EraseGC);
X	  new->clock.EraseGC = XtGetGC((Widget)gcurrent, valuemask, &myXGCV);
X	  redisplay = TRUE;
X	  }
X     
X     return (redisplay);
X
X}
E!O!F! Clock.c
echo Clock.h 1>&2
sed -e 's/^X//' > Clock.h <<'E!O!F! Clock.h'
X/*
X* $XConsortium: Clock.h,v 1.28 89/07/20 14:54:38 jim Exp $
X*/
X
X
X/***********************************************************
XCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X
X                        All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its 
Xdocumentation for any purpose and without fee is hereby granted, 
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in 
Xsupporting documentation, and that the names of Digital or MIT not be
Xused in advertising or publicity pertaining to distribution of the
Xsoftware without specific, written prior permission.  
X
XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
XSOFTWARE.
X
X******************************************************************/
X
X#ifndef _XawClock_h
X#define _XawClock_h
X
X/***********************************************************************
X *
X * Clock Widget
X *
X ***********************************************************************/
X
X#include <X11/Xmu/Converters.h>
X
X/* Parameters:
X
X Name		     Class		RepType		Default Value
X ----		     -----		-------		-------------
X analog		     Boolean		Boolean		True
X background	     Background		Pixel		white
X backingStore	     BackingStore	BackingStore	default
X border		     BorderColor	Pixel		Black
X borderWidth	     BorderWidth	Dimension	1
X chime		     Boolean		Boolean		False
X destroyCallback     Callback		Pointer		NULL
X font		     Font		XFontStruct*	fixed
X foreground	     Foreground		Pixel		black
X hand		     Foreground		Pixel		black
X height		     Height		Dimension	164
X highlight	     Foreground		Pixel		black
X mappedWhenManaged   MappedWhenManaged	Boolean		True
X padding	     Margin		int		8
X reverseVideo	     ReverseVideo	Boolean		False
X update		     Interval		int		60 (seconds)
X width		     Width		Dimension	164
X x		     Position		Position	0
X y		     Position		Position	0
X hourSound           HourSound          String          NULL
X quarterPastSound    QuarterPastSound   String          NULL
X halfPastSound       HalfPastSound      String          NULL
X quarterOfSound      QuarterOfSound     String          NULL
X chimeSound          ChimeSound         String          NULL
X volume              Volume             int             75
X
X*/
X
X/* Resource names used to the clock widget */
X
X		/* color of hands */
X#define XtNhand "hands"
X
X
X		/* Boolean: digital if FALSE */
X#define XtNanalog "analog"
X
X		/* Boolean:  */
X#define XtNchime "chime"
X
X		/* Int: amount of space around outside of clock */
X#define XtNpadding "padding"
X#define XtNhourSound "hourSound"
X#define XtCHourSound "HourSound"
X#define XtNquarterPastSound "quarterPastSound"
X#define XtCQuarterPastSound "QuarterPastSound"
X#define XtNhalfPastSound "halfPastSound"
X#define XtCHalfPastSound "HalfPastSound"
X#define XtNquarterOfSound "quarterOfSound"
X#define XtCQuarterOfSound "QuarterOfSound"
X#define XtNchimeSound "chimeSound"
X#define XtCChimeSound "ChimeSound"
X#define XtNvolume "volume"
X#define XtCVolume "Volume"
X
Xtypedef struct _ClockRec *ClockWidget;  /* completely defined in ClockPrivate.h */
Xtypedef struct _ClockClassRec *ClockWidgetClass;    /* completely defined in ClockPrivate.h */
X
Xextern WidgetClass clockWidgetClass;
X
X#endif /* _XawClock_h */
X/* DON'T ADD STUFF AFTER THIS #endif */
E!O!F! Clock.h
echo ClockP.h 1>&2
sed -e 's/^X//' > ClockP.h <<'E!O!F! ClockP.h'
X/*
X* $XConsortium: ClockP.h,v 1.19 89/12/06 15:23:06 kit Exp $
X*/
X
X
X/***********************************************************
XCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X
X                        All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its 
Xdocumentation for any purpose and without fee is hereby granted, 
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in 
Xsupporting documentation, and that the names of Digital or MIT not be
Xused in advertising or publicity pertaining to distribution of the
Xsoftware without specific, written prior permission.  
X
XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
XSOFTWARE.
X
X******************************************************************/
X
X#ifndef _XawClockP_h
X#define _XawClockP_h
X
X#include <X11/Xos.h>		/* Needed for struct tm. */
X#include "Clock.h"
X#include <X11/CoreP.h>
X
X#define SEG_BUFF_SIZE		128
X#define ASCII_TIME_BUFLEN	32	/* big enough for 26 plus slop */
X
X/* New fields for the clock widget instance record */
Xtypedef struct {
X	 Pixel	fgpixel;	/* color index for text */
X	 Pixel	Hipixel;	/* color index for Highlighting */
X	 Pixel	Hdpixel;	/* color index for hands */
X	 XFontStruct	*font;	/* font for text */
X	 GC	myGC;		/* pointer to GraphicsContext */
X	 GC	EraseGC;	/* eraser GC */
X	 GC	HandGC;		/* Hand GC */
X	 GC	HighGC;		/* Highlighting GC */
X/* start of graph stuff */
X	 int	update;		/* update frequence */
X	 Dimension radius;		/* radius factor */
X	 int	backing_store;	/* backing store type */
X	 Boolean reverse_video;
X	 Boolean chime;
X	 Boolean beeped;
X	 Boolean analog;
X	 Boolean show_second_hand;
X	 Dimension second_hand_length;
X	 Dimension minute_hand_length;
X	 Dimension hour_hand_length;
X	 Dimension hand_width;
X	 Dimension second_hand_width;
X	 Position centerX;
X	 Position centerY;
X	 int	numseg;
X	 int	padding;
X	 XPoint	segbuff[SEG_BUFF_SIZE];
X	 XPoint	*segbuffptr;
X	 XPoint	*hour, *sec;
X	 struct tm  otm ;
X	 XtIntervalId interval_id;
X	 char prev_time_string[ASCII_TIME_BUFLEN];
X	 String          hour_sound;   /* sounds to play at different times */
X	 String          quarter_past_sound;
X	 String          half_past_sound;
X	 String          quarter_of_sound;
X	 String          chime_sound;
X	 int             volume;
X  } ClockPart;
X
X/* Full instance record declaration */
Xtypedef struct _ClockRec {
X   CorePart core;
X   ClockPart clock;
X   } ClockRec;
X
X/* New fields for the Clock widget class record */
Xtypedef struct {int dummy;} ClockClassPart;
X
X/* Full class record declaration. */
Xtypedef struct _ClockClassRec {
X   CoreClassPart core_class;
X   ClockClassPart clock_class;
X   } ClockClassRec;
X
X/* Class pointer. */
Xextern ClockClassRec clockClassRec;
X
X#endif /* _XawClockP_h */
E!O!F! ClockP.h
echo Imakefile 1>&2
sed -e 's/^X//' > Imakefile <<'E!O!F! Imakefile'
X        DEFINES = -DSUNOS4_1
X       INCLUDES = -I/usr/demo/SOUND
X        DEPLIBS = XawClientDepLibs
XLOCAL_LIBRARIES =  XawClientLibs
X  SYS_LIBRARIES = -L/usr/demo/SOUND -laudio -lm
X
X#ifdef SparcArchitecture
XSRCS = xclock.c Clock.c transform.c play.c libst.c libsst.c
XOBJS = xclock.o Clock.o transform.o play.o libst.o libsst.o
X#else
XSRCS = xclock.c Clock.c transform.c
XOBJS = xclock.o Clock.o transform.o
X#endif
X
XComplexProgramTarget(xclock)
XInstallAppDefaults(XClock)
E!O!F! Imakefile
echo Makefile 1>&2
sed -e 's/^X//' > Makefile <<'E!O!F! Makefile'
X# Makefile generated by imake - do not edit!
X# $XConsortium: imake.c,v 1.51 89/12/12 12:37:30 jim Exp $
X#
X# The cpp used on this machine replaces all newlines and multiple tabs and
X# spaces in a macro expansion with a single space.  Imake tries to compensate
X# for this, but is not always successful.
X#
X
X###########################################################################
X# Makefile generated from "Imake.tmpl" and <Imakefile>
X# $XConsortium: Imake.tmpl,v 1.77 89/12/18 17:01:37 jim Exp $
X#
X# Platform-specific parameters may be set in the appropriate .cf
X# configuration files.  Site-wide parameters may be set in the file
X# site.def.  Full rebuilds are recommended if any parameters are changed.
X#
X# If your C preprocessor doesn't define any unique symbols, you'll need
X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
X# "make Makefile", "make Makefiles", or "make World").
X#
X# If you absolutely can't get imake to work, you'll need to set the
X# variables at the top of each Makefile as well as the dependencies at the
X# bottom (makedepend will do this automatically).
X#
X
X###########################################################################
X# platform-specific configuration parameters - edit sun.cf to change
X
XSYSLIBS=-lXt -lX11
XMWM_DEFINES=-DSHAPE -DOPAQUE
X
X# platform:  $XConsortium: sun.cf,v 1.38 89/12/23 16:10:10 jim Exp $
X# operating system:  SunOS 4.1
X
X###########################################################################
X# site-specific configuration parameters - edit site.def to change
X
X# site:  $XConsortium: site.def,v 1.21 89/12/06 11:46:50 jim Exp $
X
X            SHELL = /bin/sh
X
X              TOP = .
X      CURRENT_DIR = .
X
X               AR = ar cq
X  BOOTSTRAPCFLAGS =
X               CC = cc
X
X         COMPRESS = compress
X              CPP = /lib/cpp $(STD_CPP_DEFINES)
X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
X          INSTALL = install
X               LD = ld
X             LINT = lint
X      LINTLIBFLAG = -C
X         LINTOPTS = -axz
X               LN = ln -s
X             MAKE = make
X               MV = mv
X               CP = cp
X           RANLIB = ranlib
X  RANLIBINSTFLAGS =
X               RM = rm -f
X     STD_INCLUDES =
X  STD_CPP_DEFINES =
X      STD_DEFINES =
X EXTRA_LOAD_FLAGS =
X  EXTRA_LIBRARIES =
X             TAGS = ctags
X
X    SHAREDCODEDEF = -DSHAREDCODE
X         SHLIBDEF = -DSUNSHLIB
X
X    PROTO_DEFINES =
X
X     INSTPGMFLAGS =
X
X     INSTBINFLAGS = -m 0755
X     INSTUIDFLAGS = -m 4755
X     INSTLIBFLAGS = -m 0664
X     INSTINCFLAGS = -m 0444
X     INSTMANFLAGS = -m 0444
X     INSTDATFLAGS = -m 0444
X    INSTKMEMFLAGS = -m 4755
X
X          DESTDIR =
X
X     TOP_INCLUDES = -I$(INCROOT)
X
X      CDEBUGFLAGS = -O
X        CCOPTIONS = -D_NO_PROTO -DSTRINGS_ALIGNED -DNO_REGEX -DNO_ISDIR -DUSE_RE_COMP -DUSE_GETWD
X      COMPATFLAGS =
X
X      ALLINCLUDES = $(STD_INCLUDES) $(TOP_INCLUDES) $(INCLUDES) $(EXTRA_INCLUDES)
X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(DEFINES) $(COMPATFLAGS)
X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS)
X   LDCOMBINEFLAGS = -X -r
X
X        MACROFILE = sun.cf
X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
X
X    IMAKE_DEFINES =
X
X         IRULESRC = $(CONFIGDIR)
X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
X
X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
X			$(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
X			$(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
X
X###########################################################################
X# X Window System Build Parameters
X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
X
X###########################################################################
X# X Window System make variables; this need to be coordinated with rules
X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
X
X          PATHSEP = /
X        USRLIBDIR = $(DESTDIR)/usr/lib
X           BINDIR = $(DESTDIR)/usr/bin/X11
X          INCROOT = $(DESTDIR)/usr/include
X     BUILDINCROOT = $(TOP)
X      BUILDINCDIR = $(BUILDINCROOT)/X11
X      BUILDINCTOP = ..
X           INCDIR = $(INCROOT)/X11
X           ADMDIR = $(DESTDIR)/usr/adm
X           LIBDIR = $(USRLIBDIR)/X11
X        CONFIGDIR = $(LIBDIR)/config
X       LINTLIBDIR = $(USRLIBDIR)/lint
X
X          FONTDIR = $(LIBDIR)/fonts
X         XINITDIR = $(LIBDIR)/xinit
X           XDMDIR = $(LIBDIR)/xdm
X           AWMDIR = $(LIBDIR)/awm
X           TWMDIR = $(LIBDIR)/twm
X           GWMDIR = $(LIBDIR)/gwm
X          MANPATH = $(DESTDIR)/usr/man
X    MANSOURCEPATH = $(MANPATH)/man
X           MANDIR = $(MANSOURCEPATH)n
X        LIBMANDIR = $(MANSOURCEPATH)3
X      XAPPLOADDIR = $(LIBDIR)/app-defaults
X
X        SOXLIBREV = 4.2
X          SOXTREV = 4.0
X         SOXAWREV = 4.0
X        SOOLDXREV = 4.0
X         SOXMUREV = 4.0
X        SOXEXTREV = 4.0
X
X       FONTCFLAGS = -t
X
X     INSTAPPFLAGS = $(INSTDATFLAGS)
X
X            IMAKE = imake
X           DEPEND = makedepend
X              RGB = rgb
X            FONTC = bdftosnf
X        MKFONTDIR = mkfontdir
X        MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier.sh
X
X        CONFIGSRC = $(TOP)/config
X        CLIENTSRC = $(TOP)/clients
X          DEMOSRC = $(TOP)/demos
X           LIBSRC = $(TOP)/lib
X          FONTSRC = $(TOP)/fonts
X       INCLUDESRC = $(TOP)/X11
X        SERVERSRC = $(TOP)/server
X          UTILSRC = $(TOP)/util
X        SCRIPTSRC = $(UTILSRC)/scripts
X       EXAMPLESRC = $(TOP)/examples
X       CONTRIBSRC = $(TOP)/../contrib
X           DOCSRC = $(TOP)/doc
X           RGBSRC = $(TOP)/rgb
X        DEPENDSRC = $(UTILSRC)/makedepend
X         IMAKESRC = $(CONFIGSRC)
X         XAUTHSRC = $(LIBSRC)/Xau
X          XLIBSRC = $(LIBSRC)/X
X           XMUSRC = $(LIBSRC)/Xmu
X       TOOLKITSRC = $(LIBSRC)/Xt
X       AWIDGETSRC = $(LIBSRC)/Xaw
X       OLDXLIBSRC = $(LIBSRC)/oldX
X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
X     MKFONTDIRSRC = $(FONTSRC)/mkfontdir
X     EXTENSIONSRC = $(TOP)/extensions
X
X  DEPEXTENSIONLIB = $(USRLIBDIR)/libXext.a
X     EXTENSIONLIB =  -lXext
X
X          DEPXLIB = $(DEPEXTENSIONLIB)
X             XLIB = $(EXTENSIONLIB) -lX11
X
X      DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
X         XAUTHLIB =  -lXau
X
X        DEPXMULIB =
X           XMULIB = -lXmu
X
X       DEPOLDXLIB =
X          OLDXLIB = -loldX
X
X      DEPXTOOLLIB =
X         XTOOLLIB = -lXt
X
X        DEPXAWLIB =
X           XAWLIB = -lXaw
X
X LINTEXTENSIONLIB = $(USRLIBDIR)/llib-lXext.ln
X         LINTXLIB = $(USRLIBDIR)/llib-lX11.ln
X          LINTXMU = $(USRLIBDIR)/llib-lXmu.ln
X        LINTXTOOL = $(USRLIBDIR)/llib-lXt.ln
X          LINTXAW = $(USRLIBDIR)/llib-lXaw.ln
X
X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
X
X         DEPLIBS1 = $(DEPLIBS)
X         DEPLIBS2 = $(DEPLIBS)
X         DEPLIBS3 = $(DEPLIBS)
X
X      USRINCDIR = $(DESTDIR)/usr/include
X        TESTSRC = $(TOP)/tests
X    MTOOLKITSRC = $(LIBSRC)/Xt
X     MWIDGETSRC = $(LIBSRC)/Xm
X   MRESOURCESRC = $(LIBSRC)/Mrm
X         UILSRC = $(CLIENTSRC)/uil
X
X            UIL = uil
X
X          DEPLIBS =
X
X         DEPLIBS1 = $(DEPLIBS)
X         DEPLIBS2 = $(DEPLIBS)
X         DEPLIBS3 = $(DEPLIBS)
X
X          SOXMREV = 1.1
X         SOMRMREV = 1.1
X
X       DEPXMLIB =
X          XMLIB = -lXm
X
XDEPMRESOURCELIB =
X   MRESOURCELIB = -lMrm
X
X      DEPUILLIB = $(USRLIBDIR)/libUil.a
X         UILLIB =  -lUil
X  LINTMRESOURCE = $(USRLIBDIR)/llib-lMrm.ln
XLINTXMWIDGETLIB = $(USRLIBDIR)/llib-lXm.ln
X     LINTUILLIB = $(USRLIBDIR)/llib-lUil.ln
X
X###########################################################################
X# Imake rules for building libraries, programs, scripts, and data files
X# rules:  $XConsortium: Imake.rules,v 1.67 89/12/18 17:14:15 jim Exp $
X
X###########################################################################
X# start of Imakefile
X
X        DEFINES = -DSUNOS4_1
X       INCLUDES = -I/usr/demo/SOUND
X        DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
XLOCAL_LIBRARIES =  $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
X  SYS_LIBRARIES = -L/usr/demo/SOUND -laudio -lm
X
XSRCS = xclock.c Clock.c transform.c play.c libst.c libsst.c
XOBJS = xclock.o Clock.o transform.o play.o libst.o libsst.o
X
X PROGRAM = xclock
X
Xall:: xclock
X
Xxclock: $(OBJS) $(DEPLIBS)
X	$(RM) $@
X	$(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS)
X
Xinstall:: xclock
X	$(INSTALL) -c $(INSTPGMFLAGS)   xclock $(BINDIR)
X
Xinstall.man:: xclock.man
X	$(INSTALL) -c $(INSTMANFLAGS) xclock.man $(MANDIR)/xclock.n
X
Xdepend::
X	$(DEPEND) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
X
Xlint:
X	$(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
Xlint1:
X	$(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
X
Xclean::
X	$(RM) $(PROGRAM)
X
Xinstall:: XClock.ad
X	$(INSTALL) -c $(INSTAPPFLAGS) XClock.ad $(XAPPLOADDIR)/XClock
X
X###########################################################################
X# common rules for all Makefiles - do not edit
X
Xemptyrule::
X
Xclean::
X	$(RM_CMD) \#*
X
XMakefile::
X	-@if [ -f Makefile ]; then \
X	echo "	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
X	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
X	else exit 0; fi
X	$(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
X
Xtags::
X	$(TAGS) -w *.[ch]
X	$(TAGS) -xw *.[ch] > TAGS
X
X###########################################################################
X# empty rules for directories that do not have SUBDIRS - do not edit
X
Xinstall::
X	@echo "install in $(CURRENT_DIR) done"
X
Xinstall.man::
X	@echo "install.man in $(CURRENT_DIR) done"
X
XMakefiles::
X
Xincludes::
X
X###########################################################################
X# dependencies generated by makedepend
X
E!O!F! Makefile
echo README 1>&2
sed -e 's/^X//' > README <<'E!O!F! README'
XI     added      the      sound   things      that         Mike Wagner
X(wagner@cadillac.siemens.com) added to  "oclock"  to xclock. I  prefer
X"xclock" over "oclock".
X
XRefer to the manual page for former information.
X
XMatthias Pfuetzner
Xpfuetzner@agd.fhg.de
XJan. 25, 1991
E!O!F! README
echo XClock.ad 1>&2
sed -e 's/^X//' > XClock.ad <<'E!O!F! XClock.ad'
XXClock.input: false
E!O!F! XClock.ad
======= end of part 01 =========
            @work:            | Matthias Pfuetzner  |         @home:
  ZGDV, Wilhelminenstrasse 7  | 6100 Darmstadt, FRG |  Lichtenbergstrasse 73
    +49 6151 155-164 or -101  \    <- Tel.nr. ->    /     +49 6151 75717
   pfuetzner@agd.fhg.de    pfuetzner@zgdvda.UUCP    XBR1YD3U@DDATHD21.BITNET


--
Dan Heller
------------------------------------------------
O'Reilly && Associates 		      Zyrcom Inc
Senior Writer			       President
argv@ora.com			argv@zipcode.com