Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!princeton!orsvax1!pyrnj!caip!topaz!lll-crg!lll-lcc!vecpyr!atari!jwt From: jwt@atari.UUcp (Jim Tittsler) Newsgroups: net.micro.atari16 Subject: ST Calendar Desk Accessory (SOURCE) Message-ID: <210@atari.UUcp> Date: Thu, 24-Apr-86 15:19:24 EDT Article-I.D.: atari.210 Posted: Thu Apr 24 15:19:24 1986 Date-Received: Sun, 27-Apr-86 06:32:48 EDT Organization: Atari Corp., Sunnyvale, CA Lines: 547 Keywords: ST Accessory Here is a shar file containing the source for a simple "sort of perpetual" calendar desk accessory. #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # cal.c string.c echo x cal.c sed 's/^X//' > cal.c << 'xEOF' X/* X * cal.c -- simple TOS desktop calendar accessory X * X * provides a "perpetual" (well, really 1980-2009) calendar page display X * uses vertical scroll bar: arrows move by month, shaded area by year X * X * link68 cal.68k=accstart,cal,string,osbind,vdibind,aesbind X * relmod cal X * ren cal.prg cal.acc (must be DESKN.ACC in early TOS) X * X * - a further experiment into the realm of writing a desk accessory X * This was a personal experiment to learn more about desk accessories. X * It may be freely distributed, on an "as-is" basis. Comments and X * suggestions are welcome. This is NOT an official, supported, X * Atari product. X * Jim Tittsler, Atari Corp. X * X * 15Oct85 jwt v0.01 hacked from WATCH accessory X * 17Jan86 jwt v0.02 set first displayed page at OPEN time, X * not init time X * added Day of Week string X * 21Jan86 jwt v0.03 use reverse video to highlight current date X * 30Jan86 jwt v0.04 reduce height & width of highlight in high res X * 18Apr86 jwt v0.05 "reopen" at same place as last close X * 24Apr86 jwt v1.00 distribute X */ X Xstatic char id[] = "@(#)CAL.ACC V1.00 jwt@atari"; X X/* #define DEBUG 1 */ X/* #define DDEVICE 2 */ X#define REVHIGHLIGHT 1 X X#include "obdefs.h" X#include "define.h" X#include "gemdefs.h" X#include "osbind.h" X X#define WI_KIND (MOVER|CLOSER|NAME|UPARROW|DNARROW|VSLIDE) X X#define NO_WINDOW (-1) X X#define AR_UPPG 0 X#define AR_DNPG 1 X#define AR_UPLN 2 X#define AR_DNLN 3 X X#define STRINGWIDTH 22 X#define BLANKSTRING " " X#define CALLINES 8 X#define DAYOFWEEKSTRING " Sn M Tu W Th F Sa " X#define LENDOWS STRINGWIDTH X X#define YEAROFFSET 1980 X#define BASEYEAR 1980 X#define CALLEN 30 X#define LASTYEAR (BASEYEAR+CALLEN-1) X X#define MIN_WIDTH (STRINGWIDTH*gl_wchar) X#define MIN_HEIGHT (CALLINES*gl_hchar+1) X X#define INIT_X 100 X#define INIT_Y 50 X#define INIT_WIDTH MIN_WIDTH X#define INIT_HEIGHT MIN_HEIGHT X Xextern int gl_apid; X Xint year,month,day; Xint curyr,curmo,curday; X Xint initx = INIT_X; Xint inity = INIT_Y; X Xint lastdate = -1; /* last DOS date */ Xint washighlighted; Xint hires; /* 1 if in high resolution */ Xchar dtoabuf[10]; Xchar calstring[CALLINES][(STRINGWIDTH+1)]; Xchar *months[]= {"January", "February", "March", "April", X "May", "June", "July", "August", X "September", "October", "November", "December"}; Xint daypermon[]= {31, 28, 31, 30, X 31, 30, 31, 31, X 30, 31, 30, 31}; X Xint gl_hchar; Xint gl_wchar; Xint gl_wbox; Xint gl_hbox; /* system sizes */ X Xint menu_id ; /* our menu id */ X Xint phys_handle; /* physical workstation handle */ Xint handle; /* virtual workstation handle */ Xint wi_handle; /* window handle */ Xint top_window; /* handle of topped window */ X Xint xwork,ywork,hwork,wwork; /* work area */ X Xint msgbuff[8]; /* event message buffer */ Xint keycode; /* keycode returned by event-keyboard */ Xint mx,my; /* mouse x and y pos. */ Xint ret; /* dummy return variable */ X Xint hidden; /* current state of cursor */ X Xint contrl[12]; Xint intin[128]; Xint ptsin[128]; Xint intout[128]; Xint ptsout[128]; /* storage wasted for idiotic bindings */ X Xint work_in[11]; /* Input to GSX parameter array */ Xint work_out[57]; /* Output from GSX parameter array */ Xint pxyarray[10]; /* input point array */ X X/*page */ Xchar *dtoa( i, fwidth ) register int i,fwidth; { Xregister char *ptr,*lptr; Xregister int cnt; Xchar tbuf[6]; X X ptr = dtoabuf; X X if (i < 0) { X *ptr++ = '-'; X --fwidth; X i = -i; X } X X lptr = tbuf; X cnt = 0; X X do { X *lptr++ = (i % 10)+0x30; X ++cnt; X } while ( (i /= 10) && (cnt