IDE: build modes: picklist for types

git-svn-id: trunk@23168 -
This commit is contained in:
mattias 2009-12-17 16:24:54 +00:00
parent c7786f3099
commit 488b027106

View File

@ -26,9 +26,9 @@ interface
uses uses
Classes, SysUtils, LCLProc, Controls, FileUtil, LResources, Forms, Grids, Classes, SysUtils, LCLProc, Controls, FileUtil, LResources, Forms, Grids,
Menus, ComCtrls, Dialogs, Menus, ComCtrls, Dialogs, AvgLvlTree,
IDEImagesIntf, ProjectIntf, IDEImagesIntf,
LazarusIDEStrConsts, CompilerOptions, IDEProcs; Project, PackageSystem, LazarusIDEStrConsts, CompilerOptions, IDEProcs;
type type
@ -65,6 +65,7 @@ type
function ValidateCell(const ACol, ARow: Integer; function ValidateCell(const ACol, ARow: Integer;
var NewValue:string): boolean; var NewValue:string): boolean;
procedure UpdateIndexInGroup(aRow: integer); procedure UpdateIndexInGroup(aRow: integer);
procedure UpdateTypePickList;
public public
constructor Create(TheOwner: TComponent); override; constructor Create(TheOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
@ -162,10 +163,10 @@ begin
TypeCol:=GroupModeCount+1; TypeCol:=GroupModeCount+1;
ValueCol:=TypeCol+1; ValueCol:=TypeCol+1;
if i=0 then begin if i=0 then begin
Cells[0, 0]:=lisBuildMode; Columns[0].Title.Caption:=lisBuildMode;
for i:=1 to GroupModeCount do Cells[i,0]:=''; for i:=1 to GroupModeCount do Columns[i].Title.Caption:='';
Cells[TypeCol, 0]:=dlgEnvType; Columns[TypeCol].Title.Caption:=dlgEnvType;
Cells[ValueCol, 0]:=dlgValueColor; Columns[ValueCol].Title.Caption:=dlgValueColor;
end else begin end else begin
CurRow:=ModeRows[i-1]; CurRow:=ModeRows[i-1];
// name // name
@ -282,6 +283,67 @@ begin
end; end;
end; end;
procedure TBuildModesGrid.UpdateTypePickList;
var
Identifiers: TStringToStringTree;
procedure AddVar(V: TLazBuildVariable);
begin
if (V.Identifier='') or (not IsValidIdent(V.Identifier)) then exit;
if Identifiers.Contains(V.Identifier) then exit;
Identifiers[V.Identifier]:='';
end;
procedure AddVars(Vars: TLazBuildVariables);
var
i: Integer;
begin
for i:=0 to Vars.Count-1 do
AddVar(Vars.Items[i]);
end;
var
TypeCol: Integer;
i: Integer;
Node: TAvgLvlTreeNode;
t: TBuildModeFlagType;
s: String;
sl: TStringList;
begin
TypeCol:=GroupModeCount+1;
Identifiers:=TStringToStringTree.Create(false);
sl:=nil;
try
// add types
for t:=low(TBuildModeFlagType) to high(TBuildModeFlagType) do
begin
s:=BuildModeFlagTypeCaptions(t);
if s<>'' then
Identifiers[s]:='';
end;
// add standard variable names
Identifiers['TargetOS']:='';
Identifiers['TargetCPU']:='';
// add package variable names
for i:=0 to PackageGraph.Count-1 do
AddVars(PackageGraph.Packages[i].CompilerOptions.BuildVariables);
// add project variable names
AddVars(Project1.CompilerOptions.BuildVariables);
sl:=TStringList.Create;
Node:=Identifiers.Tree.FindLowest;
while Node<>nil do begin
sl.Add(PStringToStringItem(Node.Data)^.Name);
Node:=Identifiers.Tree.FindSuccessor(Node);
end;
Columns[TypeCol].PickList:=sl;
finally
sl.Free;
Identifiers.Free;
end;
end;
function TBuildModesGrid.GetModeRowCount: integer; function TBuildModesGrid.GetModeRowCount: integer;
begin begin
Result:=FModeRows.Count; Result:=FModeRows.Count;
@ -452,16 +514,28 @@ begin
// setup grid // setup grid
RowCount:=FModeRows.Count+1; RowCount:=FModeRows.Count+1;
FixedRows:=1; FixedRows:=1;
ColCount:=GroupModeCount+3;
FixedCols:=0; FixedCols:=0;
DebugLn(['TBuildModesGrid.RebuildGrid AAA0 ',Columns.Count,' ',ColCount,' ',TypeCol,' ',GroupModeCount]);
while Columns.Count<GroupModeCount+3 do
Columns.Add;
while Columns.Count>GroupModeCount+3 do
Columns.Delete(Columns.Count-1);
TypeCol:=GroupModeCount+1; TypeCol:=GroupModeCount+1;
DebugLn(['TBuildModesGrid.RebuildGrid AAA1 ',Columns.Count,' ',ColCount,' ',TypeCol,' ',GroupModeCount]);
ValueCol:=TypeCol+1; ValueCol:=TypeCol+1;
ColWidths[0]:=150; Columns[0].Width:=150;
ColWidths[TypeCol]:=120; for i:=1 to TypeCol-1 do
ColWidths[ValueCol]:=1000; Columns[i].Width:=20;
DebugLn(['TBuildModesGrid.RebuildGrid AAA2 ',Columns.Count,' ',ColCount,' ',TypeCol,' ',GroupModeCount]);
Columns[TypeCol].Width:=120;
Columns[TypeCol].ButtonStyle:=cbsPickList;
Columns[ValueCol].Width:=1000;
// fill cells // fill cells
for i:=0 to ModeRowCount do for i:=0 to ModeRowCount do
FillGridRow(i); FillGridRow(i);
UpdateTypePickList;
end; end;
{ TBuildModeGridRow } { TBuildModeGridRow }