Xkal - X appointment calendar, Part03/04

George Ferguson ferguson at cs.rochester.edu
Thu Nov 15 08:29:33 AEST 1990


#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 3 (of 4)."
# Contents:  db.c month.c resources.h schedule.c
# Wrapped by ferguson at swan.cs.rochester.edu on Mon Nov 12 14:07:07 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'db.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'db.c'\"
else
echo shar: Extracting \"'db.c'\" \(9500 characters\)
sed "s/^X//" >'db.c' <<'END_OF_FILE'
X/*
X *	db.c : Database routines for xkal.
X *	       Handles searching and updating the appointment array.
X *
X *	George Ferguson (ferguson at cs.rochester.edu), 27 Oct 1990.
X *
X *	$Id: db.c,v 1.5 90/11/07 11:22:44 ferguson Exp $
X *
X */
X#include <stdio.h>
X#include <string.h>
X#include <ctype.h>
X#include <errno.h>
X#include <X11/Intrinsic.h>
X#include "util.h"
X#include "date-strings.h"
Xextern char *getenv();
X
Xextern char *program;
X
X/*
X * Functions defined here:
X */
Xvoid initDb(), addAppoint(), deleteAppoint();
Xvoid addScheduleDow(), addSchedule(), deleteScheduleDow(), deleteSchedule();
Xchar *lookup(),*lookupAppoint(),*lookupScheduleDow(),*lookupSchedule();
Xvoid readAppoints(), writeAppoints();
Xstatic void parseApp(), parseSched();
Xstatic char *expandFilename();
X
X/*	-	-	-	-	-	-	-	-	*/
X
Xtypedef struct _msgrec {
X	int pos;
X	char *text;
X	struct _msgrec *next;
X} Msgrec;
Xtypedef struct _dayrec {
X	int day;
X	Msgrec *msgs;
X	struct _dayrec *next;
X} Dayrec;
Xtypedef struct _monrec {
X	int mon;
X	Dayrec *days;
X	struct _monrec *next;
X} Monrec;
Xtypedef struct _yearrec {
X	int year;
X	Monrec *mons;
X	struct _yearrec *next;
X} Yearrec;
X
Xstatic Yearrec *Db = NULL;
Xstatic char *schedule[7][22];
X
X/*	-	-	-	-	-	-	-	-	*/
X/* Initialization (pretty lame) */
X
Xvoid
XinitDb()
X{
X    int i,j;
X
X    Db = NULL;	/* should really free everything... */
X    for (i=0; i < 7; i++)
X	for (j=0; j < 22; j++)
X	    schedule[i][j] = NULL;
X}
X
X/*	-	-	-	-	-	-	-	-	*/
X/* Appointment routines */
X
Xvoid
XaddAppoint(pos,day,mon,year,text)
Xint pos,day,mon,year;
Xchar *text;
X{
X  Yearrec *yp;
X  Monrec *mp;
X  Dayrec *dp;
X  Msgrec *xp;
X
X    if (Db == NULL) {
X	Db = XtNew(Yearrec);
X	Db->year = year;
X	Db->mons = NULL;
X	Db->next = NULL;
X    }
X    for (yp = Db; yp->year != year && yp->next != NULL; yp = yp->next) ;
X    if (yp->year != year) {
X	yp->next = XtNew(Yearrec);
X	yp->next->year = year;
X	yp->next->mons = NULL;
X	yp->next->next = NULL;
X	yp = yp->next;
X    }
X    if (yp->mons == NULL) {
X	yp->mons = XtNew(Monrec);
X	yp->mons->mon = mon;
X	yp->mons->days = NULL;
X	yp->mons->next = NULL;
X    }
X    for (mp = yp->mons; mp->mon != mon && mp->next != NULL; mp = mp->next) ;
X    if (mp->mon != mon) {
X	mp->next = XtNew(Monrec);
X	mp->next->mon = mon;
X	mp->next->days = NULL;
X	mp->next->next=NULL;
X	mp = mp->next;
X    }
X
X    if (mp->days == NULL) {
X	mp->days = XtNew(Dayrec);
X	mp->days->day = day;
X	mp->days->msgs = NULL;
X	mp->days->next = NULL;
X    }
X    for (dp = mp->days; dp->day != day && dp->next != NULL; dp = dp->next) ;
X    if (dp->day != day) {
X	dp->next = XtNew(Dayrec);
X	dp->next->day = day;
X	dp->next->msgs = NULL;
X	dp->next->next=NULL;
X	dp = dp->next;
X    }
X
X    if (dp->msgs == NULL) {
X	dp->msgs = XtNew(Msgrec);
X	dp->msgs->pos = pos;
X	dp->msgs->text = NULL;
X	dp->msgs->next = NULL;
X    }
X    for (xp = dp->msgs; xp->pos != pos && xp->next != NULL; xp = xp->next) ;
X    if (xp->pos != pos) {
X	xp->next = XtNew(Msgrec);
X	xp->next->pos = pos;
X	xp->next->text = NULL;
X	xp->next->next = NULL;
X	xp = xp->next;
X    }
X    XtFree(xp->text);
X    xp->text = XtNewString(text);
X}
X
Xvoid
XdeleteAppoint(pos,day,mon,year)
Xint pos,day,mon,year;
X{
X  Yearrec *yp,*yp2;
X  Monrec *mp,*mp2;
X  Dayrec *dp,*dp2;
X  Msgrec *xp,*xp2;
X
X    for (yp = Db; yp != NULL && yp->year != year; yp = yp->next) ;
X    if (yp == NULL)
X	return;		/* error? */
X
X    for (mp = yp->mons; mp != NULL && mp->mon != mon; mp = mp->next) ;
X    if (mp == NULL)
X	return;		/* error? */
X
X    for (dp = mp->days; dp != NULL && dp->day != day; dp = dp->next) ;
X    if (dp == NULL)
X	return;		/* error? */
X
X    for (xp = dp->msgs; xp != NULL && xp->pos != pos; xp = xp->next) ;
X    if (xp == NULL)
X	return;		/* error? */
X
X	/* Now free 'em up */
X
X    XtFree(xp->text);		/* free the text */
X    
X    if (dp->msgs == xp)		/* and the msgrec */
X	dp->msgs = xp->next;
X    else {
X	for (xp2 = dp->msgs; xp2->next != xp; xp2 = xp2->next) ;
X	xp2->next = xp->next;
X    }
X    XtFree(xp);
X
X    if (dp->msgs == NULL) {	/* if no more entries, free the day */
X	if (mp->days == dp)
X	    mp->days = dp->next;
X	else {
X	    for (dp2 = mp->days; dp2->next != dp; dp2 = dp2->next) ;
X	    dp2->next = dp->next;
X	}
X	XtFree(dp);
X    }
X
X    if (mp->days == NULL) {	/* if no more days, free the month */
X	if (yp->mons == mp)
X	    yp->mons = mp->next;
X	else {
X	    for (mp2 = yp->mons; mp2->next != mp; mp2 = mp2->next) ;
X	    mp2->next = mp->next;
X	}
X	XtFree(mp);
X    }
X
X    if (yp->mons == NULL) {	/* if no more months, free the year */
X	if (Db == yp)
X	    Db = NULL;
X	else {
X	    for (yp2 = Db; yp2->next != yp; yp2 = yp2->next) ;
X	    yp2->next = yp->next;
X	}
X	XtFree(yp);
X    }
X}
X
X/*	-	-	-	-	-	-	-	-	*/
X/* Schedule routines */
X
Xvoid
XaddScheduleDow(pos,dow,msg)
Xint pos,dow;
Xchar *msg;
X{
X    XtFree(schedule[dow][pos]);
X    schedule[dow][pos] = XtNewString(msg);
X}
X
Xvoid
XaddSchedule(pos,day,mon,year,msg)
Xint pos,day,mon,year;
Xchar *msg;
X{
X    lookupScheduleDow(pos,computeDOW(day,mon,year),msg);
X}
X
Xvoid
XdeleteScheduleDow(pos,dow)
Xint pos,dow;
X{
X    XtFree(schedule[dow][pos]);
X    schedule[dow][pos] = NULL;
X}
X
Xvoid
XdeleteSchedule(pos,day,mon,year)
Xint pos,day,mon,year;
X{
X    lookupScheduleDow(pos,computeDOW(day,mon,year));
X}
X
X/*	-	-	-	-	-	-	-	-	*/
X/* Lookup routines */
X
Xchar *
Xlookup(pos,day,mon,year)
X{
X    char *s;
X
X    if ((s=lookupAppoint(pos,day,mon,year)) != NULL)
X	return(s);
X    else
X	return(lookupSchedule(pos,day,mon,year));
X}
X
Xchar *
XlookupAppoint(pos,day,mon,year)
Xint pos,day,mon,year;
X{
X    Yearrec *yp;
X    Monrec *mp;
X    Dayrec *dp;
X    Msgrec *xp;
X
X    for (yp = Db; yp != NULL && yp->year != year; yp = yp->next) ;
X    if (yp != NULL) {
X      for (mp = yp->mons; mp != NULL && mp->mon != mon; mp = mp->next) ;
X      if (mp != NULL) {
X	for (dp = mp->days; dp != NULL && dp->day != day; dp = dp->next) ;
X	if (dp != NULL) {
X	  for (xp = dp->msgs; xp != NULL && xp->pos != pos; xp = xp->next) ;
X	  if (xp != NULL)
X	      return(xp->text);
X	}
X      }
X    }
X    return(NULL);
X}
X
Xchar *
XlookupScheduleDow(pos,dow)
Xint pos,dow;
X{
X    return(schedule[dow][pos]);
X}
X
Xchar *
XlookupSchedule(pos,day,mon,year)
Xint pos,day,mon,year;
X{
X    return(lookupScheduleDow(pos,computeDOW(day,mon,year)));
X}
X    
X    
X/*	-	-	-	-	-	-	-	-	*/
X/* I/O routines */
X
Xvoid
XreadAppoints(name)
Xchar *name;
X{
X    FILE *fp;
X    char *fname,buf[256];
X    int line,i,n,c;
X
X    fname = expandFilename(name);
X    if ((fp=fopen(fname,"r")) == NULL) {
X	if (errno != ENOENT)	/* appointment file may not exist */
X	    perror(fname);
X	return;
X    }
X    line = 0;
X    while (1) {
X	n = 0;
X	line += 1;
X	while (n < 255 && (c=getc(fp)) != EOF && c != '\n')
X	    buf[n++] = c;
X	buf[n] = '\0';
X	if (n == 0)
X	    break;
X	else if (c != EOF && c != '\n') {
X	    fprintf(stderr,"%s: line %d too long, file %s\n",program,
X								line,fname);
X	    while ((c=getc(fp)) != EOF && c != '\n') ;
X	}
X	for (i=0; isspace(buf[i]) && i < n; i++) ;
X	if (buf[i] == '#')
X	    continue;
X	else if (isdigit(buf[i]))
X	    parseApp(buf,line,fname);
X	else
X	    parseSched(buf,line,fname);
X    }
X    fclose(fp);
X}
X
Xstatic void
XparseApp(buf,line,fname)
Xchar *buf;
Xint line;
Xchar *fname;
X{
X    int d,m,y,h,h2,pos;
X    char mstr[4],msg[256];
X
X    if (sscanf(buf,"%d %3s %d %d:%d %256[^\n]",&d,mstr,&y,&h,&h2,msg) != 6) {
X	fprintf(stderr,"%s: file \"%s\", line %d: invalid appointment: %s\n",
X							program,fname,line,buf);
X	return;
X    }
X    if (islower(mstr[0]))
X	mstr[0] = toupper(mstr[0]);
X    for (m=0; m < 12; m++)
X	if (strncmp(shortMonStr[m],mstr,3) == 0)
X	    break;
X    if (m == 12) {
X	fprintf(stderr,"%s: file \"%s\", line %d: invalid month: %s\n",
X						program,fname,line,mstr);
X	return;
X    }
X    if (h2 < 30)
X	pos = (h-8)*2;
X    else
X	pos = (h-8)*2+1;
X    addAppoint(pos,d,m,y-1900,msg);
X}
X
Xstatic void
XparseSched(buf,line,fname)
Xchar *buf;
Xint line;
Xchar *fname;
X{
X    int d,h,h2,pos;
X    char dowstr[4],msg[256];
X
X    if (sscanf(buf,"%3s %d:%d %256[^\n]",dowstr,&h,&h2,msg) != 4) {
X	fprintf(stderr,"%s: file \"%s\", line %d: invalid schedule entry: %s\n",
X							program,fname,line,buf);
X	return;
X    }
X    if (islower(dowstr[0]))
X	dowstr[0] = toupper(dowstr[0]);
X    for (d=0; d<7; d++)
X	if (strcmp(dowstr,shortDayStr[d]) == 0)
X	    break;
X    if (d == 7) {
X	fprintf(stderr,"%s: file \"%s\", line %d: invalid day-of-week: %s\n",
X						program,fname,line,dowstr);
X	return;
X    }
X    if (h2 < 30)
X	pos = (h-8)*2;
X    else
X	pos = (h-8)*2+1;
X    addScheduleDow(pos,d,msg);
X}
X
Xvoid
XwriteAppoints(name)
Xchar *name;
X{
X    FILE *fp;
X    char *fname;
X    Yearrec *yp;
X    Monrec *mp;
X    Dayrec *dp;
X    Msgrec *xp;
X    int h,h2,i,d;
X
X    fname = expandFilename(name);
X    if ((fp=fopen(fname,"w")) == NULL) {
X	perror(fname);
X	return;
X    }
X    for (d=0; d < 7; d++)
X	for (i=0; i < 22; i++)
X	    if (schedule[d][i] != NULL)
X		fprintf(fp,"%3s %2d:%02d %s\n",shortDayStr[d],i/2+8,i%2*30,
X								schedule[d][i]);
X    for (yp = Db; yp != NULL; yp = yp->next)
X	for (mp = yp->mons; mp != NULL; mp = mp->next)
X	    for (dp = mp->days; dp != NULL; dp = dp->next)
X		for (xp = dp->msgs; xp != NULL; xp = xp->next) {
X		    h = 8+(xp->pos / 2);
X		    h2 = (xp->pos % 2)*30;
X		    fprintf(fp,"%2d %3.3s %4d %2d:%02d %s\n",
X						dp->day,shortMonStr[mp->mon],
X								1900+yp->year,
X								h,h2,xp->text);
X		}
X    fclose(fp);
X}
X
Xstatic char filename[1024];
X
Xstatic char *
XexpandFilename(name)
Xchar *name;
X{
X    char *s;
X
X    if (*name == '~') {
X	if ((s=getenv("HOME")) == NULL) {
X	    printf("%s: can't expand ~ to $HOME\n",program);
X	    return;
X	} else {
X	    strcpy(filename,s);
X	    strcat(filename,name+1);
X	}
X    } else {
X	strcpy(filename,name);
X    }
X    return(filename);
X}
END_OF_FILE
if test 9500 -ne `wc -c <'db.c'`; then
    echo shar: \"'db.c'\" unpacked with wrong size!
