~ubuntu-branches/ubuntu/saucy/lazarus/saucy

« back to all changes in this revision

Viewing changes to lcl/interfaces/carbon/carboncalendarview.pas

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Bart Martens, Paul Gevers
  • Date: 2013-06-08 14:12:17 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20130608141217-7k0cy9id8ifcnutc
Tags: 1.0.8+dfsg-1
[ Abou Al Montacir ]
* New upstream major release and multiple maintenace release offering many
  fixes and new features marking a new milestone for the Lazarus development
  and its stability level.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_fixes_branch
* LCL changes:
  - LCL is now a normal package.
      + Platform independent parts of the LCL are now in the package LCLBase
      + LCL is automatically recompiled when switching the target platform,
        unless pre-compiled binaries for this target are already installed.
      + No impact on existing projects.
      + Linker options needed by LCL are no more added to projects that do
        not use the LCL package.
  - Minor changes in LCL basic classes behaviour
      + TCustomForm.Create raises an exception if a form resource is not
        found.
      + TNotebook and TPage: a new implementation of these classes was added.
      + TDBNavigator: It is now possible to have focusable buttons by setting
        Options = [navFocusableButtons] and TabStop = True, useful for
        accessibility and for devices with neither mouse nor touch screen.
      + Names of TControlBorderSpacing.GetSideSpace and GetSpace were swapped
        and are now consistent. GetSideSpace = Around + GetSpace.
      + TForm.WindowState=wsFullscreen was added
      + TCanvas.TextFitInfo was added to calculate how many characters will
        fit into a specified Width. Useful for word-wrapping calculations.
      + TControl.GetColorResolvingParent and
        TControl.GetRGBColorResolvingParent were added, simplifying the work
        to obtain the final color of the control while resolving clDefault
        and the ParentColor.
      + LCLIntf.GetTextExtentExPoint now has a good default implementation
        which works in any platform not providing a specific implementation.
        However, Widgetset specific implementation is better, when available.
      + TTabControl was reorganized. Now it has the correct class hierarchy
        and inherits from TCustomTabControl as it should.
  - New unit in the LCL:
      + lazdialogs.pas: adds non-native versions of various native dialogs,
        for example TLazOpenDialog, TLazSaveDialog, TLazSelectDirectoryDialog.
        It is used by widgetsets which either do not have a native dialog, or
        do not wish to use it because it is limited. These dialogs can also be
        used by user applications directly.
      + lazdeviceapis.pas: offers an interface to more hardware devices such
        as the accelerometer, GPS, etc. See LazDeviceAPIs
      + lazcanvas.pas: provides a TFPImageCanvas descendent implementing
        drawing in a LCL-compatible way, but 100% in Pascal.
      + lazregions.pas. LazRegions is a wholly Pascal implementation of
        regions for canvas clipping, event clipping, finding in which control
        of a region tree one an event should reach, for drawing polygons, etc.
      + customdrawncontrols.pas, customdrawndrawers.pas,
        customdrawn_common.pas, customdrawn_android.pas and
        customdrawn_winxp.pas: are the Lazarus Custom Drawn Controls -controls
        which imitate the standard LCL ones, but with the difference that they
        are non-native and support skinning.
  - New APIs added to the LCL to improve support of accessibility software
    such as screen readers.
* IDE changes:
  - Many improvments.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/New_IDE_features_since#v1.0_.282012-08-29.29
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes#IDE_Changes
* Debugger / Editor changes:
  - Added pascal sources and breakpoints to the disassembler
  - Added threads dialog.
