COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

	Copyright (c) GeoWorks 1993	-- All Rights Reserved

PROJECT:	Zoomer
MODULE:		DatePicker
FILE:		datepick.def

AUTHOR:		John D. Mitchell

REVISION HISTORY:
	Name	Date		Description
	----	----		-----------
	JDM	93.05.25	Initial version.

DESCRIPTION:
	This is the global definition file for the DatePicker library.

	$Id: datepick.def,v 1.1 97/04/04 14:25:32 newdeal Exp $

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@

SetDef	__DATEPICKER

StartLibrary	datepick


COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
		Constant Definitions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@

;
; The following enum is used to specify the frequence of repeating events.
;
RepeatType			etype byte, 0 ,1
RT_none				enum RepeatType		; Non repeating.
RT_daily			enum RepeatType
RT_weekly			enum RepeatType
RT_monthlyByDay			enum RepeatType
RT_monthlyByDate		enum RepeatType
RT_yearly			enum RepeatType

;
; The following enum is used to specifiy the day of the month on which 
; repeating event occurrs.
;
DayOfMonth			etype byte, 0 ,1
DOM_firstSunday			enum DayOfMonth
DOM_firstMonday			enum DayOfMonth
DOM_firstTuesday		enum DayOfMonth
DOM_firstWednesday		enum DayOfMonth
DOM_firstThurday		enum DayOfMonth
DOM_firstFriday			enum DayOfMonth
DOM_firstSaturday		enum DayOfMonth
DOM_secondSunday		enum DayOfMonth
DOM_secondMonday		enum DayOfMonth
DOM_secondTuesday		enum DayOfMonth
DOM_secondWednesday		enum DayOfMonth
DOM_secondThurday		enum DayOfMonth
DOM_secondFriday		enum DayOfMonth
DOM_secondSaturday		enum DayOfMonth
DOM_thirdSunday			enum DayOfMonth
DOM_thirdMonday			enum DayOfMonth
DOM_thirdTuesday		enum DayOfMonth
DOM_thirdWednesday		enum DayOfMonth
DOM_thirdThurday		enum DayOfMonth
DOM_thirdFriday			enum DayOfMonth
DOM_thirdSaturday		enum DayOfMonth
DOM_fourthSunday		enum DayOfMonth
DOM_fourthMonday		enum DayOfMonth
DOM_fourthTuesday		enum DayOfMonth
DOM_fourthWednesday		enum DayOfMonth
DOM_fourthThurday		enum DayOfMonth
DOM_fourthFriday		enum DayOfMonth
DOM_fourthSaturday		enum DayOfMonth
DOM_lastSunday			enum DayOfMonth
DOM_lastMonday			enum DayOfMonth
DOM_lastTuesday			enum DayOfMonth
DOM_lastWednesday		enum DayOfMonth
DOM_lastThurday			enum DayOfMonth
DOM_lastFriday			enum DayOfMonth
DOM_lastSaturday		enum DayOfMonth

AdvanceNoticeType		etype byte, 0 ,1
ANT_minutes			enum AdvanceNoticeType
ANT_hours			enum AdvanceNoticeType
ANT_days			enum AdvanceNoticeType


COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
		Structure Types
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@

DateAndTime			struct
	DAT_year 		word
	DAT_month		byte
	DAT_day			byte
	DAT_hour		byte
	DAT_minute		byte   
DateAndTime			ends		


DateType			struct
	DT_year 		word
	DT_month		byte
	DT_day			byte
DateType			ends		


TimeType			struct
	TT_minute		byte   
	TT_hour			byte
TimeType			ends		

; This structure is uesed by the function GetNextRepeatDate.
;
RepeatInfo			struct
	RI_repeatType		RepeatType
	RI_repeatInterval	word
	RI_repeatDayOfMonth	DayOfMonth
	RI_start		DateType
	RI_end			DateType
	RI_current		DateType
	RI_startTime		TimeType
	RI_currentTime		TimeType
RepeatInfo			ends	


COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
		Date Stuff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@

global FixupDate:far
;
;	Description:	Takes an incremented date value and adjusts
;			it to a valid date.
;	Pass:		cx	- year
;			dh	- month
;			dl	- day
;	Return:		cx	- year
;			dh	- month
;			dl	- day
;	Destroyed:	nothing


global DayOfWeek:far
;
;	Description:	Returns the day of the Week (0-6) 0=Sunday, based
;			on the month, day, and year passed
;	Pass:		cx	- month
;			dh	- year (19xx)
;			dl	- day
;	Return:		dx	- day of the week
;	Destroyed:	nothing


global DaysInMonth:far
;
;	Description:	Returns the number of days in a month based 
;			on the month and year passed.
;	Pass:		ax	- month
;			bx	- year
;	Return:		cx	- number of days in the month
;	Destroyed:	nothing


global GetNextRepeatDate:far
;
;	Description:	Calculte the next occurrence of a repeating event.
;
;	Pass:		es:di	- pointer to RepeatInfo
;	Return:		ax	- year
;			bl	- month
;			bh	- day
;			carry set if no date calculated
;	Destroyed:	nothing