fi
# end of 'db.c'
fi
if test -f 'month.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'month.c'\"
else
echo shar: Extracting \"'month.c'\" \(5647 characters\)
sed "s/^X//" >'month.c' <<'END_OF_FILE'
X/*
X *	month.c : Widget creation and action binding for the month
X *		  forms, and it's sub-widgets.
X *
X *      George Ferguson (ferguson at cs.rochester.edu), 27 Oct 1990.
X *
X *	$Id: month.c,v 1.1 90/11/07 11:22:57 ferguson Exp $
X */
X#include <X11/Intrinsic.h>
X#include <X11/Shell.h>
X#include <X11/StringDefs.h>
X#include <X11/Xaw/Form.h>
X#include <X11/Xaw/Command.h>
X#include <X11/Xaw/Toggle.h>
X#include <X11/Xaw/Label.h>
X#include <X11/Xaw/AsciiText.h>
X#include <X11/Xaw/Cardinals.h>
X#include "app-resources.h"
X#include "widgets.h"
X#include "month.h"
X#include "day.h"
X#include "db.h"
X#include "date-strings.h"
X
Xextern int numMonths;
X
X/*
X * Functions defined in this file
X */
XMonthFormData *createMonthFormData();
Xvoid setMonthFormData();
Xvoid selectDay();
Xvoid shadeButton();
X
Xstatic void dayButtonCallbackProc();
Xstatic void getGCAndXY();
X
X/*
X * Data defined in this file
X */
Xstatic int dayAppointsChanged;
Xstatic Widget radioGroup;
X
X/*	-	-	-	-	-	-	-	-	*/
X/* returns an unmanaged form */
X
XMonthFormData *
XcreateMonthFormData(parent,name,num)
XWidget parent;
Xchar *name;
Xint num;		/* 1,3,12 */
X{
X    MonthFormData *m;
X    DayButtonData *d;
X    Widget widget;
X    Arg args[3];
X    char text[16];
X    int row,col;
X    int w,h;
X
X    m = XtNew(MonthFormData);
X    m->form = XtCreateWidget(name,formWidgetClass,parent,NULL,ZERO);
X    switch (num) {
X	case 1: w = appResources.dateWidth1;
X		h = appResources.dateHeight1;
X		break;
X	case 3: w = appResources.dateWidth3;
X		h = appResources.dateHeight3;
X		break;
X	case 12: w = appResources.dateWidth12;
X		 h = appResources.dateHeight12;
X		 break;
X    }
X    sprintf(text,"monthLabel%d",num);
X    m->label = XtCreateManagedWidget(text,labelWidgetClass,m->form,NULL,ZERO);
X    if (appResources.dowLabels) {
X	sprintf(text,"dowLabel%d",num);
X	XtSetArg(args[0],XtNfromVert,m->label);
X	XtSetArg(args[1],XtNfromHoriz,NULL);
X	for (col=0; col < 7; col++) {
X	    XtSetArg(args[2],XtNlabel,shortDayStr[col]);
X	    widget = XtCreateManagedWidget(text,labelWidgetClass,m->form,
X								args,THREE);
X	    XtSetArg(args[1],XtNfromHoriz,widget);
X	}
X	XtSetArg(args[0],XtNfromVert,widget);
X    } else {
X	XtSetArg(args[0],XtNfromVert,m->label);
X    }
X    sprintf(text,"dayButton%d",num);
X    for (row=0; row < 6; row++) {
X	XtSetArg(args[1],XtNfromHoriz,NULL);
X	for (col=0; col < 7; col++) {
X	    d = m->days[row*7+col] = XtNew(DayButtonData);
X	    d->button = XtCreateManagedWidget(text,toggleWidgetClass,
X							m->form,args,TWO);
X	    XtAddCallback(d->button,"callback",dayButtonCallbackProc,d);
X	    XtSetArg(args[2],XtNradioData,d->button);
X	    XtSetValues(d->button,args+2,ONE);
X	    if (radioGroup == NULL)
X		radioGroup = d->button;
X	    XawToggleChangeRadioGroup(d->button,radioGroup);
X	    d->pixmap = XCreatePixmap(display,root,w,h,
X						DefaultDepthOfScreen(screen));
X
X	    XtSetArg(args[1],XtNfromHoriz,d->button);
X	}
X        XtSetArg(args[0],XtNfromVert,d->button);
X    }
X    return(m);
X}
X
Xvoid
XsetMonthFormData(m,num,month,year)
XMonthFormData *m;
Xint num,month,year;
X{
X    DayButtonData *d;
X    Arg args[1];
X    GC gc;
X    char text[16];
X    int first,numDays;
X    int i,x,y,n;
X
X    first = firstDOW(month,year);
X    numDays = lastDay(month,year);
X    getGCAndXY(num,&gc,&x,&y);
X    XawFormDoLayout(m->form,False);
X    XawToggleUnsetCurrent(radioGroup);
X    sprintf(text,"%s %d",longMonStr[month],year+1900);
X    XtSetArg(args[0],XtNlabel,text);
X    XtSetValues(m->label,args,ONE);
X    for (i=0; i < 42; i++) {
X	d = m->days[i];
X	if (i < first || i >= first+numDays) {
X	    d->day = 0;
X	    XFillRectangle(display,d->pixmap,emptyGC,0,0,50,50);
X	    XtSetArg(args[0],XtNbitmap,d->pixmap);
X	    XtSetValues(d->button,args,ONE);
X	} else {
X	    d->day = i-first+1;
X	    d->month = month;
X	    d->year = year;
X	    shadeButton(d,gc,x,y);
X	}
X    }
X    XawFormDoLayout(m->form,True);
X    m->month = month;
X    m->year = year;
X}
X
X/* This function is here so it can be outside the loop in setMonthFormData(),
X   but really belongs in shadeButton.					*/
Xstatic void
XgetGCAndXY(num,gcp,xp,yp)
XGC *gcp;
Xint *xp,*yp;
X{
X    int w,h;
X
X    switch (num) {
X	case 1: XParseGeometry(appResources.datePosition1,xp,yp,&w,&h);
X		*gcp = dateGC1;
X		break;
X	case 3: XParseGeometry(appResources.datePosition3,xp,yp,&w,&h);
X		*gcp = dateGC3;
X		break;
X	case 12: XParseGeometry(appResources.datePosition12,xp,yp,&w,&h);
X		 *gcp = dateGC12;
X		 break;
X    }
X}
X
X/* Global so can be called after appointments have changed */
Xvoid
XshadeButton(d,gc,x,y)
XDayButtonData *d;
XGC gc;
Xint x,y;
X{
X    Arg args[1];
X    char text[4];
X    int n;
X
X    if (gc == (GC)NULL)
X	getGCAndXY(numMonths,&gc,&x,&y);
X    n = countAppoints(d->day,d->month,d->year);
X    XFillRectangle(display,d->pixmap,shadeGC[n],0,0,50,50);
X    sprintf(text,"%d",d->day);
X    if (appResources.opaqueDates)
X	XDrawImageString(display,d->pixmap,gc,x,y,text,strlen(text));
X    else
X	XDrawString(display,d->pixmap,gc,x,y,text,strlen(text));
X    XtSetArg(args[0],XtNbitmap,d->pixmap);
X    XtSetValues(d->button,args,ONE);
X}
X
Xvoid
XselectDay(m,day,mon,year)
XMonthFormData *m;
Xint day,mon,year;
X{
X    int first,i;
X
X    first = firstDOW(mon,year);
X    for (i=0; i < 42; i++)
X	if (i == first+day-1) {
X	    XawToggleSetCurrent(radioGroup,m->days[i]->button);
X	    break;
X	}
X}
X
Xstatic void
XdayButtonCallbackProc(w,client_data,call_data)
XWidget w;
Xcaddr_t client_data,call_data;
X{
X    DayButtonData *d = (DayButtonData *)client_data;
X
X    if (d->day == 0)
X	return;
X    if (currentDayFormData == NULL)
X	currentDayFormData = createPopupDayFormData();
X    else
X	checkpointAppoints(currentDayFormData);
X    currentDayFormData->buttonData = d;
X    setDayFormData(currentDayFormData,d->day,d->month,d->year);
X}
END_OF_FILE
if test 5647 -ne `wc -c <'month.c'`; then
    echo shar: \"'month.c'\" unpacked with wrong size!
