[comp.sources.misc] v17i093: calentool - day/week/month/year-at-a-glance SunView tool, Part12/23

billr@saab.CNA.TEK.COM (Bill Randle) (04/06/91)

Submitted-by: Bill Randle <billr@saab.CNA.TEK.COM>
Posting-number: Volume 17, Issue 93
Archive-name: calentool/part12

#! /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 12 (of 23)."
# Contents:  dates/literature holidays.c month.cursor notify.c
# Wrapped by billr@saab on Thu Mar 28 08:38:23 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'dates/literature' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dates/literature'\"
else
echo shar: Extracting \"'dates/literature'\" \(7284 characters\)
sed "s/^X//" >'dates/literature' <<'END_OF_FILE'
X# CalenTool V2.2 - nflag=1 range=1,12 - DO NOT REMOVE THIS LINE
X# $Header: literature,v 1.2 91/03/07 16:21:13 billr Exp $
X# Special dates in the history of literature, newspapers and comics.
X# Today in History dates provided by Robert Heckendorn at
X# Hewlett-Packard in Fort Collins, Colorado.
X# Any corrections or additions may be sent to robert@fc.hp.com
X#
X# Additional dates provided from ProLine's today file
X#
X# Converted to calentool format by Larry Virden (lwv27%cas.BITNET@CUNYVM.CUNY.Edu)
X# and further edited and merged by Bill Randle (billr@saab.cna.tek.com).
X#
X** 01 07 99 99 00 "Tarzan", one of the first adventure comic strips appears. (1929)
X** 01 07 99 99 00 Buck Rogers and Tarzan first appear in comic strips (1929)
X** 01 09 99 99 00 First issue of the "Progressive" magazine (1909)
X** 01 10 99 99 00 Thomas Paine publishes "Common Sense" (1776)
X** 01 22 99 99 00 The Alta California becomes a daily paper, 1st such in Calif. (1850)
X** 02 13 99 99 00 "Prince Valiant" comic strip appears; known for historical detail and fine detail drawing. Thanks Hal (1937)
X** 02 13 99 99 00 Blondie and Dagwood get married (1933)
X** 02 16 99 99 00 Ladies Home Journal begins publication. (1883)
X** 02 18 99 99 00 Mark Twain's "Adventures of Huckleberry Finn" is published (1885)
X** 03 02 99 99 00 Time magazine is first published (1923)
X** 03 06 99 99 00 "The Philosophical Transactions of the Royal Society" was 1st published, and is still published today (1665)
X** 03 16 99 99 00 First Black newspaper founded (1827)
X** 04 09 99 99 00 TV Guide publishes their first issue. (1953)
X** 04 10 99 99 00 First issue of the New York Tribune. The publisher was Horace Greeley (1841)
X** 04 14 99 99 00 The first edition of Noah Webster's "American Dictionary of the English Language" was published (1828)
X** 04 16 99 99 00 The Book of the Month Club begins in the US (1926)
X** 04 18 99 99 00 the first crossword puzzle book is published (1924)
X** 04 24 99 99 00 First publication of U.S. newspaper printed on regular basis (1704)
X** 04 27 99 99 00 John Milton sells his rights to "Paradise Lost" for a total of 10 pounds (1667)
X** 05 05 99 99 00 The first issue of Soviet Communist Party paper Pravda was published (1912)
X** 05 09 99 99 00 The first newspaper cartoon appeared in America. (1754)
X** 05 17 99 99 00 the first regular comic, "Comic Cuts", is published in London (1890)
X** 05 29 99 99 00 Popeye rubs the Wiffle Hen becoming practically indestructible (1929)
X** 06 03 99 99 00 "Casey at the Bat" is 1st published (by the SF Examiner) (1888)
X** 06 05 99 99 00 "U.S. Today" (a newspaper) ran for 1st time (1981)
X** 06 06 99 99 00 George Orwell's novel "1984" is published (1949)
X** 06 09 99 99 00 The first dime novel was published -- "Malaeska: The Indian Wife of the White Hunter" (1860)
X** 06 13 99 99 00 "Pentagon Papers" (re: Vietnam); first published in New York Times. (1971)
X** 06 19 99 99 00 Garfield the cat. "Big fat hairy deal". (1978)
X** 06 20 99 99 00 Krazy Kat cartoon strip first appears (1910)
X** 06 29 99 99 00 The London Telegraph is published for the first time (1855)
X** 06 30 99 99 00 "Gone with the Wind" is published (1936)
X** 07 04 99 99 00 Thoreau moves into his shack on Walden Pond. (1845)
X** 07 06 99 99 00 Newton publishes Principia Mathematica (1687)
X** 07 08 99 99 00 Vol 1, No 1, of "The Wall Street Journal" published. (1889)
X** 07 25 99 99 00 Das Kapital by Karl Marx is published (1867)
X** 07 27 99 99 00 Billboard magazine starts publishing best-seller's charts. (1940)
X** 07 30 99 99 00 1st English newspaper published in Hawaii. (1836)
X** 08 07 99 99 00 the Alley Oop cartoon strip first appears (1933)
X** 08 13 99 99 00 Li'l Abner debut (1934)
X** 08 14 99 99 00 Henry David Thoreau jailed for tax resistance. (1846)
X** 08 14 99 99 00 The first book ever published was printed, The Book of Psalms, published by Faust (1457)
X** 08 17 99 99 00 Animal Farm, written by George Orwell, first published (1945)
X** 08 22 99 99 00 Ann Franklin becomes the first woman editor of an American newspaper, "The Mercry" in Newport, R.I. (1762)
X** 08 27 99 99 00 "Tarzan of the Apes" published (1912)
X** 08 30 99 99 00 Mary Shelley, wrote Frankenstein (1797)
X** 09 04 99 99 00 1st daily newspaper in Hawaii published. (1866)
X** 09 04 99 99 00 Barney Flaherty, a ten year old, was hired as the first known paper boy (1833)
X** 09 05 99 99 00 On The Road, by author Jack Kerouac, was first published. (1957)
X** 09 06 99 99 00 Thoreau leaves Walden Pond (1847)
X** 09 19 99 99 00 President George Washington's farewell address was published. (1796)
X** 09 21 99 99 00 1st daily newspaper in US begins publication in Pennsylvania. (1784)
X** 09 21 99 99 00 Eleanor John publishes the first Weekly Reader (1928)
X** 09 25 99 99 00 One of the earliest American newspapers "Publick Occurrences", published its first and last edition in Boston (1690)
X** 09 27 99 99 00 James Franklin, Benjamin's half brother, publishes the first issue of "The Rhode Island Gazette" (1727)
X** 09 28 99 99 00 "Pilgrim's Progress" published (1678)
X** 09 30 99 99 00 Bill the Cat loses control of his sports car on route 66 outside of Bloom County. He was returning from a party at Mary Worth's LA home. (1983)
X** 10 02 99 99 00 First publication of the Peanuts comic strip (1950)
X** 10 04 99 99 00 Dick Tracy, created by Chester Gould, debuts (1931)
X** 10 10 99 99 00 Catch-22 is published (1961)
X** 10 16 99 99 00 Gordo (by Gus Arriola) 1st appeared in newspapers. (1941)
X** 10 16 99 99 00 audience in Boston walks out on Poe during his reading of the "The Raven" (1845)
X** 10 20 99 99 00 The New York Times is first published simultaneously in Paris and New York (1960)
X** 10 26 99 99 00 the "Doonesbury" comic strip debuts in 28 newspapers (1970)
X** 10 27 99 99 00 The 'Federalist' letters started appearing in NY newspapers. (1787)
X** 11 03 99 99 00 Treasure Island, by Robert Louis Stevenson, published (1883)
X** 11 05 99 99 00 Lemuel Gulliver arrives in Lilliput (1699)
X** 11 14 99 99 00 "Moby Dick", by Herman Melville, is published. (1851)
X** 11 15 99 99 00 The cartoon strip Mutt and Jeff first appeared (1907)
X** 11 18 99 99 00 Mark Twain (Samuel Clemens) publishes his first work, "Jim Smiley and His Jumping Frog" (1865)
X** 11 23 99 99 00 The first issue of "Life" magazine is published (1936)
X** 11 26 99 99 00 Alice Liddel receives an early Christmas present of "Alice in Wonderland" from Charles Dodgson (1864)
X** 11 29 99 99 00 The London times is first newspaper published with a steam powered press (1814)
X** 12 09 99 99 00 Noah Webster establishes New York's 1st daily newspaper. (1793)
X** 12 16 99 99 00 "Variety", covering all phases of show business, 1st published. (1905)
X** 12 19 99 99 00 "A Christmas Carol" by Charles Dickens is first published (1843)
X** 12 19 99 99 00 Benjamin Franklin begins publication of "Poor Richard's Almanack" (1732)
X** 12 19 99 99 00 Thomas Paine publishes his first "American Crisis" essay in which he wrote, "These are the times that try men's souls." (1776)
X** 12 21 99 99 00 Phineas Fogg completes trip around world in under 80 days
X** 12 23 99 99 00 "Twas the night before Christmas ..." was first published (1823)
X** 12 23 99 99 00 Tom Paine publishes "Crisis" (1776)
X** 12 25 99 99 00 Dick Tracy marries Tess Truehart (1949)
END_OF_FILE
if test 7284 -ne `wc -c <'dates/literature'`; then
    echo shar: \"'dates/literature'\" unpacked with wrong size!
