154
// What is the first day of this month?
155
tempTime := CFGregorianDateGetAbsoluteTime( inData.date, inData.timeZone );
156
inData.firstDay := CFAbsoluteTimeGetDayOfWeek( tempTime, inData.timeZone ) mod 7;
153
// What is the first day of this month?
154
tempTime := CFGregorianDateGetAbsoluteTime( inData.date, inData.timeZone );
155
inData.firstDay := CFAbsoluteTimeGetDayOfWeek( tempTime, inData.timeZone ) mod 7;
158
// How many days in this month?
159
tempTime := CFAbsoluteTimeAddGregorianUnits( tempTime, inData.timeZone, nextMonthMinusADay );
160
tempDate := CFAbsoluteTimeGetGregorianDate( tempTime, inData.timeZone );
161
inData.daysInMonth := tempDate.day;
157
// How many days in this month?
158
tempTime := CFAbsoluteTimeAddGregorianUnits( tempTime, inData.timeZone, nextMonthMinusADay );
159
tempDate := CFAbsoluteTimeGetGregorianDate( tempTime, inData.timeZone );
160
inData.daysInMonth := tempDate.day;
164
163
// -----------------------------------------------------------------------------
724
Result := GetEventParameter( inEvent, kEventParamControlPart, typeControlPartCode, nil, sizeof( ControlPartCode ), nil, @part );
725
if Result <> noErr then Exit;
727
Result := GetEventParameter( inEvent, kEventParamControlDataTag, typeEnumeration, nil, sizeof( OSType ), nil, @tag );
728
if Result <> noErr then Exit;
730
Result := GetEventParameter( inEvent, kEventParamControlDataBuffer, typePtr, nil, sizeof( Ptr ), nil, @ptr );
731
if Result <> noErr then Exit;
733
Result := GetEventParameter( inEvent, kEventParamControlDataBufferSize, typeLongInteger, nil, sizeof( Size ), nil, @sz );
734
if Result <> noErr then Exit;
737
kControlCalendarTitleRatioTag:
739
if sz = sizeof( single ) then
740
PSingle(ptr)^ := inData.titleRowRatio
742
Result := errDataSizeMismatch;
743
outSize := sizeof( single);
746
kControlCalendarDayNameRatioTag:
748
if sz = sizeof( single ) then
749
PSingle(ptr)^ := inData.dayNameRowRatio
751
Result := errDataSizeMismatch;
752
outSize := sizeof( single );
755
kControlCalendarDayRatioTag:
757
if ( sz = sizeof( single ) ) then
758
PSingle(ptr)^ := inData.dayRowRatio
760
Result := errDataSizeMismatch;
761
outSize := sizeof( single );
764
kControlCalendarDateTag:
766
if sz = sizeof( CFGregorianDate ) then begin
767
CFGregorianDatePtr(ptr)^ := inData.date;
768
if (inData.selDay>0) and (inData.selDay<inData.daysInMonth) then
723
Result := GetEventParameter( inEvent, kEventParamControlPart, typeControlPartCode, nil, sizeof( ControlPartCode ), nil, @part );
724
if Result <> noErr then Exit;
726
Result := GetEventParameter( inEvent, kEventParamControlDataTag, typeEnumeration, nil, sizeof( OSType ), nil, @tag );
727
if Result <> noErr then Exit;
729
Result := GetEventParameter( inEvent, kEventParamControlDataBuffer, typePtr, nil, sizeof( Ptr ), nil, @ptr );
730
if Result <> noErr then Exit;
732
Result := GetEventParameter( inEvent, kEventParamControlDataBufferSize, typeLongInteger, nil, sizeof( Size ), nil, @sz );
733
if Result <> noErr then Exit;
736
kControlCalendarTitleRatioTag:
738
if sz = sizeof( single ) then
739
PSingle(ptr)^ := inData.titleRowRatio
741
Result := errDataSizeMismatch;
742
outSize := sizeof( single);
745
kControlCalendarDayNameRatioTag:
747
if sz = sizeof( single ) then
748
PSingle(ptr)^ := inData.dayNameRowRatio
750
Result := errDataSizeMismatch;
751
outSize := sizeof( single );
754
kControlCalendarDayRatioTag:
756
if ( sz = sizeof( single ) ) then
757
PSingle(ptr)^ := inData.dayRowRatio
759
Result := errDataSizeMismatch;
760
outSize := sizeof( single );
763
kControlCalendarDateTag:
765
if sz = sizeof( CFGregorianDate ) then
767
CFGregorianDatePtr(ptr)^ := inData.date;
768
if (inData.selDay>0) and (inData.selDay<=inData.daysInMonth) then
769
769
CFGregorianDatePtr(ptr)^.day := inData.selDay;
771
Result := errDataSizeMismatch;
772
outSize := sizeof( CFGregorianDate );
772
Result := errDataSizeMismatch;
773
outSize := sizeof( CFGregorianDate );
775
kControlCalendarDrawProcTag:
776
kControlCalendarDrawProcTag:
777
if sz =sizeof( CalendarDrawProc ) then
778
if sz =sizeof( CalendarDrawProc ) then
778
779
CalendarDrawProc(Ptr^):=inData.drawProc
780
Result := errDataSizeMismatch;
781
outSize := sizeof( CalendarDrawProc );
781
Result := errDataSizeMismatch;
782
outSize := sizeof( CalendarDrawProc );
784
kControlCalendarLabelProcTag:
785
kControlCalendarLabelProcTag:
786
if sz = sizeof( CalendarDrawProc ) then
787
if sz = sizeof( CalendarDrawProc ) then
787
788
CalendarDrawProc(Ptr^):=inData.labelProc
789
Result := errDataSizeMismatch;
790
outSize := sizeof( CalendarDrawProc );
790
Result := errDataSizeMismatch;
791
outSize := sizeof( CalendarDrawProc );
794
Result := errDataNotSupported;
795
Result := errDataNotSupported;
798
if ( Result = noErr ) then
799
Result := SetEventParameter( inEvent, kEventParamControlDataBufferSize, typeLongInteger, sizeof( sz ), @outSize );
799
if ( Result = noErr ) then
800
Result := SetEventParameter( inEvent, kEventParamControlDataBufferSize, typeLongInteger, sizeof( sz ), @outSize );
802
803
// -----------------------------------------------------------------------------
987
988
function CalendarViewCreate(inWindow : WindowRef; const inBounds : Rect; var outControl: ControlRef): OSStatus;
992
993
BounName : PChar = 'Boun';
994
// Make sure this type of view is registered
995
Result := CalendarViewRegister;
995
// Make sure this type of view is registered
996
Result := CalendarViewRegister;
996
997
if Result <> noErr then Exit;
998
// Make the initialization event
999
Result := CreateEvent(nil, kEventClassHIObject, kEventHIObjectInitialize, GetCurrentEventTime(), 0, event );
999
// Make the initialization event
1000
Result := CreateEvent(nil, kEventClassHIObject, kEventHIObjectInitialize, GetCurrentEventTime(), 0, event {%H-});
1000
1001
if Result <> noErr then Exit;
1002
// Set the bounds into the event
1003
Result := SetEventParameter( event, EventParamNamePtr(BounName)^, typeQDRectangle, sizeof( Rect ), @inBounds );
1004
if Result <> noErr then Exit;
1006
Result := HIObjectCreate( kCalendarViewClassID, event, outControl );
1007
if Result <> noErr then Exit;
1009
// Get the content root
1010
Result := GetRootControl( inWindow, root );
1003
// Set the bounds into the event
1004
Result := SetEventParameter( event, EventParamNamePtr(BounName)^, typeQDRectangle, sizeof( Rect ), @inBounds );
1005
if Result <> noErr then Exit;
1007
Result := HIObjectCreate( kCalendarViewClassID, event, outControl );
1008
if Result <> noErr then Exit;
1010
// Get the content root
1011
Result := GetRootControl( inWindow, root {%H-});
1011
1012
if Result <> noErr then Exit;
1014
1015
//HIViewFindByID(root, kHIViewWindowContentID, root);
1016
// And stick this view into it
1017
Result := HIViewAddSubview( root, outControl );
1017
// And stick this view into it
1018
Result := HIViewAddSubview( root, outControl );
1019
1020
ReleaseEvent(event);