* Components changes:
  - TAChart: many fixes and new features
  - CodeTool: support Delphi style generics and new syntax extensions.
  - AggPas: removed to honor free licencing. (Closes: Bug#708695)
[Bart Martens]
* New debian/watch file fixing issues with upstream RC release.
[Abou Al Montacir]
* Avoid changing files in .pc hidden directory, these are used by quilt for
  internal purpose and could lead to surprises during build.
[Paul Gevers]
* Updated get-orig-source target and it compinion script orig-tar.sh so that they
  repack the source file, allowing bug 708695 to be fixed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
{ $Id: $
2
 
                  --------------------------------------------
 
1
{                 --------------------------------------------
3
2
                  carbonprivate.pp  -  Carbon internal classes
4
3
                  --------------------------------------------
5
4
 
151
150
                minutes:=0;
152
151
                seconds:=0;
153
152
  end;
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;
157
156
 
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;
162
161
end;
163
162
 
164
163
// -----------------------------------------------------------------------------
186
185
    end
187
186
  else
188
187
        if (inData.hilitePart > 0) and (inData.hilitePart = inPart) then begin
189
 
      GetThemeBrushAsColor( kThemeBrushPrimaryHighlightColor, 32, true, color );
 
188
      GetThemeBrushAsColor( kThemeBrushPrimaryHighlightColor, 32, true, color {%H-});
190
189
      CGContextSetRGBFillColor( inData.context, color.red / 65536, color.green / 65536, color.blue / 65536, 1 );
191
190
      CGContextFillRect(inData.context, inPartRect );
192
191
    end;
357
356
//      CalendarViewDestruct
358
357
// -----------------------------------------------------------------------------
359
358
//
360
 
function CalendarViewDestruct(inEvent : EventRef; var inData : CalendarViewDataPtr): OSStatus;
 
359
function CalendarViewDestruct({%H-}inEvent : EventRef; var inData : CalendarViewDataPtr): OSStatus;
361
360
begin
362
361
  //#pragma unused( inEvent )
363
362
        // Clean up any allocated data
395
394
            nil, sizeof( CGContextRef ), nil, @drawData.context );
396
395
  if Result <> noErr then Exit;  
397
396
 
398
 
        Result := HIViewGetBounds( inData.view, bounds );
 
397
        Result := HIViewGetBounds( inData.view, bounds {%H-});
399
398
 
400
399
  // highlighting only selected day
401
400
        //drawData.hilitePart := GetControlHilite( inData.view );
600
599
                        nil, sizeof( HIPoint ), nil, @where );
601
600
  if Result <> noErr then Exit;
602
601
 
603
 
        HIViewGetBounds( inData.view, bounds );
 
602
        HIViewGetBounds( inData.view, bounds {%H-});
604
603
 
605
604
        part := FindPart(bounds, where, inData );
606
605
 
629
628
                        niL, sizeof( HIPoint ), nil, @where );
630
629
  if Result <> noErr then Exit;
631
630
 
632
 
        Result := HIViewGetBounds( inData.view, bounds );
 
631
        Result := HIViewGetBounds( inData.view, bounds {%H-});
633
632
        
634
633
        startHilite := GetControlHilite( inData.view );
635
634
        
647
646
                lastPart := part;
648
647
 
649
648
    //TODO!!!!!!
650
 
                Result := TrackMouseLocation( GrafPtr(-1), qdPt, mouseResult );
 
649
                Result := TrackMouseLocation( GrafPtr(-1), qdPt{%H-}, mouseResult {%H-});
651
650
 
652
651
                // Need to convert from global
653
652
                QDGlobalToLocalPoint( GetWindowPort( GetControlOwner( inData.view ) ), qdPt );
670
669
 
671
670
        if ( lastPart >= kCalendarPreviousYearPart) and (lastPart <= kCalendarNextYearPart ) then
672
671
  begin
673
 
    FillChar(dateChange, sizeof(dateChange), 0);                
 
672
    FillChar(dateChange{%H-}, sizeof(dateChange), 0);
674
673
 
675
674
                tempTime := CFGregorianDateGetAbsoluteTime( inData.date, inData.timeZone );
676
675
 
699
698
//      CalendarViewChanged
700
699
// -----------------------------------------------------------------------------
701
700
//
702
 
function CalendarViewChanged(inEvent :EventRef; const inData: CalendarViewData): OSStatus;
 
701
function CalendarViewChanged({%H-}inEvent :EventRef; const inData: CalendarViewData): OSStatus;
703
702
begin
704
703
  //#pragma unused( inEvent )
705
704
        //Status                        err = noErr;
721
720
        sz      : Size;
722
721
        outSize : Size;
723
722
begin
724
 
        Result := GetEventParameter( inEvent, kEventParamControlPart, typeControlPartCode,      nil, sizeof( ControlPartCode ), nil, @part );
