📄 ieprnform2.pas
字号:
xmult := 2.54
else
xmult := 1;
end;
// preview or print
procedure TfiePrnForm2.printpreview(Sender: TObject);
var
VerticalPos: TIEVerticalPos;
HorizontalPos: TIEHorizontalPos;
Size: TIESize;
MarginLeft, MarginTop, MarginRight, MarginBottom, SpecWidth, SpecHeight, GammaCorrection: double;
ie:TImageEnVect;
lc:TCursor;
begin
if activating then
exit;
VerticalPos := ievpCENTER;
HorizontalPos := iehpCENTER;
if SpeedButton1.Down or SpeedButton2.Down or SpeedButton3.Down then
VerticalPos := ievpTOP;
if SpeedButton7.Down or SpeedButton8.Down or SpeedButton9.Down then
VerticalPos := ievpBOTTOM;
if SpeedButton1.Down or SpeedButton4.Down or SpeedButton7.Down then
HorizontalPos := iehpLEFT;
if SpeedButton3.Down or SpeedButton6.Down or SpeedButton9.Down then
HorizontalPos := iehpRIGHT;
Size := iesFITTOPAGE;
case ComboBox1.ItemIndex of
0: Size := iesNORMAL;
1: Size := iesFITTOPAGE;
2: Size := iesFITTOPAGESTRETCH;
3: Size := iesSPECIFIEDSIZE;
end;
MarginLeft := IEStrToFloatDef(Edit2.Text, 0) / xmult;
MarginTop := IEStrToFloatDef(Edit1.Text, 0) / xmult;
MarginRight := IEStrToFloatDef(Edit3.Text, 0) / xmult;
MarginBottom := IEStrToFloatDef(Edit4.text, 0) / xmult;
SpecWidth := IEStrToFloatDef(Edit5.Text, 1) / xmult; if SpecWidth=0 then SpecWidth:=0.001;
SpecHeight := IEStrToFloatDef(Edit6.Text, 1) / xmult; if SpecHeight=0 then SpecHeight:=0.001;
GammaCorrection := IEStrToFloatDef(Edit7.Text, 1);
lc:=Screen.Cursor;
Screen.Cursor:=crHourGlass;
if PrintAnnotations then
begin
if Sender = Button1 then
begin
// print
Printer.BeginDoc;
Printer.Title := fTaskName;
ie:=TImageEnVect.Create(nil);
ie.IEBitmap.Assign( io.IEBitmap );
if io.Params.ImagingAnnot.ObjectsCount>0 then
begin
io.Params.ImagingAnnot.CopyToTImageEnVect(ie);
ie.IEBitmap.PixelFormat:=ie24RGB;
ie.CopyObjectsToBack(false);
ie.RemoveAllObjects;
end;
ie.IO.Params.DpiX:=io.Params.DpiX;
ie.IO.Params.DpiY:=io.Params.DpiY;
ie.IO.PrintingFilterOnSubsampling:=io.PrintingFilterOnSubsampling;
ie.io.PrintImage(Printer.Canvas, MarginLeft, MarginTop, MarginRight, MarginBottom, VerticalPos, HorizontalPos,
Size, SpecWidth, SpecHeight, GammaCorrection);
FreeAndNil(ie);
Printer.EndDoc;
end
else
begin
// preview
ie:=TImageEnVect.Create(nil);
ie.IEBitmap.Assign( io.IEBitmap );
if io.Params.ImagingAnnot.ObjectsCount>0 then
begin
io.Params.ImagingAnnot.CopyToTImageEnVect(ie);
ie.IEBitmap.PixelFormat:=ie24RGB;
ie.CopyObjectsToBack(false);
ie.RemoveAllObjects;
ie.Update;
end;
ie.IO.Params.DpiX:=io.Params.DpiX;
ie.IO.Params.DpiY:=io.Params.DpiY;
ie.IO.PrintingFilterOnSubsampling:=io.PrintingFilterOnSubsampling;
ie.io.PreviewPrintImage(ImageEnView1.Bitmap, ImageEnView1.Width, ImageEnView1.Height, Printer, MarginLeft, MarginTop, MarginRight, MarginBottom, VerticalPos, HorizontalPos,
Size, SpecWidth, SpecHeight, GammaCorrection);
ImageEnView1.Update;
ImageEnView1.Fit;
FreeAndNil(ie);
end;
end
else
begin
if Sender = Button1 then
begin
// print
Printer.BeginDoc;
Printer.Title := fTaskName;
io.PrintImage(Printer.Canvas, MarginLeft, MarginTop, MarginRight, MarginBottom, VerticalPos, HorizontalPos,
Size, SpecWidth, SpecHeight, GammaCorrection);
Printer.EndDoc;
end
else
begin
// preview
io.PreviewPrintImage(ImageEnView1.Bitmap, ImageEnView1.Width, ImageEnView1.Height, Printer, MarginLeft, MarginTop, MarginRight, MarginBottom, VerticalPos, HorizontalPos,
Size, SpecWidth, SpecHeight, GammaCorrection);
ImageEnView1.Update;
ImageEnView1.Fit;
end;
end;
Screen.Cursor:=lc;
end;
procedure tfiePrnForm2.SetLanguage_units;
begin
if (fDialogsMeasureUnit = ieduInches) or (fDialogsMeasureUnit = ieduSelectableDefInches) then
begin
// inches
GroupBox1.Caption := ' ' + iemsg(IEMSG_MARGINS, fLanguage) + ' (' + iemsg(IEMSG_INCHES, fLanguage) + ') ';
Label7.Caption := iemsg(IEMSG_INCHES, fLanguage);
Label8.Caption := iemsg(IEMSG_INCHES, fLanguage);
end
else
begin
// centimeters (Cm)
GroupBox1.Caption := ' ' + iemsg(IEMSG_MARGINS, fLanguage) + ' (cm) ';
Label7.Caption := 'cm';
Label8.Caption := 'cm';
end;
end;
procedure tfiePrnForm2.SetLanguage(l: TMsgLanguage);
begin
fLanguage := l;
Caption := iemsg(IEMSG_PRINT, l);
SetLanguage_units;
Label1.Caption := iemsg(IEMSG_TOP, l);
Label2.Caption := iemsg(IEMSG_LEFT, l);
Label3.Caption := iemsg(IEMSG_RIGHT, l);
Label4.Caption := iemsg(IEMSG_BOTTOM, l);
GroupBox2.Caption := ' ' + iemsg(IEMSG_POSITION, l) + ' ';
GroupBox5.Caption := ' ' + iemsg(IEMSG_PREVIEW, l) + ' ';
GroupBox3.Caption := ' ' + iemsg(IEMSG_SIZE, l) + ' ';
ComboBox1.Items[0] := iemsg(IEMSG_NORMAL, l);
ComboBox1.Items[1] := iemsg(IEMSG_FITTOPAGE, l);
ComboBox1.Items[2] := iemsg(IEMSG_STRETCHTOPAGE, l);
ComboBox1.Items[3] := iemsg(IEMSG_SPECIFIEDSIZE, l);
Label5.Caption := iemsg(IEMSG_WIDTH, l);
Label6.Caption := iemsg(IEMSG_HEIGHT, l);
GroupBox4.Caption := ' ' + iemsg(IEMSG_GAMMACORRECTION, l) + ' ';
Label9.Caption := iemsg(IEMSG_VALUE2, l);
Button1.Caption := iemsg(IEMSG_OK, l);
Button2.Caption := iemsg(IEMSG_CANCEL, l);
Button4.Caption := iemsg(IEMSG_PRINTSETUP, l) + '...';
GroupBox6.Caption := iemsg(IEMSG_MEASUREUNITS, l);
Label10.Caption := iemsg(IEMSG_UNITS, l);
ComboBox2.Items[0] := iemsg(IEMSG_INCHES, l);
end;
procedure TfiePrnForm2.incdecmargins(text: TEdit; Button: TUDBtnType);
begin
case button of
btNext:
text.Text := floattostrF(dmax(IEStrToFloatDef(text.Text, 0) + FLOATINC, 0), ffGeneral,4,4);
btPrev:
text.Text := floattostrF(dmax(IEStrToFloatDef(text.Text, 0) - FLOATINC, 0), ffGeneral,4,4);
end;
end;
procedure TfiePrnForm2.UpDown1Click(Sender: TObject; Button: TUDBtnType);
begin
incdecmargins(Edit1, Button);
end;
procedure TfiePrnForm2.UpDown2Click(Sender: TObject; Button: TUDBtnType);
begin
incdecmargins(Edit2, Button);
end;
procedure TfiePrnForm2.UpDown3Click(Sender: TObject; Button: TUDBtnType);
begin
incdecmargins(Edit3, Button);
end;
procedure TfiePrnForm2.UpDown4Click(Sender: TObject; Button: TUDBtnType);
begin
incdecmargins(Edit4, Button);
end;
procedure TfiePrnForm2.UpDown7Click(Sender: TObject; Button: TUDBtnType);
begin
case button of
btNext:
Edit7.Text := floattostrF(dmax(IEStrToFloatDef(Edit7.Text, 0) + 0.1, 0), ffGeneral,4,4);
btPrev:
Edit7.Text := floattostrF(dmax(IEStrToFloatDef(Edit7.Text, 0) - 0.1, 0), ffGeneral,4,4);
end;
end;
procedure TfiePrnForm2.UpDown5Click(Sender: TObject; Button: TUDBtnType);
begin
incdecmargins(Edit5, Button);
end;
procedure TfiePrnForm2.UpDown6Click(Sender: TObject; Button: TUDBtnType);
begin
incdecmargins(Edit6, Button);
end;
// setup
procedure TfiePrnForm2.Button4Click(Sender: TObject);
begin
PrinterSetupDialog1.Execute;
printpreview(self);
end;
// units
procedure TfiePrnForm2.ComboBox2Change(Sender: TObject);
var
pred: TIEDialogsMeasureUnit;
xmult: double;
begin
pred := fDialogsMeasureUnit;
if ComboBox2.ItemIndex = 0 then
fDialogsMeasureUnit := ieduSelectableDefInches
else
fDialogsMeasureUnit := ieduSelectableDefCm;
if pred <> fDialogsMeasureUnit then
begin
if pred = ieduSelectableDefCm then
xmult := 1 / 2.54
else
xmult := 2.54;
Edit1.Text := floattostrF(IEStrToFloatDef(Edit1.Text, 0) * xmult, ffGeneral,4,4);
Edit2.Text := floattostrF(IEStrToFloatDef(Edit2.Text, 0) * xmult, ffGeneral,4,4);
Edit3.Text := floattostrF(IEStrToFloatDef(Edit3.Text, 0) * xmult, ffGeneral,4,4);
Edit4.Text := floattostrF(IEStrToFloatDef(Edit4.Text, 0) * xmult, ffGeneral,4,4);
Edit5.Text := floattostrF(IEStrToFloatDef(Edit5.Text, 0) * xmult, ffGeneral,4,4);
Edit6.Text := floattostrF(IEStrToFloatDef(Edit6.Text, 0) * xmult, ffGeneral,4,4);
SetLanguage_units;
end;
end;
procedure TfiePrnForm2.FormCreate(Sender: TObject);
begin
// 2.2.7
case iegDialogsBackground of
iedbPaper:
begin
ImageEnView1.Background:=clWhite;
IECreateOSXBackgroundPaper(Image1.Picture.Bitmap,Image1.Width,Image1.Height);
Image1.Update;
end;
iedbMetal:
begin
ImageEnView1.Background:=clSilver;
IECreateOSXBackgroundMetal(Image1.Picture.Bitmap,Image1.Width,Image1.Height);
Image1.Update;
end;
end;
end;
{$ELSE} // {$ifdef IEINCLUDEPRINTDIALOGS}
interface
implementation
{$ENDIF}
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -