1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
|
{*****************************************}
{ }
{ FastReport v2.3 }
{ Page options }
{ }
{ Copyright (c) 1998-99 by Tzyganenko A. }
{ }
{*****************************************}
unit LR_pgopt;
interface
{$I LR_Vers.inc}
uses
Classes, SysUtils, LResources,
Forms, Controls, Graphics, Dialogs,
ExtCtrls, Buttons, StdCtrls,ComCtrls,LCLType, ButtonPanel, Spin, Printers;
type
{ TfrPgoptForm }
TfrPgoptForm = class(TForm)
ButtonPanel1: TButtonPanel;
CB5: TCheckBox;
E3: TEdit;
E4: TEdit;
E5: TEdit;
E6: TEdit;
GroupBox4: TGroupBox;
imgColumns: TImage;
imgRows: TImage;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
lblLayout: TLabel;
PageControl1: TPageControl;
ecolCount: TSpinEdit;
Panel1: TPanel;
RBColumns: TRadioButton;
RBRows: TRadioButton;
RB1: TRadioButton;
RB2: TRadioButton;
TabSheet1: TTabSheet;
TabSheet3: TTabSheet;
GroupBox2: TGroupBox;
imgLandScape: TImage;
imgPortrait: TImage;
GroupBox1: TGroupBox;
CB1: TCheckBox;
GroupBox3: TGroupBox;
ComB1: TComboBox;
E1: TEdit;
E2: TEdit;
Label1: TLabel;
Label2: TLabel;
GroupBox5: TGroupBox;
Label7: TLabel;
E7: TEdit;
Label8: TLabel;
procedure ComB1DrawItem(Control: TWinControl; Index: Integer; ARect: TRect;
State: TOwnerDrawState);
procedure ComB1Select(Sender: TObject);
procedure E1Change(Sender: TObject);
procedure ecolCountChange(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure RB1Click(Sender: TObject);
procedure RB2Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure CB5Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure RBColumnsClick(Sender: TObject);
procedure RBRowsClick(Sender: TObject);
private
{ Private declarations }
FCustomWidth, FCustomHeight: Integer;
function GetPgSize: Integer;
procedure UpdateColumnsLayout;
procedure UpdatePaperSize;
public
{ Public declarations }
property PgSize: Integer read GetPgSize;
property PaperWidth: Integer read FCustomWidth write FCustomWidth;
property PaperHeight: Integer read FCustomHeight write FCustomHeight;
end;
var
frPgoptForm: TfrPgoptForm;
implementation
{$R *.lfm}
uses LR_Prntr, LR_Class, LR_Const, LR_Utils, Math;
procedure TfrPgoptForm.RB1Click(Sender: TObject);
begin
ImgPortrait.Show;
ImgLandscape.Visible:=False;
end;
procedure TfrPgoptForm.ComB1DrawItem(Control: TWinControl; Index: Integer;
ARect: TRect; State: TOwnerDrawState);
var
S: String;
i: Integer;
begin
with TCombobox(Control) do begin
if odSelected in State then
Canvas.Brush.Color := clHighLight
else
Canvas.Brush.Color:=clWindow;
Canvas.FillRect(aRect);
Canvas.TextRect(aRect, aRect.Left + 17, aRect.Top+ 3, Items[Index]);
aRect.Right := aRect.Left + 16;
Canvas.Brush.Color := clWhite;
Canvas.FillRect(aRect);
i := PtrInt(Items.Objects[Index]);
if (i>=1)and(i<=MAX_TYP_KNOWN) then S := 'W' else // Known Windows std paper size
if (i>MAX_TYP_KNOWN) and (i<256) then S := 'w' else // Unknown Windows std paper size
if (i=256) then S := 'U' else // User Defined paper size
if (i>=2000) and (i<2050) then S := 'I' // Looks like an Input Slot
else S := 'C'; // Known Custom No-Std Paper Size
Canvas.Font.Color := clWindowText;
Canvas.TextRect(aRect, aRect.Left+1, aRect.Top+3, S);
end;
end;
procedure TfrPgoptForm.ComB1Select(Sender: TObject);
begin
UpdatePaperSize;
end;
procedure TfrPgoptForm.E1Change(Sender: TObject);
begin
if pgSize=256 then begin
if Sender=E1 then FCustomWidth := StrToIntDef(E1.Text, 0);
if Sender=E2 then FCustomHeight := StrToIntDef(E2.Text, 0);
end;
end;
procedure TfrPgoptForm.ecolCountChange(Sender: TObject);
begin
UpdateColumnsLayout;
end;
procedure TfrPgoptForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if (ModalResult=mrOk) and (PgSize=256) then
begin
canClose := (PaperWidth>1) and (PaperHeight>1);
if not canClose then
ShowMessage(sPgoptFormInvalidCustomPaperSize);
end;
end;
procedure TfrPgoptForm.RB2Click(Sender: TObject);
begin
ImgLandscape.Show;
ImgPortrait.Visible:=False;
end;
procedure TfrPgoptForm.FormActivate(Sender: TObject);
begin
OnActivate:=nil;
if RB1.Checked then
RB1Click(nil)
else
RB2Click(nil);
UpdatePaperSize;
CB5Click(nil);
ComB1.Width:=E1.Width;
ecolCount.Width:=E1.Width;
Label3.Left:=Max(Label3.Left, Label4.Width + Label4.Left);
Label3.Left:=Max(Label3.Left, Label5.Width + Label5.Left);
UpdateColumnsLayout;
end;
procedure TfrPgoptForm.CB5Click(Sender: TObject);
begin
frEnableControls([Label3, Label4, Label5, Label6, E3, E4, E5, E6],
not CB5.Checked);
end;
procedure TfrPgoptForm.FormCreate(Sender: TObject);
begin
Caption := sPgoptFormCapt + ' - ' + QuotedStr(prn.Printer.PrinterName);
TabSheet1.Caption := sPgoptFormPaper;
GroupBox2.Caption := sPgoptFormOr;
RB1.Caption := sPgoptFormPort;
RB2.Caption := sPgoptFormLand;
GroupBox3.Caption :=sPgoptFormSize;
Label1.Caption := sPgoptFormWidth;
Label2.Caption := sPgoptFormHeight;
GroupBox4.Caption := sPgoptFormPgMargins;
Label3.Caption := sPgoptFormLeft;
Label4.Caption := sPgoptFormTop;
Label5.Caption := sPgoptFormRight;
Label6.Caption := sPgoptFormBottom;
CB5.Caption := sPgoptFormDontUse;
TabSheet3.Caption := sPgoptFormOptions;
GroupBox1.Caption := sPgoptFormOptions;
CB1.Caption := sPgoptFormpRINT;
GroupBox5.Caption := sPgoptFormColumn;
Label7.Caption := sPgoptFormNumber;
Label8.Caption := sPgoptFormColGap;
lblLayout.Caption := sPgoptFormLayoutOrder;
RBColumns.Caption := sPgoptFormByColumns;
RBRows.Caption := sPgoptFormByRows;
end;
procedure TfrPgoptForm.RBColumnsClick(Sender: TObject);
begin
ImgColumns.Visible:=true;
ImgRows.Visible:=false;
end;
procedure TfrPgoptForm.RBRowsClick(Sender: TObject);
begin
ImgColumns.Visible:=false;
ImgRows.Visible:=true;
end;
function TfrPgoptForm.GetPgSize: Integer;
begin
result := PtrInt(ComB1.Items.Objects[Comb1.ItemIndex]);
end;
procedure TfrPgoptForm.UpdateColumnsLayout;
begin
if EColCount.Value<2 then begin
RBColumns.Enabled:=false;
RBRows.Enabled:=false;
end else begin
RBColumns.Enabled:=true;
RBRows.Enabled:=true;
end;
end;
procedure TfrPgoptForm.UpdatePaperSize;
var
isCustom: Boolean;
pgIndex: Integer;
PaperRect: TPaperRect;
begin
isCustom := (pgSize = $100);
frEnableControls([Label1, Label2, E1, E2], isCustom);
if isCustom then begin
E1.Text := IntToStr(PaperWidth);
E2.Text := IntToStr(PaperHeight);
end else begin
pgIndex := prn.GetArrayPos(pgSize);
PaperRect := prn.Printer.PaperSize.PaperRectOf[prn.PaperNames[pgIndex]];
E1.Text := IntToStr(round(PaperRect.PhysicalRect.Width*25.4/prn.Printer.XDPI));
E2.Text := IntToStr(round(PaperRect.PhysicalRect.Height*25.4/prn.Printer.YDPI));
end;
end;
end.
|