Converter: Add popup menu and Insert / Delete options for replacement string grid.

git-svn-id: trunk@25967 -
This commit is contained in:
juha 2010-06-08 12:53:53 +00:00
parent 666532d672
commit 67e574cfdb
2 changed files with 31 additions and 1 deletions

View File

@ -28,6 +28,7 @@ object ReplaceNamesForm: TReplaceNamesForm
end>
FixedCols = 0
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll]
PopupMenu = PopupMenu1
RowCount = 2
TabOrder = 0
OnEditingDone = NamePairGridEditingDone
@ -100,4 +101,16 @@ object ReplaceNamesForm: TReplaceNamesForm
TabOrder = 2
end
end
object PopupMenu1: TPopupMenu
left = 131
top = 91
object InsertRow1: TMenuItem
Caption = 'Insert Row'
OnClick = InsertRow1Click
end
object DeleteRow1: TMenuItem
Caption = 'Delete Row'
OnClick = DeleteRow1Click
end
end
end

View File

@ -6,7 +6,8 @@ interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
Grids, Buttons, ExtCtrls, CodeToolsStructs, SynRegExpr, LazarusIDEStrConsts;
Grids, Buttons, ExtCtrls, Menus, CodeToolsStructs, SynRegExpr,
LazarusIDEStrConsts;
type
@ -44,8 +45,13 @@ type
btnOK: TBitBtn;
BtnPanel: TPanel;
HelpButton: TBitBtn;
InsertRow1: TMenuItem;
DeleteRow1: TMenuItem;
NamePairGrid: TStringGrid;
PopupMenu1: TPopupMenu;
procedure FormCreate(Sender: TObject);
procedure InsertRow1Click(Sender: TObject);
procedure DeleteRow1Click(Sender: TObject);
procedure NamePairGridEditingDone(Sender: TObject);
procedure NamePairGridSetEditText(Sender: TObject; ACol, ARow: Integer;
const Value: string);
@ -161,6 +167,7 @@ var
OldIdent, NewIdent: string;
i: Integer;
begin
fStringMap.Clear;
// Collect (maybe edited) properties from StringGrid to NameReplacements.
for i:=1 to fGrid.RowCount-1 do begin // Skip the fixed row.
OldIdent:=fGrid.Cells[0,i];
@ -196,6 +203,16 @@ begin
IsLasRow:=false;
end;
procedure TReplaceNamesForm.InsertRow1Click(Sender: TObject);
begin
NamePairGrid.InsertColRow(False, NamePairGrid.Row);
end;
procedure TReplaceNamesForm.DeleteRow1Click(Sender: TObject);
begin
NamePairGrid.DeleteColRow(False, NamePairGrid.Row);
end;
// Add rows automatically to the end of the grid
// using OnSetEditText and OnEditingDone handlers and IsLasRow flag.
procedure TReplaceNamesForm.NamePairGridEditingDone(Sender: TObject);