725
 
  if Result <> noErr then Exit;
726
 
 
727
 
        Result := GetEventParameter( inEvent, kEventParamControlDataTag, typeEnumeration, nil, sizeof( OSType ), nil, @tag );
728
 
  if Result <> noErr then Exit;
729
 
 
730
 
        Result := GetEventParameter( inEvent, kEventParamControlDataBuffer, typePtr, nil, sizeof( Ptr ), nil, @ptr );
731
 
  if Result <> noErr then Exit;
732
 
 
733
 
        Result := GetEventParameter( inEvent, kEventParamControlDataBufferSize, typeLongInteger, nil, sizeof( Size ), nil, @sz );
734
 
        if Result <> noErr then Exit;
735
 
 
736
 
        case tag of
737
 
                kControlCalendarTitleRatioTag:
738
 
    begin
739
 
                        if sz = sizeof( single ) then
740
 
                                PSingle(ptr)^ := inData.titleRowRatio
741
 
                        else
742
 
                                Result := errDataSizeMismatch;
743
 
                        outSize := sizeof( single);
744
 
                end;
745
 
 
746
 
                kControlCalendarDayNameRatioTag:
747
 
    begin
748
 
        if sz = sizeof( single ) then
749
 
                                PSingle(ptr)^ := inData.dayNameRowRatio
750
 
                        else
751
 
                                Result := errDataSizeMismatch;
752
 
                        outSize := sizeof( single );
753
 
    end;
754
 
 
755
 
                kControlCalendarDayRatioTag:
756
 
    begin
757
 
                        if ( sz = sizeof( single ) ) then
758
 
                                PSingle(ptr)^ := inData.dayRowRatio
759
 
                        else
760
 
                                Result := errDataSizeMismatch;
761
 
                        outSize := sizeof( single );
762
 
                end;
763
 
 
764
 
                kControlCalendarDateTag:
765
 
    begin
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;
 
725
 
 
726
  Result := GetEventParameter( inEvent, kEventParamControlDataTag, typeEnumeration, nil, sizeof( OSType ), nil, @tag );
 
727
  if Result <> noErr then Exit;
 
728
 
 
729
  Result := GetEventParameter( inEvent, kEventParamControlDataBuffer, typePtr, nil, sizeof( Ptr ), nil, @ptr );
 
730
  if Result <> noErr then Exit;
 
731
 
 
732
  Result := GetEventParameter( inEvent, kEventParamControlDataBufferSize, typeLongInteger, nil, sizeof( Size ), nil, @sz );
 
733
  if Result <> noErr then Exit;
 
734
 
 
735
  case tag of
 
736
    kControlCalendarTitleRatioTag:
 
737
    begin
 
738
      if sz = sizeof( single ) then
 
739
        PSingle(ptr)^ := inData.titleRowRatio
 
740
      else
 
741
        Result := errDataSizeMismatch;
 
742
      outSize := sizeof( single);
 
743
    end;
 
744
 
 
745
    kControlCalendarDayNameRatioTag:
 
746
    begin
 
747
      if sz = sizeof( single ) then
 
748
        PSingle(ptr)^ := inData.dayNameRowRatio
 
749
      else
 
750
        Result := errDataSizeMismatch;
 
751
      outSize := sizeof( single );
 
752
    end;
 
753
 
 
754
    kControlCalendarDayRatioTag:
 
755
    begin
 
756
      if ( sz = sizeof( single ) ) then
 
757
        PSingle(ptr)^ := inData.dayRowRatio
 
758
      else
 
759
        Result := errDataSizeMismatch;
 
760
      outSize := sizeof( single );
 
761
    end;
 
762
 
 
763
    kControlCalendarDateTag:
 
764
    begin
 
765
      if sz = sizeof( CFGregorianDate ) then
 
766
      begin
 
767
        CFGregorianDatePtr(ptr)^ := inData.date;
 
768
        if (inData.selDay>0) and (inData.selDay<=inData.daysInMonth) then
769
769
          CFGregorianDatePtr(ptr)^.day := inData.selDay;
770
 
                        end else
771
 
                                Result := errDataSizeMismatch;
