1 unit fExportPref;
2 
3 {$mode objfpc}{$H+}
4 
5 interface
6 
7 uses
8   Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
9   StdCtrls, frExportPref;
10 
11 type
12 
13   { TfrmExportPref }
14 
15   TfrmExportPref = class(TForm)
16     btnOK : TButton;
17     btnCancel : TButton;
18     btnReSet: TButton;
19     CheckBox1: TCheckBox;
20     fraExportPref1: TfraExportPref;
21     procedure btnOKClick(Sender : TObject);
22     procedure btnReSetClick(Sender: TObject);
23     procedure chkAutoColumnChange(Sender: TObject);
24     procedure FormShow(Sender : TObject);
25   private
26     { private declarations }
27   public
28     { public declarations }
29     Procedure HideWidths(Hid:Boolean);
30     Procedure HideAll(Hid:Boolean);
31   end;
32 
33 var
34   frmExportPref : TfrmExportPref;
35   AllChk        : Boolean = False;
36 
37 implementation
38 {$R *.lfm}
39 
40 uses dUtils,fMain;
41 
42 { TfrmExportPref }
43 Procedure TfrmExportPref.HideAll(Hid:Boolean);
44 var  i : integer;
45 Begin
46 for i := 0 to fraExportPref1.ComponentCount - 1 do
47     if fraExportPref1.Components[i] is TEdit then
48        tedit(fraExportPref1.Components[i]).Visible := not Hid;
49 end;
50 Procedure TfrmExportPref.HideWidths(Hid:Boolean);
51 var  i : integer;
52 Begin
53    for i := 0 to fraExportPref1.ComponentCount - 1 do
54     if fraExportPref1.Components[i] is TEdit then
55        if (StrToIntDef(tedit(fraExportPref1.Components[i]).Text,-1) > -1 ) then
56           tedit(fraExportPref1.Components[i]).Visible := not Hid;
57 end;
58 
59 procedure TfrmExportPref.FormShow(Sender : TObject);
60 begin
61   dmUtils.LoadFontSettings(frmExportPref);
62   fraExportPref1.LoadExportPref;
63   if  not frmMain.ShowWidths then //this is ADIF export case
64      Begin
65        HideAll(True);
66        fraExportPref1.chkAutoColumn.Visible := False;
67      end
68    else if fraExportPref1.chkAutoColumn.Checked = True then // HTML export but auto column checked
69      HideWidths(true);
70 end;
71 
72 procedure TfrmExportPref.btnOKClick(Sender : TObject);
73 begin
74   fraExportPref1.SaveExportPref;
75   ModalResult := mrOK
76 end;
77 
78 procedure TfrmExportPref.btnReSetClick(Sender: TObject);
79 var  i : integer;
80 begin
81     for i := 0 to fraExportPref1.ComponentCount - 1 do
82       if fraExportPref1.Components[i] is TCheckbox then
83          tcheckbox(fraExportPref1.Components[i]).checked := AllChk;
84     AllChk := not AllChk;
85 end;
86 
87 procedure TfrmExportPref.chkAutoColumnChange(Sender: TObject);
88 begin
89   if frmMain.ShowWidths then // only in HTML export
90    Begin
91       if fraExportPref1.chkAutoColumn.Checked = True then
92          HideWidths(True)
93        else
94          HideWidths(False);
95    end;
96 end;
97 
98 
99 end.
100 
101