home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 4
/
AACD04.ISO
/
AACD
/
Utilities
/
OHAC
/
source
/
OHAC.e
Wrap
Text File
|
1999-09-20
|
26KB
|
832 lines
/* $VER: OHAC 1.3 (20.9.99) by J. Tierney
OHAC (Oh Heck, Another Calendar!) v1.3
Began: 04/29/99
- 1.3
(9/20/99)
- The reset button's text is now "Today".
- resetcal() now displays "Today." (w/ a period).
- "Set Today" & "Reset Today" menu items.
- New procs: settoday(), resettoday().
- Removed an unneeded line in dayreport().
- The "Today" button now has 3 functions:
- Today - Jump to the currently set "today".
- SHIFT Today - Set the currently displayed date as "today".
- ALT Today - Reset "today" to the current system date.
- New startup option: SETTODAY.
- 1.2a
(6/20/99)
- Year inc/decrement gadgets.
- New proc: incyear().
(6/19/99)
- LEFTEDGE and TOPEDGE are (again) initialized to -1. Fixed the
EasyGUI-JJT centering problem with a few Max()'s.
- 1.2
(6/17/99)
- LEFTEDGE and TOPEDGE are initialized to 0. EasyGUI-JJT doesn't properly
center windows if WIDTH/HEIGHT <> 0.
(6/16/99)
- Using a new EasyGUI-JJT.m.
- EG_WIDTH and EG_HEIGHT tags.
- No longer necessary (or desirable) to initialize the WIDTH and HEIGHT
opts to -1.
- datemenu() now uses guihandle.menutrigger (the "data" arg is no longer
the menuitem).
(6/10/99)
- Renamed MENUDATE arg to DATEMENU.
(6/8/99)
- Discovered the docs for the calendar gadget :-), so it can now be resized
vertically, too.
- New arg: HEIGHT (saw that one comming, didn't ya?).
- New error message: STR_ERRCAL.
(6/7/99)
- Reorganized source.
(6/6/99)
- diskfont.library is no longer required. initfontreq() and loadfont()
take this into account.
- loadfont() reverts to the screen's font if the requested font can't be
opened.
- Localized the change-font releates strings.
- Optimized localize().
- New proc: locassignstrs().
- Removed catsetstr() and nocatsetstr().
- EXPERIMENTAL: Using ooresourcestack12.
(6/5/99)
- Bug fix: GetProgramName() returns path, but wbarg.name doesn't.
- Removed the string-length check in parsedate(). This allows MENUDATEs
to have additional text (eg "01.01.2000 - Y2K").
- Removed a useless bit of code from main().
- The WIDTH arg is back. I switched from using easyguiA() to guiinitA()
and doing a sizewin() afterwards.
- "Change Font" menu option.
- New procs: initfontreq(), chngfont().
(6/4/99)
- Snapshot is back (and done). :-)
- Removed a couple NM_BARLABELS.
(6/1/99)
- Adding Iconify feature.
(5/31/99)
- Using new date format: dd.mm.yyyy. The seperator char doesn't matter,
and each field will revert to the current setting if it isn't valid.
Ex: 25.12.???? will = Dec 25, this year.
- Switched to EasyGUI-JJT.m - I changed the menu func to pass the menuitem
to the action func.
- Adding user-defined Date menu.
- New procs: copydatestrs(), makemenus(), datemenu().
- The SHOWDATE arg is added to the Date menu (right after "Today").
(5/28/99)
- Got the EG_FONT tag working (it's necessary to first open the font;
EasyGUI won't).
- New procs: fixfontname() & loadfont().
- Added the EG_TOP and EG_LEFT tags. There aren't any tags to set the
width or height. Ha!
- Removed WIDTH arg (see above) and snaphot (see above). :-)
- The SHOWDATE arg works. Uses dd-mm-yy format.
- New proc: parsedate().
- Day report now accepts a NIL gui arg, and will just set g_tmpstr.
- PUBSCREEN arg works.
- Screen-jump feature.
- New proc: jumpscr().
(5/27/99)
- Planning to add snaphot and iconify features. ...& parseargs().
- Changed localize() to get month names and "Today" from default Locale.
(5/25/99)
- Using OOResourceStack11.m.
- Localizing...
(5/24/99)
- Optimized openlibs().
- Planning to localize...
- 1.1
(5/13/99)
- Bug fix: usgn_less() never returned the result. D'oh!.
- Menus! "About" and "Quit".
- ezreq().
- Error reporting.
(5/6/99)
- Replaced calls to Div() in day report with utility.library's UdivMod32().
Allows for the maximum amount of years (1978 - 2113).
(5/5/99)
- Using usgn_less in dayreport(). Allows max year of 2066.
- Thank You, God!!!
*/
OPT LARGE
MODULE 'dos/dos',
'dos/rdargs',
'exec/io',
'graphics/text',
'intuition/intuition',
'intuition/screens',
'asl',
'diskfont',
'icon',
'locale',
'timer',
'utility',
'utility/date',
'utility/tagitem',
'wb',
'workbench/startup',
'workbench/workbench',
'devices/inputevent',
'devices/timer',
'libraries/asl',
'libraries/gadtools',
'libraries/locale',
'tools/EasyGUI-JJT',
'plugins/calendar',
'other/oolist',
'other/oostring',
'other/ooresourcestack12'
CONST SECSINDAY = 86400, MAXPUBSCRNAME = MAXPUBSCREENNAME + 1,
SHIFT = IEQUALIFIER_LSHIFT OR IEQUALIFIER_RSHIFT,
ALT = IEQUALIFIER_LALT OR IEQUALIFIER_RALT
ENUM OK=0, QUIT, ER_TIMER, ER_ARGS,
RA_X=0, RA_Y, RA_W, RA_H,
RA_PUBSCR,
RA_FONT, RA_FSIZE,
RA_DATE, RA_TODAY, RA_ICONIFY, RA_ICONIMG,
RA_USRDATES,
RA_COUNT,
STR_TXTCREDIT=0,
STR_TXTDAY, STR_TXTDAYS, STR_TXTAGO, STR_TXTAWAY,
STR_TXTJAN, STR_TXTFEB, STR_TXTMAR, STR_TXTAPR, STR_TXTMAY, STR_TXTJUN,
STR_TXTJUL, STR_TXTAUG, STR_TXTSEP, STR_TXTOCT, STR_TXTNOV, STR_TXTDEC,
STR_TXTTODAY, STR_TXTTODAY2,
STR_REQERROR=50, STR_REQWARN, STR_REQABOUT, STR_REQFONT,
STR_ERRMEM=75, STR_ERRGUI, STR_ERRBIG, STR_ERRTIMER, STR_ERRARGS,
STR_ERRICONIFY, STR_ERRMPORT, STR_ERRAPICON, STR_ERRCAL,
STR_GADOK=125, STR_GADRESET,
STR_MNUPROJ=175,
STR_MNUJUMP, STR_MNUICONIFY, STR_MNUFONT, STR_MNUSNAP, STR_MNUABOUT,
STR_MNUQUIT,
STR_MNUDATES,
STR_MNUDATESET, STR_MNUDATERESET,
STR_COUNT
DEF timerbase, g_timerio:timerequest, g_time:timeval, g_date:clockdata,
g_locale=NIL, g_catalog=NIL, g_stringlist[STR_COUNT]:LIST,
g_args[RA_COUNT]:ARRAY OF LONG,
g_font, g_txtattr:textattr,
g_gui:PTR TO guihandle,
g_cal:PTR TO calendar, g_caldate:clockdata,
gad_month, gad_year, gad_text, g_menudata, g_usermenucnt,
g_tmpstr[80]:STRING,
g_ohacname[256]:STRING,
g_iconifyicon:PTR TO diskobject, g_fontreq=NIL:PTR TO fontrequester
PROC main() HANDLE
DEF str, endprg
initresourcelist()
openlibs([{aslbase}, 'asl.library', 36, FALSE,
{diskfontbase}, 'diskfont.library', 0, FALSE,
{localebase}, 'locale.library', 38, FALSE,
{iconbase}, 'icon.library', 36, TRUE,
{utilitybase}, 'utility.library', 0, TRUE,
{workbenchbase}, 'workbench.library', 36, TRUE,
0])
parseargs(g_args)
localize()
opentimer()
initfontreq()
loadfont(g_args[RA_FONT], g_args[RA_FSIZE])
syncdate(g_date)
parsedate(g_args[RA_TODAY], g_date)
syncdate(g_caldate)
parsedate(g_args[RA_DATE], g_caldate)
NEW g_cal.calendar(g_caldate, TRUE, TRUE)
g_menudata:=makemenus(g_args[RA_USRDATES], g_usermenucnt)
IF g_args[RA_ICONIFY] THEN iconify(NIL)
dayreport(NIL)
makegui()
REPEAT
Wait(g_gui.sig)
endprg:=guimessage(g_gui)
UNTIL endprg >= 0
EXCEPT DO
IF exception > QUIT
SELECT exception
CASE "MEM"
str:=STR_ERRMEM
CASE "GT"
str:='Unable to open gadtools.library.'
CASE "GUI"
str:=STR_ERRGUI
CASE "bigg"
str:=STR_ERRBIG
CASE "cal"
str:=STR_ERRCAL
CASE ER_TIMER
str:=STR_ERRTIMER
DEFAULT
str:=NIL
ENDSELECT
IF str THEN ezreq(0, g_stringlist[STR_REQERROR], g_stringlist[str])
ENDIF
cleangui(g_gui)
END g_cal
freeresourcelist()
ENDPROC
PROC parseargs(argary:PTR TO LONG) HANDLE
DEF wb:PTR TO wbstartup, warg:PTR TO wbarg, freefunc=NIL,
info:PTR TO diskobject, rdargs, rdopts[RA_COUNT]:ARRAY OF LONG,
i, cd
FOR i:=0 TO RA_COUNT - 1
argary[i]:=NIL
rdopts[i]:=NIL
ENDFOR
argary[RA_X]:=-1
argary[RA_Y]:=-1
IF wbmessage
wb:=wbmessage
i:=IF wb.numargs > 1 THEN 1 ELSE 0
warg:=wb.arglist[i]
cd:=CurrentDir(warg.lock)
StringF(g_ohacname, 'PROGDIR:\s', warg.name)
IF (info:=GetDiskObject(warg.name))
freefunc:=`FreeDiskObject(info)
FOR i:=0 TO 4
IF (rdargs:=FindToolType(info.tooltypes, ListItem(['LEFTEDGE', 'TOPEDGE', 'WIDTH', 'HEIGHT', 'FONTSIZE'], i)))
argary[ListItem([RA_X, RA_Y, RA_W, RA_H, RA_FSIZE], i)]:=Val(rdargs) AND $FFFF
ENDIF
ENDFOR
FOR i:=0 TO 3
rdopts[ListItem([RA_PUBSCR, RA_FONT, RA_DATE, RA_TODAY, RA_ICONIMG], i)]:=FindToolType(info.tooltypes, ListItem(['PUBSCREEN', 'FONT', 'SHOWDATE', 'SETTODAY', 'ICONIFIEDIMAGE'], i))
ENDFOR
rdopts[RA_ICONIFY]:=FindToolType(info.tooltypes, 'ICONIFY')
i, g_usermenucnt:=copydatestrs(info.tooltypes, TRUE)
argary[RA_USRDATES]:=i
ENDIF
CurrentDir(cd)
ELSE
GetProgramName(g_ohacname, 256)
IF (rdargs:=ReadArgs('X=LEFTEDGE/K/N,Y=TOPEDGE/K/N,W=WIDTH/K/N,H=HEIGHT/K/N,'+
'PS=PUBSCREEN/K,F=FONT/K,FS=FONTSIZE/K/N,'+
'SD=SHOWDATE/K,ST=SETTODAY/K,I=ICONIFY/S,IMG=ICONIFIEDIMAGE/K,'+
'DM=DATEMENU/K/M', rdopts, NIL))
freefunc:=`FreeArgs(rdargs)
FOR i:=0 TO 4
cd:=ListItem([RA_X, RA_Y, RA_W, RA_H, RA_FSIZE], i)
IF rdopts[cd] THEN argary[cd]:=Long(rdopts[cd])
ENDFOR
i, g_usermenucnt:=copydatestrs(rdopts[RA_USRDATES], FALSE)
argary[RA_USRDATES]:=i
ENDIF
ENDIF
FOR i:=0 TO 2
cd:=ListItem([RA_DATE, RA_TODAY, RA_ICONIMG], i)
IF rdopts[cd] THEN argary[cd]:=clonestr(rdopts[cd])
ENDFOR
argary[RA_PUBSCR]:=LockPubScreen(rdopts[RA_PUBSCR])
addresource(`UnlockPubScreen(NIL, g_args[RA_PUBSCR]))
ScreenToFront(argary[RA_PUBSCR])
IF rdopts[RA_FONT] THEN argary[RA_FONT]:=fixfontname(rdopts[RA_FONT])
argary[RA_ICONIFY]:=IF rdopts[RA_ICONIFY] THEN TRUE ELSE NIL
EXCEPT DO
IF freefunc THEN Eval(freefunc)
ReThrow()
ENDPROC
PROC copydatestrs(strarray:PTR TO LONG, ttlist)
DEF estrlist=NIL, estr, str, i=0, laststr, strcount
IF strarray
WHILE (str:=strarray[i++])
IF ttlist
str:=IF StrCmp(str, 'DATEMENU=', 9) THEN str + 9 ELSE NIL
ENDIF
IF str
estr:=clonestr(str, TRIM_BOTH)
IF estrlist THEN Link(laststr, estr) ELSE estrlist:=estr
laststr:=estr
INC strcount
-> WriteF('\s\n', str)
ENDIF
ENDWHILE
ENDIF
ENDPROC estrlist, strcount
PROC localize()
DEF i
IF localebase
g_locale:=OpenLocale(NIL)
addresource(`CloseCatalog(g_locale))
g_catalog:=OpenCatalogA(NIL, 'ohac.catalog', NIL)
addresource(`CloseCatalog(g_catalog))
ENDIF
FOR i:=0 TO 12
g_stringlist[STR_TXTJAN + i]:=IF g_locale THEN GetLocaleStr(g_locale, MON_1 + i) ELSE ListItem(['January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'], i)
ENDFOR
g_stringlist[STR_TXTTODAY]:=IF g_locale THEN GetLocaleStr(g_locale, TODAYSTR) ELSE 'Today'
g_stringlist[STR_TXTTODAY2]:=clonestr(StringF(g_tmpstr, '\s.', g_stringlist[STR_TXTTODAY]))
locassignstrs(STR_TXTCREDIT, ['', -> '\nEnglish translation by J. Tierney\n<jtierney@cyberlink-inc.com>',
'day',
'days',
'ago',
'away'])
locassignstrs(STR_REQERROR, ['OHAC Error:',
'OHAC Warning:',
'About:',
'OHAC Font:'])
locassignstrs(STR_ERRMEM, ['Unable to allocate memory.',
'GUI creation failed.',
'GUI\as minimum size is too large for this screen.',
'Unable to open timer.device.',
'Bad args.',
'Unable to iconify:',
'Unable to open a message port.',
'AppIcon creation failed.',
'Unable to create calendar gadget.'])
locassignstrs(STR_GADOK, ['Okay', 'Reset'])
locassignstrs(STR_MNUPROJ, ['Project',
'Next PubScreen',
'Iconify',
'Change Font...',
'Snapshot',
'About...',
'Quit',
'Dates',
'Set Today',
'Reset Today'])
ENDPROC
PROC locassignstrs(from, strlist:PTR TO LONG)
DEF defstr, i, li=0
FOR i:=from TO from + ListLen(strlist) - 1
defstr:=strlist[li++]
g_stringlist[i]:=IF g_catalog THEN GetCatalogStr(g_catalog, i, defstr) ELSE defstr
ENDFOR
ENDPROC
PROC opentimer()
NEW g_timerio
IF OpenDevice('timer.device', UNIT_MICROHZ, g_timerio, NIL) THEN Raise(ER_TIMER)
timerbase:=g_timerio.io.device
addresource(`CloseDevice(g_timerio))
ENDPROC
PROC initfontreq()
IF (aslbase <> NIL) AND (diskfontbase <> NIL)
g_fontreq:=AllocAslRequest(ASL_FONTREQUEST, [ASLFO_SLEEPWINDOW, TRUE,
ASLFO_TITLETEXT, g_stringlist[STR_REQFONT],
ASLFO_MAXHEIGHT, 96,
TAG_DONE])
addresource(`FreeAslRequest(g_fontreq))
ENDIF
ENDPROC
PROC fixfontname(name)
DEF fontname, l
l:=StrLen(name) + 5
fontname:=String(l)
StrCopy(fontname, name)
IF InStr(fontname, '.font') = -1 THEN StrAdd(fontname, '.font')
ENDPROC fontname
PROC loadfont(fname, fsize)
DEF scrn:PTR TO screen
IF (fname <> NIL) AND (fsize <> NIL) AND (diskfontbase <> NIL)
g_txtattr.name:=clonestr(fname)
g_txtattr.ysize:=fsize
g_font:=OpenDiskFont(g_txtattr)
ENDIF
IF g_font = NIL
-> * Fall back to screen's font.
scrn:=g_args[RA_PUBSCR]
g_txtattr.name:=clonestr(scrn.font.name)
g_txtattr.ysize:=scrn.font.ysize
g_font:=OpenFont(g_txtattr)
ENDIF
ENDPROC
PROC makemenus(strlist, strcount)
DEF menus:PTR TO newmenu, mi, size, nms
mi:=14
nms:=SIZEOF newmenu
size:=mi + 2 + strcount
NEW menus[size]
CopyMem([NM_TITLE, 0, g_stringlist[STR_MNUPROJ], 0, 0, 0, 0,
NM_ITEM, 0, g_stringlist[STR_MNUJUMP], 'J', 0, 0, {jumpscr},
NM_ITEM, 0, g_stringlist[STR_MNUICONIFY], 'I', 0, 0, {iconify},
NM_ITEM, 0, g_stringlist[STR_MNUFONT], 0, 0, 0, {chngfont},
NM_ITEM, 0, g_stringlist[STR_MNUSNAP], 0, 0, 0, {snapshot},
NM_ITEM, 0, NM_BARLABEL, 0, 0, 0, 0,
NM_ITEM, 0, g_stringlist[STR_MNUABOUT], '?', 0, 0, {about},
NM_ITEM, 0, NM_BARLABEL, 0, 0, 0, 0,
NM_ITEM, 0, g_stringlist[STR_MNUQUIT], 'Q', 0, 0, {quit},
NM_TITLE, 0, g_stringlist[STR_MNUDATES], 0, 0, 0, 0,
NM_ITEM, 0, g_stringlist[STR_MNUDATESET], 0, 0, 0, {settoday},
NM_ITEM, 0, g_stringlist[STR_MNUDATERESET], 0, 0, 0, {resettoday},
NM_ITEM, 0, NM_BARLABEL, 0, 0, 0, 0,
NM_ITEM, 0, g_stringlist[STR_TXTTODAY], 0, 0, 0, {resetcal}]:newmenu, menus[0], mi * nms)
IF g_args[RA_DATE]
CopyMem([NM_ITEM, 0, g_args[RA_DATE], 0, 0, 0, {datemenu}]:newmenu, menus[mi++], nms)
ENDIF
WHILE strlist
CopyMem([NM_ITEM, 0, strlist, 0, 0, 0, {datemenu}]:newmenu, menus[mi++], nms)
strlist:=Next(strlist)
ENDWHILE
CopyMem([NM_END, 0, 0, 0, 0, 0, 0]:newmenu, menus[mi], nms)
ENDPROC menus
PROC makegui()
g_gui:=guiinitA('OHAC v1.3',
[ROWS,
[COLS,
gad_month:=[CYCLE, {setmonth}, NIL, [g_stringlist[STR_TXTJAN],
g_stringlist[STR_TXTFEB],
g_stringlist[STR_TXTMAR],
g_stringlist[STR_TXTAPR],
g_stringlist[STR_TXTMAY],
g_stringlist[STR_TXTJUN],
g_stringlist[STR_TXTJUL],
g_stringlist[STR_TXTAUG],
g_stringlist[STR_TXTSEP],
g_stringlist[STR_TXTOCT],
g_stringlist[STR_TXTNOV],
g_stringlist[STR_TXTDEC], 0], g_caldate.month - 1],
gad_year:=[INTEGER, {setyear}, NIL, g_caldate.year, 6],
[BUTTON, {incyear}, '<', 0],
[BUTTON, {incyear}, '>', 1]
],
[SPACE],
[SPACE],
[PLUGIN, {dayreport}, g_cal],
[COLS,
gad_text:=[TEXT, g_tmpstr, NIL, TRUE, 2],
[BUTTON, {resetcal}, g_stringlist[STR_TXTTODAY]]
]
], [EG_MENU, g_menudata,
EG_LEFT, g_args[RA_X],
EG_TOP, g_args[RA_Y],
EG_WIDTH, g_args[RA_W],
EG_HEIGHT, g_args[RA_H],
EG_FONT, g_txtattr,
EG_SCRN, g_args[RA_PUBSCR],
TAG_DONE])
ENDPROC
PROC ezreq(win, title, bodytext, buttons=NIL, arglist=NIL)
DEF choice
choice:=EasyRequestArgs(win, [SIZEOF easystruct,
NIL,
title,
bodytext,
IF buttons THEN buttons ELSE g_stringlist[STR_GADOK]]:easystruct, NIL, arglist)
ENDPROC choice
PROC long2ints(num) -> *** Splits a LONG into 2 INTs (high and low).
DEF intptr:PTR TO INT, hi, lo
intptr:={num}
hi:=intptr[] AND $FFFF
lo:=intptr[1] AND $FFFF
ENDPROC hi, lo
PROC usgn_less(a, b)
DEF ahi, alo, bhi, blo, result
ahi, alo:=long2ints(a)
bhi, blo:=long2ints(b)
result:=IF ahi = bhi THEN alo < blo ELSE ahi < bhi
ENDPROC result
PROC syncdate(date:PTR TO clockdata)
GetSysTime(g_time)
/*
Amiga2Date($8FFFFFFF, date)
WriteF('\d\n', date.year)
*/
Amiga2Date(g_time.secs, date)
date.sec:=0
date.min:=0
date.hour:=0
ENDPROC
PROC parsedate(datestr, date:PTR TO clockdata)
DEF dstr[11]:ARRAY OF CHAR, n, ok
IF datestr
AstrCopy(dstr, datestr, 11)
dstr[2]:=0
dstr[5]:=0
n, ok:=Val(dstr)
IF ok THEN date.mday:=Bounds(n, 1, 31)
n, ok:=Val(dstr + 3)
IF ok THEN date.month:=Bounds(n, 1, 12)
n, ok:=Val(dstr + 6)
IF ok THEN date.year:=Bounds(n, 1978, 2113)
ENDIF
ENDPROC
/* --- Gadget procs --- */
PROC setmonth(gui, month)
g_cal.date.month:=month + 1
g_cal.setdate()
dayreport(gui)
ENDPROC
PROC setyear(gui, year)
year:=Bounds(year, 1978, 2113)
setinteger(gui, gad_year, year)
g_cal.date.year:=year
g_cal.setdate()
dayreport(gui)
ENDPROC
PROC incyear(inc, gui)
DEF year
year:=g_cal.date.year + IF inc THEN 1 ELSE -1
IF (year > 1977) AND (year < 2114)
g_cal.date.year:=year
setinteger(gui, gad_year, year)
g_cal.setdate()
dayreport(gui)
ENDIF
ENDPROC
PROC dayreport(gui, day=0)
DEF cal, real, diff, past
real:=Date2Amiga(g_date)
cal:=Date2Amiga(g_caldate)
IF cal = real
StrCopy(g_tmpstr, g_stringlist[STR_TXTTODAY2])
ELSE
past:=usgn_less(cal, real)
diff:=UdivMod32(IF past THEN real - cal ELSE cal - real, SECSINDAY)
StringF(g_tmpstr, '\d \s \s.', diff, IF diff > 1 THEN g_stringlist[STR_TXTDAYS] ELSE g_stringlist[STR_TXTDAY], IF past THEN g_stringlist[STR_TXTAGO] ELSE g_stringlist[STR_TXTAWAY])
ENDIF
IF gui THEN settext(gui, gad_text, g_tmpstr)
ENDPROC
PROC resetcal(qual, d, gui)
IF qual AND SHIFT -> *** g_date = Displayed date.
g_date.mday:=g_caldate.mday
g_date.month:=g_caldate.month
g_date.year:=g_caldate.year
ELSEIF qual AND ALT -> *** g_date = Actual date.
resettoday(gui)
RETURN
ELSE -> *** Jump to g_date.
g_caldate.mday:=g_date.mday
g_caldate.month:=g_date.month
g_caldate.year:=g_date.year
setcycle(gui, gad_month, g_date.month - 1)
setinteger(gui, gad_year, g_date.year)
g_cal.setdate()
ENDIF
settext(gui, gad_text, g_stringlist[STR_TXTTODAY2])
ENDPROC
/* --- Menu procs --- */
PROC jumpscr(gui)
DEF psname[MAXPUBSCRNAME]:ARRAY OF CHAR, pslock
IF NextPubScreen(g_args[RA_PUBSCR], psname)
IF (pslock:=LockPubScreen(psname))
UnlockPubScreen(NIL, g_args[RA_PUBSCR])
closewin(gui)
changescreen(gui, pslock)
g_args[RA_PUBSCR]:=pslock
openwin(gui)
ScreenToFront(pslock)
ENDIF
ENDIF
ENDPROC
PROC iconify(gui)
DEF mport, amsg:PTR TO appmessage, aicon,
iname, done
IF (mport:=CreateMsgPort())
IF gui THEN closewin(gui)
IF g_iconifyicon = NIL
IF g_args[RA_ICONIMG]
done:=InStr(iname, '.info')
iname:=StrCopy(g_tmpstr, g_args[RA_ICONIMG], done)
ELSE
iname:=g_ohacname
ENDIF
g_iconifyicon:=GetDiskObjectNew(iname)
addresource(`FreeDiskObject(g_iconifyicon))
ENDIF
IF (aicon:=AddAppIconA(NIL, NIL, 'OHAC', mport, NIL, g_iconifyicon, NIL))
REPEAT
WaitPort(mport)
WHILE (amsg:=GetMsg(mport))
done:=amsg.numargs = 0
ReplyMsg(amsg)
ENDWHILE
UNTIL done
RemoveAppIcon(aicon)
ELSE
ezreq(NIL, g_stringlist[STR_REQERROR], '\s\n\s', NIL, [g_stringlist[STR_ERRICONIFY], g_stringlist[STR_ERRAPICON]])
ENDIF
IF gui THEN openwin(gui)
WHILE (amsg:=GetMsg(mport)) DO ReplyMsg(amsg)
DeleteMsgPort(mport)
ELSE
ezreq(NIL, g_stringlist[STR_REQERROR], '\s\n\s', NIL, [g_stringlist[STR_ERRICONIFY], g_stringlist[STR_ERRMPORT]])
ENDIF
ENDPROC
PROC chngfont(gui:PTR TO guihandle) HANDLE
DEF newfont=NIL
IF g_fontreq
IF AslRequest(g_fontreq, [ASLFO_WINDOW, gui.wnd,
TAG_DONE])
IF newfont:=OpenDiskFont(g_fontreq.attr)
closewin(gui)
changefont(gui, g_fontreq.attr)
openwin(gui)
ENDIF
ENDIF
ENDIF
EXCEPT DO
IF exception
IF exception = "bigg"
ezreq(0, g_stringlist[STR_REQERROR], g_stringlist[STR_ERRBIG])
CloseFont(newfont)
makegui()
ELSE
ReThrow()
ENDIF
ELSEIF newfont
replacestr(g_txtattr.name, g_fontreq.attr.name)
g_txtattr.ysize:=g_fontreq.attr.ysize
CloseFont(g_font)
g_font:=newfont
ENDIF
ENDPROC
PROC snapshot(gui:PTR TO guihandle)
DEF icon:PTR TO diskobject,
oldttlist:PTR TO LONG, newttlist[100]:ARRAY OF LONG, ttstr,
xstr[15]:STRING, ystr[15]:STRING, wstr[15]:STRING, hstr[15]:STRING,
i=0, ii=4, li
StringF(xstr, 'LEFTEDGE=\d', gui.wnd.leftedge)
StringF(ystr, 'TOPEDGE=\d', gui.wnd.topedge)
StringF(wstr, 'WIDTH=\d', gui.wnd.width)
StringF(hstr, 'HEIGHT=\d', gui.wnd.height)
icon:=GetDiskObjectNew(g_ohacname)
newttlist[0]:=xstr
newttlist[1]:=ystr
newttlist[2]:=wstr
newttlist[3]:=hstr
IF (oldttlist:=icon.tooltypes)
WHILE (ttstr:=oldttlist[i++])
IF ForAll({li}, ['LEFTEDGE', 'TOPEDGE', 'WIDTH', 'HEIGHT'], `InStr(ttstr, li)) THEN newttlist[ii++]:=ttstr
ENDWHILE
ENDIF
newttlist[ii]:=0
icon.tooltypes:=newttlist
PutDiskObject(g_ohacname, icon)
icon.tooltypes:=oldttlist
FreeDiskObject(icon)
ENDPROC
PROC about(gui:PTR TO guihandle)
/* Text is space-padded to avoid problems w/ MCP's auto-centering. */
ezreq(gui.wnd, g_stringlist[STR_REQABOUT], ' OHAC v1.3 \n'+
'(Oh Heck, Another Calendar!)\n\n'+
' by J. Tierney \n'+
' jtierney@cyberlink-inc.com \n\n'+
' Public Domain '+
'\n\s', NIL, [g_stringlist[STR_TXTCREDIT]])
ENDPROC
PROC quit() IS Raise(QUIT)
PROC datemenu(gui:PTR TO guihandle)
parsedate(gui.menutrigger.itemfill::intuitext.itext, g_caldate)
setcycle(gui, gad_month, g_caldate.month - 1)
setinteger(gui, gad_year, g_caldate.year)
g_cal.setdate()
dayreport(gui)
ENDPROC
PROC settoday(gui)
resetcal(SHIFT, 0, gui)
ENDPROC
PROC resettoday(gui)
syncdate(g_date)
dayreport(gui)
ENDPROC
CHAR '$VER: OHAC 1.3 (20.9.99) by J. Tierney', 0