mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-21 13:00:01 +02:00
IDE: make the TGenericCheckListForm more generic.
git-svn-id: trunk@42237 -
This commit is contained in:
parent
a17184add8
commit
74327375f3
@ -1145,24 +1145,13 @@ procedure TConfigureBuildLazarusDlg.CompileAdvancedButtonClick(Sender: TObject);
|
|||||||
// mrCancel=do nothing
|
// mrCancel=do nothing
|
||||||
var
|
var
|
||||||
EditForm: TGenericCheckListForm;
|
EditForm: TGenericCheckListForm;
|
||||||
btnBuild: TBitBtn;
|
|
||||||
i, ind: Integer;
|
i, ind: Integer;
|
||||||
begin
|
begin
|
||||||
PrepareClose;
|
PrepareClose;
|
||||||
EditForm:=TGenericCheckListForm.Create(Nil);
|
// Add a button for building all.
|
||||||
|
EditForm:=TGenericCheckListForm.CreateWithActionButton(lisBuild, 'menu_build');
|
||||||
try
|
try
|
||||||
EditForm.Caption:=lisLazBuildSelectProfilesToBuild;
|
EditForm.Caption:=lisLazBuildSelectProfilesToBuild;
|
||||||
// Button for save and compile
|
|
||||||
btnBuild:=TBitBtn.Create(EditForm.ButtonPanel1);
|
|
||||||
btnBuild.Caption:=lisBuild;
|
|
||||||
btnBuild.Kind:=bkCustom;
|
|
||||||
btnBuild.ModalResult:=mrYes;
|
|
||||||
btnBuild.Align:=alRight;
|
|
||||||
btnBuild.BorderSpacing.Left:=6;
|
|
||||||
btnBuild.BorderSpacing.Right:=6;
|
|
||||||
btnBuild.Parent:=EditForm.ButtonPanel1;
|
|
||||||
btnBuild.LoadGlyphFromLazarusResource('menu_build');
|
|
||||||
btnBuild.AutoSize:=True;
|
|
||||||
// Copy profile names to checkboxlist and check the previously selected ones.
|
// Copy profile names to checkboxlist and check the previously selected ones.
|
||||||
for i:=0 to fProfiles.Count-1 do begin
|
for i:=0 to fProfiles.Count-1 do begin
|
||||||
ind:=EditForm.CheckListBox1.Items.Add(fProfiles[i].Name);
|
ind:=EditForm.CheckListBox1.Items.Add(fProfiles[i].Name);
|
||||||
|
@ -7,7 +7,7 @@ object GenericCheckListForm: TGenericCheckListForm
|
|||||||
Caption = 'GenericCheckListForm'
|
Caption = 'GenericCheckListForm'
|
||||||
ClientHeight = 301
|
ClientHeight = 301
|
||||||
ClientWidth = 343
|
ClientWidth = 343
|
||||||
OnCreate = FormCreate
|
OnShow = FormShow
|
||||||
Position = poScreenCenter
|
Position = poScreenCenter
|
||||||
LCLVersion = '1.1'
|
LCLVersion = '1.1'
|
||||||
object ButtonPanel1: TButtonPanel
|
object ButtonPanel1: TButtonPanel
|
||||||
@ -36,6 +36,7 @@ object GenericCheckListForm: TGenericCheckListForm
|
|||||||
Width = 343
|
Width = 343
|
||||||
Align = alClient
|
Align = alClient
|
||||||
ItemHeight = 0
|
ItemHeight = 0
|
||||||
|
OnItemClick = CheckListBox1ItemClick
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -15,11 +15,14 @@ type
|
|||||||
TGenericCheckListForm = class(TForm)
|
TGenericCheckListForm = class(TForm)
|
||||||
ButtonPanel1: TButtonPanel;
|
ButtonPanel1: TButtonPanel;
|
||||||
CheckListBox1: TCheckListBox;
|
CheckListBox1: TCheckListBox;
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure CheckListBox1ItemClick(Sender: TObject; Index: integer);
|
||||||
|
procedure FormShow(Sender: TObject);
|
||||||
private
|
private
|
||||||
|
fActionBtn: TBitBtn;
|
||||||
|
procedure UpdateButtons;
|
||||||
public
|
public
|
||||||
|
constructor CreateWithActionButton(aCaption: TCaption; aResourceGlyphName: string = '');
|
||||||
|
destructor Destroy; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -31,10 +34,51 @@ implementation
|
|||||||
|
|
||||||
{ TGenericCheckListForm }
|
{ TGenericCheckListForm }
|
||||||
|
|
||||||
procedure TGenericCheckListForm.FormCreate(Sender: TObject);
|
constructor TGenericCheckListForm.CreateWithActionButton(aCaption: TCaption;
|
||||||
|
aResourceGlyphName: string);
|
||||||
begin
|
begin
|
||||||
//ButtonPanel1.OKButton.Caption:=lisMenuOk;
|
inherited Create(Nil);
|
||||||
//ButtonPanel1.CancelButton.Caption:=lisCancel;
|
fActionBtn := TBitBtn.Create(ButtonPanel1);
|
||||||
|
fActionBtn.Caption:=aCaption;
|
||||||
|
fActionBtn.ModalResult:=mrYes; // ActionButton will return mrYes.
|
||||||
|
fActionBtn.Align:=alRight;
|
||||||
|
fActionBtn.BorderSpacing.Left:=6;
|
||||||
|
fActionBtn.BorderSpacing.Right:=6;
|
||||||
|
if aResourceGlyphName <> '' then
|
||||||
|
fActionBtn.LoadGlyphFromLazarusResource(aResourceGlyphName);
|
||||||
|
fActionBtn.AutoSize:=True;
|
||||||
|
fActionBtn.Parent:=ButtonPanel1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TGenericCheckListForm.Destroy;
|
||||||
|
begin
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TGenericCheckListForm.FormShow(Sender: TObject);
|
||||||
|
begin
|
||||||
|
UpdateButtons;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TGenericCheckListForm.CheckListBox1ItemClick(Sender: TObject; Index: integer);
|
||||||
|
begin
|
||||||
|
UpdateButtons;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TGenericCheckListForm.UpdateButtons;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
if Assigned(fActionBtn) then
|
||||||
|
begin
|
||||||
|
for i := 0 to CheckListBox1.Count-1 do
|
||||||
|
if CheckListBox1.Checked[i] then
|
||||||
|
begin
|
||||||
|
fActionBtn.Enabled := True;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
fActionBtn.Enabled := False;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user