cmdlinecfg:

* minimized TCmdLineLayoutInfo class public section;
* updated the TCmdLineScrollBoxControl loader to use %%other switch; using hash list to check of used/unused controls;
* updated readme.txt description for UI layout controls;
* updated IDE package to make the dialog look close to the existing compiler options;
* updated testguibuild to be able to load a certain section only;
* added smaller sample files for testguibuild, modified conf.coptui to have %%other switch, where all "non-default" compiler options would go;

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2806 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
skalogryz
2013-10-12 17:15:48 +00:00
parent c63c5bb6b7
commit 33dadcd154
15 changed files with 474 additions and 148 deletions

View File

@@ -3,8 +3,7 @@ unit cmdlinecfgui;
interface
uses
Classes, SysUtils,
cmdlinecfg;
Classes, SysUtils, contnrs, cmdlinecfg;
type
{ TCmdLineLayoutInfo }
@@ -15,6 +14,7 @@ type
{ TLayoutSection }
TLayoutElementType = (letSwitch, letSection);
TLayoutElementTypes = set of TLayoutElementType;
TLayoutSection = class(TObject)
//level : integer; // number of "dots" in the name
@@ -27,22 +27,17 @@ type
Elements : array of TLayoutSection;
ElemCount : integer;
function AddElement(const AName: string; AElementType: TLayoutElementType): TLayoutSection;
constructor Create(const AName: string = ''; AElementType: TLayoutElementType = letSection);
destructor Destroy; override;
property Name: string read fName;
property ElementType: TLayoutElementType read fElementType;
end;
TCmdLineLayoutInfo = class(TObject)
private
fSections: TStringList;
fValidOrder: Boolean;
function DoGetSection(const SectName: String; Forced: Boolean = true): TLayoutSection;
public
RootElement : TLayoutSection;
constructor Create;
destructor Destroy; override;
function AddSection(const Section: string): TLayoutSection;
function GetSection(const Section: string): TLayoutSection;
//function GetSwitches(const Section: string; Dst: TStrings): Boolean;
end;
{ TCmdLineUIControl }
@@ -53,14 +48,94 @@ type
protected
procedure ValueChanged; virtual;
public
procedure Init(cfg: TCmdLineCfg; layout: TCmdLineLayoutInfo); virtual; abstract;
procedure Init(cfg: TCmdLineCfg; layout: TCmdLineLayoutInfo; const ASection : string = ''); virtual; abstract;
procedure SetValues(list: TList {of TCmdLineOptionValue}); virtual; abstract;
procedure Serialize(list: TList {of TCmdLineOptionValue}); virtual; abstract;
property OnValueChanged: TNotifyEvent read FValueChanged write fValueChanged;
end;
function LayoutFindElement(aparent: TLayoutSection; const Name: string; LookFor: TLayoutElementTypes = [letSection] ): TLayoutSection;
procedure LayoutEnumElement(aparent: TLayoutSection; list: TList; LookFor: TLayoutElementTypes = [letSection] );
procedure LayoutGetUnused(cmd: TCmdLineCfg; layout: TLayoutSection; list: TList);
implementation
procedure LayoutGetSwitches(root: TLayoutSection; hash: TFPHashObjectList);
var
sct : TList;
i : Integer;
j : Integer;
el : TLayoutSection;
sel : TLayoutSection;
begin
sct:=TList.Create;
try
sct.Add(root);
j:=0;
while j<sct.Count do begin
el:=TLayoutSection(sct[j]);
for i:=0 to el.ElemCount-1 do begin
sel:=el.Elements[i];
if sel.ElementType = letSection then
sct.Add(sel)
else begin
hash.Add(sel.Name, sel);
end;
end;
inc(j);
end;
finally
sct.Free;
end;
end;
procedure LayoutEnumElement(aparent: TLayoutSection; list: TList;
LookFor: TLayoutElementTypes);
var
i : integer;
begin
if not Assigned(list) or not Assigned(aparent) or (LookFor = []) then Exit;
for i:=0 to aparent.ElemCount-1 do begin
if aparent.Elements[i].ElementType in LookFor then
list.Add(aparent.Elements[i]);
end;
end;
procedure LayoutGetUnused(cmd: TCmdLineCfg; layout: TLayoutSection; list: TList);
var
i : Integer;
hash : TFPHashObjectList;
opt : TCmdLineCfgOption;
begin
if not Assigned(cmd) or not Assigned(layout) or not Assigned(list) then Exit;
hash := TFPHashObjectList.Create(false);
try
LayoutGetSwitches(layout, hash);
for i:=0 to cmd.Options.Count-1 do begin
opt:=TCmdLineCfgOption(cmd.Options[i]);
if not Assigned(hash.Find(opt.Name)) then begin
list.Add(opt);
end;
end;
finally
hash.Free;
end;
end;
function LayoutFindElement(aparent: TLayoutSection; const Name: string; LookFor: TLayoutElementTypes = [letSection]): TLayoutSection;
var
i : integer;
nm : string;
begin
Result:=nil;
if not Assigned(aparent) or (LookFor = []) then Exit;
nm:=AnsiLowerCase(Name);
for i:=0 to aparent.ElemCount-1 do
if (aparent.Elements[i].fElementType in LookFor) and (AnsiLowerCase(aparent.Elements[i].Name)=nm) then
Result:=aparent.Elements[i];
end;
{ TLayoutSection }
function TLayoutSection.AddElement(const AName: string; AElementType: TLayoutElementType): TLayoutSection;
@@ -69,14 +144,20 @@ begin
if ElemCount=0 then SetLength(Elements, 2)
else SetLength(Elements, ElemCount*2);
end;
Result:=TLayoutSection.Create;
Result.fName:=AName;
Result.fElementType:=AElementType;
Result:=TLayoutSection.Create(AName, AElementType);
Result.Display:=Aname;
Elements[ElemCount]:=Result;
inc(ElemCount);
end;
constructor TLayoutSection.Create(const AName: string;
AElementType: TLayoutElementType);
begin
inherited Create;
fName:=AName;
fElementType:=AElementType;
end;
destructor TLayoutSection.Destroy;
var
i : integer;
@@ -86,7 +167,7 @@ begin
end;
{ TCmdLineLayoutInfo }
{
function TCmdLineLayoutInfo.DoGetSection(const SectName: String; Forced: Boolean): TLayoutSection;
var
i : integer;
@@ -101,18 +182,17 @@ begin
end else
Result:=TLayoutSection(fSections.Objects[i]);
end;
}
constructor TCmdLineLayoutInfo.Create;
begin
fSections:=TStringList.Create;
fSections.OwnsObjects:=true;
AddSection('');
RootElement:=TLayoutSection.Create;
RootElement.fName:='';
RootElement.fElementType:=letSection;
end;
destructor TCmdLineLayoutInfo.Destroy;
begin
fSections.Clear; // need to call clear explicitly, since FREE doesn't free objects (even if owned)
fSections.Free;
RootElement.Free;
inherited Destroy;
end;
@@ -121,7 +201,7 @@ end;
begin
GetSection(Section).fswitches.Add(SwitchOrName);
end;}
{
function TCmdLineLayoutInfo.AddSection(const Section: string): TLayoutSection;
begin
Result:=DoGetSection(Section, true);
@@ -131,7 +211,7 @@ function TCmdLineLayoutInfo.GetSection(const Section: string): TLayoutSection;
begin
Result:=DoGetSection(Section, false);
end;
}
{function TCmdLineLayoutInfo.GetSections(Dst: TStrings): Boolean;
var
i : Integer;