{ ***************************************************************************** See the file COPYING.modifiedLGPL.txt, included in this distribution, for details about the license. ***************************************************************************** } unit CheckListboxEditorDlg; {$mode objfpc}{$H+} interface uses Classes, SysUtils, Forms, Controls, Graphics, Dialogs, CheckLst, ExtCtrls, Buttons, ComCtrls, ButtonPanel, IDEImagesIntf, ObjInspStrConsts, LCLType, ActnList; type { TCheckListBoxEditorDlg } TCheckListBoxEditorDlg = class(TForm) actAdd: TAction; actDel: TAction; actEdit: TAction; actMoveUp: TAction; actMoveDown: TAction; ActionList1: TActionList; BtnPanel: TButtonPanel; FCheck: TCheckListBox; aCheck: TCheckListBox; ToolBar: TToolBar; tbAdd: TToolButton; tbDelete: TToolButton; ToolButton3: TToolButton; tbUp: TToolButton; tbDown: TToolButton; ToolButton6: TToolButton; tbEdit: TToolButton; procedure actAddExecute(Sender: TObject); procedure actDelExecute(Sender: TObject); procedure actEditExecute(Sender: TObject); procedure actMoveDownExecute(Sender: TObject); procedure actMoveUpExecute(Sender: TObject); procedure FCheckClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure ApplyCheck(Sender: TObject); private { private declarations } FModified: Boolean; procedure Change; public { public declarations } property Modified: Boolean read FModified write FModified; end; procedure AssignCheckList(dstCheck, srcCheck: TCheckListBox); implementation {$R *.lfm} procedure AssignCheckList(dstCheck, srcCheck: TCheckListBox); var i: integer; begin dstCheck.Items.Clear; dstCheck.AllowGrayed := srcCheck.AllowGrayed; dstCheck.Items := srcCheck.Items; dstCheck.ItemHeight := srcCheck.ItemHeight; for i := 0 to srcCheck.Items.Count - 1 do begin if srcCheck.Items[i] <> dstCheck.Items[i] then dstCheck.Items[i] := srcCheck.Items[i]; dstCheck.State[i] := srcCheck.State[i] end; end; { TCheckListBoxEditorDlg } procedure TCheckListBoxEditorDlg.actAddExecute(Sender: TObject); var strItem: string; begin strItem:=''; if InputQuery(clbCheckListBoxEditor, clbAdd, strItem) then begin FCheck.Items.Add(strItem); Change; end; end; procedure TCheckListBoxEditorDlg.actDelExecute(Sender: TObject); var OldIndex : integer; begin if FCheck.ItemIndex = -1 then exit; if MessageDlg(clbCheckListBoxEditor, Format(clbDeleteQuest, [FCheck.ItemIndex, FCheck.Items[FCheck.ItemIndex]]), mtConfirmation, mbYesNo, 0) = mrYes then begin // save old index OldIndex := FCheck.ItemIndex; FCheck.Items.Delete(FCheck.ItemIndex); if (FCheck.Count-1 -1; actEdit.Enabled := FCheck.ItemIndex <> -1; actMoveUp.Enabled := (FCheck.ItemIndex <> -1) and (FCheck.ItemIndex > 0); actMoveDown.Enabled := (FCheck.ItemIndex <> -1) and (FCheck.ItemIndex < FCheck.Count - 1); end; end.