mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-20 11:59:08 +02:00
Printers, fix GTK printing problem issue #34932
git-svn-id: trunk@60732 -
This commit is contained in:
parent
1b4646b785
commit
1a7930cb2c
@ -163,6 +163,10 @@ type
|
|||||||
{ TCairoPsCanvas }
|
{ TCairoPsCanvas }
|
||||||
|
|
||||||
TCairoPsCanvas = class(TCairoFileCanvas)
|
TCairoPsCanvas = class(TCairoFileCanvas)
|
||||||
|
private
|
||||||
|
fHandle: Pcairo_t;
|
||||||
|
procedure GetPageProperties(out aWidth, aHeight: double; out orStr:string);
|
||||||
|
procedure UpdatePageTransform;
|
||||||
protected
|
protected
|
||||||
function CreateCairoHandle: HDC; override;
|
function CreateCairoHandle: HDC; override;
|
||||||
public
|
public
|
||||||
@ -1515,28 +1519,60 @@ end;
|
|||||||
|
|
||||||
{ TCairoPsCanvas }
|
{ TCairoPsCanvas }
|
||||||
|
|
||||||
|
procedure TCairoPsCanvas.GetPageProperties(out aWidth, aHeight: double; out
|
||||||
|
orStr: string);
|
||||||
|
begin
|
||||||
|
if Orientation in [poLandscape, poReverseLandscape] then begin
|
||||||
|
orStr := '%%PageOrientation: Landscape';
|
||||||
|
aWidth := PaperHeight*ScaleY; //switch H, W
|
||||||
|
aHeight := PaperWidth*ScaleX;
|
||||||
|
end else begin
|
||||||
|
orStr := '%%PageOrientation: Portait';
|
||||||
|
aWidth := PaperWidth*ScaleX;
|
||||||
|
aHeight := PaperHeight*ScaleY;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCairoPsCanvas.UpdatePageTransform;
|
||||||
|
var
|
||||||
|
W, H: double;
|
||||||
|
Dummy: string;
|
||||||
|
begin
|
||||||
|
GetPageProperties(W, H, Dummy);
|
||||||
|
|
||||||
|
cairo_identity_matrix(fHandle);
|
||||||
|
|
||||||
|
case Orientation of
|
||||||
|
poLandscape: begin
|
||||||
|
cairo_translate(fHandle, 0, H);
|
||||||
|
cairo_rotate(fHandle, -PI/2);
|
||||||
|
end;
|
||||||
|
poReverseLandscape: begin
|
||||||
|
cairo_translate(fHandle, W, 0);
|
||||||
|
cairo_rotate(fHandle, PI/2);
|
||||||
|
end;
|
||||||
|
poReversePortrait: begin
|
||||||
|
cairo_translate(fHandle, W, H);
|
||||||
|
cairo_rotate(fHandle, PI);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
function TCairoPsCanvas.CreateCairoHandle: HDC;
|
function TCairoPsCanvas.CreateCairoHandle: HDC;
|
||||||
var
|
var
|
||||||
s: string;
|
s: string;
|
||||||
W, H: Double;
|
W, H: Double;
|
||||||
acr: Pcairo_t;
|
|
||||||
begin
|
begin
|
||||||
if Orientation in [poLandscape, poReverseLandscape] then begin
|
GetPageProperties(W, H, s);
|
||||||
s := '%%PageOrientation: Landscape';
|
|
||||||
W := PaperHeight*ScaleY; //switch H, W
|
|
||||||
H := PaperWidth*ScaleX;
|
|
||||||
end else begin
|
|
||||||
s := '%%PageOrientation: Portait';
|
|
||||||
W := PaperWidth*ScaleX;
|
|
||||||
H := PaperHeight*ScaleY;
|
|
||||||
end;
|
|
||||||
|
|
||||||
//Sizes are in Points, 72DPI (1pt = 1/72")
|
//Sizes are in Points, 72DPI (1pt = 1/72")
|
||||||
if fStream<>nil then
|
if fStream<>nil then
|
||||||
sf := cairo_ps_surface_create_for_stream(@WriteToStream, fStream, W, H)
|
sf := cairo_ps_surface_create_for_stream(@WriteToStream, fStream, W, H)
|
||||||
else
|
else
|
||||||
sf := cairo_ps_surface_create(PChar(FOutputFileName), W, H);
|
sf := cairo_ps_surface_create(PChar(FOutputFileName), W, H);
|
||||||
acr := cairo_create(sf);
|
fHandle := cairo_create(sf);
|
||||||
|
|
||||||
cairo_ps_surface_dsc_begin_setup(sf);
|
cairo_ps_surface_dsc_begin_setup(sf);
|
||||||
cairo_ps_surface_dsc_comment(sf, PChar(s));
|
cairo_ps_surface_dsc_comment(sf, PChar(s));
|
||||||
@ -1549,26 +1585,23 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
//rotate and move
|
//rotate and move
|
||||||
case Orientation of
|
UpdatePageTransform;
|
||||||
poLandscape: begin
|
|
||||||
cairo_translate(acr, 0, H);
|
result := {%H-}HDC(fHandle);
|
||||||
cairo_rotate(acr, -PI/2);
|
|
||||||
end;
|
|
||||||
poReverseLandscape: begin
|
|
||||||
cairo_translate(acr, W, 0);
|
|
||||||
cairo_rotate(acr, PI/2);
|
|
||||||
end;
|
|
||||||
poReversePortrait: begin
|
|
||||||
cairo_translate(acr, W, H);
|
|
||||||
cairo_rotate(acr, PI);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
result := {%H-}HDC(acr);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCairoPsCanvas.UpdatePageSize;
|
procedure TCairoPsCanvas.UpdatePageSize;
|
||||||
|
var
|
||||||
|
W, H: Double;
|
||||||
|
S: string;
|
||||||
begin
|
begin
|
||||||
cairo_ps_surface_set_size(sf, PaperWidth*ScaleX, PaperHeight*ScaleY);
|
GetPageProperties(W, H, S);
|
||||||
|
|
||||||
|
cairo_ps_surface_dsc_begin_page_setup(sf);
|
||||||
|
cairo_ps_surface_dsc_comment(sf, PChar(s));
|
||||||
|
cairo_ps_surface_set_size(sf, W, H);
|
||||||
|
|
||||||
|
UpdatePageTransform;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TCairoPngCanvas.Create(APrinter: TPrinter);
|
constructor TCairoPngCanvas.Create(APrinter: TPrinter);
|
||||||
|
@ -747,7 +747,6 @@ end;
|
|||||||
|
|
||||||
procedure TPrinter.SetOrientation(const AValue: TPrinterOrientation);
|
procedure TPrinter.SetOrientation(const AValue: TPrinterOrientation);
|
||||||
begin
|
begin
|
||||||
CheckPrinting(False);
|
|
||||||
DoSetOrientation(aValue);
|
DoSetOrientation(aValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user