* Redesigned the directory option menu.

git-svn-id: trunk@3431 -
This commit is contained in:
daniel 2006-05-06 14:35:42 +00:00
parent b1be8ffd32
commit 99760aa507
2 changed files with 283 additions and 50 deletions

View File

@ -635,45 +635,174 @@ begin
end;
{$endif SUPPORT_REMOTE}
procedure TIDEApp.Directories;
var R,R2: TRect;
D: PCenterDialog;
IL : array[0..11] of PEditorInputLine;
Count,I : integer;
const
LW = 25;
procedure TIDEApp.directories;
{Shows a window where the user can configure the directories the compilerproc
will search files or output files to.}
var tab:Ptab;
tabR,R,R2:Trect;
D:PCenterDialog;
s,misc_string:string;
E_units,E_includes,E_libraries,E_objects,e:Pfpmemo;
L_units,L_includes,L_libraries,L_objects:Plabel;
c:PunsortedStringCollection;
count,i,j:integer;
IL:array[0..11] of PEditorInputLine;
misc_items:PTabItem;
misc_tabfocus:Pview;
const LW=25;
begin
Count:=DirectorySwitches^.ItemCount;
R.Assign(0,0,round(ScreenWidth*64/80),2+Count*2);
New(D, Init(R, dialog_directories));
with D^ do
begin
HelpCtx:=hcdirectories;
GetExtent(R);
R.Grow(-2,-2);
Dec(R.B.X);
R.B.Y:=R.A.Y+1;
for i:=Count-1 downto 0 do
begin
R2.Copy(R);
R2.A.X:=LW;
New(IL[i], Init(R2, 255));
IL[i]^.Data^:=DirectorySwitches^.GetStringItem(i);
Insert(IL[i]);
R2.Copy(R);
R2.B.X:=LW;
Insert(New(PLabel, Init(R2, DirectorySwitches^.ItemName(i), IL[i])));
R.Move(0,2);
end;
end;
InsertButtons(D);
IL[Count-1]^.Select;
if Desktop^.ExecView(D)=cmOK then
begin
for i:=Count-1 downto 0 do
DirectorySwitches^.SetStringItem(i,IL[i]^.Data^);
end;
Dispose(D, Done);
R.assign(0,0,screenwidth*64 div 80,18);
new(D,init(R,dialog_directories));
if d^.size.x<72 then
misc_string:='~M~isc.'
else
misc_string:='~M~iscellaneous';
{Create editors.}
R.assign(1,4,d^.size.x-4,d^.size.y-4);
new(E_units,init(R,nil,nil,nil));
R.assign(1,3,d^.size.x-4,4);
new(L_units,init(R,'Unit ~d~irectories:',E_units));
R.assign(1,4,d^.size.x-4,d^.size.y-4);
new(E_includes,init(R,nil,nil,nil));
R.assign(1,3,d^.size.x-4,4);
new(L_includes,init(R,'Include ~d~irectories:',E_includes));
R.assign(1,4,d^.size.x-4,d^.size.y-4);
new(E_libraries,init(R,nil,nil,nil));
R.assign(1,3,d^.size.x-4,4);
new(L_libraries,init(R,'Library ~d~irectories:',E_libraries));
R.assign(1,4,d^.size.x-4,d^.size.y-4);
new(E_objects,init(R,nil,nil,nil));
R.assign(1,3,d^.size.x-4,4);
new(L_objects,init(R,'Object file ~d~irectories:',E_objects));
{The switches that are put into the editors are of type multistring.
We add multistrings to the editor. Other inputboxes are created on
demand on the "Miscellaneous" tab.}
R.assign(1,4,d^.size.x-5,5);
count:=DirectorySwitches^.ItemCount;
misc_items:=nil;
misc_tabfocus:=nil;
for i:=0 to count-1 do
begin
if directorySwitches^.GetItemTyp(i)=ot_MultiString then
begin
case directorySwitches^.itemParam(i)[3] of
'u':
e:=E_units;
'i':
e:=E_includes;
'l':
e:=E_libraries;
'o':
e:=E_objects;
else
messagebox('Internal error: Unknown switch.',nil,mfOkButton);
end;
e^.setcontent(directorySwitches^.getMultiStringItem(i));
e^.addline(''); {Empty line so user can scroll below existing dirs.}
IL[i]:=nil;
end
else
begin
R2.copy(R);
R2.A.X:=LW;
new(IL[i],init(R2,255));
IL[i]^.data^:=DirectorySwitches^.GetStringItem(i);
misc_items:=newTabItem(IL[i],misc_items);
if misc_tabfocus=nil then
misc_tabfocus:=IL[i];
R2.copy(R);
R2.B.X:=LW;
misc_items:=newTabItem(
new(Plabel,init(R2,
DirectorySwitches^.ItemName(i),
IL[i])),
misc_items);
R.move(0,2);
end;
end;
{Create some tabs in the window.}
tabR.assign(1,1,d^.size.x-2,d^.size.y-1);
new(tab,init(tabR,
newtabdef('~U~nits',e_units,
NewTabItem(L_units,
NewTabItem(E_units,
nil)),
NewTabDef('~I~nclude files',E_includes,
NewTabItem(L_includes,
NewTabItem(E_includes,
nil)),
NewTabDef('~L~ibraries',E_libraries,
NewTabItem(L_libraries,
NewTabItem(E_libraries,
nil)),
NewTabDef('~O~bject files',E_objects,
NewTabItem(L_objects,
NewTabItem(E_objects,
nil)),
NewTabDef(misc_string,misc_tabfocus,
misc_items,
nil)))))
));
tab^.growmode:=0;
d^.insert(tab);
insertbuttons(D);
if desktop^.execview(D)=cmOK then
begin
{Move the data from the window back into the switches.}
for i:=0 to count-1 do
if directorySwitches^.GetItemTyp(i)=ot_MultiString then
begin
case directorySwitches^.itemParam(i)[3] of
'u':
e:=E_units;
'i':
e:=E_includes;
'l':
e:=E_libraries;
'o':
e:=E_objects;
else
messagebox('Internal error: Unknown switch.',nil,mfOkButton);
end;
c:=directorySwitches^.getMultiStringItem(i);
c^.freeall;
for j:=0 to e^.getlinecount-1 do
begin
s:=e^.getlinetext(j);
{Strip string.}
while (length(s)>0) and (s[length(s)]=' ') do
dec(s[0]);
while (length(s)>0) and (s[1]=' ') do
system.delete(s,1,1);
if s<>'' then
c^.insert(newstr(s));
end;
end
else
begin
s:=IL[i]^.data^;
{Strip string.}
while (length(s)>0) and (s[length(s)]=' ') do
dec(s[0]);
while (length(s)>0) and (s[1]=' ') do
system.delete(s,1,1);
DirectorySwitches^.SetStringItem(i,s);
end;
end;
dispose(D,done);
end;
procedure TIDEApp.Tools;

