home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1992 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1992.iso
/
usenet
/
altsrcs
/
1
/
1608
/
pcalinit.h
< prev
next >
Wrap
Text File
|
1990-12-28
|
6KB
|
240 lines
/*
* pcalinit.h - provides the PostScript routines for pcal.c
*/
/* modified by AWR to skip printing days of week on small calendars */
char *header_1[] = {
"/month_names [ (January) (February) (March) (April) (May) (June) (July)",
"\t\t(August) (September) (October) (November) (December) ] def",
"/prtnum { 3 string cvs show} def",
"/drawgrid {\t\t% draw calendar boxes",
"\tdayfont findfont 10 scalefont setfont",
"\t0 1 6 {",
"\t\t/i exch def",
"\t\tsubmonth 0 eq {",
"\t\t\ti 100 mul 40 moveto",
"\t\t\t[ (Sunday) (Monday) (Tuesday) (Wednesday) (Thursday) (Friday) (Saturday) ] i get",
"\t\t\t100 center",
"\t\t} if",
"\t\ti 100 mul 35 moveto",
"\t\t1.0 setlinewidth",
"\t\t0 1 5 {",
"\t\t\tgsave",
"\t\t\t100 0 rlineto ",
"\t\t\t0 -80 rlineto",
"\t\t\t-100 0 rlineto",
"\t\t\tclosepath stroke",
"\t\t\tgrestore",
"\t\t\t0 -80 rmoveto",
"\t\t pop } for",
"\t} for",
"} def",
"/drawnums {\t\t% place day numbers on calendar",
"\tdayfont findfont 30 scalefont setfont",
"\t/start startday def",
"\t/days ndays def",
"\t/n 0 def",
"\tstart 100 mul 5 add 10 rmoveto",
"\t1 1 days {",
"\t\t/day exch def",
"\t\tgsave",
"\t\tsubmonth 0 eq {",
(char *)0
};
/* modified by AWR to calculate leap years correctly, print holidays in gray,
and to center month and year together */
char *header_2[] = {
"\t\t\tday holidays n get eq {",
"\t\t\t\t.8 setgray",
"\t\t\t\t/n n 1 add def",
"\t\t\t} if",
"\t\t} if",
"\t\tday prtnum",
"\t\tgrestore",
"\t\tday start add 7 mod 0 eq",
"\t\t{",
"\t\t\tcurrentpoint exch pop 80 sub 5 exch moveto",
"\t\t}",
"\t\t{",
"\t\t\t100 0 rmoveto",
"\t\t} ifelse",
"\t} for",
"} def",
"/drawfill {\t\t% place fill squares on calendar",
"\t/start startday def",
"\t/days ndays def",
"\t0 35 rmoveto",
"\t1.0 setlinewidth",
"\t0 1 start 1 sub {",
"\t\tgsave",
"\t\t.9 setgray",
"\t\t100 0 rlineto ",
"\t\t0 -80 rlineto",
"\t\t-100 0 rlineto",
"\t\tclosepath fill",
"\t\tgrestore",
"\t\t100 0 rmoveto",
"\tpop } for",
"\tsubmonth 1 eq",
"\t{",
"\t\t/lastday 42 def",
"\t\t600 -365 moveto",
"\t}",
"\t{",
"\t\t/lastday 40 def",
"\t\t400 -365 moveto",
"\t} ifelse",
"\tlastday -1 ndays start 1 add add",
"\t{",
"\t\t/day exch def",
"\t\tgsave",
"\t\t.9 setgray",
"\t\t100 0 rlineto ",
"\t\t0 -80 rlineto",
"\t\t-100 0 rlineto",
"\t\tclosepath fill",
"\t\tgrestore",
"\t\tday 7 mod 1 eq",
"\t\t{",
"\t\t\t600 -365 80 add moveto",
"\t\t}",
"\t\t{",
"\t\t\t-100 0 rmoveto",
"\t\t} ifelse",
"\t} for",
"} def",
"/isleap {\t\t% is this a leap year?",
"\tyear 4 mod 0 eq\t\t% multiple of 4",
"\tyear 100 mod 0 ne \t% not century",
"\tyear 400 mod 0 eq or and\t% or divisible by 400",
"} def",
"/days_month [ 31 28 31 30 31 30 31 31 30 31 30 31 ] def",
"/ndays {\t\t% number of days in this month",
"\tdays_month month 1 sub get",
"\tmonth 2 eq\t% Feb",
"\tisleap and",
"\t{",
"\t\t1 add",
"\t} if",
"} def",
"/startday {\t\t% starting day-of-week for this month",
"\t/off year 2000 sub def\t% offset from start of epoch",
"\toff",
"\toff 4 idiv add\t\t% number of leap years",
"\toff 100 idiv sub\t% number of centuries",
"\toff 400 idiv add\t% number of years divisible by 400",
"\t6 add 7 mod 7 add \t% offset from Jan 1 2000",
"\t/off exch def",
"\t1 1 month 1 sub {",
"\t\t/idx exch def",
"\t\tdays_month idx 1 sub get",
"\t\tidx 2 eq",
"\t\tisleap and",
"\t\t{",
"\t\t\t1 add",
"\t\t} if",
"\t\t/off exch off add def",
"\t} for",
"\toff 7 mod\t\t% 0--Sunday, 1--monday, etc.",
"} def",
"/center {\t\t% center string in given width",
"\t/width exch def",
"\t/str exch def width str ",
"\tstringwidth pop sub 2 div 0 rmoveto str show",
"} def",
"/strcat {\t\t% concatenate two strings",
"\t2 copy",
"\tlength exch length",
"\tdup 3 -1 roll add",
"\tstring",
"\tdup 0 6 -1 roll putinterval",
"\tdup 3 -1 roll 4 -1 roll putinterval",
"} def",
"/calendar",
"{",
"\ttitlefont findfont 48 scalefont setfont",
"\t/month_name month_names month 1 sub get def",
"\t/yearstring year 10 string cvs def",
"\t0 60 moveto",
"\tmonth_name ( ) strcat yearstring strcat 700 center",
"\t0 0 moveto",
"\tdrawnums",
"\t0 0 moveto",
"\tdrawfill",
"\t0 0 moveto",
"\tdrawgrid",
"} def",
"/daytext {",
"\t/Helvetica-Narrow findfont 6 scalefont setfont",
"\t/mytext\texch def /myday exch def",
"\tstartday myday 1 sub add dup 7 mod 100 mul 5 add % gives column",
"\texch 7 idiv -80 mul % gives row",
"\tdup /ypos exch def moveto",
"\t/LM currentpoint pop def /RM LM 95 add def",
" mytext { dup (.p) eq { crlf pop} {prstr ( ) show} ifelse } forall",
"} def",
"/crlf {",
" ypos 8 sub /ypos exch def LM ypos moveto",
"} def",
"/prstr {",
" dup stringwidth pop currentpoint pop",
" add RM gt {crlf} if show",
"} def",
"/printmonth {",
(char *)0,
};
char *header_3[] = {
"\t/submonth 0 def",
"\tcalendar",
"\tmonth 1 sub 0 eq",
"\t{",
"\t\t/lmonth 12 def",
"\t\t/lyear year 1 sub def",
"\t}",
"\t{",
"\t\t/lmonth month 1 sub def",
"\t\t/lyear year def",
"\t} ifelse",
"\tmonth 1 add 13 eq",
"\t{",
"\t\t/nmonth 1 def",
"\t\t/nyear year 1 add def",
"\t} ",
"\t{",
"\t\t/nmonth month 1 add def",
"\t\t/nyear year def",
"\t} ifelse",
"\t/savemonth month def",
"\t/saveyear year def",
"\t/submonth 1 def",
"\t/year lyear def",
"\t/month lmonth def",
"\tgsave",
"\t500 -365 translate",
"\tgsave",
"\t.138 .138 scale",
"\t10 -120 translate",
"\tcalendar",
"\tgrestore",
"\t/submonth 1 def",
"\t/year nyear def",
"\t/month nmonth def",
"\t100 0 translate",
"\tgsave",
"\t.138 .138 scale",
"\t10 -120 translate",
"\tcalendar",
"\tgrestore",
"\t/month savemonth def",
"\t/year saveyear def",
"\t/submonth 0 def",
"\tgrestore",
"} def",
(char *)0,
};