1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
unit FileFilterPropEditor;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils,
// LCL
Forms, Controls, ButtonPanel, Grids, Buttons,
// IdeIntf
ObjInspStrConsts, IDEImagesIntf, IDEWindowIntf;
type
{ TFileFilterPropEditForm }
TFileFilterPropEditForm = class(TForm)
ButtonPanel1: TButtonPanel;
MoveDownBtn: TSpeedButton;
MoveUpBtn: TSpeedButton;
StringGrid1: TStringGrid;
procedure FormClose(Sender: TObject; var {%H-}CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure MoveUpBtnClick(Sender: TObject);
procedure MoveDownBtnClick(Sender: TObject);
procedure StringGrid1ButtonClick(Sender: TObject; {%H-}aCol, {%H-}aRow: Integer);
procedure StringGrid1Click(Sender: TObject);
procedure StringGrid1EditingDone(Sender: TObject);
private
function GetFilter: string;
procedure SetFilter(const AValue: string);
procedure UpdateEnabledStates;
public
property Filter:string read GetFilter write SetFilter;
end;
var
FileFilterPropEditForm: TFileFilterPropEditForm;
implementation
{$R *.lfm}
{ TFileFilterPropertyEditorForm }
procedure TFileFilterPropEditForm.FormCreate(Sender: TObject);
begin
Caption:=peFilterEditor;
StringGrid1.Cells[0, 0] := peFilterName;
StringGrid1.Cells[1, 0] := peFilter;
IDEImages.AssignImage(MoveUpBtn, 'arrow_up');
IDEImages.AssignImage(MoveDownBtn, 'arrow_down');
MoveUpBtn.Hint := rscdMoveUp;
MoveDownBtn.Hint := rscdMoveDown;
IDEDialogLayoutList.ApplyLayout(Self);
end;
procedure TFileFilterPropEditForm.FormClose(Sender: TObject;
var CloseAction: TCloseAction);
begin
IDEDialogLayoutList.SaveLayout(Self);
end;
procedure TFileFilterPropEditForm.MoveUpBtnClick(Sender: TObject);
begin
with StringGrid1 do
MoveColRow(False, Row, Row-1);
UpdateEnabledStates;
end;
procedure TFileFilterPropEditForm.MoveDownBtnClick(Sender: TObject);
begin
with StringGrid1 do
MoveColRow(False, Row, Row+1);
UpdateEnabledStates;
end;
procedure TFileFilterPropEditForm.StringGrid1ButtonClick(Sender: TObject; aCol,
aRow: Integer);
begin
UpdateEnabledStates;
end;
procedure TFileFilterPropEditForm.StringGrid1Click(Sender: TObject);
begin
UpdateEnabledStates;
end;
procedure TFileFilterPropEditForm.StringGrid1EditingDone(Sender: TObject);
begin
UpdateEnabledStates;
end;
function TFileFilterPropEditForm.GetFilter: string;
var
i: integer;
begin
Result := '';
for i := 1 to StringGrid1.RowCount-1 do
begin
if StringGrid1.Cells[1,i] <> '' then
begin
if Result <> '' then
Result := Result + '|';
if StringGrid1.Cells[0,i] <> '' then
Result := Result+StringGrid1.Cells[0,i]+'|'+StringGrid1.Cells[1,i]
else
Result := Result+StringGrid1.Cells[1,i]+'|'+StringGrid1.Cells[1,i];
end
else
break;
end;
end;
procedure TFileFilterPropEditForm.SetFilter(const AValue: string);
var
S: string;
C1, i: integer;
begin
S := AValue;
I := 1;
while (S <> '') do
begin
C1 := Pos('|',S);
if C1 > 0 then
begin
StringGrid1.Cells[0,i] := Copy(S, 1, C1-1);
Delete(S, 1, C1);
C1 := Pos('|',S);
if (C1 > 0) then
begin
StringGrid1.Cells[1,i] := Copy(S, 1, C1-1);
Delete(S, 1, C1);
end
else
begin
StringGrid1.Cells[1,i] := S;
S := '';
end;
end
else
begin
StringGrid1.Cells[0,i] := S;
StringGrid1.Cells[1,i] := S;
S := '';
end;
inc(i);
end;
UpdateEnabledStates;
end;
procedure TFileFilterPropEditForm.UpdateEnabledStates;
begin
MoveUpBtn.Enabled := StringGrid1.Row > StringGrid1.FixedRows;
MoveDownBtn.Enabled := True;
end;
end.
|