1 {
2  ***************************************************************************
3  *                                                                         *
4  *   This source is free software; you can redistribute it and/or modify   *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This code is distributed in the hope that it will be useful, but      *
10  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
12  *   General Public License for more details.                              *
13  *                                                                         *
14  *   A copy of the GNU General Public License is available on the World    *
15  *   Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also      *
16  *   obtain it by writing to the Free Software Foundation,                 *
17  *   Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA.   *
18  *                                                                         *
19  ***************************************************************************
20 
21 }
22 unit frmCustomApplicationOptions;
23 
24 {$mode objfpc}{$H+}
25 
26 interface
27 
28 uses
29   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
30   ExtCtrls, Buttons,ButtonPanel,
31   LazarusIDEStrConsts;
32 
33 type
34 
35   { TCustomApplicationOptionsForm }
36 
37   TCustomApplicationOptionsForm = class(TForm)
38     ButtonPanel:TButtonPanel;
39     CGOptions: TCheckGroup;
40     EClassName: TEdit;
41     ETitle: TEdit;
42     LETitle: TLabel;
43     LEClassName: TLabel;
44     procedure EClassNameKeyPress(Sender: TObject; var Key: char);
45     procedure FormCreate(Sender: TObject);
GetAppNamenull46     function GetAppName: String;
GetBoolnull47     function GetBool(Index: integer): Boolean;
GetTitlenull48     function GetTitle: String;
49   private
50     { private declarations }
51   public
52     { public declarations }
53     Property Title : String Read GetTitle;
54     Property AppClassName : String Read GetAppName;
55     Property CodeUsage : Boolean Index 0 Read GetBool;
56     Property CodeStopOnError : Boolean Index 1 Read GetBool;
57     Property CodeConstructor : Boolean Index 2 Read GetBool;
58     Property CodeDestructor : Boolean Index 3 Read GetBool;
59     Property CodeCheckOptions : Boolean Index 4 Read GetBool;
60   end;
61 
62 var
63   CustomApplicationOptionsForm: TCustomApplicationOptionsForm;
64 
65 implementation
66 
67 {$R *.lfm}
68 
69 { TCustomApplicationOptionsForm }
70 
TCustomApplicationOptionsForm.GetAppNamenull71 function TCustomApplicationOptionsForm.GetAppName: String;
72 begin
73   Result:=EClassName.Text;
74 end;
75 
76 procedure TCustomApplicationOptionsForm.EClassNameKeyPress(Sender: TObject;
77   var Key: char);
78 
79 Const
80   Alpha = ['a'..'z','A'..'Z'];
81   Num   = ['0'..'9'];
82   Oth   = ['_',#8,#9,#27]; // allow Backspace, tab, escape
83   AllowedKeys = Alpha+Num+Oth;
84 
85 begin
86   If Not (Key in AllowedKeys) then
87     Key:=#0;
88 end;
89 
90 procedure TCustomApplicationOptionsForm.FormCreate(Sender: TObject);
91 var
92   i: Integer;
93 begin
94   Caption:= lisNewConsoleApplication;
95   LEClassName.Caption:= lisApplicationClassName;
96   LETitle.Caption:= lisTitle;
97   CGOptions.Caption:= lisCodeGenerationOptions;
98   CGOptions.Items.Clear;
99   CGOptions.Items.Add(lisUsageMessageHOption);
100   CGOptions.Items.Add(lisStopOnException);
101   CGOptions.Items.Add(lisConstructorCode);
102   CGOptions.Items.Add(lisDestructorCode);
103   CGOptions.Items.Add(lisCheckOptions);
104 
105   ButtonPanel.OKButton.Caption:=lisMenuOk;
106   ButtonPanel.CancelButton.Caption:=lisCancel;
107 
108   // set all defaults to true
109   for i:=0 to CGOptions.Items.Count-1 do
110     CGOptions.Checked[i]:= true;
111 end;
112 
GetBoolnull113 function TCustomApplicationOptionsForm.GetBool(Index: integer): Boolean;
114 begin
115   Result:= CGOptions.Checked[Index];
116 end;
117 
TCustomApplicationOptionsForm.GetTitlenull118 function TCustomApplicationOptionsForm.GetTitle: String;
119 begin
120   Result:=ETitle.Text;
121 end;
122 
123 end.
124 
125