mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-03 05:23:47 +02:00

* Added additional key ProjectFile= Any file whose name (no extension) matches this, will be renamed to __PROJNAME__ * Improved variables dialog: when there is no message, the grid is disabled, and the message adapted accordingly git-svn-id: trunk@16196 -
125 lines
2.7 KiB
ObjectPascal
125 lines
2.7 KiB
ObjectPascal
unit frmTemplateVariables;
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,
|
|
Grids, ProjectTemplates, Buttons, StdCtrls, EditBtn;
|
|
|
|
type
|
|
|
|
{ TProjectVariablesForm }
|
|
|
|
TProjectVariablesForm = class(TForm)
|
|
BOK: TButton;
|
|
BCancel: TButton;
|
|
DEProject: TDirectoryEdit;
|
|
EProjectName: TEdit;
|
|
Label1: TLabel;
|
|
Label2: TLabel;
|
|
PDescription: TPanel;
|
|
SGVariables: TStringGrid;
|
|
procedure BOKClick(Sender: TObject);
|
|
procedure ProjectVariablesFormShow(Sender: TObject);
|
|
private
|
|
FSChanged: Boolean;
|
|
FTemplates: TProjectTemplates;
|
|
{ private declarations }
|
|
FVariables : TStrings;
|
|
function GetProjectDir: String;
|
|
function GetProjectName: String;
|
|
procedure SetVariables(const AValue: TStrings);
|
|
public
|
|
{ public declarations }
|
|
Property Templates : TProjectTemplates Read FTemplates Write FTemplates;
|
|
Property ProjectName : String Read GetProjectName;
|
|
Property ProjectDir : String Read GetProjectDir;
|
|
Property Variables : TStrings Read FVariables Write SetVariables;
|
|
Property SettingsChanged: Boolean Read FSChanged Write FSChanged;
|
|
end;
|
|
|
|
var
|
|
ProjectVariablesForm: TProjectVariablesForm;
|
|
|
|
implementation
|
|
|
|
ResourceString
|
|
SVariable = 'Variable';
|
|
SValue = 'Value';
|
|
SDescription = 'Description';
|
|
SNoAdditionalVars = 'This project has no additional variables.';
|
|
|
|
|
|
{ TProjectVariablesForm }
|
|
|
|
procedure TProjectVariablesForm.ProjectVariablesFormShow(Sender: TObject);
|
|
begin
|
|
SGVariables.Cells[0,0]:=SVariable;
|
|
SGVariables.Cells[1,0]:=SValue;
|
|
SGVariables.Cells[2,0]:=SDescription;
|
|
end;
|
|
|
|
procedure TProjectVariablesForm.BOKClick(Sender: TObject);
|
|
|
|
Var
|
|
N,V : String;
|
|
I : Integer;
|
|
|
|
begin
|
|
For I:=0 to FVariables.Count-1 do
|
|
begin
|
|
V:='';
|
|
N:='';
|
|
FVariables.GetNameValue(I,N,V);
|
|
V:=SGVariables.Cells[1,I+1];
|
|
FVariables[i]:=N+'='+V;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TProjectVariablesForm.SetVariables(const AValue: TStrings);
|
|
|
|
Var
|
|
N,V : String;
|
|
I : Integer;
|
|
|
|
begin
|
|
FVariables:=AValue;
|
|
If (FVariables.Count=0) then
|
|
begin
|
|
SGVariables.Enabled:=False;
|
|
PDescription.Caption:=SNoAdditionalVars;
|
|
end
|
|
else
|
|
begin
|
|
SGVariables.RowCount:=FVariables.Count+1;
|
|
For I:=1 to FVariables.Count do
|
|
begin
|
|
V:='';
|
|
N:='';
|
|
FVariables.GetNameValue(I-1,N,V);
|
|
SGVariables.Cells[0,I]:=N;
|
|
SGVariables.Cells[1,I]:='';
|
|
SGVariables.Cells[2,I]:=V;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
function TProjectVariablesForm.GetProjectDir: String;
|
|
begin
|
|
Result:=DEProject.Text;
|
|
end;
|
|
|
|
function TProjectVariablesForm.GetProjectName: String;
|
|
begin
|
|
Result:=EProjectName.Text;
|
|
end;
|
|
|
|
initialization
|
|
{$I frmtemplatevariables.lrs}
|
|
|
|
end.
|
|
|