File: lr_pgopt.pas

package info (click to toggle)
lazarus 2.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 214,460 kB
  • sloc: pascal: 1,862,622; xml: 265,709; cpp: 56,595; sh: 3,008; java: 609; makefile: 535; perl: 297; sql: 222; ansic: 137
file content (226 lines) | stat: -rw-r--r-- 5,731 bytes parent folder | download | duplicates (6)
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

{*****************************************}
{                                         }
{             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;

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 ecolCountChange(Sender: TObject);
    procedure RB1Click(Sender: TObject);
    procedure RB2Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure ComB1Click(Sender: TObject);
    procedure CB5Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure RBColumnsClick(Sender: TObject);
    procedure RBRowsClick(Sender: TObject);
  private
    { Private declarations }
    procedure UpdateColumnsLayout;
  public
    { Public declarations }
  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 // Unkknown Windows std paper size
    if (i=256) then S:='U' else             // User Defined paper size
    if (i>=2000) then S:='I' else           // Looks like an Input Slot
    if (i>=1000) then S:='C'                // Known Custom No-Std Paper Size
    else
      S:='?';                               // unknown unclassified paper size
    Canvas.Font.Color := clWindowText;
    Canvas.TextRect(aRect, aRect.Left+1, aRect.Top+3, S);

  end;
end;

procedure TfrPgoptForm.ecolCountChange(Sender: TObject);
begin
  UpdateColumnsLayout;
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);
  ComB1Click(nil);
  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.ComB1Click(Sender: TObject);
begin
  frEnableControls([Label1, Label2, E1, E2],
    Prn.PaperSizes[ComB1.ItemIndex] = $100);
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;
  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;

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;

end.