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

« back to all changes in this revision

Viewing changes to lcl/postscriptcanvas.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:
53
53
  TpsPoint=record
54
54
    fx,fy:single;
55
55
  end;
 
56
  TpsBounds=record
 
57
    fx,fy,fwidth,fheight:single;
 
58
  end;
56
59
 
57
60
  TPsCanvasState = ( pcsPosValid, pcsClipping, pcsClipSaved );
58
61
  TPsCanvasStatus = set of TPsCanvasState;
87
90
    procedure WriteBoundingBox(UseHeader: boolean);
88
91
    
89
92
    function TranslateCoord(cnvX,cnvY : Integer):TpsPoint;
 
93
    function TxRectToBounds(aRect: TRect): TpsBounds;
90
94
    procedure SetPosition(X,Y : Integer);
91
95
    
92
96
    procedure UpdateLineWidth;
125
129
 
126
130
    function GetClipRect: TRect; override;
127
131
    procedure SetClipRect(const ARect: TRect); override;
128
 
    function GetClipping: Boolean; {$ifndef ver2_2}override;{$endif}
129
 
    procedure SetClipping(const AValue: boolean); {$ifndef ver2_2}override;{$endif}
 
132
    function GetClipping: Boolean; override;
 
133
    procedure SetClipping(const AValue: boolean); override;
130
134
    
131
135
    procedure BeginDoc; override;
132
136
    procedure EndDoc;   override;
205
209
  end;
206
210
 
207
211
Const
208
 
  cBrushStyle : Array[TBrushStyle] of String =
209
 
     ('bsClear', 'bsSolid', 'bsBDiagonal',
210
 
      'bsFDiagonal', 'bsCross', 'bsDiagCross',
211
 
      'bsHorizontal', 'bsVertical', 'bsImage', 'bsPattern');
212
 
 
213
 
 
214
212
  cFontPSMetrics : Array[0..12] of TFontPSMetrics =(
215
213
    (Name  : 'Courier';
216
214
     ULPos : -100; ULThickness : 50; Ascender : 604; Descender : -186;
772
770
    Result.Fx, Result.Fy);
773
771
end;
774
772
 
 
773
function TPostScriptPrinterCanvas.TxRectToBounds(aRect: TRect): TpsBounds;
 
774
var
 
775
  p1,p2: TPsPoint;
 
776
begin
 
777
  p1 := TranslateCoord(aRect.Left, aRect.Top);
 
778
  p2 := TranslateCoord(aRect.Right, aRect.Bottom);
 
779
  Result.fx := p1.fx;
 
780
  Result.fy := p2.fy;
 
781
  Result.fwidth := p2.fx-p1.fx;
 
782
  Result.fheight := p1.fy-p2.fy;
 
783
end;
 
784
 
775
785
//Save the last position
776
786
procedure TPostScriptPrinterCanvas.SetPosition(X, Y: Integer);
777
787
begin
795
805
//Init the color of line (pen)
796
806
procedure TPostScriptPrinterCanvas.UpdateLineColor(aColor : TColor = clNone);
797
807
Var R,G,B    : Real;
798
 
    RGBColor : TColor;
 
808
    RGBColor : TColorRef;
799
809
begin
800
810
  if aColor=clNone then
801
811
    aColor:=Pen.Color;
834
844
//Init the color for fill
835
845
procedure TPostScriptPrinterCanvas.UpdateFillColor;
836
846
Var R,G,B    : Real;
837
 
    RGBColor : TColor;
 
847
    RGBColor : TColorRef;
838
848
begin
839
849
  if (Brush.Style=bsSolid) and (Brush.Color<>fcPenColor) then
840
850
  begin
851
861
//Update current font
852
862
procedure TPostScriptPrinterCanvas.UpdateFont;
853
863
Var R,G,B    : Real;
854
 
    RGBColor : TColor;
 
864
    RGBColor : TColorRef;
855
865
begin
856
866
  if Font.Color=clNone then
857
867
    Font.Color:=clBlack;
920
930
//Use SetBorder and SetFill for initialize 1 or 2 sequence
921
931
procedure TPostScriptPrinterCanvas.SetBrushFillPattern(Lst: TStringList;
922
932
  SetBorder, SetFill: Boolean);
 
933
var
 
934
  s: string;
923
935
begin
924
936
  If not Assigned(Lst) then Exit;
925
937
  
938
950
         else
939
951
         begin
940
952
           UpdateLineColor(Brush.Color);
941
 
           write(Format('/%s findfont  %% a pattern font patternfill',[cBrushStyle[Brush.Style]]));
 
953
           WriteStr(s, Brush.Style);
 
954
           write(Format('/%s findfont  %% a pattern font patternfill',[s]));
942
955
           Write(Lst);
943
956
           write('patternfill');
944
957
         end;
1093
1106
end;
1094
1107
 
1095
1108
procedure TPostScriptPrinterCanvas.SaveClip;
 
1109
var
 
1110
  B: TpsBounds;
1096
1111
begin
1097
1112
  Self.WriteComment('Pushing and Setting current clip rect');
1098
1113
  Self.Write('clipsave');
1099
 
  psDrawRect(FLazClipRect);
1100
 
  Write(FBuffer);
1101
 
  Self.Write('clip');
 
1114
  B := TxRectToBounds(FLazClipRect);
 
1115
  with B do
 
1116
    Self.Write(Format('%f %f %f %f rectclip',[fx, fy, fwidth, fheight],FFs));
1102
1117
  Include(FStatus, pcsClipSaved);
1103
1118
end;
1104
1119
 
1507
1522
  WriteHeader('');
1508
1523
  WriteHeader('%%Page: 1 1');
1509
1524
  WritePageTransform;
 
1525
 
 
1526
  if assigned(printer) then
 
1527
    FLazClipRect:=printer.PaperSize.PaperRect.WorkRect;
1510
1528
end;
1511
1529
 
1512
1530
procedure TPostScriptPrinterCanvas.EndDoc;
2258
2276
 
2259
2277
procedure TPostScriptPrinterCanvas.TextRect(ARect: TRect; X, Y: integer;
2260
2278
  const Text: string; const Style: TTextStyle);
 
2279
var
 
2280
  OldClip: TRect;
2261
2281
begin
2262
2282
  {$IFDEF VerboseLCLTodos}{$WARNING TPostScriptPrinterCanvas.TextRect is not yet fully implemented!}{$ENDIF}
2263
 
  //TODO: clipping, layout, etc.
 
2283
  //TODO: layout, etc.
 
2284
 
 
2285
  if Style.Clipping then begin
 
2286
    OldClip := GetClipRect;
 
2287
    SetClipRect(ARect);
 
2288
  end;
 
2289
 
2264
2290
  TextOut(X,Y, Text);
 
2291
 
 
2292
  if Style.Clipping then
 
2293
    SetClipRect(OldClip);
2265
2294
end;
2266
2295
 
2267
2296
function IsMaxClip(ARect:TRect):boolean;