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
| unit FeuilleEtiquettes;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
System.Math,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
FMX.Edit, FMX.EditBox, FMX.SpinBox, FMX.MultiView, FMX.Layouts,
FMX.Controls.Presentation, FMX.Objects;
type
TForm1stPage = class(TForm)
Feuille: TGridPanelLayout;
Header: TLayout;
btnMenu: TButton;
MultiView1: TMultiView;
Colonnes: TSpinBox;
Lignes: TSpinBox;
btnRedraw: TButton;
lblColonnes: TLabel;
lblLignes: TLabel;
Hauteur: TSpinBox;
Largeur: TSpinBox;
lblLargeur: TLabel;
lblHauteur: TLabel;
GroupEtiquettes: TGroupBox;
GroupFeuille: TGroupBox;
Footer: TLayout;
btnOk: TButton;
procedure MultiView1Shown(Sender: TObject);
procedure btnRedrawClick(Sender: TObject);
procedure MultiView1Hidden(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure btnOkClick(Sender: TObject);
private
{ Déclarations privées }
procedure Drawlabels(Cols, Lines : word);
procedure Zoom;
public
{ Déclarations publiques }
end;
var
Form1stPage: TForm1stPage;
implementation
{$R *.fmx}
procedure TForm1stPage.btnOkClick(Sender: TObject);
begin
ModalResult:=mrOk;
end;
procedure TForm1stPage.btnRedrawClick(Sender: TObject);
begin
MultiView1.HideMaster;
end;
procedure TForm1stPage.Drawlabels(Cols, Lines: word);
var c,l,n : word;
APanel : TPanel;
begin
Feuille.BeginUpdate;
Feuille.Height:=Trunc(Hauteur.Value);
Feuille.Width:=Trunc(Largeur.Value);
Zoom;
Feuille.ControlCollection.Clear;
Feuille.RowCollection.Clear;
Feuille.ColumnCollection.Clear;
for l := 1 to cols do
begin
With Feuille.ColumnCollection.Add do
begin
SizeStyle:=TGridPanelLayout.TSizeStyle.Percent;
Value:=100 / Cols
end;
end;
for c:= 1 to Lines do
begin
With Feuille.RowCollection.Add do
begin
SizeStyle:=TGridPanelLayout.TSizeStyle.Percent;
Value:=100 / Lines;
end;
end;
for n := 1 to cols*lines do
begin
APanel:=TPanel.Create(Self);
Apanel.StyleLookup:='Etiquette';
Apanel.Parent:=Feuille;
Apanel.Align:=TALignLayout.Client;
Feuille.ControlCollection.AddControl(Apanel,-1,-1);
end;
Feuille.EndUpdate;
end;
procedure TForm1stPage.FormCreate(Sender: TObject);
begin
Hauteur.Value:=297;
Largeur.Value:=210;
Lignes.Value:=7;
Colonnes.Value:=3;
DrawLabels(3,7);
end;
procedure TForm1stPage.FormResize(Sender: TObject);
begin
Zoom;
end;
procedure TForm1stPage.MultiView1Hidden(Sender: TObject);
begin
DrawLabels(Trunc(Colonnes.Value),Trunc(Lignes.Value));
end;
procedure TForm1stPage.MultiView1Shown(Sender: TObject);
begin
Feuille.BeginUpdate;
Feuille.ControlCollection.Clear;
Feuille.RowCollection.Clear;
Feuille.ColumnCollection.Clear;
Feuille.EndUpdate;
end;
procedure TForm1stPage.Zoom;
var factor : Single;
begin
Factor:= (ClientHeight-Header.Height-Footer.Height-20)/Hauteur.Value; // Hauteur
Factor:=Min((ClientWidth-20)/Largeur.Value,factor); // largeur
Feuille.Scale.x:=Factor;
Feuille.Scale.y:=Factor;
end;
end. |