fi
# end of 'dates/literature'
fi
if test -f 'holidays.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'holidays.c'\"
else
echo shar: Extracting \"'holidays.c'\" \(11221 characters\)
sed "s/^X//" >'holidays.c' <<'END_OF_FILE'
X/*
X * $Header: holidays.c,v 2.4 91/03/27 16:45:41 billr Exp $
X */
X/*
X * holidays.c
X *
X * Author: Bill Randle, Tektronix, Inc. <billr@saab.CNA.TEK.COM>
X *	(based on a test driver by R.P.C. Rodgers)
X *
X * Copyright (C) 1989, Tektronix, Inc.  All Rights Reserved
X *
X * Permission is hereby granted to use and modify this code in source
X * or binary form as long as it is not sold for profit and this copyright
X * notice remains intact.
X */
X/*
X * functions from datelib (by R.P.C. Rodgers)
X */
X#include "ct.h"		/* for the NO_HOLIDAYS #define */
X#ifndef NO_HOLIDAYS
X
X#include <sys/time.h>
X
Xdouble	election_day();			/* Secular US holidays */
X
Xdouble	autumn_equinox(),		/* Astronomical events */
X	summer_solstice(),
X	vernal_equinox(),
X	winter_solstice();
X
Xdouble	ascension_day(),		/* Christian holidays */
X	ash_wednesday(),
X	corpus_christi(),
X	easter(),
X	easter_monday(),
X	easter_offset(),
X	first_sunday_advent(),
X	first_sunday_lent(),
X	fourth_sunday_lent(),
X	good_friday(),
X	maundy_thursday(),
X	palm_sunday(),
X	passion_sunday(),
X	rogation_sunday(),
X	septuagesima(),
X	sexagesima(),
X	quinquagesima(),
X	second_sunday_lent(),
X	shrove_monday(),
X	shrove_tuesday(),
X	third_sunday_lent(),
X	trinity_sunday(),
X	whitsunday();
X
Xdouble	islamic_new_year(),		/* Islamic holidays */
X	muharram_9(),
X	muharram_10(),
X	muharram_16(),
X	eid_i_milad_un_nabi(),
X	jumada_al_akhir_23(),
X	shab_e_miraj(),
X	shab_e_barat(),
X	shab_e_qadr(),
X	ramadan(),
X	eid_al_fitr(),
X	dhul_hijja_9(),
X	eid_al_adha(),
X	ghadir();
X
Xdouble	chanukah(),			/* Jewish holidays */
X	passover(),
X	passover_offset(),
X	purim(),
X	rosh_hashanah(),
X	shavuot(),
X	simchat_torah(),
X	sukkot(),
X	yom_kippur();
X
Xextern struct tm current;	/* current day displayed from calentool */
X#define NUM_ADATES	4
X#define NUM_CDATES	22
X#define NUM_IDATES	28
X#define NUM_JDATES	8
X#define NUM_SDATES	1
X
Xint	marked_note;
Xint	gsave_year = -1;  /* indicates datelib initialized */
Xstruct appt_entry a_appts[NUM_ADATES], c_appts[NUM_CDATES];
Xstruct appt_entry i_appts[NUM_IDATES], j_appts[NUM_JDATES];
Xstruct appt_entry s_appts[NUM_SDATES];
X
Xint
Xa_dates(flag)
Xint flag;
X{
X	static int save_year = -1;
X
X	/*
X	 * Astromonical Events
X	 */
X	if (!flag || current.tm_year == save_year)
X		return(NUM_ADATES);
X	marked_note = flag - 1;
X	if (current.tm_year != gsave_year) {
X		datelib_init(current.tm_year+1900);
X		gsave_year = current.tm_year;
X	}
X	save_year = current.tm_year;
X	get_date(&a_appts[0], "Vernal Equinox", vernal_equinox, TRUE);
X	get_date(&a_appts[1], "Summer Solstice", summer_solstice, TRUE);
X	get_date(&a_appts[2], "Autumn Equinox", autumn_equinox, TRUE);
X	get_date(&a_appts[3], "Winter Solstice", winter_solstice, TRUE);
X	return(NUM_ADATES);
X}
X
Xint
Xc_dates(flag)
Xint flag;
X{
X	static int save_year = -1;
X
X	/*
X	 * Christian holidays
X	 */
X	if (!flag || current.tm_year == save_year)
X		return(NUM_CDATES);
X	marked_note = flag - 1;
X	if (current.tm_year != gsave_year) {
X		datelib_init(current.tm_year+1900);
X		gsave_year = current.tm_year;
X	}
X	save_year = current.tm_year;
X	get_date(&c_appts[0], "Septuagesima Sunday", septuagesima, FALSE);
X	get_date(&c_appts[1], "Sexagesima Sunday", sexagesima, FALSE);
X	get_date(&c_appts[2], "Quinquagesima Sunday", quinquagesima, FALSE);
X	get_date(&c_appts[3], "Shrove Monday", shrove_monday, FALSE);
X	get_date(&c_appts[4], "Shrove Tuesday (Mardi Gras)", shrove_tuesday, FALSE);
X	get_date(&c_appts[5], "Ash Wednesday", ash_wednesday, FALSE);
X	get_date(&c_appts[6], "First Sunday in Lent", first_sunday_lent, FALSE);
X	get_date(&c_appts[7], "Second Sunday in Lent", second_sunday_lent, FALSE);
X	get_date(&c_appts[8], "Third Sunday in Lent", third_sunday_lent, FALSE);
X	get_date(&c_appts[9], "Fourth Sunday in Lent", fourth_sunday_lent, FALSE);
X	get_date(&c_appts[10], "Passion Sunday", passion_sunday, FALSE);
X	get_date(&c_appts[11], "Palm Sunday", palm_sunday, FALSE);
X	get_date(&c_appts[12], "Maundy Thursday", maundy_thursday, FALSE);
X	get_date(&c_appts[13], "Good Friday", good_friday, FALSE);
X	get_date(&c_appts[14], "Easter", easter, FALSE);
X	get_date(&c_appts[15], "Easter Monday (Canada)", easter_monday, FALSE);
X	get_date(&c_appts[16], "Rogation Sunday", rogation_sunday, FALSE);
X	get_date(&c_appts[17], "Ascension Day", ascension_day, FALSE);
X	get_date(&c_appts[18], "Whitsunday", whitsunday, FALSE);
X	get_date(&c_appts[19], "Trinity Sunday", trinity_sunday, FALSE);
X	get_date(&c_appts[20], "Corpus Christi", corpus_christi, FALSE);
X	get_date(&c_appts[21], "First Sunday in Advent", first_sunday_advent, FALSE);
X	return(NUM_CDATES);
X}
X
Xint
Xi_dates(flag)
Xint flag;
X{
X	int ndates;
X	static int save_year = -1, i = 0;
X	int get_idate();
X
X	/*
X	 * Islamic holidays
X	 */
X	if (!flag || current.tm_year == save_year)
X		return(i);
X	marked_note = flag - 1;
X	if (current.tm_year != gsave_year) {
X		datelib_init(current.tm_year+1900);
X		gsave_year = current.tm_year;
X	}
X	save_year = current.tm_year;
X	i = 0;
X	if (get_idate(&i_appts[i++],
X	    "Muharram 1, %d A.H.: Islamic New Year", islamic_new_year, 1) == 2)
X		get_idate(&i_appts[i++],
X		    "Muharram 1, %d A.H.: Islamic New Year", islamic_new_year, 2);
X	if (get_idate(&i_appts[i++],
X	    "Muharram 9, %d A.H.: Day of fasting", muharram_9, 1) == 2)
X		get_idate(&i_appts[i++],
X		    "Muharram 9, %d A.H.: Day of fasting", muharram_9, 2);
X	if (get_idate(&i_appts[i++],
X	    "Muharram 10, %d A.H.: Deliverance of Moses from the Pharoah (for Shia Islam, martyrdom of Husain)",
X	    muharram_10, 1) == 2)
X		get_idate(&i_appts[i++],
X		    "Muharram 10, %d A.H.: Deliverance of Moses from the Pharoah (for Shia Islam, martyrdom of Husain)",
X		    muharram_10, 2);
X	if (get_idate(&i_appts[i++],
X	    "Muharram 16, %d A.H. (Imamat Day; Ismaili Khoja)", muharram_16, 1) == 2)
X		get_idate(&i_appts[i++],
X		    "Muharram 16, %d A.H. (Imamat Day; Ismaili Khoja)", muharram_16, 2);
X	if (get_idate(&i_appts[i++],
X	    "Rabi I 12, %d A.H. (Eid-i-Milad-un-Nabi: The Prophet's Birthday)",
X	    eid_i_milad_un_nabi, 1) == 2)
X		get_idate(&i_appts[i++],
X		    "Rabi I 12, %d A.H. (Eid-i-Milad-un-Nabi: The Prophet's Birthday)",
X		    eid_i_milad_un_nabi, 2);
X	if (get_idate(&i_appts[i++],
X	    "Jumada al-Akhir 23, %d A.H. (Birth of Agha Khan IV, Ismaili)",
X	    jumada_al_akhir_23, 1) == 2)
X		get_idate(&i_appts[i++],
X		    "Jumada al-Akhir 23, %d A.H. (Birth of Agha Khan IV, Ismaili)",
X		    jumada_al_akhir_23, 2);
X	if (get_idate(&i_appts[i++],
X	    "Rajab 27, %d A.H. (Shab-e-Mi'raj: The Prophet's Ascension)",
X	    shab_e_miraj, 1) == 2)
X		get_idate(&i_appts[i++],
X		    "Rajab 27, %d A.H. (Shab-e-Mi'raj: The Prophet's Ascension)",
X		    shab_e_miraj, 2);
X	if (get_idate(&i_appts[i++],
X	    "Shaban 15, %d A.H. (Shab-e-Bara't: Night, followed by day of fasting)",
X	    shab_e_barat, 1) == 2)
X		get_idate(&i_appts[i++],
X		    "Shaban 15, %d A.H. (Shab-e-Bara't: Night, followed by day of fasting)",
X		    shab_e_barat, 2);
X	if (get_idate(&i_appts[i++],
X	    "Ramadan 1, %d A.H. (Fasting month begins)", ramadan, 1) == 2)
X		get_idate(&i_appts[i++],
X		    "Ramadan 1, %d A.H. (Fasting month begins)", ramadan, 2);
X	if (get_idate(&i_appts[i++],
X	    "Ramadan 27, %d A.H. (Shab-e-Qadr: Night vigil)", shab_e_qadr, 1) == 2)
X		get_idate(&i_appts[i++],
X		    "Ramadan 27, %d A.H. (Shab-e-Qadr: Night vigil)", shab_e_qadr, 2);
X	if (get_idate(&i_appts[i++],
X	    "Shawwal 1, %d A.H. (Eid-al-Fitr: Day of Feast)", eid_al_fitr, 1) == 2)
X		get_idate(&i_appts[i++],
X		    "Shawwal 1, %d A.H. (Eid-al-Fitr: Day of Feast)", eid_al_fitr, 2);
X	if (get_idate(&i_appts[i++],
X	    "Dhul-Hijj 9, %d A.H. (Day of Pilgrimage at Arafat, Mecca)",
X	    dhul_hijja_9, 1) == 2)
X		get_idate(&i_appts[i++],
X		    "Dhul-Hijj 9, %d A.H. (Day of Pilgrimage at Arafat, Mecca)",
X		    dhul_hijja_9, 2);
X	if (get_idate(&i_appts[i++],
X	    "Dhul-Hijj 10, %d A.H. (Eid-al-Azha: Day of Abraham's Sacrifice)",
X	    eid_al_adha, 1) == 2)
X		get_idate(&i_appts[i++],
X		    "Dhul-Hijj 10, %d A.H. (Eid-al-Azha: Day of Abraham's Sacrifice)",
X		    eid_al_adha, 2);
X	if (get_idate(&i_appts[i++],
X	    "Dhul-Hijj 18, %d A.H. (Ghadir: Ali's Nomination)", ghadir, 1) == 2)
X		get_idate(&i_appts[i++],
X		    "Dhul-Hijj 18, %d A.H. (Ghadir: Ali's Nomination)", ghadir, 2);
X	return(i);
X}
X
Xint
Xj_dates(flag)
Xint flag;
X{
X	char buf[24];
X	int jyear;
X	static int save_year = -1;
X
X	/*
X	 * Jewish holidays
X	 */
X	if (!flag || current.tm_year == save_year)
X		return(NUM_JDATES);
X	marked_note = flag - 1;
X	if (current.tm_year != gsave_year) {
X		datelib_init(current.tm_year+1900);
X		gsave_year = current.tm_year;
X	}
X	save_year = current.tm_year;
X	get_jdate(&j_appts[0], "Purim", purim);
X	get_jdate(&j_appts[1], "First day of Passover (8 days)", passover);
X	get_jdate(&j_appts[2], "Shavuot (2 days)", shavuot);
X	get_jdate(&j_appts[3], "Rosh Hashanah (Jewish New Year) (2 days)", rosh_hashanah);
X	get_jdate(&j_appts[4], "Yom Kippur", yom_kippur);
X	get_jdate(&j_appts[5], "First day of Sukkot (9 days)", sukkot);
X	get_jdate(&j_appts[6], "Simchat Torah", simchat_torah);
X	get_jdate(&j_appts[7], "First day of Chanukah (8 days)", chanukah);
X	return(NUM_JDATES);
X}
X
Xint
Xs_dates(flag)
Xint flag;
X{
X	static int save_year = -1;
X
X	/*
X	 * SECULAR US HOLIDAYS
X	 * [Holidays specified as a given date (e.g. July 4) or as
X	 *  a known nth mday of a month (e.g. 2nd Monday) are not
X	 *  calculated here.  They are available from one of the
X	 *  auxillary date files.]
X	 */
X	if (!flag || current.tm_year == save_year)
X		return(NUM_SDATES);
X	marked_note = flag - 1;
X	if (current.tm_year != gsave_year) {
X		datelib_init(current.tm_year+1900);
X		gsave_year = current.tm_year;
X	}
X	save_year = current.tm_year;
X	get_date(&s_appts[0], "Election Day", election_day, FALSE);
X	return(NUM_SDATES);
X}
X
X/*
X * check for gregorian (i.e. US secular & Christian) holidays
X */
Xget_date(aptr, str, func, timeflag)
Xstruct appt_entry *aptr;
Xchar *str;
Xdouble (*func)();
Xint timeflag;
X{
X	double	hday;
X	char 	*julian_time();
X
X	hday = (*func)(current.tm_year+1900);
X	fill_holiday(aptr, hday);
X	strcpy(aptr->str, str);
X	if (timeflag) {
X		strcat(aptr->str, julian_time(hday));
X		strcat(aptr->str, " GMT");
X	}
X}
X
X/*
X * check for Islamic holidays
X */
Xint
Xget_idate(aptr, str, func, which)
Xstruct appt_entry *aptr;
Xchar *str;
Xint (*func)();
Xint which;
X{
X	double	date1, date2;
X	int	nr_dates, year1, year2;
X
X	(void)(*func)(current.tm_year+1900, &nr_dates, &date1, &date2, &year1, &year2);
X	if (which == 1) {
X		fill_holiday(aptr, date1);
X		sprintf(aptr->str, str, year1);
X	} else if (which == 2 && nr_dates == 2) {
X		fill_holiday(aptr, date2);
X		sprintf(aptr->str, str, year2);
X	}
X	return (nr_dates);
X}
X
X/*
X * check for Jewish holidays
X */
Xget_jdate(aptr, str, func)
Xstruct appt_entry *aptr;
Xchar *str;
Xdouble (*func)();
X{
X	int	jyear;
X	double	hday;
X	char	buf[32];
X
X	hday = (*func)(current.tm_year+1900, &jyear);
X	fill_holiday(aptr, hday);
X	strcpy(aptr->str, str);
X	sprintf(buf, " [Jewish year %d]", jyear);
X	strcat(aptr->str, buf);
X}
X
Xfill_holiday(aptr, hday)
Xstruct appt_entry *aptr;
Xdouble hday;
X{
X	int	month, year;
X	double	day;
X
X	gregorian_date(&day, &month, &year, hday);
X	aptr->year = current.tm_year;
X	aptr->month = month - 1;
X	aptr->day = (int)day;
X	aptr->arrows = aptr->repeat = aptr->lookahead = 0;
X	aptr->runlength = 0;
X	aptr->warn = 10;
X	aptr->flags = (A_NOTE | READONLY);
X	if (marked_note)
X		aptr->flags |= MARKED;
X}
X#endif	/* NO_HOLIDAYS */
END_OF_FILE
if test 11221 -ne `wc -c <'holidays.c'`; then
    echo shar: \"'holidays.c'\" unpacked with wrong size!
