home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Bila Vrana
/
BILA_VRANA.iso
/
028A
/
AUROR.ZIP
/
CALEN4.AML
< prev
next >
Wrap
Text File
|
1996-07-17
|
5KB
|
247 lines
//--------------------------------------------------------------------
// CALEN4.AML
// Four-month Calendar, (C) 1993-1996 by nuText Systems
//
// (See Calen4.dox for user help)
//
// This macro displays a calendar window with four months, starting with
// the previous month. The current day is highlighted.
//
// This macro also calls Cfg\Cfgintnl.x
//
// Usage:
//
// Select this macro from the Macro List (on the Macro menu), or run it
// from the macro picklist <shift f12>.
//--------------------------------------------------------------------
include bootpath "define.aml"
// define the colors to use
constant cal_border_color = color white on gray
constant cal_bordera_color = color brightgreen on gray
constant cal_title_color = color brightblue on gray
constant cal_client_color = color black on gray
constant cal_today_color = color brightgreen on gray
constant cal_control_color = color yellow
variable year, month
// create the calendar window
createwindow
setframe ">b"
setwinctrl '≡'
setshadow 2 1
sizewindow 3 4 75 20 "ad"
setborder "1i"
settitle "Four Month Calendar" 'c'
setcolor border_color cal_border_color
setcolor border_flash_color cal_bordera_color
setcolor text_color cal_client_color
setcolor control_color cal_control_color
// current year and month
year = getrawtime [1:4]
month = getrawtime [5:2]
// keep this object resident
resident ON
settype "win"
constant daynames = 1
constant monthnames = 2
// get day and month names
names = runmacro (bootpath "cfg\\cfgintnl.x") '' 'n'
months = names.monthnames
dayheader = ' '
for i = 1 to 7 do
dayheader = dayheader + names.daynames [i][1..3] + ' '
end
// function to redraw the calendar at x,y on the screen
private function draw (x y)
variable monthdays
// save the x coordinate
xleft = x
// set the calendar title based on the year and month
title = months [month] + " " + year
writestr '' : ((35 - length title) / 2) + title:-35
cal_border_color x y
y = y + 1
// get the day in which the year starts using a perpetual
// calendar (0-6, 0=sunday)
startday = "5012356013456123460124560234" [year mod 28 + 1]
// string indicating the days over 28 for each month
over28 = concat (if? (not (year mod 4)) "31" "30") "3232332323"
// get total days in the month
maxdays = 28 + over28 [month]
// get the number of days in previous months
for i = 1 to month - 1 do
monthdays = monthdays + 28 + over28 [i]
end
// calculate the starting day for the month (0-6, 0=sunday)
startday = (startday + monthdays) mod 7
// set 'today' to today's day number if it's the right
// year and month
rawtime = getrawtime
today = if rawtime [5:2] == month and rawtime [1:4] == year then
rawtime [7:2]
end
// draw the days header
writestr dayheader cal_title_color x y
y = y + 1
// move the video cursor to the start-day position
daystr = '':(startday * 5)
xrem = 0
yfirst = y
// write the calendar body
for day = 1 to maxdays do
if length daystr + xrem >= 35 then
writestr daystr cal_client_color x y
x = xleft
y = y + 1
daystr = ''
xrem = 0
end
// highlight today
if day == today then
if daystr then
writestr daystr cal_client_color x y
end
todaystr = concat ' ' day:3 ' '
writestr todaystr cal_today_color xleft + length daystr y
xrem = length daystr + length todaystr
x = x + xrem
daystr = ''
else
daystr = concat daystr ' 'day:3 ' '
end
end
// write last incomplete calendar line, if any
if daystr then
writestr daystr:-35 cal_client_color x y
y = y + 1
end
// write last blank line, if any
if y - yfirst < 6 then
writestr '':35 cal_client_color x y
end
// set month and year for next time around
month = month + 1
if month > 12 then
month = 1
year = year + 1
end
end
// draw four calander windows
private function draw4
fillrect (getviewcols) (getviewrows) ' ' 1 1
month2 = month
year2 = year
draw 1 1
draw 38 1
draw 1 10
draw 38 10
month = month2
year = year2
end
// get the current year and month
year = getrawtime [1:4]
month = getrawtime [5:2]
// get the previous month
month = month - 1
if not month then
month = 12
year = year - 1
end
draw4
event <destroy>
// call 'close' in object 'win'
close
end
// macro help
macrofile = arg 1
key <f1>
helpmacro macrofile
end
function "≡" destroyobject
key <esc> destroyobject
// forward one month
key <pgdn>
month = month + 1
if month > 12 then
month = 1
year = year + 1
end
draw4
end
// backward one month
key <pgup>
month = month - 1
if not month then
month = 12
year = year - 1
end
draw4
end
// goto january
key <ctrl pgup>
month = 1
draw4
end
// goto december
key <ctrl pgdn>
month = 12
draw4
end
// forward one year
key <right>
year = year + 1
draw4
end
// backward one year
key <left>
if year then
year = year - 1
end
draw4
end