View File

@ -38,7 +38,7 @@ type
TSwitchMode = (om_Normal,om_Debug,om_Release);
TSwitchItemTyp = (ot_Select,ot_Boolean,ot_String,ot_Longint);
TSwitchItemTyp = (ot_Select,ot_Boolean,ot_String,ot_MultiString,ot_Longint);
PSwitchItem = ^TSwitchItem;
TSwitchItem = object(TObject)
@ -48,8 +48,9 @@ type
ParamID : TParamID;
constructor Init(const n,p:string; AID: TParamID);
function NeedParam:boolean;virtual;
function ParamValue:string;virtual;
function ParamValue(nr:sw_integer):string;virtual;
function ParamValueBool(SM: TSwitchMode):boolean;virtual;
function ParamCount:sw_integer;virtual;
function GetSwitchStr(SM: TSwitchMode): string; virtual;
function GetNumberStr(SM: TSwitchMode): string; virtual;
function GetOptionStr(SM: TSwitchMode): string; virtual;
@ -81,10 +82,22 @@ type
SeparateSpaces : boolean;
constructor Init(const n,p:string;AID: TParamID; mult,allowspaces:boolean);
function NeedParam:boolean;virtual;
function ParamValue:string;virtual;
function ParamValue(nr:sw_integer):string;virtual;
procedure Reset;virtual;
end;
PMultiStringItem = ^TMultiStringItem;
TMultiStringItem = object(TSwitchItem)
MultiStr : array[TSwitchMode] of PunsortedStringCollection;
constructor Init(const n,p:string;AID: TParamID);
function NeedParam:boolean;virtual;
function ParamValue(nr:sw_integer):string;virtual;
function ParamCount:sw_integer;virtual;
procedure Reset;virtual;
destructor done;virtual;
end;
PLongintItem = ^TLongintItem;
TLongintItem = object(TSwitchItem)
Val : array[TSwitchMode] of longint;
@ -110,13 +123,16 @@ type
procedure AddBooleanItem(const name,param:string; AID: TParamID);
procedure AddLongintItem(const name,param:string; AID: TParamID);
procedure AddStringItem(const name,param:string;AID: TParamID;mult,allowspaces:boolean);
procedure AddMultiStringItem(const name,param:string;AID: TParamID);
function GetCurrSel:integer;
function GetCurrSelParam : String;
function GetBooleanItem(index:integer):boolean;
function GetLongintItem(index:integer):longint;
function GetStringItem(index:integer):string;
function GetMultiStringItem(index:integer):PunsortedStringCollection;
function GetItemTyp(index:integer):TSwitchItemTyp;
procedure SetCurrSel(index:integer);
function SetCurrSelParam(const s : String) : boolean;
function SetCurrSelParam(const s:string) : boolean;
procedure SetBooleanItem(index:integer;b:boolean);
procedure SetLongintItem(index:integer;l:longint);
procedure SetStringItem(index:integer;const s:string);
@ -203,7 +219,7 @@ begin
end;
function TSwitchItem.ParamValue:string;
function TSwitchItem.ParamValue(nr:sw_integer):string;
begin
ParamValue:='';
end;
@ -214,6 +230,12 @@ begin
ParamValueBool:=false;
end;
function TSwitchItem.ParamCount:sw_integer;
begin
ParamCount:=1;
end;
function TSwitchItem.GetSwitchStr(SM: TSwitchMode): string;
begin
Abstract;
@ -309,7 +331,7 @@ begin
end;
function TStringItem.ParamValue:string;
function TStringItem.ParamValue(nr:sw_integer):string;
begin
ParamValue:=Str[SwitchesMode];
end;
@ -320,6 +342,58 @@ begin
FillChar(Str,sizeof(Str),0);
end;
{*****************************************************************************
TMultiStringItem
*****************************************************************************}
constructor TMultiStringItem.Init(const n,p:string;AID:TParamID);
var i:TSwitchMode;
begin
inherited Init(n,p,AID);
typ:=ot_MultiString;
for i:=low(MultiStr) to high(MultiStr) do
new(MultiStr[i],init(5,5));
{ Reset;}
end;
function TMultiStringItem.NeedParam:boolean;
begin
NeedParam:=(multistr[SwitchesMode]^.count<>0);
end;
function TMultiStringItem.ParamValue(nr:sw_integer):string;
begin
ParamValue:=MultiStr[SwitchesMode]^.at(nr)^;
end;
function TMultiStringItem.ParamCount:sw_integer;
begin
ParamCount:=Multistr[SwitchesMode]^.count;
end;
procedure TMultiStringItem.Reset;
var i:TSwitchMode;
begin
for i:=low(multiStr) to high(multiStr) do
MultiStr[i]^.freeall;
end;
destructor TmultiStringItem.done;
var i:TSwitchMode;
begin
for i:=low(MultiStr) to high(MultiStr) do
dispose(MultiStr[i],done);
inherited done;
end;
{*****************************************************************************
TLongintItem
@ -410,11 +484,15 @@ begin
end;
procedure TSwitches.AddStringItem(const name,param:string;AID: TParamID;mult,allowspaces:boolean);
procedure TSwitches.AddStringItem(const name,param:string;AID:TParamID;mult,allowspaces:boolean);
begin
Items^.Insert(New(PStringItem,Init(name,Param,AID,mult,allowspaces)));
end;
procedure TSwitches.AddMultiStringItem(const name,param:string;AID:TParamID);
begin
Items^.Insert(New(PMultiStringItem,Init(name,Param,AID)));
end;
function TSwitches.ItemCount:integer;
begin
@ -496,6 +574,29 @@ begin
GetStringItem:='';
end;
function TSwitches.GetMultiStringItem(index:integer):PUnsortedStringCollection;
var p:PMultiStringItem;
begin
if index<ItemCount then
p:=Items^.at(Index)
else
p:=nil;
if (p<>nil) and (p^.typ=ot_multistring) then
GetMultiStringItem:=p^.MultiStr[SwitchesMode]
else
GetMultiStringItem:=nil;
end;
function TSwitches.GetItemTyp(index:integer):TSwitchItemTyp;
var p:PSwitchItem;
begin
assert(index<itemcount);
GetItemTyp:=PSwitchItem(items^.at(index))^.typ;
end;
procedure TSwitches.SetBooleanItem(index:integer;b:boolean);
var
@ -613,7 +714,8 @@ var
end
else
if P^.Param<>'/' then
Writeln(CfgFile,' -'+Pref+P^.Param+P^.ParamValue);
for i:=0 to p^.ParamCount-1 do
Writeln(CfgFile,' -'+Pref+P^.Param+P^.ParamValue(i));
end;
end;
@ -681,6 +783,8 @@ begin
else
PStringItem(FoundP)^.Str[SwitchesMode]:=Copy(s,length(FoundP^.Param)+1,255);
end;
ot_MultiString :
PMultiStringItem(foundP)^.MultiStr[SwitchesMode]^.insert(newstr(copy(s,length(foundP^.param)+1,255)));
ot_Longint : Val(Copy(s,length(FoundP^.Param)+1,255),PLongintItem(FoundP)^.Val[SwitchesMode],code);
end;
ReadItemsCfg:=true;
@ -988,10 +1092,10 @@ begin
New(DirectorySwitches,Init('F'));
with DirectorySwitches^ do
begin
AddStringItem(opt_unitdirectories,'u',idNone,true,true);
AddStringItem(opt_includedirectories,'i',idNone,true,true);
AddStringItem(opt_librarydirectories,'l',idNone,true,true);
AddStringItem(opt_objectdirectories,'o',idNone,true,true);
AddMultiStringItem(opt_unitdirectories,'u',idNone);
AddMultiStringItem(opt_includedirectories,'i',idNone);
AddMultiStringItem(opt_librarydirectories,'l',idNone);
AddMultiStringItem(opt_objectdirectories,'o',idNone);
AddStringItem(opt_exeppudirectories,'E',idNone,true,true);
AddStringItem(opt_ppuoutputdirectory,'U',idNone,true,true);
AddStringItem(opt_cross_tools_directory,'D',idNone,true,true);