fi
# end of 'month.c'
fi
if test -f 'resources.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'resources.h'\"
else
echo shar: Extracting \"'resources.h'\" \(9114 characters\)
sed "s/^X//" >'resources.h' <<'END_OF_FILE'
X/*
X *	resources.h: All the resource definitions for xkal.
X *
X *	These are only used in xkal.c, other users should simply
X *	include app-resources.h for access to the resources after
X *	they've been loaded.
X *
X */
X
X/*
X * Non-widget resources obtained from the resource manager
X */
Xstatic XtResource resources[] = {
X    { "appoints", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,appoints), XtRImmediate, "~/.appoints" },
X    { "date", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,date), XtRImmediate, "" },
X    { "numMonths", "Int", XtRInt, sizeof(int),
X      XtOffset(AppResources *,numMonths), XtRImmediate, (XtPointer)1 },
X    { "bothShown", "Boolean", XtRBoolean, sizeof(Boolean),
X      XtOffset(AppResources *,bothShown), XtRImmediate, (XtPointer)True },
X    { "listOnly", "Boolean", XtRBoolean, sizeof(Boolean),
X      XtOffset(AppResources *,listOnly), XtRImmediate, (XtPointer)False },
X    { "silent", "Boolean", XtRBoolean, sizeof(Boolean),
X      XtOffset(AppResources *,silent), XtRImmediate, (XtPointer)False },
X    { "opaqueDates", "Boolean", XtRBoolean, sizeof(Boolean),
X      XtOffset(AppResources *,opaqueDates), XtRImmediate, (XtPointer)False },
X    { "dowLabels", "Boolean", XtRBoolean, sizeof(Boolean),
X      XtOffset(AppResources *,dowLabels), XtRImmediate, (XtPointer)False },
X
X    { "dateFont1", "Font", XtRFont, sizeof(Font),
X      XtOffset(AppResources *,dateFont1), XtRString, "*fixed*bold*" },
X    { "dateFont3", "Font", XtRFont, sizeof(Font),
X      XtOffset(AppResources *,dateFont3), XtRString, "*fixed*bold*" },
X    { "dateFont12", "Font", XtRFont, sizeof(Font),
X      XtOffset(AppResources *,dateFont12), XtRString, "*fixed*bold*" },
X
X    { "datePosition1", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,datePosition1), XtRImmediate, "+10+10" },
X    { "datePosition3", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,datePosition3), XtRImmediate, "+10+10" },
X    { "datePosition12", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,datePosition12), XtRImmediate, "+10+10" },
X
X    { "dateWidth1", "Int", XtRInt, sizeof(int),
X      XtOffset(AppResources *,dateWidth1), XtRImmediate, (XtPointer)50 },
X    { "dateWidth3", "Int", XtRInt, sizeof(int),
X      XtOffset(AppResources *,dateWidth3), XtRImmediate, (XtPointer)18 },
X    { "dateWidth12", "Int", XtRInt, sizeof(int),
X      XtOffset(AppResources *,dateWidth12), XtRImmediate, (XtPointer)10 },
X
X    { "dateHeight1", "Int", XtRInt, sizeof(int),
X      XtOffset(AppResources *,dateHeight1), XtRImmediate, (XtPointer)50 },
X    { "dateHeight3", "Int", XtRInt, sizeof(int),
X      XtOffset(AppResources *,dateHeight3), XtRImmediate, (XtPointer)18 },
X    { "dateHeight12", "Int", XtRInt, sizeof(int),
X      XtOffset(AppResources *,dateHeight12), XtRImmediate, (XtPointer)10 },
X
X    { "noDayShade", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,noDayShade), XtRImmediate, "wide_weave" },
X
X    { "shade1", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,shade[1]), XtRImmediate, "gray3" },
X    { "shade2", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,shade[2]), XtRImmediate, "gray3" },
X    { "shade3", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,shade[3]), XtRImmediate, "light_gray" },
X    { "shade4", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,shade[4]), XtRImmediate, "light_gray" },
X    { "shade5", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,shade[5]), XtRImmediate, "gray" },
X    { "shade6", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,shade[6]), XtRImmediate, "gray" },
X    { "shade7", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,shade[7]), XtRImmediate, "flipped_gray" },
X    { "shade8", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,shade[8]), XtRImmediate, "flipped_gray" },
X    { "shade9", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,shade[9]), XtRImmediate, "flipped_gray" },
X    { "shade10", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,shade[10]), XtRImmediate, "flipped_gray" },
X    { "shade11", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,shade[11]), XtRImmediate, "flipped_gray" },
X    { "shade12", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,shade[12]), XtRImmediate, "flipped_gray" },
X    { "shade13", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,shade[13]), XtRImmediate, "flipped_gray" },
X    { "shade14", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,shade[14]), XtRImmediate, "flipped_gray" },
X    { "shade15", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,shade[15]), XtRImmediate, "flipped_gray" },
X    { "shade16", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,shade[16]), XtRImmediate, "flipped_gray" },
X    { "shade17", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,shade[17]), XtRImmediate, "flipped_gray" },
X    { "shade18", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,shade[18]), XtRImmediate, "flipped_gray" },
X    { "shade19", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,shade[19]), XtRImmediate, "flipped_gray" },
X    { "shade20", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,shade[20]), XtRImmediate, "flipped_gray" },
X    { "shade21", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,shade[21]), XtRImmediate, "flipped_gray" },
X    { "shade22", "String", XtRString, sizeof(String),
X      XtOffset(AppResources *,shade[22]), XtRImmediate, "flipped_gray" },
X
X    { "color1", "Pixel", XtRPixel, sizeof(Pixel),
X      XtOffset(AppResources *,color[1]), XtRString, "Green" },
X    { "color2", "Pixel", XtRPixel, sizeof(Pixel),
X      XtOffset(AppResources *,color[2]), XtRString, "Green" },
X    { "color3", "Pixel", XtRPixel, sizeof(Pixel),
X      XtOffset(AppResources *,color[3]), XtRString, "Blue" },
X    { "color4", "Pixel", XtRPixel, sizeof(Pixel),
X      XtOffset(AppResources *,color[4]), XtRString, "Blue" },
X    { "color5", "Pixel", XtRPixel, sizeof(Pixel),
X      XtOffset(AppResources *,color[5]), XtRString, "Yellow" },
X    { "color6", "Pixel", XtRPixel, sizeof(Pixel),
X      XtOffset(AppResources *,color[6]), XtRString, "Yellow" },
X    { "color7", "Pixel", XtRPixel, sizeof(Pixel),
X      XtOffset(AppResources *,color[7]), XtRString, "Red" },
X    { "color8", "Pixel", XtRPixel, sizeof(Pixel),
X      XtOffset(AppResources *,color[8]), XtRString, "Red" },
X    { "color9", "Pixel", XtRPixel, sizeof(Pixel),
X      XtOffset(AppResources *,color[9]), XtRString, "Red" },
X    { "color10", "Pixel", XtRPixel, sizeof(Pixel),
X      XtOffset(AppResources *,color[10]), XtRString, "Red" },
X    { "color11", "Pixel", XtRPixel, sizeof(Pixel),
X      XtOffset(AppResources *,color[11]), XtRString, "Red" },
X    { "color12", "Pixel", XtRPixel, sizeof(Pixel),
X      XtOffset(AppResources *,color[12]), XtRString, "Red" },
X    { "color13", "Pixel", XtRPixel, sizeof(Pixel),
X      XtOffset(AppResources *,color[13]), XtRString, "Red" },
X    { "color14", "Pixel", XtRPixel, sizeof(Pixel),
X      XtOffset(AppResources *,color[14]), XtRString, "Red" },
X    { "color15", "Pixel", XtRPixel, sizeof(Pixel),
X      XtOffset(AppResources *,color[15]), XtRString, "Red" },
X    { "color16", "Pixel", XtRPixel, sizeof(Pixel),
X      XtOffset(AppResources *,color[16]), XtRString, "Red" },
X    { "color17", "Pixel", XtRPixel, sizeof(Pixel),
X      XtOffset(AppResources *,color[17]), XtRString, "Red" },
X    { "color18", "Pixel", XtRPixel, sizeof(Pixel),
X      XtOffset(AppResources *,color[18]), XtRString, "Red" },
X    { "color19", "Pixel", XtRPixel, sizeof(Pixel),
X      XtOffset(AppResources *,color[19]), XtRString, "Red" },
X    { "color20", "Pixel", XtRPixel, sizeof(Pixel),
X      XtOffset(AppResources *,color[20]), XtRString, "Red" },
X    { "color21", "Pixel", XtRPixel, sizeof(Pixel),
X      XtOffset(AppResources *,color[21]), XtRString, "Red" },
X    { "color22", "Pixel", XtRPixel, sizeof(Pixel),
X      XtOffset(AppResources *,color[22]), XtRString, "Red" },
X
X    { "revision", "Revision", XtRString, sizeof(String),
X      XtOffset(AppResources *,revision), XtRImmediate, "" },
X};
X
X/*
X *	Non-widget resources settable on command line.
X */
Xstatic XrmOptionDescRec options[] = {
X    { "-appoints",	".appoints",	XrmoptionSepArg,	"~/.appoints" },
X    { "-date",		".date",	XrmoptionSepArg,	"" },
X    { "-numMonths",	".numMonths",	XrmoptionSepArg,	"1" },
X    { "-bothShown",	".bothShown",	XrmoptionNoArg,		"True" },
X    { "-nobothShown",	".bothShown",	XrmoptionNoArg,		"False" },
X    { "-listOnly",	".listOnly",	XrmoptionNoArg,		"True" },
X    { "-silent",	".silent",	XrmoptionNoArg,		"True" },
X    { "-opaqueDates",	".opaqueDates",	XrmoptionNoArg,		"True" },
X    { "-noopaqueDates",	".opaqueDates",	XrmoptionNoArg,		"False" },
X    { "-dowLabels",	".dowLabels",	XrmoptionNoArg,		"True" },
X    { "-nodowLabels",	".dowLabels",	XrmoptionNoArg,		"False" },
X};
END_OF_FILE
if test 9114 -ne `wc -c <'resources.h'`; then
    echo shar: \"'resources.h'\" unpacked with wrong size!