global DayOfMonthOfDate:far
;
;	Description:	Returns the day of a month (i.e. first friday) 
;			on which the specified date occurs.
;	Pass:		ax	- year
;			bl	- month
;			bh	- day
;	Return:		cx	- DayOfMonth
;	Destroyed:	nothing


global GetAdvanceDateAndTime:far
;
;	Description:	Adjust the date and time passed by the advance time
;			passed.  The advance time is subtracted from the 
;			date and time.
;
;	Pass:		ax	- year
;			bl 	- month (1 through 12)
;		        bh	- day (1 through 31)
;			cl	- hours (0-23)
;			ch	- minutes (0-59)
;			dl	- length of advance notice (5 minutes)
;			dh	- AdvanceNoticeType
;
;	Return:		ax	- adjusted year
;			bl 	- adjusted month (1 through 12)
;		        bh	- adjusted day (1 through 31)
;			cl	- adjusted hours (0-23)
;			ch	- adjusted minutes (0-59)
;	Destroyed:	nothing


global DateToJulianDay:far
;
;	Description:	Returns the number of days since 12/31/1899.
;	Pass:		ax	- year
;			bl	- month (1 through 12)
;			bh	- day (1 through 31)
;	Return:		cx	- number of days since 12/31/1899
;			carry set if date is outside valid range.
;	Destroyed:	nothing

;
; C stub versions:
;
global	DAYOFWEEK:far
global	DAYSINMONTH:far
global	DATETOJULIANDAY:far



COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
		Date Selector Class
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@

DateSelectorClass	class   GenInteractionClass

MSG_DATE_SELECTOR_GET_DATE			message
;
; Get the current day, month and year from the date selector.
;
; Pass:		nothing
; Return:	cx	- year (full year, ex: 1993)
;		dl	- month
;		dh	- day
; Destroy:	nothing	


MSG_DATE_SELECTOR_SET_DATE			message
;
; Set the current day, month and year of the date selector.  This
; message is send by the month gadget when the month gadget's selected
; day is changed. 
;
; Pass:		cx	- year (full year, ex: 1993)
;		dh	- month
;		dl	- day
; Return:	nothing
; Destroy:	nothing	


MSG_DATE_SELECTOR_SET_TO_TODAY			message
;
; Set the day, month and year of the date selector to today's date.
;
; Pass:		nothing
; Return:	nothing
; Destroy:	nothing


MSG_DATE_SELECTOR_CHANGE_DAY			message
;
; Change the day instance data of the DateSelector object.  This message is 
; sent by the MonthGadget object defined for changing the day.  To optr of 
; the MonthGadget object is stored in DSI_daySelector of the instance date.
;
; Source:	GenValue object
; Destination:	A DateSelector object.
; Pass:		dl	- day to set to
; Return:	nothing
; Destroy:	nothing

MSG_DATE_SELECTOR_CHANGE_MONTH			message
;
; Change the month display by the DateSelector object.  This message is 
; sent by the GenValue object defined for changing the month.  To optr of 
; the GenValue object is stored in DSI_monthSelector of the instance date.
;
; Source:	GenValue object
; Destination:	A DateSelector object.
; Pass:		dx	- month to set to
; Return:	nothing
; Destroy:	nothing

MSG_DATE_SELECTOR_CHANGE_YEAR			message
;
; Change the year display by the DateSelector object.  This message is 
; sent by the GenValue object defined for changing the year.  To optr of 
; the GenValue object is stored in DSI_yearSelector of the instance date.
;
; Source:	GenValue object
; Destination:	A DateSelector object.
; Pass:		dx	- year to set to
; Return:	nothing
; Destroy:	nothing


MSG_DATE_SELECTOR_SET_APPLY_ACTION		message
;
; Change the destination for the date selector.
;
; Pass:		cx:dx -- optr of destination object
;		bp    -- message to send on apply
; Return:	nothing
; Destroy:	nothing


MSG_DATE_SELECTOR_SET_YEAR_BOUNDS		message
;
; Set the range of allowable years for the date selector.
;
; Pass:		cx -- Minimum valid year.
;		dx -- Maximum valid year.
; Return:	nothing
; Destroys:	nothing


global	DATESELECTORGETDUPOBJECT:far
DateSelectorGetDupObject	equ	DATESELECTORGETDUPOBJECT
;
;	Description:	Get a DatePicker.
;	Pass:		Void.
;	Return:		DX:AX	- DatePicker optr.
;	Destroyed:	Nada.


    DSI_day		word		; Day highlighted.
    DSI_month		word		; Month to draw.
    DSI_year		word		; Year to draw.
    DSI_daySelector	optr		; MonthGadget for selecting day.
    DSI_monthSelector	optr		; GenValue for selecting month.
    DSI_yearSelector	optr		; GenValue for selecting year.

    DSI_destination	optr
	; Destination of apply messages sent out by the object.

    DSI_applyMsg	word	0
	; Message to send out to the destination on MSG_APPLY.
	; The arguments passed in the notify message are as follows:
	;
	; Pass:		cx - year
	;		dl - month
	;		dh - day
	; Return:	nothing
	;		ax, cx, dx, bp -- destroyed
	;
DateSelectorClass	endc


EndLibrary	datepick
