#!/bin/sh
# MetaCard 2.4 stack
# The following is not ASCII text,
# so now would be a good time to q out of more
exec mc $0 "$@"
altAnswerDateHarness 1 N U Tahoma U tahoma U Tahoma cREVGeneral @ N
Pick Date Epon mouseUp
put "2006" into tYear
put "8" into tMonth
put "12" into tDay
start using stack "calendarWidget100"
get altAnswerDate(tYear,tMonth,tDay)
stop using stack "calendarWidget100"
if it is empty then exit mouseUp
put it into fld 1
end mouseUp
; R cREVGeneral revUniqueID
1154780774494
Field )` d cREVGeneral revUniqueID
1154780876902 2006,8,10,5
description p 7on linkClicked pLink
revGoURL pLink
end linkClicked
b
cREVTable currentview
altAnswerDate
This is a free wrapper for Shao Sean'sfine calendarWidget which can be called simply like an answer dialog box. (Thanks again Shao for a great tool!!!!)
To use this stack, make the stack "calendarWidget100" a substack of your main stack. Then when you need to prompt the user for a date, you can put the following into a button script (like the one below):
on mouseUp
put "2006" into tYear
put "8" into tMonth
put "12" into tDay
start using stack "calendarWidget100"
get altAnswerDate(tYear,tMonth,tDay)
stop using stack "calendarWidget100"
if it is empty then exit mouseUp
put it into fld 1
end mouseUp
Note: If you like, you can insert the start using and stop using statements in your startup routine. This will keep the stack loaded in memory. Also, note you can force the calendar to open to a specific date. If you want it to open to today's date, then put "" into tYear, tMonth and tDay.
cREVGeneral revUniqueID
1154785407631 altAnswerDate
This is a free wrapper for Shao Sean'sfine calendarWidget which can be called simply like an answer dialog box. (Thanks again Shao for a great tool!!!!) To use this stack, make the stack "calendarWidget100" a substack of your main stack. Then when you need to prompt the user for a date, you can put the following into a button script (like the one below): on mouseUp
@
put "2006" into tYear
@
put "8" into tMonth
@
put "12" into tDay
@
( start using stack "calendarWidget100"
@
' get altAnswerDate(tYear,tMonth,tDay)
@
@ ' stop using stack "calendarWidget100"
@
# if it is empty then exit mouseUp
@
@
@
put it into fld 1
@
end mouseUp
@
#Note: If you like, you can insert the start using and stop using statements in your startup routine. This will keep the stack loaded in memory. Also, note you can force the calendar to open to a specific date. If you want it to open to today's date, then put "" into tYear, tMonth and tDay. ` @ `
description P 7on linkClicked pLink
revGoURL pLink
end linkClicked
7 B cREVGeneral revUniqueID
1154785712289 "returns 4 comma-delimitted items: mitem 1 is year, item 2 is month, item 3 is date, item 4 is day of the week (1 is Sunday, 2 is Monday, etc..) calendarWidget100 function altAnswerDate pYear,pMonth,pDate
put the name of me into tStack
--> SET UP
show me
set the uYear of group "calendarWidget" of tStack to pYear
set the uMonth of group "calendarWidget" of tStack to pMonth
set the uDate of group "calendarWidget" of tStack to pDate
send "calendarWidgetDraw" to group "calendarWidget" of tStack in 30 millisecs
modal me
return the dialogdata
end altAnswerDate
on stripAndShip
put "" into fld "log" of me
end stripAndShip
uDay 2 Choose a date
U Lucida Grande U usesystemfont U Lucida Grande W Lucida Grande
U Lucida Grande
W Lucida Grande @U Lucida Grande U Tahoma
U Tahoma cREVGeneral cREVGeometryCache stackID 1046 p
cREVGeneral cREVGeometryCacheIDs 1153549409546 10141154781135336 10461153570278846 10281153570234891 10261153560000051 10211153570189912 10251154781100540 10451153570300858 10311153570300743 10291153566368750 10231153555512396 10161153556736270 10171153570300828 10301153570544938 1033 cREVGeometrycache order
total 14 calendarWidget i## FILE INFORMATION
# File Name .....: Calendar Widget
# Version .......: 1.0.0
# Build Date ....: 2006-07-22
## AUTHOUR INFORMATION
# Written By ....: Shao Sean
# Email .........: support@shaosean.tk
# Website .......: www.shaosean.tk
## NOTE TO DEVELOPERS
# Any of the handlers/functions that start with a "z" are considered to be private
# and are called from within the public handlers.
## PUBLIC DOMAIN DISCLAIMER
# This software was developed by Shao Sean and is available for use by the public
# without need of a license.
## DISCLAIMER
# THE SOFTWARE AND RELATED MATERIALS ARE PROVIDED "AS-IS" WITHOUT WARRANTY OR INDEMNITY OF ANY KIND
# INCLUDING ANY WARRANTIES OF USE, PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE OR
# PURPOSE OR FOR ANY PURPOSE WHATSOEVER.
#
# USER BEARS ALL RISK RELATING TO USE, QUALITY AND PERFORMANCE OF THE SOFTWARE.
constant kFieldName = "calendarWidgetField" -- change this to match the name of the field
local sOldClickChunk
-------------------------------------------------------------------------------------------------
-- Commands to control the calendar display
--
-- calendarWidgetDraw .......... draws the calendar based on the year, month and date stored
-- calendarWidgetNextMonth ..... redraws the calendar moving to the next month (wraps around on month 12)
-- calendarWidgetPreviousMonth . redraws the calendar moving to the previous mont (wraps around on month 1)
-- calendarWidgetNextYear ...... redraws the calendar moving to the next year (see centuryCutoff for limitations)
-- calendarWidgetPreviousYear .. redraws the calendar moving to the previous year (see centuryCuttoff for limitations)
-------------------------------------------------------------------------------------------------
on calendarWidgetDraw
local tWidgetText
lock screen
zCalendarWidgetSetDateItems
--- build the calendar header
repeat for each line tWeekdayName in the system weekdayNames
put char 1 of tWeekdayName & TAB after tWidgetText
end repeat
if (the last char of tWidgetText = TAB) then delete char -1 of tWidgetText
put LF after tWidgetText
--- build the calendar
repeat (the uMonthStart of me - 1)
put TAB after tWidgetText
end repeat
repeat with i = 1 to zCalendarWidgetNumberOfDays()
put i & TAB after tWidgetText
end repeat
if (the last char of tWidgetText = TAB) then delete char -1 of tWidgetText
put tWidgetText into field kFieldName --- populate the calendar widget
zCalendarWidgetSelect the uDate of me --- hilite the day selected
try
calendarWidgetUpdated the uYear of me, the uMonth of me, the uDate of me, the uDay of me -- callback
catch tError
end try
end calendarWidgetDraw
on calendarWidgetNextMonth
local tYear
local tMonth
put the uYear of me into tYear
put the uMonth of me into tMonth
if (tMonth = 12) then
add 1 to tYear
put 1 into tMonth
else add 1 to tMonth
set the uYear of me to tYear
set the uMonth of me to tMonth
calendarWidgetDraw
end calendarWidgetNextMonth
on calendarWidgetPreviousMonth
local tYear
local tMonth
put the uYear of me into tYear
put the uMonth of me into tMonth
if (tMonth = 1) then
subtract 1 from tYear
put 12 into tMonth
else subtract 1 from tMonth
set the uYear of me to tYear
set the uMonth of me to tMonth
calendarWidgetDraw
end calendarWidgetPreviousMonth
on calendarWidgetNextYear
local tYear
put the uYear of me into tYear
add 1 to tYear
set the uYear of me to tYear
calendarWidgetDraw
end calendarWidgetNextYear
on calendarWidgetPreviousYear
local tYear
put the uYear of me into tYear
subtract 1 from tYear
set the uYear of me to tYear
calendarWidgetDraw
end calendarWidgetPreviousYear
-------------------------------------------------------------------------------------------------
-- Handle user input (mouse and keyboard)
-------------------------------------------------------------------------------------------------
on mouseUp
lock screen
if (word 2 of the clickLine = 1) OR (the clickChunk is EMPTY) then
if (sOldClickChunk is not EMPTY) then
set the backgroundColor of sOldClickChunk to (the effective hiliteColor)
end if
else zCalendarWidgetSelect the clickText
end mouseUp
on arrowKey pKey
local tToken
switch
case (pKey = "up") AND (the uDate of me > 7)
put (the uDate of me - 7) into tToken
break
case (pKey = "down") AND (the uDate of me < zCalendarWidgetNumberOfDays() - 6)
put (the uDate of me + 7) into tToken
break
case (pKey = "left") AND (the uDate of me > 1)
put (the uDate of me - 1) into tToken
break
case (pKey = "right") AND (the uDate of me < zCalendarWidgetNumberOfDays())
put (the uDate of me + 1) into tToken
break
end switch
if (tToken is not EMPTY) then
zCalendarWidgetSetDateItems
zCalendarWidgetSelect tToken
end if
end arrowKey
-------------------------------------------------------------------------------------------------
-- Private commands.. *shoo* Go away ;-)
-------------------------------------------------------------------------------------------------
on zCalendarWidgetSelect pToken
if (sOldClickChunk is not EMPTY) then
set the backgroundColor of sOldClickChunk to EMPTY
end if
select EMPTY
set the itemDelimiter to TAB
select item (the uMonthStart of me + pToken + 5) of fld kFieldName
set the uDate of me to (the selectedText)
set the uDay of me to (the uMonthStart of me + pToken + 5) mod 7 +1
set the backgroundColor of the selectedChunk to (the effective hiliteColor)
put the selectedChunk into sOldClickChunk
try
calendarWidgetDateChanged the uYear of me, the uMonth of me, the uDate of me, the uDay of me
catch tError
end try
end zCalendarWidgetSelect
function zCalendarWidgetNumberOfDays
if (the uMonth of me is among the items "1,3,5,7,8,10,12") then
return 31
else if (the uMonth of me is among the items "4,6,9,11") then
return 30
else if ((the uYear of me MOD 400 = 0) OR ((the uYear of me MOD 100 <> 0) AND (the uYear of me MOD 4 = 0))) then
return 29
else return 28
end zCalendarWidgetNumberOfDays
on zCalendarWidgetSetDateItems
--- get today's dateItems
if (the uYear of me is EMPTY) OR (the uMonth of me is EMPTY) OR (the uDate of me is EMPTY) then
convert the seconds to dateItems
set the uYear of me to item 1 of it
set the uMonth of me to item 2 of it
set the uDate of me to item 3 of it
set the uDay of me to item 7 of it
else
convert (the uYear of me,the uMonth of me,the uDate of me,3,59,59,0) from dateItems to seconds
convert it from seconds to dateItems
set the uDay of me to item 7 of it
end if
--- get the month's start day
convert (the uYear of me,the uMonth of me,1,3,59,59,0) from dateItems to seconds
convert it from seconds to dateItems
set the uMonthStart of me to item 7 of it
end zCalendarWidgetSetDateItems
--> MOVED FROM CARD BY CHIPP
on calendarWidgetDateChanged pYear, pMonth, pDate, pDay
put pYear, pMonth, pDate, pDay & LF before fld "log"
end calendarWidgetDateChanged
on calendarWidgetUpdated pYear, pMonth, pDate, pDay
lock screen
put pYear into fld "year"
put line pMonth of the system monthNames into field "month"
end calendarWidgetUpdated
* n uMonthStart 3uDay 7uDate 12uMonth 8uYear 2006 cREVGeneral revUniqueID
1153560000051
Rectangle K@ . ~ e cREVGeneral revUniqueID
1153556736270 Button @g @ . ~ cREVGeneral revUniqueID
1153555512396
calendarWidgetField (" @ . ~ f
cREVTable currentvscroll 0currenthscroll 0currentxmouseloc 72
viewablerows 9currentymouseloc 24scrollbarwidth 20
cellyspacing 13rightfieldloc 264viewablecolumns 9numbertabstops 1topfieldloc 63
leftfieldloc 114
cellxspacing 18currentview 3S M T W T F S
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
4
bottomfieldloc 179 cREVGeneral revUniqueID
1153549409546 S M T W T F S V 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
33^^
9 Go To Today Ex
on mouseUp
set the uYear of group "calendarWidget" to ""
set the uMonth of group "calendarWidget" to ""
set the uDate of group "calendarWidget" to ""
send "calendarWidgetDraw" to group "calendarWidget"
end mouseUp
x cREVGeneral revUniqueID
1153566368750 previousMonth e Won mouseUp
send "calendarWidgetPreviousMonth" to group "calendarWidget"
end mouseUp
Previous Month <