Cleanups.

git-svn-id: trunk@3587 -
This commit is contained in:
lazarus 2002-10-30 19:49:04 +00:00
parent 3ae29b7c22
commit 361a0b4f55

View File

@ -68,25 +68,22 @@ type
SaveOnlyProjectUnitInfoCheckBox: TCheckBox;
// buttons at bottom
OkButton: TButton;
CancelButton: TButton;
OkButton: TBitBtn;
CancelButton: TBitBtn;
procedure OkButtonClick(Sender: TObject);
procedure CancelButtonClick(Sender: TObject);
procedure ProjectOptionsClose(Sender: TObject; var Action: TCloseAction);
procedure ProjectOptionsResize(Sender: TObject);
procedure FormsAddToAutoCreatedFormsBtnClick(Sender: TObject);
procedure FormsRemoveFromAutoCreatedFormsBtnClick(Sender: TObject);
procedure FormsMoveAutoCreatedFormUpBtnClick(Sender: TObject);
procedure FormsMoveAutoCreatedFormDownBtnClick(Sender: TObject);
procedure ProjectOptionsDialogResize(Sender: TObject);
private
FProject: TProject;
procedure SetProject(AProject: TProject);
procedure SetupApplicationPage;
procedure SetupFormsPage;
procedure SetupInfoPage;
procedure ResizeApplicationPage;
procedure ResizeFormsPage;
procedure ResizeInfoPage;
procedure FillAutoCreateFormsListbox;
procedure FillAvailFormsListBox;
function IndexOfAutoCreateForm(FormName: string): integer;
@ -107,16 +104,12 @@ implementation
function ShowProjectOptionsDialog(AProject: TProject): TModalResult;
var ProjectOptionsDialog: TProjectOptionsDialog;
begin
ProjectOptionsDialog:=TProjectOptionsDialog.Create(Application);
try
with ProjectOptionsDialog do begin
Project:=AProject;
Result:=ShowModal;
end;
with TProjectOptionsDialog.Create(Application) do try
Project:= AProject;
Result:= ShowModal;
finally
ProjectOptionsDialog.Free;
Free;
end;
end;
@ -129,58 +122,51 @@ begin
if LazarusResources.Find(ClassName)=nil then begin
Width:=430;
Height:=375;
Position:=poScreenCenter;
OnResize:=@ProjectOptionsDialogResize;
Position:= poScreenCenter;
OnResize:= @ProjectOptionsResize;
OnClose:= @ProjectOptionsClose;
Caption:=dlgProjectOptions;
Constraints.MinWidth:= 400;
Constraints.MinHeight:= 300;
NoteBook:=TNoteBook.Create(Self);
with NoteBook do begin
Name:='NoteBook';
Parent:=Self;
SetBounds(0,0,Self.ClientWidth,Self.ClientHeight-50);
if PageCount>0 then
SetBounds(0, 0, Self.ClientWidth, Self.ClientHeight - 33);
Anchors:= [akTop, akLeft, akRight, akBottom];
if PageCount > 0 then
Pages[0]:=dlgPOApplication
else
Pages.Add(dlgPOApplication);
Pages.Add(dlgPOFroms);
Pages.Add(dlgPOInfo);
Visible:=true;
end;
SetupFormsPage;
SetupApplicationPage;
SetupInfoPage;
CancelButton:=TButton.Create(Self);
CancelButton:=TBitBtn.Create(Self);
with CancelButton do begin
Name:='CancelButton';
Parent:=Self;
Width:=70;
Height:=23;
Left:=Self.ClientWidth-Width-15;
Top:=Self.ClientHeight-Height-15;
Caption:=dlgCancel;
OnClick:=@CancelButtonClick;
Show;
Parent:= Self;
Left:= Self.ClientWidth - Width - 4;
Top:= Self.ClientHeight - Height - 4;
Kind:= bkCancel;
Anchors:= [akBottom, akRight];
end;
OkButton:=TButton.Create(Self);
OkButton:=TBitBtn.Create(Self);
with OkButton do begin
Name:='OkButton';
Parent:=Self;
Width:=CancelButton.Width;
Height:=CancelButton.Height;
Left:=CancelButton.Left-15-Width;
Top:=CancelButton.Top;
Caption:='Ok';
OnClick:=@OkButtonClick;
Show;
Parent:= Self;
Left:= CancelButton.Left - Width - 4;
Top:= CancelButton.Top;
Kind:= bkOk;
Anchors:= [akBottom, akRight];
end;
end;
IDEDialogLayoutList.ApplyLayout(Self,430,375);
IDEDialogLayoutList.ApplyLayout(Self, 430, 375);
ProjectOptionsDialogResize(nil);
end;
procedure TProjectOptionsDialog.SetupApplicationPage;
@ -190,72 +176,64 @@ begin
AppSettingsGroupBox:=TGroupBox.Create(Self);
with AppSettingsGroupBox do begin
Name:='AppSettingsGroupBox';
Parent:=NoteBook.Page[0];
Left:=5;
Top:=5;
Width:=MaxX-2*Left;
Height:=60;
Anchors:= [akTop, akLeft, akRight];
Caption:=dlgApplicationSettings;
Visible:=true;
end;
TitleLabel:=TLabel.Create(Self);
with TitleLabel do begin
Name:='TitleLabel';
Parent:=AppSettingsGroupBox;
Left:=15;
Top:=1;
Width:=100;
Height:=23;
Left:= 5;
Top:= 4;
Width:= 50;
Height:= 23;
Caption:=dlgPOTitle;
Visible:=true;
end;
TitleEdit:=TEdit.Create(Self);
with TitleEdit do begin
Name:='TitleEdit';
Parent:=AppSettingsGroupBox;
Left:=TitleLabel.Left+TitleLabel.Width+2;
Top:=TitleLabel.Top+4;
Top:=TitleLabel.Top - 1;
Width:=AppSettingsGroupBox.ClientWidth-Left-10;
Anchors:= [akTop, akLeft, akRight];
Text:='';
Visible:=true;
end;
OutputSettingsGroupBox:=TGroupBox.Create(Self);
with OutputSettingsGroupBox do begin
Name:='OutputSettingsGroupBox';
Parent:=NoteBook.Page[0];
Left:=AppSettingsGroupBox.Left;
Top:=AppSettingsGroupBox.Top+AppSettingsGroupBox.Height+5;
Width:=AppSettingsGroupBox.Width;
Height:=60;
Caption:=dlgPOOutputSettings ;
Visible:=true;
Anchors:= [akTop, akLeft, akRight];
Caption:=dlgPOOutputSettings;
end;
TargetFileLabel:=TLabel.Create(Self);
with TargetFileLabel do begin
Name:='TargetFileLabel';
Parent:=OutputSettingsGroupBox;
Left:=5;
Top:=1;
Width:=200;
Height:=23;
Caption:=dlgPOTargetFileName ;
Visible:=true;
Left:= 5;
Top:= 4;
Width:= 100;
Height:= 23;
Caption:=dlgPOTargetFileName;
end;
TargetFileEdit:=TEdit.Create(Self);
with TargetFileEdit do begin
Name:='TargetFileEdit';
Parent:=OutputSettingsGroupBox;
Left:=TargetFileLabel.Left+TargetFileLabel.Width+5;
Top:=TargetFileLabel.Top+4;
Top:=TargetFileLabel.Top - 1;
Width:=OutputSettingsGroupBox.Width-Left-10;
Anchors:= [akTop, akLeft, akRight];
Text:='';
Visible:=true;
end;
end;
@ -263,55 +241,46 @@ procedure TProjectOptionsDialog.SetupFormsPage;
begin
FormsAutoCreatedLabel:=TLabel.Create(Self);
with FormsAutoCreatedLabel do begin
Name:='FormsAutoCreatedLabel';
Parent:=NoteBook.Page[1];
Left:=40;
Top:=1;
Top:=4;
Width:=150;
Height:=23;
Caption:=dlgAutoCreateForms;
Visible:=true;
end;
FormsAutoCreatedListBox:=TListBox.Create(Self);
with FormsAutoCreatedListBox do begin
Name:='FormsAutoCreatedListBox';
Parent:=NoteBook.Page[1];
Left:=40;
Top:=28;
Width:=165;
Height:=228;
MultiSelect:=true;
Visible:=true;
end;
FormsAvailFormsLabel:=TLabel.Create(Self);
with FormsAvailFormsLabel do begin
Name:='FormsAvailFormsLabel';
Parent:=NoteBook.Page[1];
Left:=FormsAutoCreatedListBox.Left+FormsAutoCreatedListBox.Width+45;
Top:=FormsAutoCreatedLabel.Top;
Width:=FormsAutoCreatedLabel.Width;
Height:=FormsAutoCreatedLabel.Height;
Caption:=dlgAvailableForms ;
Visible:=true;
Caption:=dlgAvailableForms;
end;
FormsAvailFormsListBox:=TListBox.Create(Self);
with FormsAvailFormsListBox do begin
Name:='FormsAvailFormsListBox';
Parent:=NoteBook.Page[1];
Left:=FormsAvailFormsLabel.Left;
Top:=FormsAutoCreatedListBox.Top;
Width:=FormsAutoCreatedListBox.Width;
Height:=FormsAutoCreatedListBox.Height;
MultiSelect:=true;
Visible:=true;
end;
FormsAddToAutoCreatedFormsBtn:=TSpeedButton.Create(Self);
with FormsAddToAutoCreatedFormsBtn do begin
Name:='FormsAddToAutoCreatedFormsBtn';
Parent:=NoteBook.Page[1];
Left:=FormsAutoCreatedListBox.Left+FormsAutoCreatedListBox.Width+10;
Top:=FormsAutoCreatedListBox.Top+80;
@ -320,12 +289,10 @@ begin
Glyph:=TPixmap.Create;
Glyph.LoadFromLazarusResource('leftarrow');
OnClick:=@FormsAddToAutoCreatedFormsBtnClick;
Visible:=true;
end;
FormsRemoveFromAutoCreatedFormsBtn:=TSpeedButton.Create(Self);
with FormsRemoveFromAutoCreatedFormsBtn do begin
Name:='FormsRemoveFromAutoCreatedFormsBtn';
Parent:=NoteBook.Page[1];
Left:=FormsAddToAutoCreatedFormsBtn.Left;
Top:=FormsAddToAutoCreatedFormsBtn.Top
@ -335,12 +302,10 @@ begin
Glyph:=TPixmap.Create;
Glyph.LoadFromLazarusResource('rightarrow');
OnClick:=@FormsRemoveFromAutoCreatedFormsBtnClick;
Visible:=true;
end;
FormsMoveAutoCreatedFormUpBtn:=TSpeedButton.Create(Self);
with FormsMoveAutoCreatedFormUpBtn do begin
Name:='FormsMoveAutoCreatedFormUpBtn';
Parent:=NoteBook.Page[1];
Left:=FormsAutoCreatedListBox.Left-35;
Top:=FormsAutoCreatedListBox.Top+80;
@ -349,12 +314,10 @@ begin
Glyph:=TPixmap.Create;
Glyph.LoadFromLazarusResource('uparrow');
OnClick:=@FormsMoveAutoCreatedFormUpBtnClick;
Visible:=true;
end;
FormsMoveAutoCreatedFormDownBtn:=TSpeedButton.Create(Self);
with FormsMoveAutoCreatedFormDownBtn do begin
Name:='FormsMoveAutoCreatedFormDownBtn';
Parent:=NoteBook.Page[1];
Left:=FormsMoveAutoCreatedFormUpBtn.Left;
Top:=FormsMoveAutoCreatedFormUpBtn.Top
@ -364,91 +327,38 @@ begin
Glyph:=TPixmap.Create;
Glyph.LoadFromLazarusResource('downarrow');
OnClick:=@FormsMoveAutoCreatedFormDownBtnClick;
Visible:=true;
end;
FormsAutoCreateNewFormsCheckBox:=TCheckBox.Create(Self);
with FormsAutoCreateNewFormsCheckBox do begin
Name:='FormsAutoCreateNewFormsCheckBox';
Parent:=NoteBook.Page[1];
Left:=FormsAutoCreatedListBox.Left+5;
Top:=FormsAutoCreatedListBox.Top+FormsAutoCreatedListBox.Height+5;
Width:=200;
Height:=25;
Caption:=dlgAutoCreateNewForms ;
Enabled:=false;
Visible:=true;
Enabled:= false;
end;
end;
procedure TProjectOptionsDialog.SetupInfoPage;
begin
SaveClosedUnitInfoCheckBox:=TCheckBox.Create(Self);
SaveClosedUnitInfoCheckBox:= TCheckBox.Create(Self);
with SaveClosedUnitInfoCheckBox do begin
Name:='SaveClosedUnitInfoCheckBox';
Parent:=NoteBook.Page[2];
Left:=10;
Top:=10;
Width:=350;
Caption:=dlgSaveEditorInfo ;
Visible:=true;
Parent:= NoteBook.Page[2];
Left:= 10;
Top:= 10;
Width:= 350;
Caption:= dlgSaveEditorInfo;
end;
SaveOnlyProjectUnitInfoCheckBox:=TCheckBox.Create(Self);
SaveOnlyProjectUnitInfoCheckBox:= TCheckBox.Create(Self);
with SaveOnlyProjectUnitInfoCheckBox do begin
Name:='SaveOnlyProjectUnitInfoCheckBox';
Parent:=NoteBook.Page[2];
Left:=SaveClosedUnitInfoCheckBox.Left;
Top:=SaveClosedUnitInfoCheckBox.Top+SaveClosedUnitInfoCheckBox.Height+10;
Width:=SaveClosedUnitInfoCheckBox.Width;
Caption:=dlgSaveEditorInfoProject;
Visible:=true;
end;
end;
procedure TProjectOptionsDialog.ResizeApplicationPage;
var MaxX:integer;
begin
MaxX:=ClientWidth-5;
with AppSettingsGroupBox do begin
Left:=5;
Top:=5;
Width:=MaxX-2*Left;
Height:=60;
end;
with TitleLabel do begin
Left:=5;
Top:=1;
Width:=100;
Height:=23;
end;
with TitleEdit do begin
Left:=TitleLabel.Left+TitleLabel.Width+2;
Top:=TitleLabel.Top+4;
Width:=AppSettingsGroupBox.ClientWidth-Left-10;
end;
with OutputSettingsGroupBox do begin
Left:=AppSettingsGroupBox.Left;
Top:=AppSettingsGroupBox.Top+AppSettingsGroupBox.Height+5;
Width:=AppSettingsGroupBox.Width;
Height:=60;
end;
with TargetFileLabel do begin
Left:=5;
Top:=1;
Width:=160;
Height:=23;
end;
with TargetFileEdit do begin
Left:=TargetFileLabel.Left+TargetFileLabel.Width+5;
Top:=TargetFileLabel.Top+4;
Width:=OutputSettingsGroupBox.Width-Left-10;
Parent:= NoteBook.Page[2];
Left:= SaveClosedUnitInfoCheckBox.Left;
Top:= SaveClosedUnitInfoCheckBox.Top+SaveClosedUnitInfoCheckBox.Height+10;
Width:= SaveClosedUnitInfoCheckBox.Width;
Caption:= dlgSaveEditorInfoProject;
end;
end;
@ -460,12 +370,6 @@ begin
ListBoxWidth:=(MaxX-95) div 2;
ListBoxHeight:=MaxY-70;
with FormsAutoCreatedLabel do begin
Left:=40;
Top:=1;
Width:=190;
end;
with FormsAutoCreatedListBox do begin
Left:=FormsAutoCreatedLabel.Left;
Top:=FormsAutoCreatedLabel.Top+FormsAutoCreatedLabel.Height+3;
@ -525,21 +429,6 @@ begin
end;
end;
procedure TProjectOptionsDialog.ResizeInfoPage;
begin
with SaveClosedUnitInfoCheckBox do begin
Left:=10;
Top:=10;
Width:=350;
end;
with SaveOnlyProjectUnitInfoCheckBox do begin
Left:=SaveClosedUnitInfoCheckBox.Left;
Top:=SaveClosedUnitInfoCheckBox.Top+SaveClosedUnitInfoCheckBox.Height+10;
Width:=SaveClosedUnitInfoCheckBox.Width;
end;
end;
procedure TProjectOptionsDialog.SetProject(AProject: TProject);
begin
FProject:=AProject;
@ -557,35 +446,32 @@ begin
(pfSaveOnlyProjectUnits in AProject.Flags);
end;
procedure TProjectOptionsDialog.OkButtonClick(Sender: TObject);
procedure TProjectOptionsDialog.ProjectOptionsClose(Sender: TObject; var Action: TCloseAction);
var NewFlags: TProjectFlags;
begin
with Project do begin
Title:=TitleEdit.Text;
TargetFilename:=TargetFileEdit.Text;
end;
// flags
NewFlags:=Project.Flags;
if SaveClosedUnitInfoCheckBox.Checked then
Include(NewFlags,pfSaveClosedUnits)
else
Exclude(NewFlags,pfSaveClosedUnits);
if SaveOnlyProjectUnitInfoCheckBox.Checked then
Include(NewFlags,pfSaveOnlyProjectUnits)
else
Exclude(NewFlags,pfSaveOnlyProjectUnits);
Project.Flags:=NewFlags;
SetAutoCreateForms;
IDEDialogLayoutList.SaveLayout(Self);
ModalResult:=mrOk;
end;
if ModalResult = mrOk then begin
procedure TProjectOptionsDialog.CancelButtonClick(Sender: TObject);
begin
with Project do begin
Title:=TitleEdit.Text;
TargetFilename:=TargetFileEdit.Text;
end;
// flags
NewFlags:=Project.Flags;
if SaveClosedUnitInfoCheckBox.Checked then
Include(NewFlags,pfSaveClosedUnits)
else
Exclude(NewFlags,pfSaveClosedUnits);
if SaveOnlyProjectUnitInfoCheckBox.Checked then
Include(NewFlags,pfSaveOnlyProjectUnits)
else
Exclude(NewFlags,pfSaveOnlyProjectUnits);
Project.Flags:=NewFlags;
SetAutoCreateForms;
end;
IDEDialogLayoutList.SaveLayout(Self);
ModalResult:=mrCancel;
end;
function TProjectOptionsDialog.GetAutoCreatedFormsList: TStrings;
@ -615,37 +501,38 @@ end;
procedure TProjectOptionsDialog.FillAutoCreateFormsListbox;
var sl: TStrings;
begin
sl:=GetAutoCreatedFormsList;
sl:= GetAutoCreatedFormsList;
FormsAutoCreatedListBox.Items.BeginUpdate;
FormsAutoCreatedListBox.Items.Clear;
if sl<>nil then
if sl <> nil then begin
FormsAutoCreatedListBox.Items.Assign(sl);
sl.Free;
end;
FormsAutoCreatedListBox.Items.EndUpdate;
if sl<>nil then sl.Free;
end;
procedure TProjectOptionsDialog.FillAvailFormsListBox;
var sl: TStringList;
i: integer;
begin
if (FProject<>nil) then begin
sl:=TStringList.Create;
for i:=0 to FProject.UnitCount-1 do begin
if (FProject.Units[i].IsPartOfProject)
and (FProject.Units[i].FormName<>'') then begin
if IndexOfAutoCreateForm(FProject.Units[i].FormName)<0 then begin
sl.Add(FProject.Units[i].FormName);
end;
end;
end;
sl.Sort;
end else begin
sl:=nil;
end;
FormsAvailFormsListBox.Items.BeginUpdate;
FormsAvailFormsListBox.Items.Clear;
if sl<>nil then
FormsAvailFormsListBox.Items.Assign(sl);
if (FProject<>nil) then begin
sl:= TStringList.Create;
try
for i:= 0 to FProject.UnitCount - 1 do begin
if (FProject.Units[i].IsPartOfProject)
and (FProject.Units[i].FormName <> '')
and (IndexOfAutoCreateForm(FProject.Units[i].FormName) < 0) then
sl.Add(FProject.Units[i].FormName);
end;
sl.Sort;
FormsAvailFormsListBox.Items.Assign(sl);
finally
sl.Free;
end;
end;
FormsAvailFormsListBox.Items.EndUpdate;
end;
@ -768,29 +655,9 @@ begin
SelectOnlyThisAutoCreateForm(i+1);
end;
procedure TProjectOptionsDialog.ProjectOptionsDialogResize(Sender: TObject);
procedure TProjectOptionsDialog.ProjectOptionsResize(Sender: TObject);
begin
with NoteBook do begin
SetBounds(0,0,Self.ClientWidth,Self.ClientHeight-50);
end;
ResizeFormsPage;
ResizeApplicationPage;
ResizeInfoPage;
with CancelButton do begin
Width:=70;
Height:=23;
Left:=Self.ClientWidth-Width-15;
Top:=Self.ClientHeight-Height-15;
end;
with OkButton do begin
Width:=CancelButton.Width;
Height:=CancelButton.Height;
Left:=CancelButton.Left-15-Width;
Top:=CancelButton.Top;
end;
end;
procedure TProjectOptionsDialog.SelectOnlyThisAutoCreateForm(
@ -799,7 +666,7 @@ var i: integer;
begin
with FormsAutoCreatedListBox do begin
for i:=0 to Items.Count-1 do
Selected[i]:=(i=Index);
Selected[i]:= (i = Index);
end;
end;