772
 
                        outSize := sizeof( CFGregorianDate );
773
 
                end;
 
770
      end
 
771
      else
 
772
        Result := errDataSizeMismatch;
 
773
      outSize := sizeof( CFGregorianDate );
 
774
    end;
774
775
 
775
 
                kControlCalendarDrawProcTag:
 
776
    kControlCalendarDrawProcTag:
776
777
    begin
777
 
                        if sz =sizeof( CalendarDrawProc ) then
 
778
      if sz =sizeof( CalendarDrawProc ) then
778
779
        CalendarDrawProc(Ptr^):=inData.drawProc
779
 
                        else
780
 
                                Result := errDataSizeMismatch;
781
 
                        outSize := sizeof( CalendarDrawProc );
782
 
                end;
 
780
      else
 
781
        Result := errDataSizeMismatch;
 
782
      outSize := sizeof( CalendarDrawProc );
 
783
    end;
783
784
 
784
 
                kControlCalendarLabelProcTag:
 
785
    kControlCalendarLabelProcTag:
785
786
    begin
786
 
                        if sz = sizeof( CalendarDrawProc ) then
 
787
      if sz = sizeof( CalendarDrawProc ) then
787
788
        CalendarDrawProc(Ptr^):=inData.labelProc
788
 
                        else
789
 
                                Result := errDataSizeMismatch;
790
 
                        outSize := sizeof( CalendarDrawProc );
791
 
                end;
 
789
      else
 
790
        Result := errDataSizeMismatch;
 
791
      outSize := sizeof( CalendarDrawProc );
 
792
    end;
792
793
 
793
794
  else
794
 
        Result := errDataNotSupported;
795
 
                outSize := 0;
796
 
        end;
 
795
    Result := errDataNotSupported;
 
796
    outSize := 0;
 
797
  end;
797
798
 
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 );
800
801
end;
801
802
 
802
803
// -----------------------------------------------------------------------------
888
889
        Result := GetEventParameter( inEvent, kEventParamControlPart, typeControlPartCode, nil, sizeof( ControlPartCode ), nil, @part );
889
890
        if Result <> noErr then Exit;
890
891
 
891
 
  HIViewGetBounds(inData.view, bounds);
 
892
  HIViewGetBounds(inData.view, bounds{%H-});
892
893
  outShape:=HIShapeCreateWithRect(bounds);
893
894
  Result := SetEventParameter(inEvent, kEventParamShape, typeHIShapeRef, sizeof(HIShapeRef), @outShape);
894
895
  CFRelease(outShape);
986
987
 
987
988
function CalendarViewCreate(inWindow : WindowRef; const inBounds : Rect; var outControl: ControlRef): OSStatus;
988
989
var
989
 
        root  : ControlRef;
990
 
        event : EventRef;
 
990
  root  : ControlRef;
 
991
  event : EventRef;
991
992
const
992
993
  BounName : PChar = 'Boun';
993
994
begin
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;
997
998
 
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;
1001
1002
  try
1002
 
        // Set the bounds into the event
1003
 
        Result := SetEventParameter( event, EventParamNamePtr(BounName)^, typeQDRectangle,      sizeof( Rect ), @inBounds );
1004
 
        if Result <> noErr then Exit;
1005
 
 
1006
 
        Result := HIObjectCreate( kCalendarViewClassID, event, outControl );
1007
 
    if Result <> noErr then Exit;
1008
 
 
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;
 
1006
 
 
1007
    Result := HIObjectCreate( kCalendarViewClassID, event, outControl );
 
1008
    if Result <> noErr then Exit;
 
1009
 
 
1010
    // Get the content root
 
1011
    Result := GetRootControl( inWindow, root {%H-});
1011
1012
    if Result <> noErr then Exit;
1012
1013
 
1013
1014
    // - added -
1014
1015
    //HIViewFindByID(root, kHIViewWindowContentID, root);
1015
1016
 
1016
 
        // And stick this view into it
1017
 
        Result := HIViewAddSubview( root, outControl );
 
1017
    // And stick this view into it
 
1018
    Result := HIViewAddSubview( root, outControl );
1018
1019
  finally
1019
1020
    ReleaseEvent(event);
1020
1021
  end;