fi
# end of 'resources.h'
fi
if test -f 'schedule.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'schedule.c'\"
else
echo shar: Extracting \"'schedule.c'\" \(2630 characters\)
sed "s/^X//" >'schedule.c' <<'END_OF_FILE'
X/*
X *	schedule.c : The schedule editor window
X *
X *	$Id: schedule.c,v 1.1 90/11/07 11:23:13 ferguson Exp $
X */
X#include <X11/Intrinsic.h>
X#include <X11/Shell.h>
X#include <X11/StringDefs.h>
X#include <X11/Xaw/Form.h>
X#include <X11/Xaw/Command.h>
X#include <X11/Xaw/Cardinals.h>
X#include "widgets.h"
X#include "month.h"
X#include "day.h"
X#include "db.h"
X#include "date-strings.h"
X
Xextern int appointsChanged;
X
X/*
X * Functions defined in this file
X */
Xvoid createPopupSchedule();
Xstatic void dismissSchedProc(), applySchedProc();
X
X/*
X * Data defined in this file
X */
Xstatic Widget schedulePopupShell;
Xstatic DayFormData *scheduleDayFormDatas[7];
Xstatic void dismissSchedProc(),applySchedProc();
X
X/*	-	-	-	-	-	-	-	-	*/
X 
Xvoid
XcreatePopupSchedule()
X{
X    Widget form,dismiss,apply,w;
X    Arg args[1];
X    int dow,i;
X    char *s;
X
X    schedulePopupShell = XtCreatePopupShell("schedulePopupShell",
X				topLevelShellWidgetClass,toplevel,NULL,ZERO);
X    form = XtCreateManagedWidget("popupForm",formWidgetClass,schedulePopupShell,
X								NULL,ZERO);
X    dismiss = XtCreateManagedWidget("dismissSchedButton",commandWidgetClass,
X							form,NULL,ZERO);
X    apply = XtCreateManagedWidget("applySchedButton",commandWidgetClass,form,
X								NULL,ZERO);
X    XtAddCallback(dismiss,"callback",dismissSchedProc,NULL);
X    XtAddCallback(apply,"callback",applySchedProc,NULL);
X    w = NULL;
X    for (dow=0; dow < 7; dow++) {
X	scheduleDayFormDatas[dow] = createDayFormData(form);
X	XtSetArg(args[0],XtNfromHoriz,w);
X	XtSetValues(scheduleDayFormDatas[dow]->form,args,ONE);
X	XtSetArg(args[0],XtNlabel,longDayStr[dow]);
X	XtSetValues(scheduleDayFormDatas[dow]->date,args,ONE);
X	w = scheduleDayFormDatas[dow]->form;
X	for (i=0; i < 22; i++)
X	    if ((s=lookupScheduleDow(i,dow)) != NULL) {
X		XtSetArg(args[0],XtNstring,s);
X		XtSetValues(scheduleDayFormDatas[dow]->items[i]->text,args,ONE);
X	    }
X    }
X    XtPopup(schedulePopupShell,XtGrabNone);
X}
X
Xstatic void
XdismissSchedProc(w,client_data,call_data)
XWidget w;
Xcaddr_t client_data,call_data;
X{
X    XtPopdown(schedulePopupShell);
X    XtDestroyWidget(schedulePopupShell);
X}
X
Xstatic void
XapplySchedProc(w,client_data,call_data)
XWidget w;
Xcaddr_t client_data,call_data;
X{
X    Arg args[1];
X    char *new,*old;
X    int dow,i;
X
X    XtSetArg(args[0],XtNstring,&new);
X    for (dow=0; dow < 7; dow++)
X	for (i=0; i < 22; i++) {
X	    XtGetValues(scheduleDayFormDatas[dow]->items[i]->text,args,ONE);
X	    old = lookupScheduleDow(i,dow);
X	    if (new != old) {
X		if (*new == '\0')
X		    deleteScheduleDow(i,dow,new);
X		else
X		    addScheduleDow(i,dow,new);
X		appointsChanged = True;
X	    }
X	}
X    /* refresh display */
X}
END_OF_FILE
if test 2630 -ne `wc -c <'schedule.c'`; then
    echo shar: \"'schedule.c'\" unpacked with wrong size!
fi
# end of 'schedule.c'
fi
echo shar: End of archive 3 \(of 4\).
cp /dev/null ark3isdone
MISSING=""
for I in 1 2 3 4 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 4 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
George Ferguson			ARPA: ferguson at cs.rochester.edu
University of Rochester		UUCP: {decvax,rutgers}!rochester!ferguson
Rochester  NY  14627		VOX:  (716) 275-2527



More information about the Alt.sources mailing list