File: frmgenoptions.pp

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 (106 lines) | stat: -rw-r--r-- 2,399 bytes parent folder | download | duplicates (8)
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
unit frmgenoptions;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  ButtonPanel, EditBtn;

type

  { TGenCodeFormOptions }

  TGenCodeFormOptions = class(TForm)
    ButtonPanel1: TButtonPanel;
    CBView: TCheckBox;
    EBaseClass: TEdit;
    EUnitName: TEdit;
    EExtraUnits: TEdit;
    EPrefix: TEdit;
    EFileName: TFileNameEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    LFileName: TLabel;
    procedure EUnitNameEditingDone(Sender: TObject);
  private
    function GetB: Boolean;
    function GetS(AIndex: Integer): String;
    procedure SetB(AValue: Boolean);
    procedure SetS(AIndex: Integer; AValue: String);
    { private declarations }
  public
    { public declarations }
    Property FileName : String index 0 read GetS Write SetS;
    Property UnitName : String index 1 read GetS Write SetS;
    Property ExtraUnits : String index 2 read GetS Write SetS;
    Property Prefix : String index 3 read GetS Write SetS;
    Property BaseClass : String index 4  read GetS Write SetS;
    Property DoPreview : Boolean Read GetB Write SetB;
  end;

var
  GenCodeFormOptions: TGenCodeFormOptions;

implementation

{$R *.lfm}

{ TGenCodeFormOptions }

procedure TGenCodeFormOptions.EUnitNameEditingDone(Sender: TObject);

Var
  E,FN : String;

begin
  E:=ExtractFileExt(EFileName.FileName);
  if E='' then
    E:=EFileName.DefaultExt;
  FN:=ExtractFilePath(EFileName.FileName);
  if FN='' then
    FN:=IncludeTrailingPathDelimiter(Application.Location);
  FN:=FN+EUnitName.Text+E;
  EFileName.FileName:=FN;
end;

function TGenCodeFormOptions.GetB: Boolean;
begin
  Result:=CBView.Checked;
end;

function TGenCodeFormOptions.GetS(AIndex: Integer): String;
begin
  Case AIndex of
    0 : Result:=EFileName.Text;
    1 : Result:=EUnitName.Text;
    2 : Result:=EExtraUnits.Text;
    3 : Result:=EPRefix.Text;
    4 : Result:=EBaseClass.Text;
  end;
end;

procedure TGenCodeFormOptions.SetB(AValue: Boolean);
begin
  CBView.Checked:=AValue
end;

procedure TGenCodeFormOptions.SetS(AIndex: Integer; AValue: String);
begin
  Case AIndex of
    0 : EFileName.Text:=Avalue;
    1 : begin
        EUnitName.Text:=AValue;
        EUnitNameEditingDone(EUnitName);
        end;
    2 : EExtraUnits.Text:=AValue;
    3 : EPRefix.Text:=AValue;
    4 : EBaseClass.Text:=AValue;
  end;
end;

end.