mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-13 12:09:21 +02:00
CairoCanvas, updated test
git-svn-id: trunk@44431 -
This commit is contained in:
parent
585b1dd06a
commit
9f64f946ed
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<CONFIG>
|
<CONFIG>
|
||||||
<ProjectOptions>
|
<ProjectOptions>
|
||||||
<Version Value="9"/>
|
<Version Value="9"/>
|
||||||
@ -26,7 +26,6 @@
|
|||||||
<RunParams>
|
<RunParams>
|
||||||
<local>
|
<local>
|
||||||
<FormatVersion Value="1"/>
|
<FormatVersion Value="1"/>
|
||||||
<LaunchingApplication PathPlusParams="/usr/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
|
||||||
</local>
|
</local>
|
||||||
</RunParams>
|
</RunParams>
|
||||||
<RequiredPackages Count="3">
|
<RequiredPackages Count="3">
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
object Form1: TForm1
|
object Form1: TForm1
|
||||||
Left = 226
|
Left = 100
|
||||||
Height = 552
|
Height = 552
|
||||||
Top = 148
|
Top = 77
|
||||||
Width = 628
|
Width = 628
|
||||||
Caption = 'Form1'
|
Caption = 'Form1'
|
||||||
ClientHeight = 552
|
ClientHeight = 552
|
||||||
ClientWidth = 628
|
ClientWidth = 628
|
||||||
OnPaint = FormPaint
|
OnPaint = FormPaint
|
||||||
LCLVersion = '1.1'
|
LCLVersion = '1.3'
|
||||||
object Button1: TButton
|
object Button1: TButton
|
||||||
Left = 548
|
Left = 548
|
||||||
Height = 25
|
Height = 25
|
||||||
@ -50,7 +50,7 @@ object Form1: TForm1
|
|||||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||||
ChildSizing.ControlsPerLine = 1
|
ChildSizing.ControlsPerLine = 1
|
||||||
ClientHeight = 62
|
ClientHeight = 57
|
||||||
ClientWidth = 93
|
ClientWidth = 93
|
||||||
Items.Strings = (
|
Items.Strings = (
|
||||||
'24217'
|
'24217'
|
||||||
@ -69,6 +69,7 @@ object Form1: TForm1
|
|||||||
Top = 236
|
Top = 236
|
||||||
Width = 75
|
Width = 75
|
||||||
Caption = 'btnPrintAll'
|
Caption = 'btnPrintAll'
|
||||||
|
OnClick = btnPrintAllClick
|
||||||
TabOrder = 4
|
TabOrder = 4
|
||||||
end
|
end
|
||||||
object btnOther: TButton
|
object btnOther: TButton
|
||||||
@ -95,7 +96,7 @@ object Form1: TForm1
|
|||||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||||
ChildSizing.ControlsPerLine = 3
|
ChildSizing.ControlsPerLine = 3
|
||||||
ClientHeight = 58
|
ClientHeight = 53
|
||||||
ClientWidth = 64
|
ClientWidth = 64
|
||||||
Columns = 3
|
Columns = 3
|
||||||
ItemIndex = 0
|
ItemIndex = 0
|
||||||
@ -127,7 +128,7 @@ object Form1: TForm1
|
|||||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||||
ChildSizing.ControlsPerLine = 1
|
ChildSizing.ControlsPerLine = 1
|
||||||
ClientHeight = 82
|
ClientHeight = 77
|
||||||
ClientWidth = 64
|
ClientWidth = 64
|
||||||
ItemIndex = 0
|
ItemIndex = 0
|
||||||
Items.Strings = (
|
Items.Strings = (
|
||||||
|
@ -24,6 +24,7 @@ type
|
|||||||
radOtherAngle: TRadioGroup;
|
radOtherAngle: TRadioGroup;
|
||||||
procedure btn19435Click(Sender: TObject);
|
procedure btn19435Click(Sender: TObject);
|
||||||
procedure btnOtherClick(Sender: TObject);
|
procedure btnOtherClick(Sender: TObject);
|
||||||
|
procedure btnPrintAllClick(Sender: TObject);
|
||||||
procedure Button1Click(Sender: TObject);
|
procedure Button1Click(Sender: TObject);
|
||||||
procedure btn24217Click(Sender: TObject);
|
procedure btn24217Click(Sender: TObject);
|
||||||
procedure chkTestsItemClick(Sender: TObject; Index: integer);
|
procedure chkTestsItemClick(Sender: TObject; Index: integer);
|
||||||
@ -32,6 +33,10 @@ type
|
|||||||
procedure Draw19435(cnv: TCanvas; XDPI,YDPI: Integer);
|
procedure Draw19435(cnv: TCanvas; XDPI,YDPI: Integer);
|
||||||
procedure Draw24217(cnv: TCanvas; XDPI,YDPI: Integer);
|
procedure Draw24217(cnv: TCanvas; XDPI,YDPI: Integer);
|
||||||
procedure DrawOther(cnv: TCanvas; XDPI,YDPI: Integer);
|
procedure DrawOther(cnv: TCanvas; XDPI,YDPI: Integer);
|
||||||
|
function GetOtherAlignment:TAlignment;
|
||||||
|
function GetOtherLayout:TTextLayout;
|
||||||
|
procedure GetReferencePoint(const r: TRect; cnv:TCanvas; out x, y: Integer);
|
||||||
|
procedure PrintOther(aFileName: string = 'other'; aBackend: TCairoBackend = cbPDF);
|
||||||
public
|
public
|
||||||
{ public declarations }
|
{ public declarations }
|
||||||
end;
|
end;
|
||||||
@ -79,18 +84,51 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.btnOtherClick(Sender: TObject);
|
procedure TForm1.btnOtherClick(Sender: TObject);
|
||||||
var
|
|
||||||
CairoPrinter: TCairoFilePrinter;
|
|
||||||
begin
|
begin
|
||||||
CairoPrinter := TCairoFilePrinter.create;
|
PrintOther;
|
||||||
//CairoPrinter.CairoBackend:=cbPS;
|
end;
|
||||||
CairoPrinter.CairoBackend:=cbPDF;
|
|
||||||
CairoPrinter.FileName:='other';
|
procedure TForm1.btnPrintAllClick(Sender: TObject);
|
||||||
CairoPrinter.BeginDoc;
|
|
||||||
with CairoPrinter do
|
procedure PrintBackend(aBackend: TCairoBackend);
|
||||||
DrawOther(Canvas, XDPI, YDPI);
|
var
|
||||||
CairoPrinter.EndDoc;
|
angle: Integer;
|
||||||
CairoPrinter.Free;
|
angleIndex: Integer;
|
||||||
|
alignIndex: Integer;
|
||||||
|
aFileName, lstr,astr: string;
|
||||||
|
CairoPrinter: TCairoFilePrinter;
|
||||||
|
begin
|
||||||
|
CairoPrinter := TCairoFilePrinter.create;
|
||||||
|
CairoPrinter.CairoBackend:=aBackend;
|
||||||
|
CairoPrinter.FileName:='testing other';
|
||||||
|
CairoPrinter.BeginDoc;
|
||||||
|
for angleIndex:=0 to 3 do begin
|
||||||
|
radOtherAngle.ItemIndex := angleIndex;
|
||||||
|
for alignIndex := 0 to 8 do begin
|
||||||
|
radOtherAlign.ItemIndex := alignIndex;
|
||||||
|
//angle := StrToInt(radOtherAngle.Items[angleIndex]);
|
||||||
|
//WriteStr(lstr, GetOtherLayout);
|
||||||
|
//WriteStr(astr, GetOtherAlignment);
|
||||||
|
//aFileName := format('other_angle(%.3d)_alignment(%s)_layout(%s)',
|
||||||
|
// [angle, lstr, astr]);
|
||||||
|
|
||||||
|
with CairoPrinter do
|
||||||
|
DrawOther(Canvas, XDPI, YDPI);
|
||||||
|
|
||||||
|
if not ((angleIndex=3) and (alignIndex=8)) then
|
||||||
|
CairoPrinter.NewPage;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
CairoPrinter.EndDoc;
|
||||||
|
CairoPrinter.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
|
||||||
|
if chkTests.Checked[2] then begin
|
||||||
|
PrintBackend(cbPDF);
|
||||||
|
PrintBackend(cbPS);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.btn24217Click(Sender: TObject);
|
procedure TForm1.btn24217Click(Sender: TObject);
|
||||||
@ -248,11 +286,17 @@ const
|
|||||||
'01.' + LineEnding+
|
'01.' + LineEnding+
|
||||||
'1.0' + LineEnding+
|
'1.0' + LineEnding+
|
||||||
'.01';
|
'.01';
|
||||||
|
BRKTEXT = 'Si tu gusto gustara del gusto que gusta mi gusto, '+
|
||||||
|
'mi gusto gustara del gusto que gusta tu gusto, '+
|
||||||
|
'PERO COMO TU GUSTO NO GUSTA DEL GUSTO QUE GUSTA MI GUSTO, '+
|
||||||
|
'MI GUSTO NO GUSTA DEL GUSTO QUE GUSTA TU GUSTO';
|
||||||
|
|
||||||
var
|
var
|
||||||
x,y: Integer;
|
x,y: Integer;
|
||||||
R: TRect;
|
R: TRect;
|
||||||
sz: TSize;
|
sz: TSize;
|
||||||
style: TTextStyle;
|
style: TTextStyle;
|
||||||
|
sL,sA: string;
|
||||||
begin
|
begin
|
||||||
|
|
||||||
R := Rect(XDPI, YDPI*2, XDPI*3, round(YDPI*2.5));
|
R := Rect(XDPI, YDPI*2, XDPI*3, round(YDPI*2.5));
|
||||||
@ -261,6 +305,7 @@ begin
|
|||||||
cnv.Font.Size := 40;
|
cnv.Font.Size := 40;
|
||||||
cnv.Font.Color := clBlue;
|
cnv.Font.Color := clBlue;
|
||||||
cnv.Pen.Color := RGBToColor($AA, $CC, $FF);
|
cnv.Pen.Color := RGBToColor($AA, $CC, $FF);
|
||||||
|
cnv.Font.Orientation:=0;
|
||||||
cnv.Brush.Style := bsClear;
|
cnv.Brush.Style := bsClear;
|
||||||
cnv.TextRect(R, R.Left, R.Top, CTEXT);
|
cnv.TextRect(R, R.Left, R.Top, CTEXT);
|
||||||
cnv.Rectangle(R);
|
cnv.Rectangle(R);
|
||||||
@ -272,6 +317,7 @@ begin
|
|||||||
cnv.Rectangle(R);
|
cnv.Rectangle(R);
|
||||||
|
|
||||||
OffsetRect(R, -5, Round(YDPI*0.5));
|
OffsetRect(R, -5, Round(YDPI*0.5));
|
||||||
|
Cnv.Font.Size:=16;
|
||||||
sz := cnv.TextExtent('Line1');
|
sz := cnv.TextExtent('Line1');
|
||||||
cnv.Font.color := clDefault;
|
cnv.Font.color := clDefault;
|
||||||
cnv.TextOut(R.Left, R.Top, 'Line1'); OffsetRect(R, 0, sz.cy);
|
cnv.TextOut(R.Left, R.Top, 'Line1'); OffsetRect(R, 0, sz.cy);
|
||||||
@ -279,42 +325,78 @@ begin
|
|||||||
cnv.TextOut(R.Left, R.Top, 'Line3'); OffsetRect(R, 0, sz.cy);
|
cnv.TextOut(R.Left, R.Top, 'Line3'); OffsetRect(R, 0, sz.cy);
|
||||||
|
|
||||||
R := Rect(XDPI*4, YDPI*2, Round(XDPI*6), round(YDPI*6));
|
R := Rect(XDPI*4, YDPI*2, Round(XDPI*6), round(YDPI*6));
|
||||||
|
|
||||||
cnv.Font.Name := 'Sans';
|
cnv.Font.Name := 'Sans';
|
||||||
cnv.Font.Size := 20;
|
cnv.Font.Size := 20;
|
||||||
cnv.Font.Color := clGreen;
|
cnv.Font.Color := clGreen;
|
||||||
cnv.Font.Orientation:=1800;
|
cnv.Font.Orientation := radOtherAngle.ItemIndex * 90 * 10;
|
||||||
cnv.Brush.Style := bsClear;
|
cnv.Brush.Style := bsClear;
|
||||||
cnv.Pen.Color := clSilver;
|
cnv.Pen.Color := clSilver;
|
||||||
|
|
||||||
style := cnv.TextStyle;
|
style := cnv.TextStyle;
|
||||||
style.SingleLine := false;
|
style.SingleLine := false;
|
||||||
style.Alignment := taRightJustify;
|
with style do begin
|
||||||
|
Alignment := GetOtherAlignment;
|
||||||
|
Layout := GetOtherLayout;
|
||||||
|
end;
|
||||||
cnv.TextStyle := style;
|
cnv.TextStyle := style;
|
||||||
|
GetReferencePoint(R, cnv, x, y);
|
||||||
|
|
||||||
//cnv.TextRect(R, R.Left, R.Top, Par);
|
//cnv.TextRect(R, R.Left, R.Top, Par);
|
||||||
cnv.TextRect(R, R.Right, R.Bottom, Par);
|
cnv.TextRect(R, x, y, Par);
|
||||||
cnv.Rectangle(R);
|
cnv.Rectangle(R);
|
||||||
|
|
||||||
|
|
||||||
R := Rect(XDPI, YDPI*7, XDPI*7, YDPI*9);
|
R := Rect(XDPI, YDPI*7, XDPI*7, YDPI*9);
|
||||||
cnv.Font.Size := 30;
|
cnv.Font.Size := 30;
|
||||||
cnv.Font.Color := clFuchsia;
|
cnv.Font.Color := clFuchsia;
|
||||||
cnv.Pen.Color := clSilver;
|
cnv.Pen.Color := clSilver;
|
||||||
// style
|
GetReferencePoint(r, Cnv, x, y);
|
||||||
style := cnv.TextStyle;
|
cnv.TextRect(R, x, y, Par);
|
||||||
style.SingleLine := false;
|
cnv.Rectangle(R);
|
||||||
with style do begin
|
|
||||||
case radOtherAlign.ItemIndex of
|
R := Rect(XDPI, Round(YDPI*3.5), XDPI*3, round(YDPI*6));
|
||||||
0,3,6: Alignment := taLeftJustify;
|
cnv.Font.Color := clBlue;
|
||||||
1,4,7: Alignment := taCenter;
|
cnv.Font.Size := 16;
|
||||||
else Alignment := taRightJustify;
|
cnv.Pen.Color := clRed;
|
||||||
end;
|
Style.Wordbreak:=true;
|
||||||
case radOtherAlign.ItemIndex of
|
cnv.TextStyle := Style;
|
||||||
0,1,2: Layout := tlTop;
|
GetReferencePoint(R, cnv, x, y);
|
||||||
3,4,5: Layout := tlCenter;
|
cnv.TextRect(R, x, y, BRKTEXT);
|
||||||
else Layout := tlBottom;
|
cnv.Rectangle(R);
|
||||||
end;
|
|
||||||
|
|
||||||
|
WriteStr(sA, cnv.TextStyle.Alignment);
|
||||||
|
WriteStr(sL, cnv.TextStyle.Layout);
|
||||||
|
cnv.Font.Size := 14;
|
||||||
|
cnv.Font.Color := clMaroon;
|
||||||
|
cnv.Font.Orientation:=0;
|
||||||
|
cnv.TextOut(XDPI, YDPI*7 - Round(YDPI*0.5),
|
||||||
|
format('Alignment: "%s" Layout: "%s" Orientation: %d° ',[sA, sL, radOtherAngle.ItemIndex * 90]));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TForm1.GetOtherAlignment: TAlignment;
|
||||||
|
begin
|
||||||
|
case radOtherAlign.ItemIndex of
|
||||||
|
0,3,6: Result := taLeftJustify;
|
||||||
|
1,4,7: Result := taCenter;
|
||||||
|
else Result := taRightJustify;
|
||||||
end;
|
end;
|
||||||
cnv.TextStyle := style;
|
end;
|
||||||
|
|
||||||
|
function TForm1.GetOtherLayout: TTextLayout;
|
||||||
|
begin
|
||||||
|
case radOtherAlign.ItemIndex of
|
||||||
|
0,1,2: Result := tlTop;
|
||||||
|
3,4,5: Result := tlCenter;
|
||||||
|
else Result := tlBottom;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.GetReferencePoint(const r: TRect; cnv: TCanvas; out x,
|
||||||
|
y: Integer);
|
||||||
|
begin
|
||||||
// orientation
|
// orientation
|
||||||
cnv.Font.Orientation := radOtherAngle.ItemIndex * 90 * 10;
|
|
||||||
x := r.Left;
|
x := r.Left;
|
||||||
y := r.Top;
|
y := r.Top;
|
||||||
case cnv.Font.Orientation of
|
case cnv.Font.Orientation of
|
||||||
@ -339,8 +421,21 @@ begin
|
|||||||
y := r.Top;
|
y := r.Top;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
cnv.TextRect(R, x, y, Par);
|
end;
|
||||||
cnv.Rectangle(R);
|
|
||||||
|
procedure TForm1.PrintOther(aFileName: string = 'other'; aBackend: TCairoBackend = cbPDF);
|
||||||
|
var
|
||||||
|
CairoPrinter: TCairoFilePrinter;
|
||||||
|
begin
|
||||||
|
CairoPrinter := TCairoFilePrinter.create;
|
||||||
|
//CairoPrinter.CairoBackend:=cbPS;
|
||||||
|
CairoPrinter.CairoBackend:=aBackend;
|
||||||
|
CairoPrinter.FileName:=aFileName;
|
||||||
|
CairoPrinter.BeginDoc;
|
||||||
|
with CairoPrinter do
|
||||||
|
DrawOther(Canvas, XDPI, YDPI);
|
||||||
|
CairoPrinter.EndDoc;
|
||||||
|
CairoPrinter.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user