fi
# end of 'holidays.c'
fi
if test -f 'month.cursor' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'month.cursor'\"
else
echo shar: Extracting \"'month.cursor'\" \(285 characters\)
sed "s/^X//" >'month.cursor' <<'END_OF_FILE'
X/* $Header: month.cursor,v 2.1 89/05/09 14:31:06 billr Exp $ */
X/* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
X */
X        0x3FFC, 0x6006, 0xE007, 0x97E9, 0x8811, 0x9429, 0x9249, 0x9189,
X        0x9189, 0x9249, 0x9429, 0x8811, 0x97E9, 0xE007, 0x6006, 0x3FFC
END_OF_FILE
if test 285 -ne `wc -c <'month.cursor'`; then
    echo shar: \"'month.cursor'\" unpacked with wrong size!
fi
# end of 'month.cursor'
fi
if test -f 'notify.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'notify.c'\"
else
echo shar: Extracting \"'notify.c'\" \(32214 characters\)
sed "s/^X//" >'notify.c' <<'END_OF_FILE'
X/*
X * $Header: notify.c,v 2.4 91/03/27 16:46:01 billr Exp $
X */
X/*
X * notify.c
X *
X * Author: Philip Heller, Sun Microsystems. Inc. <terrapin!heller@sun.com>
X *
X * Original source Copyright (C) 1987, Sun Microsystems, Inc.
X *	All Rights Reserved
X * Permission is hereby granted to use and modify this program in source
X * or binary form as long as it is not sold for profit and this copyright
X * notice remains intact.
X *
X *
X * Changes/additions by: Bill Randle, Tektronix, Inc. <billr@saab.CNA.TEK.COM>
X *
X * Changes and additions Copyright (C) 1988, 1989, 1991 Tektronix, Inc.
X *	All Rights Reserved
X * Permission is hereby granted to use and modify the modifications in source
X * or binary form as long as they are not sold for profit and this copyright
X * notice remains intact.
X */
X/**********************************************************
X *							  *
X *	 These are the notify routines which are invoked  *
X * by events in the control panel subwindow,and the	  *
X * various popup window panels.				  *
X *							  *
X **********************************************************/
X
X
X
X#include <stdio.h>
X#include <suntool/sunview.h>
X#include <suntool/canvas.h>
X#include <suntool/panel.h>
X#include <suntool/menu.h>
X#include "ct.h"
X
Xextern int monday_first;
Xextern int mainsw_state, nr_weekdays, day_is_open;
Xextern int dayslot_width, nr_weekdays;
Xextern struct tm today, current;
Xextern Cursor month_cursor, week_cursor, day_cursor, year_cursor;
Xextern Pixfont *font;
Xextern Frame frame;
Xextern Panel panel;
Xextern Canvas canvas;
Xextern Pixwin *main_pixwin;
Xextern Menu next_menu, previous_menu, year_menu, month_menu;
Xextern Menu day_menu, week_menu, current_menu;
Xextern Menu done_menu;
Xextern Frame fframe;
Xextern Panel_item repeat_pi, remind_pi, daysel_pi;
Xextern Panel_item everyx_pi, whichwk_pi, marked_pi;
Xextern Panel_item del_choice_pi, setdate_pi;
Xextern Panel_item runl_pi, advw_pi;
X#ifndef NO_SUN_MOON
Xextern Frame mframe, sframe;
Xextern Panel_item moonbutton_pi, sunbutton_pi;
X#endif
Xextern Frame fileframe;
Xextern Panel_item filename_pi, file_ro_pi;
X#ifndef NO_PRINTER
Xextern Panel_item prcmd_pi, prfile_pi;
Xextern int print_to_file;
Xextern Frame prframe;
Xextern Menu print_menu;
X#endif
Xextern Frame prompt_frame, date_frame;
Xextern struct appt_entry future[];
Xextern struct dayslot *slots;
Xextern int attr_bi;  /* index into currently active day slot */
Xextern int new_entry;
Xextern struct tm olddate;
Xextern int otherfile, read_only;
Xextern char *othername, apts_pathname[], orig_apts_pathname[];
Xextern int orig_ro;
Xextern char printer[];
Xextern int show_future;
Xextern int show_time;
Xextern int update_interval;
Xextern struct appt_entry shelf_appt;
Xextern int day_first;
Xextern void close_frame();
Xextern Notify_value leave();
X
Xint i;
X
X
Xvoid
Xdonebutton_notify(item, event)
XPanel_item item;
XEvent *event;
X{
X	if (event_id(event) == MS_LEFT) {
X		/* close to icon */
X		close_frame();
X	} else
X		panel_default_handle_event(item, event);
X}
X
Xvoid
Xdone_menu_event(item, event)
XPanel_item item;
XEvent *event;
X{
X	int value;
X
X	if (event_id(event) == MS_RIGHT && event_is_down(event)) {
X		value = (int) menu_show(done_menu, panel, event, 0);
X		if (value == 1)
X			/* close frame */
X			close_frame();
X		else if (value == 2)
X			/* quit tool */
X			(void)leave((Notify_client)0, 0, (Notify_signal_mode)0);
X	} else
X		panel_default_handle_event(item, event);
X}
X
Xvoid
Xweekbutton_notify(item, event)
XPanel_item item;
XEvent *event;
X{
X	if (event_id(event) == MS_LEFT) {
X		switch (mainsw_state) {
X			case DISPLAYING_DAY:
X				close_day();
X				break;
X			case DISPLAYING_WEEK:
X				return;
X			case DISPLAYING_MONTH:
X				/* first week in month */
X				current.tm_mday = 1;
X				first_wkday();
X				break;
X			case DISPLAYING_YEAR:
X				/* first week in year */
X				current.tm_mday = 1;
X				current.tm_mon = JAN;
X				first_wkday();
X				break;
X		}
X		mainsw_state = DISPLAYING_WEEK;
X		draw_week();
X		window_set(canvas, WIN_CURSOR, week_cursor, 0);
X	} else
X		panel_default_handle_event(item, event);
X}
X
X
Xvoid
Xweek_menu_event(item, event)
XPanel_item item;
XEvent *event;
X{
X	int value, i;
X	Menu_item an_item;
X
X	if (event_id(event) == MS_RIGHT && event_is_down(event)) {
X		if (mainsw_state > DISPLAYING_MONTH) {
X			/* make all entries inactive */
X			for (i=1; i<=6; i++) {
X				an_item = menu_get(week_menu, MENU_NTH_ITEM, i);
X				menu_set(an_item, MENU_INACTIVE, TRUE, 0);
X			}
X		} else {
X			/* make all entries active */
X			for (i=1; i<=6; i++) {
X				an_item = menu_get(week_menu, MENU_NTH_ITEM, i);
X				menu_set(an_item, MENU_INACTIVE, FALSE, 0);
X			}
X		}
X		value = (int) menu_show(week_menu, panel, event, 0);
X		if (value > 0) {
X			current.tm_mday = (value - 1) * 7 + 1;
X			if (current.tm_mday > monthlength(current.tm_mon))
X				current.tm_mday = monthlength(current.tm_mon);
X			if (mainsw_state == DISPLAYING_DAY)
X				close_day();
X			if (mainsw_state != DISPLAYING_WEEK) {
X				mainsw_state = DISPLAYING_WEEK;
X				window_set(canvas, WIN_CURSOR, week_cursor, 0);
X			}
X			draw_week();
X		}
X	} else
X		panel_default_handle_event(item, event);
X}
X
Xlastmonth()
X{
X
X	current.tm_mon -= 1;
X	current.tm_mday = 1;
X	draw_month();
X}
X
X 
Xnextmonth()
X{ 
X	current.tm_mon += 1;
X	current.tm_mday = 1;
X        draw_month();
X} 
X 
X
Xvoid
Xmonthmenu_notify(item, event)  
XPanel_item item;  
XEvent *event;
X{  
X	int i, j, new_day;
X
X	if (event_id(event) == MS_LEFT) {
X		if (mainsw_state == DISPLAYING_YEAR)
X			/* go to first month of year */
X			current.tm_mon = JAN;
X		current.tm_mday = 1;
X		if (mainsw_state == DISPLAYING_DAY)
X			close_day();
X		if (mainsw_state != DISPLAYING_MONTH) {
X			mainsw_state = DISPLAYING_MONTH;
X			window_set(canvas, WIN_CURSOR, month_cursor, 0);
X		}
X		draw_month();
X	} else
X		panel_default_handle_event(item, event);
X}
X
Xvoid
Xmonth_menu_event(item, event)
XPanel_item item;
XEvent *event;
X{
X	int value;
X
X	if (event_id(event) == MS_RIGHT && event_is_down(event)) {
X		value = (int) menu_show(month_menu, panel, event, 0);
X		if (value > 0) {
X			current.tm_mday = 1;
X			current.tm_mon = value - 1;
X			if (mainsw_state == DISPLAYING_DAY)
X				close_day();
X			if (mainsw_state != DISPLAYING_MONTH) {
X				mainsw_state = DISPLAYING_MONTH;
X				window_set(canvas, WIN_CURSOR, month_cursor, 0);
X			}
X			draw_month();
X		}
X	} else
X		panel_default_handle_event(item, event);
X}
X
X
Xlastyear()
X{
X	current.tm_mday = 1;
X	current.tm_mon = JAN;
X	current.tm_year -= 1;
X	draw_year();
X}
X
Xnextyear()
X{
X	current.tm_mday = 1;
X	current.tm_mon = JAN;
X	current.tm_year += 1;
X	draw_year();
X}
X
Xvoid
Xyearmenu_notify(item, event)
XPanel_item item;
XEvent *event;
X{
X	int old_state;
X
X	if (event_id(event) == MS_LEFT) {
X		if (mainsw_state == DISPLAYING_DAY) 
X			close_day(); 
X		old_state = mainsw_state;
X		mainsw_state = DISPLAYING_YEAR; 
X		draw_year(); 
X		if (old_state != DISPLAYING_YEAR)
X			window_set(canvas, WIN_CURSOR, year_cursor, 0);
X	} else
X		panel_default_handle_event(item, event);
X} 
X
Xvoid
Xyear_menu_event(item, event)
XPanel_item item;
XEvent *event;
X{
X	int value, old_state;
X
X	if (event_id(event) == MS_RIGHT && event_is_down(event)) {
X		value = (int) menu_show(year_menu, panel, event, 0);
X		if (value > 0) {
X			current.tm_year = START_YEAR + value - 1;
X			if (mainsw_state == DISPLAYING_DAY) 
X				close_day(); 
X			old_state = mainsw_state;
X			mainsw_state = DISPLAYING_YEAR; 
X			draw_year(); 
X			if (old_state != DISPLAYING_YEAR)
X				window_set(canvas, WIN_CURSOR, year_cursor, 0);
X		}
X	} else
X		panel_default_handle_event(item, event);
X}
X
X
Xlastweek()
X{
X	if (mainsw_state == DISPLAYING_DAY) {
X		close_day();
X		current.tm_mday -= 7;
X		draw_day();
X	} else if (mainsw_state == DISPLAYING_WEEK) {
X		current.tm_mday -= 7;
X		draw_week();
X	}
X}
X
X
Xnextweek()
X{
X        if (mainsw_state == DISPLAYING_DAY) {
X                close_day();
X		current.tm_mday += 7;
X                draw_day();
X        } else if (mainsw_state == DISPLAYING_WEEK) {
X		current.tm_mday += 7;
X                draw_week();
X	}
X}
X
X
X
Xyesterday()
X{
X	if (mainsw_state != DISPLAYING_DAY)
X		return(0);
X	close_day();
X	current.tm_mday--;
X	draw_day();
X	return(1);
X}
X
X
Xvoid
Xtodaybutton_notify(item, event)
XPanel_item item;
XEvent *event;
X{
X	if (event_id(event) == MS_LEFT) {
X		if (mainsw_state == DISPLAYING_DAY)
X			close_day();
X		else {
X			mainsw_state = DISPLAYING_DAY;
X			window_set(canvas, WIN_CURSOR, day_cursor, 0);
X		}
X		get_today();
X		current = today;
X		draw_day();
X	} else
X		panel_default_handle_event(item, event);
X}
X
X
X
Xtomorrow()
X{ 
X        if (mainsw_state != DISPLAYING_DAY)
X                return(0);
X        close_day(); 
X	current.tm_mday++;
X        draw_day(); 
X	return(1);
X} 
X 
X
Xvoid
Xcurrentbutton_notify(item, event)
XPanel_item item;
XEvent *event;
X{
X	if (event_id(event) == MS_LEFT) {
X		if (mainsw_state == DISPLAYING_DAY)
X			close_day();
X		get_today();
X		current = today;
X		switch (mainsw_state) {
X			case DISPLAYING_DAY:
X				draw_day();
X				break;
X			case DISPLAYING_WEEK:
X				draw_week();
X				break;
X			case DISPLAYING_MONTH:
X				draw_month();
X				break;
X			case DISPLAYING_YEAR:
X				draw_year();
X				break;
X		}
X	} else
X		panel_default_handle_event(item, event);
X}
X
Xvoid
Xcurrent_menu_event(item, event)
XPanel_item item;
XEvent *event;
X{
X	Menu_item an_item;
X	char date[9];
X	int value, rtn;
X	struct tm Save;
X
X	if (event_id(event) == MS_RIGHT && event_is_down(event)) {
X		value = (int) menu_show(current_menu, panel, event, 0);
X		if (value == 0)
X			return;	/* no selection made */
X		if (mainsw_state == DISPLAYING_DAY)
X			close_day();
X		get_today();
X		Save = current;
X		current = today;
X		switch (value) {
X			case 1:	/* current day */
X				mainsw_state = DISPLAYING_DAY;
X				window_set(canvas, WIN_CURSOR, day_cursor, 0);
X				draw_day();
X				break;
X
X			case 2:	/* current week */
X				mainsw_state = DISPLAYING_WEEK;
X				window_set(canvas, WIN_CURSOR, week_cursor, 0);
X				draw_week();
X				break;
X
X			case 3:	/* current month */
X				mainsw_state = DISPLAYING_MONTH;
X				window_set(canvas, WIN_CURSOR, month_cursor, 0);
X				draw_month();
X				break;
X
X			case 4:	/* current year */
X				mainsw_state = DISPLAYING_YEAR;
X				window_set(canvas, WIN_CURSOR, year_cursor, 0);
X				draw_year();
X				break;
X
X			case 5:	/* change date */
X				if (day_first)
X					sprintf(date, "%d/%d/%02d", Save.tm_mday, Save.tm_mon+1, Save.tm_year);
X				else
X					sprintf(date, "%d/%d/%02d", Save.tm_mon+1, Save.tm_mday, Save.tm_year);
X				panel_set_value(setdate_pi, date);
X				do {
X					window_loop(date_frame);
X					/* change "current" date to reflect entry */
X					rtn = parse_date((char *)panel_get_value(setdate_pi), FALSE);
X				} while (rtn);
X				mainsw_state = DISPLAYING_DAY;
X				window_set(canvas, WIN_CURSOR, day_cursor, 0);
X				draw_day();
X				break;
X		}
X	} else
X		panel_default_handle_event(item, event);
X}
X
X/*
X * notifier for set date frame "Done" button
X */
Xvoid
Xdtdone_proc(item, event)
XPanel_item item;
XEvent *event;
X{
X	if (event_id(event) == MS_LEFT)
X		window_return(0);
X}
X
X/* "done" from subframe menu of change date frame */
Xvoid
Xdtframe_done(frame)
XFrame frame;
X{
X	window_set(date_frame, WIN_SHOW, FALSE, 0);
X}
X
Xvoid
Xdaybutton_notify(item, event)
XPanel_item item;
XEvent *event;
X{
X	if (event_id(event) == MS_LEFT) {
X		switch (mainsw_state) {
X			case DISPLAYING_DAY:
X				/* no change */
X				return;
X			case DISPLAYING_WEEK:
X				/* pick first day in week */
X				while (current.tm_wday != SUN) {
X					current.tm_mday--;
X					current.tm_wday--;
X				}
X				if (nr_weekdays < 7)
X					/* start with MON */
X					current.tm_mday++;
X				break;
X			case DISPLAYING_MONTH:
X				/* pick first day in month */
X				current.tm_mday = 1;
X				first_wkday();
X				break;
X			case DISPLAYING_YEAR:
X				/* pick first day in year */
X				current.tm_mon = JAN;
X				current.tm_mday = 1;
X				first_wkday();
X				break;
X		}
X		mainsw_state = DISPLAYING_DAY;
X		draw_day();
X		window_set(canvas, WIN_CURSOR, day_cursor, 0);
X	} else
X		panel_default_handle_event(item, event);
X}
X
Xvoid
Xday_menu_event(item, event)
XPanel_item item;
XEvent *event;
X{
X	int value, i;
X	Menu_item an_item;
X
X	if (event_id(event) == MS_RIGHT && event_is_down(event)) {
X		if (mainsw_state > DISPLAYING_WEEK) {
X			/* make all entries inactive */
X			for (i=1; i<=7; i++) {
X				an_item = menu_get(day_menu, MENU_NTH_ITEM, i);
X				menu_set(an_item, MENU_INACTIVE, TRUE, 0);
X			}
X		} else {
X			/* make all entries active */
X			for (i=1; i<=7; i++) {
X				an_item = menu_get(day_menu, MENU_NTH_ITEM, i);
X				menu_set(an_item, MENU_INACTIVE, FALSE, 0);
X			}
X		}
X		value = (int) menu_show(day_menu, panel, event, 0);
X		if (value > 0) {
X			/* find selected day in this week */
X			if (monday_first) {
X			    ++value;
X			    if (value == 7) value = 0;
X			}
X			if (--value > current.tm_wday)
X				current.tm_mday += value - current.tm_wday;
X			else
X				current.tm_mday -= current.tm_wday - value;
X			mainsw_state = DISPLAYING_DAY;
X			draw_day();
X			window_set(canvas, WIN_CURSOR, day_cursor, 0);
X		}
X	} else
X		panel_default_handle_event(item, event);
X}
X
Xfirst_wkday()
X{
X	/*
X	 * Set day to first displayable day of the week selected.
X	 * If we have a 7-day week display, then it will always
X	 * be the first day of the month. If we have a 5 or 6 day
X	 * display, the first day may need to be adjusted to the
X	 * following monday.
X	 */
X	if (nr_weekdays == 7)
X		/* it's ok as is */
X		return;
X	fix_current_day();	/* update wkday, etc. */
X	if (current.tm_wday == SUN)
X		current.tm_mday++;
X	else if (current.tm_wday > nr_weekdays)
X		current.tm_mday += 7 - current.tm_wday + 1;
X}
X
Xvoid
Xnext_menu_event(item, event)
XPanel_item item;
XEvent *event;
X{
X	Menu_item an_item;
X	int value;
X
X	if (event_id(event) == MS_RIGHT && event_is_down(event)) {
X		i = 0;
X		while (++i < mainsw_state) {
X			an_item = menu_get(next_menu, MENU_NTH_ITEM, i);
X			menu_set(an_item, MENU_INACTIVE, TRUE, 0);
X		}
X		for (i=mainsw_state; i<=DISPLAYING_YEAR; i++) {
X			an_item = menu_get(next_menu, MENU_NTH_ITEM, i);
X			menu_set(an_item, MENU_INACTIVE, FALSE, 0);
X		}
X		value = (int) menu_show(next_menu, panel, event, 0);
X		if (value == 0)
X			return;	/* no selection made */
X		value--;
X		switch (mainsw_state) {
X			case DISPLAYING_DAY:
X				switch (value) {
X					case 0:	/* day */
X						tomorrow();
X						break;
X					case 1: /* week */
X						close_day();
X						current.tm_mday += 7;
X						draw_day();
X						break;
X					case 2:	/* month */
X						close_day();
X						current.tm_mon++;
X						/* make sure day ends up in proper month */
X						if (current.tm_mday == monthlength(current.tm_mon-1))
X							/* last day of month */
X							current.tm_mday = monthlength(current.tm_mon%12);
X						else if (current.tm_mday > monthlength(current.tm_mon%12))
X							current.tm_mday = monthlength(current.tm_mon%12);
X						draw_day();
X						break;
X					case 3: /* year */
X						close_day();
X						current.tm_year++;
X						draw_day();
X						break;
X				}
X				break;
X			case DISPLAYING_WEEK:
X				switch (value) {
X					case 1:	/* week */
X						nextweek();
X						break;
X					case 2:	/* month */
X						current.tm_mon++;
X						draw_week();
X						break;
X					case 3:	/* year */
X						current.tm_year++;
X						draw_week();
X						break;
X				}
X				break;
X			case DISPLAYING_MONTH:
X				switch (value) {
X					case 2: /* month */
X						nextmonth();
X						break;
X					case 3:	/* year */
X						current.tm_year++;
X						draw_month();
X						break;
X				}
X				break;
X			case DISPLAYING_YEAR:
X				if (value == 3)
X					nextyear();
X				break;
X		}
X	} else
X		panel_default_handle_event(item, event);
X}
X
Xvoid
Xnextbutton_notify(item, event) 
XPanel_item item; 
XEvent *event; 
X{ 
X	if (event_id(event) == MS_LEFT) {
X		switch (mainsw_state) {
X			case DISPLAYING_DAY:
X				tomorrow();
X				break;
X			case DISPLAYING_WEEK:
X				nextweek();
X				break;
X			case DISPLAYING_MONTH:
X				nextmonth();
X				break;
X			case DISPLAYING_YEAR:
X				nextyear();
X				break;
X		}
X	} else
X		panel_default_handle_event(item, event);
X}
X
Xvoid
Xprevious_menu_event(item, event)
XPanel_item item;
XEvent *event;
X{
X	Menu_item an_item;
X	int value;
X
X	if (event_id(event) == MS_RIGHT && event_is_down(event)) {
X		i = 0;
X		while (++i < mainsw_state) {
X			an_item = menu_get(previous_menu, MENU_NTH_ITEM, i);
X			menu_set(an_item, MENU_INACTIVE, TRUE, 0);
X		}
X		for (i=mainsw_state; i<=DISPLAYING_YEAR; i++) {
X			an_item = menu_get(previous_menu, MENU_NTH_ITEM, i);
X			menu_set(an_item, MENU_INACTIVE, FALSE, 0);
X		}
X		value = (int) menu_show(previous_menu, panel, event, 0);
X		if (value == 0)
X			return;	/* no selection made */
X		value--;
X		switch (mainsw_state) {
X			case DISPLAYING_DAY:
X				switch (value) {
X					case 0:	/* day */
X						yesterday();
X						break;
X					case 1: /* week */
X						close_day();
X						current.tm_mday -= 7;
X						draw_day();
X						break;
X					case 2:	/* month */
X						close_day();
X						current.tm_mon--;
X						/* make sure day ends up in proper month */
X						if (current.tm_mday == monthlength(current.tm_mon+1))
X							/* last day of month */
X							current.tm_mday = monthlength((current.tm_mon+12)%12);
X						else if (current.tm_mday > monthlength((current.tm_mon+12)%12))
X							current.tm_mday = monthlength((current.tm_mon+12)%12);
X						draw_day();
X						break;
X					case 3: /* year */
X						close_day();
X						current.tm_year--;
X						draw_day();
X						break;
X				}
X				break;
X			case DISPLAYING_WEEK:
X				switch (value) {
X					case 1:	/* week */
X						lastweek();
X						break;
X					case 2:	/* month */
X						current.tm_mon--;
X						draw_week();
X						break;
X					case 3:	/* year */
X						current.tm_year--;
X						draw_week();
X						break;
X				}
X				break;
X			case DISPLAYING_MONTH:
X				switch (value) {
X					case 2: /* month */
X						lastmonth();
X						break;
X					case 3:	/* year */
X						current.tm_year--;
X						draw_month();
X						break;
X				}
X				break;
X			case DISPLAYING_YEAR:
X				if (value == 3)
X					lastyear();
X				break;
X		}
X	} else {
X		panel_default_handle_event(item, event);
X	}
X}
X
Xvoid
Xprevious_menu_notify(item, event)
XPanel_item item; 
XEvent *event; 
X{ 
X	if (event_id(event) == MS_LEFT) {
X		switch (mainsw_state) {
X			case DISPLAYING_DAY:
X				yesterday();
X				break;
X			case DISPLAYING_WEEK:
X				lastweek();
X				break;
X			case DISPLAYING_MONTH:
X				lastmonth();
X				break;
X			case DISPLAYING_YEAR:
X				lastyear();
X				break;
X		}
X	} else
X		panel_default_handle_event(item, event);
X}
X
X#ifndef NO_SUN_MOON
Xvoid
Xmoonbutton_notify(item, event) 
XPanel_item item; 
XEvent *event; 
X{ 
X	if (event_id(event) == MS_LEFT) {
X		/* display popup frame with moon data */
X		moon_data_frame();
X		panel_set(moonbutton_pi, PANEL_SHOW_ITEM, FALSE, 0);
X	} else
X		panel_default_handle_event(item, event);
X}
X
Xvoid
Xsunbutton_notify(item, event) 
XPanel_item item; 
XEvent *event; 
X{ 
X	if (event_id(event) == MS_LEFT) {
X		/* display popup frame with moon data */
X		sun_data_frame();
X		panel_set(sunbutton_pi, PANEL_SHOW_ITEM, FALSE, 0);
X	} else
X		panel_default_handle_event(item, event);
X}
X#endif
X
XNotify_value
Xmyframe_interposer(client, event, arg, type)
XNotify_client client;
XEvent *event;
XNotify_arg arg;
XNotify_event_type type;
X{
X	static int start_up = 1;
X	int closed_initial, closed_current;
X	Notify_value value;
X	void sframe_done(), mframe_done();
X
X	/* get initial state */
X	closed_initial = (int)window_get(frame, FRAME_CLOSED);
X	/* let the frame do its thing */
X	value = notify_next_event_func(client, event, arg, type);
X	/* get new state */
X	closed_current = (int)window_get(frame, FRAME_CLOSED);
X	if (start_up) {
X		/* first time thru */
X		start_up = 0;
X		if (closed_initial)
X			/* starting up iconic */
X			olddate = current;
X		else
X			/* starting up open */
X			if (mainsw_state == DISPLAYING_DAY)
X				/* create future appt popup */
X				draw_future_appts();
X	} else if (closed_current != closed_initial) {
X		/* it changed state - either opened or closed */
X		if (closed_current) {
X			/* frame just closed */
X			close_frame();
X		} else {
X			/* frame just opened */
X			/*
X			 * redraw display in case the "today" changed
X			 * and a different day needs to be highlighted
X			 */
X			if (day_is_open)
X				close_day();
X			current = olddate;
X			switch (mainsw_state) {
X				case DISPLAYING_DAY:
X					draw_day1();
X					/* create future popup next time thru */
X					start_up = 1;
X					break;
X				case DISPLAYING_WEEK:
X					draw_week();
X					break;
X				case DISPLAYING_MONTH:
X					draw_month();
X					break;
X				case DISPLAYING_YEAR:
X					draw_year();
X					break;
X			}
X		}
X	}
X
X	return(NOTIFY_DONE);
X}
X
X/*
X * notifier for "Done" button in the popup future appt frame
X */
Xvoid
Xfdone_proc(item, event)
XPanel_item item;
XEvent *event;
X{
X	if (event_id(event) == MS_LEFT) {
X		window_destroy(fframe);
X		fframe = 0;
X		show_future = 0;
X	}
X}
X
X/*
X * notifier for "Keep" button in the popup future appt frame
X */
Xvoid
Xfkeep_proc(item, event)
XPanel_item item;
XEvent *event;
X{
X	if (event_id(event) == MS_LEFT) {
X		window_destroy(fframe);
X		fframe = 0;
X	}
X}
X
X/*
X * Notifier for future appts. We get here when the user
X * selects one of the displayed messages. When this happens,
X * the day display for the selected future appt is displayed.
X */
Xvoid
Xfappt_notify(item, event)
XPanel_item item;
XEvent *event;
X{
X	int value;
X
X	if (event_id(event) != MS_LEFT)
X		return;
X	
X	value = (int)panel_get(item, PANEL_CLIENT_DATA);
X	/* set current date to match the selected appt */
X	current.tm_year = future[value].year;
X	current.tm_mon = future[value].month;
X	current.tm_mday = future[value].day;
X	fix_current_day();
X
X	/* draw new day page */
X	draw_day();
X}
X
X/*
X * Notify routine for everyx panel item in the attributes
X * popup window. In this routine, we only care about the state
X * of the "Selected Week" choice, which determines which panel
X * item is displayed.
X */
Xvoid
Xeveryx_notify(item, event)
XPanel_item item;
XEvent *event;
X{
X	int value;
X
X	value = (int) panel_get_value(everyx_pi);
X	if (value & 0x4) {
X		if (value & 0x3) {
X			/* not allowed for ALL_DAYS or EVERY_MON_FRI */
X			value &= ~0x4;
X			panel_set_value(everyx_pi, value);
X		} else {
X			panel_set(repeat_pi, PANEL_SHOW_ITEM, FALSE, 0);
X			panel_set(whichwk_pi, PANEL_SHOW_ITEM, TRUE, 0);
X		}
X	} else {
X		panel_set(whichwk_pi, PANEL_SHOW_ITEM, FALSE, 0);
X		panel_set(repeat_pi, PANEL_SHOW_ITEM, TRUE, 0);
X	}
X}
X
X/*
X * Notify routine for the appointment attributes popup window.
X * Since each panel item does not have its own notify routine,
X * we check the current state of everything when the user
X * selects the accept button and set the slot flags appropriately.
X */
Xvoid
Xattr_accept(item, event)
XPanel_item item;
XEvent *event;
X{
X	int value, flag = 0, repeat = 0;
X	int oflag;
X	struct appt_entry *apt = slots[attr_bi].cur_appt;
X
X	if (event_id(event) != MS_LEFT)
X		return;  /* ignore everything else */
X	
X	oflag = apt->flags;
X
X	/* get the everyx value (every day, week, month, year) */
X	value = (int) panel_get_value(everyx_pi);
X	/* value is bitmap of selected choices */
X	/* EVERY_MON_FRI and ALL_DAYS are mutually exclusive */
X	if (value & 0x1)
X		flag |= EVERY_MON_FRI;
X	else if (value & 0x2)
X		flag |= ALL_DAYS;
X	else if (oflag & (EVERY_MON_FRI|ALL_DAYS))
X		apt->day = current.tm_mday;
X	if (value & 0x4)
X		flag |= Setday(current.tm_wday);
X	else if (oflag & EVERY_SOMEDAY)
X		apt->day = current.tm_mday;
X	if (value & 0x8)
X		flag |= ALL_MONTHS;
X	else if (oflag & ALL_MONTHS)
X		apt->month = current.tm_mon;
X	if (value & 0x10)
X		flag |= ALL_YEARS;
X	else if (oflag & ALL_YEARS)
X		apt->year = current.tm_year;
X	
X	if (value & 0x4) {
X		/* repeat at week intervals selected by which week pi */
X		value = (int) panel_get_value(whichwk_pi);
X		if (value == 0 || value == 0x40)
X			/* ALL selected or no selection */
X			value = ALL_WEEKS;
X		flag |= REPEAT;
X		repeat = value;
X	} else {
X		/* get repeat interval */
X		value = atoi((char *)panel_get_value(repeat_pi));
X		if (value > 0) {
X			flag |= REPEAT;
X			repeat = value;
X		}
X	}
X
X	/* get lookahead value */
X	value = atoi((char *)panel_get_value(remind_pi));
X	if (value > 0) {
X		flag |= LOOKAHEAD;
X		if (apt->lookahead != value) {
X			new_entry = 1;
X			apt->lookahead = value;
X		}
X	}
X
X	/* get runlength value */
X	value = atoi((char *)panel_get_value(runl_pi));
X	if (value > 0) {
X		flag |= RUN;
X		if (apt->runlength != value) {
X			new_entry = 1;
X			apt->runlength = value;
X		}
X	}
X
X	/* get advance warning value */
X	value = atoi((char *)panel_get_value(advw_pi));
X	if (apt->warn != value) {
X		new_entry = 1;
X		apt->warn = value;
X	}
X
X	if (oflag & A_NOTE) {
X		flag |= A_NOTE;
X		/* marked indicator */
X		value = (int) panel_get_value(marked_pi);
X		if (value == 1)
X			flag |= MARKED;  /* don't show in month/yr display */
X	}
X	/* shouldn't really be in this routine if the appt
X	 * was read only, however, this is still here for potential
X	 * future use.
X	 */
X	if (oflag & READONLY)
X		flag |= READONLY;
X
X	if (apt->repeat != repeat || oflag != flag)
X		new_entry = 1;	/* something changed */
X
X	/* set the slot info */
X	apt->repeat = repeat;
X	apt->flags = flag;
X
X	window_return(0);
X}
X
X/*
X * abort the attribute setting process, leaving the current
X * appointment unmodified.
X */
Xvoid
Xattr_abort(item, event)
XPanel_item item;
XEvent *event;
X{
X	if (event_id(event) == MS_LEFT)
X		window_return(0);
X}
X
X/*
X * Notify routine for the delete mode popup window.
X * Since the panel item does not have its own notify routine,
X * we check the current state when the user
X * selects the done button and set the slot flags appropriately.
X */
Xvoid
Xdel_done(item, event)
XPanel_item item;
XEvent *event;
X{
X	int value;
X	struct appt_entry tmp;
X
X	if (event_id(event) != MS_LEFT)
X		return;  /* ignore everything else */
X	
X	value = (int) panel_get_value(del_choice_pi);
X	if (value == 0) {
X		/* don't show it today */
X		/* create duplicate entry with delete flag set */
X		tmp = *slots[attr_bi].cur_appt;
X		tmp.flags &= ~(ALL_YEARS|ALL_MONTHS|ALL_DAYS|EVERY_SOMEDAY|REPEAT|EVERY_MON_FRI|RUN);
X		tmp.flags |= DELETED;
X		tmp.year = current.tm_year;
X		tmp.month = current.tm_mon;
X		tmp.day = current.tm_mday;
X		add_to_slot(attr_bi, &tmp, TRUE);
X		/* in the case of "cut", modify the shelf appt */
X		if ((int)panel_get(del_choice_pi, PANEL_CLIENT_DATA)) {
X			shelf_appt.flags &= ~(ALL_YEARS|ALL_MONTHS|ALL_DAYS|EVERY_SOMEDAY|REPEAT|EVERY_MON_FRI|RUN);
X			shelf_appt.year = current.tm_year;
X			shelf_appt.month = current.tm_mon;
X			shelf_appt.day = current.tm_mday;
X		}
X	} else {
X		/* completely kill appt */
X		cut_delete(attr_bi);
X	}
X	new_entry = 1;
X
X	window_return(0);
X}
X
X#ifndef NO_SUN_MOON
X/*
X * notifier for "Done" button in the popup sun data frame
X */
Xvoid
Xsdone_proc(item, event)
XPanel_item item;
XEvent *event;
X{
X	if (event_id(event) == MS_LEFT) {
X		window_destroy(sframe);
X		sframe = 0;
X		panel_set(sunbutton_pi, PANEL_SHOW_ITEM, TRUE, 0);
X	}
X}
X
X/*
X * notifier for "Done" button in the popup moon data frame
X */
Xvoid
Xmdone_proc(item, event)
XPanel_item item;
XEvent *event;
X{
X	if (event_id(event) == MS_LEFT) {
X		window_destroy(mframe);
X		mframe = 0;
X		panel_set(moonbutton_pi, PANEL_SHOW_ITEM, TRUE, 0);
X	}
X}
X
X/* "done" from subframe menu */
Xvoid
Xsframe_done(frame)
XFrame frame;
X{
X	window_destroy(sframe);
X	sframe = 0;
X	panel_set(sunbutton_pi, PANEL_SHOW_ITEM, TRUE, 0);
X}
X
X/* "done" from subframe menu */
Xvoid
Xmframe_done(frame)
XFrame frame;
X{
X	window_destroy(mframe);
X	mframe = 0;
X	panel_set(moonbutton_pi, PANEL_SHOW_ITEM, TRUE, 0);
X}
X#endif	/* NO_SUN_MOON */
X
X/*
X * notifier for file button in main control panel
X */
Xvoid
Xfilebutton_notify(item, event)
XPanel_item item;
XEvent *event;
X{
X	if (event_id(event) == MS_LEFT) {
X		panel_set_value(filename_pi, apts_pathname);
X		panel_set_value(file_ro_pi, (read_only ? 0 : 1));
X		window_set(fileframe, WIN_SHOW, TRUE, 0);
X	} else
X		panel_default_handle_event(item, event);
X}
X
X/*
X * notifier for "Done" button in the popup file frame
X */
Xvoid
Xfile_done(item, event)
XPanel_item item;
XEvent *event;
X{
X	if (event_id(event) == MS_LEFT)
X		window_set(fileframe, WIN_SHOW, FALSE, 0);
X}
X
X/*
X * notifier for "Accept" button in the popup file frame
X */
Xvoid
Xfile_accept(item, event)
XPanel_item item;
XEvent *event;
X{
X	char save_name[160];
X	int save_ro;
X	struct tm save_date;
X
X	if (event_id(event) == MS_LEFT) {
X	        save_date = current;
X		/* cleanup existing appts file and open new one */
X		strcpy(save_name, apts_pathname);
X		save_ro = read_only;
X		cleanup();
X		othername = (char *)panel_get_value(filename_pi);
X		otherfile = 1;
X		read_only = ((int)panel_get_value(file_ro_pi) == 0 ? 1 : 0);
X		if (do_files(TRUE)) {
X			/* error in opening new file - restore old */
X			othername = save_name;
X			read_only = save_ro;
X			if (do_files(TRUE))
X				/* can't restore original */
X				err_rpt("can't restore appts file", FATAL);
X		} else {
X			/* read_only may have been changed by do_files() */
X			panel_set_value(file_ro_pi, (read_only ? 0 : 1));
X	                current = save_date;
X			switch(mainsw_state) {
X				case DISPLAYING_DAY:
X					draw_day();
X					break;
X				case DISPLAYING_WEEK:
X					draw_week();
X					break;
X				case DISPLAYING_MONTH:
X					draw_month();
X					break;
X				case DISPLAYING_YEAR:
X					draw_year();
X					break;
X			}
X		}
X	}
X}
X
X/*
X * notifier for "Reset" button in the popup file frame
X */
Xvoid
Xfile_reset(item, event)
XPanel_item item;
XEvent *event;
X{
X	if (event_id(event) == MS_LEFT)
X		panel_set_value(filename_pi, apts_pathname);
X}
X
X/*
X * notifier for "Save" button in the popup file frame
X */
Xvoid
Xfile_save(item, event)
XPanel_item item;
XEvent *event;
X{
X	if (event_id(event) == MS_LEFT) {
X		othername = (char *)panel_get_value(filename_pi);
X		if (!strcmp(othername, apts_pathname)) {
X			/* no filename change */
X			if (mainsw_state == DISPLAYING_DAY && day_is_open)
X				close_day();
X		}
X	}
X}
X
X/*
X * notifier for "Original" button in the popup file frame
X */
Xvoid
Xfile_orig(item, event)
XPanel_item item;
XEvent *event;
X{
X	if (event_id(event) == MS_LEFT) {
X		panel_set_value(filename_pi, orig_apts_pathname);
X		panel_set_value(file_ro_pi, (orig_ro ? 0 : 1));
X		/* force an Accept button event */
X		file_accept(item, event);
X	}
X}
X
X/*
X * "Done" from subframe menu of the file selection popup frame
X */
Xvoid
Xfileframe_done(frame)
XFrame frame;
X{
X	window_set(fileframe, WIN_SHOW, FALSE, 0);
X}
X
X/*
X * notifier for prompt frame "No" button
X */
Xvoid
Xprompt_no_notify(item, event)
XPanel_item item;
XEvent *event;
X{
X	if (event_id(event) == MS_LEFT)
X		window_return(1);
X}
X
X/*
X * notifier for prompt frame "Yes" or "Ok" button
X */
Xvoid
Xprompt_yes_notify(item, event)
XPanel_item item;
XEvent *event;
X{
X	if (event_id(event) == MS_LEFT)
X		window_return(0);
X}
X
X#ifndef NO_PRINTER
X/*
X * notifier for "Print" button in main control panel
X */
Xvoid
Xprintbutton_notify(item, event)
XPanel_item item;
XEvent *event;
X{
X	int prt_fmt;
X
X	if (event_id(event) == MS_LEFT) {
X#ifdef RASTER_ONLY
X		/* default to printing a raster file */
X		print_calendar(PR_RASTER);
X#else
X		/* default to printing a postscript file */
X		print_calendar(PR_POSTSCRIPT);
X#endif
X	} else if (event_id(event) == MS_RIGHT) {
X		/* print selected format */
X		if ((prt_fmt = (int) panel_get(item, PANEL_CLIENT_DATA)) <= 2)
X			print_calendar(prt_fmt);
X	} else
X		panel_default_handle_event(item, event);
X}
X
Xvoid
Xprint_menu_event(item, event)
XPanel_item item;
XEvent *event;
X{
X	int value;
X#ifdef RASTER_ONLY
X	Menu_item an_item;
X#endif
X
X	if (event_id(event) == MS_RIGHT && event_is_down(event)) {
X#ifdef RASTER_ONLY
X		an_item = menu_get(print_menu, MENU_NTH_ITEM, PR_POSTSCRIPT);
X		menu_set(an_item, MENU_INACTIVE, TRUE, 0);
X#endif
X		value = (int) menu_show(print_menu, panel, event, 0);
X		if (value > 0) {
X			panel_set(item, PANEL_CLIENT_DATA, value, 0);
X			if (value == 3) {
X				/* change printer */
X				panel_set_value(prfile_pi, print_to_file);
X				panel_set_value(prcmd_pi, printer);
X				window_set(prframe, WIN_SHOW, TRUE, 0);
X			} else {
X				panel_begin_preview(item, event);
X				panel_accept_preview(item, event);
X			}
X		}
X	} else
X		panel_default_handle_event(item, event);
X}
X
Xvoid
Xprdone_proc(item, event)
XPanel_item item;
XEvent *event;
X{
X	char *newstr;
X	/**
X	int status = 0;
X	**/
X
X	if (event_id(event) == MS_LEFT) {
X		newstr = (char *) panel_get_value(prcmd_pi);
X		print_to_file = (int) panel_get_value(prfile_pi);
X		window_set(prframe, WIN_SHOW, FALSE, 0);
X		if (strcmp(printer, newstr)) {
X			/* the string changed */
X			strcpy(printer, newstr);
X			/******
X			 * writing to the defaults file doesn't work.
X			 *
X			 * create_prompt_frame("Printer changed - overwrite .defaults entry?", TRUE);
X			 * if (!window_loop(prompt_frame))
X			 * 	defaults_set_string("/CalenTool/Printer", printer, &status);
X			 *****/
X		}
X	}
X}
X
Xvoid
Xprframe_done(frame)
XFrame frame;
X{
X	/* mark as no change */
X	window_set(prframe, WIN_SHOW, FALSE, 0);
X}
X#endif	/* NO_PRINTER */
END_OF_FILE
if test 32214 -ne `wc -c <'notify.c'`; then
    echo shar: \"'notify.c'\" unpacked with wrong size!
fi
# end of 'notify.c'
fi
echo shar: End of archive 12 \(of 23\).
cp /dev/null ark12isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 23 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0

exit 0 # Just in case...
-- 
Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
Sterling Software, IMD           UUCP:     uunet!sparky!kent
Phone:    (402) 291-8300         FAX:      (402) 291-4362
Please send comp.sources.misc-related mail to kent@uunet.uu.net.