mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-25 23:59:20 +02:00
LCL, implements cliping rect in postscriptcanvas from Anton Kavalenka, issue #13826
git-svn-id: trunk@21111 -
This commit is contained in:
parent
856382f17b
commit
83b97ddf94
@ -70,6 +70,7 @@ Type
|
|||||||
fPenPos : TPoint;
|
fPenPos : TPoint;
|
||||||
FPsUnicode : TPSUnicode;
|
FPsUnicode : TPSUnicode;
|
||||||
FFs : TFormatSettings;
|
FFs : TFormatSettings;
|
||||||
|
fSaveCount : Integer;
|
||||||
|
|
||||||
procedure psDrawRect(ARect:TRect);
|
procedure psDrawRect(ARect:TRect);
|
||||||
procedure WriteHeader(St : String);
|
procedure WriteHeader(St : String);
|
||||||
@ -112,6 +113,7 @@ Type
|
|||||||
procedure RegionChanging(APen: TObject); override;
|
procedure RegionChanging(APen: TObject); override;
|
||||||
procedure RequiredState(ReqState: TCanvasState); override;
|
procedure RequiredState(ReqState: TCanvasState); override;
|
||||||
procedure DoEllipseAndFill(const Bounds: TRect); override;
|
procedure DoEllipseAndFill(const Bounds: TRect); override;
|
||||||
|
procedure SetClipRect(const ARect:TRect);override;
|
||||||
|
|
||||||
procedure BeginDoc; override;
|
procedure BeginDoc; override;
|
||||||
procedure EndDoc; override;
|
procedure EndDoc; override;
|
||||||
@ -1457,6 +1459,7 @@ begin
|
|||||||
write('newpath');
|
write('newpath');
|
||||||
|
|
||||||
Self.fcPenWidth:=-1; // prevent cached line width affect new page
|
Self.fcPenWidth:=-1; // prevent cached line width affect new page
|
||||||
|
fSaveCount:=0;
|
||||||
UpdateLineWidth;
|
UpdateLineWidth;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1922,6 +1925,20 @@ var
|
|||||||
PenUnder : Real;
|
PenUnder : Real;
|
||||||
PosUnder : Integer;
|
PosUnder : Integer;
|
||||||
pp:TpsPoint;
|
pp:TpsPoint;
|
||||||
|
saved:boolean;
|
||||||
|
|
||||||
|
procedure rotate;
|
||||||
|
begin
|
||||||
|
if Font.Orientation<>0 then
|
||||||
|
begin
|
||||||
|
write('gsave');
|
||||||
|
inc(fSaveCount);
|
||||||
|
Self.FPsUnicode.ResetLastFont;
|
||||||
|
saved:=true;
|
||||||
|
write(format('%.2f rotate',[Font.Orientation / 10],fFS));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
pp:=TranslateCoord(X,Y);
|
pp:=TranslateCoord(X,Y);
|
||||||
|
|
||||||
@ -1931,9 +1948,10 @@ begin
|
|||||||
FPSUnicode.FontSize:=Font.Size;
|
FPSUnicode.FontSize:=Font.Size;
|
||||||
FPSUnicode.FontStyle:=FontStyleToInt(Font.Style);
|
FPSUnicode.FontStyle:=FontStyleToInt(Font.Style);
|
||||||
|
|
||||||
//The Y origine for ps text it's Left bottom corner
|
//The Y origin for ps text it's Left bottom corner
|
||||||
//Dec(Y,Abs(Font.Size));
|
pp.fy := pp.fy - abs(Font.Size); // in points
|
||||||
pp.fy:=pp.fy-abs(Font.Size); // in points
|
|
||||||
|
saved:=false;
|
||||||
|
|
||||||
if fsUnderline in Font.Style then
|
if fsUnderline in Font.Style then
|
||||||
begin
|
begin
|
||||||
@ -1941,6 +1959,7 @@ begin
|
|||||||
if fsBold in Font.Style then
|
if fsBold in Font.Style then
|
||||||
PenUnder:=1.0;
|
PenUnder:=1.0;
|
||||||
PosUnder:=(Abs(Round(Font.Size/3))*-1)+2;
|
PosUnder:=(Abs(Round(Font.Size/3))*-1)+2;
|
||||||
|
rotate();
|
||||||
Write(format('%f %f uli',[pp.fx,pp.fy],FFs));
|
Write(format('%f %f uli',[pp.fx,pp.fy],FFs));
|
||||||
FPSUnicode.OutputString(MapedString(Text));
|
FPSUnicode.OutputString(MapedString(Text));
|
||||||
write(Format('%.3f %d ule',[PenUnder,PosUnder],FFs));
|
write(Format('%.3f %d ule',[PenUnder,PosUnder],FFs));
|
||||||
@ -1948,9 +1967,16 @@ begin
|
|||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
write(Format('%f %f moveto',[pp.fx,pp.fy],FFs));
|
write(Format('%f %f moveto',[pp.fx,pp.fy],FFs));
|
||||||
|
rotate();
|
||||||
FPSUnicode.OutputString(MapedString(Text));
|
FPSUnicode.OutputString(MapedString(Text));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if saved then
|
||||||
|
begin
|
||||||
|
write('grestore');
|
||||||
|
dec(fSaveCount);
|
||||||
|
end;
|
||||||
|
|
||||||
MoveToLastPos;
|
MoveToLastPos;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2134,6 +2160,39 @@ begin
|
|||||||
TextOut(X,Y, Text);
|
TextOut(X,Y, Text);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function IsMaxClip(ARect:TRect):boolean;
|
||||||
|
begin
|
||||||
|
Result:=(Arect.Right=MaxInt) and (ARect.Bottom=MaxInt) and (Arect.Left=0) and (ARect.Top=0);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TPostScriptPrinterCanvas.SetClipRect(const ARect:TRect);
|
||||||
|
begin
|
||||||
|
inherited SetClipRect(ARect);
|
||||||
|
if (fSaveCount>0) then // restore original clipping
|
||||||
|
begin
|
||||||
|
Self.Write('grestore');
|
||||||
|
dec(fSaveCount);
|
||||||
|
end;
|
||||||
|
|
||||||
|
// if the rect is empty or max-possible - do not clip
|
||||||
|
if (IsRectEmpty(ARect) or IsMaxClip(ARect)) then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
// save PS state and clip
|
||||||
|
UpdateLineWidth;
|
||||||
|
UpdateLineColor;
|
||||||
|
UpdateFillColor;
|
||||||
|
UpdateFont;
|
||||||
|
Self.Write('gsave');
|
||||||
|
Self.WriteComment('This is clip path');
|
||||||
|
inc(fSaveCount);
|
||||||
|
psDrawRect(ARect);
|
||||||
|
Self.WriteB('clip');
|
||||||
|
Self.Write(fBuffer);
|
||||||
|
// Self.MovetoLastpos;
|
||||||
|
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TPostScriptPrinterCanvas.FloodFill(X, Y: Integer; FillColor: TColor; FillStyle: TFillStyle);
|
procedure TPostScriptPrinterCanvas.FloodFill(X, Y: Integer; FillColor: TColor; FillStyle: TFillStyle);
|
||||||
begin
|
begin
|
||||||
|
@ -65,7 +65,7 @@ type
|
|||||||
destructor destroy; override;
|
destructor destroy; override;
|
||||||
procedure OutputString(S:string);
|
procedure OutputString(S:string);
|
||||||
function BlockFor(var w: word):integer;
|
function BlockFor(var w: word):integer;
|
||||||
|
procedure ResetLastFont;
|
||||||
property Font: string read FFont write SetFont;
|
property Font: string read FFont write SetFont;
|
||||||
property FontSize: Integer read FFontSize write SetFontSize;
|
property FontSize: Integer read FFontSize write SetFontSize;
|
||||||
property FOntStyle: Integer read FFontStyle write SetFontStyle;
|
property FOntStyle: Integer read FFontStyle write SetFontStyle;
|
||||||
@ -523,5 +523,10 @@ begin
|
|||||||
FFontStyle := AValue;
|
FFontStyle := AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TPsUnicode.ResetLastFont;
|
||||||
|
begin
|
||||||
|
FLastFontIndex:=-1;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user